bank-crawlers-hapoalim 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path("../../lib/bank_crawlers", __FILE__)
2
+
3
+ require 'bundler/setup'
4
+ require 'hpricot'
5
+ require 'timecop'
6
+ require 'hapoalim'
@@ -0,0 +1,9 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe String do
4
+ describe "#dateify" do
5
+ it "should parse Hapoalim's date format" do
6
+ expect("01/01".dateify).to eq Date.new(2014,1,1)
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bank-crawlers-hapoalim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Maiz Lulkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
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
97
+ - !ruby/object:Gem::Dependency
98
+ name: poltergeist
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.6'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hpricot
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A crappy crawler for a crappy bank interface
126
+ email:
127
+ - maiz@lulk.in
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - bank-crawlers-hapoalim.gemspec
138
+ - lib/bank_crawlers/hapoalim.rb
139
+ - lib/bank_crawlers/hapoalim/cache.rb
140
+ - lib/bank_crawlers/hapoalim/crawler.rb
141
+ - lib/bank_crawlers/hapoalim/hpricot_patches.rb
142
+ - lib/bank_crawlers/hapoalim/parser.rb
143
+ - lib/bank_crawlers/hapoalim/runner.rb
144
+ - lib/bank_crawlers/hapoalim/string_patches.rb
145
+ - lib/bank_crawlers/hapoalim/version.rb
146
+ - run.rb
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
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.2.2
176
+ signing_key:
177
+ specification_version: 4
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