cxeed 0.2.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 +7 -0
- data/.editorconfig +13 -0
- data/.gitignore +109 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/cxeed +10 -0
- data/bin/setup +8 -0
- data/cxeed.gemspec +39 -0
- data/exe/cxeed +7 -0
- data/lib/cxeed/attendance.rb +36 -0
- data/lib/cxeed/command.rb +88 -0
- data/lib/cxeed/credential.rb +33 -0
- data/lib/cxeed/proxy.rb +111 -0
- data/lib/cxeed/version.rb +3 -0
- data/lib/cxeed.rb +9 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1b6f37b1c8c68d786c3821952f708cf4e8bc3af
|
4
|
+
data.tar.gz: 1e90b04cf21a0acd5dc4a58fafdc401b0d7f808f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd18fbfe74a1925c92d0c0585ff9d6f430f61aad4534d82b439d70c3916626fa19dc85be4a34cdb7ff0e65edf31d94d25965994add9f75a8c54288743f438fd6
|
7
|
+
data.tar.gz: 2330fd356aaed5d41178ecb2e12863c00682ed88f4866f4049efb79c67479089379a2deb8e1f15e74b9f440068aa943ed45f03f54006770141ae1587a4234adb
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
### https://raw.github.com/github/gitignore/d5ce0fc1d4a677eaa60d5b8e01ac9e42ec7cfcd1/Global/JetBrains.gitignore
|
2
|
+
|
3
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
4
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
5
|
+
|
6
|
+
.idea
|
7
|
+
|
8
|
+
# User-specific stuff:
|
9
|
+
.idea/**/workspace.xml
|
10
|
+
.idea/**/tasks.xml
|
11
|
+
.idea/dictionaries
|
12
|
+
|
13
|
+
# Sensitive or high-churn files:
|
14
|
+
.idea/**/dataSources/
|
15
|
+
.idea/**/dataSources.ids
|
16
|
+
.idea/**/dataSources.xml
|
17
|
+
.idea/**/dataSources.local.xml
|
18
|
+
.idea/**/sqlDataSources.xml
|
19
|
+
.idea/**/dynamic.xml
|
20
|
+
.idea/**/uiDesigner.xml
|
21
|
+
|
22
|
+
# Gradle:
|
23
|
+
.idea/**/gradle.xml
|
24
|
+
.idea/**/libraries
|
25
|
+
|
26
|
+
# CMake
|
27
|
+
cmake-build-debug/
|
28
|
+
|
29
|
+
# Mongo Explorer plugin:
|
30
|
+
.idea/**/mongoSettings.xml
|
31
|
+
|
32
|
+
## File-based project format:
|
33
|
+
*.iws
|
34
|
+
|
35
|
+
## Plugin-specific files:
|
36
|
+
|
37
|
+
# IntelliJ
|
38
|
+
out/
|
39
|
+
|
40
|
+
# mpeltonen/sbt-idea plugin
|
41
|
+
.idea_modules/
|
42
|
+
|
43
|
+
# JIRA plugin
|
44
|
+
atlassian-ide-plugin.xml
|
45
|
+
|
46
|
+
# Cursive Clojure plugin
|
47
|
+
.idea/replstate.xml
|
48
|
+
|
49
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
50
|
+
com_crashlytics_export_strings.xml
|
51
|
+
crashlytics.properties
|
52
|
+
crashlytics-build.properties
|
53
|
+
fabric.properties
|
54
|
+
|
55
|
+
|
56
|
+
### https://raw.github.com/github/gitignore/d5ce0fc1d4a677eaa60d5b8e01ac9e42ec7cfcd1/Ruby.gitignore
|
57
|
+
|
58
|
+
*.gem
|
59
|
+
*.rbc
|
60
|
+
/.config
|
61
|
+
/coverage/
|
62
|
+
/InstalledFiles
|
63
|
+
/pkg/
|
64
|
+
/spec/reports/
|
65
|
+
/spec/examples.txt
|
66
|
+
/test/tmp/
|
67
|
+
/test/version_tmp/
|
68
|
+
/tmp/
|
69
|
+
|
70
|
+
# Used by dotenv library to load environment variables.
|
71
|
+
# .env
|
72
|
+
|
73
|
+
## Specific to RubyMotion:
|
74
|
+
.dat*
|
75
|
+
.repl_history
|
76
|
+
build/
|
77
|
+
*.bridgesupport
|
78
|
+
build-iPhoneOS/
|
79
|
+
build-iPhoneSimulator/
|
80
|
+
|
81
|
+
## Specific to RubyMotion (use of CocoaPods):
|
82
|
+
#
|
83
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
84
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
85
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
86
|
+
#
|
87
|
+
# vendor/Pods/
|
88
|
+
|
89
|
+
## Documentation cache and generated files:
|
90
|
+
/.yardoc/
|
91
|
+
/_yardoc/
|
92
|
+
/doc/
|
93
|
+
/rdoc/
|
94
|
+
|
95
|
+
## Environment normalization:
|
96
|
+
/.bundle/
|
97
|
+
/vendor/bundle
|
98
|
+
/lib/bundler/man/
|
99
|
+
|
100
|
+
# for a library or gem, you might want to ignore these files since the code is
|
101
|
+
# intended to run in multiple environments; otherwise, check them in:
|
102
|
+
# Gemfile.lock
|
103
|
+
# .ruby-version
|
104
|
+
# .ruby-gemset
|
105
|
+
|
106
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
107
|
+
.rvmrc
|
108
|
+
|
109
|
+
|
data/.rspec
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 sac2ndg+develop@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,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cxeed (0.2.1)
|
5
|
+
selenium-webdriver
|
6
|
+
thor
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
childprocess (0.8.0)
|
12
|
+
ffi (~> 1.0, >= 1.0.11)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
ffi (1.9.18)
|
15
|
+
rake (10.5.0)
|
16
|
+
rspec (3.6.0)
|
17
|
+
rspec-core (~> 3.6.0)
|
18
|
+
rspec-expectations (~> 3.6.0)
|
19
|
+
rspec-mocks (~> 3.6.0)
|
20
|
+
rspec-core (3.6.0)
|
21
|
+
rspec-support (~> 3.6.0)
|
22
|
+
rspec-expectations (3.6.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.6.0)
|
25
|
+
rspec-mocks (3.6.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.6.0)
|
28
|
+
rspec-support (3.6.0)
|
29
|
+
rubyzip (1.2.1)
|
30
|
+
selenium-webdriver (3.5.2)
|
31
|
+
childprocess (~> 0.5)
|
32
|
+
rubyzip (~> 1.0)
|
33
|
+
thor (0.20.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.15)
|
40
|
+
cxeed!
|
41
|
+
rake (~> 10.0)
|
42
|
+
rspec (~> 3.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.15.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 rhythm191
|
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,69 @@
|
|
1
|
+
# Cxeed
|
2
|
+
|
3
|
+
CYBER XEED ruby client
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
install chrome driver
|
8
|
+
|
9
|
+
$ brew install chromedriver
|
10
|
+
|
11
|
+
|
12
|
+
install it yourself as:
|
13
|
+
|
14
|
+
$ gem install cxeed
|
15
|
+
or
|
16
|
+
$ gem install specific_install
|
17
|
+
$ gem specific_install https://github.com/rhythm191/cxeed.git master
|
18
|
+
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
認証情報のセットアップをします。
|
23
|
+
認証情報は`~/.cxeed`に保存されます。
|
24
|
+
|
25
|
+
$ cxeed init
|
26
|
+
|
27
|
+
認証情報が正しいかどうか確認します。
|
28
|
+
エラーが出た場合はinitのいずれかのパラメータが異なります。
|
29
|
+
|
30
|
+
$ cxeed login_test
|
31
|
+
|
32
|
+
出社を報告します。引数なしで現在の時刻を入力します。
|
33
|
+
|
34
|
+
$ cxeed arrive
|
35
|
+
or
|
36
|
+
$ cxeed arrive 10:00
|
37
|
+
|
38
|
+
退社を報告します。引数なしで現在の時刻を入力します。
|
39
|
+
|
40
|
+
$ cxeed leave
|
41
|
+
or
|
42
|
+
$ cxeed leave 19:00
|
43
|
+
|
44
|
+
今日の勤怠を見ます。
|
45
|
+
|
46
|
+
$ cxeed today
|
47
|
+
|
48
|
+
任意の日時の勤怠を見ます。
|
49
|
+
|
50
|
+
$ cxeed attendance
|
51
|
+
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
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.
|
56
|
+
|
57
|
+
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).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cxeed. 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
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
66
|
+
|
67
|
+
## Code of Conduct
|
68
|
+
|
69
|
+
Everyone interacting in the Cxeed project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cxeed/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cxeed"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/cxeed
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
|
6
|
+
# require "rubygems"
|
7
|
+
# cxeed_gemspec = Gem::Specification.load(File.expand_path("../../cxeed.gemspec", __FILE__))
|
8
|
+
# cxeed_gemspec.instance_variable_set(:@full_gem_path, File.expand_path("../..", __FILE__))
|
9
|
+
# cxeed_gemspec.activate if cxeed_gemspec.respond_to?(:activate)
|
10
|
+
load File.expand_path("../../exe/cxeed", __FILE__)
|
data/bin/setup
ADDED
data/cxeed.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "cxeed/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cxeed"
|
8
|
+
spec.version = Cxeed::VERSION
|
9
|
+
spec.authors = ["rhythm191"]
|
10
|
+
spec.email = ["sac2ndg+develop@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{cyber xeed ruby client}
|
13
|
+
spec.description = %q{cyber xeed ruby client}
|
14
|
+
spec.homepage = "https://github.com/rhythm191/cxeed.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
|
37
|
+
spec.add_dependency 'thor'
|
38
|
+
spec.add_dependency 'selenium-webdriver'
|
39
|
+
end
|
data/exe/cxeed
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module Cxeed
|
5
|
+
class Attendance
|
6
|
+
attr_accessor :date, :arrive_at, :leave_at
|
7
|
+
|
8
|
+
def initialize(date, arrive_at, leave_at)
|
9
|
+
@date = Time.parse(date, Time.now)
|
10
|
+
@arrive_at = parse_time(arrive_at)
|
11
|
+
@leave_at = parse_time(leave_at)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_time(time)
|
15
|
+
if time.empty? || time == ' : '
|
16
|
+
nil
|
17
|
+
else
|
18
|
+
Time.parse(time, Time.now)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def working_hour
|
24
|
+
if @leave_at.nil? || @arrive_at.nil?
|
25
|
+
0
|
26
|
+
else
|
27
|
+
# TODO: 午前休とかに対応する
|
28
|
+
(@leave_at - @arrive_at) / 3600 - 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def attendance_time
|
33
|
+
"#{ @arrive_at&.strftime('%H:%M') } - #{ @leave_at&.strftime('%H:%M') } (#{ '%.2f' % working_hour }) "
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'thor'
|
3
|
+
require 'cxeed'
|
4
|
+
|
5
|
+
module Cxeed
|
6
|
+
class Command < Thor
|
7
|
+
desc 'init', 'initialize credential'
|
8
|
+
def init
|
9
|
+
cred = Cxeed::Credential.new
|
10
|
+
|
11
|
+
login_url = ask "input login url #{ cred.login_url&.empty? ? '' : "(#{cred.login_url})" }:"
|
12
|
+
cred.login_url = login_url unless login_url.empty?
|
13
|
+
|
14
|
+
company_code = ask "input company code #{ cred.company_code&.empty? ? '' : "(#{cred.company_code})" }:"
|
15
|
+
cred.company_code = company_code unless company_code.empty?
|
16
|
+
|
17
|
+
employee_code = ask "input employee code #{ cred.employee_code&.empty? ? '' : "(#{cred.employee_code})" }:"
|
18
|
+
cred.employee_code = employee_code unless employee_code.empty?
|
19
|
+
|
20
|
+
password = ask '(required!)input password:', echo: false
|
21
|
+
cred.password = password
|
22
|
+
|
23
|
+
cred.store
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'cred', 'show credential'
|
27
|
+
def cred
|
28
|
+
cred = Cxeed::Credential.new
|
29
|
+
|
30
|
+
say "login url : #{ cred.login_url }"
|
31
|
+
say "company code : #{ cred.company_code }"
|
32
|
+
say "employee code: #{ cred.employee_code }"
|
33
|
+
say "password : #{ cred.password }"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'login_test', 'login_test'
|
37
|
+
def login_test
|
38
|
+
cred = Cxeed::Credential.new
|
39
|
+
proxy = Cxeed::Proxy.new cred
|
40
|
+
|
41
|
+
if proxy.login_test == 'https://cxg2.i-abs.co.jp/cyberx/Xgw0001.asp?CxClientDispFlg=0'
|
42
|
+
say 'login success'
|
43
|
+
else
|
44
|
+
say 'login fail'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'arrive [time]', 'submit arrival time (time format is "%H:%M")'
|
49
|
+
def arrive(time = Time.now.strftime('%H:%M'))
|
50
|
+
cred = Cxeed::Credential.new
|
51
|
+
proxy = Cxeed::Proxy.new cred
|
52
|
+
|
53
|
+
proxy.arrive time
|
54
|
+
|
55
|
+
puts "arrive #{ time}"
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'leave [time]', 'submit leave time (time format is "%H:%M")'
|
59
|
+
def leave(time = Time.now.strftime('%H:%M'))
|
60
|
+
cred = Cxeed::Credential.new
|
61
|
+
proxy = Cxeed::Proxy.new cred
|
62
|
+
|
63
|
+
proxy.leave time
|
64
|
+
|
65
|
+
puts "leave #{ time}"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'today', 'show today attendance'
|
69
|
+
def today
|
70
|
+
cred = Cxeed::Credential.new
|
71
|
+
proxy = Cxeed::Proxy.new cred
|
72
|
+
|
73
|
+
today = proxy.today
|
74
|
+
|
75
|
+
puts "today(#{ today.date.strftime('%m/%d') }) #{ today.attendance_time }"
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'attendance date(format: %Y/%m/%d)', 'show day attendance'
|
79
|
+
def attendance(date)
|
80
|
+
cred = Cxeed::Credential.new
|
81
|
+
proxy = Cxeed::Proxy.new cred
|
82
|
+
|
83
|
+
attendance = proxy.day_attendance date
|
84
|
+
|
85
|
+
puts "#{ attendance.date.strftime('%Y/%m/%d') } #{ attendance.attendance_time }"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Cxeed
|
5
|
+
class Credential
|
6
|
+
|
7
|
+
attr_accessor :login_url, :company_code, :employee_code, :password
|
8
|
+
|
9
|
+
CREDENTIAL_FILE_PATH = '~/.cxeed'
|
10
|
+
|
11
|
+
def initialize(filename = CREDENTIAL_FILE_PATH)
|
12
|
+
if File.exists?(File.expand_path(filename))
|
13
|
+
json = open(File.expand_path(filename)) {|io| JSON.load(io) }
|
14
|
+
@login_url = json['login_url']
|
15
|
+
@company_code = json['company_code']
|
16
|
+
@employee_code = json['employee_code']
|
17
|
+
@password = json['password']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json
|
22
|
+
hash = {}
|
23
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
24
|
+
hash.to_json
|
25
|
+
end
|
26
|
+
|
27
|
+
def store
|
28
|
+
File.open(File.expand_path(CREDENTIAL_FILE_PATH), 'w', 0600) do |file|
|
29
|
+
file.puts self.to_json
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/cxeed/proxy.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'selenium-webdriver'
|
3
|
+
|
4
|
+
module Cxeed
|
5
|
+
class Proxy
|
6
|
+
def initialize(credential)
|
7
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome('chromeOptions': {args: %i(--headless --disable-gpu window-size=1920,1080)})
|
8
|
+
@driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
|
9
|
+
|
10
|
+
@credential = credential
|
11
|
+
end
|
12
|
+
|
13
|
+
def login
|
14
|
+
@driver.navigate.to(@credential.login_url)
|
15
|
+
|
16
|
+
# 会社コード入力
|
17
|
+
@driver.find_element(:name, 'DataSource').send_keys(@credential.company_code)
|
18
|
+
# 個人コード入力
|
19
|
+
@driver.find_element(:name, 'LoginID').send_keys(@credential.employee_code)
|
20
|
+
# パスワード入力
|
21
|
+
@driver.find_element(:name, 'PassWord').send_keys(@credential.password)
|
22
|
+
# ログイン処理
|
23
|
+
@driver.find_element(:xpath, '//td[@class="loginBtn"]/a').click
|
24
|
+
end
|
25
|
+
|
26
|
+
def login_test
|
27
|
+
login
|
28
|
+
|
29
|
+
@driver.current_url
|
30
|
+
end
|
31
|
+
|
32
|
+
def navigate_to_input_form
|
33
|
+
# frameの指定
|
34
|
+
@driver.switch_to.frame @driver.find_element(id: 'FRAME1')
|
35
|
+
# 勤務データ入力遷移
|
36
|
+
@driver.find_element(:xpath, '//a[@title="勤務データ入力"]').click
|
37
|
+
|
38
|
+
# 一旦main documentに戻る
|
39
|
+
@driver.switch_to.default_content
|
40
|
+
# frameの指定
|
41
|
+
@driver.switch_to.frame @driver.find_element(name: 'FRAME2')
|
42
|
+
end
|
43
|
+
|
44
|
+
def arrive(time = Time.now.strftime('%H:%M'))
|
45
|
+
login
|
46
|
+
|
47
|
+
navigate_to_input_form
|
48
|
+
|
49
|
+
# 出勤時間の入力
|
50
|
+
work_field = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-6"]')
|
51
|
+
@driver.action.send_keys(work_field, time).perform
|
52
|
+
|
53
|
+
# 登録処理
|
54
|
+
@driver.find_element(:xpath, '//input[@name="regbutton"]').click
|
55
|
+
end
|
56
|
+
|
57
|
+
def leave(time = Time.now.strftime('%H:%M'))
|
58
|
+
login
|
59
|
+
|
60
|
+
navigate_to_input_form
|
61
|
+
|
62
|
+
# 退勤時間の入力
|
63
|
+
work_field = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-9"]')
|
64
|
+
@driver.action.send_keys(work_field, time).perform
|
65
|
+
|
66
|
+
# 登録処理
|
67
|
+
@driver.find_element(:xpath, '//input[@name="regbutton"]').click
|
68
|
+
end
|
69
|
+
|
70
|
+
def today
|
71
|
+
login
|
72
|
+
|
73
|
+
navigate_to_input_form
|
74
|
+
|
75
|
+
date = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-0"]/nobr').text
|
76
|
+
arrive_at = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-6"]/nobr').text
|
77
|
+
leave_at = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-9"]/nobr').text
|
78
|
+
|
79
|
+
today = Cxeed::Attendance.new date, arrive_at, leave_at
|
80
|
+
|
81
|
+
today
|
82
|
+
end
|
83
|
+
|
84
|
+
def day_attendance(day)
|
85
|
+
login
|
86
|
+
|
87
|
+
navigate_to_input_form
|
88
|
+
|
89
|
+
# 日付の整形
|
90
|
+
day_str = DateTime.parse(day).strftime('%Y%m%d')
|
91
|
+
|
92
|
+
backspace = "\ue003"
|
93
|
+
|
94
|
+
# 処理期間の入力
|
95
|
+
@driver.find_element(:xpath, '//input[@name="StartYMD"]').send_keys(backspace * 8)
|
96
|
+
@driver.find_element(:xpath, '//input[@name="StartYMD"]').send_keys(day_str)
|
97
|
+
@driver.find_element(:xpath, '//input[@name="EndYMD"]').send_keys(backspace * 8)
|
98
|
+
@driver.find_element(:xpath, '//input[@name="EndYMD"]').send_keys(day_str)
|
99
|
+
|
100
|
+
# 検索
|
101
|
+
@driver.find_element(:xpath, '//input[@name="srchbutton"]').click
|
102
|
+
|
103
|
+
|
104
|
+
date = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-0"]/nobr').text
|
105
|
+
arrive_at = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-6"]/nobr').text
|
106
|
+
leave_at = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-9"]/nobr').text
|
107
|
+
|
108
|
+
Cxeed::Attendance.new date, arrive_at, leave_at
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/lib/cxeed.rb
ADDED
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cxeed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rhythm191
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: selenium-webdriver
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: cyber xeed ruby client
|
84
|
+
email:
|
85
|
+
- sac2ndg+develop@gmail.com
|
86
|
+
executables:
|
87
|
+
- cxeed
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".editorconfig"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/cxeed
|
103
|
+
- bin/setup
|
104
|
+
- cxeed.gemspec
|
105
|
+
- exe/cxeed
|
106
|
+
- lib/cxeed.rb
|
107
|
+
- lib/cxeed/attendance.rb
|
108
|
+
- lib/cxeed/command.rb
|
109
|
+
- lib/cxeed/credential.rb
|
110
|
+
- lib/cxeed/proxy.rb
|
111
|
+
- lib/cxeed/version.rb
|
112
|
+
homepage: https://github.com/rhythm191/cxeed.git
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.6.11
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: cyber xeed ruby client
|
136
|
+
test_files: []
|