menthol 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -6
  3. data/exe/menthol +29 -5
  4. data/lib/menthol/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa8769e7fbe59ab7cf97f693fc2822df3c172603
4
- data.tar.gz: a2a0dca36250ffe10c3229efc37f95adf7a3420c
3
+ metadata.gz: c9a061597984e8421a60f0d97087590ce061cb2f
4
+ data.tar.gz: 949e0bfb5e75b7b3f858ae9c711455ca00965947
5
5
  SHA512:
6
- metadata.gz: 1bd3be12cc6ba50258e180579592db71c9ce4ae321524a287db14fc2b491888fae864341935950b297ff561e850636d4fb35abbd11e689019e53bacb67e9bc93
7
- data.tar.gz: e2680debffa9a410ad5a8e2c59bfdd224df51d2516c5e2ccca6888d2394aff153902a17ac87e37a174fe95086d6ac653a020e95323f05400c71aa61d938e3efe
6
+ metadata.gz: 66481de0ec1da19e1c379bfbf4d6111a05c16a72e22ff287cbccb74518d95ed3f1bfba644566cda59dc50e132be78676152775d4ab0acab1b007b003b7b20b83
7
+ data.tar.gz: 8e00e80974cc0e0ca043727a2dd6cc9557171fe69a89164cf796c0adfbc128354e37ff46cce6f67c643159b4e59cc583245906a91ff48009c9194979aa25a7f3
data/README.md CHANGED
@@ -2,10 +2,16 @@
2
2
 
3
3
  **Warning**: This project is a work in progress.
4
4
 
5
+ Install with:
6
+
7
+ ```
8
+ gem install menthol
9
+ ```
10
+
5
11
  Menthol is a web scraper that fetch your Thai bank account balances and sum
6
12
  them for you in your terminal.
7
13
 
8
- Store your configuration under `~/.mentholrc` and run with `exe/mentholrc sync`.
14
+ Store your configuration under `~/.mentholrc` and run with `mentholrc fetch`.
9
15
 
10
16
  Here's a sample `~/.mentholrc` configuration file:
11
17
 
@@ -31,10 +37,9 @@ This library currently support:
31
37
  - Local (the amount must be given in the configuration file as the
32
38
  smallest currency subunit)
33
39
 
34
- You'll need to instal the `watir` gem. You'll also need Chrome installed and
35
- `chrome-webdriver` somewhere on your PATH.
40
+ You'll also need Chrome installed and [chrome-webdriver][1] somewhere on
41
+ your PATH.
36
42
 
37
- TODO:
43
+ If you run on a linux box in only a terminal you can install the optional `headless` gem and let it run without the need for a screen to be attached.
38
44
 
39
- - store accounts in redis
40
- - add web server to display balances and their history
45
+ [1]: https://sites.google.com/a/chromium.org/chromedriver/downloads
@@ -4,21 +4,45 @@ require "menthol"
4
4
 
5
5
  profile = Menthol::Profile.configure(File.expand_path("~/.mentholrc"))
6
6
 
7
+ begin
8
+ require "headless"
9
+ rescue LoadError
10
+ end
11
+
12
+ if defined?(Headless)
13
+ headless = Headless.new
14
+ headless.start
15
+ end
16
+
7
17
  case ARGV.first
8
- when "sync"
18
+ when "fetch"
9
19
  profile.sync_all!
10
20
 
21
+ accounts = []
22
+
11
23
  profile.providers.each do |provider|
12
24
  provider.accounts.each do |account|
13
- puts ["===", account.provider, "|", account.name, "==="].join(" ")
14
- puts account.amount.format
25
+ accounts.push({
26
+ name: "#{provider.name} #{account.name}",
27
+ amount: account.amount.fractional,
28
+ currency: account.amount.currency.iso_code,
29
+ })
15
30
  end
16
31
  end
17
32
 
18
- puts "=== Total ==="
19
- puts profile.amount.format
33
+ puts(JSON.pretty_generate({
34
+ accounts: accounts,
35
+ total: {
36
+ amount: profile.amount.fractional,
37
+ currency: profile.amount.currency.iso_code,
38
+ }
39
+ }) << "\n")
20
40
  else
21
41
  puts "usage: menthold COMMAND"
22
42
  end
23
43
 
44
+ if defined?(Headless)
45
+ headless.destroy
46
+ end
47
+
24
48
  exit 0
@@ -1,3 +1,3 @@
1
1
  module Menthol
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: menthol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Clart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-21 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir