king_of_time 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 878a57145c2809d92159b793058404b4fa853105
4
+ data.tar.gz: ee11239ab9eead3b11f01ef0827fd896ed1d309c
5
+ SHA512:
6
+ metadata.gz: 82a9c45d433e101721ba598624766450a5dab4e11fe616d680c5ec750923c8227d666996c6a9a183fe66f882c3c4e9c490421ec49caa3200bab91a68b15a3945
7
+ data.tar.gz: 18fdb1248ca1360c32ba39fe882001d3c77246fb34d6c6fe01b64e51eaff7d03ec9e732914553243f69fe442cbf4f923a0b4511064c49a5957d3838f3328f2a3
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ - 2.3.0
5
+ - rbx
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in king_of_time.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # KingOfTime
2
+
3
+ Ruby API library for daily check-in/check-out operation.
4
+
5
+ - http://www.kingtime.jp/
6
+
7
+ [![Build Status](https://travis-ci.org/matsubo/king_of_time.svg?branch=master)](https://travis-ci.org/matsubo/king_of_time)
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'king_of_time'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install king_of_time
25
+
26
+ ## Usage
27
+
28
+
29
+ ```
30
+ king_of_time = KingOfTime.new({
31
+ timerecorder_id: 1111111111,
32
+ employee_id: 2222222222,
33
+ name: '松倉 友樹',
34
+ })
35
+
36
+ # check in
37
+ king_of_time.check_in
38
+
39
+ # check out
40
+ king_of_time.check_out
41
+ ```
42
+
43
+
44
+ ## Test
45
+
46
+
47
+ ```
48
+ % rspec
49
+ ```
50
+
51
+ ## Future work
52
+
53
+ - I18n
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ 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).
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/matsubo/king_of_time.
64
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "king_of_time"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://kingoftime-recorder.appspot.com/ajax?function=record_timestamp_and_log
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9&employee_id=2222222222&employee_timerecorder_id=1111111111&timerecorder_id=1111111111&recording_type_code=1&device_type_code=4&recording_time=20160426225315&now=1461678795&kot_url=https%3A%2F%2Fs3.kingtime.jp%2Fgateway%2Fgaegateway%3Fpage_id%3D%2Fgaegateway%2F&log=04%2F26%2022%3A53%20%3Cfont%20color%3D'%230000FF'%3ECheck-in%3C%2Ffont%3E%20%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9
9
+ headers:
10
+ Accept:
11
+ - application/json, text/javascript, */*; q=0.01
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ User-Agent:
17
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML,
18
+ like Gecko) Chrome/50.0.2661.75 Safari/537.36
19
+ X-Requested-With:
20
+ - XMLHttpRequest
21
+ Content-Length:
22
+ - '425'
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ Date:
29
+ - Tue, 26 Apr 2016 13:53:16 GMT
30
+ Content-Type:
31
+ - text/html
32
+ Server:
33
+ - Google Frontend
34
+ Content-Length:
35
+ - '20'
36
+ Alternate-Protocol:
37
+ - 443:quic
38
+ Alt-Svc:
39
+ - quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"
40
+ body:
41
+ encoding: UTF-8
42
+ string: result=OK&time=22:53
43
+ http_version:
44
+ recorded_at: Tue, 26 Apr 2016 13:53:16 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://kingoftime-recorder.appspot.com/ajax?function=record_timestamp_and_log
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9&employee_id=2222222222&employee_timerecorder_id=1111111111&timerecorder_id=1111111111&recording_type_code=2&device_type_code=4&recording_time=20160426225316&now=1461678796&kot_url=https%3A%2F%2Fs3.kingtime.jp%2Fgateway%2Fgaegateway%3Fpage_id%3D%2Fgaegateway%2F&log=04%2F26%2022%3A53%20%3Cfont%20color%3D'%23FF0000'%3ECheck-out%3C%2Ffont%3E%20%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9
9
+ headers:
10
+ Accept:
11
+ - application/json, text/javascript, */*; q=0.01
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ User-Agent:
17
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML,
18
+ like Gecko) Chrome/50.0.2661.75 Safari/537.36
19
+ X-Requested-With:
20
+ - XMLHttpRequest
21
+ Content-Length:
22
+ - '426'
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ Date:
29
+ - Tue, 26 Apr 2016 13:53:16 GMT
30
+ Content-Type:
31
+ - text/html
32
+ Server:
33
+ - Google Frontend
34
+ Content-Length:
35
+ - '20'
36
+ Alternate-Protocol:
37
+ - 443:quic
38
+ Alt-Svc:
39
+ - quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"
40
+ body:
41
+ encoding: UTF-8
42
+ string: result=OK&time=22:53
43
+ http_version:
44
+ recorded_at: Tue, 26 Apr 2016 13:53:16 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://kingoftime-recorder.appspot.com/ajax?function=record_timestamp_and_log
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9&employee_id=2222222222&employee_timerecorder_id=1111111111&timerecorder_id=1111111111&recording_type_code=4&device_type_code=4&recording_time=20160426225317&now=1461678797&kot_url=https%3A%2F%2Fs3.kingtime.jp%2Fgateway%2Fgaegateway%3Fpage_id%3D%2Fgaegateway%2F&log=04%2F26%2022%3A53%20%3Cfont%20color%3D'%23FF00FF'%3EEnd-break%3C%2Ffont%3E%20%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9
9
+ headers:
10
+ Accept:
11
+ - application/json, text/javascript, */*; q=0.01
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ User-Agent:
17
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML,
18
+ like Gecko) Chrome/50.0.2661.75 Safari/537.36
19
+ X-Requested-With:
20
+ - XMLHttpRequest
21
+ Content-Length:
22
+ - '426'
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ Date:
29
+ - Tue, 26 Apr 2016 13:53:18 GMT
30
+ Content-Type:
31
+ - text/html
32
+ Server:
33
+ - Google Frontend
34
+ Content-Length:
35
+ - '20'
36
+ Alternate-Protocol:
37
+ - 443:quic
38
+ Alt-Svc:
39
+ - quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"
40
+ body:
41
+ encoding: UTF-8
42
+ string: result=OK&time=22:53
43
+ http_version:
44
+ recorded_at: Tue, 26 Apr 2016 13:53:18 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://kingoftime-recorder.appspot.com/ajax?function=record_timestamp_and_log
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9&employee_id=2222222222&employee_timerecorder_id=1111111111&timerecorder_id=1111111111&recording_type_code=3&device_type_code=4&recording_time=20160426225316&now=1461678796&kot_url=https%3A%2F%2Fs3.kingtime.jp%2Fgateway%2Fgaegateway%3Fpage_id%3D%2Fgaegateway%2F&log=04%2F26%2022%3A53%20%3Cfont%20color%3D'%2300FF00'%3EStart%20break%3C%2Ffont%3E%20%E6%9D%BE%E5%80%89%20%E5%8F%8B%E6%A8%B9
9
+ headers:
10
+ Accept:
11
+ - application/json, text/javascript, */*; q=0.01
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ User-Agent:
17
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML,
18
+ like Gecko) Chrome/50.0.2661.75 Safari/537.36
19
+ X-Requested-With:
20
+ - XMLHttpRequest
21
+ Content-Length:
22
+ - '430'
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ Date:
29
+ - Tue, 26 Apr 2016 13:53:17 GMT
30
+ Content-Type:
31
+ - text/html
32
+ Server:
33
+ - Google Frontend
34
+ Content-Length:
35
+ - '20'
36
+ Alternate-Protocol:
37
+ - 443:quic
38
+ Alt-Svc:
39
+ - quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"
40
+ body:
41
+ encoding: UTF-8
42
+ string: result=OK&time=22:53
43
+ http_version:
44
+ recorded_at: Tue, 26 Apr 2016 13:53:17 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'king_of_time/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "king_of_time"
8
+ spec.version = KingOfTime::VERSION
9
+ spec.authors = ["Yuki Matsukura"]
10
+ spec.email = ["matsubokkuri@gmail.com"]
11
+
12
+ spec.summary = %q{King of Time HTTP client.}
13
+ spec.description = %q{King of Time HTTP client.}
14
+ spec.homepage = "http://www.kingtime.jp/"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ unless spec.respond_to?(:metadata)
19
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.11"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "vcr"
30
+ spec.add_development_dependency "rest-client"
31
+ spec.add_development_dependency "rspec"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "pry-doc"
34
+ spec.add_development_dependency "simplecov"
35
+
36
+ end
@@ -0,0 +1,72 @@
1
+ require "king_of_time/version"
2
+ require 'rest-client'
3
+
4
+ class KingOfTime
5
+
6
+ END_POINT = 'https://kingoftime-recorder.appspot.com/ajax?function=record_timestamp_and_log'
7
+
8
+ def initialize(name:, employee_id:, timerecorder_id:)
9
+ @param = {}
10
+ @param[:name] = name
11
+ @param[:employee_id] = employee_id
12
+ @param[:timerecorder_id] = @param[:employee_timerecorder_id] = timerecorder_id
13
+ end
14
+
15
+ def check_in
16
+ http_request(:checkin)
17
+ end
18
+
19
+ def check_out
20
+ http_request(:checkout)
21
+ end
22
+
23
+
24
+ def start_break
25
+ http_request(:start_break)
26
+ end
27
+
28
+ def end_break
29
+ http_request(:end_break)
30
+ end
31
+
32
+ private
33
+ def http_request(type)
34
+
35
+ messages = {
36
+ checkin: "<font color='#0000FF'>Check-in</font>",
37
+ checkout: "<font color='#FF0000'>Check-out</font>",
38
+ start_break: "<font color='#00FF00'>Start break</font>",
39
+ end_break: "<font color='#FF00FF'>End-break</font>",
40
+ }
41
+
42
+ codes = {
43
+ checkin: 1,
44
+ checkout: 2,
45
+ start_break: 3,
46
+ end_break: 4,
47
+ }
48
+
49
+ params = @param.merge({
50
+ recording_type_code: codes[type],
51
+ device_type_code:4,
52
+ recording_time: Time.now.strftime('%Y%m%d%H%M%S'),
53
+ now: Time.now.to_i,
54
+ kot_url: 'https://s3.kingtime.jp/gateway/gaegateway?page_id=/gaegateway/',
55
+ log: Time.now.strftime('%m/%d %H:%M') + ' ' + messages[type] + ' ' + @param[:name],
56
+ # input_password: '', # not necessary
57
+ })
58
+
59
+ headers = {
60
+ 'Accept' => 'application/json, text/javascript, */*; q=0.01',
61
+ 'Content-Type' => 'application/x-www-form-urlencoded',
62
+ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36',
63
+ 'X-Requested-With' => 'XMLHttpRequest',
64
+ }
65
+
66
+ RestClient.post END_POINT, params, headers
67
+
68
+
69
+ end
70
+
71
+
72
+ end
@@ -0,0 +1,3 @@
1
+ class KingOfTime
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: king_of_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuki Matsukura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-27 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: vcr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: rspec
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
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: pry-doc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: King of Time HTTP client.
126
+ email:
127
+ - matsubokkuri@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - README.md
137
+ - Rakefile
138
+ - bin/console
139
+ - bin/setup
140
+ - fixtures/vcr_cassettes/check_in.yml
141
+ - fixtures/vcr_cassettes/check_out.yml
142
+ - fixtures/vcr_cassettes/end_break.yml
143
+ - fixtures/vcr_cassettes/start_break.yml
144
+ - king_of_time.gemspec
145
+ - lib/king_of_time.rb
146
+ - lib/king_of_time/version.rb
147
+ homepage: http://www.kingtime.jp/
148
+ licenses: []
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.5.1
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: King of Time HTTP client.
170
+ test_files: []
171
+ has_rdoc: