adp-downloader 0.2.5 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a4956fc33bceb12c43fae6e8a2667828524b0e86
4
- data.tar.gz: 70acb5b0cda437e1ba652f854d2032012059d747
2
+ SHA256:
3
+ metadata.gz: 384b5c0fe414958a0fb3bd2acf06a0dd8807658c52f257def6b7916518f87cb2
4
+ data.tar.gz: fefb3828e092784a1a6617a4e9e956011394185032c18fbe51beed6ac8fa11b7
5
5
  SHA512:
6
- metadata.gz: d811e831b8ce53644974f6e2b9361f33b009cc4c2cb835436241b16224d2433ff03fe21d58d0ef1aea7a9cdc4826c4ba8ebc3f5614690d078de5ff3d52ad6109
7
- data.tar.gz: 8e907f3793fe04cd286bab418d0fb4d1b4484a95e3cb4e615fbda091bfa776f1d6a46975af1cc8c91662a7e3e8063e82a16116a006835d7d649c9e5988c86083
6
+ metadata.gz: f7ab75292bea4ff60aa1bce6292d6383feb7e67fb321f305a6e37ded16bf1c80ef684d92820e0ba1f486bb14319c4eb6ee4ff96b1b5b987895ecc4195568a2d2
7
+ data.tar.gz: 037f878196c368e8d38673dd1ec8d3b762982c0890db4915ef2ff09ed5282eeae59c9c9543fc4531b1c184a4d04cc88e201fc0eda872ba51fd266b871f073d8f
@@ -6,6 +6,27 @@ Changelog
6
6
  * -
7
7
 
8
8
 
