standup_cli 0.0.1

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: cb753fce014af7874d84adbfe0fcf2c4c836d691
4
+ data.tar.gz: 64938e0e1a83ee85000600ae2a4dd54deb76eb95
5
+ SHA512:
6
+ metadata.gz: 4eff642f096bdb0df347578ccb39fa1e2214f9a1b480283d9ea49123dbc5659da30d7da09fd8769f909063fe1cd44cb09f71442e2a8cf7923a9eabed679390c4
7
+ data.tar.gz: 623c727ff28185ca96b681ffd63a0d1d8fcca207552e50af401c4c79fbddb4066927305cf3bf790475aaff01e70677e7e92b37c9ea3e228e6ce1161f6c0d32d0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'httparty'
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ standup_cli (0.0.1)
5
+ gli (= 2.13.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.14.1)
11
+ childprocess (~> 0.5.6)
12
+ contracts (~> 0.9)
13
+ cucumber (>= 1.3.19)
14
+ ffi (~> 1.9.10)
15
+ rspec-expectations (>= 2.99)
16
+ thor (~> 0.19)
17
+ builder (3.2.2)
18
+ childprocess (0.5.9)
19
+ ffi (~> 1.0, >= 1.0.11)
20
+ contracts (0.13.0)
21
+ cucumber (2.3.3)
22
+ builder (>= 2.1.2)
23
+ cucumber-core (~> 1.4.0)
24
+ cucumber-wire (~> 0.0.1)
25
+ diff-lcs (>= 1.1.3)
26
+ gherkin (~> 3.2.0)
27
+ multi_json (>= 1.7.5, < 2.0)
28
+ multi_test (>= 0.1.2)
29
+ cucumber-core (1.4.0)
30
+ gherkin (~> 3.2.0)
31
+ cucumber-wire (0.0.1)
32
+ diff-lcs (1.2.5)
33
+ ffi (1.9.10)
34
+ gherkin (3.2.0)
35
+ gli (2.13.4)
36
+ httparty (0.13.7)
37
+ json (~> 1.8)
38
+ multi_xml (>= 0.5.2)
39
+ json (1.8.3)
40
+ multi_json (1.11.2)
41
+ multi_test (0.1.2)
42
+ multi_xml (0.5.5)
43
+ rake (11.1.2)
44
+ rdoc (4.2.2)
45
+ json (~> 1.4)
46
+ rspec-expectations (3.4.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.4.0)
49
+ rspec-support (3.4.1)
50
+ thor (0.19.1)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ aruba
57
+ httparty
58
+ rake
59
+ rdoc
60
+ standup_cli!
61
+
62
+ BUNDLED WITH
63
+ 1.11.2
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Command line inteface for daily standup
2
+
3
+ ## Install
4
+ $ gem install standup_cli
5
+
6
+ ## Usage
7
+
8
+ ### Show standup report
9
+
10
+ - Without explicit directory of git repository
11
+ ##### Example output
12
+
13
+ ```
14
+ # Given git log for commits of the day with the following command:
15
+ $ git log --since=midnight --author="$(git config user.name)" --oneline
16
+ # shows
17
+ eabf185 Added user sign up with Facebook
18
+ ```
19
+
20
+ ```
21
+ # then
22
+ $ standup report
23
+ # should show
24
+ $ "I had worked on added user sign up with Facebook today"
25
+ ```
26
+ - With current directory
27
+ -
28
+ $ standup report --repo=~/dir/to/my/repo
29
+
30
+ ## TODO
31
+
32
+ - Check for Pull Request and show links for the commit
33
+ - Post standup report to team channels, i.e. [hipchat, slack]
data/README.rdoc ADDED
@@ -0,0 +1,33 @@
1
+ # Command line inteface for daily standup
2
+
3
+ ## Install
4
+ $ gem install standup_cli
5
+
6
+ ## Usage
7
+
8
+ ### Show standup report
9
+
10
+ - Without explicit directory of git repository
11
+ ##### Example output
12
+
13
+ ```
14
+ # Given git log for commits of the day with the following command:
15
+ $ git log --since=midnight --author="$(git config user.name)" --oneline
16
+ # shows
17
+ eabf185 Added user sign up with Facebook
18
+ ```
19
+
20
+ ```
21
+ # then
22
+ $ standup report
23
+ # should show
24
+ $ "I had worked on added user sign up with Facebook today"
25
+ ```
26
+ - With current directory
27
+ -
28
+ $ standup report --repo=~/dir/to/my/repo
29
+
30
+ ## TODO
31
+
32
+ - Check for Pull Request and show links for the commit
33
+ - Post standup report to team channels, i.e. [hipchat, slack]
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('standup_cli.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
34
+
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.test_files = FileList['test/*_test.rb']
42
+ end
43
+
44
+ task :default => [:test,:features]
data/bin/standup.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'httparty'
2
+
3
+ class Standup
4
+ attr_reader :repository
5
+
6
+ def initialize(options)
7
+ @repository = options[:repository] || %x(pwd).strip
8
+ end
9
+
10
+ def abs_path(path)
11
+ if path[0] == '~'
12
+
13
+ end
14
+ end
15
+
16
+ def commits_for_today
17
+ metadata = {
18
+ token: ENV['GITHUB_ACCESS_TOKEN'],
19
+ url: 'https://api.github.com/user/repos',
20
+ username: %x(git config user.name).strip
21
+ }
22
+
23
+ # req = HTTParty.get(
24
+ # metadata[:url],
25
+ # headers: {
26
+ # 'Authorization' => "token #{metadata[:token]}",
27
+ # 'User-Agent' => metadata[:username]
28
+ # }
29
+ # )
30
+ logs = %x(
31
+ git -C #{@repository} log \
32
+ --since=midnight \
33
+ --author="$(git config user.name)" \
34
+ --oneline \
35
+ --branches \
36
+ )
37
+
38
+ commits = logs.split("\n")
39
+
40
+ commits.map! do |commit|
41
+ hash, message = commit.split(nil, 2)
42
+
43
+ # TODO:
44
+ # - check hash for pull request
45
+ # - get link from github for PR
46
+
47
+ message.strip.tap { |msg| msg[0] = msg[0].downcase }
48
+ end
49
+ end
50
+
51
+ def report
52
+ report_progress
53
+
54
+ # TODO:
55
+ # - report_hurdles
56
+
57
+ # TODO:
58
+ # - hipchat integration
59
+ end
60
+
61
+ def report_progress
62
+ # TODO:
63
+ # - grab standup timeline from command args
64
+
65
+ # report_for_yesterday
66
+ report_for_today
67
+ # planning_for_tomorrow
68
+ end
69
+
70
+ def report_for_today
71
+ first_msg, *rest_of_msg = commits_for_today
72
+
73
+ return 'No commit message found for today.' unless first_msg
74
+
75
+ paragraph = []
76
+ paragraph << full_sentence(first_msg, :progress, 'today')
77
+ paragraph << full_sentence(rest_of_msg, :continuation) if rest_of_msg.any?
78
+ paragraph.join(separator[:full_stop])
79
+ end
80
+
81
+ def full_sentence(message, topic, day = nil)
82
+ message = join_long_messages(message) if message.is_a? Array
83
+
84
+ sentence = [subject[topic].sample, message].join(' ')
85
+
86
+ return sentence unless day
87
+
88
+ add_day_around(sentence, day)
89
+ end
90
+
91
+ def join_long_messages(messages)
92
+ last_message = messages.pop
93
+
94
+ [messages.join(separator[:comma]), last_message].join(separator[:and])
95
+ end
96
+
97
+ def add_day_around(sentence, day)
98
+ format = [sentence, day].sample(2)
99
+
100
+ format.join(' ').tap { |msg| msg[0] = msg[0].upcase }
101
+ end
102
+
103
+ def subject
104
+ {
105
+ progress: ['I am working on', 'I had worked on'],
106
+ continuation: ['Also,', 'Then,']
107
+ }
108
+ end
109
+
110
+ def separator
111
+ {
112
+ comma: ', ',
113
+ and: ' and ',
114
+ full_stop: '. '
115
+ }
116
+ end
117
+ end
data/bin/standup_cli ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require_relative 'standup'
4
+
5
+ include GLI::App
6
+
7
+ program_desc 'Post your daily standup to various team channel from your git commits!'
8
+
9
+ version '0.0.1'
10
+
11
+ subcommand_option_handling :normal
12
+ arguments :strict
13
+
14
+ desc 'Team channel'
15
+ default_value 'hipchat'
16
+ arg_name 'hipchat'
17
+ flag [:c,:channel]
18
+
19
+ desc 'Show report'
20
+ arg_name 'Describe arguments to hipchat here'
21
+ command :report do |c|
22
+ c.desc 'Show report'
23
+ c.flag [:r, :repo], desc: 'Directory of repository for generating standup report'
24
+ c.action do |global_options,options,args|
25
+ p Standup.new(repository: options[:repo]).report
26
+ end
27
+ end
28
+
29
+ exit run(ARGV)
@@ -0,0 +1,4 @@
1
+ require 'standup_cli/version.rb'
2
+
3
+ # Add requires for other files you add to your project here, so
4
+ # you just need to require this one file in your bin file
@@ -0,0 +1,3 @@
1
+ module StandupCli
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,22 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','standup_cli','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'standup_cli'
5
+ s.version = StandupCli::VERSION
6
+ s.author = 'ChinLoong Tan'
7
+ s.email = 'chinloong91@gmail.com'
8
+ s.homepage = 'http://your.website.com'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'CLI for posting daily standup to various team channel'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.require_paths << 'lib'
13
+ s.has_rdoc = true
14
+ s.extra_rdoc_files = ['README.rdoc','standup_cli.rdoc']
15
+ s.rdoc_options << '--title' << 'standup_cli' << '--main' << 'README.rdoc' << '-ri'
16
+ s.bindir = 'bin'
17
+ s.executables << 'standup_cli'
18
+ s.add_development_dependency('rake')
19
+ s.add_development_dependency('rdoc')
20
+ s.add_development_dependency('aruba')
21
+ s.add_runtime_dependency('gli','2.13.4')
22
+ end
data/standup_cli.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = standup_cli
2
+
3
+ Generate this with
4
+ standup_cli rdoc
5
+ After you have described your command line interface
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: standup_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ChinLoong Tan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gli
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.4
69
+ description:
70
+ email: chinloong91@gmail.com
71
+ executables:
72
+ - standup_cli
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.rdoc
76
+ - standup_cli.rdoc
77
+ files:
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - README.rdoc
82
+ - Rakefile
83
+ - bin/standup.rb
84
+ - bin/standup_cli
85
+ - lib/standup_cli.rb
86
+ - lib/standup_cli/version.rb
87
+ - standup_cli.gemspec
88
+ - standup_cli.rdoc
89
+ homepage: http://your.website.com
90
+ licenses: []
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options:
94
+ - "--title"
95
+ - standup_cli
96
+ - "--main"
97
+ - README.rdoc
98
+ - "-ri"
99
+ require_paths:
100
+ - lib
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.5.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: CLI for posting daily standup to various team channel
118
+ test_files: []