linode 0.9.0 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de9411d548f39b5daf2fca55e3fd7ffbad6eba21
4
- data.tar.gz: fe8344bce96367b6e9fd3a324a9a9bec6a8d265e
3
+ metadata.gz: 9a231618cd2673977b0cd51db2a668cc8bc16f33
4
+ data.tar.gz: 373181a8417e1d7d9cc433bb899cf472395da55c
5
5
  SHA512:
6
- metadata.gz: f6ef8c7081d9acdc29baa57c67cc2387943872935a19fa6231b8e338d98f264fc2a9c73ab50ed60ea59f5ff1280fa9dba4aeac8c46e1fcb591c3500e5986bc48
7
- data.tar.gz: bf0bb76385fb2d1770c255e200304e43b16ba10f8a7a5b2c955baf39b06c5badfd0fa224a8821cd0bb877c8523d90232a46be4567cc365f8d0f92a3aa8273736
6
+ metadata.gz: 31a2549bb3a7717450268fa62f376e284a3eb977de81b075ef998cb2366abb10ab68d39ad75f6abc838687cd7b467fcea3572a3499dfe74c787391150d5f56e8
7
+ data.tar.gz: 8fe99fa8ed3b992811411db750a03b725568895c6a82372858e098ff81d0da51a788cfaf70adb9129880e0663c172c6f2957ecf1c53a3dac60d593bd9dd52096
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  coverage/
2
2
  pkg/
3
3
  .rbenv*
4
+ Gemfile.lock
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.9.1 / 2016-08-18
2
+ ==================
3
+ * Removed explicit dependency on JSON gem
4
+ * Removed Gemfile.lock as this is a library
5
+ * Made Gemfile rely on gemspec to remove duplication
6
+ * Updated README to include how to use with older Rubies
7
+ * Updated README to encourage using Gemfile and Bundler for Installation
8
+ * Updated README to include a CONTRIBUTE section
1
9
 
2
10
  0.7.10 / 2012-10-19
3
11
  ===================
data/Gemfile CHANGED
@@ -1,10 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- group :test do
4
- gem "rake", "~>10.0"
5
- gem "rspec","~>2.0"
6
- gem "mocha", "~>1.0"
7
- end
8
-
9
- gem "httparty", "~>0.0"
10
- gem "json", "~>1.0"
3
+ gemspec
data/README.md CHANGED
@@ -1,12 +1,70 @@
1
1
  # Linode Ruby API
2
2
 
