adp-downloader 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f532e9d9ce46bc71b7810e9b2568136150817de
4
- data.tar.gz: 6d7b5658c4d0be440d499114a8869f5e775c63a7
3
+ metadata.gz: 5e22d6a2d101c5fd813316d6eb144e30357be097
4
+ data.tar.gz: a94fa0e54e3f023fb695d5dcdf7791ed73a81c04
5
5
  SHA512:
6
- metadata.gz: 64431a0a68a9b125cafd9489f5a6e3698cd9f6efa7989a67967f962a596be70cec01292d0a4857c7b57f228f43562f1a207b888094c85f52f5eaa5a8e4de12a0
7
- data.tar.gz: b32d96d331cce56b7afcaebe3c754144f6f8bea422d1a764d7accfa07d98f27e609497e061883c754077e8ad382da08d6034e86ea32ef7ed078158d5e2889921
6
+ metadata.gz: 1fe857e5187102d7e8d04061250b8b96ff9786453435f982b73b6677b84be04882e0b75e060eeeb87bfcb4fa237ce7a8fb2bd98c3963c9edd0698ea12e9d90d3
7
+ data.tar.gz: 4d3973c4d8db0f06721345fb9d75f05d591703201dd19b52655adaa844de243560ca8c04eba2d2af723143ae8c7e04c01c9165f8fc689f7c9a30b2cf66319742
data/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ Changelog
2
+ =========
3
+
4
+ ## Unreleased
5
+
6
+ * -
7
+
8
+
9
+ ## 0.2.1
10
+
11
+ * [88d8f76][] Add command line options to prevent output
12
+
13
+ [88d8f76]: ../../commit/88d8f76
14
+
15
+
16
+ ## 0.2.1
17
+
18
+ * [#3][] Fixed bug with Tempfiles in older versions of ruby
19
+
20
+ [#3]: ../../issues/3
21
+
22
+
23
+ ## 0.2.0
24
+
25
+ ### Breaking changes:
26
+
27
+ * [481f738][] Use PDF ID instead of JSON ID for file names
28
+ * [8af8c55][] Add adjustment suffix to pay adjustment PDF files
29
+ * [5fb1fb9][] Organize downloaded files by year
30
+
31
+ [481f738]: ../../commit/481f738
32
+ [8af8c55]: ../../commit/8af8c55
33
+ [5fb1fb9]: ../../commit/5fb1fb9
34
+
35
+ **WARNING**: Do not run `adp-downloader` in the same directory as `v.0.1.4`.
36
+ Either move all old statements to a different directory or run it in a new
37
+ directory. Once all statements are downloaded, you can manually move
38
+ previously downloaded old statements (those no longer available through the
39
+ API) into the correct new directories. The names of older statements will
40
+ still have the old ID but since they're no longer available through the API,
41
+ this should not cause any problems.
42
+
43
+ ### Other changes:
44
+
45
+ * [812fbfc][] Keep simple statement JSON info along with detailed JSON
46
+ * [481f738][] Download pay and tax statements
47
+ * [fdc5494][] Download pay statement JSON only when available
48
+
49
+ [812fbfc]: ../../commit/812fbfc
50
+ [481f738]: ../../commit/481f738
51
+ [fdc5494]: ../../commit/fdc5494
52
+
53
+
54
+ ## 0.1.4
55
+
56
+ * [75bcbf9][] Use `.netrc` for storing credentials
57
+
58
+ [75bcbf9]: ../../commit/75bcbf9
59
+
60
+
61
+ ## 0.1.3 [YANKED]
62
+ ## 0.1.2 [YANKED]
63
+ ## 0.1.1 [YANKED]
64
+ ## 0.1.0 [YANKED]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adp-downloader (0.2.1)
4
+ adp-downloader (0.2.2)
5
5
  mechanize (~> 2.7)
6
6
  netrc (~> 0.11)
7
7
  parallel (~> 1.10)
data/bin/adp-downloader CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require "adp-downloader"
4
4
 
5
- ADPDownloader.download
5
+ runner = ADPDownloader::Runner.new(ARGV)
6
+ runner.run
@@ -1,26 +1,10 @@
1
- require "adp-downloader/downloader"
2
- require "adp-downloader/http_client"
3
-
4
- module ADPDownloader
5
- def self.download
6
- begin
7
- downloader = Downloader.new(HttpClient.new)
8
- downloader.get_all_tax_statements
9
- downloader.get_all_pay_statements
10
- rescue Exception => e
11
- path = log_exception_to_file(e)
12
- puts "An error ocurred: #{e}"
13
- puts "Details were logged to #{path}"
14
- exit 1
15
- end
16
- end
17
-
18
- private
19
- def self.log_exception_to_file(e)
20
- file = Tempfile.new("adp-downloader-")
21
- file.puts(e)
22
- file.puts(e.backtrace)
23
- FileUtils.mv file.path, File.join("", "tmp")
24
- File.join("", "tmp", File.basename(file.path))
25
- end
26
- end
1
+ require "adp-downloader/config.rb"
2
+ require "adp-downloader/constants.rb"
3
+ require "adp-downloader/downloader.rb"
4
+ require "adp-downloader/http_client.rb"
5
+ require "adp-downloader/runner"
6
+ require "adp-downloader/runner.rb"
7
+ require "adp-downloader/statement/statement.rb"
8
+ require "adp-downloader/statement/pay_statement.rb"
9
+ require "adp-downloader/statement/tax_statement.rb"
10
+ require "adp-downloader/version.rb"
@@ -1,31 +1,38 @@
1
1
  require "io/console"
2
2
  require "netrc"
3
- require "adp-downloader/constants"
4
3
 
5
4
  module ADPDownloader
6
5
  class Config
7
- def self.credentials
8
- from_netrc or from_stdin
9
- end
6
+ class << self
7
+ attr_writer :quiet
10
8
 
11
- private
12
- def self.creds(username, password)
13
- { username: username, password: password }
14
- end
9
+ def credentials
10
+ from_netrc or from_stdin
11
+ end
15
12
 
16
- def self.from_netrc
17
- n = Netrc.read
18
- username, password = n[MACHINE_NAME]
19
- creds(username, password) if username and password
20
- end
13
+ def quiet?
14
+ @quiet
15
+ end
16
+
17
+ private
18
+ def creds(username, password)
19
+ { username: username, password: password }
20
+ end
21
+
22
+ def from_netrc
23
+ n = Netrc.read
24
+ username, password = n[MACHINE_NAME]
25
+ creds(username, password) if username and password
26
+ end
21
27
 
22
- def self.from_stdin
23
- print "Username: "
24
- username = STDIN.gets.chomp
25
- print "Password: "
26
- password = STDIN.noecho(&:gets).chomp
27
- puts
28
- creds(username, password)
28
+ def from_stdin
29
+ print "Username: "
30
+ username = STDIN.gets.chomp
31
+ print "Password: "
32
+ password = STDIN.noecho(&:gets).chomp
33
+ puts
34
+ creds(username, password)
35
+ end
29
36
  end
30
37
  end
31
38
  end
@@ -1,8 +1,5 @@
1
1
  require "json"
2
2
  require "parallel"
3
- require "adp-downloader/constants"
4
- require "adp-downloader/statement/pay_statement"
5
- require "adp-downloader/statement/tax_statement"
6
3
 
7
4
  module ADPDownloader
8
5
  class Downloader
@@ -40,18 +37,20 @@ module ADPDownloader
40
37
 
41
38
  def download_or_skip_statement(statement)
42
39
  if not downloaded? statement
43
- puts "Saving #{statement.date} - #{statement.id}..."
40
+ puts "Saving #{statement.date} - #{statement.id}..." unless Config.quiet?
44
41
  download_statement_files(statement)
45
42
  end
46
43
  end
47
44
 
48
45
  def get_all_pay_statements
46
+ puts "Downloading all pay statements..." unless Config.quiet?
49
47
  Parallel.each(pay_statements) do |statement|
50
48
  download_or_skip_statement(statement)
51
49
  end
52
50
  end
53
51
 
54
52
  def get_all_tax_statements
53
+ puts "Downloading all tax statements..." unless Config.quiet?
55
54
  Parallel.each(tax_statements) do |statement|
56
55
  download_or_skip_statement(statement)
57
56
  end
@@ -1,7 +1,5 @@
1
1
  require "json"
2
2
  require "mechanize"
3
- require "adp-downloader/config"
4
- require "adp-downloader/constants"
5
3
 
6
4
  module ADPDownloader
7
5
  class HttpClient
@@ -0,0 +1,41 @@
1
+ require "tempfile"
2
+ require "optparse"
3
+
4
+ module ADPDownloader
5
+ class Runner
6
+ def initialize(arguments)
7
+ @arguments = arguments
8
+ end
9
+
10
+ def run
11
+ parse_options
12
+ begin
13
+ downloader = Downloader.new(HttpClient.new)
14
+ downloader.get_all_tax_statements
15
+ downloader.get_all_pay_statements
16
+ rescue Exception => e
17
+ path = log_exception_to_file(e)
18
+ puts "An error ocurred: #{e}"
19
+ puts "Details were logged to #{path}"
20
+ exit 1
21
+ end
22
+ end
23
+
24
+ private
25
+ def log_exception_to_file(e)
26
+ file = Tempfile.new("adp-downloader-")
27
+ file.puts(e)
28
+ file.puts(e.backtrace)
29
+ FileUtils.mv file.path, File.join("", "tmp")
30
+ File.join("", "tmp", File.basename(file.path))
31
+ end
32
+
33
+ def parse_options
34
+ options = OptionParser.new
35
+ options.banner = "Usage: adp-downloader [options]"
36
+ options.on("-v", "--quiet", "Only display errors") { Config.quiet = true }
37
+ options.on("-h", "--help", "Show this message") { puts(options); exit }
38
+ options.parse!(@arguments)
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,3 @@
1
- require "adp-downloader/statement/statement"
2
-
3
1
  module ADPDownloader
4
2
  class PayStatement < Statement
5
3
  def id
@@ -1,5 +1,3 @@
1
- require "adp-downloader/statement/statement"
2
-
3
1
  module ADPDownloader
4
2
  class TaxStatement < Statement
5
3
  def id
@@ -1,3 +1,3 @@
1
1
  module ADPDownloader
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.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.1
4
+ version: 0.2.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-01-23 00:00:00.000000000 Z
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -103,6 +103,7 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
+ - CHANGELOG.md
106
107
  - Gemfile
107
108
  - Gemfile.lock
108
109
  - LICENSE.md
@@ -116,6 +117,7 @@ files:
116
117
  - lib/adp-downloader/constants.rb
117
118
  - lib/adp-downloader/downloader.rb
118
119
  - lib/adp-downloader/http_client.rb
120
+ - lib/adp-downloader/runner.rb
119
121
  - lib/adp-downloader/statement/pay_statement.rb
120
122
  - lib/adp-downloader/statement/statement.rb
121
123
  - lib/adp-downloader/statement/tax_statement.rb