toggl-jobcan 0.2.0 → 0.3.0

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
2
  SHA256:
3
- metadata.gz: c00b08fdda200e0497122388bb5d2db2c99900e402bcb1f5a010159e19a590e6
4
- data.tar.gz: 24b1c959733b880de6da0df91abcace2ff1968038869f76fc3741410211e6847
3
+ metadata.gz: 244e975f62315605010d0406d950787e3ee36e185e0ee44047906ac0ec733ef9
4
+ data.tar.gz: 3597150dc8da666f61eead6e61e3aa24176a0c6fb84cbe013f905db779771ab6
5
5
  SHA512:
6
- metadata.gz: ef121f202a902d3455b7b5e3dd30b47eef1b6a2b0548a962ef4673f13f3dc1c63933cfdc68d0eb351eb5afd36f9724258b70156044c8619ce45c83fd980e1775
7
- data.tar.gz: 763dc53f7743d916cf1dad3b946f63689affb2f1f2955d052d53e91b9b0f9561e2a99841a90fc70d2b33fef7c3960442a37ad979a612019042e258faf9ec194c
6
+ metadata.gz: 5c9c96bd57d7638a9c84a50eed6564a59e863bf6dd20956cf091445119e9cc0a3c27add50a2b5746a5d7da9661795c5d006e29357dfb5089c15341d6d7475131
7
+ data.tar.gz: db76e625afd07b6fa2eff0433f037f4f3e7bc02826c85d9f1320153d44aecb1959c79a9dec6625edcdbacb2506ec3adcaa9727e10036ae63eeeae54beb1feb4a
@@ -1,2 +1,5 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.5
3
+
4
+ Metrics/AbcSize:
5
+ Max: 20
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- toggl-jobcan (0.1.0)
4
+ toggl-jobcan (0.3.0)
5
5
  chromedriver-helper
6
6
  selenium-webdriver
7
- toggl-worktime (>= 0.2.0)
7
+ toggl-worktime (~> 0.3.0, >= 0.3.2)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -15,22 +15,22 @@ GEM
15
15
  byebug (10.0.2)
16
16
  childprocess (0.9.0)
17
17
  ffi (~> 1.0, >= 1.0.11)
18
- chromedriver-helper (1.2.0)
18
+ chromedriver-helper (2.1.0)
19
19
  archive-zip (~> 0.10)
20
20
  nokogiri (~> 1.8)
21
21
  coderay (1.1.2)
22
22
  diff-lcs (1.3)
23
- faraday (0.14.0)
23
+ faraday (0.15.3)
24
24
  multipart-post (>= 1.2, < 3)
25
- ffi (1.9.23)
25
+ ffi (1.9.25)
26
26
  io-like (0.3.0)
27
27
  logger (1.2.8)
28
28
  method_source (0.9.0)
29
29
  mini_portile2 (2.3.0)
30
30
  multipart-post (2.0.0)
31
- nokogiri (1.8.2)
31
+ nokogiri (1.8.4)
32
32
  mini_portile2 (~> 2.3.0)
33
- oj (3.5.0)
33
+ oj (3.6.10)
34
34
  pry (0.11.3)
35
35
  coderay (~> 1.1.0)
36
36
  method_source (~> 0.9.0)
@@ -51,11 +51,11 @@ GEM
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
52
  rspec-support (~> 3.7.0)
53
53
  rspec-support (3.7.1)
54
- rubyzip (1.2.1)
55
- selenium-webdriver (3.11.0)
54
+ rubyzip (1.2.2)
55
+ selenium-webdriver (3.14.0)
56
56
  childprocess (~> 0.5)
57
57
  rubyzip (~> 1.2)
58
- toggl-worktime (0.2.0)
58
+ toggl-worktime (0.3.2)
59
59
  awesome_print
60
60
  togglv8
61
61
  togglv8 (1.2.1)
data/README.md CHANGED
@@ -14,11 +14,15 @@ gem 'toggl-jobcan'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ ```console
18
+ bundle
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install toggl-jobcan
23
+ ```console
24
+ gem install toggl-jobcan
25
+ ```
22
26
 
23
27
  ## Configuration
24
28
 
@@ -28,8 +32,9 @@ Prepare `~/.toggl_worktime` for [Toggl::Worktime](https://github.com/limitusus/t
28
32
 
29
33
  Prepare `~/.jobcan` YAML file that includes:
30
34
 
35
+ From v0.3.0 you need to specify *Jobcan ID*, not *Jobcan Attendance ID*. For details read the [documentation by Jobcan](https://jobcanwf.zendesk.com/hc/ja/articles/224910508).
36
+
31
37
  ```yaml
32
- client_id: YOUR_CLIENT_ID
33
38
  email: YOUR_EMAIL_ADDRESS
34
39
  password: YOUR_PASSWORD