3
+ ## NOTICE
4
+
5
+ Please welcome [Marques Johansson](https://github.com/displague) and [Drew DeVault](https://github.com/sircmpwn),
6
+ both of Linode, as new maintainers of the ruby Linode API library!
7
+
3
8
  ## INSTALLATION:
4
9
 
5
- Make sure gemcutter.org is in your gem sources list, then:
10
+ The recommended way to use this library is to include `linode` in your Gemfile and use Bundler.
11
+
12
+ ```ruby
13
+ gem 'linode', '~> 0.9.0'
14
+ ```
15
+
16
+ By default, this will also install the latest version of the linode library's dependencies:
17
+
18
+ * httparty
6
19
 
7
- % sudo gem install linode
20
+ The latest version of these dependencies requires Ruby >= 1.9.3
21
+ If for some reason you need to use an older version of Ruby (1.8.7),
22
+ you can include the following dependencies in your Gemfile.
8
23
 
9
- To run tests you will need both rspec and mocha installed.
24
+ ```ruby
25
+ gem 'json', '~>1.8'
26
+ gem 'httparty', '0.11'
27
+ ```
28
+
29
+ Running on versions of Ruby older than 1.9.3 is considered deprecated
30
+ and support will not actively be maintained for older versions of Ruby.
31
+ Using this library with EOL versions of Ruby is frowned upon :(
32
+
33
+ At this point you can use Bundler to install or update your dependencies.
34
+
35
+ ```bash
36
+ bundle install
37
+ ```
38
+
39
+ ## CONTRIBUTING
40
+
41
+ If you would like to submit a bug fix or feature, you can do so with the traditional GitHub workflow.
42
+
43
+ * Fork this repo
44
+ * Git clone your repo locally
45
+ * `cd` into the repo
46
+ * `bundle install` to get all runtime and development dependencies
47
+ * Make a new branch
48
+ * Submit a PR
49
+
50
+ ### Development
51
+
52
+ Bug fixes and features should include new tests using the RSpec format.
53
+ Reviewing the current way tests are written is the best way to understand this.
54
+ All tests live under the `spec` folder at the root of the repo.
55
+
56
+ You can run the tests suite by executing:
57
+
58
+ ```bash
59
+ rake test
60
+ ```
61
+
62
+ Adding new dependencies is highly discouraged!
63
+ Maintaining compatibility with Ruby 1.9.3 is currently required.
64
+
65
+ Testing your changes against Ruby 1.9.3 and ~> 2.3 should be enough to ensure compatibilty between all version inclusively.
66
+
67
+ [RVM](rmv.io) can greatly help with testing different versions of Ruby.
10
68
 
11
69
  ## RUNNING:
12
70
 
@@ -16,7 +74,8 @@ You will need to get an API key (check your account profile).
16
74
  Here is an annoyingly exhaustive IRB session where I play around with the API:
17
75
 
18
76
  ```ruby
19
- irb> require 'rubygems'
77
+ bundle exec irb
78
+
20
79
  irb> require 'linode'
21
80
  irb> api_key = 'TOPSECRETAPIKEY'
22
81
  irb> l = Linode.new(:api_key => api_key)
data/Rakefile CHANGED
@@ -1,12 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
-
5
- begin
6
- require 'rdoc/task'
7
- rescue LoadError
8
- require 'rake/rdoctask'
9
- end
10
4
  require 'rspec/core/rake_task'
11
5
 
12
6
  desc 'Default: run specs.'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -83,14 +83,25 @@ class Linode
83
83
  reformat_response(response)
84
84
  end
85
85
 
86
- protected
86
+ def fetch_api_key(options = {})
87
+ request = { :api_action => 'user.getapikey', :api_responseFormat => 'json', :username => username, :password => password }
88
+
89
+ if options.key?(:label)
90
+ request[:label] = options[:label]
91
+ end
87
92
 
88
- def fetch_api_key
89
- response = post(:api_action => 'user.getapikey', :api_responseFormat => 'json', :username => username, :password => password)
93
+ if options.key?(:expires)
94
+ expires = options[:expires]
95
+ request[:expires] = expires.nil? ? 0 : expires
96
+ end
97
+
98
+ response = post(request)
90
99
  raise "Errors completing request [user.getapikey] @ [#{api_url}] for username [#{username}]:\n#{error_message(response, 'user.getapikey')}" if error?(response)
91
100
  reformat_response(response).api_key
92
101
  end
93
102
 
103
+ protected
104
+
94
105
  def post(data)
95
106
  logger.info "POST #{api_url.to_s} body:#{data.inspect}" if logger
96
107
  HTTParty.post(api_url, :body => data).parsed_response
@@ -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, :clone, :resize
4
+ has_method :update, :create, :kvmify, :list, :mutate, :shutdown, :boot, :delete, :reboot, :clone, :resize
5
5
  end
@@ -2,8 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "linode"
5
- s.version = "0.9.0"
6
- s.date = "2016-01-02"
5
+ s.version = File.open("VERSION", "r").read.strip
7
6
  s.description = "This is a wrapper around Linode's automation facilities."
8
7
  s.summary = "a Ruby wrapper for the Linode API"
9
8
  s.authors = ["Rick Bradley"]
@@ -25,7 +24,10 @@ Gem::Specification.new do |s|
25
24
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
25
  s.require_paths = ["lib"]
27
26
 
28
- s.add_runtime_dependency(%q<httparty>, ["~> 0.0"])
29
- s.add_runtime_dependency(%q<json>, ["~> 1.0"])
27
+ s.add_runtime_dependency "httparty", "~> 0.0"
28
+
29
+ s.add_development_dependency "rake", "~> 10.0"
30
+ s.add_development_dependency "rspec", "~> 2.0"
31
+ s.add_development_dependency "mocha", "~> 1.0"
30
32
  end
31
33
 
@@ -11,7 +11,7 @@ describe Linode::Linode do
11
11
  @linode.class.should < Linode
12
12
  end
13
13
 
14
- %w(update create list shutdown boot delete reboot clone resize).each do |action|
14
+ %w(update create kvmify list mutate shutdown boot delete reboot clone resize).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
@@ -93,6 +93,80 @@ describe 'Linode' do
93
93
  @linode.api_key.should == @api_key
94
94
  end
95
95
 
96
+ it 'should request the API key only when accessed' do
97
+ @linode = Linode.new(:username => @username, :password => @api_url)
98
+ @linode.stubs(:fetch_api_key).returns 'foo'
99
+ @linode.api_key.should == 'foo'
100
+ end
101
+
102
+ it 'should allow assigning a label to an API key' do
103
+ @json = '{"ERRORARRAY":[],"DATA":{"USERNAME":"ogc","API_KEY":"blahblahblah"},"ACTION":"user.getapikey"}'
104
+ @json.stubs(:parsed_response).returns(JSON.parse(@json))
105
+
106
+ HTTParty.expects(:post).with(@api_url,
107
+ :body => {
108
+ :api_action => 'user.getapikey',
109
+ :api_responseFormat => 'json',
110
+ :username => @username,
111
+ :password => @password,
112
+ :label => 'foobar'
113
+ }
114
+ ).returns(@json)
115
+
116
+ @linode.fetch_api_key(:label => 'foobar')
117
+ end
118
+
119
+ it 'should allow assigning expires when requesting an API key' do
120
+ @json = '{"ERRORARRAY":[],"DATA":{"USERNAME":"ogc","API_KEY":"blahblahblah"},"ACTION":"user.getapikey"}'
121
+ @json.stubs(:parsed_response).returns(JSON.parse(@json))
122
+
123
+ HTTParty.expects(:post).with(@api_url,
124
+ :body => {
125
+ :api_action => 'user.getapikey',
126
+ :api_responseFormat => 'json',
127
+ :username => @username,
128
+ :password => @password,
129
+ :expires => 5
130
+ }
131
+ ).returns(@json)
132
+
133
+ @linode.fetch_api_key(:expires => 5)
134
+ end
135
+
136
+ it 'should allow use 0 to signify a non-expiring api-key when passed a nil :expires' do
137
+ @json = '{"ERRORARRAY":[],"DATA":{"USERNAME":"ogc","API_KEY":"blahblahblah"},"ACTION":"user.getapikey"}'
138
+ @json.stubs(:parsed_response).returns(JSON.parse(@json))
139
+
140
+ HTTParty.expects(:post).with(@api_url,
141
+ :body => {
142
+ :api_action => 'user.getapikey',
143
+ :api_responseFormat => 'json',
144
+ :username => @username,
145
+ :password => @password,
146
+ :expires => 0
147
+ }
148
+ ).returns(@json)
149
+
150
+ @linode.fetch_api_key(:expires => nil)
151
+ end
152
+
153
+ it 'should not specify expires when :expires was not specified' do
154
+ @json = '{"ERRORARRAY":[],"DATA":{"USERNAME":"ogc","API_KEY":"blahblahblah"},"ACTION":"user.getapikey"}'
155
+ @json.stubs(:parsed_response).returns(JSON.parse(@json))
156
+
157
+ HTTParty.expects(:post).with(@api_url,
158
+ :body => {
159
+ :api_action => 'user.getapikey',
160
+ :api_responseFormat => 'json',
161
+ :username => @username,
162
+ :password => @password
163
+ }
164
+ ).returns(@json)
165
+
166
+ @linode.fetch_api_key
167
+ end
168
+
169
+
96
170
  it 'should fail when looking up the API key if API key remote lookup fails' do
97
171
  @linode.stubs(:fetch_api_key).raises
98
172
  lambda { @linode.api_key }.should raise_error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Bradley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -25,13 +25,41 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
61
  version: '1.0'
34
- type: :runtime
62
+ type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
@@ -49,7 +77,6 @@ files:
49
77
  - ".rspec"
50
78
  - CHANGELOG
51
79
  - Gemfile
52
- - Gemfile.lock
53
80
  - MIT-LICENSE
54
81
  - README.md
55
82
  - Rakefile
@@ -111,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
138
  version: '0'
112
139
  requirements: []
113
140
  rubyforge_project:
114
- rubygems_version: 2.2.5
141
+ rubygems_version: 2.5.1
115
142
  signing_key:
116
143
  specification_version: 4
117
144
  summary: a Ruby wrapper for the Linode API
@@ -1,31 +0,0 @@
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)