cxeed 0.3.2 → 0.3.4

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
  SHA1:
3
- metadata.gz: f2ed9c15754f3bd188355f900cd89cde4e0962e5
4
- data.tar.gz: 3b1e2902c7f6f9690bf0717f12ab58af95dc0eb3
3
+ metadata.gz: b9e0a1ec87cb391cc7de11c2e116029585bacd9c
4
+ data.tar.gz: cde12341979322e9fd5c503b12a9007a01f90cb2
5
5
  SHA512:
6
- metadata.gz: 57e7d0228f1b42daba0d476e2a3b07e8a453b7405de837861d6dabcb775c68755962feb0bf25e8cd706f27b9bfb9b530db7845efd73bd1bb35c9bb49cdd09d00
7
- data.tar.gz: cff45674ca9bf15c774b89fe4cba0b550a9eeae8bdea6569ccd49ba42fe717b86d23bc7ccf7c856a6964d7e69da0ab52146732b6ab16cc5c2ae4f6ff30d69a8a
6
+ metadata.gz: d5d3361d38bc04095fed1c67e6dade284f97b5a5973159251fc5227e8d52c2ec763d9c0bf17185cc212b21c97e034c619206709e2ec8bdffdac67256708fd116
7
+ data.tar.gz: 4b0c01c525edd0b910eda57613b571fd349cdf09575f98dd91ce238a7a35c304631a3a2033c6b923c76b60433f3d0d61392fcd52bd2eebf22a50b9b70ecd0deb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cxeed (0.3.0)
4
+ cxeed (0.3.3)
5
5
  selenium-webdriver
6
6
  thor
7
7
 
@@ -42,4 +42,4 @@ DEPENDENCIES
42
42
  rspec (~> 3.0)
43
43
 
44
44
  BUNDLED WITH
45
- 1.15.4
45
+ 1.16.1
data/README.md CHANGED
@@ -62,7 +62,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
62
62
 
63
63
  ## Contributing
64
64
 
65
- 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.
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rhythm191/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.
66
66
 
67
67
  ## License
68
68
 
@@ -70,4 +70,4 @@ The gem is available as open source under the terms of the [MIT License](http://
70
70
 
71
71
  ## Code of Conduct
72
72
 
73
- 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).
73
+ 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/rhythm191/cxeed/blob/master/CODE_OF_CONDUCT.md).
@@ -34,11 +34,13 @@ module Cxeed
34
34
  end
35
35
 
36
36
  desc 'login_test', 'login_test'
37
+ method_option :verbose, :aliases => '-v', :desc => 'Make the operation more talkative'
38
+ method_option :save_screenshot, :aliases => '-s', :desc => 'Save debug screenshot'
37
39
  def login_test
38
40
  cred = Cxeed::Credential.new
39
- proxy = Cxeed::Proxy.new cred
41
+ proxy = Cxeed::Proxy.new cred, verbose: options.key?(:verbose), save_screenshot: options.key?(:save_screenshot)
40
42
 
41
- if proxy.login_test == 'https://cxg2.i-abs.co.jp/cyberx/Xgw0001.asp?CxClientDispFlg=0'
43
+ if proxy.login_test != cred.login_url
42
44
  say 'login success'
43
45
  else
44
46
  say 'login fail'
@@ -46,9 +48,12 @@ module Cxeed
46
48
  end
47
49
 
48
50
  desc 'arrive [time] [date]', 'submit arrival time (time format is "%H:%M") (date format 2017/09/27)'
51
+ method_option :verbose, :aliases => '-v', :desc => 'Make the operation more talkative'
52
+ method_option :save_screenshot, :aliases => '-s', :desc => 'Save debug screenshot'
49
53
  def arrive(time = Time.now.strftime('%H:%M'), date = Time.now.strftime('%Y/%m/%d'))
54
+
50
55
  cred = Cxeed::Credential.new
51
- proxy = Cxeed::Proxy.new cred
56
+ proxy = Cxeed::Proxy.new cred, verbose: options.key?(:verbose), save_screenshot: options.key?(:save_screenshot)
52
57
 
53
58
  proxy.arrive time, DateTime.parse(date)
54
59
 
@@ -56,9 +61,13 @@ module Cxeed
56
61
  end
