Skip to content

Commit

Permalink
Merge pull request #307 from defect/felix-ruby_client_2.2
Browse files Browse the repository at this point in the history
collins_client clean up
  • Loading branch information
defect committed Jun 4, 2015
2 parents b82df0c + 2158f42 commit 6442ae3
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 176 deletions.
14 changes: 1 addition & 13 deletions support/ruby/collins-client/Gemfile
@@ -1,15 +1,3 @@
source "https://rubygems.org"

gem 'httparty', '~> 0.8.3'

group :development do
gem 'jeweler', '~> 1.8.3'
gem 'yard'
gem 'redcarpet'
end

group :test do
gem 'rspec'
gem 'webmock'
gem 'simplecov'
end
gemspec
50 changes: 0 additions & 50 deletions support/ruby/collins-client/Gemfile.lock

This file was deleted.

34 changes: 0 additions & 34 deletions support/ruby/collins-client/Rakefile
Expand Up @@ -10,47 +10,13 @@ rescue Bundler::BundlerError => e
exit e.status_code
end
require 'rake'
require 'jeweler'
require 'yard'

jeweler = Jeweler::Tasks.new do |gem|
gem.name = 'collins_client'
gem.homepage = 'https://github.com/tumblr/collins/tree/master/support/ruby/collins-client'
gem.license = 'APL 2.0'
gem.summary = %Q{Client library for Collins API}
gem.description = "Provides ruby support for interacting with the Collins API"
gem.email = 'bmatheny@tumblr.com'
gem.authors = ['Blake Matheny']
gem.files.exclude "spec/**/*"
gem.files.exclude '.gitignore'
gem.files.exclude '.rspec'
gem.files.exclude '.rvmrc'
gem.add_runtime_dependency 'httparty', '~> 0.8.3'
end

task :help do
puts("rake -T # See available rake tasks")
puts("rake publish # generate gemspec, build it, push it to repo")
puts("rake version:bump:patch # Bump patch number")
puts("rake all # bump patch and publish")
puts("rake # Run tests")
end

task :publish => [:gemspec, :build] do
package_abs = jeweler.jeweler.gemspec_helper.gem_path
package_name = File.basename(package_abs)

["repo.tumblr.net","repo.ewr01.tumblr.net"].each do |host|
puts("Copying #{package_abs} to #{host} and installing, you may be prompted for your password")
system "scp #{package_abs} #{host}:"
system "ssh -t #{host} 'sudo tumblr_gem install #{package_name}'"
end
end

task :all => ["version:bump:patch", :publish] do
puts("Done!")
end

require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
Expand Down
2 changes: 1 addition & 1 deletion support/ruby/collins-client/VERSION
@@ -1 +1 @@
0.2.15
0.2.16
28 changes: 9 additions & 19 deletions support/ruby/collins-client/collins_client.gemspec
@@ -1,8 +1,3 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = "collins_client"
s.version = File.read 'VERSION'
Expand All @@ -11,13 +6,12 @@ Gem::Specification.new do |s|
s.authors = ["Blake Matheny", "Gabe Conradi", "Will Richard"]
s.date = "2015-03-17"
s.description = "Provides ruby support for interacting with the Collins API"
s.email = ["accounts@tumblr.com","gabe@tumblr.com","will@tumblr.com"]
s.email = ["collins-sm@googlegroups.com","gabe@tumblr.com","will@tumblr.com"]
s.extra_rdoc_files = [
"README.md"
]
s.files = [
"Gemfile",
"Gemfile.lock",
"README.md",
"Rakefile",
"VERSION",
Expand Down Expand Up @@ -59,19 +53,15 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/tumblr/collins/tree/master/support/ruby/collins-client"
s.licenses = ["APL 2.0"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.23"
s.summary = "Client library for Collins API"

if s.respond_to? :specification_version then
s.specification_version = 3
s.required_ruby_version = '>= 1.9.2'

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<httparty>, ["~> 0.8.3"])
else
s.add_dependency(%q<httparty>, ["~> 0.8.3"])
end
else
s.add_dependency(%q<httparty>, ["~> 0.8.3"])
end
end
s.add_runtime_dependency 'httparty', '~> 0.11.0'

s.add_development_dependency 'yard', '~> 0.8'
s.add_development_dependency 'rspec', '~> 2.99'
s.add_development_dependency 'webmock', '~> 1.21'
s.add_development_dependency 'simplecov', '~> 0.10'
s.add_development_dependency 'rake', '~> 10.4'
end
30 changes: 15 additions & 15 deletions support/ruby/collins-client/spec/collins/address_spec.rb
Expand Up @@ -7,34 +7,34 @@
}

