bankcrawlers-hapoalim 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{bank-crawlers-hapoalim.gemspec → bankcrawlers-hapoalim.gemspec} +9 -8
- data/lib/bank_crawlers/hapoalim.rb +6 -3
- data/lib/bank_crawlers/hapoalim/cache.rb +4 -4
- data/lib/bank_crawlers/hapoalim/crawler.rb +7 -11
- data/lib/bank_crawlers/hapoalim/hpricot_patches.rb +6 -0
- data/lib/bank_crawlers/hapoalim/parser.rb +8 -10
- data/lib/bank_crawlers/hapoalim/{monkey_patches.rb → string_patches.rb} +0 -7
- data/spec/cache_spec.rb +23 -0
- data/spec/crawler_spec.rb +31 -0
- data/spec/fixtures/transactions.html +1502 -0
- data/spec/hpricot_patches_spec.rb +15 -0
- data/spec/parser_spec.rb +23 -0
- data/spec/runner_spec.rb +35 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/string_patches_spec.rb +9 -0
- metadata +61 -30
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Hpricot::Elem do
|
4
|
+
describe "#clean_text" do
|
5
|
+
let(:content) { "<td>A<script>alert('Hey')</script>B</td>" }
|
6
|
+
let(:result) { "AB" }
|
7
|
+
let(:td) { Hpricot(content).search('td').first }
|
8
|
+
|
9
|
+
subject(:cleaned_text){ td.clean_text }
|
10
|
+
|
11
|
+
it "should clean script" do
|
12
|
+
expect(cleaned_text).to eq result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
include BankCrawlers::Hapoalim
|
4
|
+
|
5
|
+
describe Parser do
|
6
|
+
let(:html) { File.read(Dir.pwd + "/spec/fixtures/transactions.html") }
|
7
|
+
|
8
|
+
subject(:parser) do
|
9
|
+
Parser.new(html)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#balance" do
|
13
|
+
it "should get the last amount" do
|
14
|
+
expect(parser.balance).to eq(43153.06)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#transactions" do
|
19
|
+
it "should have 2 transactions" do
|
20
|
+
expect(parser.transactions.length).to be(2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
include BankCrawlers::Hapoalim
|
4
|
+
|
5
|
+
describe Runner do
|
6
|
+
let(:html) { File.read(Dir.pwd + "/spec/fixtures/transactions.html") }
|
7
|
+
|
8
|
+
subject(:runner) do
|
9
|
+
Runner.new 'user', 'id', 'pass'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#run" do
|
13
|
+
context 'given cache is empty' do
|
14
|
+
before do
|
15
|
+
Cache.new.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'gets from the crawler' do
|
19
|
+
allow_any_instance_of(Crawler).to receive(:transaction_table).and_return(html)
|
20
|
+
runner.run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'given cache is set' do
|
25
|
+
before do
|
26
|
+
Cache.new.set("!")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'gets from the cache' do
|
30
|
+
allow_any_instance_of(Cache).to receive(:get).and_return(html)
|
31
|
+
runner.run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,111 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankcrawlers-hapoalim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maiz Lulkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.14'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: timecop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: capybara
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.4.4
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.4.4
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: poltergeist
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '1.6'
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '1.6'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: hpricot
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
description: A crappy crawler for a crappy bank interface
|
@@ -115,21 +129,30 @@ executables: []
|
|
115
129
|
extensions: []
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
|
-
- .gitignore
|
132
|
+
- ".gitignore"
|
119
133
|
- Gemfile
|
120
134
|
- LICENSE.txt
|
121
135
|
- README.md
|
122
136
|
- Rakefile
|
123
|
-
-
|
137
|
+
- bankcrawlers-hapoalim.gemspec
|
124
138
|
- lib/bank_crawlers/hapoalim.rb
|
125
139
|
- lib/bank_crawlers/hapoalim/cache.rb
|
126
140
|
- lib/bank_crawlers/hapoalim/crawler.rb
|
127
|
-
- lib/bank_crawlers/hapoalim/
|
141
|
+
- lib/bank_crawlers/hapoalim/hpricot_patches.rb
|
128
142
|
- lib/bank_crawlers/hapoalim/parser.rb
|
129
143
|
- lib/bank_crawlers/hapoalim/runner.rb
|
144
|
+
- lib/bank_crawlers/hapoalim/string_patches.rb
|
130
145
|
- lib/bank_crawlers/hapoalim/version.rb
|
131
146
|
- run.rb
|
132
|
-
|
147
|
+
- spec/cache_spec.rb
|
148
|
+
- spec/crawler_spec.rb
|
149
|
+
- spec/fixtures/transactions.html
|
150
|
+
- spec/hpricot_patches_spec.rb
|
151
|
+
- spec/parser_spec.rb
|
152
|
+
- spec/runner_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/string_patches_spec.rb
|
155
|
+
homepage: https://github.com/joaomilho/bank-crawlers-hapoalim
|
133
156
|
licenses:
|
134
157
|
- MIT
|
135
158
|
metadata: {}
|
@@ -139,18 +162,26 @@ require_paths:
|
|
139
162
|
- lib
|
140
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
164
|
requirements:
|
142
|
-
- -
|
165
|
+
- - ">="
|
143
166
|
- !ruby/object:Gem::Version
|
144
167
|
version: '0'
|
145
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
169
|
requirements:
|
147
|
-
- -
|
170
|
+
- - ">="
|
148
171
|
- !ruby/object:Gem::Version
|
149
172
|
version: '0'
|
150
173
|
requirements: []
|
151
174
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.2.2
|
153
176
|
signing_key:
|
154
177
|
specification_version: 4
|
155
|
-
summary: A crappy crawler for a crappy bank interface
|
156
|
-
test_files:
|
178
|
+
summary: A crappy crawler for a crappy bank interface. Deal with it.
|
179
|
+
test_files:
|
180
|
+
- spec/cache_spec.rb
|
181
|
+
- spec/crawler_spec.rb
|
182
|
+
- spec/fixtures/transactions.html
|
183
|
+
- spec/hpricot_patches_spec.rb
|
184
|
+
- spec/parser_spec.rb
|
185
|
+
- spec/runner_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
- spec/string_patches_spec.rb
|