35
40
  ```
@@ -58,7 +63,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
58
63
 
59
64
  ## Contributing
60
65
 
61
- Bug reports and pull requests are welcome on GitHub at https://github.com/limitusus/toggl-jobcan. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+ Bug reports and pull requests are welcome on GitHub at [limitusus/toggl-jobcan](https://github.com/limitusus/toggl-jobcan). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
67
 
63
68
  ## License
64
69
 
@@ -22,8 +22,10 @@ opt.on('--dryrun') { |v| dryrun = v }
22
22
  opt.parse!(ARGV)
23
23
 
24
24
  raise RangeError, 'No dates given' if ARGV.empty?
25
+
25
26
  target_days = ARGV.map do |s|
26
27
  raise RangeError, 'Invalid format' unless s.match?(/\d#{8}/)
28
+
27
29
  Date.parse(s)
28
30
  end
29
31
 
@@ -46,12 +48,12 @@ puts 'Driver ready'
46
48
 
47
49
  target_days.each do |date|
48
50
  puts "Input date: #{date}"
49
- jobcan.navigate_to_attendance_modify_day(date)
50
51
  working_times = jobcan.fetch_toggl_worktime(date).flatten
51
52
  if working_times.any?(&:nil?)
52
53
  puts 'Includes nil data: skip'
53
54
  next
54
55
  end
56
+ jobcan.navigate_to_attendance_modify_day(date)
55
57
  jobcan.input_day_worktime(date, working_times)
56
58
  sleep 1
57
59
  puts " - Finish: #{date}; Total time: #{jobcan.toggl.total_time}"
@@ -8,9 +8,13 @@ module Toggl
8
8
  attr_reader :driver
9
9
  attr_reader :toggl
10
10
 
11
+ class JobcanLoginFailure < StandardError; end
12
+
11
13
  include Toggl::Jobcan::TogglSupport
12
14
 
13
15
  JOBCAN_URLS = {
16
+ login: 'https://id.jobcan.jp/users/sign_in',
17
+ attendance_login: 'https://ssl.jobcan.jp/jbcoauth/login',
14
18
  attendance: 'https://ssl.jobcan.jp/employee/attendance',
15
19
  attendance_modify: 'https://ssl.jobcan.jp/employee/adit/modify/'
16
20
  }.freeze
@@ -18,8 +22,8 @@ module Toggl
18
22
  XPATHS = {
19
23
  notice: %(//textarea[@name='notice']),
20
24
  load_button: %(//input[@value='表示']),
21
- submit: %(//button[@type='submit']),
22
- password_label: %(//label[@for='password'])
25
+ submit: %(//input[@type='submit']),
26
+ flash: %(//p[@class='flash flash__alert'])
23
27
  }.freeze
24
28
 
25
29
  def initialize(
@@ -38,20 +42,20 @@ module Toggl
38
42
  end
39
43
 
40
44
  def login
41
- @driver.navigate.to JOBCAN_URLS[:attendance]
42
- # login if <label for="password"> exists
43
- return unless may_find_element(:xpath, XPATHS[:password_label])
45
+ @driver.navigate.to JOBCAN_URLS[:login]
44
46
  send_credentials
45
47
  @driver.find_element(:xpath, XPATHS[:submit]).click
46
- # attendance again
48
+ raise JobcanLoginFailure if may_find_element(:xpath, XPATHS[:flash])
49
+
50
+ # attendance login
51
+ @driver.navigate.to JOBCAN_URLS[:attendance_login]
47
52
  @driver.navigate.to JOBCAN_URLS[:attendance]
48
53
  end
49
54
 
50
55
  def send_credentials
51
56
  [
52
- ['client_id', :client_id],
53
- ['email', :email],
54
- ['password', :password]
57
+ ['user_email', :email],
58
+ ['user_password', :password]
55
59
  ].each do |id, method|
56
60
  element = @driver.find_element(:id, id)
57
61
  element.send_keys(@credentials.send(method))
@@ -6,14 +6,13 @@ module Toggl
6
6
  module Jobcan
7
7
  # Jobcan credentials manager
8
8
  class Credentials
9
- attr_accessor :client_id
10
9
  attr_accessor :email
11
10
  attr_accessor :password
12
11
 
13
- ATTRS = %i[client_id email password].freeze
12
+ ATTRS = %i[email password].freeze
14
13
 
15
14
  def initialize(args)
16
- attr_set(args) if args.key?(:client_id)
15
+ attr_set(args) if args.key?(:email)
17
16
  c = self.class.load_config(args[:path])
18
17
  attr_set(c)
19
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Toggl
4
4
  module Jobcan
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency 'chromedriver-helper'
26
26
  spec.add_dependency 'selenium-webdriver'
27
- spec.add_dependency 'toggl-worktime', '~> 0.3.0'
27
+ spec.add_dependency 'toggl-worktime', '~> 0.3.0', '>= 0.3.2'
28
28
  spec.add_development_dependency 'bundler', '~> 1.16'
29
29
  spec.add_development_dependency 'pry'
30
30
  spec.add_development_dependency 'pry-byebug'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggl-jobcan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoya Kabe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chromedriver-helper
@@ -45,6 +45,9 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.3.0
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.3.2
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,6 +55,9 @@ dependencies:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
57
  version: 0.3.0
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.3.2
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: bundler
57
63
  requirement: !ruby/object:Gem::Requirement