lsgh 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06fc3bbd9773aa9eab371950f0e1e566b4ec41d3
4
+ data.tar.gz: db7c1850853dd8e9a2b898a01e837b6793f80feb
5
+ SHA512:
6
+ metadata.gz: 4acf26f8ccec869c3a4cf81b189ef9620d5f603c9eeca1d7d49d5f7e9d0e73f546baa1f14e1dd3f75081c316ba8e5c36d659d3e59c0f84b527ca5bc0ba8c4a2c
7
+ data.tar.gz: 468b84d26f3a643306dd4985986f01a62f8eaf616117db9c6080e0bd5326f9c176eff09b64ae6e3fe87c3ed69a1c7a30dc732580986a0398e92ad225c067edbc
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at blazeeboy@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lsgh.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Emad Elsaid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,92 @@
1
+ # Lsgh (ls github)
2
+
3
+ List a github organisation/user repositories and open pull requests for each repository in a directory hirarchy format
4
+
5
+ ## Installation
6
+
7
+ install if via `gem`, an executable `lsgh` will be available in your system
8
+
9
+ $ gem install lsgh
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ Usage: lsgh [options]...
15
+ -v, --version Print version
16
+ -h, --help Show this help text
17
+ -t, --token=github_token Github access token, if not specified the environment variable GITHUB_API_TOKEN is used
18
+ -o, --org=organisation_name github organisation name to list repositories for
19
+ -u, --user=username github user name to list repositories for
20
+ -r, --repo=Repository list a specific repository pull requests for this user or org
21
+ ```
22
+
23
+ ## Example output
24
+
25
+ ```
26
+ $ lsgh -u blazeeboy
27
+ ```
28
+
29
+ lists all repositories in that format
30
+ ```
31
+ user/private|public/repo name/user name/pull request title
32
+ ```
33
+
34
+ ```
35
+ blazeeboy/public/active_admin
36
+ blazeeboy/public/Airpad
37
+ blazeeboy/public/amun
38
+ blazeeboy/public/askwiki
39
+ blazeeboy/public/awesome-static-analysis
40
+ blazeeboy/public/Birdflu
41
+ blazeeboy/public/blazeeboy.github.io
42
+ blazeeboy/public/Bounce-Game
43
+ blazeeboy/public/capistrano-decompose
44
+ blazeeboy/public/chef-postgresql
45
+ blazeeboy/public/Codeigniter-Egypt
46
+ blazeeboy/public/CodeIgniter-Ion-Auth
47
+ blazeeboy/public/Colosseum-plugin
48
+ blazeeboy/public/CommunityRules
49
+ blazeeboy/public/CS3D499-Plugin
50
+ blazeeboy/public/darkroomjs
51
+ blazeeboy/public/deploy
52
+ blazeeboy/public/devtools
53
+ blazeeboy/public/dirtree
54
+ blazeeboy/public/dirtree/nemoload/Local dependencies
55
+ blazeeboy/public/EgyptianGeeksArchive
56
+ blazeeboy/public/fb2jekyll
57
+ blazeeboy/public/Gamra
58
+ blazeeboy/public/Github-PHP-Wiki
59
+ blazeeboy/public/inquirer.rb
60
+ blazeeboy/public/jumping-blocks
61
+ blazeeboy/public/noty
62
+ blazeeboy/public/octopress
63
+ blazeeboy/public/portableBrowser
64
+ blazeeboy/public/QA
65
+ blazeeboy/public/Quantum
66
+ blazeeboy/public/rubrowser
67
+ blazeeboy/public/RubyScripts
68
+ blazeeboy/public/Sefa-lang
69
+ blazeeboy/public/Sema-lang
70
+ blazeeboy/public/timer
71
+ blazeeboy/public/Todo
72
+ blazeeboy/public/touch-mouse
73
+ blazeeboy/public/xlog
74
+ ```
75
+
76
+ ## Conjunctions
77
+
78
+ You can use it in conjunction with [dirtree](https://www.github.com/blazeeboy/dirtree) to draw an interactive tree from the output.
79
+
80
+ ![](http://i.imgur.com/nkmQNKu.png)
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/blazeeboy/lsgh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
85
+
86
+ ## License
87
+
88
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
89
+
90
+ ## Code of Conduct
91
+
92
+ Everyone interacting in the Lsgh project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/blazeeboy/lsgh/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
4
+
5
+ require 'lsgh'
6
+ require 'github_api'
7
+ require 'optparse'
8
+
9
+ options = {
10
+ token: ENV['GITHUB_API_TOKEN']
11
+ }
12
+
13
+ OptionParser.new do |opts|
14
+ opts.banner = 'Usage: lsgh [options]...'
15
+
16
+ opts.on(
17
+ '-v',
18
+ '--version',
19
+ 'Print version'
20
+ ) do
21
+ puts "lsgh version #{Lsgh::VERSION}"
22
+ exit
23
+ end
24
+
25
+ opts.on(
26
+ '-h',
27
+ '--help',
28
+ 'Show this help text'
29
+ ) do
30
+ puts opts
31
+ exit
32
+ end
33
+
34
+ opts.on(
35
+ '-tToken',
36
+ '--token=github_token',
37
+ 'Github access token, if not specified the environment variable GITHUB_API_TOKEN is used'
38
+ ) do |value|
39
+ options[:org] = value
40
+ end
41
+
42
+ opts.on(
43
+ '-oOrganisation',
44
+ '--org=organisation_name',
45
+ 'github organisation name to list repositories for'
46
+ ) do |value|
47
+ options[:org] = value
48
+ end
49
+
50
+ opts.on(
51
+ '-uUser',
52
+ '--user=username',
53
+ 'github user name to list repositories for'
54
+ ) do |value|
55
+ options[:user] = value
56
+ end
57
+
58
+ opts.on(
59
+ '-rRepository',
60
+ '--repo=Repository',
61
+ 'list a specific repository pull requests for this user or org'
62
+ ) do |value|
63
+ options[:repo] = value
64
+ end
65
+ end.parse!
66
+
67
+ unless options.key?(:user) || options.key?(:org)
68
+ puts 'A user (-u) or organisation (-o) must be specified.'
69
+ exit(1)
70
+ end
71
+
72
+ token = options[:token]
73
+
74
+ user = Lsgh::User.new(options[:user] || options[:org])
75
+ client = Github.new(oauth_token: token, auto_pagination: true)
76
+
77
+ if options.key?(:repo)
78
+ repository = client.repos.find(user: user.name, repo: options[:repo])
79
+ user.add Lsgh::Repository.new(repository, client)
80
+ else
81
+ key = options.key?(:org) ? :org : :user
82
+ client.repos.list(key => user.name).each do |repo|
83
+ user.add Lsgh::Repository.new(repo, client)
84
+ end
85
+ end
86
+
87
+ puts user.to_paths
@@ -0,0 +1,3 @@
1
+ require 'lsgh/version'
2
+ require 'lsgh/user'
3
+ require 'lsgh/repository'
@@ -0,0 +1,43 @@
1
+ module Lsgh
2
+ class Repository
3
+ def initialize(repo, client)
4
+ @repo = repo
5
+ @pull_requests = client.pull_requests.all(user: repo['owner']['login'], repo: repo['name'])
6
+ end
7
+
8
+ def to_paths
9
+ paths = [name]
10
+ paths += pull_requests_paths.map do |path|
11
+ "#{name}/#{path}"
12
+ end
13
+
14
+ paths
15
+ end
16
+
17
+ def type
18
+ if @repo['private']
19
+ :private
20
+ else
21
+ :public
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def pull_requests_paths
28
+ paths = @pull_requests.group_by do |pull|
29
+ pull['user']['login']
30
+ end
31
+
32
+ paths.map do |user, pr_group|
33
+ pr_group.map do |pr|
34
+ "#{user}/#{pr.title.tr('/', ' ')}"
35
+ end
36
+ end.inject(:+).to_a
37
+ end
38
+
39
+ def name
40
+ @repo['name']
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ module Lsgh
2
+ class User
3
+ attr_reader :name
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ @public = []
8
+ @private = []
9
+ end
10
+
11
+ def add(repo)
12
+ case repo.type
13
+ when :public
14
+ @public << repo
15
+ when :private
16
+ @private << repo
17
+ end
18
+ end
19
+
20
+ def to_paths
21
+ [
22
+ ['public', @public],
23
+ ['private', @private]
24
+ ].map do |type, value|
25
+ value.map do |repo|
26
+ repo.to_paths.map do |path|
27
+ "#{@name}/#{type}/#{path}"
28
+ end
29
+ end.inject(:+).to_a
30
+ end.inject(:+)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Lsgh
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'lsgh/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'lsgh'
9
+ spec.version = Lsgh::VERSION
10
+ spec.authors = ['Emad Elsaid']
11
+ spec.email = ['blazeeboy@gmail.com']
12
+
13
+ spec.summary = 'list github organisation projects and pull requests'
14
+ spec.description = 'list github organisation projects and pull requests'
15
+ spec.homepage = 'https://www.github.com/blazeeboy/lsgh'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'github_api', '~> 0.17'
24
+ spec.add_development_dependency 'bundler', '~> 1.15'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lsgh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Emad Elsaid
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: github_api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.17'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: list github organisation projects and pull requests
56
+ email:
57
+ - blazeeboy@gmail.com
58
+ executables:
59
+ - lsgh
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - exe/lsgh
70
+ - lib/lsgh.rb
71
+ - lib/lsgh/repository.rb
72
+ - lib/lsgh/user.rb
73
+ - lib/lsgh/version.rb
74
+ - lsgh.gemspec
75
+ homepage: https://www.github.com/blazeeboy/lsgh
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.12
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: list github organisation projects and pull requests
99
+ test_files: []