twstats 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c03859f83739b7704e23e9df4faba575ea6f3aa6
4
+ data.tar.gz: 5906375e59625f9a5ffef39dbd8905325e2ea4f4
5
+ SHA512:
6
+ metadata.gz: 3a6d20cc0fe85c57ad9872e33f16237d54440725cbed8e6cc17dc155a090e96cdf970b2a56dab224e5fc403275872bb470e34128a39747ad7b3a622f3e6667ef
7
+ data.tar.gz: 7d25b85fb90cfc3da98763eca74f47c4f3d6377fab7075e2faf3be86912e7000c6ce585797bc5155ef9e73f555e5ee0196f198de94de18ae4b619ec4f63ee287
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea
@@ -0,0 +1,23 @@
1
+ image: "ruby:2.4"
2
+
3
+ stages:
4
+ - publish
5
+ # This is a basic example for a gem or script which doesn't use
6
+ # services such as redis or postgres
7
+ before_script:
8
+ - ruby -v
9
+ - gem install bundler --no-ri --no-rdoc
10
+ - bundle install
11
+
12
+ # Use dpl to publish the tem
13
+ rubygems:
14
+ stage: publish
15
+ only:
16
+ - tags
17
+ environment:
18
+ name: rubygems
19
+ url: https://rubygems.org/gems/twstats
20
+ script:
21
+ - gem build twstats.gemspec
22
+ - gem install dpl
23
+ - dpl --provider=rubygems --api-key=$RUBYGEMS_KEY
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 jp.araque@cern.ch. 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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in twstats.gemspec
6
+ gemspec
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ twstats (0)
5
+ tty-prompt (~> 0.17)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ equatable (0.5.0)
12
+ hitimes (1.3.0)
13
+ necromancer (0.4.0)
14
+ pastel (0.7.2)
15
+ equatable (~> 0.5.0)
16
+ tty-color (~> 0.4.0)
17
+ rake (10.5.0)
18
+ rspec (3.8.0)
19
+ rspec-core (~> 3.8.0)
20
+ rspec-expectations (~> 3.8.0)
21
+ rspec-mocks (~> 3.8.0)
22
+ rspec-core (3.8.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-expectations (3.8.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-mocks (3.8.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-support (3.8.0)
31
+ timers (4.1.2)
32
+ hitimes
33
+ tty-color (0.4.3)
34
+ tty-cursor (0.6.0)
35
+ tty-prompt (0.17.0)
36
+ necromancer (~> 0.4.0)
37
+ pastel (~> 0.7.0)
38
+ timers (~> 4.0)
39
+ tty-cursor (~> 0.6.0)
40
+ tty-reader (~> 0.4.0)
41
+ tty-reader (0.4.0)
42
+ tty-cursor (~> 0.6.0)
43
+ tty-screen (~> 0.6.4)
44
+ wisper (~> 2.0.0)
45
+ tty-screen (0.6.5)
46
+ wisper (2.0.0)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ bundler (~> 1.16)
53
+ rake (~> 10.0)
54
+ rspec (~> 3.0)
55
+ twstats!
56
+
57
+ BUNDLED WITH
58
+ 1.16.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 J.P. Araque
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # TW-stats gem
2
+ The teamwork stats (tw-stats) gem allows you to import a csv file with the times logged in a given project and extract usefull information about the time spent filtered by different metrics.
3
+
4
+ ## Generate report
5
+ To install just run
6
+
7
+ `gem install tw-stat`
8
+
9
+ and run it as follows
10
+
11
+ `tw-stat -f filename.csv`
12
+
13
+ using a file named `filename.csv` with the times logged.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "twstats"
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(__FILE__)
@@ -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,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "twstats"
4
+
5
+ Twstats::Runner.new
@@ -0,0 +1,25 @@
1
+ require_relative 'twstats/version'
2
+ require_relative 'twstats/csv_reader'
3
+ require_relative 'twstats/runner'
4
+ require_relative 'twstats/tw_log'
5
+
6
+ module Twstats
7
+
8
+ DEFAULT_OPTIONS = {encoding: 'ISO-8859-1:UTF-8', headers: true}
9
+ WELLCOME_MESSAGE = "\n***************************************************************************************
10
+ ** TWStats helps you to get some stats from a CSV export of Time loggin gin Teamwork **
11
+ ***************************************************************************************\n\n"
12
+ STATS_MENU_CHOICES = [
13
+ {name: 'Projects', value: 0},
14
+ {name: 'People', value: 1},
15
+ {name: 'Tags', value: 2},
16
+ {name: 'Billable vs non-villable', value: 3},
17
+ {name: 'Full stats', value: 4},
18
+ {name: 'Back', value: 5}
19
+ ]
20
+ MENU_CHOICES = [
21
+ {name: 'Stats', value: 0},
22
+ {name: 'Info', value: 1},
23
+ {name: 'Quit', value: 2}
24
+ ]
25
+ end
@@ -0,0 +1,47 @@
1
+ require 'csv'
2
+ require "twstats/tw_log"
3
+
4
+ module Twstats
5
+ class CSVReader
6
+ attr_reader :logs
7
+ attr_reader :tags
8
+ attr_reader :people
9
+ attr_reader :tasks
10
+ attr_reader :projects
11
+ # Create an object structure from the csv file which allows to easily read the content
12
+ def initialize(file)
13
+ @logs = Set.new([])
14
+ @tags = Set.new([])
15
+ @people = Set.new([])
16
+ @tasks = Set.new([])
17
+ @projects = Set.new([])
18
+ # Initialize the reader with a csv file and fill the times as an array of columns
19
+ CSV.foreach(file, DEFAULT_OPTIONS) do |row|
20
+ update_info TwLog.new(row)
21
+ end
22
+ end
23
+
24
+ def update_info(log)
25
+ @projects << log.project
26
+ @people << log.who
27
+ log.tags.each{|x| @tags << x}
28
+ @tasks << log.task
29
+ @logs << log
30
+ end
31
+
32
+ def get_total_time(object, element)
33
+ case object
34
+ when :projects
35
+ logs.select{|log| log.project == element}.inject(0){ |sum, l| sum + l.decimal_time}
36
+ when :tags
37
+ logs.select{|log| log.tags.include?(element)}.inject(0){ |sum, l| sum + l.decimal_time}
38
+ when :people
39
+ logs.select{|log| log.who == element}.inject(0){ |sum, l| sum + l.decimal_time}
40
+ when :tasks
41
+ logs.select{|log| log.task == element}.inject(0){ |sum, l| sum + l.decimal_time}
42
+ else
43
+ -99999
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,71 @@
1
+ require 'tty-prompt'
2
+
3
+ require_relative 'csv_reader'
4
+
5
+ module Twstats
6
+ class Runner
7
+ def initialize
8
+ # Load interactive console
9
+ @prompt = TTY::Prompt.new
10
+ puts WELLCOME_MESSAGE
11
+ # Ask for the csv file
12
+ file = @prompt.ask('Specify the CSV file from a Teamwork time log export', default: 'exportTimeLog.csv') do |input|
13
+ input.modify :chomp
14
+ end
15
+ @csv = CSVReader.new(file)
16
+ loop do
17
+ option = @prompt.select("Choose an option", Twstats::MENU_CHOICES)
18
+ case option
19
+ when 0
20
+ show_stats_menu
21
+ when 1
22
+ show_info
23
+ when 2
24
+ break
25
+ else
26
+ puts 'Option not recognized!'
27
+ end
28
+ end
29
+ end
30
+
31
+ def show_stats_menu
32
+ loop do
33
+ option = @prompt.select("Select what time logging stats you want to see", Twstats::STATS_MENU_CHOICES)
34
+ case option
35
+ when 0
36
+ show_stats :projects
37
+ when 1
38
+ show_stats :people
39
+ when 2
40
+ show_stats :tags
41
+ when 3
42
+ show_bil_vs_non_stats
43
+ when 4
44
+ show_full_stats
45
+ when 5
46
+ return
47
+ else
48
+ puts 'Option not recognized'
49
+ end
50
+ end
51
+ end
52
+
53
+ def show_stats(obj)
54
+ puts "Time logged vs #{obj.to_s}:"
55
+ toshow = {}
56
+ max = 0
57
+ @csv.send(obj).each do |element|
58
+ toshow[element] = @csv.get_total_time(obj, element).round(2)
59
+ max = element.size if max < element.size
60
+ end
61
+ toshow.sort_by{ |k,v| v}.reverse.to_h.each do |k,v|
62
+ puts " - #{k.ljust(max,' ')} -> #{v}"
63
+ end
64
+ end
65
+
66
+ def show_info
67
+
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,26 @@
1
+ require 'time'
2
+ module Twstats
3
+ class TwLog
4
+ attr_reader :who
5
+ attr_reader :time
6
+ attr_reader :decimal_time
7
+ attr_reader :description
8
+ attr_reader :tags
9
+ attr_reader :project
10
+ attr_reader :task
11
+
12
+
13
+ # Class use to store the information needed form a given log
14
+ def initialize(row)
15
+ # Receives a row of the CSV file
16
+ @who = row["Who"]
17
+ @decimal_time = row["Decimal Hours"].to_f
18
+ @time = (DateTime.parse(row["End Date/Time"]) - DateTime.parse(row["Date/Time"]))*24
19
+ @description = row["Description"]
20
+ @tags = row["Tags"].split(',')
21
+ @project = row["Project"]
22
+ @task = row["Task"]
23
+ @billable = row["Is it Billable?"]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Twstats
2
+ VERSION = `git describe --tags`
3
+ end
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "twstats/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "twstats"
8
+ spec.version = Twstats::VERSION
9
+ spec.authors = ["J.P. Araque"]
10
+ spec.email = ["jp.araque@cern.ch"]
11
+
12
+ spec.summary = 'Read a csv file generate by Teamwork to quickly get some stats from time logging.'
13
+ spec.description = 'Teamwork allows to log time for all tasks within a project but the stats capabilities do not allow for a quick overview of time loggin stats. TWStats produces useful stats from a CSV file exported from Teamwork'
14
+ spec.homepage = "https://gitlab.com/jensen-technologies/public/tw-stats"
15
+ spec.license = "MIT"
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
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = 'http://mygemserver.com'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_runtime_dependency "tty-prompt", "~> 0.17"
39
+
40
+ spec.required_ruby_version = '~> 2.0'
41
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twstats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - J.P. Araque
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-21 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: tty-prompt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.17'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.17'
69
+ description: Teamwork allows to log time for all tasks within a project but the stats
70
+ capabilities do not allow for a quick overview of time loggin stats. TWStats produces
71
+ useful stats from a CSV file exported from Teamwork
72
+ email:
73
+ - jp.araque@cern.ch
74
+ executables:
75
+ - twstats
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".gitlab-ci.yml"
81
+ - ".rspec"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - bin/console
89
+ - bin/setup
90
+ - exe/twstats
91
+ - lib/twstats.rb
92
+ - lib/twstats/csv_reader.rb
93
+ - lib/twstats/runner.rb
94
+ - lib/twstats/tw_log.rb
95
+ - lib/twstats/version.rb
96
+ - twstats.gemspec
97
+ homepage: https://gitlab.com/jensen-technologies/public/tw-stats
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ allowed_push_host: http://mygemserver.com
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.6.11
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Read a csv file generate by Teamwork to quickly get some stats from time
122
+ logging.
123
+ test_files: []