it "#is_private?" do
Collins::Address.is_private?("10.0.0.1").should be_true
Collins::Address.is_private?("192.168.1.1").should be_true
Collins::Address.is_private?("172.16.0.1").should be_true
Collins::Address.is_private?("172.20.0.1").should be_true
Collins::Address.is_private?("172.31.255.255").should be_true
Collins::Address.is_private?("10.0.0.1").should be true
Collins::Address.is_private?("192.168.1.1").should be true
Collins::Address.is_private?("172.16.0.1").should be true
Collins::Address.is_private?("172.20.0.1").should be true
Collins::Address.is_private?("172.31.255.255").should be true
end
it "#is_public?" do
Collins::Address.is_public?("4.2.2.4").should be_true
Collins::Address.is_public?("172.15.255.255").should be_true
Collins::Address.is_public?("172.32.0.1").should be_true
Collins::Address.is_public?("4.2.2.4").should be true
Collins::Address.is_public?("172.15.255.255").should be true
Collins::Address.is_public?("172.32.0.1").should be true
end

it_behaves_like "flexible initializer", :id => 23, :address => "hello"

it "#is_addressable?" do
subject[0].is_addressable?.should be_true
subject[1].is_addressable?.should be_true
subject[0].is_addressable?.should be true
subject[1].is_addressable?.should be true
s = Collins::Address.new
s.is_addressable?.should be_false
s.is_addressable?.should be false
end

it "#is_private?" do
subject[0].is_private?.should be_true
subject[0].is_public?.should be_false
subject[0].is_private?.should be true
subject[0].is_public?.should be false
end
it "#is_public?" do
subject[1].is_public?.should be_true
subject[1].is_private?.should be_false
subject[1].is_public?.should be true
subject[1].is_private?.should be false
end

end
18 changes: 9 additions & 9 deletions support/ruby/collins-client/spec/collins/api/asset_spec.rb
Expand Up @@ -51,19 +51,19 @@ def uri; "/api/asset/#{tag}" end
it "supports using a reason" do
args = Hash[:reason => 'Angry gods']
api.with(:body => body(args)).returns 200, CollinsFixture.status_response(false)
subject.delete!(tag, args).should be_true
subject.delete!(tag, args).should be true
end
it "supports not using a reason" do
api.returns 200, CollinsFixture.status_response(false)
subject.delete!(tag).should be_true
subject.delete!(tag).should be true
end
it "raises a RequestError if the status is >= 400" do
api.returns 409, CollinsFixture.delete_conflict
expect { subject.delete!(tag).should }.to raise_exception(Collins::RequestError)
end
it "does not raise an error if !strict" do
api.returns 409, CollinsFixture.delete_conflict
subject(false).delete!(tag).should be_false
subject(false).delete!(tag).should be false
end
end

Expand All @@ -74,23 +74,23 @@ def uri; "/api/asset/sl-129278" end

it "return false on 404" do
api.returns 404, CollinsFixture.no_such_asset(false)
subject(false).exists?("sl-129278").should be_false
subject(false).exists?("sl-129278").should be false
end
it "return false on 404 even when strict" do
api.returns 404, CollinsFixture.no_such_asset(false)
subject.exists?("sl-129278").should be_false
subject.exists?("sl-129278").should be false
end
it "return true on 200" do
api.returns 200, CollinsFixture.full_asset(false)
subject.exists?("sl-129278").should be_true
subject.exists?("sl-129278").should be true
end
it "return true on 200 when status is specified" do
api.returns 200, CollinsFixture.full_asset(false)
subject.exists?("sl-129278", "Allocated").should be_true
subject.exists?("sl-129278", "Allocated").should be true
end
it "return false on 200 when status is specified but not same" do
api.returns 200, CollinsFixture.full_asset(false)
subject.exists?("sl-129278", "Incomplete").should be_false
subject.exists?("sl-129278", "Incomplete").should be false
end
end

Expand Down Expand Up @@ -138,7 +138,7 @@ def uri; "/api/asset/sl-129278" end

it "returns false if asset does not exist and not strict" do
api.returns 500, CollinsFixture.no_such_asset(false)
subject(false).get("sl-129278").should be_false
subject(false).get("sl-129278").should be false
end

