cloudster 2.13.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -49,6 +49,10 @@ Create AWS resources :
49
49
  :multi_az => true
50
50
  )
51
51
 
52
+ storage = Cloudster::S3.new(
53
+ :name => 'MyBucket'
54
+ )
55
+
52
56
  Make a cloud :
53
57
 
54
58
  cloud = Cloudster::Cloud.new(:access_key_id => 'accesskeyid', :secret_access_key => 'topsecretaccesskey', :region => 'us-west-1')
@@ -132,10 +136,9 @@ helpful.
132
136
 
133
137
  ## Need help?
134
138
 
135
- You can use the [Issues](https://github.com/emilsoman/cloudster/issues) page to ask a new question. This is how you do it:
136
- 1. Click on New Issue
137
- 2. Type in your question
138
- 3. Add a "question" label to the issue
139
+ You can use the [Issues](https://github.com/emilsoman/cloudster/issues) page to ask a new question for now. This is how you do it:
140
+ 1. Click on New Issue.
141
+ 2. Type in your question and submit.
139
142
 
140
143
  ## Have a patch?
141
144
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.13.1
1
+ 2.14.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudster"
8
- s.version = "2.13.1"
8
+ s.version = "2.14.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Emil Soman"]
12
- s.date = "2012-12-18"
12
+ s.date = "2012-12-27"
13
13
  s.description = "Cloudster is a Ruby gem that was born to cut the learning curve involved \n in writing your own CloudFormation templates. If you don't know what a CloudFormation template is, \n but know about the AWS Cloud offerings, you can still use cloudster to provision your stack. \n Still in infancy , cloudster can create a very basic stack like a breeze. All kinds of contribution welcome !"
14
14
  s.email = "emil.soman@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -35,11 +35,13 @@ Gem::Specification.new do |s|
35
35
  "lib/cloudster/elb.rb",
36
36
  "lib/cloudster/options_manager.rb",
37
37
  "lib/cloudster/rds.rb",
38
+ "lib/cloudster/s3.rb",
38
39
  "spec/chef_client_spec.rb",
39
40
  "spec/cloud_spec.rb",
40
41
  "spec/ec2_spec.rb",
41
42
  "spec/elb_spec.rb",
42
43
  "spec/rds_spec.rb",
44
+ "spec/s3_spec.rb",
43
45
  "spec/spec_helper.rb"
44
46
  ]
45
47
  s.homepage = "http://github.com/emilsoman/cloudster"
@@ -8,5 +8,6 @@ include OptionsManager
8
8
  require 'cloudster/ec2'
9
9
  require 'cloudster/elb'
10
10
  require 'cloudster/rds'
11
+ require 'cloudster/s3'
11
12
  require 'cloudster/cloud'
12
13
  require 'cloudster/chef_client'
