merrow 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: e8ad7147c9e9f4debea198f7bf7e0a38d46b6bea
4
+ data.tar.gz: 43a2eb892c3f5e5be2cd3e2761faad1de3e21ce3
5
+ SHA512:
6
+ metadata.gz: 8ca36b4ee2485e53bbdb89ae6006388778f3cbb3e4772463ad36c96695320fe29f98f128ec5896bd2f9391e1ded915ff5e0695aa2f634313a281d4f49fcc17ba
7
+ data.tar.gz: 621ac183648734043e29fd9ae72c3cf7869aab35ea27f1ca886e14c46ac89a3f23104e03c8876144578d55157ae612b2a7e6b337851085b32c3fd0bf1b74fe2f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in merrow.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jordi Polo
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,44 @@
1
+ # Jackal
2
+
3
+ A simple tool to list all the PRs available in certain repositories.
4
+ Saves you time when you are working on/has to be aware of several projects at the same time.
5
+
6
+
7
+ ## Installation
8
+
9
+ Install it yourself as:
10
+
11
+ $ gem install merrow
12
+
13
+
14
+ ## Configuration
15
+
16
+ Jackal reads a list of repositories and an access tocken from the ~/.merrow.yml file.
17
+ The file looks like this:
18
+
19
+ ---
20
+ repos:
21
+ - mdsol/kender
22
+ - Railsmania/capistrano3-copy
23
+ - rails/rails
24
+ access_token: mylongaccesstokenwouldbewrittendowninhere
25
+
26
+
27
+ Add as many repos as you want, if you do not know how to make an access token, do not worry about that. Only add your repos, Jackal will generate one and write it down in the config file for you the first time it is executed
28
+
29
+ ## Usage
30
+
31
+ Hopefully binaries of your gems are in your PATH, then just execute:
32
+
33
+ ```
34
+ merrow
35
+ ```
36
+
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/JordiPolo/merrow/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/merrow ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'octokit'
5
+ require 'merrow'
6
+
7
+
8
+ configuration = Configuration.new
9
+
10
+ client = Octokit::Client.new(access_token: configuration.access_token)
11
+
12
+
13
+ def format(text, indent)
14
+ (" " * indent) + text
15
+ end
16
+
17
+ def days_ago(date)
18
+ days = ((Time.now - date) / 60 / 60 / 24).to_i
19
+ if days == 0
20
+ 'today:'
21
+ elsif days == 1
22
+ 'yesterday:'
23
+ else
24
+ "#{days} days ago:"
25
+ end.ljust(13)
26
+ end
27
+
28
+ def print_pull_requests(pull_requests)
29
+ indent = 2
30
+ pull_requests.each do |pr|
31
+ days_ago = days_ago(pr[:updated_at])
32
+ puts format("#{days_ago} #{pr[:title]} ", indent)
33
+ puts format(pr[:url], days_ago.size + indent + 1)
34
+ puts format(pr[:user][:login], days_ago.size + indent + 1 )
35
+ end
36
+ puts ""
37
+ end
38
+
39
+ def get_pull_requests(client, repo)
40
+ client.pull_requests(repo)
41
+ rescue Octokit::NotFound
42
+ puts "The repository #{repo} could not be found."
43
+ []
44
+ end
45
+
46
+ puts "Checking PRs in your repos"
47
+
48
+ configuration.repos.each do |repo|
49
+ pull_requests = get_pull_requests(client, repo)
50
+ if !pull_requests.empty?
51
+ puts "On #{repo}:"
52
+ print_pull_requests(pull_requests)
53
+ end
54
+ end
55
+
56
+
57
+
@@ -0,0 +1,57 @@
1
+ #This class manages the configuration in the .merrow.yml file
2
+ require 'yaml'
3
+ require 'octokit'
4
+
5
+ class Configuration
6
+ FILENAME= '.merrow.yml'
7
+
8
+ def access_token
9
+ if !data['access_token']
10
+ data['access_token'] = create_access_token
11
+ save(data)
12
+ end
13
+ data['access_token']
14
+ end
15
+
16
+ def repos
17
+ data["repos"]
18
+ end
19
+
20
+
21
+ private
22
+
23
+ def create_access_token
24
+ puts "There is no access token configured in Jackal. You need to create one to access your repositories"
25
+ puts "You will need to provide your username and password. This will be only asked once to create the access token"
26
+ puts "The username and password will not be stored anywhere"
27
+ puts "What is your username for Github?"
28
+ username = gets.chomp
29
+ puts "What is your password for Github?"
30
+ password = gets.chomp
31
+ token_name = "Token used by Jackal"
32
+ client = Octokit::Client.new login: username, password: password
33
+ auth = client.create_authorization(scopes: ["repo", "public_repo", "user"], note: token_name)
34
+ puts "A new token has been created for your user with the name #{auth[:app][:name]}"
35
+ auth[:token]
36
+ end
37
+
38
+ def save(data)
39
+ File.open(configuration_file,'w') do |file|
40
+ file.write data.to_yaml
41
+ end
42
+ end
43
+
44
+ def data
45
+ @data ||= YAML.load_file(configuration_file)
46
+ end
47
+
48
+ def configuration_file
49
+ config_file = File.join(Dir.home, FILENAME)
50
+ if File.exists?(config_file)
51
+ config_file
52
+ else
53
+ puts "Config file #{config_file}, not found. Please create a configuration file following the instructions in the README"
54
+ exit(-1)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module Jackal
2
+ VERSION = "0.0.1"
3
+ end
data/lib/merrow.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "merrow/version"
2
+ require 'merrow/configuration'
data/merrow.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'merrow/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "merrow"
8
+ spec.version = Jackal::VERSION
9
+ spec.authors = ["Jordi Polo"]
10
+ spec.email = ["mumismo@gmail.com"]
11
+ spec.summary = %q{Small tool to look at all you pending PR in Github.}
12
+ spec.description = %q{Small tool to look at all you pending PR in Github }
13
+ spec.homepage = ""
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'byebug', '~> 3.0'
24
+ spec.add_dependency "octokit", "~> 3.0"
25
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: merrow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jordi Polo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: byebug
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: octokit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: 'Small tool to look at all you pending PR in Github '
70
+ email:
71
+ - mumismo@gmail.com
72
+ executables:
73
+ - merrow
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/merrow
83
+ - lib/merrow.rb
84
+ - lib/merrow/configuration.rb
85
+ - lib/merrow/version.rb
86
+ - merrow.gemspec
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.2.2
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Small tool to look at all you pending PR in Github.
111
+ test_files: []
112
+ has_rdoc: