spurious-ruby-awssdk-helper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cb200df5ba22167d976452f41ebf4f1eab6a4e3
4
+ data.tar.gz: e119267c58eba5a166b358445cb02f5d5232bb46
5
+ SHA512:
6
+ metadata.gz: 8aa421e29b8690368fe034ca99d1d205f7b4e0f476f2e981e24d9196c22501cc65dd2c9b9e8427ff784827771bbe40f388d471f8574ad5b060b4e51c251755d2
7
+ data.tar.gz: 0268bc12da04f9603725f524245f374fe2ff061a8d437d732935569d25183142e6b1a0c2c8e7d9cf654b93b952798830619af21540cfbf1f9459b1d1f3ba3f10
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spurious-ruby-awssdk-helper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Steven Jack
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Spurious::Ruby::Awssdk::Helper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'spurious-ruby-awssdk-helper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install spurious-ruby-awssdk-helper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/stevenjack/spurious-ruby-awssdk-helper/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ require "spurious/ruby/awssdk/helper/version"
2
+ require 'spurious/ruby/awssdk/strategy'
3
+ require "aws-sdk"
4
+ require "json"
5
+
6
+ module Spurious
7
+ module Ruby
8
+ module Awssdk
9
+ module Helper
10
+
11
+ def self.port_config()
12
+ config = `spurious ports --json`
13
+ JSON.parse(config)
14
+ rescue Exception
15
+ raise("The spurious CLI tool didn't return the port configuration")
16
+ end
17
+
18
+ def self.configure(strategy = nil)
19
+ strategy ||= Spurious::Ruby::Awssdk::Strategy.new(true)
20
+ strategy.apply(port_config)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ module Spurious
2
+ module Ruby
3
+ module Awssdk
4
+ module Helper
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,54 @@
1
+ require "spurious/ruby/awssdk/helper/version"
2
+ require "aws-sdk"
3
+
4
+ module Spurious
5
+ module Ruby
6
+ module Awssdk
7
+ class Strategy
8
+ attr_accessor :mapping
9
+
10
+ def initialize(set_all = false)
11
+ @mapping = {}
12
+ if set_all then
13
+ dynamo(true, true)
14
+ sqs(true, true)
15
+ s3(true, true)
16
+ end
17
+ end
18
+
19
+ def dynamo(port = true, ip = false)
20
+ mapping['spurious-dynamo'] = {
21
+ 'port' => port,
22
+ 'ip' => ip,
23
+ 'identifier' => 'dynamo_db'
24
+ }
25
+ end
26
+
27
+ def sqs(port = true, ip = false)
28
+ mapping['spurious-sqs'] = {
29
+ 'port' => port,
30
+ 'ip' => ip,
31
+ 'identifier' => 'sqs'
32
+ }
33
+ end
34
+
35
+ def s3(port = true, ip = false)
36
+ mapping['spurious-s3'] = {
37
+ 'port' => port,
38
+ 'ip' => ip,
39
+ 'identifier' => 's3'
40
+ }
41
+ end
42
+
43
+ def apply(config)
44
+ mapping.each do |type, mappings|
45
+ ports = config[type]
46
+ AWS.config("#{mappings['identifier']}_port".to_sym => ports.first['HostPort']) if mappings['port']
47
+ AWS.config("#{mappings['identifier']}_endpoint".to_sym => 'localhost') if mappings['ip']
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,4 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+
3
+ require 'spurious/ruby/awssdk/helper'
4
+ require 'spurious/ruby/awssdk/strategy'
@@ -0,0 +1,56 @@
1
+ require 'helper'
2
+
3
+ describe Spurious::Ruby::Awssdk::Strategy do
4
+
5
+ describe "#apply" do
6
+ let(:config) {
7
+ {
8
+ 'spurious-sqs' => [
9
+ {
10
+ 'GuestPort' => 123,
11
+ 'HostPort' => 456
12
+ }
13
+ ],
14
+ 'spurious-s3' => [
15
+ {
16
+ 'GuestPort' => 789,
17
+ 'HostPort' => 101
18
+ }
19
+ ],
20
+ 'spurious-dynamo' => [
21
+ {
22
+ 'GuestPort' => 121,
23
+ 'HostPort' => 314
24
+ }
25
+ ]
26
+ }
27
+ }
28
+
29
+ it "applys ports from config" do
30
+ subject.dynamo
31
+ subject.sqs
32
+ subject.s3
33
+
34
+ expect(AWS).to receive(:config).exactly(3).times
35
+ subject.apply(config)
36
+
37
+ end
38
+
39
+ it "only applys a subset of the options" do
40
+ subject.dynamo(true, true)
41
+
42
+ expect(AWS).to receive(:config).exactly(2).times
43
+ subject.apply(config)
44
+
45
+ end
46
+
47
+ it "only sets the port for one service" do
48
+ subject.dynamo(true)
49
+
50
+ expect(AWS).to receive(:config).once.with(:dynamo_db_port => 314).times
51
+ subject.apply(config)
52
+
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'spurious/ruby/awssdk/helper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spurious-ruby-awssdk-helper"
8
+ spec.version = Spurious::Ruby::Awssdk::Helper::VERSION
9
+ spec.authors = ["Steven Jack"]
10
+ spec.email = ["stevenmajack@gmail.com"]
11
+ spec.summary = %q{Helper gem for configuring the AWS ruby SDK with spurious details}
12
+ spec.description = %q{Helper gem for configuring the AWS ruby SDK with spurious details}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_runtime_dependency "aws-sdk"
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spurious-ruby-awssdk-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Jack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Helper gem for configuring the AWS ruby SDK with spurious details
56
+ email:
57
+ - stevenmajack@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/spurious/ruby/awssdk/helper.rb
68
+ - lib/spurious/ruby/awssdk/helper/version.rb
69
+ - lib/spurious/ruby/awssdk/strategy.rb
70
+ - spec/helper.rb
71
+ - spec/strategy_spec.rb
72
+ - spurious-ruby-awssdk-helper.gemspec
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Helper gem for configuring the AWS ruby SDK with spurious details
97
+ test_files:
98
+ - spec/helper.rb
99
+ - spec/strategy_spec.rb