57
62
 
58
63
  desc 'leave [time] [date]', 'submit leave time (time format is "%H:%M") (date format 2017/09/27)'
64
+ method_option :verbose, :aliases => '-v', :desc => 'Make the operation more talkative'
65
+ method_option :save_screenshot, :aliases => '-s', :desc => 'Save debug screenshot'
59
66
  def leave(time = Time.now.strftime('%H:%M'), date = Time.now.strftime('%Y/%m/%d'))
67
+ verbose = options.key? :verbose
68
+
60
69
  cred = Cxeed::Credential.new
61
- proxy = Cxeed::Proxy.new cred
70
+ proxy = Cxeed::Proxy.new cred, verbose: options.key?(:verbose), save_screenshot: options.key?(:save_screenshot)
62
71
 
63
72
  proxy.leave time, DateTime.parse(date)
64
73
 
@@ -66,9 +75,11 @@ module Cxeed
66
75
  end
67
76
 
68
77
  desc 'today', 'show today attendance'
78
+ method_option :verbose, :aliases => '-v', :desc => 'Make the operation more talkative'
79
+ method_option :save_screenshot, :aliases => '-s', :desc => 'Save debug screenshot'
69
80
  def today
70
81
  cred = Cxeed::Credential.new
71
- proxy = Cxeed::Proxy.new cred
82
+ proxy = Cxeed::Proxy.new cred, verbose: options.key?(:verbose), save_screenshot: options.key?(:save_screenshot)
72
83
 
73
84
  today = proxy.today
74
85
 
@@ -76,9 +87,10 @@ module Cxeed
76
87
  end
77
88
 
78
89
  desc 'attendance date(format: %Y/%m/%d)', 'show day attendance'
90
+ method_option :verbose, :aliases => '-v', :desc => 'Make the operation more talkative'
79
91
  def attendance(date)
80
92
  cred = Cxeed::Credential.new
81
- proxy = Cxeed::Proxy.new cred
93
+ proxy = Cxeed::Proxy.new cred, verbose: options.key?(:verbose), save_screenshot: options.key?(:save_screenshot)
82
94
 
83
95
  attendance = proxy.day_attendance date
84
96
 
@@ -5,24 +5,41 @@ module Cxeed
5
5
  class Proxy
6
6
  BACKSPACE = "\ue003".freeze
7
7
 
8
- def initialize(credential)
8
+ def initialize(credential, verbose: false, save_screenshot: false)
9
9
  caps = Selenium::WebDriver::Remote::Capabilities.chrome('chromeOptions': {args: %i(--headless --disable-gpu window-size=1920,1080)})
10
10
  @driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
11
11
 
12
12
  @credential = credential
13
+ @verbose = verbose
14
+ @save_screenshot = save_screenshot
13
15
  end
14
16
 
15
17
  def login
18
+ verbose_log 'start login'
19
+
16
20
  @driver.navigate.to(@credential.login_url)
17
21
 
22
+ verbose_log "at #{ @driver.current_url }"
23
+ save_screenshot
24
+
18
25
  # 会社コード入力
19
26
  @driver.find_element(:name, 'DataSource').send_keys(@credential.company_code)
20
27
  # 個人コード入力
21
28
  @driver.find_element(:name, 'LoginID').send_keys(@credential.employee_code)
22
29
  # パスワード入力
23
30
  @driver.find_element(:name, 'PassWord').send_keys(@credential.password)
31
+
32
+
33
+ verbose_log "input DataSource: #{ @driver.find_element(:name, 'DataSource').attribute('value')}"
34
+ verbose_log "input login id: #{ @driver.find_element(:name, 'LoginID').attribute('value')}"
35
+ verbose_log "input password: #{ @driver.find_element(:name, 'PassWord').attribute('value')}"
36
+ save_screenshot
37
+
24
38
  # ログイン処理
25
39
  @driver.find_element(:xpath, '//td[@class="loginBtn"]/a').click
40
+
41
+ verbose_log "after click login page: #{ @driver.current_url }"
42
+ save_screenshot
26
43
  end
27
44
 
28
45
  def login_test
@@ -32,6 +49,9 @@ module Cxeed
32
49
  end
33
50
 
34
51
  def navigate_to_input_form
52
+ verbose_log "start navigate input form: frame2=#{ @driver.find_element(:name, 'FRAME2').attribute('src') }"
53
+ save_screenshot
54
+
35
55
  # frameの指定
36
56
  @driver.switch_to.frame @driver.find_element(id: 'FRAME1')
37
57
  # 勤務データ入力遷移
@@ -41,18 +61,31 @@ module Cxeed
41
61
  @driver.switch_to.default_content
42
62
  # frameの指定
43
63
  @driver.switch_to.frame @driver.find_element(name: 'FRAME2')
64
+
65
+ verbose_log "finish navigate input form: #{ @driver.current_url }"
66
+ save_screenshot
44
67
  end
45
68
 
46
69
  # 引数の日付の入力画面に遷移する
47
70
  def open_date(date)
71
+ verbose_log "start open date command: #{ @driver.current_url }: #{ @driver.find_element(:class, 'cxCmnTitleStr').text }"
72
+
48
73
  # 処理期間の入力
49
74
  @driver.find_element(:xpath, '//input[@name="StartYMD"]').send_keys(BACKSPACE * 8)
50
75
  @driver.find_element(:xpath, '//input[@name="StartYMD"]').send_keys(date.strftime('%Y%m%d'))
51
76
  @driver.find_element(:xpath, '//input[@name="EndYMD"]').send_keys(BACKSPACE * 8)
52
77
  @driver.find_element(:xpath, '//input[@name="EndYMD"]').send_keys(date.strftime('%Y%m%d'))
53
78
 
79
+
80
+ verbose_log "input start date: #{ @driver.find_element(:xpath, '//input[@name="StartYMD"]').attribute('value') }"
81
+ verbose_log "input end date: #{ @driver.find_element(:xpath, '//input[@name="EndYMD"]').attribute('value') }"
82
+ save_screenshot
83
+
54
84
  # 検索
55
85
  @driver.find_element(:xpath, '//input[@name="srchbutton"]').click
86
+
87
+ verbose_log "after click search button: #{ @driver.current_url }"
88
+ save_screenshot
56
89
  end
57
90
 
58
91
  def arrive(time = Time.now.strftime('%H:%M'), date = Time.now)
@@ -65,9 +98,13 @@ module Cxeed
65
98
  # 出勤時間の入力
66
99
  work_field = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-6"]')
67
100
  @driver.action.send_keys(work_field, time).perform
101
+ save_screenshot
68
102
 
69
103
  # 登録処理
70
104
  @driver.find_element(:xpath, '//input[@name="regbutton"]').click
105
+
106
+ verbose_log "after click register button: #{ @driver.current_url }"
107
+ save_screenshot
71
108
  end
72
109
 
73
110
  def leave(time = Time.now.strftime('%H:%M'), date = Time.now)
@@ -80,9 +117,13 @@ module Cxeed
80
117
  # 退勤時間の入力
81
118
  work_field = @driver.find_element(:xpath, '//td[@id="grdXyw1100G-rc-0-9"]')
82
119
  @driver.action.send_keys(work_field, time).perform
120
+ save_screenshot
83
121
 
84
122
  # 登録処理
85
123
  @driver.find_element(:xpath, '//input[@name="regbutton"]').click
124
+
125
+ verbose_log "after click register button: #{ @driver.current_url }"
126
+ save_screenshot
86
127
  end
87
128
 
88
129
  def today
@@ -123,5 +164,20 @@ module Cxeed
123
164
 
124
165
  Cxeed::Attendance.new date, arrive_at, leave_at
125
166
  end
167
+
168
+ private
169
+
170
+ def verbose_log(output_string)
171
+ puts "* #{ output_string }" if @verbose
172
+ end
173
+
174
+ def frame_source(frame_name)
175
+ @driver.find_element(:name, frame_name).attribute('src')
176
+ end
177
+
178
+ def save_screenshot
179
+ @driver.save_screenshot("./cxeed_#{ Time.now.strftime('%Y%m%d%H%M%S%L') }.png") if @save_screenshot
180
+ end
181
+
126
182
  end
127
183
  end
@@ -1,3 +1,3 @@
1
1
  module Cxeed
2
- VERSION = "0.3.2"
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - rhythm191
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler