gitdig 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8157fc1094b115472d91fa4acec30579d9b864d9413d0b3eccc92e4a8c26107a
4
+ data.tar.gz: b04230e9821ace8f9ce9f40094a38a6c74d6a66db9ea8fc846bf056c0dd9b993
5
+ SHA512:
6
+ metadata.gz: '0846aab5b0d846474ec118152cff7818c40504f0a3911482af4240a7684111cc0f046f78c19b63317a46a3ad65cb61ec886d6ceb102eae24a4c7b30408919ec4'
7
+ data.tar.gz: f6fd77c4d59ae0f7ec19eb57369e129ead218604f62d6ca7a587fe945434987dfdbeb0e057af643cc913a8faa0e5af9f960b5883b651906e5599e0b434162f7c
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Style/Documentation:
5
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.1
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 1.17.2
@@ -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 phuocviet89@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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gitdig.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,145 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitdig (0.1.1)
5
+ octokit (~> 4.13.0)
6
+ pastel (~> 0.7.2)
7
+ thor (~> 0.20.0)
8
+ tty-box (~> 0.3.0)
9
+ tty-color (~> 0.4)
10
+ tty-command (~> 0.8.0)
11
+ tty-config (~> 0.3.0)
12
+ tty-cursor (~> 0.6)
13
+ tty-editor (~> 0.5.0)
14
+ tty-file (~> 0.7.0)
15
+ tty-font (~> 0.2.0)
16
+ tty-markdown (~> 0.5.0)
17
+ tty-pager (~> 0.12.0)
18
+ tty-pie (~> 0.1.0)
19
+ tty-platform (~> 0.2.0)
20
+ tty-progressbar (~> 0.16.0)
21
+ tty-prompt (~> 0.18.0)
22
+ tty-screen (~> 0.6)
23
+ tty-spinner (~> 0.9.0)
24
+ tty-table (~> 0.10.0)
25
+ tty-tree (~> 0.2.0)
26
+ tty-which (~> 0.4)
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ addressable (2.5.2)
32
+ public_suffix (>= 2.0.2, < 4.0)
33
+ byebug (11.0.0)
34
+ diff-lcs (1.3)
35
+ equatable (0.5.0)
36
+ faraday (0.15.4)
37
+ multipart-post (>= 1.2, < 3)
38
+ kramdown (1.16.2)
39
+ multipart-post (2.0.0)
40
+ necromancer (0.4.0)
41
+ octokit (4.13.0)
42
+ sawyer (~> 0.8.0, >= 0.5.3)
43
+ pastel (0.7.2)
44
+ equatable (~> 0.5.0)
45
+ tty-color (~> 0.4.0)
46
+ public_suffix (3.0.3)
47
+ rake (10.5.0)
48
+ rouge (3.3.0)
49
+ rspec (3.8.0)
50
+ rspec-core (~> 3.8.0)
51
+ rspec-expectations (~> 3.8.0)
52
+ rspec-mocks (~> 3.8.0)
53
+ rspec-core (3.8.0)
54
+ rspec-support (~> 3.8.0)
55
+ rspec-expectations (3.8.2)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.8.0)
58
+ rspec-mocks (3.8.0)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.8.0)
61
+ rspec-support (3.8.0)
62
+ sawyer (0.8.1)
63
+ addressable (>= 2.3.5, < 2.6)
64
+ faraday (~> 0.8, < 1.0)
65
+ strings (0.1.4)
66
+ strings-ansi (~> 0.1.0)
67
+ unicode-display_width (~> 1.4.0)
68
+ unicode_utils (~> 1.4.0)
69
+ strings-ansi (0.1.0)
70
+ thor (0.20.3)
71
+ timers (4.3.0)
72
+ tty-box (0.3.0)
73
+ pastel (~> 0.7.2)
74
+ strings (~> 0.1.4)
75
+ tty-cursor (~> 0.6.0)
76
+ tty-color (0.4.3)
77
+ tty-command (0.8.2)
78
+ pastel (~> 0.7.0)
79
+ tty-config (0.3.1)
80
+ tty-cursor (0.6.0)
81
+ tty-editor (0.5.0)
82
+ tty-prompt (~> 0.18)
83
+ tty-which (~> 0.4)
84
+ tty-file (0.7.0)
85
+ diff-lcs (~> 1.3)
86
+ pastel (~> 0.7.2)
87
+ tty-prompt (~> 0.18)
88
+ tty-font (0.2.0)
89
+ tty-markdown (0.5.1)
90
+ kramdown (~> 1.16.2)
91
+ pastel (~> 0.7.2)
92
+ rouge (~> 3.3)
93
+ strings (~> 0.1.4)
94
+ tty-color (~> 0.4)
95
+ tty-screen (~> 0.6)
96
+ tty-pager (0.12.0)
97
+ strings (~> 0.1.4)
98
+ tty-screen (~> 0.6)
99
+ tty-which (~> 0.4)
100
+ tty-pie (0.1.0)
101
+ pastel (~> 0.7.2)
102
+ tty-cursor (~> 0.6.0)
103
+ tty-platform (0.2.0)
104
+ tty-progressbar (0.16.0)
105
+ strings-ansi (~> 0.1.0)
106
+ tty-cursor (~> 0.6.0)
107
+ tty-screen (~> 0.6.4)
108
+ unicode-display_width (~> 1.3)
109
+ tty-prompt (0.18.1)
110
+ necromancer (~> 0.4.0)
111
+ pastel (~> 0.7.0)
112
+ timers (~> 4.0)
113
+ tty-cursor (~> 0.6.0)
114
+ tty-reader (~> 0.5.0)
115
+ tty-reader (0.5.0)
116
+ tty-cursor (~> 0.6.0)
117
+ tty-screen (~> 0.6.4)
118
+ wisper (~> 2.0.0)
119
+ tty-screen (0.6.5)
120
+ tty-spinner (0.9.0)
121
+ tty-cursor (~> 0.6.0)
122
+ tty-table (0.10.0)
123
+ equatable (~> 0.5.0)
124
+ necromancer (~> 0.4.0)
125
+ pastel (~> 0.7.2)
126
+ strings (~> 0.1.0)
127
+ tty-screen (~> 0.6.4)
128
+ tty-tree (0.2.0)
129
+ tty-which (0.4.0)
130
+ unicode-display_width (1.4.1)
131
+ unicode_utils (1.4.0)
132
+ wisper (2.0.0)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ bundler (~> 1.17)
139
+ byebug
140
+ gitdig!
141
+ rake (~> 10.0)
142
+ rspec (~> 3.0)
143
+
144
+ BUNDLED WITH
145
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Viet Tran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Gitdig
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gitdig`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'gitdig'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gitdig
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gitdig. 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.
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Gitdig project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gitdig/blob/master/CODE_OF_CONDUCT.md).
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2019 Viet Tran. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gitdig"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/gitdig ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'gitdig/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Gitdig::CLI.start
15
+ rescue Gitdig::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
data/gitdig.gemspec ADDED
@@ -0,0 +1,52 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gitdig/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitdig"
8
+ spec.license = "MIT"
9
+ spec.version = Gitdig::VERSION
10
+ spec.authors = ["Viet (Drake) Tran"]
11
+ spec.email = ["phuocviet89@gmail.com"]
12
+
13
+ spec.summary = "Weekly digest for your github account"
14
+ spec.homepage = "https://github.com/tiev"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "tty-box", "~> 0.3.0"
26
+ spec.add_dependency "tty-color", "~> 0.4"
27
+ spec.add_dependency "tty-command", "~> 0.8.0"
28
+ spec.add_dependency "tty-config", "~> 0.3.0"
29
+ spec.add_dependency "tty-cursor", "~> 0.6"
30
+ spec.add_dependency "tty-editor", "~> 0.5.0"
31
+ spec.add_dependency "tty-file", "~> 0.7.0"
32
+ spec.add_dependency "tty-font", "~> 0.2.0"
33
+ spec.add_dependency "tty-markdown", "~> 0.5.0"
34
+ spec.add_dependency "tty-pager", "~> 0.12.0"
35
+ spec.add_dependency "tty-pie", "~> 0.1.0"
36
+ spec.add_dependency "tty-platform", "~> 0.2.0"
37
+ spec.add_dependency "tty-progressbar", "~> 0.16.0"
38
+ spec.add_dependency "tty-prompt", "~> 0.18.0"
39
+ spec.add_dependency "tty-screen", "~> 0.6"
40
+ spec.add_dependency "tty-spinner", "~> 0.9.0"
41
+ spec.add_dependency "tty-table", "~> 0.10.0"
42
+ spec.add_dependency "tty-tree", "~> 0.2.0"
43
+ spec.add_dependency "tty-which", "~> 0.4"
44
+ spec.add_dependency "pastel", "~> 0.7.2"
45
+ spec.add_dependency "thor", "~> 0.20.0"
46
+ spec.add_dependency "octokit", "~> 4.13.0"
47
+
48
+ spec.add_development_dependency "bundler", "~> 1.17"
49
+ spec.add_development_dependency "rake", "~> 10.0"
50
+ spec.add_development_dependency "rspec", "~> 3.0"
51
+ spec.add_development_dependency "byebug"
52
+ end
data/lib/gitdig.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "gitdig/version"
2
+
3
+ module Gitdig
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
data/lib/gitdig/cli.rb ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Gitdig
6
+ # Handle the application command line parsing
7
+ # and the dispatch to various command objects
8
+ #
9
+ # @api public
10
+ class CLI < Thor
11
+ # Error raised by this runner
12
+ Error = Class.new(StandardError)
13
+
14
+ class_option :editor, type: :string, lazy_default: 'true',
15
+ desc: 'Open output in editor'
16
+
17
+ desc 'version', 'gitdig version'
18
+ def version
19
+ require_relative 'version'
20
+ puts "v#{Gitdig::VERSION}"
21
+ end
22
+ map %w[--version -v] => :version
23
+
24
+ require_relative 'commands/pr'
25
+ register Gitdig::Commands::Pr, 'pr', 'pr [SUBCOMMAND]', 'Command description...'
26
+
27
+ require_relative 'commands/config'
28
+ register Gitdig::Commands::Config, 'config', 'config [SUBCOMMAND]', 'Command description...'
29
+ end
30
+ end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Gitdig
6
+ class Command
7
+ extend Forwardable
8
+
9
+ CONFIG_FILE = '.gitdig'
10
+
11
+ def_delegators :command, :run
12
+
13
+ # Execute this command
14
+ #
15
+ # @api public
16
+ def execute(*)
17
+ raise(
18
+ NotImplementedError,
19
+ "#{self.class}##{__method__} must be implemented"
20
+ )
21
+ end
22
+
23
+ # The external commands runner
24
+ #
25
+ # @see http://www.rubydoc.info/gems/tty-command
26
+ #
27
+ # @api public
28
+ def command(**options)
29
+ require 'tty-command'
30
+ TTY::Command.new(options)
31
+ end
32
+
33
+ # The cursor movement
34
+ #
35
+ # @see http://www.rubydoc.info/gems/tty-cursor
36
+ #
37
+ # @api public
38
+ def cursor
39
+ require 'tty-cursor'
40
+ TTY::Cursor
41
+ end
42
+
43
+ # Open a file or text in the user's preferred editor
44
+ #
45
+ # @see http://www.rubydoc.info/gems/tty-editor
46
+ #
47
+ # @api public
48
+ def editor
49
+ require 'tty-editor'
50
+ TTY::Editor
51
+ end
52
+
53
+ # File manipulation utility methods
54
+ #
55
+ # @see http://www.rubydoc.info/gems/tty-file
56
+ #
57
+ # @api public
58
+ def generator
59
+ require 'tty-file'
60
+ TTY::File
61
+ end
62
+
63
+ # Terminal output paging
64
+ #
65
+ # @see http://www.rubydoc.info/gems/tty-pager
66
+ #
67
+ # @api public
68
+ def pager(**options)
69
+ require 'tty-pager'
70
+ TTY::Pager.new(options)
71
+ end
72
+
73
+ # Terminal platform and OS properties
74
+ #
75
+ # @see http://www.rubydoc.info/gems/tty-pager
76
+ #
77
+ # @api public
78
+ def platform
79
+ require 'tty-platform'
80
+ TTY::Platform.new
81
+ end
82
+
83
+ # The interactive prompt
84
+ #
85
+ # @see http://www.rubydoc.info/gems/tty-prompt
86
+ #
87
+ # @api public
88
+ def prompt(**options)
89
+ require 'tty-prompt'
90
+ TTY::Prompt.new(options)
91
+ end
92
+
93
+ # Get terminal screen properties
94
+ #
95
+ # @see http://www.rubydoc.info/gems/tty-screen
96
+ #
97
+ # @api public
98
+ def screen
99
+ require 'tty-screen'
100
+ TTY::Screen
101
+ end
102
+
103
+ # The unix which utility
104
+ #
105
+ # @see http://www.rubydoc.info/gems/tty-which
106
+ #
107
+ # @api public
108
+ def which(*args)
109
+ require 'tty-which'
110
+ TTY::Which.which(*args)
111
+ end
112
+
113
+ # Check if executable exists
114
+ #
115
+ # @see http://www.rubydoc.info/gems/tty-which
116
+ #
117
+ # @api public
118
+ def exec_exist?(*args)
119
+ require 'tty-which'
120
+ TTY::Which.exist?(*args)
121
+ end
122
+
123
+ # Config for the tool
124
+ def configs
125
+ require 'tty-config'
126
+ @configs ||= TTY::Config.new.tap do |c|
127
+ c.filename = CONFIG_FILE
128
+ c.append_path Dir.pwd
129
+ c.append_path Dir.home
130
+ c.read
131
+ end
132
+ end
133
+
134
+ # Octokit client for Github
135
+ def github_client
136
+ require 'octokit'
137
+ @github_client ||= Octokit::Client.new(
138
+ access_token: configs.fetch(:token)
139
+ )
140
+ end
141
+ end
142
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Gitdig
6
+ module Commands
7
+ class Config < Thor
8
+ namespace :config
9
+
10
+ class_option :global, aliases: '-g', type: :boolean,
11
+ desc: 'Global configuration'
12
+
13
+ desc 'token TOKEN', 'Set Github personal access token'
14
+ method_option :help, aliases: '-h', type: :boolean,
15
+ desc: 'Display usage information'
16
+ def token(token)
17
+ if options[:help]
18
+ invoke :help, ['token']
19
+ else
20
+ require_relative 'config/token'
21
+ command = Gitdig::Commands::Config::Token.new(token, options)
22
+ ensure_scope(command).execute
23
+ end
24
+ end
25
+
26
+ desc 'org NAME', 'Set your Github organization name'
27
+ method_option :help, aliases: '-h', type: :boolean,
28
+ desc: 'Display usage information'
29
+ def org(name)
30
+ if options[:help]
31
+ invoke :help, ['org']
32
+ else
33
+ require_relative 'config/org'
34
+ command = Gitdig::Commands::Config::Org.new(name, options)
35
+ ensure_scope(command).execute
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def ensure_scope(command)
42
+ command.configs.prepend_path Dir.home if options[:global]
43
+
44
+ command
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../command'
4
+
5
+ module Gitdig
6
+ module Commands
7
+ class Config
8
+ class Org < Gitdig::Command
9
+ def initialize(name, options)
10
+ @name = name
11
+ @options = options
12
+ end
13
+
14
+ def execute(input: $stdin, output: $stdout)
15
+ configs.set(:org, value: @name)
16
+ configs.write(force: true)
17
+ output.puts 'OK'
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../command'
4
+
5
+ module Gitdig
6
+ module Commands
7
+ class Config
8
+ class Token < Gitdig::Command
9
+ def initialize(my_token, options)
10
+ @my_token = my_token
11
+ @options = options
12
+ end
13
+
14
+ def execute(input: $stdin, output: $stdout)
15
+ configs.set(:token, value: @my_token)
16
+ configs.write(force: true)
17
+ output.puts 'OK'
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitdig
4
+ module Commands
5
+ module Mixin
6
+ module Editorable
7
+ OUTPUT_FILE = File.expand_path('.gitdig_output.md', Dir.home)
8
+
9
+ def editor_exec(command)
10
+ if options[:editor]
11
+ out = StringIO.new
12
+ command.execute(output: out)
13
+ opts = { content: out.string }
14
+ opts[:command] = options[:editor] if options[:editor] != 'true'
15
+ open_editor(command, opts)
16
+ else
17
+ command.execute
18
+ end
19
+ end
20
+
21
+ def open_editor(command, opts)
22
+ command.generator.remove_file OUTPUT_FILE, verbose: false
23
+ command.editor.open(OUTPUT_FILE, opts)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Gitdig
6
+ module Commands
7
+ class Pr < Thor
8
+ require_relative 'mixin/editorable'
9
+ include Mixin::Editorable
10
+
11
+ namespace :pr
12
+
13
+ class_option :created, type: :string, desc: 'Filter :created'
14
+
15
+ desc 'team [TEAM_ID]', 'Get pull requests created by a team'
16
+ method_option :help, aliases: '-h', type: :boolean,
17
+ desc: 'Display usage information'
18
+ method_option :organization,
19
+ aliases: '-o', type: :string,
20
+ desc: 'Within this organization, if missing get configured organization'
21
+ method_option :team, aliases: '-t', type: :string,
22
+ desc: 'Within this team'
23
+ def team(team_id = nil)
24
+ if options[:help]
25
+ invoke :help, ['team']
26
+ else
27
+ require_relative 'pr/team'
28
+ editor_exec(Gitdig::Commands::Pr::Team.new(team_id, options))
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../command'
4
+
5
+ module Gitdig
6
+ module Commands
7
+ class Pr
8
+ class Team < Gitdig::Command
9
+ REPO_REGEX = %r{[^/]+/[^/]+$}.freeze
10
+
11
+ def initialize(team_id, options)
12
+ @team_id = team_id
13
+ @options = options
14
+ end
15
+
16
+ def execute(input: $stdin, output: $stdout)
17
+ issues = github_client.search_issues(
18
+ search_str,
19
+ sort: 'created', order: 'asc', per_page: 100
20
+ )
21
+ issues.items.each do |i|
22
+ output.puts pr_output(i)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def team
29
+ @team = @team_id || prompt.select('Choose a team to get pull requests') do |menu|
30
+ teams.each { |t| menu.choice "#{t.name} (#{t.id})", t.id }
31
+ end
32
+ end
33
+
34
+ def search_str
35
+ @search_str ||=
36
+ begin
37
+ author_str = members(team).map { |mem| "author:#{mem.login}" }.join(' ')
38
+ search_str = "type:pr #{author_str}"
39
+ search_str = "#{search_str} created:#{@options[:created]}" if @options[:created]
40
+ search_str = "#{search_str} org:#{org}" if org
41
+
42
+ search_str
43
+ end
44
+ end
45
+
46
+ def org
47
+ @org ||= @options[:organization] || configs.fetch(:org)
48
+ end
49
+
50
+ def teams
51
+ @teams ||= if @options[:team]
52
+ github_client.child_teams(@options[:team])
53
+ elsif @options[:organization]
54
+ github_client.organization_teams(@options[:organization])
55
+ elsif (org = configs.fetch(:org))
56
+ github_client.organization_teams(org)
57
+ end
58
+ end
59
+
60
+ def members(team_id)
61
+ github_client.team_members(team_id)
62
+ end
63
+
64
+ def pr_output(pull)
65
+ repo = REPO_REGEX.match(pull.repository_url).to_s
66
+ "* [#{pull.title}](#{pull.html_url}) <#{pull.state}>"\
67
+ " #{repo}##{pull.number} @#{pull.user.login}"
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,3 @@
1
+ module Gitdig
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,438 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitdig
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Viet (Drake) Tran
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-box
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.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.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-color
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-command
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-config
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.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: 0.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-cursor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-editor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-file
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.7.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.7.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-font
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.2.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.2.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: tty-markdown
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.5.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.5.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: tty-pager
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.12.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.12.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: tty-pie
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.1.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.1.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: tty-platform
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.2.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.2.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: tty-progressbar
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.16.0
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.16.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty-prompt
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.18.0
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.18.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: tty-screen
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.6'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.6'
223
+ - !ruby/object:Gem::Dependency
224
+ name: tty-spinner
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: 0.9.0
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: 0.9.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: tty-table
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.10.0
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.10.0
251
+ - !ruby/object:Gem::Dependency
252
+ name: tty-tree
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 0.2.0
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: 0.2.0
265
+ - !ruby/object:Gem::Dependency
266
+ name: tty-which
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '0.4'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '0.4'
279
+ - !ruby/object:Gem::Dependency
280
+ name: pastel
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: 0.7.2
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: 0.7.2
293
+ - !ruby/object:Gem::Dependency
294
+ name: thor
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: 0.20.0
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.20.0
307
+ - !ruby/object:Gem::Dependency
308
+ name: octokit
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: 4.13.0
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: 4.13.0
321
+ - !ruby/object:Gem::Dependency
322
+ name: bundler
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - "~>"
326
+ - !ruby/object:Gem::Version
327
+ version: '1.17'
328
+ type: :development
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - "~>"
333
+ - !ruby/object:Gem::Version
334
+ version: '1.17'
335
+ - !ruby/object:Gem::Dependency
336
+ name: rake
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '10.0'
342
+ type: :development
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '10.0'
349
+ - !ruby/object:Gem::Dependency
350
+ name: rspec
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '3.0'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '3.0'
363
+ - !ruby/object:Gem::Dependency
364
+ name: byebug
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - ">="
368
+ - !ruby/object:Gem::Version
369
+ version: '0'
370
+ type: :development
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - ">="
375
+ - !ruby/object:Gem::Version
376
+ version: '0'
377
+ description:
378
+ email:
379
+ - phuocviet89@gmail.com
380
+ executables:
381
+ - gitdig
382
+ extensions: []
383
+ extra_rdoc_files: []
384
+ files:
385
+ - ".gitignore"
386
+ - ".rspec"
387
+ - ".rubocop.yml"
388
+ - ".ruby-version"
389
+ - ".travis.yml"
390
+ - CODE_OF_CONDUCT.md
391
+ - Gemfile
392
+ - Gemfile.lock
393
+ - LICENSE.txt
394
+ - README.md
395
+ - Rakefile
396
+ - bin/console
397
+ - bin/setup
398
+ - exe/gitdig
399
+ - gitdig.gemspec
400
+ - lib/gitdig.rb
401
+ - lib/gitdig/cli.rb
402
+ - lib/gitdig/command.rb
403
+ - lib/gitdig/commands/.gitkeep
404
+ - lib/gitdig/commands/config.rb
405
+ - lib/gitdig/commands/config/org.rb
406
+ - lib/gitdig/commands/config/token.rb
407
+ - lib/gitdig/commands/mixin/editorable.rb
408
+ - lib/gitdig/commands/pr.rb
409
+ - lib/gitdig/commands/pr/team.rb
410
+ - lib/gitdig/templates/.gitkeep
411
+ - lib/gitdig/templates/config/org/.gitkeep
412
+ - lib/gitdig/templates/config/token/.gitkeep
413
+ - lib/gitdig/templates/pr/team/.gitkeep
414
+ - lib/gitdig/version.rb
415
+ homepage: https://github.com/tiev
416
+ licenses:
417
+ - MIT
418
+ metadata: {}
419
+ post_install_message:
420
+ rdoc_options: []
421
+ require_paths:
422
+ - lib
423
+ required_ruby_version: !ruby/object:Gem::Requirement
424
+ requirements:
425
+ - - ">="
426
+ - !ruby/object:Gem::Version
427
+ version: '0'
428
+ required_rubygems_version: !ruby/object:Gem::Requirement
429
+ requirements:
430
+ - - ">="
431
+ - !ruby/object:Gem::Version
432
+ version: '0'
433
+ requirements: []
434
+ rubygems_version: 3.0.1
435
+ signing_key:
436
+ specification_version: 4
437
+ summary: Weekly digest for your github account
438
+ test_files: []