gh-cards 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gh-cards/cards.html +56 -0
- data/.gh-cards/last +1 -0
- data/.gitignore +9 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +99 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gh-cards +4 -0
- data/gh-cards.gemspec +37 -0
- data/lib/gh/cards/cli.rb +20 -0
- data/lib/gh/cards/version.rb +5 -0
- data/lib/gh/cards.rb +124 -0
- data/templates/default.html.erb +52 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '07629067776ce059225686bf45244ee46075e49a278c51a2a86b3f40ed028f01'
|
4
|
+
data.tar.gz: 1eb4656405f1fda42fa3b422f31e67ebc6f8e2aa4b849cd033b4c39777ba0086
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0dc8f8dae97af766abb9241f7100aedffb08abe1428b869d6e1cc8b2204ecc00deff15908c809530a60faea0a63a2fef94b94f6442839926f5e73e4385b07619
|
7
|
+
data.tar.gz: d6313c9c14325677f56e595dbf0b25012225fc5e174c9e9bde419e9137f3cf947d4417aeeb7cfdfe98795f2dd5c81d1293a2c41de2334174ca028b83af9fb4af
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Cards for JSainsburyPLC/gh-cards</title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
8
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
9
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
10
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
11
|
+
<style>
|
12
|
+
.card-deck .card {
|
13
|
+
max-width: calc(33% - 30px);
|
14
|
+
}
|
15
|
+
</style>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
<div class="container">
|
19
|
+
<div class="row">
|
20
|
+
<div class="col-12">
|
21
|
+
<div class="card-deck">
|
22
|
+
|
23
|
+
|
24
|
+
<div class="card">
|
25
|
+
<div class="card-header">
|
26
|
+
gh-cards
|
27
|
+
</div>
|
28
|
+
<div class="card-body">
|
29
|
+
<h4 class="card-title"><span class="font-weight-bold">#1</span> Test Issue</h4>
|
30
|
+
|
31
|
+
<h6 class="text-secondary">Labels:</h6>
|
32
|
+
<div class="small text-secondary test-lowercase">
|
33
|
+
|
34
|
+
bug<br />
|
35
|
+
|
36
|
+
good first issue<br />
|
37
|
+
|
38
|
+
help wanted<br />
|
39
|
+
|
40
|
+
</div>
|
41
|
+
|
42
|
+
</div>
|
43
|
+
<div class="card-footer small text-secondary">
|
44
|
+
Created by: Tim Birkett<br />
|
45
|
+
at 2019-11-07
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<div class="w-100 py-2"></div>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</body>
|
56
|
+
</html>
|
data/.gh-cards/last
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.6.5
|
6
|
+
|
7
|
+
before_install: gem install bundler -v 2.0.2
|
8
|
+
|
9
|
+
deploy:
|
10
|
+
provider: rubygems
|
11
|
+
api_key:
|
12
|
+
secure: ca+G7zy/ysMlw+odJ+aAIfrRgyDJaWh51vb4BqEEW9zgUpQDbmFWNsER94KuOBAORKSoS6KRbHBT3TkFwyJThAymOIZYsh/jijAOlu66KkKTZE/MYdqJuGAsFf1Ru311I73UIGBBZFWQKpQiEpAY+R+K4FLWfcsPRTRf2TKSjjFm7UDVh5NemEQ5yMBu4U9BxAYyNuDyCq8lNC9531KtnBVVl9ijex9ObSO6lNDl49DlmMWgyG/NCvHrVJQdDFHQ+MTpDRt3iWmg8U/D7/xvNIkJl6ifFmZWcf+grvkCM+I/0QDSLCSmBBgxjg493BCK4glm0LDuc7QU1ebM3S74R3qQ0Wjppyuvzi2AkGyghtPrtY6rwo8IslSh5zUltjiEPYtR3ZLoe/AT+Xn8P18ZmQ2aedl7akq5vXNHGRa1KvbWAwT9r/oauiA/S1q+bgujaCH50l71ZpggF1g8T2QSI7kuNJGFXy1KFZXCxxDg+BFpAD9WJls/J8ix9ek21jwhUAqF2rtm/BttvkZQERwX4DdaX8zHybdFeRcviYVZWsi3g1TUu4AHN0yXZsAULLQ59UamAMe/8TkXNDBKcOo9ksMdugG1TJssAdcM/kuP0SGCpwHZ3m4tdq4/550iYWFiU0huGdTYVnXvQw3FvMImxTaMQ/DOwWRfsAEUoyJbnVw=
|
13
|
+
gem: gh-cards
|
14
|
+
on:
|
15
|
+
tags: true
|
16
|
+
repo: devopsmakers/gh-cards
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 tim.birkett@sainsburys.co.uk. 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
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Devops Makers
|
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 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,
|
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Devops Makers
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# gh-cards
|
2
|
+
|
3
|
+
Create HTML format cards from Github Issues for printing
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install gh-cards
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The `gh-cards` cli tool is designed to be run inside a repo. It will create a
|
14
|
+
directory `.gh-cards` containing a file named `last` which stores the last card
|
15
|
+
and a file `cards.html` which are the cards to be printed.
|
16
|
+
|
17
|
+
At least the `.gh-cards/last` file should be committed to your repo so that anyone
|
18
|
+
can print cards as necessary.
|
19
|
+
|
20
|
+
To generate cards from all open issues, `rm .gh-cards/last`.
|
21
|
+
|
22
|
+
```
|
23
|
+
Commands:
|
24
|
+
gh-cards generate # Generate your Github issue cards HTML file
|
25
|
+
gh-cards help [COMMAND] # Describe available commands or one specific command
|
26
|
+
|
27
|
+
Options:
|
28
|
+
-t, [--template=TEMPLATE] # Template name or path to erb template
|
29
|
+
# Default: default
|
30
|
+
-d, [--directory=DIRECTORY] # The directory to use for output
|
31
|
+
# Default: .gh-cards
|
32
|
+
-r, [--repo=REPO] # The org/repo you want to generate cards for (autodetected when inside a repo)
|
33
|
+
```
|
34
|
+
|
35
|
+
To generate cards:
|
36
|
+
```
|
37
|
+
cd my-repo
|
38
|
+
gh-cards generate
|
39
|
+
```
|
40
|
+
|
41
|
+
## Card Templates
|
42
|
+
|
43
|
+
Cards are generated using ERB Templates. The default template is in this repo
|
44
|
+
at: `templates/default.html.erb` which is designed to use minimal ink. If templates
|
45
|
+
are added in the future (Hint: open PRs) you'll be able to reference them with
|
46
|
+
the `-t` or `--template` option.
|
47
|
+
|
48
|
+
You can also create your own templates, for example if you create a template at:
|
49
|
+
`.gh-cards/my-template.html.erb` you can generate cards using your template:
|
50
|
+
```
|
51
|
+
gh-cards generate --template=.gh-cards/my-template.html.erb
|
52
|
+
```
|
53
|
+
|
54
|
+
The cards passed to the ERB are an array of objects:
|
55
|
+
```
|
56
|
+
[
|
57
|
+
{
|
58
|
+
:title=>"Test Issue",
|
59
|
+
:number=>1,
|
60
|
+
:labels=>[
|
61
|
+
{
|
62
|
+
:name=>"bug",
|
63
|
+
:color=>"d73a4a"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
:name=>"good first issue",
|
67
|
+
:color=>"7057ff"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
:name=>"help wanted",
|
71
|
+
:color=>"008672"
|
72
|
+
}
|
73
|
+
],
|
74
|
+
:created_by=>"Tim Birkett",
|
75
|
+
:created_at=>2019-11-07 15:07:31 UTC
|
76
|
+
},
|
77
|
+
...
|
78
|
+
...
|
79
|
+
...
|
80
|
+
]
|
81
|
+
```
|
82
|
+
|
83
|
+
## Development
|
84
|
+
|
85
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
86
|
+
|
87
|
+
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).
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gh-cards. 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.
|
92
|
+
|
93
|
+
## License
|
94
|
+
|
95
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
96
|
+
|
97
|
+
## Code of Conduct
|
98
|
+
|
99
|
+
Everyone interacting in the Gh::Cards project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gh-cards/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gh/cards"
|
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
data/exe/gh-cards
ADDED
data/gh-cards.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "gh/cards/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gh-cards"
|
7
|
+
spec.version = Gh::Cards::VERSION
|
8
|
+
spec.authors = ["Tim Birkett"]
|
9
|
+
spec.email = ["tim.birkett@devopsmakers.co.uk"]
|
10
|
+
|
11
|
+
spec.summary = "Create HTML format cards from Github Issues for printing"
|
12
|
+
spec.homepage = "https://github.com/devopsmakers/gh-cards"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "octokit", "~> 4.14"
|
29
|
+
spec.add_runtime_dependency "netrc", "~> 0.11.0"
|
30
|
+
spec.add_runtime_dependency "git", "~> 1.5"
|
31
|
+
spec.add_runtime_dependency "thor", "~> 0.20.3"
|
32
|
+
spec.add_runtime_dependency "activesupport", "~> 6.0"
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
37
|
+
end
|
data/lib/gh/cards/cli.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "gh/cards"
|
3
|
+
|
4
|
+
module Gh
|
5
|
+
module Cards
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :template, :type => :string, :aliases => "-t",
|
8
|
+
:desc => "Template name or path to erb template", :default => "default"
|
9
|
+
class_option :directory, :type => :string, :aliases => "-d",
|
10
|
+
:desc => "The directory to use for output", :default => ".gh-cards"
|
11
|
+
class_option :repo, :type => :string, :aliases => "-r",
|
12
|
+
:desc => "The org/repo you want to generate cards for (autodetected when inside a repo)"
|
13
|
+
|
14
|
+
desc "generate", "Generate your Github issue cards HTML file"
|
15
|
+
def generate
|
16
|
+
Gh::Cards.generate options[:template], options[:directory], options[:repo]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/gh/cards.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require "gh/cards/version"
|
2
|
+
require "git"
|
3
|
+
require "octokit"
|
4
|
+
require "active_support/inflector"
|
5
|
+
require "erb"
|
6
|
+
|
7
|
+
module Gh
|
8
|
+
module Cards
|
9
|
+
|
10
|
+
$user_names_cache = {}
|
11
|
+
|
12
|
+
def self.generate(template, directory, repo)
|
13
|
+
@template = template
|
14
|
+
@directory = directory
|
15
|
+
@repo = repo || _get_this_repo()
|
16
|
+
|
17
|
+
@last_issue = _get_last_issue(@directory)
|
18
|
+
|
19
|
+
@cards = _get_cards_from_gh_issues(@last_issue)
|
20
|
+
|
21
|
+
_generate_cards_html(@template, @directory, @repo, @cards)
|
22
|
+
|
23
|
+
_set_last_issue(@directory, @cards)
|
24
|
+
|
25
|
+
system("open", "#{@directory}/cards.html")
|
26
|
+
puts "Done!"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self._get_this_repo
|
30
|
+
@repo_regex = /^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+).git$/
|
31
|
+
begin
|
32
|
+
@g = Git.open('.')
|
33
|
+
rescue
|
34
|
+
abort("Unable to detect git repo! Make sure you're in a repo or use the --repo option")
|
35
|
+
end
|
36
|
+
@r = @g.remote('origin').url.match(@repo_regex)
|
37
|
+
return "#{@r[4]}/#{@r[5]}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self._get_last_issue(directory)
|
41
|
+
@last_file = "#{directory}/last"
|
42
|
+
|
43
|
+
if ! File.directory?(directory)
|
44
|
+
FileUtils.mkdir_p directory
|
45
|
+
end
|
46
|
+
|
47
|
+
if ! File.file?(@last_file)
|
48
|
+
File.open(@last_file, "w") do |f|
|
49
|
+
f.write(0)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
@last_issue_number = File.open(@last_file, "r"){ |file| file.read }
|
54
|
+
return @last_issue_number.to_i
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def self._set_last_issue(directory, cards)
|
59
|
+
@last_file = "#{directory}/last"
|
60
|
+
File.open(@last_file, "w") do |f|
|
61
|
+
f.write(@cards[0][:number])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self._get_cards_from_gh_issues(last_issue)
|
66
|
+
@client = Octokit::Client.new(:netrc => true)
|
67
|
+
@client.auto_paginate = true
|
68
|
+
|
69
|
+
@issues = @client.list_issues @repo
|
70
|
+
@issues.reject!{ |issue| issue[:number] <= last_issue or issue[:pull_request]}
|
71
|
+
|
72
|
+
if @issues.empty?
|
73
|
+
@exit_msg = "No issues found in #{@repo}"
|
74
|
+
if last_issue > 0
|
75
|
+
@exit_msg << "\n\nFile: #{@directory}/last shows the last issue generated as #{last_issue}"
|
76
|
+
@exit_msg << "\nTo reset and generate all cards, delete #{@directory}/last and re-run"
|
77
|
+
end
|
78
|
+
puts @exit_msg
|
79
|
+
exit 0
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "Found #{@issues.length} new #{"issue".pluralize @issues.length} in #{@repo} to generate cards from"
|
83
|
+
|
84
|
+
@cards = @issues.map do |issue|
|
85
|
+
{
|
86
|
+
:title => issue[:title],
|
87
|
+
:number => issue[:number],
|
88
|
+
:labels => issue[:labels].map{|label| {:name => label[:name], :color => label[:color]}},
|
89
|
+
:created_by => _get_gh_user_name(issue[:user][:login]),
|
90
|
+
:created_at => issue[:created_at]
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
return @cards
|
95
|
+
end
|
96
|
+
|
97
|
+
def self._get_gh_user_name(user_login)
|
98
|
+
if $user_names_cache[user_login.to_sym].nil?
|
99
|
+
$user_names_cache[user_login.to_sym] = @client.user(user_login)[:name] || user_login
|
100
|
+
end
|
101
|
+
return $user_names_cache[user_login.to_sym]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self._generate_cards_html(template, directory, repo, cards)
|
105
|
+
|
106
|
+
if File.file?("#{__dir__}/../../templates/#{template}.html.erb")
|
107
|
+
@template_file = "#{__dir__}/../../templates/#{template}.html.erb"
|
108
|
+
elsif File.file?("#{__dir__}/../../templates/#{template}")
|
109
|
+
@template_file = "#{__dir__}/../../templates/#{template}"
|
110
|
+
elsif File.file?(template)
|
111
|
+
@template_file = template
|
112
|
+
else
|
113
|
+
abort("Unable to find template: #{template}")
|
114
|
+
end
|
115
|
+
|
116
|
+
@cards = cards
|
117
|
+
@repo = repo
|
118
|
+
|
119
|
+
puts "Generating cards using template: #{template}"
|
120
|
+
erb = ERB.new(File.read(@template_file))
|
121
|
+
File.write("#{directory}/cards.html", erb.result(binding))
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Cards for <%= @repo %></title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
8
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
9
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
10
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
11
|
+
<style>
|
12
|
+
.card-deck .card {
|
13
|
+
max-width: calc(33% - 30px);
|
14
|
+
}
|
15
|
+
</style>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
<div class="container">
|
19
|
+
<div class="row">
|
20
|
+
<div class="col-12">
|
21
|
+
<div class="card-deck">
|
22
|
+
<% @cards.each_slice(3) do |slice| %>
|
23
|
+
<% slice.each do |card| %>
|
24
|
+
<div class="card">
|
25
|
+
<div class="card-header">
|
26
|
+
<%= @repo.split('/')[-1] %>
|
27
|
+
</div>
|
28
|
+
<div class="card-body">
|
29
|
+
<h4 class="card-title"><span class="font-weight-bold">#<%= card[:number] %></span> <%= card[:title] %></h4>
|
30
|
+
<% if card[:labels].length > 0 %>
|
31
|
+
<h6 class="text-secondary">Labels:</h6>
|
32
|
+
<div class="small text-secondary test-lowercase">
|
33
|
+
<% for @label in card[:labels] %>
|
34
|
+
<%= @label[:name] %><br />
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
39
|
+
<div class="card-footer small text-secondary">
|
40
|
+
Created by: <%= card[:created_by] %><br />
|
41
|
+
<%= card[:created_at].strftime("at %F") %>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
<% end %>
|
45
|
+
<div class="w-100 py-2"></div>
|
46
|
+
<% end %>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</body>
|
52
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gh-cards
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Birkett
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.14'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: netrc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.11.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.11.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: git
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.20.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.20.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '6.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '6.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '5.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '5.0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- tim.birkett@devopsmakers.co.uk
|
128
|
+
executables:
|
129
|
+
- gh-cards
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gh-cards/cards.html"
|
134
|
+
- ".gh-cards/last"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".travis.yml"
|
137
|
+
- CHANGELOG.md
|
138
|
+
- CODE_OF_CONDUCT.md
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE
|
141
|
+
- LICENSE.txt
|
142
|
+
- README.md
|
143
|
+
- Rakefile
|
144
|
+
- bin/console
|
145
|
+
- bin/setup
|
146
|
+
- exe/gh-cards
|
147
|
+
- gh-cards.gemspec
|
148
|
+
- lib/gh/cards.rb
|
149
|
+
- lib/gh/cards/cli.rb
|
150
|
+
- lib/gh/cards/version.rb
|
151
|
+
- templates/default.html.erb
|
152
|
+
homepage: https://github.com/devopsmakers/gh-cards
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata:
|
156
|
+
homepage_uri: https://github.com/devopsmakers/gh-cards
|
157
|
+
source_code_uri: https://github.com/devopsmakers/gh-cards
|
158
|
+
changelog_uri: https://github.com/devopsmakers/gh-cards/blob/master/CHANGELOG.md
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubygems_version: 3.0.3
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Create HTML format cards from Github Issues for printing
|
178
|
+
test_files: []
|