gitorinox 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: 51a736cc4788d4f32ab87bb5219b6014370cd91e
4
+ data.tar.gz: 6e3c1cc1adce15fb171287a5c4d6790fccb61906
5
+ SHA512:
6
+ metadata.gz: 355d4ad08b8a0c6afe18a7973994d83c1fb69b5838b3e41a8b32881ebd015f275c525cefb2f01c30ab678b228b1d9d5b833c5b92c3c9ea3612a540a5229f7dd3
7
+ data.tar.gz: bb2c6e6d9cf4a98a026a910ac2c027055d65890f2f6d62d9a93cbb4e5d34605669edd4b34a215e504ee174a338d579146d246330464c52e641a43c717a261775
data/.gitignore ADDED
@@ -0,0 +1,15 @@
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
15
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitorinox.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 jvillarejo
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,51 @@
1
+ # Gitorinox
2
+
3
+ Gitorinox is the Army Knife for Github. It's a command line tool that let you interact with Github API
4
+
5
+ ## Installation
6
+
7
+ Install it yourself as:
8
+
9
+ $ gem install gitorinox
10
+
11
+ ## Usage
12
+
13
+ For every command you have to put your github credentials using this options
14
+
15
+ $ gitorinox -l YOUR_LOGIN_USERNAME -p YOUR_LOGIN_PASSWORD
16
+
17
+ Here are the currently supported commands
18
+
19
+ ### List
20
+
21
+ It list all your currently watched repositories and outputs on standard output.
22
+
23
+ Example:
24
+
25
+ $ gitorinox list -l YOUR_LOGIN_USERNAME -p YOUR_LOGIN_PASSWORD
26
+
27
+ You can also pass another option -m that filters the repositories that match the repository name with the option param. It's like a UNIX grep
28
+
29
+ Example
30
+
31
+ $ gitorinox list -l YOUR_LOGIN_USERNAME -p YOUR_LOGIN_PASSWORD -m 2015
32
+
33
+ It will output all the repositories which the name contains a 2015 substring
34
+
35
+ ### Unwatch
36
+
37
+ It unwatches the repositories you are currently watched repositories. The optinal matching param name is required for this action.
38
+
39
+ Example:
40
+
41
+ $ gitorinox unwatch -l YOUR_LOGIN_USERNAME -p YOUR_LOGIN_PASSWORD -m 2015
42
+
43
+ Gitorinox will unwatch all the repositories that match 2015 in the repository name
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/gitorinox/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/gitorinox ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gitorinox'
4
+
5
+ Gitorinox::Runner.run
data/gitorinox.gemspec ADDED
@@ -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 'gitorinox/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitorinox"
8
+ spec.version = Gitorinox::VERSION
9
+ spec.authors = ["jvillarejo"]
10
+ spec.email = ["arzivian87@gmail.com"]
11
+ spec.summary = %q{Your command line tool for github}
12
+ spec.description = %q{You can list your repositories, and unwatch them}
13
+ spec.homepage = "https://github.com/jvillarejo/gitorinox"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ['gitorinox']
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
+
24
+ spec.add_dependency "clamp", "~> 0.6.4"
25
+ spec.add_dependency 'github_api', "~> 0.12.3"
26
+ end
data/lib/gitorinox.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'clamp'
2
+ require 'github_api'
3
+
4
+ require "gitorinox/version"
5
+ require "gitorinox/runner"
6
+
7
+ module Gitorinox
8
+ end
@@ -0,0 +1,18 @@
1
+ require 'gitorinox/github_api'
2
+
3
+ module Gitorinox
4
+ class Command < Clamp::Command
5
+ option ["-l", "--login"], "LOGIN", "Github Login", required: true
6
+ option ["-p", "--password"], "PASSWORD", "Github Password", required: true
7
+
8
+ def github
9
+ @github ||= Gitorinox::GithubAPI.new(login,password)
10
+ end
11
+
12
+ class << self
13
+ def match_option(required=false)
14
+ option ["-m", "--match"], "MATCH", "Repository Matching Name Expression", required: required
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module Gitorinox
2
+ class GithubAPI
3
+ def initialize(login, password)
4
+ @client ||= Github.new(login: login, password: password)
5
+ end
6
+
7
+ def matched_repositories(match)
8
+ result = []
9
+
10
+ @client.activity.watching.watched.each_page do |page|
11
+ page.each do |repo|
12
+ if match
13
+ result << repo if repo.name.match(match)
14
+ else
15
+ result << repo
16
+ end
17
+ end
18
+ end
19
+
20
+ result
21
+ end
22
+
23
+ def unwatch(repository)
24
+ @client.activity.watching.delete(user: repository.owner.login, repo: repository.name)
25
+ end
26
+
27
+ def authenticated_username
28
+ @client.users.get.login
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ module Gitorinox
2
+ class List < Command
3
+ match_option
4
+
5
+ def execute
6
+ github.matched_repositories(match).each { |repo| puts repo.name}
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require "gitorinox/command"
2
+ require "gitorinox/list"
3
+ require "gitorinox/unwatch"
4
+
5
+ module Gitorinox
6
+ class Runner < Clamp::Command
7
+ subcommand 'list', "List your current watching repositories", Gitorinox::List
8
+ subcommand 'unwatch', "Unwatch the matching repositories you are currently watching", Gitorinox::Unwatch
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module Gitorinox
2
+ class Unwatch < Gitorinox::Command
3
+ match_option(true)
4
+
5
+ def execute
6
+ unwatched_repositories = []
7
+
8
+ github.matched_repositories(match).each do |repo|
9
+ unwatched_repositories << repo.name if github.unwatch(repo)
10
+ end
11
+
12
+ puts "#{unwatched_repositories.size} repositories unwatched"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Gitorinox
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitorinox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - jvillarejo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-31 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: clamp
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: github_api
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.12.3
69
+ description: You can list your repositories, and unwatch them
70
+ email:
71
+ - arzivian87@gmail.com
72
+ executables:
73
+ - gitorinox
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/gitorinox
83
+ - gitorinox.gemspec
84
+ - lib/gitorinox.rb
85
+ - lib/gitorinox/command.rb
86
+ - lib/gitorinox/github_api.rb
87
+ - lib/gitorinox/list.rb
88
+ - lib/gitorinox/runner.rb
89
+ - lib/gitorinox/unwatch.rb
90
+ - lib/gitorinox/version.rb
91
+ homepage: https://github.com/jvillarejo/gitorinox
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Your command line tool for github
115
+ test_files: []