it "throws an exception if asset does not exist and strict" do
Expand Down
14 changes: 7 additions & 7 deletions support/ruby/collins-client/spec/collins/asset_spec.rb
Expand Up @@ -65,7 +65,7 @@
subject.backend_ip_address.should == "10.80.97.233"
end
it "#backend_address?" do
subject.backend_address?.should be_true
subject.backend_address?.should be true
end
it "#backend_ip_addresses" do
subject.backend_ip_addresses.length.should == 1
Expand Down Expand Up @@ -99,16 +99,16 @@
context "Update" do
it "lshw is not an attribute" do
["lshw","LSHW"].each do |name|
::Collins::Asset::Update.is_attribute?(name).should be_false
::Collins::Asset::Update.is_attribute?(name).should be false
::Collins::Asset::Update.get_param(name).should === "lshw"
::Collins::Asset::Update.is_file_param?(name).should be_true
::Collins::Asset::Update.is_file_param?(name).should be true
end
end
it "chassis_tag is not an attribute" do
["CHASSIS_TAG","chassis_tag"].each do |name|
::Collins::Asset::Update.is_attribute?(name).should be_false
::Collins::Asset::Update.is_attribute?(name).should be false
::Collins::Asset::Update.get_param(name).should === "CHASSIS_TAG"
::Collins::Asset::Update.is_file_param?(name).should be_false
::Collins::Asset::Update.is_file_param?(name).should be false
end
end
it "file params support reading from files" do
Expand All @@ -123,9 +123,9 @@
}.to raise_error(::Collins::ExpectationFailedError)
end
it "foo is an attribute" do
::Collins::Asset::Update.is_attribute?("foo").should be_true
::Collins::Asset::Update.is_attribute?("foo").should be true
::Collins::Asset::Update.get_param("foo").should === "foo"
::Collins::Asset::Update.is_attribute?("FOO").should be_true
::Collins::Asset::Update.is_attribute?("FOO").should be true
::Collins::Asset::Update.get_param("FOO").should === "FOO"
end
end
Expand Down
2 changes: 1 addition & 1 deletion support/ruby/collins-client/spec/collins/ipmi_spec.rb
Expand Up @@ -9,7 +9,7 @@
it_behaves_like "flexible initializer", :id => 23, :address => "hello"

it "#empty?" do
subject.empty?.should be_false
subject.empty?.should be false
end

it "#address" do
Expand Down
6 changes: 3 additions & 3 deletions support/ruby/collins-client/spec/collins/option_spec.rb
Expand Up @@ -78,17 +78,17 @@ def get_none
none = get_none
none.exists? { |v|
code.work(v)
}.should be_false
}.should be false
end
it "false and execute when some" do
get_some("henry").exists? { |v|
v != "henry"
}.should be_false
}.should be false
end
it "true and execute when some" do
get_some("henry").exists? { |v|
v == "henry"
}.should be_true
}.should be true
end
end

Expand Down
26 changes: 13 additions & 13 deletions support/ruby/collins-client/spec/collins/power_spec.rb
Expand Up @@ -9,25 +9,25 @@
it_behaves_like "flexible initializer", :unit_id => 23

context "#normalize_action" do
it "Off" do example.description.should have_power_action "powerOff" end
it "PowerOff" do example.description.should have_power_action "powerOff" end
it "Off" do |example| example.description.should have_power_action "powerOff" end
it "PowerOff" do |example| example.description.should have_power_action "powerOff" end

it "On" do example.description.should have_power_action "powerOn" end
it "PowerOn" do example.description.should have_power_action "powerOn" end
it "On" do |example| example.description.should have_power_action "powerOn" end
it "PowerOn" do |example| example.description.should have_power_action "powerOn" end

it "PowerSoft" do example.description.should have_power_action "powerSoft" end
it "PowerSoft" do |example| example.description.should have_power_action "powerSoft" end

it "Soft" do example.description.should have_power_action "rebootSoft" end
it "RebootSoft" do example.description.should have_power_action "rebootSoft" end
it "Soft" do |example| example.description.should have_power_action "rebootSoft" end
it "RebootSoft" do |example| example.description.should have_power_action "rebootSoft" end

it "Hard" do example.description.should have_power_action "rebootHard" end
it "RebootHard" do example.description.should have_power_action "rebootHard" end
it "Hard" do |example| example.description.should have_power_action "rebootHard" end
it "RebootHard" do |example| example.description.should have_power_action "rebootHard" end

it "Status" do example.description.should have_power_action "powerState" end
it "PowerState" do example.description.should have_power_action "powerState" end
it "Status" do |example| example.description.should have_power_action "powerState" end
it "PowerState" do |example| example.description.should have_power_action "powerState" end

it "Verify" do example.description.should have_power_action "verify" end
it "Identify" do example.description.should have_power_action "identify" end
it "Verify" do |example| example.description.should have_power_action "verify" end
it "Identify" do |example| example.description.should have_power_action "identify" end
end

it "#keys" do
Expand Down

0 comments on commit 6442ae3

Please sign in to comment.