restfully 0.7.1.rc4 → 0.7.1.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/restfully +2 -15
- data/lib/restfully/session.rb +17 -1
- data/lib/restfully/version.rb +1 -1
- metadata +3 -3
data/bin/restfully
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
|
20
20
|
logger = Logger.new(STDERR)
|
21
21
|
logger.level = Logger::WARN
|
22
|
-
@options = {"logger" => logger
|
22
|
+
@options = {"logger" => logger}
|
23
23
|
|
24
24
|
option_parser = OptionParser.new do |opts|
|
25
25
|
opts.banner = <<BANNER
|
@@ -40,6 +40,7 @@ BANNER
|
|
40
40
|
@options["configuration_file"] = v
|
41
41
|
end
|
42
42
|
opts.on("-r=", "--require=", "Require an additional media-type") do |v|
|
43
|
+
@options["require"] ||= []
|
43
44
|
@options["require"].push(v)
|
44
45
|
end
|
45
46
|
opts.on("--log=", "Outputs log messages to the given file. Defaults to stdout") do |v|
|
@@ -63,24 +64,10 @@ end
|
|
63
64
|
|
64
65
|
option_parser.parse!
|
65
66
|
|
66
|
-
if @options["configuration_file"]
|
67
|
-
@options.merge!(YAML.load_file(
|
68
|
-
File.expand_path(@options["configuration_file"])
|
69
|
-
))
|
70
|
-
end
|
71
|
-
|
72
|
-
@options["require"].each do |r|
|
73
|
-
logger.info "Requiring #{r} media-type..."
|
74
|
-
require "restfully/media_type/#{r.underscore}"
|
75
|
-
end
|
76
|
-
|
77
67
|
if given_uri = ARGV.shift
|
78
68
|
@options["uri"] = given_uri
|
79
69
|
end
|
80
70
|
|
81
|
-
# Compatibility with restfully < 0.6
|
82
|
-
@options["uri"] ||= @options.delete("base_uri")
|
83
|
-
|
84
71
|
@session = Restfully::Session.new(@options)
|
85
72
|
|
86
73
|
def session
|
data/lib/restfully/session.rb
CHANGED
@@ -16,10 +16,26 @@ module Restfully
|
|
16
16
|
def initialize(options = {})
|
17
17
|
@config = options.symbolize_keys
|
18
18
|
@logger = @config.delete(:logger) || Logger.new(STDERR)
|
19
|
+
|
20
|
+
# Read configuration from file:
|
21
|
+
config_file = @config.delete(:configuration_file) || ENV['RESTFULLY_CONFIG']
|
22
|
+
config_file = File.expand_path(config_file) if config_file
|
23
|
+
if config_file && File.file?(config_file) && File.readable?(config_file)
|
24
|
+
@logger.info "Using configuration file located at #{config_file}."
|
25
|
+
@config = YAML.load_file(config_file).symbolize_keys.merge(@config)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Require additional media-types:
|
29
|
+
(@config[:require] || []).each do |r|
|
30
|
+
@logger.info "Requiring #{r} media-type..."
|
31
|
+
require "restfully/media_type/#{r.underscore}"
|
32
|
+
end
|
33
|
+
|
19
34
|
@config[:retry_on_error] ||= 5
|
20
35
|
@config[:wait_before_retry] ||= 5
|
21
36
|
|
22
|
-
|
37
|
+
# Compatibility with :base_uri parameter of Restfully <= 0.6
|
38
|
+
@uri = @config.delete(:uri) || @config.delete(:base_uri)
|
23
39
|
if @uri.nil? || @uri.empty?
|
24
40
|
raise ArgumentError, "You must pass a :uri option."
|
25
41
|
else
|
data/lib/restfully/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfully
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424103
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
9
|
- 1
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 0.7.1.
|
11
|
+
- 5
|
12
|
+
version: 0.7.1.rc5
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Cyril Rohr
|