wawka 0.1.0
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/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +12 -0
- data/README.md +65 -0
- data/Rakefile +6 -0
- data/bin/console +15 -0
- data/bin/rake +17 -0
- data/bin/setup +8 -0
- data/exe/wawka +5 -0
- data/lib/example/config.yml +28 -0
- data/lib/example/evidence.xls +0 -0
- data/lib/wawka/cli.rb +25 -0
- data/lib/wawka/container.rb +17 -0
- data/lib/wawka/harvest.rb +21 -0
- data/lib/wawka/transactions/base.rb +11 -0
- data/lib/wawka/transactions/fetch_harvest.rb +23 -0
- data/lib/wawka/transactions/generate_evidence.rb +49 -0
- data/lib/wawka/transactions/generate_excel.rb +57 -0
- data/lib/wawka/transactions/operation.rb +11 -0
- data/lib/wawka/version.rb +3 -0
- data/lib/wawka.rb +35 -0
- data/wawka.gemspec +39 -0
- metadata +212 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1acdf3ba19b34b704abe92a4173337a944e9d6a8
|
|
4
|
+
data.tar.gz: 31efa254b0b540726deaf59ec2784035fc620462
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c5427faad647bc685b7d76909d86a466ccc8ea002d29badf9ab1a2bb393ae507ee1845741b545a32f828be07d3bd6c1813c4c3369ebd955bb206b26ecaaaa8de
|
|
7
|
+
data.tar.gz: 139a9ac9644860c340f816351072a11c41fa74f886706b9f59c8f05587a00eae8ca7d81f22be0eeacdfaf232fe25540129dfb8855dbf5703efef9d1a9c548edd
|
data/.gitignore
ADDED
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 arkadiusz.buras@codesthq.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,102 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
wawka (0.1.0)
|
|
5
|
+
activesupport (~> 5.2)
|
|
6
|
+
dry-transaction (~> 0.13)
|
|
7
|
+
httparty (~> 0.16.2)
|
|
8
|
+
simple-spreadsheet (~> 0.5.0)
|
|
9
|
+
spreadsheet (~> 1.1)
|
|
10
|
+
thor (~> 0.20.0)
|
|
11
|
+
|
|
12
|
+
GEM
|
|
13
|
+
remote: https://rubygems.org/
|
|
14
|
+
specs:
|
|
15
|
+
activesupport (5.2.0)
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
|
+
i18n (>= 0.7, < 2)
|
|
18
|
+
minitest (~> 5.1)
|
|
19
|
+
tzinfo (~> 1.1)
|
|
20
|
+
coderay (1.1.2)
|
|
21
|
+
concurrent-ruby (1.0.5)
|
|
22
|
+
diff-lcs (1.3)
|
|
23
|
+
dry-configurable (0.7.0)
|
|
24
|
+
concurrent-ruby (~> 1.0)
|
|
25
|
+
dry-container (0.6.0)
|
|
26
|
+
concurrent-ruby (~> 1.0)
|
|
27
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
|
28
|
+
dry-core (0.4.7)
|
|
29
|
+
concurrent-ruby (~> 1.0)
|
|
30
|
+
dry-equalizer (0.2.1)
|
|
31
|
+
dry-events (0.1.0)
|
|
32
|
+
concurrent-ruby (~> 1.0)
|
|
33
|
+
dry-core (~> 0.4)
|
|
34
|
+
dry-equalizer (~> 0.2)
|
|
35
|
+
dry-matcher (0.7.0)
|
|
36
|
+
dry-monads (1.0.0)
|
|
37
|
+
concurrent-ruby (~> 1.0)
|
|
38
|
+
dry-core (~> 0.4, >= 0.4.4)
|
|
39
|
+
dry-equalizer
|
|
40
|
+
dry-transaction (0.13.0)
|
|
41
|
+
dry-container (>= 0.2.8)
|
|
42
|
+
dry-events (>= 0.1.0)
|
|
43
|
+
dry-matcher (>= 0.7.0)
|
|
44
|
+
dry-monads (>= 0.4.0)
|
|
45
|
+
httparty (0.16.2)
|
|
46
|
+
multi_xml (>= 0.5.2)
|
|
47
|
+
i18n (1.0.1)
|
|
48
|
+
concurrent-ruby (~> 1.0)
|
|
49
|
+
method_source (0.9.0)
|
|
50
|
+
mini_portile2 (2.3.0)
|
|
51
|
+
minitest (5.11.3)
|
|
52
|
+
multi_xml (0.6.0)
|
|
53
|
+
nokogiri (1.8.4)
|
|
54
|
+
mini_portile2 (~> 2.3.0)
|
|
55
|
+
pry (0.11.3)
|
|
56
|
+
coderay (~> 1.1.0)
|
|
57
|
+
method_source (~> 0.9.0)
|
|
58
|
+
rake (10.5.0)
|
|
59
|
+
roo (2.7.1)
|
|
60
|
+
nokogiri (~> 1)
|
|
61
|
+
rubyzip (~> 1.1, < 2.0.0)
|
|
62
|
+
roo-xls (1.2.0)
|
|
63
|
+
nokogiri
|
|
64
|
+
roo (>= 2.0.0, < 3)
|
|
65
|
+
spreadsheet (> 0.9.0)
|
|
66
|
+
rspec (3.7.0)
|
|
67
|
+
rspec-core (~> 3.7.0)
|
|
68
|
+
rspec-expectations (~> 3.7.0)
|
|
69
|
+
rspec-mocks (~> 3.7.0)
|
|
70
|
+
rspec-core (3.7.1)
|
|
71
|
+
rspec-support (~> 3.7.0)
|
|
72
|
+
rspec-expectations (3.7.0)
|
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
|
+
rspec-support (~> 3.7.0)
|
|
75
|
+
rspec-mocks (3.7.0)
|
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
+
rspec-support (~> 3.7.0)
|
|
78
|
+
rspec-support (3.7.1)
|
|
79
|
+
ruby-ole (1.2.12.1)
|
|
80
|
+
rubyzip (1.2.1)
|
|
81
|
+
simple-spreadsheet (0.5.0)
|
|
82
|
+
roo (~> 2.4)
|
|
83
|
+
roo-xls (~> 1.0)
|
|
84
|
+
spreadsheet (1.1.7)
|
|
85
|
+
ruby-ole (>= 1.0)
|
|
86
|
+
thor (0.20.0)
|
|
87
|
+
thread_safe (0.3.6)
|
|
88
|
+
tzinfo (1.2.5)
|
|
89
|
+
thread_safe (~> 0.1)
|
|
90
|
+
|
|
91
|
+
PLATFORMS
|
|
92
|
+
ruby
|
|
93
|
+
|
|
94
|
+
DEPENDENCIES
|
|
95
|
+
bundler (~> 1.16)
|
|
96
|
+
pry
|
|
97
|
+
rake (~> 10.0)
|
|
98
|
+
rspec (~> 3.0)
|
|
99
|
+
wawka!
|
|
100
|
+
|
|
101
|
+
BUNDLED WITH
|
|
102
|
+
1.16.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
2
|
+
Version 2, December 2004
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2018 Arkadiusz Buras
|
|
5
|
+
|
|
6
|
+
14 rue de Plaisance, 75014 Paris, France
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
8
|
+
copies of this license document, and changing it is allowed as long
|
|
9
|
+
as the name is changed.
|
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Wawka
|
|
2
|
+
|
|
3
|
+
Tool for generating documents for people in Warsaw.
|
|
4
|
+
|
|
5
|
+
https://youtu.be/j1epEtB0lVo?t=1m59s
|
|
6
|
+
|
|
7
|
+
## Instalation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem install wawka
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Prepare configuration:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
wawka config
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Your configuration now resides at `~/.wawka.yaml`. Generate and fetch personal access token from: `https://id.getharvest.com/developers`
|
|
22
|
+
|
|
23
|
+
### Customizing messages for report:
|
|
24
|
+
|
|
25
|
+
In `~/.wawka.yaml` file, there is a `enterprise` where you can map Task Category to messages.
|
|
26
|
+
|
|
27
|
+
```YAML
|
|
28
|
+
enterprise:
|
|
29
|
+
Development:
|
|
30
|
+
- Rozwój wewnętrznych narzędzi oraz oprogramowania dla ...
|
|
31
|
+
Code review:
|
|
32
|
+
- Audyt i sprawdzanie poprawności tworzonego kodu
|
|
33
|
+
Meeting:
|
|
34
|
+
- Planowanie architektury systemu
|
|
35
|
+
Support:
|
|
36
|
+
- Wsparcie techniczne
|
|
37
|
+
Admin:
|
|
38
|
+
- Administracja serwerami oraz infrastruktórą
|
|
39
|
+
Design:
|
|
40
|
+
- Projektowanie wyglądu oprogramowania
|
|
41
|
+
Project Managment:
|
|
42
|
+
- Zarządzanie projektem
|
|
43
|
+
Research:
|
|
44
|
+
- Analiza narzędzi oraz rozwój oprogramowania
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Generating harvest report:
|
|
48
|
+
|
|
49
|
+
For current date
|
|
50
|
+
```
|
|
51
|
+
wawka harvest ./evidence.xls
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For specified date
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
wawka harvest ./evidence.xls 2018-07-20
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## TODO
|
|
61
|
+
|
|
62
|
+
- Support for creating invoices using https://www.infakt.pl/developers
|
|
63
|
+
- Whole pipeline for generating invoice and evidence xls
|
|
64
|
+
- Sending xls evidence and invoice using email
|
|
65
|
+
- Cron!
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "wawka"
|
|
5
|
+
require 'pry'
|
|
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
|
+
Pry.start(__FILE__)
|
data/bin/rake
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
#
|
|
4
|
+
# This file was generated by Bundler.
|
|
5
|
+
#
|
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
|
7
|
+
# this file is here to facilitate running it.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
require "pathname"
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
12
|
+
Pathname.new(__FILE__).realpath)
|
|
13
|
+
|
|
14
|
+
require "rubygems"
|
|
15
|
+
require "bundler/setup"
|
|
16
|
+
|
|
17
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/setup
ADDED
data/exe/wawka
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Fetch personal access token from https://id.getharvest.com/developers`
|
|
2
|
+
harvest:
|
|
3
|
+
token: ""
|
|
4
|
+
account_id: 1
|
|
5
|
+
|
|
6
|
+
# Date of your agreement, that will be placed in xls
|
|
7
|
+
agreement_date: 2017-11-12
|
|
8
|
+
# Company name , that will be placed in xls
|
|
9
|
+
company_name: 'Company name with Surname and First Name'
|
|
10
|
+
|
|
11
|
+
# Mapping between harvest task and more enterprise description used in xls.
|
|
12
|
+
enterprise:
|
|
13
|
+
Development:
|
|
14
|
+
- Rozwój wewnętrznych narzędzi oraz oprogramowania dla ...
|
|
15
|
+
Code review:
|
|
16
|
+
- Audyt i sprawdzanie poprawności tworzonego kodu
|
|
17
|
+
Meeting:
|
|
18
|
+
- Planowanie architektury systemu
|
|
19
|
+
Support:
|
|
20
|
+
- Wsparcie techniczne
|
|
21
|
+
Admin:
|
|
22
|
+
- Administracja serwerami oraz infrastruktórą
|
|
23
|
+
Design:
|
|
24
|
+
- Projektowanie wyglądu oprogramowania
|
|
25
|
+
Project Managment:
|
|
26
|
+
- Zarządzanie projektem
|
|
27
|
+
Research:
|
|
28
|
+
- Analiza narzędzi oraz rozwój oprogramowania
|
|
Binary file
|
data/lib/wawka/cli.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
module Wawka
|
|
3
|
+
class Cli < Thor
|
|
4
|
+
desc "harvest <output-file> <date>", "generate required excel evidence based on harvest data"
|
|
5
|
+
def harvest(output_file, date=Date.today)
|
|
6
|
+
Transactions::GenerateEvidence.new(date).call do |resp|
|
|
7
|
+
resp.success do |file|
|
|
8
|
+
FileUtils.cp(file.path, output_file)
|
|
9
|
+
puts "Generated evidence: #{output_file}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
resp.failure {}
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "config", "copy example configuration file"
|
|
17
|
+
def config
|
|
18
|
+
raise "There is already: #{Wawka.config_path}" if Wawka.config_path.exist?
|
|
19
|
+
FileUtils.cp(
|
|
20
|
+
Wawka.root.join('example/config.yml'),
|
|
21
|
+
Wawka.config_path.to_s
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Wawka
|
|
2
|
+
class Container
|
|
3
|
+
extend Dry::Container::Mixin
|
|
4
|
+
|
|
5
|
+
namespace 'harvest' do
|
|
6
|
+
register 'fetch' do
|
|
7
|
+
Transactions::FetchHarvest.new
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
namespace 'excel' do
|
|
12
|
+
register 'generate' do
|
|
13
|
+
Transactions::GenerateExcel.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Wawka
|
|
2
|
+
class Harvest
|
|
3
|
+
include HTTParty
|
|
4
|
+
base_uri 'https://api.harvestapp.com'
|
|
5
|
+
|
|
6
|
+
def time_entries(from:, to:, page: 1)
|
|
7
|
+
self.class.get('/v2/time_entries', headers: headers, query: { from: from, to: to, per_page: 100, page: page })
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def headers
|
|
13
|
+
{
|
|
14
|
+
'Authorization' => 'Bearer ' + Wawka.config.dig('harvest', 'token'),
|
|
15
|
+
'Harvest-Account-Id' => Wawka.config.dig('harvest', 'account_id').to_s,
|
|
16
|
+
'User-Agent' => 'KakaDemona'
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Wawka
|
|
2
|
+
module Transactions
|
|
3
|
+
class FetchHarvest < Operation
|
|
4
|
+
def call(date:)
|
|
5
|
+
page = 1
|
|
6
|
+
entries = []
|
|
7
|
+
loop do
|
|
8
|
+
data = harvest.time_entries(from: date - 1.month, to: date, page: page)
|
|
9
|
+
entries += data['time_entries']
|
|
10
|
+
break if data['page'] == data['total_pages']
|
|
11
|
+
page = data['page'] + 1
|
|
12
|
+
end
|
|
13
|
+
Success(entries)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def harvest
|
|
19
|
+
@harvest ||= Harvest.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Wawka
|
|
2
|
+
module Transactions
|
|
3
|
+
class GenerateEvidence < Base
|
|
4
|
+
step :prepare_date
|
|
5
|
+
step :fetch_entries, with: 'harvest.fetch'
|
|
6
|
+
step :accumulate_services
|
|
7
|
+
step :be_more_enterprise
|
|
8
|
+
step :generate_excel, with: 'excel.generate'
|
|
9
|
+
|
|
10
|
+
attr_reader :date
|
|
11
|
+
|
|
12
|
+
def initialize(input_date)
|
|
13
|
+
super({})
|
|
14
|
+
@date = input_date.is_a?(Date) ? input_date : Date.parse(input_date)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def prepare_date(_)
|
|
18
|
+
Success(date: date)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def accumulate_services(entries)
|
|
22
|
+
Success(entries.inject({}) do |output, entry|
|
|
23
|
+
task = entry.dig('task', 'name')
|
|
24
|
+
output[task] ||= 0
|
|
25
|
+
output[task] += entry['hours']
|
|
26
|
+
output
|
|
27
|
+
end)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def be_more_enterprise(services)
|
|
31
|
+
enterprise_services = services.inject([]) do |output, (name, hours)|
|
|
32
|
+
enterprise_name = Wawka.config.dig('enterprise', name).sample
|
|
33
|
+
output << { name: enterprise_name, hours: hours }
|
|
34
|
+
output
|
|
35
|
+
end
|
|
36
|
+
Success(services: enterprise_services)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def generate_excel(services:)
|
|
40
|
+
super(
|
|
41
|
+
agreement_date: Wawka.config['agreement_date'],
|
|
42
|
+
name: Wawka.config['company_name'],
|
|
43
|
+
services: services,
|
|
44
|
+
date: date
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Wawka
|
|
2
|
+
module Transactions
|
|
3
|
+
class GenerateExcel < Operation
|
|
4
|
+
MONTH_NAMES = %w(Styczeń Luty Marzec Kwiecień Maj Czerwiec Lipiec Sierpień Wrzesień Październik Listopad Grudzień)
|
|
5
|
+
|
|
6
|
+
def call(agreement_date:, name:, date: Date.today, services:)
|
|
7
|
+
update_row(0, 0, "<<DATE>>", agreement_date.strftime("%Y-%m-%d"))
|
|
8
|
+
update_row(4, 3, "<<NAME>>", name)
|
|
9
|
+
update_row(5, 3, "<<MONTH>>", MONTH_NAMES[date.mon-1])
|
|
10
|
+
update_row(6, 3, "<<YEAR>>", date.year)
|
|
11
|
+
|
|
12
|
+
start = 9
|
|
13
|
+
finish = 19
|
|
14
|
+
|
|
15
|
+
(finish-start).times do |index|
|
|
16
|
+
row = index + start
|
|
17
|
+
service = services[index]
|
|
18
|
+
if service
|
|
19
|
+
update_row(row, 0, "<<LP>>", index+1)
|
|
20
|
+
update_row(row, 1, "<<SERVICE>>", service[:name])
|
|
21
|
+
update_row(row, 4, "<<HOURS>>", service[:hours])
|
|
22
|
+
else
|
|
23
|
+
update_row(row, 0, "<<LP>>", "")
|
|
24
|
+
update_row(row, 1, "<<SERVICE>>", "")
|
|
25
|
+
update_row(row, 4, "<<HOURS>>", "")
|
|
26
|
+
worksheet.row(row).height = 0 # deleting rows is broken as shit so set their height to 0
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
total_hours = services.inject(0) { |out, s| out += s[:hours] } || 0
|
|
31
|
+
update_row(finish, 4, "<<SUM>>", total_hours)
|
|
32
|
+
|
|
33
|
+
file = Tempfile.new('test.xls')
|
|
34
|
+
template.write file.path
|
|
35
|
+
Success(file)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def update_row(row, col, template, value)
|
|
41
|
+
worksheet[row, col] = worksheet[row, col].gsub(template, value.to_s)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def output_workbook
|
|
45
|
+
@output_workbook ||= Spreadsheet::Workbook.new
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def worksheet
|
|
49
|
+
@worksheet ||= template.worksheets[0]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def template
|
|
53
|
+
@template_workbook ||= Spreadsheet.open(Wawka.template_path)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/wawka.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "wawka/version"
|
|
2
|
+
require "wawka/cli"
|
|
3
|
+
require "dry/transaction"
|
|
4
|
+
require "dry/transaction/operation"
|
|
5
|
+
require "dry/container"
|
|
6
|
+
require 'spreadsheet'
|
|
7
|
+
require 'yaml'
|
|
8
|
+
require 'httparty'
|
|
9
|
+
require 'active_support/all'
|
|
10
|
+
|
|
11
|
+
require 'wawka/harvest'
|
|
12
|
+
require 'wawka/container'
|
|
13
|
+
require 'wawka/transactions/base'
|
|
14
|
+
require 'wawka/transactions/operation'
|
|
15
|
+
require 'wawka/transactions/generate_excel'
|
|
16
|
+
require 'wawka/transactions/fetch_harvest'
|
|
17
|
+
require 'wawka/transactions/generate_evidence'
|
|
18
|
+
|
|
19
|
+
module Wawka
|
|
20
|
+
def self.root
|
|
21
|
+
@root ||= Pathname.new(File.dirname(File.absolute_path(__FILE__)))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.template_path
|
|
25
|
+
@template_path ||= Wawka.root.join('example/evidence.xls').to_s
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.config_path
|
|
29
|
+
@config_path ||= Pathname.new(File.expand_path('~/.wawka.yaml'))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.config
|
|
33
|
+
@config ||= YAML.load(open(config_path.to_s))
|
|
34
|
+
end
|
|
35
|
+
end
|
data/wawka.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "wawka/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "wawka"
|
|
8
|
+
spec.version = Wawka::VERSION
|
|
9
|
+
spec.authors = ["Arkadiusz Buras"]
|
|
10
|
+
spec.email = ["macbury@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Handful tool for generating bureaucracy shit xlses"
|
|
13
|
+
spec.description = "Handful tool for generating bureaucracy shit xlses"
|
|
14
|
+
spec.homepage = "http://macbury.ninja"
|
|
15
|
+
spec.license = "WTFPL"
|
|
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
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
20
|
+
|
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
+
f.match(%r{^(test|spec|features)/})
|
|
23
|
+
end
|
|
24
|
+
spec.bindir = "exe"
|
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
31
|
+
spec.add_development_dependency "pry"
|
|
32
|
+
|
|
33
|
+
spec.add_dependency 'spreadsheet', '~> 1.1'
|
|
34
|
+
spec.add_dependency 'dry-transaction', '~> 0.13'
|
|
35
|
+
spec.add_dependency 'httparty', '~> 0.16.2'
|
|
36
|
+
spec.add_dependency 'simple-spreadsheet', '~> 0.5.0'
|
|
37
|
+
spec.add_dependency 'thor', '~> 0.20.0'
|
|
38
|
+
spec.add_dependency 'activesupport', '~> 5.2'
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wawka
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Arkadiusz Buras
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-20 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.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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: pry
|
|
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: spreadsheet
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '1.1'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '1.1'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: dry-transaction
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.13'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.13'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: httparty
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.16.2
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.16.2
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: simple-spreadsheet
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.5.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.5.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: thor
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.20.0
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 0.20.0
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: activesupport
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '5.2'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '5.2'
|
|
153
|
+
description: Handful tool for generating bureaucracy shit xlses
|
|
154
|
+
email:
|
|
155
|
+
- macbury@gmail.com
|
|
156
|
+
executables:
|
|
157
|
+
- wawka
|
|
158
|
+
extensions: []
|
|
159
|
+
extra_rdoc_files: []
|
|
160
|
+
files:
|
|
161
|
+
- ".gitignore"
|
|
162
|
+
- ".rspec"
|
|
163
|
+
- ".travis.yml"
|
|
164
|
+
- CODE_OF_CONDUCT.md
|
|
165
|
+
- Gemfile
|
|
166
|
+
- Gemfile.lock
|
|
167
|
+
- LICENSE.txt
|
|
168
|
+
- README.md
|
|
169
|
+
- Rakefile
|
|
170
|
+
- bin/console
|
|
171
|
+
- bin/rake
|
|
172
|
+
- bin/setup
|
|
173
|
+
- exe/wawka
|
|
174
|
+
- lib/example/config.yml
|
|
175
|
+
- lib/example/evidence.xls
|
|
176
|
+
- lib/wawka.rb
|
|
177
|
+
- lib/wawka/cli.rb
|
|
178
|
+
- lib/wawka/container.rb
|
|
179
|
+
- lib/wawka/harvest.rb
|
|
180
|
+
- lib/wawka/transactions/base.rb
|
|
181
|
+
- lib/wawka/transactions/fetch_harvest.rb
|
|
182
|
+
- lib/wawka/transactions/generate_evidence.rb
|
|
183
|
+
- lib/wawka/transactions/generate_excel.rb
|
|
184
|
+
- lib/wawka/transactions/operation.rb
|
|
185
|
+
- lib/wawka/version.rb
|
|
186
|
+
- wawka.gemspec
|
|
187
|
+
homepage: http://macbury.ninja
|
|
188
|
+
licenses:
|
|
189
|
+
- WTFPL
|
|
190
|
+
metadata:
|
|
191
|
+
allowed_push_host: https://rubygems.org
|
|
192
|
+
post_install_message:
|
|
193
|
+
rdoc_options: []
|
|
194
|
+
require_paths:
|
|
195
|
+
- lib
|
|
196
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
|
+
requirements:
|
|
198
|
+
- - ">="
|
|
199
|
+
- !ruby/object:Gem::Version
|
|
200
|
+
version: '0'
|
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
|
+
requirements:
|
|
203
|
+
- - ">="
|
|
204
|
+
- !ruby/object:Gem::Version
|
|
205
|
+
version: '0'
|
|
206
|
+
requirements: []
|
|
207
|
+
rubyforge_project:
|
|
208
|
+
rubygems_version: 2.6.11
|
|
209
|
+
signing_key:
|
|
210
|
+
specification_version: 4
|
|
211
|
+
summary: Handful tool for generating bureaucracy shit xlses
|
|
212
|
+
test_files: []
|