restfully 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/restfully CHANGED
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The command line Restfully client
3
3
 
4
- lib_dir = File.expand_path(File.dirname(__FILE__) + '/../lib')
5
- $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include? lib_dir
6
-
7
4
  require 'restfully'
8
5
  require 'optparse'
9
6
  require 'logger'
@@ -71,10 +68,8 @@ if given_uri = ARGV.shift
71
68
  @options["uri"] = given_uri
72
69
  end
73
70
 
74
- @session = Restfully::Session.new(@options)
75
-
76
71
  def session
77
- @session
72
+ @session ||= Restfully::Session.new(@options)
78
73
  end
79
74
 
80
75
  def root
@@ -93,32 +88,36 @@ HOME = ENV['HOME'] || ENV['HOMEPATH']
93
88
  IRB.conf[:SAVE_HISTORY] = 100
94
89
  IRB.conf[:HISTORY_FILE] = "#{HOME}/.irb-save-history"
95
90
 
96
- module Readline
97
- module History
98
- LOG = "#{HOME}/.irb-history"
99
-
100
- def self.write_log(line)
101
- File.open(LOG, 'ab') {|f|
102
- f << "#{line}\n"
103
- }
104
- end
91
+ # Raises an error on Windows, so disabling it.
92
+ if RUBY_PLATFORM !~ /(win|w)32$/
93
+ module Readline
94
+ module History
95
+ LOG = "#{HOME}/.irb-history"
96
+
97
+ def self.write_log(line)
98
+ File.open(LOG, 'ab') {|f|
99
+ f << "#{line}\n"
100
+ }
101
+ end
105
102
 
106
- def self.start_session_log
107
- write_log("\n")
103
+ def self.start_session_log
104
+ write_log("\n")
105
+ end
108
106
  end
109
- end
110
107
 
111
- alias :old_readline :readline
112
- def readline(*args)
113
- ln = old_readline(*args)
114
- begin
115
- History.write_log(ln)
116
- rescue
108
+ alias :old_readline :readline
109
+ def readline(*args)
110
+ ln = old_readline(*args)
111
+ begin
112
+ History.write_log(ln)
113
+ rescue
114
+ end
115
+ ln
117
116
  end
118
- ln
119
117
  end
118
+ Readline::History.start_session_log
120
119
  end
121
- Readline::History.start_session_log
120
+
122
121
  ARGV.clear
123
122
  ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
124
123
  IRB.start
@@ -198,9 +198,8 @@ module Restfully
198
198
 
199
199
  # Build the resource after loading.
200
200
  def build
201
- metaclass = class << self; self; end
202
201
  extend Collection if collection?
203
-
202
+ metaclass = class << self; self; end
204
203
  response.links.each do |link|
205
204
  metaclass.send(:define_method, link.id.to_sym) do |*args|
206
205
  session.get(link.href, :head => {
@@ -1,3 +1,3 @@
1
1
  module Restfully
2
- VERSION = "0.8.6"
2
+ VERSION = "0.8.7"
3
3
  end
@@ -154,7 +154,7 @@ describe Restfully::MediaType::ApplicationVndBonfireXml do
154
154
  @expected_compute_hash,
155
155
  :serialization => {"__type__" => "compute"}
156
156
  )
157
- serialized.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <startup href=\"file:///path/to/startup-script/sh\"/>\n <name>Compute name</name>\n <instance_type>small</instance_type>\n <link id=\"0\" href=\"/locations/fr-inria\" rel=\"location\" type=\"application/vnd.bonfire+xml\"/>\n <link id=\"1\" href=\"/locations/uk-epcc/computes/1\" rel=\"self\"/>\n <context>\n <bonfire_credentials>crohr:p4ssw0rd</bonfire_credentials>\n <monitoring_ip>123.123.123.2</monitoring_ip>\n </context>\n <nic id=\"0\">\n <device>eth0</device>\n <mac>AA:AA:AA:AA</mac>\n <network href=\"/locations/fr-inria/networks/1\"/>\n <ip>123.123.123.123</ip>\n </nic>\n <nic id=\"1\">\n <device>eth1</device>\n <mac>BB:BB:BB:BB</mac>\n <network href=\"/locations/fr-inria/networks/2\"/>\n <ip>123.123.124.2</ip>\n </nic>\n <description>Compute description</description>\n <disk id=\"0\">\n <type>OS</type>\n <storage href=\"/locations/fr-inria/storages/1\"/>\n <target>sda</target>\n </disk>\n <disk id=\"1\">\n <type>CDROM</type>\n <storage href=\"/locations/fr-inria/storages/2\"/>\n <target>sdc</target>\n </disk>\n <state>ACTIVE</state>\n</compute>\n"
157
+ serialized.split("\n").sort.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <name>Compute name</name>\n <startup href=\"file:///path/to/startup-script/sh\"/>\n <instance_type>small</instance_type>\n <description>Compute description</description>\n <nic id=\"0\">\n <device>eth0</device>\n <mac>AA:AA:AA:AA</mac>\n <network href=\"/locations/fr-inria/networks/1\"/>\n <ip>123.123.123.123</ip>\n </nic>\n <nic id=\"1\">\n <device>eth1</device>\n <mac>BB:BB:BB:BB</mac>\n <network href=\"/locations/fr-inria/networks/2\"/>\n <ip>123.123.124.2</ip>\n </nic>\n <context>\n <bonfire_credentials>crohr:p4ssw0rd</bonfire_credentials>\n <monitoring_ip>123.123.123.2</monitoring_ip>\n </context>\n <link id=\"0\" href=\"/locations/fr-inria\" rel=\"location\" type=\"application/vnd.bonfire+xml\"/>\n <link id=\"1\" href=\"/locations/uk-epcc/computes/1\" rel=\"self\"/>\n <disk id=\"0\">\n <type>OS</type>\n <storage href=\"/locations/fr-inria/storages/1\"/>\n <target>sda</target>\n </disk>\n <disk id=\"1\">\n <type>CDROM</type>\n <storage href=\"/locations/fr-inria/storages/2\"/>\n <target>sdc</target>\n </disk>\n <state>ACTIVE</state>\n</compute>\n".split("\n").sort
158
158
  end
159
159
 
160
160
  it "should correctly deal with XML::Node elements" do
@@ -163,7 +163,7 @@ describe Restfully::MediaType::ApplicationVndBonfireXml do
163
163
  'metrics' => XML::Node.new_cdata('<metric>hello,world</metric>')
164
164
  }
