veslo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem 'mixlib-cli'
10
+ gem 'rest-client'
11
+
12
+ group :development do
13
+ gem "rspec", "~> 2.3.0"
14
+ gem "bundler", "~> 1.0.0"
15
+ gem "jeweler", "~> 1.6.4"
16
+ gem "rcov", ">= 0"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.6.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ mime-types (1.17.2)
11
+ mixlib-cli (1.2.2)
12
+ rake (0.9.2.2)
13
+ rcov (0.9.11)
14
+ rest-client (1.6.7)
15
+ mime-types (>= 1.16)
16
+ rspec (2.3.0)
17
+ rspec-core (~> 2.3.0)
18
+ rspec-expectations (~> 2.3.0)
19
+ rspec-mocks (~> 2.3.0)
20
+ rspec-core (2.3.1)
21
+ rspec-expectations (2.3.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.3.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ jeweler (~> 1.6.4)
31
+ mixlib-cli
32
+ rcov
33
+ rest-client
34
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Dimitri Krassovski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = veslo
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to veslo
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Dimitri Krassovski. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "veslo"
18
+ gem.homepage = "http://github.com/Wixpress/veslo"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Command line Noah client}
21
+ gem.description = %Q{Command line utility to manage Noah configurations}
22
+ gem.email = "dimitri@wix.com"
23
+ gem.authors = ["Dimitri Krassovski"]
24
+ gem.executables << 'veslo'
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "veslo #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/veslo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'veslo'
4
+
5
+ exit Veslo.new.run!(*ARGV)
data/lib/veslo.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'mixlib/cli'
3
+ require 'rest_client'
4
+
5
+ class Veslo
6
+ include Mixlib::CLI
7
+ Veslo::SUPPORTED_METHODS = ["put", "get"]
8
+ Veslo::SUPPORTED_RESOURCES = ["configurations"]
9
+
10
+ option :server_url,
11
+ :short => "-s SERVER",
12
+ :long => "--server SERVER",
13
+ :description => "The Noah server to work against",
14
+ :required => true
15
+
16
+ def run!(*arguments)
17
+ argv = parse_options
18
+ @server = RestClient::Resource.new(config[:server_url], :headers => {:accept => "application/octet"})
19
+ parse_commands(argv)
20
+ execute
21
+ return 0
22
+ end
23
+
24
+ def parse_commands(commands)
25
+ raise ArgumentError.new("Not the right ammount of arguments") if commands.size != 3
26
+ @resource = commands.shift
27
+ @method = commands.shift
28
+ @name = commands.shift
29
+ validate_input
30
+ end
31
+
32
+ def validate_input
33
+ raise NotImplementedError.new("method #{@method} not supported") unless SUPPORTED_METHODS.include?(@method)
34
+ raise NotImplementedError.new("resource #{@resource} not supported") unless SUPPORTED_RESOURCES.include?(@resource)
35
+ end
36
+
37
+ def execute
38
+ result = @server["#{@resource}/#{@name}"].get()
39
+ puts result.to_str
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'veslo'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Veslo" do
4
+ before :each do
5
+ @veslo = Veslo.new
6
+ end
7
+
8
+ it "should accept 3 well-formed arguments" do
9
+ lambda{@veslo.parse_commands(["configurations", "get", "chix"])}.should_not raise_error(ArgumentError)
10
+ end
11
+
12
+ it "should not accept less than 3 arguments" do
13
+ lambda{@veslo.parse_commands(["foo", "bar"])}.should raise_error(ArgumentError)
14
+ end
15
+
16
+ it "should not accept more than 3 arguments" do
17
+ lambda{@veslo.parse_commands(["foo", "bar", "baz", "foobar"])}.should raise_error(ArgumentError)
18
+ end
19
+
20
+ it "should not accept unknown methods" do
21
+ lambda{@veslo.parse_commands(["configurations", "head", "baz"])}.should raise_error(NotImplementedError)
22
+ end
23
+
24
+ it "should not accept unknown resources" do
25
+ lambda{@veslo.parse_commands(["foobars", "get", "baz"])}.should raise_error(NotImplementedError)
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veslo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dimitri Krassovski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mixlib-cli
16
+ requirement: &70364010682640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70364010682640
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70364010682160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70364010682160
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70364010681680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70364010681680
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70364010681080 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70364010681080
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &70364010680540 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.6.4
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70364010680540
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &70364010680020 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70364010680020
80
+ description: Command line utility to manage Noah configurations
81
+ email: dimitri@wix.com
82
+ executables:
83
+ - veslo
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.rdoc
88
+ files:
89
+ - .document
90
+ - .rspec
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - bin/veslo
98
+ - lib/veslo.rb
99
+ - spec/spec_helper.rb
100
+ - spec/veslo_spec.rb
101
+ homepage: http://github.com/Wixpress/veslo
102
+ licenses:
103
+ - MIT
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ segments:
115
+ - 0
116
+ hash: 2012807942837032086
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 1.8.12
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Command line Noah client
129
+ test_files: []