octocam 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -13
- data/lib/octocam/client.rb +4 -24
- data/lib/octocam/parser.rb +79 -0
- data/lib/octocam/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc7bca552f1d0e63087cea4a7079135f8eb8273d
|
4
|
+
data.tar.gz: f52493aa08f0abf773e73f78e4f4f958277247ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f94afb8856c8f57aaf40c26b3271a20ab0e738a71f9298c3b6ad3aa1cd4a9180adba873662f5a430e443ba935c83792a480bdf1c888447c49a09570cb2457ca5
|
7
|
+
data.tar.gz: 024a22120ef9a8f83a8096fdfd1e0c81a378e10b7c9e782bf2a3c5c65e0ca17aedbeafd4b3081bce9b1f0ebefd5d64a25619feb9c98952626804e52de0b03efc
|
data/README.md
CHANGED
@@ -1,28 +1,35 @@
|
|
1
1
|
# Octocam
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Octocam generate simple CHANGELOG with Markdown from GitHub pull requests.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
$ gem install octocam
|
10
8
|
|
11
|
-
|
12
|
-
gem 'octocam'
|
13
|
-
```
|
9
|
+
### GitHub Token
|
14
10
|
|
15
|
-
|
11
|
+
If you want to generate CHANGELOG from private repo, set OCTOCAM_GITHUB_TOKEN to your environment variable.
|
16
12
|
|
17
|
-
|
13
|
+
**You can easily [generate it here](https://github.com/settings/applications)**.
|
18
14
|
|
19
|
-
|
15
|
+
Then, add to your `~/.bash_profile` or `~/.zshrc` or any other place to load ENV variables string.
|
20
16
|
|
21
|
-
|
17
|
+
```
|
18
|
+
export OCTOCAM_GITHUB_TOKEN="your-40-digit-github-token"
|
19
|
+
```
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```
|
24
|
+
octocam -o zephiransas -r octocam -f 2015-01-01 -t 2015-01-31
|
25
|
+
```
|
26
|
+
|
27
|
+
```
|
28
|
+
-o (required) owner of the GitHub repository
|
29
|
+
-r (required) name of the GitHub repository
|
30
|
+
-f (required) start of merged at
|
31
|
+
-t (required) end of merged at
|
32
|
+
```
|
26
33
|
|
27
34
|
## Development
|
28
35
|
|
@@ -32,7 +39,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
39
|
|
33
40
|
## Contributing
|
34
41
|
|
35
|
-
1. Fork it ( https://github.com/
|
42
|
+
1. Fork it ( https://github.com/zephiransas/octocam/fork )
|
36
43
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
44
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
45
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/octocam/client.rb
CHANGED
@@ -1,40 +1,20 @@
|
|
1
1
|
require 'octokit'
|
2
2
|
require 'optparse'
|
3
3
|
require 'time'
|
4
|
+
require 'octocam/parser'
|
4
5
|
|
5
6
|
class Octocam::Client
|
6
7
|
|
7
8
|
def generate
|
8
|
-
|
9
|
+
options = Octocam::Parser.parse_options
|
9
10
|
|
10
11
|
Octokit.auto_paginate = true
|
11
12
|
client = Octokit::Client.new(access_token: ENV['OCTOCAM_GITHUB_TOKEN'])
|
12
13
|
|
13
|
-
pull_requests = client.pull_requests("#{
|
14
|
-
pull_requests.select{|pr| pr[:merged_at].localtime >=
|
14
|
+
pull_requests = client.pull_requests("#{options[:owner]}/#{options[:repository]}", state: 'closed').reject{|pr| pr[:merged_at] == nil }
|
15
|
+
pull_requests.select{|pr| pr[:merged_at].localtime >= options[:from] && pr[:merged_at].localtime <= options[:to] }.sort{|a, b| -(a[:merged_at] <=> b[:merged_at]) }.each do |pull_request|
|
15
16
|
puts "- #{pull_request[:title]} [[##{pull_request[:number]}](#{pull_request[:html_url]})]"
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
class Argument
|
20
|
-
def initialize
|
21
|
-
params = ARGV.getopts('o:r:f:t:')
|
22
|
-
@owner = params['o']
|
23
|
-
@repository = params['r']
|
24
|
-
@from = params['f']
|
25
|
-
@to = params['t']
|
26
|
-
end
|
27
|
-
|
28
|
-
def owner; @owner; end
|
29
|
-
def repository; @repository; end
|
30
|
-
|
31
|
-
def from
|
32
|
-
Time.parse(@from)
|
33
|
-
end
|
34
|
-
|
35
|
-
def to
|
36
|
-
Time.parse(@to)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
20
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Octocam
|
4
|
+
class Parser
|
5
|
+
def self.parse_options
|
6
|
+
options = {
|
7
|
+
owner: nil,
|
8
|
+
repository: nil,
|
9
|
+
from: nil,
|
10
|
+
to: nil
|
11
|
+
}
|
12
|
+
|
13
|
+
parser = OptionParser.new do |opts|
|
14
|
+
opts.banner = 'Usage: octocam -o [owner] -r [repository] -f [merged_from] -t [merged_to]'
|
15
|
+
|
16
|
+
opts.accept(Time) do |s|
|
17
|
+
begin
|
18
|
+
Time.parse(s) if s
|
19
|
+
rescue
|
20
|
+
raise "#{s} is not date format. ex) 2015-08-22"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on('-o [NAME]', 'Username of the owner of target GitHub repo') do |v|
|
25
|
+
options[:owner] = v
|
26
|
+
end
|
27
|
+
opts.on('-r [NAME]', 'target repository name') do |v|
|
28
|
+
options[:repository] = v
|
29
|
+
end
|
30
|
+
opts.on('-f YYYY-MM-DD', Time, 'From date of merged date') do |v|
|
31
|
+
options[:from] = v
|
32
|
+
end
|
33
|
+
opts.on('-t YYYY-MM-DD', Time, 'To date of merged date') do |v|
|
34
|
+
options[:to] = v
|
35
|
+
end
|
36
|
+
opts.parse!(ARGV)
|
37
|
+
end
|
38
|
+
|
39
|
+
if !options[:from] || !options[:to]
|
40
|
+
puts parser.banner
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
44
|
+
if !options[:owner] || !options[:repository]
|
45
|
+
options[:owner], options[:repository] = detect_owner_and_repository
|
46
|
+
end
|
47
|
+
|
48
|
+
if !options[:owner] || !options[:repository]
|
49
|
+
puts parser.banner
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
|
53
|
+
options
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def self.detect_owner_and_repository
|
59
|
+
remote = `git config --get remote.origin.url`
|
60
|
+
|
61
|
+
# git@github.com:zephiransas/octocam.git
|
62
|
+
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/.match(remote)
|
63
|
+
if match
|
64
|
+
puts "Detected owner:#{match[1]}, repository:#{match[2]}"
|
65
|
+
return [match[1], match[2]]
|
66
|
+
end
|
67
|
+
|
68
|
+
# https://github.com/zephiransas/octocam
|
69
|
+
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
70
|
+
if match
|
71
|
+
puts "Detected owner:#{match[1]}, repository:#{match[2]}"
|
72
|
+
return [match[1], match[2]]
|
73
|
+
end
|
74
|
+
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
data/lib/octocam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octocam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takafumi Yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- exe/octocam
|
86
86
|
- lib/octocam.rb
|
87
87
|
- lib/octocam/client.rb
|
88
|
+
- lib/octocam/parser.rb
|
88
89
|
- lib/octocam/version.rb
|
89
90
|
- octocam.gemspec
|
90
91
|
homepage: https://github.com/zephiransas/octocam
|