9
+ ## 0.3.2
10
+
11
+ * [6d3edab][] Fix bug when displaying auth error messages
12
+
13
+ [6d3edab]: ../../commit/6d3edab
14
+
15
+
16
+ ## 0.3.1
17
+
18
+ * [9236c97][] Display better error message on auth error
19
+
20
+ [9236c97]: ../../commit/9236c97
21
+
22
+
23
+ ## 0.3.0
24
+
25
+ * [e05377b][] Disable netrc authentication in favor of cookie only :(
26
+
27
+ [e05377b]: ../../commit/e05377b
28
+
29
+
9
30
  ## 0.2.5
10
31
 
11
32
  * [00e3ff6][] Gracefully handle empty tax or pay statements
@@ -1,49 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adp-downloader (0.2.2)
4
+ adp-downloader (0.2.5)
5
5
  mechanize (~> 2.7)
6
6
  netrc (~> 0.11)
7
- parallel (~> 1.10)
7
+ parallel (~> 1.12)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- coderay (1.1.1)
13
- domain_name (0.5.20161129)
12
+ coderay (1.1.2)
13
+ connection_pool (2.2.2)
14
+ domain_name (0.5.20180417)
14
15
  unf (>= 0.0.5, < 1.0.0)
15
16
  http-cookie (1.0.3)
16
17
  domain_name (~> 0.5)
17
- mechanize (2.7.5)
18
+ mechanize (2.7.6)
18
19
  domain_name (~> 0.5, >= 0.5.1)
19
20
  http-cookie (~> 1.0)
20
21
  mime-types (>= 1.17.2)
21
22
  net-http-digest_auth (~> 1.1, >= 1.1.1)
22
- net-http-persistent (~> 2.5, >= 2.5.2)
23
+ net-http-persistent (>= 2.5.2)
23
24
  nokogiri (~> 1.6)
24
25
  ntlm-http (~> 0.1, >= 0.1.1)
25
26
  webrobots (>= 0.0.9, < 0.2)
26
- method_source (0.8.2)
27
- mime-types (3.1)
27
+ method_source (0.9.0)
28
+ mime-types (3.2.2)
28
29
  mime-types-data (~> 3.2015)
29
- mime-types-data (3.2016.0521)
30
- mini_portile2 (2.1.0)
31
- net-http-digest_auth (1.4)
32
- net-http-persistent (2.9.4)
30
+ mime-types-data (3.2018.0812)
31
+ mini_portile2 (2.3.0)
32
+ net-http-digest_auth (1.4.1)
33
+ net-http-persistent (3.0.0)
34
+ connection_pool (~> 2.2)
33
35
  netrc (0.11.0)
34
- nokogiri (1.7.0.1)
35
- mini_portile2 (~> 2.1.0)
36
+ nokogiri (1.8.4)
37
+ mini_portile2 (~> 2.3.0)
36
38
  ntlm-http (0.1.1)
37
- parallel (1.10.0)
38
- pry (0.10.4)
39
+ parallel (1.12.1)
40
+ pry (0.11.3)
39
41
  coderay (~> 1.1.0)
40
- method_source (~> 0.8.1)
41
- slop (~> 3.4)
42
- rake (10.5.0)
43
- slop (3.6.0)
42
+ method_source (~> 0.9.0)
43
+ rake (12.3.1)
44
44
  unf (0.1.4)
45
45
  unf_ext
46
- unf_ext (0.0.7.2)
46
+ unf_ext (0.0.7.5)
47
47
  webrobots (0.1.2)
48
48
 
49
49
  PLATFORMS
@@ -51,9 +51,9 @@ PLATFORMS
51
51
 
52
52
  DEPENDENCIES
53
53
  adp-downloader!
54
- bundler (~> 1.13)
55
- pry (~> 0.10.0)
56
- rake (~> 10.0)
54
+ bundler (~> 1.16)
55
+ pry (~> 0.11)
56
+ rake (~> 12.3)
57
57
 
58
58
  BUNDLED WITH
59
- 1.13.7
59
+ 1.16.1
data/README.md CHANGED
@@ -13,6 +13,12 @@ that have not yet been downloaded.
13
13
 
14
14
  ## Upgrading
15
15
 
16
+ ### 0.2.x --> 0.3.x
17
+
18
+ Non-interactive `netrc` authentication is currently not supported due to
19
+ ADP requiring javascript to perform login. Unfortunately, the only way
20
+ to use the app is to ask for the `smsession` cookie from `stdin`. :(
21
+
16
22
  ### 0.2.x --> 0.2.3
17
23
 
18
24
  Statements can now be downloaded by employer/account. This is not a
data/Rakefile CHANGED
@@ -1,9 +1,22 @@
1
1
  require "rubygems/package_task"
2
2
 
3
- task :default => [:gem]
3
+ SPEC = eval(File.read("adp-downloader.gemspec"))
4
4
 
5
- spec = eval(File.read("adp-downloader.gemspec"))
6
- Gem::PackageTask.new(spec) do |pkg|
5
+ Gem::PackageTask.new(SPEC) do |pkg|
7
6
  pkg.need_zip = false
8
7
  pkg.need_tar = false
9
8
  end
9
+
10
+ task :default => [:gem]
11
+
12
+ task :install => [:gem] do
13
+ sh "gem install #{gem_path}"
14
+ end
15
+
16
+ task :publish => [:gem] do
17
+ sh "gem push #{gem_path}"
18
+ end
19
+
20
+ def gem_path
21
+ "pkg/adp-downloader-#{SPEC.version}.gem"
22
+ end
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency "mechanize", "~> 2.7"
24
24
  s.add_dependency "netrc", "~> 0.11"
25
- s.add_dependency "parallel", "~> 1.10"
26
- s.add_development_dependency "bundler", "~> 1.13"
27
- s.add_development_dependency "rake", "~> 10.0"
28
- s.add_development_dependency "pry", "~> 0.10.0"
25
+ s.add_dependency "parallel", "~> 1.12"
26
+ s.add_development_dependency "bundler", "~> 1.16"
27
+ s.add_development_dependency "rake", "~> 12.3"
28
+ s.add_development_dependency "pry", "~> 0.11"
29
29
  end
@@ -8,7 +8,7 @@ module ADPDownloader
8
8
  attr_accessor :employer
9
9
 
10
10
  def credentials
11
- from_netrc or from_stdin
11
+ @creds ||= from_stdin
12
12
  end
13
13
 
14
14
  def quiet?
@@ -16,8 +16,12 @@ module ADPDownloader
16
16
  end
17
17
 
18
18
  private
19
- def creds(username, password)
20
- { username: username, password: password }
19
+ def creds(username, password, smsession_cookie)
20
+ {
21
+ username: username,
22
+ password: password,
23
+ smsession_cookie: smsession_cookie,
24
+ }
21
25
  end
22
26
 
23
27
  def from_netrc
@@ -27,13 +31,26 @@ module ADPDownloader
27
31
  creds(username, password) if username and password
28
32
  end
29
33
 
34
+ def read_cookie_file
35
+ cookie_file = "cookie.txt"
36
+ unless File.exists? cookie_file
37
+ puts "Please create a file called 'cookie.txt' in this directory and"
38
+ puts "paste the value of the SMSESSION cookie in it."
39
+ exit 1
40
+ end
41
+ File.read(cookie_file).chomp
42
+ end
43
+
30
44
  def from_stdin
31
- print "Username: "
32
- username = STDIN.gets.chomp
33
- print "Password: "
34
- password = STDIN.noecho(&:gets).chomp
35
- puts
36
- creds(username, password)
45
+ # FIXME: https://github.com/andersonvom/adp-downloader/issues/6
46
+ #print "Username: "
47
+ #username = STDIN.gets.chomp
48
+ #print "Password: "
49
+ #password = STDIN.noecho(&:gets).chomp
50
+ #puts
51
+ username = 'currently-not-working'
52
+ password = 'currently-not-working'
53
+ creds(username, password, read_cookie_file)
37
54
  end
38
55
  end
39
56
  end
@@ -23,7 +23,7 @@ module ADPDownloader
23
23
 
24
24
  def download_statement_files(statement)
25
25
  if statement.json_uri
26
- json = @http_client.get(full_url(statement.json_uri)) if statement.json_uri
26
+ json = _get_or_log(statement) if statement.json_uri
27
27
  _save(JSON.pretty_generate(statement.merge(json)), statement.json)
28
28
  end
29
29
 
@@ -42,21 +42,23 @@ module ADPDownloader
42
42
  end
43
43
  end
44
44
 
45
- def get_all_pay_statements
46
- puts "Downloading all pay statements..." unless Config.quiet?
47
- Parallel.each(pay_statements) do |statement|
45
+ def get_statements(type, statements)
46
+ puts "Downloading all #{type} statements..." unless Config.quiet?
47
+ Parallel.each(statements) do |statement|
48
48
  download_or_skip_statement(statement)
49
49
  end
50
50
  end
51
51
 
52
- def get_all_tax_statements
53
- puts "Downloading all tax statements..." unless Config.quiet?
54
- Parallel.each(tax_statements) do |statement|
55
- download_or_skip_statement(statement)
52
+ private
53
+ def _get_or_log(statement)
54
+ begin
55
+ @http_client.get(full_url(statement.json_uri))
56
+ rescue
57
+ puts "Error downloading statement: #{statement.date} - #{statement.id}"
58
+ raise
56
59
  end
57
60
  end
58
61
 
59
- private
60
62
  def _save(contents, path)
61
63
  FileUtils.mkpath(File.dirname(path))
62
64
  File.open(path, "w") { |f| f.write(contents) }
@@ -4,28 +4,36 @@ require "mechanize"
4
4
  module ADPDownloader
5
5
  class HttpClient
6
6
  def initialize
7
- headers = {"Accept" => "application/json, text/plain, */*"}
8
- @agent = Mechanize.new {|a| a.request_headers = headers}
9
- res = _login(Config.credentials)
10
- _raise_on_error(res)
7
+ # FIXME: https://github.com/andersonvom/adp-downloader/issues/6
8
+ #_raise_on_error(_login(Config.credentials))
11
9
  end
12
10
 
13
11
  def get(url)
14
- contents = download(url)
12
+ res = agent.get(url)
13
+ _raise_on_error(res)
14
+ contents = res.body
15
15
  contents.to_s.empty? ? {} : JSON.parse(contents)
16
16
  end
17
17
 
18
18
  def post(url, data)
19
- @agent.post(url, data)
19
+ agent.post(url, data)
20
20
  end
21
21
 
22
22
  def download(url)
23
- @agent.get(url).body
23
+ agent.get(url).body
24
24
  end
25
25
 
26
26
  private
27
+ def agent
28
+ headers = {
29
+ "Accept" => "application/json, text/plain, */*",
30
+ "Cookie" => "SMSESSION=#{Config.credentials[:smsession_cookie]}",
31
+ }
32
+ @agent ||= Mechanize.new {|a| a.request_headers = headers}
33
+ end
34
+
27
35
  def _login(creds)
28
- @agent.post(LOGIN_URL, {
36
+ agent.post(LOGIN_URL, {
29
37
  "target" => TARGET_URL,
30
38
  "user" => creds[:username],
31
39
  "password" => creds[:password],
@@ -34,8 +42,10 @@ module ADPDownloader
34
42
 
35
43
  def _raise_on_error(res)
36
44
  uri = res.uri.to_s.downcase
37
- if not uri.start_with? TARGET_URL or uri.include? "login"
38
- raise "Unable to authenticate: make sure your username and password are correct"
45
+ #if not uri.start_with? TARGET_URL or uri.include? "login"
46
+ if uri.include? "login"
47
+ #raise "Unable to authenticate: make sure your username and password are correct"
48
+ raise "Unable to authenticate: make sure the file cookie.txt is up to date"
39
49
  end
40
50
  end
41
51
  end
@@ -11,8 +11,8 @@ module ADPDownloader
11
11
  parse_options
12
12
  begin
13
13
  downloader = Downloader.new(HttpClient.new)
14
- downloader.get_all_tax_statements
15
- downloader.get_all_pay_statements
14
+ downloader.get_statements('tax', downloader.tax_statements)
15
+ downloader.get_statements('pay', downloader.pay_statements)
16
16
  rescue Exception => e
17
17
  path = log_exception_to_file(e)
18
18
  puts "An error ocurred: #{e}"
@@ -1,3 +1,3 @@
1
1
  module ADPDownloader
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adp-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anderson Mesquita (andersonvom)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -44,56 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.10'
47
+ version: '1.12'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.10'
54
+ version: '1.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.13'
61
+ version: '1.16'
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
- version: '1.13'
68
+ version: '1.16'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '12.3'
76
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
- version: '10.0'
82
+ version: '12.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.10.0
89
+ version: '0.11'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.10.0
96
+ version: '0.11'
97
97
  description: This app incrementally downloads ADP pay statements (pay stubs) from
98
98
  MyADP
99
99
  email: andersonvom@gmail.com
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.6.13
145
+ rubygems_version: 2.7.3
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: ADP pay statement / pay stub downloader from MyADP