165
165
  }, :serialization => {"__type__" => "compute"})
166
- serialized.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <context>\n <metrics><![CDATA[<metric>hello,world</metric>]]></metrics>\n </context>\n</compute>\n"
166
+ serialized.split("\n").sort.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <context>\n <metrics><![CDATA[<metric>hello,world</metric>]]></metrics>\n </context>\n</compute>\n".split("\n").sort
167
167
  end
168
168
 
169
169
  it "should correctly deal with SAVE_AS elements" do
@@ -171,13 +171,13 @@ describe Restfully::MediaType::ApplicationVndBonfireXml do
171
171
  {
172
172
  :name => "whatever",
173
173
  :disk => [{
174
- :storage => {"href" => "/somewhere"},
175
- :save_as => {:name => "name of storage"}
174
+ :save_as => {:name => "name of storage"},
175
+ :storage => {"href" => "/somewhere"}
176
176
  }]
177
177
  },
178
178
  :serialization => {"__type__" => "compute"}
179
179
  )
180
- serialized.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <name>whatever</name>\n <disk id=\"0\">\n <save_as name=\"name of storage\"/>\n <storage href=\"/somewhere\"/>\n </disk>\n</compute>\n"
180
+ serialized.split("\n").sort.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<compute xmlns=\"http://api.bonfire-project.eu/doc/schemas/occi\">\n <name>whatever</name>\n <disk id=\"0\">\n <save_as name=\"name of storage\"/>\n <storage href=\"/somewhere\"/>\n </disk>\n</compute>\n".split("\n").sort
181
181
  end
182
182
  end
183
183
  end
metadata CHANGED
@@ -1,191 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: restfully
3
- version: !ruby/object:Gem::Version
4
- hash: 51
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.7
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 6
10
- version: 0.8.6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Cyril Rohr
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-28 00:00:00 +02:00
12
+ date: 2011-07-28 00:00:00.000000000 +02:00
19
13
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: json
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2153574600 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
19
+ requirements:
27
20
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 5
30
- segments:
31
- - 1
32
- - 5
33
- version: "1.5"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.5'
34
23
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rest-client
38
24
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2153574600
26
+ - !ruby/object:Gem::Dependency
27
+ name: rest-client
28
+ requirement: &2153574140 !ruby/object:Gem::Requirement
40
29
  none: false
41
- requirements:
30
+ requirements:
42
31
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 1
47
- - 6
48
- version: "1.6"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
49
34
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: rest-client-components
53
35
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2153574140
37
+ - !ruby/object:Gem::Dependency
38
+ name: rest-client-components
39
+ requirement: &2153573760 !ruby/object:Gem::Requirement
55
40
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
63
45
  type: :runtime
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: rack-cache
67
46
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2153573760
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-cache
50
+ requirement: &2153573300 !ruby/object:Gem::Requirement
69
51
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
77
56
  type: :runtime
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: backports
81
57
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2153573300
59
+ - !ruby/object:Gem::Dependency
60
+ name: backports
61
+ requirement: &2153572880 !ruby/object:Gem::Requirement
83
62
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
91
67
  type: :runtime
92
- version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
94
- name: addressable
95
68
  prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *2153572880