@@ -0,0 +1,75 @@
1
+ module Cloudster
2
+ #S3 Resource
3
+ class S3
4
+
5
+ attr_accessor :name, :template
6
+ # Initialize a s3 bucket
7
+ #
8
+ # ==== Notes
9
+ # options parameter must include values for the :name
10
+ #
11
+ # ==== Parameters
12
+ # * options<~Hash>
13
+ # * :name : String representing the bucket name (Required)
14
+ # * :access_control : String consisting of one of the predefined permission value. ( Example: PublicRead )
15
+ # * :website_configuration : A hash containing the name of the index document and name of the error document. ( Example: {"index_document" => "index.html", "error_document" => "error.html"} )
16
+ #
17
+ # ==== Examples
18
+ # bucket = Cloudster::S3.new(
19
+ # :name => 'unique_bucket_name'
20
+ # )
21
+
22
+ def initialize(options = {})
23
+ require_options(options, [:name])
24
+ @name = options[:name]
25
+ @access_control = options[:access_control]
26
+ @website_configuration = options[:website_configuration]
27
+ end
28
+
29
+ # Returns a Ruby hash version of the Cloud Formation template for the s3 resource
30
+ #
31
+ # ==== Examples
32
+ # s3 = Cloudster::S3.new(
33
+ # :name => 'unique_bucket_name'
34
+ # )
35
+ # s3.template
36
+ #
37
+ # ==== Returns
38
+ # * Ruby hash version of the Cloud Formation template for the s3 resource
39
+ def template
40
+ @template ||= S3.template({:name => @name, :access_control => @access_control, :website_configuration => @website_configuration})
41
+ end
42
+
43
+ # Class method that returns a Ruby hash version of the Cloud Formation template
44
+ #
45
+ # ==== Examples
46
+ # template = Cloudster::S3.template(
47
+ # :name => 'myBucket'
48
+ # )
49
+ #
50
+ # ==== Parameters
51
+ # * options<~Hash>
52
+ # * :name : String representing the bucket name (Required)
53
+ # * :access_control : String consisting of one of the predefined permission value. ( Example: PublicRead )
54
+ # * :website_configuration : A hash containing the name of the index document and name of the error document. ( Example: {"index_document" => "index.html", "error_document" => "error.html"} )
55
+ #
56
+ # ==== Returns
57
+ # * Ruby hash version of the Cloud Formation template for S3
58
+ def self.template(options = {})
59
+ require_options(options, [:name])
60
+ properties = {}
61
+ properties.merge!({"AccessControl" => options[:access_control]}) unless options[:access_control].nil?
62
+ unless options[:website_configuration].nil?
63
+ properties.merge!({"WebsiteConfiguration" => {"IndexDocument" => options[:website_configuration]["index_document"], "ErrorDocument" => options[:website_configuration]["error_document"]}})
64
+ end
65
+ template = {'Resources' => {
66
+ options[:name] => {
67
+ 'Type' => 'AWS::S3::Bucket',
68
+ 'Properties' => properties
69
+ }
70
+ }
71
+ }
72
+ return template
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cloudster::S3 do
4
+ describe 'initialize' do
5
+ it "should raise argument error if no argument is provided" do
6
+ expect { Cloudster::S3.new() }.to raise_error(ArgumentError, 'Missing required argument: name')
7
+ end
8
+ it "should not raise argument error if all arguments are provided" do
9
+ expect { Cloudster::S3.new(:name => 'mybucket') }.to_not raise_error
10
+ end
11
+ end
12
+
13
+ describe '#template' do
14
+ it "should return a ruby hash for the resource cloudformation template with only mandatory fields" do
15
+ s3 = Cloudster::S3.new(:name => 'bucket_name')
16
+ s3.template.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {}}}}
17
+ end
18
+ it "should return a ruby hash for the resource cloudformation template" do
19
+ s3 = Cloudster::S3.new(:name => 'bucket_name', :access_control => "PublicRead", :website_configuration => {"index_document" => "index.html", "error_document" => "error.html"} )
20
+ s3.template.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {"AccessControl" => "PublicRead", "WebsiteConfiguration" => { "IndexDocument" => "index.html", "ErrorDocument" => "error.html" } }}}}
21
+ end
22
+ end
23
+
24
+ describe '.template' do
25
+ it "should raise argument error if no argument is provided" do
26
+ expect { Cloudster::S3.template() }.to raise_error(ArgumentError, 'Missing required argument: name')
27
+ end
28
+ it "should return a ruby hash for the resource cloudformation template" do
29
+ hash = Cloudster::S3.template(:name => 'bucket_name', :access_control => "PublicRead", :website_configuration => {"index_document" => "index.html", "error_document" => "error.html"} )
30
+ hash.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {"AccessControl" => "PublicRead", "WebsiteConfiguration" => { "IndexDocument" => "index.html", "ErrorDocument" => "error.html" } }}}}
31
+ end
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.1
4
+ version: 2.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -137,11 +137,13 @@ files:
137
137
  - lib/cloudster/elb.rb
138
138
  - lib/cloudster/options_manager.rb
139
139
  - lib/cloudster/rds.rb
140
+ - lib/cloudster/s3.rb
140
141
  - spec/chef_client_spec.rb
141
142
  - spec/cloud_spec.rb
142
143
  - spec/ec2_spec.rb
143
144
  - spec/elb_spec.rb
144
145
  - spec/rds_spec.rb
146
+ - spec/s3_spec.rb
145
147
  - spec/spec_helper.rb
146
148
  homepage: http://github.com/emilsoman/cloudster
147
149
  licenses:
@@ -158,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
160
  version: '0'
159
161
  segments:
160
162
  - 0
161
- hash: 907847761
163
+ hash: 667254191
162
164
  required_rubygems_version: !ruby/object:Gem::Requirement
163
165
  none: false
164
166
  requirements: