klepto 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/klepto/structure.rb +4 -5
- data/lib/klepto/version.rb +1 -1
- data/spec/lib/klepto/bot_spec.rb +27 -26
- data/spec/lib/klepto/structure_spec.rb +1 -1
- metadata +12 -12
data/lib/klepto/structure.rb
CHANGED
@@ -58,12 +58,11 @@ module Klepto
|
|
58
58
|
end
|
59
59
|
|
60
60
|
else
|
61
|
-
|
62
|
-
begin
|
61
|
+
#begin
|
63
62
|
@_hash[meth] = block.call( result )
|
64
|
-
rescue Exception => ex
|
65
|
-
|
66
|
-
end
|
63
|
+
#rescue Exception => ex
|
64
|
+
# @_hash[meth] = options[:default]
|
65
|
+
#end
|
67
66
|
end
|
68
67
|
|
69
68
|
else
|
data/lib/klepto/version.rb
CHANGED
data/spec/lib/klepto/bot_spec.rb
CHANGED
@@ -172,7 +172,8 @@ describe Klepto::Bot do
|
|
172
172
|
|
173
173
|
it 'should structure the data' do
|
174
174
|
@structure.first[:name].should match(/Justin/i)
|
175
|
-
@structure.first[:links].should
|
175
|
+
@structure.first[:links].first.should match(/^http:/i)
|
176
|
+
#@structure.first[:links].should == ["http://t.co/2oSNE36kNM"]
|
176
177
|
@structure.first[:username].should eq '@justinbieber'
|
177
178
|
@structure.first[:last_tweet][:twitter_id].should == @structure.first[:tweets].first[:twitter_id]
|
178
179
|
end
|
@@ -200,32 +201,32 @@ describe Klepto::Bot do
|
|
200
201
|
end
|
201
202
|
end
|
202
203
|
|
203
|
-
describe 'handling an exception within a block' do
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
# describe 'handling an exception within a block' do
|
205
|
+
# before(:each) do
|
206
|
+
# @bot = Klepto::Bot.new("https://twitter.com/justinbieber"){
|
207
|
+
# name 'h1.fullname'
|
208
|
+
# username "span.screen-name"
|
208
209
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
end
|
210
|
+
# tweets 'li.stream-item', :as => :collection do
|
211
|
+
# twitter_id do |node|
|
212
|
+
# node['data-item-id']
|
213
|
+
# end
|
214
|
+
# tweet '.content p', :css
|
215
|
+
# permalink '.time a', :css, :attr => :href
|
216
|
+
# timestamp '._timestamp' do |node|
|
217
|
+
# raise Exception
|
218
|
+
# end
|
219
|
+
# end
|
220
|
+
# }
|
221
|
+
# @structure = @bot.resources
|
222
|
+
# end
|
223
|
+
|
224
|
+
# it 'should set the value to nil when an exception is raised' do
|
225
|
+
# @structure.first[:name].should match(/Justin/i)
|
226
|
+
# @structure.first[:tweets].first.keys.should include(:timestamp)
|
227
|
+
# @structure.first[:tweets].first[:timestamp].should be(nil)
|
228
|
+
# end
|
229
|
+
# end
|
229
230
|
|
230
231
|
describe 'a page missing a selector' do
|
231
232
|
before(:each) do
|
@@ -36,7 +36,7 @@ describe Klepto::Structure do
|
|
36
36
|
|
37
37
|
it 'should structure the data' do
|
38
38
|
@structure[:name].should match(/Justin/i)
|
39
|
-
@structure[:links].should
|
39
|
+
@structure[:links].first.should match(/^http:/i)
|
40
40
|
@structure[:username].should eq '@justinbieber'
|
41
41
|
@structure[:last_tweet][:twitter_id].should == @structure[:tweets].first[:twitter_id]
|
42
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klepto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: poltergeist
|
16
|
-
requirement: &
|
16
|
+
requirement: &70291728510800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70291728510800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: capybara
|
27
|
-
requirement: &
|
27
|
+
requirement: &70291728508300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.0.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70291728508300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &70291728505540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.5.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70291728505540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &70291728504060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70291728504060
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: multi_json
|
60
|
-
requirement: &
|
60
|
+
requirement: &70291728495700 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '1.0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70291728495700
|
69
69
|
description: Tearing up web pages into ActiveRecord resources
|
70
70
|
email:
|
71
71
|
- github@coryodaniel.com
|