70
+ - !ruby/object:Gem::Dependency
71
+ name: addressable
72
+ requirement: &2153572460 !ruby/object:Gem::Requirement
97
73
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
105
78
  type: :runtime
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: rake
109
79
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
80
+ version_requirements: *2153572460
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: &2153571960 !ruby/object:Gem::Requirement
111
84
  none: false
112
- requirements:
85
+ requirements:
113
86
  - - ~>
114
- - !ruby/object:Gem::Version
115
- hash: 27
116
- segments:
117
- - 0
118
- - 8
119
- version: "0.8"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.8'
120
89
  type: :development
121
- version_requirements: *id007
122
- - !ruby/object:Gem::Dependency
123
- name: rspec
124
90
  prerelease: false
125
- requirement: &id008 !ruby/object:Gem::Requirement
91
+ version_requirements: *2153571960
92
+ - !ruby/object:Gem::Dependency
93
+ name: rspec
94
+ requirement: &2153603940 !ruby/object:Gem::Requirement
126
95
  none: false
127
- requirements:
96
+ requirements:
128
97
  - - ~>
129
- - !ruby/object:Gem::Version
130
- hash: 7
131
- segments:
132
- - 2
133
- version: "2"
98
+ - !ruby/object:Gem::Version
99
+ version: '2'
134
100
  type: :development
135
- version_requirements: *id008
136
- - !ruby/object:Gem::Dependency
137
- name: webmock
138
101
  prerelease: false
139
- requirement: &id009 !ruby/object:Gem::Requirement
102
+ version_requirements: *2153603940
103
+ - !ruby/object:Gem::Dependency
104
+ name: webmock
105
+ requirement: &2153603560 !ruby/object:Gem::Requirement
140
106
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- hash: 3
145
- segments:
146
- - 0
147
- version: "0"
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
148
111
  type: :development
149
- version_requirements: *id009
150
- - !ruby/object:Gem::Dependency
151
- name: autotest
152
112
  prerelease: false
153
- requirement: &id010 !ruby/object:Gem::Requirement
113
+ version_requirements: *2153603560
114
+ - !ruby/object:Gem::Dependency
115
+ name: autotest
116
+ requirement: &2153603100 !ruby/object:Gem::Requirement
154
117
  none: false
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- hash: 3
159
- segments:
160
- - 0
161
- version: "0"
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
162
122
  type: :development
163
- version_requirements: *id010
164
- - !ruby/object:Gem::Dependency
165
- name: autotest-growl
166
123
  prerelease: false
167
- requirement: &id011 !ruby/object:Gem::Requirement
124
+ version_requirements: *2153603100
125
+ - !ruby/object:Gem::Dependency
126
+ name: autotest-growl
127
+ requirement: &2153602680 !ruby/object:Gem::Requirement
168
128
  none: false
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- hash: 3
173
- segments:
174
- - 0
175
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
176
133
  type: :development
177
- version_requirements: *id011
134
+ prerelease: false
135
+ version_requirements: *2153602680
178
136
  description: Consume RESTful APIs effortlessly
179
- email:
137
+ email:
180
138
  - cyril.rohr@gmail.com
181
- executables:
139
+ executables:
182
140
  - restfully
183
141
  extensions: []
184
-
185
- extra_rdoc_files:
142
+ extra_rdoc_files:
186
143
  - LICENSE
187
144
  - README.md
188
- files:
145
+ files:
189
146
  - bin/restfully
190
147
  - lib/restfully/collection.rb
191
148
  - lib/restfully/error.rb
@@ -236,40 +193,30 @@ files:
236
193
  has_rdoc: true
237
194
  homepage: http://github.com/crohr/restfully
238
195
  licenses: []
239
-
240
196
  post_install_message:
241
- rdoc_options:
197
+ rdoc_options:
242
198
  - --charset=UTF-8
243
- require_paths:
199
+ require_paths:
244
200
  - lib
245
- required_ruby_version: !ruby/object:Gem::Requirement
201
+ required_ruby_version: !ruby/object:Gem::Requirement
246
202
  none: false
247
- requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- hash: 31
251
- segments:
252
- - 1
253
- - 8
254
- version: "1.8"
255
- required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '1.8'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
256
208
  none: false
257
- requirements:
258
- - - ">="
259
- - !ruby/object:Gem::Version
260
- hash: 9
261
- segments:
262
- - 1
263
- - 3
264
- version: "1.3"
209
+ requirements:
210
+ - - ! '>='
211
+ - !ruby/object:Gem::Version
212
+ version: '1.3'
265
213
  requirements: []
266
-
267
214
  rubyforge_project:
268
215
  rubygems_version: 1.6.2
269
216
  signing_key:
270
217
  specification_version: 3
271
218
  summary: Consume RESTful APIs effortlessly
272
- test_files:
219
+ test_files:
273
220
  - spec/fixtures/bonfire-collection-with-fragments.xml
274
221
  - spec/fixtures/bonfire-compute-existing.xml
275
222
  - spec/fixtures/bonfire-empty-collection.xml