attend 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: 471822b59755387034cbc0d793c8148d27199f8a
4
+ data.tar.gz: 5551b59d7a3d781e08f14e4e557ec597a97f3492
5
+ SHA512:
6
+ metadata.gz: c98e4a99fb66075256c7343d83f4977749fb1382c96d1e32143d51e5e407796760e56ee28f878e66572628b5ebb029883645609a2ef429fedb5e4c0ea4c5e9a3
7
+ data.tar.gz: 28448fbbebfdb1de44fafa5c3e617bf5899b3822ff1bad9fa8f56c52fadfd5cac53b6e0f4e5646cec1ebec52297d8aaabfd6ce797fba0ec9ce5fda90bed4aae0
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Documentation:
2
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in attend.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ attend (0.1.0)
5
+ clamp (~> 1.1)
6
+ httparty (~> 0.15)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.3.0)
12
+ clamp (1.1.2)
13
+ diff-lcs (1.3)
14
+ httparty (0.15.5)
15
+ multi_xml (>= 0.5.2)
16
+ multi_xml (0.6.0)
17
+ parallel (1.11.2)
18
+ parser (2.4.0.0)
19
+ ast (~> 2.2)
20
+ powerpack (0.1.1)
21
+ rainbow (2.2.2)
22
+ rake
23
+ rake (10.5.0)
24
+ rspec (3.6.0)
25
+ rspec-core (~> 3.6.0)
26
+ rspec-expectations (~> 3.6.0)
27
+ rspec-mocks (~> 3.6.0)
28
+ rspec-core (3.6.0)
29
+ rspec-support (~> 3.6.0)
30
+ rspec-expectations (3.6.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.6.0)
33
+ rspec-mocks (3.6.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.6.0)
36
+ rspec-support (3.6.0)
37
+ rubocop (0.49.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.3.3.1, < 3.0)
40
+ powerpack (~> 0.1)
41
+ rainbow (>= 1.99.1, < 3.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (~> 1.0, >= 1.0.1)
44
+ ruby-progressbar (1.8.1)
45
+ unicode-display_width (1.3.0)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ attend!
52
+ bundler (~> 1.15)
53
+ rspec (~> 3.0)
54
+ rubocop (~> 0.49.1)
55
+
56
+ BUNDLED WITH
57
+ 1.15.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Mckomo
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Attend
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/attend`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'attend'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install attend
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/attend.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/attend.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'attend/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'attend'
10
+ spec.version = Attend::VERSION
11
+ spec.authors = ['Maciej Komorowski']
12
+ spec.email = ['mckomo@gmail.com']
13
+ spec.license = 'MIT'
14
+
15
+ spec.summary = 'Register Zoho Poeople attendance using CLI'
16
+ spec.description = 'Attend is command line tool that will help you register your Zoho Poeople attendance in fast and easy way'
17
+ spec.homepage = 'https://github.com/mckomo/attend'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'httparty', '~> 0.15'
27
+ spec.add_dependency 'clamp', '~> 1.1'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.15'
30
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.49.1'
32
+ end
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 'attend'
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
@@ -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
data/entrypoiny.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+
5
+ DATE_FORMAT = 'dd/MM/yyyy HH:mm:ss'
6
+ AUTH_TOKEN = '3322c84ac90c17b50ad5268795854197'
7
+
8
+ attendance_endpoint = 'https://people.zoho.com/people/api/attendance'
9
+
10
+ parameters = {
11
+ 'authtoken' => AUTH_TOKEN,
12
+ 'dateFormat' => DATE_FORMAT,
13
+ 'checkIn' => '26/06/2017 10:00:00',
14
+ 'checkOut' => '26/06/2017 18:00:00',
15
+ 'emailId' => 'krzysztof.kucharski@codete.com'
16
+ }
17
+
18
+ response = HTTParty.post(attendance_endpoint, query: parameters)
19
+
20
+ puts response.body, response.code, response.message, response.headers.inspect
data/exe/attend ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'clamp'
4
+ require 'date'
5
+ require 'httparty'
6
+
7
+ AUTH_TOKEN = ENV['ZOHO_PEOPLE_AUTH_TOKEN']
8
+ DATE_FORMAT = 'dd/MM/yyyy HH:mm:ss'
9
+
10
+ parse_date = ->(v) { Date.parse(v) }
11
+
12
+ Clamp do
13
+ option '--email', 'EMAIL', 'employee email id', required: true
14
+ option '--check_in', 'CHECK_IN', 'check in time', required: true
15
+ option '--check_out', 'CHECK_OUT', 'check out time', required: true
16
+ option '--from', 'FROM', 'date of the first work day', default: Date.today, &parse_date
17
+ option '--to', 'TO', 'date of the las work day', default: Date.today, &parse_date
18
+ option '--dry', :flag, 'enables dry run'
19
+
20
+ def execute
21
+ days_between = from.step(to).reject(&:sunday?).reject(&:saturday?)
22
+
23
+ days_between.map(&:to_datetime).each do |date_time|
24
+ check_in_time = date_time.new_offset("+#{check_in}")
25
+ check_out_time = date_time.new_offset("+#{check_out}")
26
+
27
+ if dry?
28
+ puts "DRY RUN: Committing attendance from #{check_in_time} to #{check_out_time}"
29
+ next
30
+ end
31
+
32
+ response = post_attendance(check_in_time, check_out_time)
33
+
34
+ if response.ok?
35
+ puts "Successfully registered attendance from #{check_in_time} to #{check_out_time}"
36
+ elsif response
37
+ raise "Failed to register attendance. Error: #{response.body}"
38
+ end
39
+ end
40
+ end
41
+
42
+ def post_attendance(check_in_time, check_out_time)
43
+ parameters = {
44
+ 'authtoken' => AUTH_TOKEN,
45
+ 'dateFormat' => DATE_FORMAT,
46
+ 'checkIn' => check_in_time.strftime('%d/%m/%Y %H:%M:%S'),
47
+ 'checkOut' => check_out_time.strftime('%d/%m/%Y %H:%M:%S'),
48
+ 'emailId' => email,
49
+ }
50
+
51
+ HTTParty.post('https://people.zoho.com/people/api/attendance', query: parameters)
52
+ end
53
+ end
54
+
data/lib/attend.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'attend/version'
4
+
5
+ module Attend
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Attend
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zoho
4
+ module People
5
+ class Attendance
6
+ DATE_FORMAT = 'dd/MM/yyyy HH:mm:ss'
7
+
8
+ attr_reader :check_in, :check_out, :email_id
9
+
10
+ def initialize(check_in:, check_out:, email_id:)
11
+ @check_in = check_in
12
+ @check_out = check_out
13
+ @email_id = email_id
14
+ end
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: attend
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maciej Komorowski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: clamp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.49.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.49.1
83
+ description: Attend is command line tool that will help you register your Zoho Poeople
84
+ attendance in fast and easy way
85
+ email:
86
+ - mckomo@gmail.com
87
+ executables:
88
+ - attend
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".rubocop.yml"
95
+ - ".ruby-version"
96
+ - ".travis.yml"
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - attend.gemspec
103
+ - bin/console
104
+ - bin/setup
105
+ - entrypoiny.rb
106
+ - exe/attend
107
+ - lib/attend.rb
108
+ - lib/attend/version.rb
109
+ - lib/zoho/people/attendance.rb
110
+ homepage: https://github.com/mckomo/attend
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.6.11
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Register Zoho Poeople attendance using CLI
134
+ test_files: []