railscommits 0.0.2
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 +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +18 -0
- data/Rakefile +2 -0
- data/bin/railscommits +41 -0
- data/lib/railscommits.rb +5 -0
- data/lib/railscommits/commit_history.rb +25 -0
- data/lib/railscommits/request.rb +64 -0
- data/lib/railscommits/version.rb +5 -0
- data/railscommits.gemspec +26 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0eafa569c9c5268743429f73bf497c69a6acc23a
|
4
|
+
data.tar.gz: a486d0bf885cae403c91ff9566c5f506ed6a4e4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f1b02074a39ec2dccf975e1d1c76e76906ddffccf254626f96920668dce976866ddd6c99f79a52313ebb2bb4a910c137ee2a4496f81c22873b7062bd266ee2ec
|
7
|
+
data.tar.gz: 18f84cc56835c1989360181c8ede9318ee09a20e398b9d166c8f33ce7e353e425685cc85cf3e04599604ef75e202452d12a0c932b39feec5865f3214460bd95b
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Paul Malenke
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Rails Commits CLI
|
2
|
+
|
3
|
+
A command line app that allows you to see the latest commits from the Rails repository on GitHub
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install through rubygems:
|
8
|
+
|
9
|
+
$ gem install railscommits
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
$ railscommits --token TOKEN [--count N] [--author AUTHOR]
|
14
|
+
|
15
|
+
-t, --token GitHub OAUTH Token
|
16
|
+
-c, --count Optional count (number of results)
|
17
|
+
-a, --author Optional author (e.g. dhh)
|
18
|
+
-h, --help Display this help message.
|
data/Rakefile
ADDED
data/bin/railscommits
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'railscommits'
|
4
|
+
require 'slop'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
# Main Cli Class for parsing_opts and retrieving and displaying commit results
|
8
|
+
class RailsCommitsCli
|
9
|
+
class << self
|
10
|
+
def run
|
11
|
+
opts = parse_opts
|
12
|
+
commits = retrieve_commits(opts)
|
13
|
+
display_results(commits)
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse_opts
|
17
|
+
Slop.parse(strict: true, help: true) do
|
18
|
+
banner 'Usage: railscommits --token TOKEN [--count N] [--author AUTHOR]'
|
19
|
+
separator 'Options:'
|
20
|
+
on :t, :token=, 'GitHub OAUTH Token', required: true
|
21
|
+
on :c, :count=, 'Optional count', as: Integer, default: 10
|
22
|
+
on :a, :author=, 'Optional author'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def retrieve_commits(opts)
|
27
|
+
RailsCommits::CommitHistory.new(opts['token'], opts['count'], opts['author']).history
|
28
|
+
end
|
29
|
+
|
30
|
+
def display_results(commits)
|
31
|
+
commits.each do |commit|
|
32
|
+
puts "\ncommit #{commit['sha']}"
|
33
|
+
puts "Author: #{commit['commit']['author']['name']} <#{commit['commit']['author']['email']}>"
|
34
|
+
puts "Date: #{Time.parse(commit['commit']['author']['date']).strftime("%a %b %-d %H:%M:%S %Y %z")}"
|
35
|
+
puts "\n#{commit['commit']['message']}\n".gsub(/[\n]+/, "\n ")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
RailsCommitsCli.run
|
data/lib/railscommits.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module RailsCommits
|
2
|
+
# This class is used to get the commit history for Rails on GitHub.
|
3
|
+
class CommitHistory
|
4
|
+
# Initializer
|
5
|
+
#
|
6
|
+
# == Parameters:
|
7
|
+
# token::
|
8
|
+
# GitHub OAUTH Token
|
9
|
+
# count::
|
10
|
+
# Number of results to return (default: 10)
|
11
|
+
# author::
|
12
|
+
# Retrieve commits by only certain author (default: all)
|
13
|
+
#
|
14
|
+
def initialize(token, count = 10, author = nil)
|
15
|
+
@token = token
|
16
|
+
@count = count
|
17
|
+
@author = author
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gets commit history for Rails on GitHub
|
21
|
+
def history
|
22
|
+
RailsCommits::Request.new('repos/rails/rails/commits', @token, @count, @author).run
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module RailsCommits
|
2
|
+
# This class is used to make requests to the GitHub API
|
3
|
+
# Uses path, token, count(default: 10), and author(default: all)
|
4
|
+
class Request
|
5
|
+
# Initialize Request
|
6
|
+
#
|
7
|
+
# == Parameters:
|
8
|
+
# path::
|
9
|
+
# Path to the API resource for github
|
10
|
+
# (e.g. "repos/rails/rails/commits")
|
11
|
+
# token::
|
12
|
+
# GitHub OAUTH Token
|
13
|
+
# count::
|
14
|
+
# Number of results to return (default: 10)
|
15
|
+
# author::
|
16
|
+
# Retrieve commits by only certain author (default: all)
|
17
|
+
#
|
18
|
+
def initialize(path, token, count = 10, author = nil)
|
19
|
+
@path = path
|
20
|
+
@token = token
|
21
|
+
@count = check_count(count)
|
22
|
+
@author = author
|
23
|
+
@conn = Faraday.new(url: 'https://api.github.com/') do |faraday|
|
24
|
+
faraday.use Faraday::Response::RaiseError
|
25
|
+
faraday.request :url_encoded
|
26
|
+
faraday.adapter Faraday.default_adapter
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Kicks off the request to GitHub
|
31
|
+
#
|
32
|
+
# == Parameters:
|
33
|
+
# none
|
34
|
+
#
|
35
|
+
# == Returns:
|
36
|
+
# The body of a successful faraday request
|
37
|
+
#
|
38
|
+
def run
|
39
|
+
make_request(@path)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def make_request(path)
|
45
|
+
begin
|
46
|
+
response = @conn.get(path) do |request|
|
47
|
+
request.headers['Authorization'] = "token #{@token}"
|
48
|
+
request.params['per_page'] = @count
|
49
|
+
request.params['author'] = @author if @author != nil
|
50
|
+
request.options.timeout = 5
|
51
|
+
request.options.open_timeout = 2
|
52
|
+
end
|
53
|
+
JSON.parse(response.body)
|
54
|
+
rescue Faraday::ClientError => e
|
55
|
+
abort "Error: #{e}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def check_count(count)
|
60
|
+
count = 100 if count != nil && count > 100
|
61
|
+
count
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'railscommits/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "railscommits"
|
8
|
+
spec.version = RailsCommits::VERSION
|
9
|
+
spec.authors = ["Paul Malenke"]
|
10
|
+
spec.email = ["paul.malenke@mac.com"]
|
11
|
+
spec.summary = %q{See the latest commits in the Rails repository on GitHub.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = "https://github.com/paulmalenke/railscommits/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "faraday", "~> 0.9.0"
|
22
|
+
spec.add_runtime_dependency "slop", "~> 3.5.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: railscommits
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Malenke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
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
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- paul.malenke@mac.com
|
72
|
+
executables:
|
73
|
+
- railscommits
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/railscommits
|
83
|
+
- lib/railscommits.rb
|
84
|
+
- lib/railscommits/commit_history.rb
|
85
|
+
- lib/railscommits/request.rb
|
86
|
+
- lib/railscommits/version.rb
|
87
|
+
- railscommits.gemspec
|
88
|
+
homepage: https://github.com/paulmalenke/railscommits/
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: See the latest commits in the Rails repository on GitHub.
|
112
|
+
test_files: []
|