octopus 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ begin
14
14
  gem.add_dependency "dm-sqlite-adapter", ">= 1.0.0"
15
15
  gem.add_dependency "sinatra", ">= 1.0.0"
16
16
  gem.add_dependency "thin", ">= 1.2.5"
17
+ gem.add_dependency "em-http-request"
17
18
  gem.add_dependency "rack-flash", ">= 0.1.1"
18
19
  gem.add_dependency "rack", ">= 1.0.1"
19
20
  gem.add_development_dependency "shoulda", ">= 2.10.2"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/lib/init.rb CHANGED
@@ -8,6 +8,7 @@ require 'eventmachine'
8
8
  require 'rack-flash'
9
9
  require 'dm-validations'
10
10
  require 'dm-sqlite-adapter'
11
+ require 'em-http-request'
11
12
 
12
13
 
13
14
  # Extensions to Sinatra
@@ -20,17 +20,19 @@ module Grabbers
20
20
  def check_expired_resources
21
21
  net_resources = ::NetResource.expired
22
22
  net_resources.each do |resource|
23
- uri = URI.parse(resource.url)
24
- conn = HttpClient2.connect uri.host, uri.port
23
+ http = EM::HttpRequest.new(resource.url).get
25
24
 
26
- req = conn.get(uri.path)
27
- req.callback{ |response|
25
+ http.callback{ |response|
28
26
  resource.set_next_update
29
27
  if resource_changed?(resource, response)
30
28
  notify_subscribers(resource)
31
29
  update_changed_resource(resource, response)
32
30
  end
33
31
  }
32
+ http.errback {|response|
33
+ # Do something here, maybe setting the resource
34
+ # to be not checked anymore.
35
+ }
34
36
  end
35
37
  end
36
38
 
@@ -50,7 +52,7 @@ module Grabbers
50
52
  #
51
53
  def resource_changed?(resource, response)
52
54
  changed = false
53
- if response.content.hash != resource.last_modified_hash
55
+ if response.hash != resource.last_modified_hash
54
56
  changed = true
55
57
  end
56
58
  end
@@ -62,9 +64,9 @@ module Grabbers
62
64
  # time.
63
65
  #
64
66
  def update_changed_resource(resource, response)
65
- resource.last_modified_hash = response.content.hash
67
+ resource.last_modified_hash = response.hash
66
68
  resource.last_updated = Time.now
67
- resource.body = response.content
69
+ resource.body = response
68
70
  resource.save
69
71
  end
70
72
 
data/octopus.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{octopus}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dave@boomer"]
12
- s.date = %q{2010-11-09}
12
+ s.date = %q{2010-11-12}
13
13
  s.default_executable = %q{octopus}
14
14
  s.description = %q{Grabs stuff off the net and notifies interested subscribers.}
15
15
  s.email = %q{dave.hrycyszyn@headlondon.com}
@@ -84,6 +84,7 @@ Gem::Specification.new do |s|
84
84
  s.add_runtime_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
85
85
  s.add_runtime_dependency(%q<sinatra>, [">= 1.0.0"])
86
86
  s.add_runtime_dependency(%q<thin>, [">= 1.2.5"])
87
+ s.add_runtime_dependency(%q<em-http-request>, [">= 0"])
87
88
  s.add_runtime_dependency(%q<rack-flash>, [">= 0.1.1"])
88
89
  s.add_runtime_dependency(%q<rack>, [">= 1.0.1"])
89
90
  s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
@@ -94,6 +95,7 @@ Gem::Specification.new do |s|
94
95
  s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
95
96
  s.add_dependency(%q<sinatra>, [">= 1.0.0"])
96
97
  s.add_dependency(%q<thin>, [">= 1.2.5"])
98
+ s.add_dependency(%q<em-http-request>, [">= 0"])
97
99
  s.add_dependency(%q<rack-flash>, [">= 0.1.1"])
98
100
  s.add_dependency(%q<rack>, [">= 1.0.1"])
99
101
  s.add_dependency(%q<shoulda>, [">= 2.10.2"])
@@ -105,6 +107,7 @@ Gem::Specification.new do |s|
105
107
  s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
106
108
  s.add_dependency(%q<sinatra>, [">= 1.0.0"])
107
109
  s.add_dependency(%q<thin>, [">= 1.2.5"])
110
+ s.add_dependency(%q<em-http-request>, [">= 0"])
108
111
  s.add_dependency(%q<rack-flash>, [">= 0.1.1"])
109
112
  s.add_dependency(%q<rack>, [">= 1.0.1"])
110
113
  s.add_dependency(%q<shoulda>, [">= 2.10.2"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - dave@boomer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-09 00:00:00 +00:00
18
+ date: 2010-11-12 00:00:00 +00:00
19
19
  default_executable: octopus
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,9 +83,23 @@ dependencies:
83
83
  type: :runtime
84
84
  version_requirements: *id004
85
85
  - !ruby/object:Gem::Dependency
86
- name: rack-flash
86
+ name: em-http-request
87
87
  prerelease: false
88
88
  requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ type: :runtime
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ name: rack-flash
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
89
103
  none: false
90
104
  requirements:
91
105
  - - ">="
@@ -97,11 +111,11 @@ dependencies:
97
111
  - 1
98
112
  version: 0.1.1
99
113
  type: :runtime
100
- version_requirements: *id005
114
+ version_requirements: *id006
101
115
  - !ruby/object:Gem::Dependency
102
116
  name: rack
103
117
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
105
119
  none: false
106
120
  requirements:
107
121
  - - ">="
@@ -113,11 +127,11 @@ dependencies:
113
127
  - 1
114
128
  version: 1.0.1
115
129
  type: :runtime
116
- version_requirements: *id006
130
+ version_requirements: *id007
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: shoulda
119
133
  prerelease: false
120
- requirement: &id007 !ruby/object:Gem::Requirement
134
+ requirement: &id008 !ruby/object:Gem::Requirement
121
135
  none: false
122
136
  requirements:
123
137
  - - ">="
@@ -129,11 +143,11 @@ dependencies:
129
143
  - 2
130
144
  version: 2.10.2
131
145
  type: :development
132
- version_requirements: *id007
146
+ version_requirements: *id008
133
147
  - !ruby/object:Gem::Dependency
134
148
  name: rack-test
135
149
  prerelease: false
136
- requirement: &id008 !ruby/object:Gem::Requirement
150
+ requirement: &id009 !ruby/object:Gem::Requirement
137
151
  none: false
138
152
  requirements:
139
153
  - - ">="
@@ -145,11 +159,11 @@ dependencies:
145
159
  - 2
146
160
  version: 0.5.2
147
161
  type: :development
148
- version_requirements: *id008
162
+ version_requirements: *id009
149
163
  - !ruby/object:Gem::Dependency
150
164
  name: machinist
151
165
  prerelease: false
152
- requirement: &id009 !ruby/object:Gem::Requirement
166
+ requirement: &id010 !ruby/object:Gem::Requirement
153
167
  none: false
154
168
  requirements:
155
169
  - - ">="
@@ -161,7 +175,7 @@ dependencies:
161
175
  - 3
162
176
  version: 1.0.3
163
177
  type: :development
164
- version_requirements: *id009
178
+ version_requirements: *id010
165
179
  description: Grabs stuff off the net and notifies interested subscribers.
166
180
  email: dave.hrycyszyn@headlondon.com
167
181
  executables: