1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Merge pull request #538 from gustavosobral/improve-doc-and-dev-setup

Improve documentation and development setup
This commit is contained in:
Wesley Beary 2019-11-12 08:16:05 -06:00 committed by GitHub
commit 9310aaaefa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 7 deletions

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014-2017 [CONTRIBUTORS.md](https://github.com/fog/fog-aws/blob/master/CONTRIBUTORS.md)
Copyright (c) 2014-2019 [CONTRIBUTORS.md](https://github.com/fog/fog-aws/blob/master/CONTRIBUTORS.md)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View file

@ -2,11 +2,9 @@
![Gem Version](https://badge.fury.io/rb/fog-aws.svg)
[![Build Status](https://travis-ci.org/fog/fog-aws.svg?branch=master)](https://travis-ci.org/fog/fog-aws)
[![Dependency Status](https://gemnasium.com/fog/fog-aws.svg)](https://gemnasium.com/fog/fog-aws)
[![Test Coverage](https://codeclimate.com/github/fog/fog-aws/badges/coverage.svg)](https://codeclimate.com/github/fog/fog-aws)
[![Code Climate](https://codeclimate.com/github/fog/fog-aws.svg)](https://codeclimate.com/github/fog/fog-aws)
## Installation
Add this line to your application's Gemfile:
@ -39,7 +37,10 @@ default:
aws_secret_access_key: <YOUR_SECRET_ACCESS_KEY>
```
### Connecting to EC2 service
### EC2
#### Connecting to the EC2 Service:
```ruby
ec2 = Fog::Compute.new :provider => 'AWS', :region => 'us-west-2'
```
@ -50,7 +51,7 @@ You can review all the requests available with this service using ```#requests``
ec2.requests # => [:allocate_address, :assign_private_ip_addresses, :associate_address, ...]
```
### Launch an EC2 on-demand instance:
#### Launch an EC2 on-demand instance:
```ruby
response = ec2.run_instances(
@ -67,19 +68,51 @@ instance.wait_for { ready? }
puts instance.public_ip_address # => "356.300.501.20"
```
### Terminate an EC2 instance:
#### Terminate an EC2 instance:
```ruby
instance = ec2.servers.get("i-02db5af4")
instance.destroy
```
Fog::AWS is more than EC2 since it supports many services provided by AWS. The best way to learn and to know about how many services are supported is to take a look at the source code. To review the tests directory and to play with the library in ```irb``` can be very helpful resources as well.
`Fog::AWS` is more than EC2 since it supports many services provided by AWS. The best way to learn and to know about how many services are supported is to take a look at the source code. To review the tests directory and to play with the library in ```bin/console``` can be very helpful resources as well.
### S3
#### Connecting to the S3 Service:
```ruby
s3 = Fog::Storage.new(provider: 'AWS', region: 'eu-central-1')
```
#### Creating a file:
```ruby
directory = s3.directories.new(key: 'gaudi-portal-dev')
file = directory.files.create(key: 'user/1/Gemfile', body: File.open('Gemfile'), tags: 'Org-Id=1&Service-Name=My-Service')
```
#### Listing files:
```ruby
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
directory.files
```
#### Generating a URL for a file:
```ruby
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
```
## Documentation
See the [online documentation](http://www.rubydoc.info/github/fog/fog-aws) for a complete API reference.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
## Contributing
1. Fork it ( https://github.com/fog/fog-aws/fork )

14
bin/console Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "fog-aws"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)

8
bin/setup Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here