overriaktion 0.0.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ results.html
2
+ *.gem
3
+ .bundle
4
+ pkg/*
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p0
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - rbx
5
+ - jruby
6
+ script: "bundle exec rake spec"
7
+ gemfile:
8
+ - Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in overriaktion.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ overriaktion (0.0.1.beta1)
5
+ httparty
6
+ methadone
7
+ vcr
8
+ webmock
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ addressable (2.2.6)
14
+ archive-tar-minitar (0.5.2)
15
+ aruba (0.4.6)
16
+ bcat (>= 0.6.1)
17
+ childprocess (>= 0.2.0)
18
+ cucumber (>= 1.0.2)
19
+ rdiscount (>= 1.6.8)
20
+ rspec (>= 2.6.0)
21
+ bcat (0.6.2)
22
+ rack (~> 1.0)
23
+ builder (3.0.0)
24
+ childprocess (0.2.2)
25
+ ffi (~> 1.0.6)
26
+ crack (0.3.1)
27
+ cucumber (1.1.0)
28
+ builder (>= 2.1.2)
29
+ diff-lcs (>= 1.1.2)
30
+ gherkin (~> 2.5.0)
31
+ json (>= 1.4.6)
32
+ term-ansicolor (>= 1.0.6)
33
+ diff-lcs (1.1.3)
34
+ ffi (1.0.9)
35
+ gherkin (2.5.4)
36
+ json (>= 1.4.6)
37
+ guard (0.8.4)
38
+ thor (~> 0.14.6)
39
+ guard-cucumber (0.7.3)
40
+ cucumber (>= 0.10)
41
+ guard (>= 0.8.3)
42
+ guard-rspec (0.5.0)
43
+ guard (>= 0.8.4)
44
+ httparty (0.8.1)
45
+ multi_json
46
+ multi_xml
47
+ json (1.6.1)
48
+ methadone (0.3.4)
49
+ bundler
50
+ mime-types (1.17.2)
51
+ multi_json (1.0.4)
52
+ multi_xml (0.4.1)
53
+ rack (1.3.4)
54
+ rake (0.9.2)
55
+ rdiscount (1.6.8)
56
+ rdoc (3.10)
57
+ json (~> 1.4)
58
+ relish (0.5.3)
59
+ archive-tar-minitar (>= 0.5.2)
60
+ json (>= 1.4.6)
61
+ rest-client (>= 1.6.1)
62
+ rest-client (1.6.7)
63
+ mime-types (>= 1.16)
64
+ rspec (2.6.0)
65
+ rspec-core (~> 2.6.0)
66
+ rspec-expectations (~> 2.6.0)
67
+ rspec-mocks (~> 2.6.0)
68
+ rspec-core (2.6.4)
69
+ rspec-expectations (2.6.0)
70
+ diff-lcs (~> 1.1.2)
71
+ rspec-mocks (2.6.0)
72
+ term-ansicolor (1.0.7)
73
+ thor (0.14.6)
74
+ vcr (1.11.3)
75
+ webmock (1.7.10)
76
+ addressable (~> 2.2, > 2.2.5)
77
+ crack (>= 0.1.7)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ aruba
84
+ guard
85
+ guard-cucumber
86
+ guard-rspec
87
+ overriaktion!
88
+ rake (~> 0.9.2)
89
+ rdoc
90
+ relish
91
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'cucumber' do
8
+ watch(%r{^bin/.+$}) { 'features' }
9
+ watch(%r{^features/.+\.feature$})
10
+ watch(%r{^features/support/.+$}) { 'features' }
11
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Critical Pair
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = Overriaktion
2
+
3
+ Client for the Overriak service. Provides a ruby client library and a CLI.
4
+
5
+ == Installation
6
+
7
+ gem install overriaktion
8
+
9
+ == Usage
10
+
11
+ See the usage guide on {Relish}[https://www.relishapp.com/cmeiklejohn/overriaktion].
12
+
13
+ == License
14
+
15
+ Overriaktion and Overriak are Copyright © 2011 Critical Pair. Overriaktion is free software, and may be redistributed under the terms specified in the LICENSE file.
16
+
17
+ == About
18
+
19
+ The overriaktion gem was written by {Christopher Meiklejohn}[mailto:christopher.meiklejohn@gmail.com].
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require 'bundler/setup'
6
+ require 'bundler/gem_tasks'
7
+ require 'rake'
8
+ require 'rdoc/task'
9
+ require 'rake/clean'
10
+ require 'rubygems/package_task'
11
+ require 'rspec/core/rake_task'
12
+ require 'cucumber'
13
+ require 'cucumber/rake/task'
14
+
15
+ include Rake::DSL
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ CUKE_RESULTS = 'results.html'
20
+ CLEAN << CUKE_RESULTS
21
+ Cucumber::Rake::Task.new(:features) do |t|
22
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
23
+ t.fork = false
24
+ end
25
+
26
+ Rake::RDocTask.new do |rd|
27
+ rd.main = "README.rdoc"
28
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
29
+ end
30
+
31
+ RSpec::Core::RakeTask.new do |t|
32
+ t.pattern = 'spec/**/*_spec.rb'
33
+ end
34
+
35
+ task :default => [:spec, :features]
data/bin/overriaktion ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.push File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'optparse'
6
+ require 'methadone'
7
+ require 'overriaktion'
8
+
9
+ include Methadone::Main
10
+
11
+ main do |api_key, operation, cluster_name, node_uri|
12
+ client = lambda do
13
+ Overriaktion::CLI.dispatch(api_key, operation, cluster_name, node_uri)
14
+ end
15
+
16
+ # Use VCR if the rails env is set, otherwise don't.
17
+ #
18
+ # TODO: Dirty hack, since the client process from aruba is started
19
+ # outside of the test environment. Use RAILS_ENV for now until we can
20
+ # patch aruba/methadone to handle this. Consider injection somehow.
21
+ #
22
+ if ENV['RAILS_ENV'] == 'test'
23
+ VCR.use_cassette('overriak') do
24
+ client.call
25
+ end
26
+ else
27
+ client.call
28
+ end
29
+ end
30
+
31
+ description "Client gem for the Overriak service."
32
+
33
+ arg :api_key
34
+ arg :operation
35
+ arg :cluster_name, :optional
36
+ arg :node_uri, :optional
37
+
38
+ go!
@@ -0,0 +1,41 @@
1
+ @overriak
2
+ Feature: CLI
3
+
4
+ In order to remotely administer the Overriak service from the command line
5
+ as a registered user with an API key
6
+ I should be able to access the remote API via the CLI.
7
+
8
+ Scenario: Access help
9
+ When I run `overriaktion --help`
10
+ Then the exit status should be 0
11
+ And the output should contain:
12
+ """
13
+ Usage: overriaktion api_key operation [cluster_name] [node_uri]
14
+
15
+ Client gem for the Overriak service.
16
+ """
17
+
18
+ Scenario: Throw error with invalid switch
19
+ When I run `overriaktion api_key thingy`
20
+ Then the exit status should be 0
21
+ And the output should contain:
22
+ """
23
+ 'thingy' is not a valid operation
24
+ """
25
+
26
+ Scenario: List riak clusters
27
+ When I run `overriaktion api_key list`
28
+ Then the exit status should be 0
29
+ And the output should contain:
30
+ """
31
+ Localhost
32
+ - root@127.0.0.1:8098
33
+ """
34
+
35
+ Scenario: Sample a riak node in a riak cluster
36
+ When I run `overriaktion api_key sample Localhost root@127.0.0.1:8098`
37
+ Then the exit status should be 0
38
+ And the output should contain:
39
+ """
40
+ OK
41
+ """
@@ -0,0 +1,29 @@
1
+ @overriak
2
+ Feature: Client
3
+
4
+ In order to remotely administer the Overriak service
5
+ as a registered user with an API key
6
+ I should be able to access the remote API via the client gem.
7
+
8
+ Background:
9
+ Given I have a valid API key and an instance of the client
10
+
11
+ Scenario: Retrieve a list of riak clusters
12
+ When I make a request to the API to retrieve my list of riak clusters
13
+ Then I should have a list containing the "Localhost" riak cluster
14
+
15
+ Scenario: Retrieve one riak cluster
16
+ When I make a request to the API to retrieve one riak cluster
17
+ Then I should have the "Localhost" riak cluster
18
+
19
+ Scenario: Retrieve one riak cluster's riak nodes
20
+ When I make a request to the API to retrieve one riak cluster
21
+ Then I should have the "Localhost" riak cluster
22
+ When I make a request to the API to retrive the riak clusters riak nodes
23
+ Then I should have a list containing the "root@127.0.0.1:8098" riak node
24
+
25
+ Scenario: Retrieve one riak node in a riak cluster
26
+ When I make a request to the API to retrieve one riak cluster
27
+ Then I should have the "Localhost" riak cluster
28
+ When I make a request to the API to retrive one riak node the riak cluster
29
+ Then I should have the "root@127.0.0.1:8098" riak node
@@ -0,0 +1,41 @@
1
+ # Setup
2
+
3
+ Given /^I have a valid API key and an instance of the client$/ do
4
+ @client = Overriaktion.new(:api_key => '1')
5
+ end
6
+
7
+ # Requests
8
+
9
+ When /^I make a request to the API to retrieve my list of riak clusters$/ do
10
+ @riak_clusters = @client.riak_clusters
11
+ end
12
+
13
+ When /^I make a request to the API to retrieve one riak cluster$/ do
14
+ @riak_cluster = @client.riak_cluster(1)
15
+ end
16
+
17
+ When /^I make a request to the API to retrive the riak clusters riak nodes$/ do
18
+ @riak_nodes = @riak_cluster.riak_nodes
19
+ end
20
+
21
+ When /^I make a request to the API to retrive one riak node the riak cluster$/ do
22
+ @riak_node = @riak_cluster.riak_node(1)
23
+ end
24
+
25
+ # Matchers
26
+
27
+ Then /^I should have a list containing the "([^"]*)" riak cluster$/ do |cluster_name|
28
+ @riak_clusters.select { |cluster| cluster.to_s == cluster_name }.length.should == 1
29
+ end
30
+
31
+ Then /^I should have the "([^"]*)" riak cluster$/ do |cluster_name|
32
+ @riak_cluster.to_s.should == cluster_name
33
+ end
34
+
35
+ Then /^I should have a list containing the "([^"]*)" riak node$/ do |node_uri|
36
+ @riak_nodes.select { |node| node.to_s == node_uri }.length.should == 1
37
+ end
38
+
39
+ Then /^I should have the "([^"]*)" riak node$/ do |node_uri|
40
+ @riak_node.to_s.should == node_uri
41
+ end
@@ -0,0 +1,12 @@
1
+ require 'aruba/cucumber'
2
+ require 'methadone/cucumber'
3
+
4
+ require 'overriaktion'
5
+ include Overriaktion
6
+
7
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
8
+
9
+ Before do
10
+ # Using "announce" causes massive warnings on 1.9.2
11
+ @puts = true
12
+ end
@@ -0,0 +1,3 @@
1
+ VCR.cucumber_tags do |t|
2
+ t.tag '@overriak'
3
+ end
@@ -0,0 +1,44 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://api-v2.overriak.com:80/riak_clusters.json
6
+ body: !!null
7
+ headers:
8
+ authorization:
9
+ - key
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ server:
16
+ - nginx/0.7.67
17
+ date:
18
+ - Sun, 30 Oct 2011 01:20:23 GMT
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ connection:
22
+ - keep-alive
23
+ status:
24
+ - 200 OK
25
+ x-ua-compatible:
26
+ - IE=Edge,chrome=1
27
+ etag:
28
+ - ! '"61ddb7b66cd8ba45d1d6f485ee612aaa"'
29
+ cache-control:
30
+ - must-revalidate, private, max-age=0
31
+ x-runtime:
32
+ - '0.616467'
33
+ x-rack-cache:
34
+ - miss
35
+ content-length:
36
+ - '113'
37
+ x-varnish:
38
+ - '912617012'
39
+ age:
40
+ - '0'
41
+ via:
42
+ - 1.1 varnish
43
+ body: ! '[{"created_at":"2011-10-10T03:31:34Z","id":1,"name":"Localhost","updated_at":"2011-10-10T03:31:34Z","user_id":1}]'
44
+ http_version: '1.1'
@@ -0,0 +1,44 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://api.overriak.com:80/riak_clusters.json
6
+ body: !!null
7
+ headers:
8
+ authorization:
9
+ - key
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ server:
16
+ - nginx/0.7.67
17
+ date:
18
+ - Sun, 30 Oct 2011 01:20:23 GMT
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ connection:
22
+ - keep-alive
23
+ status:
24
+ - 200 OK
25
+ x-ua-compatible:
26
+ - IE=Edge,chrome=1
27
+ etag:
28
+ - ! '"61ddb7b66cd8ba45d1d6f485ee612aaa"'
29
+ cache-control:
30
+ - must-revalidate, private, max-age=0
31
+ x-runtime:
32
+ - '0.616467'
33
+ x-rack-cache:
34
+ - miss
35
+ content-length:
36
+ - '113'
37
+ x-varnish:
38
+ - '912617012'
39
+ age:
40
+ - '0'
41
+ via:
42
+ - 1.1 varnish
43
+ body: ! '[{"created_at":"2011-10-10T03:31:34Z","id":1,"name":"Localhost","updated_at":"2011-10-10T03:31:34Z","user_id":1}]'
44
+ http_version: '1.1'