benschwarz-smoke 0.5.8 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -70,10 +70,6 @@ Source definition:
70
70
  Execution:
71
71
 
72
72
  Smoke[:delicious].username("bschwarz").output
73
-
74
- ### CI
75
-
76
- Integrity [is running for smoke](http://integrity.ffolio.net/smoke)
77
73
 
78
74
 
79
75
  ### TODO (working on, just mental notes)
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |gem|
8
8
  gem.name = "smoke"
9
- gem.summary = %Q{smoke is a DSL that allows you to take data from YQL, RSS / Atom}
9
+ gem.summary = %Q{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.}
10
10
  gem.email = "ben.schwarz@gmail.com"
11
11
  gem.homepage = "http://github.com/benschwarz/smoke"
12
12
  gem.authors = ["Ben Schwarz"]
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 8
2
+ :patch: 10
3
3
  :major: 0
4
4
  :minor: 5
data/lib/smoke.rb CHANGED
@@ -1,11 +1,12 @@
1
- __DIR__ = File.dirname(__FILE__)
2
- require File.expand_path(File.join(__DIR__, '..', 'vendor', 'gems', 'environment'))
3
-
4
- Bundler.require_env
5
-
6
1
  require 'logger'
7
2
  require 'digest/md5'
8
3
 
4
+ require 'simple-rss'
5
+ require 'json'
6
+ require 'crack'
7
+ require 'moneta'
8
+ require 'restclient'
9
+
9
10
  module Smoke
10
11
  class << self
11
12
  @@active_sources = {}
@@ -31,6 +32,11 @@ module Smoke
31
32
  active_sources[source]
32
33
  end
33
34
 
35
+ # Access registered smoke source instances
36
+ def method_missing(sym)
37
+ self[sym]
38
+ end
39
+
34
40
  # Activates new instances of sources
35
41
  # Source instances are stored within the
36
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, :type
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
- present! unless @options[:raw_response]
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 @type
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 be_an_instance_of(Smoke::Origin)
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: benschwarz-smoke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
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-08-25 00:00:00 -07:00
12
+ date: 2009-09-12 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,6 @@ files:
138
138
  - spec/supports/test_source.rb
139
139
  has_rdoc: false
140
140
  homepage: http://github.com/benschwarz/smoke
141
- licenses:
142
141
  post_install_message:
143
142
  rdoc_options:
144
143
  - --charset=UTF-8
@@ -159,10 +158,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
158
  requirements: []
160
159
 
161
160
  rubyforge_project:
162
- rubygems_version: 1.3.5
161
+ rubygems_version: 1.2.0
163
162
  signing_key:
164
163
  specification_version: 3
165
- summary: smoke is a DSL that allows you to take data from YQL, RSS / Atom
164
+ 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.
166
165
  test_files:
167
166
  - spec/core_ext/hash_spec.rb
168
167
  - spec/smoke/cache_spec.rb