restfully 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/restfully +3 -3
- data/lib/restfully/session.rb +30 -7
- data/lib/restfully/version.rb +1 -1
- metadata +24 -24
data/bin/restfully
CHANGED
@@ -68,9 +68,9 @@ if given_uri = ARGV.shift
|
|
68
68
|
@options["uri"] = given_uri
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
71
|
+
@session = Restfully::Session.new(@options)
|
72
|
+
|
73
|
+
def session; @session; end
|
74
74
|
|
75
75
|
def root
|
76
76
|
@root ||= session.root
|
data/lib/restfully/session.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'uri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
3
5
|
require 'restclient'
|
4
6
|
require 'restclient/components'
|
5
7
|
require 'rack/cache'
|
@@ -47,13 +49,13 @@ module Restfully
|
|
47
49
|
config_file = File.expand_path(config_file) if config_file
|
48
50
|
if config_file && File.file?(config_file) && File.readable?(config_file)
|
49
51
|
@logger.info "Using configuration file located at #{config_file}."
|
50
|
-
@config = YAML.load_file(config_file).symbolize_keys.merge(@config)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
@config = YAML.load_file(config_file).symbolize_keys.merge(@config) do |key, oldval, newval|
|
53
|
+
case oldval
|
54
|
+
when Array then oldval.push(newval).flatten
|
55
|
+
when Hash then oldval.merge(newval)
|
56
|
+
else newval
|
57
|
+
end
|
58
|
+
end
|
57
59
|
end
|
58
60
|
|
59
61
|
@config[:retry_on_error] ||= 5
|
@@ -73,6 +75,27 @@ module Restfully
|
|
73
75
|
authenticate(@config)
|
74
76
|
setup_cache(@config.delete(:cache))
|
75
77
|
|
78
|
+
# Require additional types (e.g.: media-types):
|
79
|
+
(@config[:require] || []).each do |r|
|
80
|
+
@logger.info "Requiring #{r}..."
|
81
|
+
if ::File.exist?(file=File.expand_path(r))
|
82
|
+
require file
|
83
|
+
elsif r =~ /^https?:\/\//i
|
84
|
+
begin
|
85
|
+
resource = get(r)
|
86
|
+
file = Tempfile.new(['restfully', '.rb'])
|
87
|
+
file << resource.response.body
|
88
|
+
file.close
|
89
|
+
require file.path.gsub(/\.rb^/,'')
|
90
|
+
rescue HTTP::Error => e
|
91
|
+
logger.fatal "Can't fetch #{r} from the Internet. Aborting."
|
92
|
+
raise e
|
93
|
+
end
|
94
|
+
else
|
95
|
+
require "restfully/media_type/#{r.underscore}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
76
99
|
yield root, self if block_given?
|
77
100
|
end
|
78
101
|
|
data/lib/restfully/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfully
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-21 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153881280 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '1.5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153881280
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rest-client
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153880820 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153880820
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rest-client-components
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153912940 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153912940
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rack-cache
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153912480 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153912480
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: backports
|
61
|
-
requirement: &
|
61
|
+
requirement: &2153912060 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2153912060
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: addressable
|
72
|
-
requirement: &
|
72
|
+
requirement: &2153911640 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153911640
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rake
|
83
|
-
requirement: &
|
83
|
+
requirement: &2153911140 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0.8'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153911140
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rspec
|
94
|
-
requirement: &
|
94
|
+
requirement: &2153910640 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '2'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2153910640
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: webmock
|
105
|
-
requirement: &
|
105
|
+
requirement: &2153910260 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2153910260
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: autotest
|
116
|
-
requirement: &
|
116
|
+
requirement: &2153909800 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *2153909800
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: autotest-growl
|
127
|
-
requirement: &
|
127
|
+
requirement: &2153909380 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *2153909380
|
136
136
|
description: Consume RESTful APIs effortlessly
|
137
137
|
email:
|
138
138
|
- cyril.rohr@gmail.com
|