dailycrap 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d710740b7a6ac9865abb707ebda3a1ca8c6b3e3a
4
+ data.tar.gz: b9d2ba09eddcf0c3877a8f2d267eabf5103ae196
5
+ SHA512:
6
+ metadata.gz: 7f44c8e249cbd918f6db91249e8d5dce177c7e2df5f024f72c7f68831501c8cf63bab4a2154f721fd46e24f007b5a60706f6da9fe0566d82e73509ac5832bb06
7
+ data.tar.gz: 3dd3d7c891ed859992210671247f5fc57327501f3dcf2c5210fc6156d1b3b30744ad962409d2b6383a63d218a9d229ab18efe692804a9e40b050a0afb53c6f52
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .github_token
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.1
5
+ before_install: gem install bundler -v 1.13.6
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: "Y53gVgrP+lEnp3bpND/W3PS1IE+0Lm2/03ST86Vsa90gCcQUb6UIXVhEjx5Z670bLM5hmedhecglc9ukcWj7e8Li1WZZQH8UYiqOn/NhtK/gnx7eCRD2aAdXMzLqio50odc0iVhazNb558URuaffn6CF2lsdBBbo3QN8IuXVw5j952ELt3WrJ4uHBSfFEK/LT/ILWoqK8wMb+U+N6PVc0oqe+5z4naK4zs4BhKJnN/CE8CkMHCMMm78yQNB+jAdc+1qe1Q1EqnGFCY+iiRsX6OObfE3prMOfbVEHz6WBTQx7w8O8VzzQ66irBBKotr5XFWmnSbKWvXBw9Og6mC9z6sxzkax06JzQKTtCX4sU5LL+bLG75E5TLE+uC8JuGRSnIetz/jMB5Kdn/UCXzEyKPYM8M2twS/yoxNj73pNbG6wdnWwy9u/s2SpcCxmkweQ0y+tlCTFKyux1A1NBMJnjVcS5E/k6B1vxZm3WTTQi4o4i1ImbaofGhF1fP2Ta8J0hDJ477C6AnJF1CEw11aEAdaS6+3c0XsaVhsXrIzqc5JRcurZYrzVvLyZt0wR5B14SiQg35dnWfpTVDjs/u5oaJNzlkQ9CXJcfDqkYBuMxm91yCtyq3xlvOH2ouXqSa7Rsft3C5XvJPZZ9WUweGHIRdnpZJABga4N2n/SQIJaNeDU="
10
+ gem: dailycrap
11
+ on:
12
+ tags: true
13
+ repo: pcboy/dailycrap
@@ -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 david.hagege@gmail.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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dailycrap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ * Version 2, December 2004
4
+ *
5
+ * Copyright (C) 2004 Sam Hocevar
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.
13
+ *
14
+ *
15
+ * David Hagege <david.hagege@gmail.com>
16
+ */
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Dailycrap
2
+
3
+ Welcome to Dailycrap, the solution to micro management!
4
+ Your company is using scrum and force you to do that daily meeting?
5
+ Dailycrap is here to generate that daily meeting for you.
6
+ Because engineers use automated tools when they can.
7
+
8
+ Note: This has been done in a few hours and may have some bugs, feel free to report those
9
+ Expect a lot of breaking changes, it's alpha.
10
+
11
+ ## Installation
12
+ ```
13
+ gem install dailycrap
14
+ ```
15
+
16
+ ## Usage
17
+ Dailycrap assumes your in progress PRs/issues have the label "in progress"
18
+ It also assumes you are not working on weekends, so Yesterday becomes Friday when you run the script on Monday.
19
+ Nothing else should matter
20
+ You need a file containing only your github token see https://github.com/settings/tokens
21
+
22
+ ```
23
+ $> dailycrap -h
24
+ Dailycrap is here to generate your daily meeting.
25
+ -t, --token-file=<s> File containing your github token (https://github.com/settings/tokens)
26
+ -r, --repository=<s> The repository you are working on
27
+ -o, --organization=<s> Your organization name
28
+ -h, --help Show this message
29
+
30
+ $> dailycrap --token-file=.github_token --organization your_github_orgname --repository your_repo
31
+
32
+ Yesterday
33
+ Worked on:
34
+ Connect to #1204 Do this wonderful stuff
35
+
36
+ Closed:
37
+ Test PR, ignore
38
+
39
+ Reviewed:
40
+ PR 42, killing Scrum
41
+
42
+
43
+ Today:
44
+ In progress:
45
+ Connect to #123124 Wonderful feature
46
+ ```
47
+
48
+ ## License
49
+ dailycrap is under the WTFPL. Do whatever you want.
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dailycrap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
54
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dailycrap"
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
data/dailycrap.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dailycrap/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dailycrap"
8
+ spec.version = Dailycrap::VERSION
9
+ spec.authors = ["David Hagege"]
10
+ spec.email = ["david.hagege@gmail.com"]
11
+
12
+ spec.summary = %q{A ruby gem for people who prefer tools over meetings. If you hate scrum this is for you.}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/pcboy/dailycrap"
15
+ spec.licenses = ['WTFPL']
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_development_dependency "awesome_print"
28
+ spec.add_development_dependency "looksee"
29
+ spec.add_dependency "github_api", '~> 0.14.5'
30
+ spec.add_dependency "activesupport", '~> 5.0.1'
31
+ spec.add_dependency 'trollop', '~> 2.1.2'
32
+ end
data/exe/dailycrap ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dailycrap'
4
+ require 'date'
5
+ require 'trollop'
6
+
7
+ opts = Trollop::options do
8
+ banner <<-EOS
9
+ Dailycrap is here to generate your daily meeting.
10
+ EOS
11
+
12
+ opt :token_file, "File containing your github token (https://github.com/settings/tokens)", required: true, type: :string
13
+ opt :repository, "The repository you are working on", required: true, type: :string
14
+ opt :organization, "Your organization name", default: nil, type: :string
15
+ end
16
+
17
+ crap = Dailycrap::Dailycrap.new(File.read(opts[:token_file]).strip,
18
+ date: Date.today.monday? ? Date.today - 3 : Date.today - 1,
19
+ repo: opts[:repository],
20
+ organization: opts[:organization])
21
+
22
+ puts crap.daily
@@ -0,0 +1,3 @@
1
+ module Dailycrap
2
+ VERSION = "0.1.0"
3
+ end
data/lib/dailycrap.rb ADDED
@@ -0,0 +1,120 @@
1
+ require "dailycrap/version"
2
+
3
+ require 'github_api'
4
+ require 'active_support/core_ext/object/try'
5
+
6
+ module Dailycrap
7
+ class Dailycrap
8
+
9
+ def initialize(token, date: Date.today - 1, repo:, user: nil, organization: nil)
10
+ @token = token
11
+ @user = user || github.users.get.login
12
+
13
+ if organization.nil? && organizations.count > 1
14
+ warn "You have more than one organization (#{organizations}), please choose one as parameter or we'll use your personal one"
15
+ end
16
+ @organization = organization || @user
17
+ @repo = repo
18
+ @date = date
19
+ end
20
+
21
+ def daily
22
+ worked_on_prs = []
23
+ closed_prs = []
24
+ reviewed_prs = []
25
+
26
+ in_progress_issues = api_from_date(github.issues) do |iterator|
27
+ iterator.list(user: @organization, repo: @repo, state: 'open', labels: 'in progress')
28
+ end.select{|x| x.assignee.login == @user }.map{|x| x.title}
29
+
30
+ events(@date).map do |event|
31
+ case event.type
32
+ when 'PushEvent'
33
+ if event.payload.ref != 'refs/heads/master'
34
+ worked_on_prs << pr_from_ref(event.payload.ref) || event.payload.ref.gsub('refs/head/', '')
35
+ end
36
+ when 'CreateEvent'
37
+ # Created a new branch
38
+ when 'IssuesEvent'
39
+ when 'PullRequestReviewCommentEvent'
40
+ unless event.payload.pull_request.user.login == @user
41
+ reviewed_prs << event.payload.pull_request.title
42
+ end
43
+ when 'PullRequestEvent'
44
+ if event.payload.action == 'closed'
45
+ closed_prs << event.payload.pull_request.title
46
+ end
47
+ else
48
+ STDERR.puts "#{event.type} not supported yet"
49
+ end
50
+ end
51
+
52
+ format_daily(worked_on_prs, closed_prs, in_progress_issues, reviewed_prs)
53
+ end
54
+
55
+ def events(date)
56
+ events = github.activity.events.performed(@user)
57
+ api_at_date(events, date) do |iterator|
58
+ iterator.body
59
+ end.select{|x| x.repo.name.split('/').last == @repo}
60
+ end
61
+
62
+ private
63
+
64
+ def format_daily(worked_on_prs, closed_prs, in_progress, reviewed_prs)
65
+ %Q{
66
+ #{@date.monday? ? 'Friday' : 'Yesterday'}
67
+ \tWorked on:
68
+ \t\t#{worked_on_prs.map{|x| x[:title]}.join("\n\t\t")}
69
+
70
+ \tClosed:
71
+ \t\t#{closed_prs.join("\n\t\t")}
72
+
73
+ \tReviewed:
74
+ \t\t#{reviewed_prs.join("\n\t\t")}
75
+
76
+ Today:
77
+ \tIn progress:
78
+ \t\t#{in_progress.join("\n\t\t")}
79
+ }.gsub(/^ +/, '')
80
+ end
81
+
82
+ def pr_from_ref(ref)
83
+ prs = api_from_date(github.pull_requests, @date) do |iterator|
84
+ iterator.list(user: @organization, repo: @repo, state: 'all')
85
+ end.map{|x| {ref: x.head.ref, title: x.title, created_at: x.created_at, merged_at: x.merged_at, href: x['_links']['self']['href'] }}
86
+ prs.find{|x| x[:ref] == ref.gsub('refs/heads/', '')}
87
+ end
88
+
89
+ def organizations
90
+ @_orgz ||= github.organizations.list.map{|x| x.login}
91
+ end
92
+
93
+ def github
94
+ @_github ||= Github.new oauth_token: @token
95
+ end
96
+
97
+ def api_at_date(iterator, date=nil)
98
+ total_events = []
99
+ begin
100
+ data = yield(iterator)
101
+ total_events += data
102
+ break if date && data.any?{|x| Date.parse(x.updated_at || x.created_at) < date}
103
+ iterator = iterator.try(:next_page)
104
+ end while iterator && iterator.has_next_page?
105
+ date ? total_events.select{ |x| Date.parse(x.updated_at || x.created_at) == date } : total_events
106
+ end
107
+
108
+ def api_from_date(iterator, date=nil)
109
+ total_events = []
110
+ begin
111
+ data = yield(iterator)
112
+ total_events += data
113
+ break if date && data.any?{|x| Date.parse(x.updated_at || x.created_at) < date}
114
+ iterator = iterator.try(:next_page)
115
+ end while iterator && iterator.has_next_page?
116
+ date ? total_events.select{ |x| Date.parse(x.updated_at || x.created_at) >= date } : total_events
117
+ end
118
+
119
+ end
120
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dailycrap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Hagege
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-08 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
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: looksee
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: github_api
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.14.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.14.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 5.0.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 5.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: trollop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.1.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.1.2
125
+ description: ''
126
+ email:
127
+ - david.hagege@gmail.com
128
+ executables:
129
+ - dailycrap
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - CODE_OF_CONDUCT.md
136
+ - Gemfile
137
+ - LICENSE
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - dailycrap.gemspec
143
+ - exe/dailycrap
144
+ - lib/dailycrap.rb
145
+ - lib/dailycrap/version.rb
146
+ homepage: https://github.com/pcboy/dailycrap
147
+ licenses:
148
+ - WTFPL
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.4.8
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: A ruby gem for people who prefer tools over meetings. If you hate scrum this
170
+ is for you.
171
+ test_files: []