linode 0.7.10 → 0.8.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2097732edf4e5731f5e8bc64005b902399c8612
4
+ data.tar.gz: 5571780e9bd4606927522ff98fdcd58fc4090709
5
+ SHA512:
6
+ metadata.gz: 45f73884d9ffaa9e9ca0add89d4d6f629f01c55322d9747e5890d6237892a433f5d41000adae9d747e0c7145da90ab16eaf983f782c2267ac4ee4076e8d5be60
7
+ data.tar.gz: b0aad4d67cd46495579ab6de99ce76504b72d02cc5d7984502f5b2b6bf43b6e521def49fd557481091e3068ae45dc866554fbde1f168d2979e9cca1adc044642
@@ -0,0 +1,3 @@
1
+ coverage/
2
+ pkg/
3
+ .rbenv*
data/.rspec CHANGED
@@ -1,4 +1,4 @@
1
1
  --format
2
- s
2
+ d
3
3
  --colour
4
4
  --backtrace
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :test do
4
- gem "rake","0.8.7"
5
- gem "rspec","2.4.0"
6
- gem "mocha"
4
+ gem "rake", "~>10.0"
5
+ gem "rspec","~>2.0"
6
+ gem "mocha", "~>1.0"
7
7
  end
8
8
 
9
- gem "httparty"
10
- gem "json"
9
+ gem "httparty", "~>0.0"
10
+ gem "json", "~>1.0"
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.2.5)
5
+ httparty (0.13.1)
6
+ json (~> 1.8)
7
+ multi_xml (>= 0.5.2)
8
+ json (1.8.1)
9
+ metaclass (0.0.4)
10
+ mocha (1.1.0)
11
+ metaclass (~> 0.0.1)
12
+ multi_xml (0.5.5)
13
+ rake (10.3.2)
14
+ rspec (2.99.0)
15
+ rspec-core (~> 2.99.0)
16
+ rspec-expectations (~> 2.99.0)
17
+ rspec-mocks (~> 2.99.0)
18
+ rspec-core (2.99.2)
19
+ rspec-expectations (2.99.2)
20
+ diff-lcs (>= 1.1.3, < 2.0)
21
+ rspec-mocks (2.99.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ httparty (~> 0.0)
28
+ json (~> 1.0)
29
+ mocha (~> 1.0)
30
+ rake (~> 10.0)
31
+ rspec (~> 2.0)
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## RUNNING:
12
12
 
13
- Consult the Linode API guide here: [http://www.linode.com/api/autodoc.cfm](http://www.linode.com/api/autodoc.cfm)
13
+ Consult the Linode API guide here: [https://www.linode.com/api/](https://www.linode.com/api/)
14
14
  You will need to get an API key (check your account profile).
15
15
 
16
16
  Here is an annoyingly exhaustive IRB session where I play around with the API:
@@ -143,4 +143,7 @@ irb> ^D@ Wed Aug 05 01:50:52 rick@Yer-Moms-Computer
143
143
  * Thanks to Musfuut ([musfuut](http://github.com/musfuut)) for diagnosing and recommending a fix for OpenStruct and 'type' data members in Linode returned results.
144
144
  * Thanks to mihaibirsan ([mihaibirsan](http://github.com/mihaibirsan)) for diagnosing a problem with dependencies on the 'crack' library.
145
145
  * Thanks to Adam Durana ([durana](http://github.com/durana)) for adding support for linode.ip.addprivate.
146
- * Thanks to Gustavo Beathyate ([goddamnhippie](http://github/goddamnhippie)) for markdownifying the README.
146
+ * Thanks to Gustavo Beathyate ([goddamnhippie](http://github.com/goddamnhippie)) for markdownifying the README.
147
+ * Thanks to Robbert Klarenbeek ([rubencaro](https://github.com/robbertkl)) for API updates.
148
+ * Thanks to [rubencaro](https://github.com/rubencaro) for adding logger functionality.
149
+ * Thanks to Marques Johansson [displague](https://github.com/displague) for API updates
data/Rakefile CHANGED
@@ -19,20 +19,3 @@ end
19
19
 
20
20
  desc 'Test the linode library.'
21
21
  task :test => :spec
22
-
23
- begin
24
- require 'jeweler'
25
- Jeweler::Tasks.new do |gemspec|
26
- gemspec.name = "linode"
27
- gemspec.summary = "a Ruby wrapper for the Linode API"
28
- gemspec.description = "This is a wrapper around Linode's automation facilities."
29
- gemspec.email = "rick@rickbradley.com"
30
- gemspec.homepage = "http://github.com/rick/linode"
31
- gemspec.authors = ["Rick Bradley"]
32
- gemspec.add_dependency('httparty', '>= 0.4.4')
33
- gemspec.add_dependency('crack', '>= 0.3.1')
34
- end
35
- Jeweler::GemcutterTasks.new
36
- rescue LoadError
37
- end
38
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.10
1
+ 0.8.1
@@ -5,6 +5,7 @@ require 'json'
5
5
 
6
6
  class Linode
7
7
  attr_reader :username, :password
8
+ attr_accessor :logger
8
9
 
9
10
  def self.has_method(*actions)
10
11
  actions.each do |action|
@@ -28,7 +29,7 @@ class Linode
28
29
  end
29
30
  end
30
31
 
31
- has_namespace :test, :avail, :user, :domain, :linode, :nodebalancer, :stackscript
32
+ has_namespace :test, :avail, :user, :domain, :linode, :nodebalancer, :stackscript, :account
32
33
 
33
34
  @@documentation_category = {}
34
35
 
@@ -50,11 +51,12 @@ class Linode
50
51
 
51
52
  def documentation_path(action)
52
53
  hits = action.match(/^(.*)\.[^.]+$/)
53
- "http://www.linode.com/api/" + @@documentation_category[hits[1]] + '/' + action
54
+ "https://www.linode.com/api/" + @@documentation_category[hits[1]] + '/' + action
54
55
  end
55
56
 
56
57
  def initialize(args)
57
58
  @api_url = args[:api_url] if args[:api_url]
59
+ @logger = args[:logger]
58
60
 
59
61
  if args.include?(:api_key)
60
62
  @api_key = args[:api_key]
@@ -90,6 +92,7 @@ class Linode
90
92
  end
91
93
 
92
94
  def post(data)
95
+ logger.info "POST #{api_url.to_s} body:#{data.inspect}" if logger
93
96
  HTTParty.post(api_url, :body => data).parsed_response
94
97
  end
95
98
 
@@ -0,0 +1,4 @@
1
+ class Linode::Account < Linode
2
+ documentation_category 'account'
3
+ has_method :estimateinvoice, :info
4
+ end
@@ -1,4 +1,4 @@
1
1
  class Linode::Avail < Linode
2
2
  documentation_category 'utility'
3
- has_method :datacenters, :kernels, :linodeplans, :distributions, :stackscripts
4
- end
3
+ has_method :datacenters, :kernels, :linodeplans, :distributions, :stackscripts, :nodebalancers
4
+ end
@@ -0,0 +1,4 @@
1
+ class Linode::Image < Linode
2
+ documentation_category 'image'
3
+ has_method :list, :delete
4
+ end
@@ -1,5 +1,5 @@
1
1
  class Linode::Linode < Linode
2
2
  documentation_category "linode"
3
3
  has_namespace :config, :disk, :ip, :job
4
- has_method :update, :create, :list, :shutdown, :boot, :delete, :reboot
5
- end
4
+ has_method :update, :create, :list, :shutdown, :boot, :delete, :reboot, :clone, :resize
5
+ end
@@ -1,4 +1,4 @@
1
1
  class Linode::Linode::Disk < Linode
2
2
  documentation_category 'linode'
3
- has_method :update, :create, :list, :createfromdistribution, :createfromstackscript, :duplicate, :delete, :resize
4
- end
3
+ has_method :update, :create, :list, :createfromdistribution, :createfromimage, :createfromstackscript, :duplicate, :delete, :resize, :imagize
4
+ end
@@ -1,4 +1,4 @@
1
1
  class Linode::Linode::Ip < Linode
2
2
  documentation_category 'linode'
3
- has_method :list, :addprivate
3
+ has_method :list, :addprivate, :addpublic, :setrdns, :swap
4
4
  end
@@ -1,86 +1,32 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
- s.name = %q{linode}
8
- s.version = "0.7.10"
4
+ s.name = "linode"
5
+ s.version = "0.8.1"
6
+ s.date = "2014-09-06"
7
+ s.description = "This is a wrapper around Linode's automation facilities."
8
+ s.summary = "a Ruby wrapper for the Linode API"
9
+ s.authors = ["Rick Bradley"]
10
+ s.email = "rick@rickbradley.com"
11
+ s.homepage = "http://github.com/rick/linode"
12
+ s.licenses = ["MIT"]
9
13
 
14
+ s.rubygems_version = "2.2.2"
10
15
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Rick Bradley"]
12
- s.date = %q{2012-10-19}
13
- s.description = %q{This is a wrapper around Linode's automation facilities.}
14
- s.email = %q{rick@rickbradley.com}
16
+ s.require_paths = ["lib"]
17
+
15
18
  s.extra_rdoc_files = [
16
19
  "README.md"
17
20
  ]
18
- s.files = [
19
- ".rspec",
20
- "CHANGELOG",
21
- "Gemfile",
22
- "MIT-LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "autotest/discover.rb",
27
- "lib/linode.rb",
28
- "lib/linode/avail.rb",
29
- "lib/linode/domain.rb",
30
- "lib/linode/domain/resource.rb",
31
- "lib/linode/linode.rb",
32
- "lib/linode/linode/config.rb",
33
- "lib/linode/linode/disk.rb",
34
- "lib/linode/linode/ip.rb",
35
- "lib/linode/linode/job.rb",
36
- "lib/linode/nodebalancer.rb",
37
- "lib/linode/nodebalancer/config.rb",
38
- "lib/linode/nodebalancer/node.rb",
39
- "lib/linode/stackscript.rb",
40
- "lib/linode/test.rb",
41
- "lib/linode/user.rb",
42
- "linode.gemspec",
43
- "spec/linode/avail_spec.rb",
44
- "spec/linode/domain/resource_spec.rb",
45
- "spec/linode/domain_spec.rb",
46
- "spec/linode/linode/config_spec.rb",
47
- "spec/linode/linode/disk_spec.rb",
48
- "spec/linode/linode/ip_spec.rb",
49
- "spec/linode/linode/job_spec.rb",
50
- "spec/linode/linode_spec.rb",
51
- "spec/linode/nodebalancer/config_spec.rb",
52
- "spec/linode/nodebalancer/node_spec.rb",
53
- "spec/linode/nodebalancer_spec.rb",
54
- "spec/linode/stackscript_spec.rb",
55
- "spec/linode/test_spec.rb",
56
- "spec/linode/user_spec.rb",
57
- "spec/linode_spec.rb",
58
- "spec/spec_helper.rb"
59
- ]
60
- s.homepage = %q{http://github.com/rick/linode}
61
- s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.6.2}
63
- s.summary = %q{a Ruby wrapper for the Linode API}
64
21
 
65
- if s.respond_to? :specification_version then
66
- s.specification_version = 3
22
+ # Manifest
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.require_paths = ["lib"]
67
27
 
68
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
70
- s.add_runtime_dependency(%q<json>, [">= 0"])
71
- s.add_runtime_dependency(%q<httparty>, [">= 0.4.4"])
72
- s.add_runtime_dependency(%q<crack>, [">= 0.3.1"])
73
- else
74
- s.add_dependency(%q<httparty>, [">= 0"])
75
- s.add_dependency(%q<json>, [">= 0"])
76
- s.add_dependency(%q<httparty>, [">= 0.4.4"])
77
- s.add_dependency(%q<crack>, [">= 0.3.1"])
78
- end
79
- else
80
- s.add_dependency(%q<httparty>, [">= 0"])
81
- s.add_dependency(%q<json>, [">= 0"])
82
- s.add_dependency(%q<httparty>, [">= 0.4.4"])
83
- s.add_dependency(%q<crack>, [">= 0.3.1"])
84
- end
28
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.0"])
29
+ s.add_runtime_dependency(%q<json>, ["~> 1.0"])
30
+ s.add_runtime_dependency(%q<crack>, ["~> 0.0"])
85
31
  end
86
32
 
@@ -0,0 +1,50 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
2
+ require 'linode'
3
+
4
+ describe Linode::Account do
5
+ before :each do
6
+ @api_key = 'foo'
7
+ @linode = Linode::Account.new(:api_key => @api_key)
8
+ end
9
+
10
+ it 'should be a Linode instance' do
11
+ @linode.class.should < Linode
12
+ end
13
+
14
+ %w(estimateinvoice info).each do |action|
15
+ it "should allow accessing the #{action} API" do
16
+ @linode.should respond_to(action.to_sym)
17
+ end
18
+
19
+ describe "when accessing the #{action} API" do
20
+ it 'should allow a data hash' do
21
+ @linode.stubs(:send_request)
22
+ lambda { @linode.send(action.to_sym, {}) }.should_not raise_error
23
+ end
24
+
25
+ it 'should not require arguments' do
26
+ @linode.stubs(:send_request)
27
+ lambda { @linode.send(action.to_sym) }.should_not raise_error
28
+ end
29
+
30
+ it "should request the account.#{action} action" do
31
+ @linode.expects(:send_request).with {|api_action, data| api_action == "account.#{action}" }
32
+ @linode.send(action.to_sym)
33
+ end
34
+
35
+ it 'should provide the data hash when making its request' do
36
+ @linode.expects(:send_request).with {|api_action, data| data = { :foo => :bar } }
37
+ @linode.send(action.to_sym, {:foo => :bar})
38
+ end
39
+
40
+ it 'should return the result of the request' do
41
+ @linode.expects(:send_request).returns(:bar => :baz)
42
+ @linode.send(action.to_sym).should == { :bar => :baz }
43
+ end
44
+
45
+ it "should consider the documentation to live at https://www.linode.com/api/account/account.#{action}" do
46
+ @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "https://www.linode.com/api/account/account.#{action}"
47
+ end
48
+ end
49
+ end
50
+ end
@@ -6,42 +6,44 @@ describe Linode::Avail do
6
6
  @api_key = 'foo'
7
7
  @linode = Linode::Avail.new(:api_key => @api_key)
8
8
  end
9
-
9
+
10
10
  it 'should be a Linode instance' do
11
11
  @linode.class.should < Linode
12
12
  end
13
-
14
- %w(datacenters kernels linodeplans distributions stackscripts).each do |action|
13
+
14
+ %w(datacenters kernels linodeplans distributions stackscripts nodebalancers).each do |action|
15
15
  it "should allow accessing the #{action} API" do
16
16
  @linode.should respond_to(action.to_sym)
17
17
  end
18
-
18
+
19
19
  describe "when accessing the #{action} API" do
20
20
  it 'should allow a data hash' do
21
- lambda { @linode.send(action.to_sym, {}) }.should_not raise_error(ArgumentError)
21
+ @linode.stubs(:send_request)
22
+ lambda { @linode.send(action.to_sym, {}) }.should_not raise_error
22
23
  end
23
-
24
+
24
25
  it 'should not require arguments' do
25
- lambda { @linode.send(action.to_sym) }.should_not raise_error(ArgumentError)
26
+ @linode.stubs(:send_request)
27
+ lambda { @linode.send(action.to_sym) }.should_not raise_error
26
28
  end
27
-
29
+
28
30
  it "should request the avail.#{action} action" do
29
31
  @linode.expects(:send_request).with {|api_action, data| api_action == "avail.#{action}" }
30
32
  @linode.send(action.to_sym)
31
33
  end
32
-
34
+
33
35
  it 'should provide the data hash when making its request' do
34
36
  @linode.expects(:send_request).with {|api_action, data| data = { :foo => :bar } }
35
37
  @linode.send(action.to_sym, {:foo => :bar})
36
38
  end
37
-
39
+
38
40
  it 'should return the result of the request' do
39
- @linode.expects(:send_request).returns(:bar => :baz)
40
- @linode.send(action.to_sym).should == { :bar => :baz }
41
+ @linode.expects(:send_request).returns(:bar => :baz)
42
+ @linode.send(action.to_sym).should == { :bar => :baz }
41
43
  end
42
-
43
- it "should consider the documentation to live at http://www.linode.com/api/utility/avail.#{action}" do
44
- @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "http://www.linode.com/api/utility/avail.#{action}"
44
+
45
+ it "should consider the documentation to live at https://www.linode.com/api/utility/avail.#{action}" do
46
+ @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "https://www.linode.com/api/utility/avail.#{action}"
45
47
  end
46
48
  end
47
49
  end
@@ -6,42 +6,44 @@ describe Linode::Domain::Resource do
6
6
  @api_key = 'foo'
7
7
  @linode = Linode::Domain::Resource.new(:api_key => @api_key)
8
8
  end
9
-
9
+
10
10
  it 'should be a Linode instance' do
11
11
  @linode.class.should < Linode
12
12
  end
13
-
13
+
14
14
  %w(create delete update list).each do |action|
15
15
  it "should allow accessing the #{action} API" do
16
16
  @linode.should respond_to(action.to_sym)
17
17
  end
18
-
18
+
19
19
  describe "when accessing the #{action} API" do
20
20
  it 'should allow a data hash' do
21
- lambda { @linode.send(action.to_sym, {}) }.should_not raise_error(ArgumentError)
21
+ @linode.stubs(:send_request)
22
+ lambda { @linode.send(action.to_sym, {}) }.should_not raise_error
22
23
  end
23
-
24
+
24
25
  it 'should not require arguments' do
25
- lambda { @linode.send(action.to_sym) }.should_not raise_error(ArgumentError)
26
+ @linode.stubs(:send_request)
27
+ lambda { @linode.send(action.to_sym) }.should_not raise_error
26
28
  end
27
-
29
+
28
30
  it "should request the avail.#{action} action" do
29
31
  @linode.expects(:send_request).with {|api_action, data| api_action == "domain.resource.#{action}" }
30
32
  @linode.send(action.to_sym)
31
33
  end
32
-
34
+
33
35
  it 'should provide the data hash when making its request' do
34
36
  @linode.expects(:send_request).with {|api_action, data| data = { :foo => :bar } }
35
37
  @linode.send(action.to_sym, {:foo => :bar})
36
38
  end
37
-
39
+
38
40
  it 'should return the result of the request' do
39
- @linode.expects(:send_request).returns(:bar => :baz)
40
- @linode.send(action.to_sym).should == { :bar => :baz }
41
+ @linode.expects(:send_request).returns(:bar => :baz)
42
+ @linode.send(action.to_sym).should == { :bar => :baz }
41
43
  end
42
-
43
- it "should consider the documentation to live at http://www.linode.com/api/dns/domain.resource.#{action}" do
44
- @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "http://www.linode.com/api/dns/domain.resource.#{action}"
44
+
45
+ it "should consider the documentation to live at https://www.linode.com/api/dns/domain.resource.#{action}" do
46
+ @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "https://www.linode.com/api/dns/domain.resource.#{action}"
45
47
  end
46
48
  end
47
49
  end