Skip to content

Commit

Permalink
Added syntax highlighting for ruby code fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
markijbema committed Dec 2, 2013
1 parent 5aefe97 commit b70c33b
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ vulnerabilities.
With this caveat, if you wish to bundle `fog` into your application on Ruby
1.8.7, you must add the following line to your `Gemfile`.

gem 'nokogiri', '~>1.5.0'
```ruby
gem 'nokogiri', '~>1.5.0'
```

Also, ensure that you are using LibXML version 2.8.0, since there is an
[issue with LibXML version 2.9.0][issue829] ([and 2.9.1][issue904]).
Expand Down Expand Up @@ -74,21 +76,23 @@ Collections share basic CRUD type operations, such as:

As an example, we'll try initializing and persisting a Rackspace Cloud server:

require 'fog'
```ruby
require 'fog'

compute = Fog::Compute.new(
:provider => 'Rackspace',
:rackspace_api_key => key,
:rackspace_username => username
)
compute = Fog::Compute.new(
:provider => 'Rackspace',
:rackspace_api_key => key,
:rackspace_username => username
)

# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
server = compute.servers.create(:flavor_id => 1, :image_id => 3, :name => 'my_server')
server.wait_for { ready? } # give server time to boot
# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
server = compute.servers.create(:flavor_id => 1, :image_id => 3, :name => 'my_server')
server.wait_for { ready? } # give server time to boot

# DO STUFF
# DO STUFF

server.destroy # cleanup after yourself or regret it, trust me
server.destroy # cleanup after yourself or regret it, trust me
```

## Models

Expand All @@ -104,7 +108,9 @@ As you might imagine, testing code using Fog can be slow and expensive, constant
Mocking allows skipping this overhead by providing an in memory representation resources as you make requests.
Enabling mocking easy to use, before you run other commands, simply run:

Fog.mock!
```ruby
Fog.mock!
```

Then proceed as usual, if you run into unimplemented mocks, fog will raise an error and as always contributions are welcome!

Expand All @@ -126,13 +132,15 @@ It will return an [excon](http://github.com/geemus/excon) response, which has `b
Play around and use the console to explore or check out [fog.io](http://fog.io) and the [provider documentation](http://fog.io/about/provider_documentation.html)
for more details and examples. Once you are ready to start scripting fog, here is a quick hint on how to make connections without the command line thing to help you.

# create a compute connection
compute = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# compute operations go here
```ruby
# create a compute connection
compute = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# compute operations go here

# create a storage connection
storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# storage operations go here
# create a storage connection
storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# storage operations go here
```

geemus says: "That should give you everything you need to get started, but let me know if there is anything I can do to help!"

Expand Down

0 comments on commit b70c33b

Please sign in to comment.