exact_hours 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2bb7f8c0d5c6e25bfdee5226bfcfcac25beebc84
4
+ data.tar.gz: 05b437ab5b5adf9857aeacc9c340cf48c1e31bc7
5
+ SHA512:
6
+ metadata.gz: 634dd4696742bc5768720e69c259af081842cf13b4e82a5635f85a335a02be5eb6cc1451cbcf3fee249bf1c66ff0c9fd074a226a3eaa91d23ceafc05d7dda6f6
7
+ data.tar.gz: 5966ab570914ed0e4ba8297cc523d66e9636aa5e1a218f74f6017125a2f4623b658a976af4566403a5e4481935463f3d0dcdbd4cc52ea87fbe514d9ee17b4842
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,8 @@
1
+ # CHANGELOG exact_hours
2
+
3
+ ## Sprint 0.0.1
4
+ - [x] working prototype
5
+ - [x] handleiding
6
+ - [x] calculate date
7
+ - [x] output to csv
8
+ - [x] resolve client id
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exact_hours.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Pim Snel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ # ExactHours
2
+
3
+ Registreer je uren in een plain text yaml bestand en converteer dit voor
4
+ exact.
5
+
6
+ ## Usage
7
+
8
+ ### 1. Maak week bestand
9
+
10
+ Maak een weekbestand aan met de naam week.jjjj.ww.yml. vervang jjjj met
11
+ 2015 en wk met het weeknummer. De naam van het bestand mag niet anders
12
+ zijn.
13
+
14
+ ### 2. clients bestand
15
+
16
+ Zorg dat in het weekbestand een clients mapping bestand aanwezig is. Dit
17
+ bestand heet ```clients``` en bevat alle klanten met hun id's space
18
+ gescheiden. A la een ```hosts``` bestand.
19
+
20
+ ```
21
+ 7517 CLIENT 1
22
+ 7519 CLIENT 2
23
+ 7520 CLIENT 3
24
+ 7521 CLIENT 4
25
+ 7523 etc.
26
+ ```
27
+
28
+ ### 3. Registreer je uren in YAML
29
+
30
+ Houdt je uren van de week bij op de volgende manier:
31
+
32
+ ```yaml
33
+ ---
34
+ employee: 5
35
+ days:
36
+ Monday:
37
+ - qty: 2.0
38
+ client: DASSLR
39
+ type: tech_quote
40
+ note: aanbieden offerte
41
+
42
+ Tuesday:
43
+ - qty: 4.0
44
+ client: VERDER
45
+ type: tech_sysadmin
46
+ note: deployments fixen testplan (sla website)
47
+ project: VERDER-2015
48
+
49
+ - qty: 1.0
50
+ client: BUWA
51
+ type: tech_quote
52
+ note: overleg over offerte servoy;
53
+
54
+ - qty: 1.0
55
+ client: BUWA
56
+ type: tech_consult
57
+ note: advies intranet, advies netwerk
58
+ ```
59
+
60
+ hanteer de volgende uursoorten:
61
+ ```
62
+ # tech_consult
63
+ # tech_support
64
+ # tech_design
65
+ # tech_dev
66
+ # tech_sysadmin
67
+ # tech_edu
68
+ # tech_quote
69
+ ```
70
+
71
+ ### 4. Draai eind van de week in de terminal het exact_hours commando
72
+
73
+ ```bash
74
+ exact_hours prepare_for_import ~/Desktop/Uren\ hervorming\ Exact/weekimports/week.2015.45.yml
75
+ ```
76
+
77
+ ### 5. Importeer de uren in exact
78
+
79
+ - klik op LLP linksboven in het nieuwe menu
80
+ - klik op import/export
81
+ - klik op CSV/Excel
82
+ - klik op Project -> Tijd
83
+ - kies ```Anders gescheiden waarden``` tenzij je al een eigen definitie
84
+ hebt gemaakt
85
+ - na succesvolle import moeten ze nog worden ingediend
86
+
87
+ ## TODO
88
+
89
+ - [ ] bulk export van meerdere lijstjes
90
+ - [ ] kan admin ieders deze lijst importeren?
91
+ - [ ] travis
92
+ - [ ] coverage
93
+
94
+ ## Installation
95
+
96
+ $ gem install exact_hours
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = "test/test_*.rb"
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
11
+
12
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'thor'
5
+ require 'exact_hours/commands'
6
+
7
+ ExactHours::Commands.start(ARGV)
8
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exact_hours/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "exact_hours"
8
+ spec.version = ExactHours::VERSION
9
+ spec.authors = ["Pim Snel"]
10
+ spec.email = ["pim@lingewoud.nl"]
11
+ spec.summary = %q{CLI utility for Exact Online}
12
+ spec.description = %q{CLI Utility working with Exact Online. converts hours to CVS}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "simplecov", "~> 0.10"
24
+ spec.add_development_dependency "minitest", "~> 5.1"
25
+
26
+ spec.add_runtime_dependency "thor", "~> 0.19"
27
+ spec.add_runtime_dependency "text-table", "~> 1.2"
28
+ end
@@ -0,0 +1,101 @@
1
+ require 'csv'
2
+ require 'yaml'
3
+ require 'pp'
4
+ require 'text-table'
5
+
6
+ module ExactHours
7
+ class Commands < Thor
8
+ class_option :verbose, :desc => 'Be more verbose', :type => :boolean, :aliases => '-v'
9
+
10
+ def initialize(*args)
11
+ super
12
+ #@@verbose = true if options[:verbose]
13
+ end
14
+
15
+ desc "version", "display version"
16
+ def version
17
+ print ExactHours::VERSION + "\n"
18
+ end
19
+
20
+ desc "prepare_for_import [weekfile]", "convert weekfile to csv for exact import"
21
+ def prepare_for_import(weekfile)
22
+
23
+ clients_ids = get_clients weekfile
24
+
25
+ year,week_num = get_date_from_weekfile weekfile
26
+
27
+ weekdata = YAML.load_file(weekfile)
28
+
29
+ table = Text::Table.new
30
+ table.head = ['Account','Date','Employee','Item','Notes','Project','Quantity']
31
+
32
+
33
+ weekdata["days"].each do | day, blocks |
34
+
35
+ blocks.each do | block |
36
+ table.rows << [clients_ids[block['client']], get_date(year, week_num, day), weekdata['employee'], block['type'],block['note'], block['project'], block['qty']]
37
+ end
38
+
39
+ end
40
+
41
+ print table.to_s
42
+
43
+
44
+ csv_string = CSV.generate force_quotes: false , col_sep: ";" do |csv|
45
+
46
+ table.rows.each do | row |
47
+ csv << row
48
+ end
49
+ end
50
+
51
+ csvfile = File.join File.dirname(weekfile), 'exact_hours.csv'
52
+ File.open(csvfile, "wb") do |f|
53
+ f.write(csv_string)
54
+ end
55
+
56
+ end
57
+
58
+
59
+ private
60
+
61
+ def get_date_from_weekfile(weekfile)
62
+ p weekfile
63
+ raise "Week file does not exist" unless File.exists? weekfile
64
+ arr = File.basename(weekfile).split('.')
65
+ [arr[1].to_i, arr[2].to_i]
66
+ end
67
+
68
+ def get_date( year, week_num , day)
69
+ week_start = Date.commercial( year, week_num, DateTime.parse(day).wday )
70
+ week_start.strftime( "%d-%m-%Y" )
71
+ end
72
+
73
+ def get_clients weekfile
74
+
75
+ clientsfile = File.join File.dirname(weekfile), 'clients'
76
+ raise "Clients does not exist" unless File.exists? clientsfile
77
+
78
+
79
+ vars = {}
80
+ IO.foreach(clientsfile) do |line|
81
+ #discard comment lines
82
+ if line.match(/^#/)
83
+ next
84
+ elsif
85
+ #discard a blank line
86
+ line.match(/^$/)
87
+ next
88
+ else
89
+ temp = []
90
+
91
+ temp[0],temp[1] = line.gsub(/\s+/m, ' ').strip.split(" ")
92
+
93
+ vars[temp[1]] = temp[0]
94
+ end
95
+ end
96
+
97
+ return vars
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,3 @@
1
+ module ExactHours
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+
3
+ class TestExactHoursCLI < Minitest::Test
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_version
9
+ assert_equal ExactHours::VERSION+"\n", run_thor_capture(['version'])
10
+ end
11
+
12
+ def test_prepare
13
+ # run_thor_capture ['prepare_for_import', '']
14
+ run_thor ['prepare_for_import', '/Users/pim/Desktop/Uren hervorming Exact/weekimports/week.2015.45.yml']
15
+
16
+ # assert_match(/uploadasadmin_yes/, out2)
17
+ end
18
+
19
+ private
20
+
21
+ def run_thor(args)
22
+ # args << '--verbose'
23
+ ExactHours::Commands.start(args)
24
+ end
25
+
26
+ def run_thor_capture(args)
27
+ # args << '--verbose'
28
+ out, _ = capture_io do
29
+ ExactHours::Commands.start(args)
30
+ end
31
+ out
32
+ end
33
+
34
+ end
@@ -0,0 +1,20 @@
1
+ require 'simplecov'
2
+ require 'thor'
3
+
4
+ SimpleCov.start do
5
+ add_filter '/test/'
6
+ add_filter '/vendor/'
7
+ end
8
+ require 'exact_hours/commands'
9
+ require 'exact_hours/version'
10
+
11
+ require 'minitest'
12
+ require 'minitest/unit'
13
+ require 'minitest/autorun'
14
+ require 'minitest/pride'
15
+
16
+ #require "codeclimate-test-reporter"
17
+ #CodeClimate::TestReporter.start
18
+
19
+
20
+
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exact_hours
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pim Snel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-06 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ - !ruby/object:Gem::Dependency
84
+ name: text-table
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ description: CLI Utility working with Exact Online. converts hours to CVS
98
+ email:
99
+ - pim@lingewoud.nl
100
+ executables:
101
+ - exact_hours
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/exact_hours
112
+ - exact_hours.gemspec
113
+ - lib/exact_hours/commands.rb
114
+ - lib/exact_hours/version.rb
115
+ - test/test_exact_hours_cli.rb
116
+ - test/test_helper.rb
117
+ homepage: ''
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.3
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: CLI utility for Exact Online
141
+ test_files:
142
+ - test/test_exact_hours_cli.rb
143
+ - test/test_helper.rb