toggl-jobcan 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +78 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/toggl-jobcan +47 -0
- data/lib/toggl/jobcan.rb +13 -0
- data/lib/toggl/jobcan/client.rb +119 -0
- data/lib/toggl/jobcan/credentials.rb +34 -0
- data/lib/toggl/jobcan/toggl_support.rb +24 -0
- data/lib/toggl/jobcan/version.rb +7 -0
- data/toggl-jobcan.gemspec +33 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f15d28d923fedef2967a7cdeb5bcf233c1fdcacf0fe069bdf1ad9fc437512447
|
4
|
+
data.tar.gz: b133d6690eb848ef5661cafc3352be8264ea034b87346b843c50a001b6d08be3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 839898c0b0804d906d6abba15a3c3f5c92fd884a677317acf08c9e257dea6e509392ebfe1408609df639c22904b5b461b07a1f6432dd351a336f6aa7b5de0f96
|
7
|
+
data.tar.gz: f7da11aac148e3597090f5deeb07736e4420cb4d600b245d130703bed3275c8fdceb03de85cbe3c1034b3944f46d7adb1889944799d6c06b8143a70753885207
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at limit.usus@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
toggl-jobcan (0.1.0)
|
5
|
+
chromedriver-helper
|
6
|
+
selenium-webdriver
|
7
|
+
toggl-worktime (>= 0.2.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
archive-zip (0.11.0)
|
13
|
+
io-like (~> 0.3.0)
|
14
|
+
awesome_print (1.8.0)
|
15
|
+
byebug (10.0.2)
|
16
|
+
childprocess (0.9.0)
|
17
|
+
ffi (~> 1.0, >= 1.0.11)
|
18
|
+
chromedriver-helper (1.2.0)
|
19
|
+
archive-zip (~> 0.10)
|
20
|
+
nokogiri (~> 1.8)
|
21
|
+
coderay (1.1.2)
|
22
|
+
diff-lcs (1.3)
|
23
|
+
faraday (0.14.0)
|
24
|
+
multipart-post (>= 1.2, < 3)
|
25
|
+
ffi (1.9.23)
|
26
|
+
io-like (0.3.0)
|
27
|
+
logger (1.2.8)
|
28
|
+
method_source (0.9.0)
|
29
|
+
mini_portile2 (2.3.0)
|
30
|
+
multipart-post (2.0.0)
|
31
|
+
nokogiri (1.8.2)
|
32
|
+
mini_portile2 (~> 2.3.0)
|
33
|
+
oj (3.5.0)
|
34
|
+
pry (0.11.3)
|
35
|
+
coderay (~> 1.1.0)
|
36
|
+
method_source (~> 0.9.0)
|
37
|
+
pry-byebug (3.6.0)
|
38
|
+
byebug (~> 10.0)
|
39
|
+
pry (~> 0.10)
|
40
|
+
rake (10.5.0)
|
41
|
+
rspec (3.7.0)
|
42
|
+
rspec-core (~> 3.7.0)
|
43
|
+
rspec-expectations (~> 3.7.0)
|
44
|
+
rspec-mocks (~> 3.7.0)
|
45
|
+
rspec-core (3.7.1)
|
46
|
+
rspec-support (~> 3.7.0)
|
47
|
+
rspec-expectations (3.7.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.7.0)
|
50
|
+
rspec-mocks (3.7.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.7.0)
|
53
|
+
rspec-support (3.7.1)
|
54
|
+
rubyzip (1.2.1)
|
55
|
+
selenium-webdriver (3.11.0)
|
56
|
+
childprocess (~> 0.5)
|
57
|
+
rubyzip (~> 1.2)
|
58
|
+
toggl-worktime (0.2.0)
|
59
|
+
awesome_print
|
60
|
+
togglv8
|
61
|
+
togglv8 (1.2.1)
|
62
|
+
faraday
|
63
|
+
logger
|
64
|
+
oj
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
bundler (~> 1.16)
|
71
|
+
pry
|
72
|
+
pry-byebug
|
73
|
+
rake (~> 10.0)
|
74
|
+
rspec (~> 3.0)
|
75
|
+
toggl-jobcan!
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Tomoya Kabe
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Toggl::Jobcan
|
2
|
+
|
3
|
+
This gem provides `toggl-jobcan` command, which synchronises working time data in Toggl to JobCan.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'toggl-jobcan'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install toggl-jobcan
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Pass date strings in `%Y%m%d` format.
|
24
|
+
|
25
|
+
```console
|
26
|
+
toggl-jobcan 20170201 20170202
|
27
|
+
```
|
28
|
+
|
29
|
+
To synchronise all days in a month, utilise `seq` command:
|
30
|
+
|
31
|
+
```console
|
32
|
+
toggl-jobcan `seq -f '201702%02g' 1 28`
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
## Code of Conduct
|
50
|
+
|
51
|
+
Everyone interacting in the Toggl::Jobcan project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/toggl-jobcan/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'toggl/jobcan'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/toggl-jobcan
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __dir__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'selenium-webdriver'
|
8
|
+
require 'toggl/jobcan'
|
9
|
+
require 'toggl/worktime'
|
10
|
+
|
11
|
+
cred_file = "#{ENV['HOME']}/.jobcan"
|
12
|
+
|
13
|
+
Version = Toggl::Jobcan::VERSION
|
14
|
+
|
15
|
+
raise RangeError, 'No dates given' if ARGV.empty?
|
16
|
+
target_days = ARGV.map do |s|
|
17
|
+
raise RangeError, 'Invalid format' unless s.match?(/\d#{8}/)
|
18
|
+
Date.parse(s)
|
19
|
+
end
|
20
|
+
|
21
|
+
puts 'Target days:'
|
22
|
+
target_days.each do |date|
|
23
|
+
puts " - #{date.strftime('%F')}"
|
24
|
+
end
|
25
|
+
|
26
|
+
credentials = Toggl::Jobcan::Credentials.new(path: cred_file)
|
27
|
+
jobcan = Toggl::Jobcan::Client.new(credentials: credentials)
|
28
|
+
jobcan.login
|
29
|
+
|
30
|
+
puts 'Driver ready'
|
31
|
+
|
32
|
+
target_days.each do |date|
|
33
|
+
puts "Input date: #{date}"
|
34
|
+
jobcan.navigate_to_attendance_modify_day(date)
|
35
|
+
working_times = jobcan.fetch_toggl_worktime(date).flatten
|
36
|
+
if working_times.any?(&:nil?)
|
37
|
+
puts 'Includes nil data: skip'
|
38
|
+
next
|
39
|
+
end
|
40
|
+
jobcan.input_day_worktime(date, working_times)
|
41
|
+
sleep 1
|
42
|
+
puts " - Finish: #{date}; Total time: #{jobcan.toggl.total_time}"
|
43
|
+
end
|
44
|
+
|
45
|
+
jobcan.driver.quit
|
46
|
+
|
47
|
+
puts 'All Input finished'
|
data/lib/toggl/jobcan.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'toggl/jobcan/toggl_support'
|
4
|
+
require 'toggl/jobcan/credentials'
|
5
|
+
require 'toggl/jobcan/client'
|
6
|
+
|
7
|
+
require 'toggl/jobcan/version'
|
8
|
+
|
9
|
+
module Toggl
|
10
|
+
# Provides Toggl::Jobcan namespace
|
11
|
+
module Jobcan
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Toggl
|
4
|
+
module Jobcan
|
5
|
+
# Jobcan client
|
6
|
+
class Client
|
7
|
+
attr_accessor :credentials
|
8
|
+
attr_reader :driver
|
9
|
+
attr_reader :toggl
|
10
|
+
|
11
|
+
include Toggl::Jobcan::TogglSupport
|
12
|
+
|
13
|
+
DEFAULT_CONFIG = {
|
14
|
+
timezone: 'Asia/Tokyo',
|
15
|
+
day_begin_hour: 6,
|
16
|
+
max_working_interval: 10
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
JOBCAN_URLS = {
|
20
|
+
attendance: 'https://ssl.jobcan.jp/employee/attendance',
|
21
|
+
attendance_modify: 'https://ssl.jobcan.jp/employee/adit/modify/'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
XPATHS = {
|
25
|
+
notice: %(//textarea[@name='notice']),
|
26
|
+
load_button: %(//input[@value='表示']),
|
27
|
+
submit: %(//button[@type='submit']),
|
28
|
+
password_label: %(//label[@for='password'])
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
def initialize(credentials: nil,
|
32
|
+
options: Selenium::WebDriver::Chrome::Options.new)
|
33
|
+
@credentials = credentials
|
34
|
+
@config = DEFAULT_CONFIG
|
35
|
+
options.add_argument('--headless')
|
36
|
+
@driver = Selenium::WebDriver.for :chrome, options: options
|
37
|
+
@toggl = Toggl::Worktime::Driver.new(
|
38
|
+
max_working_interval: @config[:max_working_interval]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def login
|
43
|
+
@driver.navigate.to JOBCAN_URLS[:attendance]
|
44
|
+
# login if <label for="password"> exists
|
45
|
+
return unless may_find_element(:xpath, XPATHS[:password_label])
|
46
|
+
send_credentials
|
47
|
+
@driver.find_element(:xpath, XPATHS[:submit]).click
|
48
|
+
# attendance again
|
49
|
+
@driver.navigate.to JOBCAN_URLS[:attendance]
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_credentials
|
53
|
+
[
|
54
|
+
['client_id', :client_id],
|
55
|
+
['email', :email],
|
56
|
+
['password', :password]
|
57
|
+
].each do |id, method|
|
58
|
+
element = @driver.find_element(:id, id)
|
59
|
+
element.send_keys(@credentials.send(method))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def navigate_to_attendance_month(year, month)
|
64
|
+
@driver.navigate.to JOBCAN_URLS[:attendance]
|
65
|
+
# Specify by month
|
66
|
+
@driver.find_element(:id, 'search_type_month').click
|
67
|
+
selector_year = select_support_for('year')
|
68
|
+
selector_year.select_by(:text, year.to_s)
|
69
|
+
selector_month = select_support_for('month')
|
70
|
+
selector_month.select_by(:text, format('%02d', month))
|
71
|
+
# load
|
72
|
+
@driver.find_element(:xpath, XPATHS[:load_button]).click
|
73
|
+
end
|
74
|
+
|
75
|
+
def navigate_to_attendance_modify_day(date)
|
76
|
+
# https://ssl.jobcan.jp/employee/adit/modify?year=2018&month=3&day=14
|
77
|
+
query_string = "year=#{date.year}&month=#{date.month}&day=#{date.day}"
|
78
|
+
@driver.navigate.to JOBCAN_URLS[:attendance_modify] + '?' + query_string
|
79
|
+
end
|
80
|
+
|
81
|
+
def select_support_for(name)
|
82
|
+
Selenium::WebDriver::Support::Select.new(
|
83
|
+
@driver.find_element(:xpath),
|
84
|
+
%(//select[@name='#{name}'])
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
def input_day_worktime(date, time_slots)
|
89
|
+
time_slots.flatten.each do |timestamp|
|
90
|
+
input_stamp = toggl_time_format(date, timestamp)
|
91
|
+
puts " - Input #{input_stamp}"
|
92
|
+
navigate_to_attendance_modify_day(date)
|
93
|
+
send_timestamp input_stamp
|
94
|
+
send_notice
|
95
|
+
@driver.find_element(:id, 'insert_button').submit
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def send_timestamp(timestamp)
|
100
|
+
time_elem = @driver.find_element(:id, 'ter_time')
|
101
|
+
time_elem.send_keys(timestamp)
|
102
|
+
end
|
103
|
+
|
104
|
+
def send_notice
|
105
|
+
notice_elem = @driver.find_element(:xpath, XPATHS[:notice])
|
106
|
+
notice_elem.clear
|
107
|
+
notice_elem.send_keys('.')
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def may_find_element(*args)
|
113
|
+
@driver.find_element(*args)
|
114
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Toggl
|
6
|
+
module Jobcan
|
7
|
+
# Jobcan credentials manager
|
8
|
+
class Credentials
|
9
|
+
attr_accessor :client_id
|
10
|
+
attr_accessor :email
|
11
|
+
attr_accessor :password
|
12
|
+
|
13
|
+
ATTRS = %i[client_id email password].freeze
|
14
|
+
|
15
|
+
def initialize(args)
|
16
|
+
attr_set(args) if args.key?(:client_id)
|
17
|
+
c = self.class.load_config(args[:path])
|
18
|
+
attr_set(c)
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def load_config(path)
|
23
|
+
YAML.safe_load(File.open(path).read).transform_keys(&:to_sym)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def attr_set(hash)
|
30
|
+
ATTRS.each { |k| send((k.to_s + '=').to_sym, hash[k]) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Toggl
|
4
|
+
module Jobcan
|
5
|
+
# Provides support methods for Toggl
|
6
|
+
module TogglSupport
|
7
|
+
def fetch_toggl_worktime(date)
|
8
|
+
@toggl.merge!(
|
9
|
+
date.month, date.day,
|
10
|
+
@config[:day_begin_hour], @config[:timezone]
|
11
|
+
)
|
12
|
+
@toggl.work_time
|
13
|
+
end
|
14
|
+
|
15
|
+
def toggl_time_format(date, timestamp)
|
16
|
+
same_day = date == timestamp.to_date
|
17
|
+
return timestamp.strftime('%H%M') if same_day
|
18
|
+
hour = timestamp.hour + 24
|
19
|
+
minute = timestamp.min
|
20
|
+
format('%02d%02d', hour, minute)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'toggl/jobcan/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'toggl-jobcan'
|
9
|
+
spec.version = Toggl::Jobcan::VERSION
|
10
|
+
spec.authors = ['Tomoya Kabe']
|
11
|
+
spec.email = ['limit.usus@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Sync toggl worktime to JobCan.'
|
14
|
+
spec.description = 'Sync toggl worktime to JobCan.'
|
15
|
+
spec.homepage = 'https://github.com/limitusus/toggl-jobcan'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'chromedriver-helper'
|
26
|
+
spec.add_dependency 'selenium-webdriver'
|
27
|
+
spec.add_dependency 'toggl-worktime', '>= 0.2.0'
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'pry-byebug'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: toggl-jobcan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomoya Kabe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chromedriver-helper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: selenium-webdriver
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: toggl-worktime
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
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: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
description: Sync toggl worktime to JobCan.
|
126
|
+
email:
|
127
|
+
- limit.usus@gmail.com
|
128
|
+
executables:
|
129
|
+
- toggl-jobcan
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
137
|
+
- CODE_OF_CONDUCT.md
|
138
|
+
- Gemfile
|
139
|
+
- Gemfile.lock
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- exe/toggl-jobcan
|
146
|
+
- lib/toggl/jobcan.rb
|
147
|
+
- lib/toggl/jobcan/client.rb
|
148
|
+
- lib/toggl/jobcan/credentials.rb
|
149
|
+
- lib/toggl/jobcan/toggl_support.rb
|
150
|
+
- lib/toggl/jobcan/version.rb
|
151
|
+
- toggl-jobcan.gemspec
|
152
|
+
homepage: https://github.com/limitusus/toggl-jobcan
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.7.3
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Sync toggl worktime to JobCan.
|
176
|
+
test_files: []
|