octopus 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/lib/init.rb +5 -1
- data/lib/octopus/grabbers/generic_http.rb +0 -2
- data/lib/octopus/models/subscription.rb +4 -1
- data/octopus.gemspec +23 -21
- data/test/test_generic_http_grabber.rb +9 -0
- data/test/test_net_resource.rb +0 -1
- data/test/test_octopus.rb +55 -28
- data/test/test_subscription.rb +5 -2
- metadata +19 -17
data/Rakefile
CHANGED
@@ -10,15 +10,15 @@ begin
|
|
10
10
|
gem.email = "dave.hrycyszyn@headlondon.com"
|
11
11
|
gem.homepage = "http://github.com/futurechimp/octopus"
|
12
12
|
gem.authors = ["dave@boomer"]
|
13
|
-
gem.add_dependency "
|
14
|
-
gem.add_dependency "
|
15
|
-
gem.add_dependency "sinatra", ">= 0.
|
13
|
+
gem.add_dependency "data_mapper", ">= 1.0.0"
|
14
|
+
gem.add_dependency "dm-sqlite-adapter", ">= 1.0.0"
|
15
|
+
gem.add_dependency "sinatra", ">= 1.0.0"
|
16
16
|
gem.add_dependency "thin", ">= 1.2.5"
|
17
17
|
gem.add_dependency "rack-flash", ">= 0.1.1"
|
18
18
|
gem.add_dependency "rack", ">= 1.0.1"
|
19
|
-
gem.add_development_dependency "
|
19
|
+
gem.add_development_dependency "shoulda", ">= 2.10.2"
|
20
20
|
gem.add_development_dependency "rack-test", ">= 0.5.2"
|
21
|
-
gem.add_development_dependency "
|
21
|
+
gem.add_development_dependency "machinist", ">= 1.0.3"
|
22
22
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
23
|
end
|
24
24
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/init.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
#
|
3
3
|
require 'rubygems'
|
4
4
|
require 'sinatra'
|
5
|
-
require '
|
5
|
+
require 'data_mapper'
|
6
6
|
require 'ruby-debug'
|
7
7
|
require 'eventmachine'
|
8
8
|
require 'rack-flash'
|
9
9
|
require 'dm-validations'
|
10
|
+
require 'dm-sqlite-adapter'
|
10
11
|
|
11
12
|
|
12
13
|
# Extensions to Sinatra
|
@@ -40,6 +41,9 @@ end
|
|
40
41
|
configure :production, :test, :development do
|
41
42
|
NetResource.auto_migrate! unless NetResource.storage_exists?
|
42
43
|
Subscription.auto_migrate! unless Subscription.storage_exists?
|
44
|
+
end
|
45
|
+
|
46
|
+
configure :production, :development do
|
43
47
|
DataMapper.auto_upgrade!
|
44
48
|
end
|
45
49
|
|
@@ -5,17 +5,20 @@ class Subscription
|
|
5
5
|
include DataMapper::Resource
|
6
6
|
|
7
7
|
# Properties
|
8
|
+
#
|
8
9
|
property :id, Serial
|
9
10
|
property :url, String, :required => true, :length => (1..254)
|
10
11
|
property :created_at, DateTime
|
11
12
|
property :updated_at, DateTime
|
12
13
|
|
13
14
|
# Associations
|
15
|
+
#
|
14
16
|
belongs_to :net_resource
|
15
17
|
|
16
18
|
# Validations
|
19
|
+
#
|
17
20
|
validates_with_method :validate_url
|
18
|
-
|
21
|
+
validates_presence_of :net_resource
|
19
22
|
|
20
23
|
# Checks that the url property is formatted correctly.
|
21
24
|
#
|
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.
|
8
|
+
s.version = "0.0.2"
|
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-
|
12
|
+
s.date = %q{2010-08-13}
|
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}
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"octopus.gemspec",
|
57
57
|
"test/helper.rb",
|
58
58
|
"test/support/blueprints.rb",
|
59
|
+
"test/test_generic_http_grabber.rb",
|
59
60
|
"test/test_net_resource.rb",
|
60
61
|
"test/test_octopus.rb",
|
61
62
|
"test/test_subscription.rb"
|
@@ -66,11 +67,12 @@ Gem::Specification.new do |s|
|
|
66
67
|
s.rubygems_version = %q{1.3.6}
|
67
68
|
s.summary = %q{An experimental octopus implementation.}
|
68
69
|
s.test_files = [
|
69
|
-
"test/
|
70
|
-
"test/test_subscription.rb",
|
71
|
-
"test/test_net_resource.rb",
|
70
|
+
"test/test_net_resource.rb",
|
72
71
|
"test/test_octopus.rb",
|
73
|
-
"test/
|
72
|
+
"test/support/blueprints.rb",
|
73
|
+
"test/helper.rb",
|
74
|
+
"test/test_generic_http_grabber.rb",
|
75
|
+
"test/test_subscription.rb"
|
74
76
|
]
|
75
77
|
|
76
78
|
if s.respond_to? :specification_version then
|
@@ -78,36 +80,36 @@ Gem::Specification.new do |s|
|
|
78
80
|
s.specification_version = 3
|
79
81
|
|
80
82
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
81
|
-
s.add_runtime_dependency(%q<
|
82
|
-
s.add_runtime_dependency(%q<
|
83
|
-
s.add_runtime_dependency(%q<sinatra>, [">= 0.
|
83
|
+
s.add_runtime_dependency(%q<data_mapper>, [">= 1.0.0"])
|
84
|
+
s.add_runtime_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
|
85
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 1.0.0"])
|
84
86
|
s.add_runtime_dependency(%q<thin>, [">= 1.2.5"])
|
85
87
|
s.add_runtime_dependency(%q<rack-flash>, [">= 0.1.1"])
|
86
88
|
s.add_runtime_dependency(%q<rack>, [">= 1.0.1"])
|
87
|
-
s.add_development_dependency(%q<
|
89
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
|
88
90
|
s.add_development_dependency(%q<rack-test>, [">= 0.5.2"])
|
89
|
-
s.add_development_dependency(%q<
|
91
|
+
s.add_development_dependency(%q<machinist>, [">= 1.0.3"])
|
90
92
|
else
|
91
|
-
s.add_dependency(%q<
|
92
|
-
s.add_dependency(%q<
|
93
|
-
s.add_dependency(%q<sinatra>, [">= 0.
|
93
|
+
s.add_dependency(%q<data_mapper>, [">= 1.0.0"])
|
94
|
+
s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
|
95
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
94
96
|
s.add_dependency(%q<thin>, [">= 1.2.5"])
|
95
97
|
s.add_dependency(%q<rack-flash>, [">= 0.1.1"])
|
96
98
|
s.add_dependency(%q<rack>, [">= 1.0.1"])
|
97
|
-
s.add_dependency(%q<
|
99
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
98
100
|
s.add_dependency(%q<rack-test>, [">= 0.5.2"])
|
99
|
-
s.add_dependency(%q<
|
101
|
+
s.add_dependency(%q<machinist>, [">= 1.0.3"])
|
100
102
|
end
|
101
103
|
else
|
102
|
-
s.add_dependency(%q<
|
103
|
-
s.add_dependency(%q<
|
104
|
-
s.add_dependency(%q<sinatra>, [">= 0.
|
104
|
+
s.add_dependency(%q<data_mapper>, [">= 1.0.0"])
|
105
|
+
s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
|
106
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
105
107
|
s.add_dependency(%q<thin>, [">= 1.2.5"])
|
106
108
|
s.add_dependency(%q<rack-flash>, [">= 0.1.1"])
|
107
109
|
s.add_dependency(%q<rack>, [">= 1.0.1"])
|
108
|
-
s.add_dependency(%q<
|
110
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
109
111
|
s.add_dependency(%q<rack-test>, [">= 0.5.2"])
|
110
|
-
s.add_dependency(%q<
|
112
|
+
s.add_dependency(%q<machinist>, [">= 1.0.3"])
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
data/test/test_net_resource.rb
CHANGED
data/test/test_octopus.rb
CHANGED
@@ -108,40 +108,67 @@ class OctopusTest < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
context "on POST to new_or_edit" do
|
112
|
+
context "for a new NetResource" do
|
113
|
+
setup do
|
114
|
+
post '/new_or_edit', {:net_resource => {
|
115
|
+
:url => "http://news.bbc.co.uk/foo/bar/#{DateTime.now.to_s}/blah.rss"
|
116
|
+
}}, basic_auth_creds
|
117
|
+
follow_redirect!
|
118
|
+
end
|
119
|
+
should "go to :new action" do
|
120
|
+
assert_equal "http://example.org/new", last_request.url
|
121
|
+
end
|
122
|
+
end
|
118
123
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
context "for an existing NetResource" do
|
125
|
+
setup do
|
126
|
+
NetResource.make
|
127
|
+
post '/new_or_edit', {:net_resource => {
|
128
|
+
:url => NetResource.first.url
|
129
|
+
}}, basic_auth_creds
|
130
|
+
follow_redirect!
|
131
|
+
end
|
132
|
+
should "go to :show action" do
|
133
|
+
assert_equal "http://example.org/edit/#{NetResource.first.id}", last_request.url
|
134
|
+
end
|
127
135
|
|
128
|
-
|
129
|
-
n = NetResource.make
|
130
|
-
put "/update/#{n.id}", {:id => n.id, :net_resource => {:update_period => 666}}, basic_auth_creds
|
131
|
-
follow_redirect!
|
132
|
-
assert_equal "http://example.org/", last_request.url
|
133
|
-
assert_equal NetResource.first.update_period, 666
|
136
|
+
end
|
134
137
|
end
|
135
138
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
context "on PUT to update" do
|
140
|
+
context "with good params" do
|
141
|
+
setup do
|
142
|
+
n = NetResource.make
|
143
|
+
put "/update/#{n.id}", {:id => n.id, :net_resource => {:update_period => 666}}, basic_auth_creds
|
144
|
+
follow_redirect!
|
145
|
+
should "display /" do
|
146
|
+
assert_equal "http://example.org/", last_request.url
|
147
|
+
end
|
148
|
+
should "set the NetResource's update period" do
|
149
|
+
assert_equal NetResource.first.update_period, 666
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
context "with bad params" do
|
154
|
+
setup do
|
155
|
+
NetResource.make
|
156
|
+
NetResource.first.update(:update_period => 60)
|
157
|
+
put "/update/#{NetResource.first.id}", {:net_resource => {:update_period => 10}}, basic_auth_creds
|
158
|
+
end
|
159
|
+
should "succeed" do
|
160
|
+
assert last_response.ok?
|
161
|
+
end
|
162
|
+
should "redisplay" do
|
163
|
+
assert_equal "http://example.org/update/#{NetResource.first.id}", last_request.url
|
164
|
+
end
|
165
|
+
should "not set the update period" do
|
166
|
+
assert_equal NetResource.first.update_period, 60
|
167
|
+
end
|
168
|
+
end
|
143
169
|
end
|
144
170
|
|
171
|
+
|
145
172
|
private
|
146
173
|
|
147
174
|
def clear_database
|
data/test/test_subscription.rb
CHANGED
@@ -5,8 +5,11 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
5
5
|
context "A Subscription instance" do
|
6
6
|
|
7
7
|
setup do
|
8
|
-
@resource = ::NetResource.new(
|
9
|
-
|
8
|
+
@resource = ::NetResource.new(
|
9
|
+
:url => "http://example.org/foo.rss",
|
10
|
+
:update_period => 25)
|
11
|
+
@resource.subscriptions << Subscription.new(
|
12
|
+
:url => "http://example2.org/callback")
|
10
13
|
@subscription = ::Subscription.new
|
11
14
|
end
|
12
15
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- dave@boomer
|
@@ -14,35 +14,35 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-13 00:00:00 +01:00
|
18
18
|
default_executable: octopus
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: data_mapper
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
|
-
- 0
|
29
|
-
- 10
|
30
28
|
- 1
|
31
|
-
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 1.0.0
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: dm-sqlite-adapter
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
segments:
|
42
|
+
- 1
|
42
43
|
- 0
|
43
|
-
- 10
|
44
44
|
- 0
|
45
|
-
version: 0.
|
45
|
+
version: 1.0.0
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -53,10 +53,10 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
56
58
|
- 0
|
57
|
-
|
58
|
-
- 4
|
59
|
-
version: 0.9.4
|
59
|
+
version: 1.0.0
|
60
60
|
type: :runtime
|
61
61
|
version_requirements: *id003
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
type: :runtime
|
103
103
|
version_requirements: *id006
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: shoulda
|
106
106
|
prerelease: false
|
107
107
|
requirement: &id007 !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
type: :development
|
131
131
|
version_requirements: *id008
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
133
|
+
name: machinist
|
134
134
|
prerelease: false
|
135
135
|
requirement: &id009 !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- octopus.gemspec
|
191
191
|
- test/helper.rb
|
192
192
|
- test/support/blueprints.rb
|
193
|
+
- test/test_generic_http_grabber.rb
|
193
194
|
- test/test_net_resource.rb
|
194
195
|
- test/test_octopus.rb
|
195
196
|
- test/test_subscription.rb
|
@@ -224,8 +225,9 @@ signing_key:
|
|
224
225
|
specification_version: 3
|
225
226
|
summary: An experimental octopus implementation.
|
226
227
|
test_files:
|
227
|
-
- test/support/blueprints.rb
|
228
|
-
- test/test_subscription.rb
|
229
228
|
- test/test_net_resource.rb
|
230
229
|
- test/test_octopus.rb
|
230
|
+
- test/support/blueprints.rb
|
231
231
|
- test/helper.rb
|
232
|
+
- test/test_generic_http_grabber.rb
|
233
|
+
- test/test_subscription.rb
|