smoke 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +0 -4
- data/VERSION.yml +1 -1
- data/lib/smoke.rb +5 -0
- data/lib/smoke/request.rb +7 -12
- data/spec/smoke_spec.rb +11 -1
- metadata +5 -5
data/README.markdown
CHANGED
data/VERSION.yml
CHANGED
data/lib/smoke.rb
CHANGED
@@ -32,6 +32,11 @@ module Smoke
|
|
32
32
|
active_sources[source]
|
33
33
|
end
|
34
34
|
|
35
|
+
# Access registered smoke source instances
|
36
|
+
def method_missing(sym)
|
37
|
+
self[sym]
|
38
|
+
end
|
39
|
+
|
35
40
|
# Activates new instances of sources
|
36
41
|
# Source instances are stored within the
|
37
42
|
# @@active_sources class variable for later use
|
data/lib/smoke/request.rb
CHANGED
@@ -15,36 +15,31 @@ module Smoke
|
|
15
15
|
:accept_encoding => "gzip"
|
16
16
|
}
|
17
17
|
|
18
|
-
attr_reader :uri, :content_type, :body
|
18
|
+
attr_reader :uri, :content_type, :body
|
19
19
|
|
20
20
|
def initialize(uri, options = {})
|
21
21
|
@uri, @options = uri, options
|
22
22
|
dispatch
|
23
23
|
end
|
24
24
|
|
25
|
+
def type
|
26
|
+
@type ||= @options[:type] || (SUPPORTED_TYPES.detect{|t| @content_type =~ /#{t}/ } || "unknown").to_sym
|
27
|
+
end
|
28
|
+
|
25
29
|
private
|
26
30
|
def dispatch
|
27
31
|
get = Smoke::Cache.fetch @uri, @@request_options
|
28
32
|
@body = get[:body]
|
29
33
|
@content_type = get[:content_type]
|
30
34
|
|
31
|
-
|
35
|
+
parse! unless @options[:raw_response]
|
32
36
|
|
33
37
|
rescue RestClient::Exception => e
|
34
38
|
Failure.new(@uri, e)
|
35
39
|
end
|
36
40
|
|
37
|
-
def present!
|
38
|
-
set_type
|
39
|
-
parse!
|
40
|
-
end
|
41
|
-
|
42
|
-
def set_type
|
43
|
-
@type = @options[:type] || (SUPPORTED_TYPES.detect{|t| @content_type =~ /#{t}/ } || "unknown").to_sym
|
44
|
-
end
|
45
|
-
|
46
41
|
def parse!
|
47
|
-
case
|
42
|
+
case type
|
48
43
|
when :json, :javascript
|
49
44
|
@body = ::Crack::JSON.parse(@body).symbolize_keys!
|
50
45
|
when :xml
|
data/spec/smoke_spec.rb
CHANGED
@@ -8,7 +8,17 @@ describe Smoke do
|
|
8
8
|
|
9
9
|
describe "active sources" do
|
10
10
|
it "should allow access to sources via an array accessor" do
|
11
|
-
Smoke[:a].should
|
11
|
+
Smoke[:a].should == @source_a
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "accessing via method call" do
|
15
|
+
it "should allow access to the sources via a method call" do
|
16
|
+
Smoke.a.should == @source_a
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should throw an argument error when missing" do
|
20
|
+
Smoke.b.should raise_error(NoMethodError)
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
it "should be able to be renamed" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smoke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Schwarz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-12 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -136,7 +136,7 @@ files:
|
|
136
136
|
- spec/supports/search-web.xml.yql
|
137
137
|
- spec/supports/slashdot.xml
|
138
138
|
- spec/supports/test_source.rb
|
139
|
-
has_rdoc:
|
139
|
+
has_rdoc: true
|
140
140
|
homepage: http://github.com/benschwarz/smoke
|
141
141
|
licenses: []
|
142
142
|
|
@@ -160,10 +160,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements: []
|
161
161
|
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.3.
|
163
|
+
rubygems_version: 1.3.5
|
164
164
|
signing_key:
|
165
165
|
specification_version: 3
|
166
|
-
summary: smoke is a DSL that allows you to
|
166
|
+
summary: smoke is a Ruby based DSL that allows you to query web services such as YQL, RSS / Atom and JSON or XML in an elegant manner.
|
167
167
|
test_files:
|
168
168
|
- spec/core_ext/hash_spec.rb
|
169
169
|
- spec/smoke/cache_spec.rb
|