copyist 0.1.0
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 +7 -0
- data/.env.sample +18 -0
- data/.env.test +13 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +46 -0
- data/LICENSE.txt +21 -0
- data/README.md +117 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/copyist.gemspec +37 -0
- data/exe/copyist +5 -0
- data/lib/copyist.rb +9 -0
- data/lib/copyist/application.rb +12 -0
- data/lib/copyist/job.rb +96 -0
- data/lib/copyist/version.rb +5 -0
- metadata +94 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 07af1b2d7af9174ff84bc3ca3e54b9318e982c4a2d051cc754e50eec8c6de685
|
|
4
|
+
data.tar.gz: d92d6cd9a2d30257a627bfa5b081856f4a10404f70732b7a4733f9a7e9ca742c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 18de1348997403742d7eccd1b247bb9272435862af895f9f58a58cf782b08a33e766db72ae45b8008e3bbb7f39285fd69323b7e9506a32927b0f0b6314f7c15f
|
|
7
|
+
data.tar.gz: c4b557e26f5fc40bfa59930ad146fbf898d19df44c54ce5b7c1707234edef997eb0137b87ad52c4ccc1e180110cb1b65a374085b3fede29b4eb9cf0080dc0352
|
data/.env.sample
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
GITHUB_PERSONAL_TOKEN=ENV['GITHUB_PERSONAL_TOKEN']
|
|
2
|
+
GITHUB_USER_NAME=
|
|
3
|
+
GITHUB_REPO_NAME=
|
|
4
|
+
|
|
5
|
+
# standard style
|
|
6
|
+
TITLE_IDENTIFIRE='#'
|
|
7
|
+
SKIP_IDENTIFIRES='skip_line:,#####'
|
|
8
|
+
LABEL_IDENTIFIRE='labels:'
|
|
9
|
+
|
|
10
|
+
GLOBAL_LABELS='copyist_generated'
|
|
11
|
+
|
|
12
|
+
# # alternative style
|
|
13
|
+
# TITLE_IDENTIFIRE='###'
|
|
14
|
+
# SKIP_IDENTIFIRES='#,##'
|
|
15
|
+
# LABEL_IDENTIFIRE='labels:'
|
|
16
|
+
|
|
17
|
+
# template must have '{ticket_description_block}'. That will be replaced by the tickets description.
|
|
18
|
+
# TEMPLATE_FILE_PATH='../template.md'
|
data/.env.test
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
GITHUB_PERSONAL_TOKEN=ENV['GITHUB_PERSONAL_TOKEN']
|
|
2
|
+
GITHUB_USER_NAME='bar'
|
|
3
|
+
GITHUB_REPO_NAME='foo'
|
|
4
|
+
|
|
5
|
+
TITLE_IDENTIFIRE='#'
|
|
6
|
+
|
|
7
|
+
SKIP_IDENTIFIRES='skip_line:,#####'
|
|
8
|
+
|
|
9
|
+
LABEL_IDENTIFIRE='labels:'
|
|
10
|
+
|
|
11
|
+
GLOBAL_LABELS='alpha,beta'
|
|
12
|
+
|
|
13
|
+
TEMPLATE_FILE_PATH=
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
copyist (0.1.0)
|
|
5
|
+
dotenv
|
|
6
|
+
thor
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
ast (2.4.2)
|
|
12
|
+
dotenv (2.7.6)
|
|
13
|
+
minitest (5.14.4)
|
|
14
|
+
parallel (1.20.1)
|
|
15
|
+
parser (3.0.2.0)
|
|
16
|
+
ast (~> 2.4.1)
|
|
17
|
+
rainbow (3.0.0)
|
|
18
|
+
rake (13.0.6)
|
|
19
|
+
regexp_parser (2.1.1)
|
|
20
|
+
rexml (3.2.5)
|
|
21
|
+
rubocop (1.18.3)
|
|
22
|
+
parallel (~> 1.10)
|
|
23
|
+
parser (>= 3.0.0.0)
|
|
24
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
25
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
26
|
+
rexml
|
|
27
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
|
28
|
+
ruby-progressbar (~> 1.7)
|
|
29
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
30
|
+
rubocop-ast (1.7.0)
|
|
31
|
+
parser (>= 3.0.1.1)
|
|
32
|
+
ruby-progressbar (1.11.0)
|
|
33
|
+
thor (1.1.0)
|
|
34
|
+
unicode-display_width (2.0.0)
|
|
35
|
+
|
|
36
|
+
PLATFORMS
|
|
37
|
+
universal-darwin-19
|
|
38
|
+
|
|
39
|
+
DEPENDENCIES
|
|
40
|
+
copyist!
|
|
41
|
+
minitest (~> 5.0)
|
|
42
|
+
rake (~> 13.0)
|
|
43
|
+
rubocop (~> 1.7)
|
|
44
|
+
|
|
45
|
+
BUNDLED WITH
|
|
46
|
+
2.2.16
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 TODO: Write your name
|
|
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,117 @@
|
|
|
1
|
+
# Copyist
|
|
2
|
+
This application is a tool that can parse a file written in markdown and generate multiple Github isuue tickets at once.
|
|
3
|
+
|
|
4
|
+
The word 'Copyist' means 'Hikko (筆耕)' in Japanese.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
1. clone this repository
|
|
9
|
+
1. `$ bundle install`
|
|
10
|
+
## How to use
|
|
11
|
+
|
|
12
|
+
### step1. set ENV
|
|
13
|
+
- set your github personal token to GITHUB_PERSONAL_TOKEN
|
|
14
|
+
- `$ export GITHUB_PERSONAL_TOKEN={YOUR_TOKEN}`
|
|
15
|
+
|
|
16
|
+
- set target github user name, target github repository name to .env file
|
|
17
|
+
|
|
18
|
+
### step2. ready markdown file
|
|
19
|
+
|
|
20
|
+
example
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
### foo
|
|
24
|
+
- fizz
|
|
25
|
+
- bazz
|
|
26
|
+
- fizzbazz
|
|
27
|
+
### bar
|
|
28
|
+
- aaa
|
|
29
|
+
- **bbb**
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### step3. run copyist
|
|
33
|
+
1. `$ bundle exec exe/copyist job path/to/markdown_file.md`
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Required or Optional Settings (to ENV or .env)
|
|
37
|
+
#### TITLE_IDENTIFIRE (requires)
|
|
38
|
+
An identifier to determine which line to use as the title of the ticket.
|
|
39
|
+
Determine if it matches the beginning of a line.
|
|
40
|
+
Add a space after the set string to judge.
|
|
41
|
+
|
|
42
|
+
example)
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
# when you set '#' as the TITLE_IDENTIFIRE
|
|
46
|
+
|
|
47
|
+
match -> '# This is title.'
|
|
48
|
+
|
|
49
|
+
not match -> '#This is title.'
|
|
50
|
+
not match -> '## This is title.'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### SKIP_IDENTIFIRES (optional)
|
|
54
|
+
Identifier to determine which lines you do not want to include in the ticket.
|
|
55
|
+
If it doesn't exist, ignore it.
|
|
56
|
+
You can specify multiple values separated by commas.
|
|
57
|
+
Determine if it matches the beginning of a line.
|
|
58
|
+
Add a space after the set string to judge.
|
|
59
|
+
|
|
60
|
+
example)
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
# when you set 'aaa,bbb:' as the SKIP_IDENTIFIRES
|
|
64
|
+
|
|
65
|
+
match -> 'aaa This line skipped.'
|
|
66
|
+
match -> 'bbb: This line skipped.'
|
|
67
|
+
|
|
68
|
+
not match -> ' aaa This line skipped.'
|
|
69
|
+
not match -> 'aaaline skipped.'
|
|
70
|
+
not match -> 'bbb line skipped.'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### LABEL_IDENTIFIRE (optional)
|
|
74
|
+
Identifier to determine the line representing the label to be given to the ticket.
|
|
75
|
+
Enter a comma-separated list of labels to be set on the line to be judged.
|
|
76
|
+
Determine if it matches the beginning of a line.
|
|
77
|
+
Add a space after the set string to judge.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
example)
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
# when you set 'labels:' as the LABEL_IDENTIFIRE
|
|
84
|
+
|
|
85
|
+
match -> 'labels: labelA,labelB' -> tickets add label 'labelA' and 'labelB'
|
|
86
|
+
match -> 'labels: labelA, labelB' -> tickets add label 'labelA' and 'labelB' (Spaces will be removed)
|
|
87
|
+
|
|
88
|
+
not match -> 'labels:labelA,labelB' -> No label will be set on the ticket.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### GLOBAL_LABELS (optional)
|
|
92
|
+
Specify the label to be set for all tickets.
|
|
93
|
+
Enter a comma-separated list of labels to be set on the line to be judged.
|
|
94
|
+
You can specify multiple values separated by commas.
|
|
95
|
+
|
|
96
|
+
#### ENVFILE_PATH
|
|
97
|
+
ENV-related settings can be specified in a file.
|
|
98
|
+
Enter the path in the environment variable ENVFILE_PATH.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
example)
|
|
102
|
+
```
|
|
103
|
+
$ export ENVFILE_PATH=.env
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
114
|
+
|
|
115
|
+
## Code of Conduct
|
|
116
|
+
|
|
117
|
+
Everyone interacting in the Copyist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/copyist/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << "test"
|
|
8
|
+
t.libs << "lib"
|
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require "rubocop/rake_task"
|
|
13
|
+
|
|
14
|
+
RuboCop::RakeTask.new
|
|
15
|
+
|
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "copyist"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/copyist.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/copyist/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "copyist"
|
|
7
|
+
spec.version = Copyist::VERSION
|
|
8
|
+
spec.authors = ["ymstshinichiro"]
|
|
9
|
+
spec.email = ["yamashitashinichirou@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "parse markdown to create github issues"
|
|
12
|
+
spec.description = ""
|
|
13
|
+
spec.homepage = "https://github.com/ymstshinichiro/copyist"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/ymstshinichiro/copyist"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/ymstshinichiro/copyist/blob/master/CHANGELOG.md"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
# Uncomment to register a new dependency of your gem
|
|
31
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
32
|
+
spec.add_dependency 'thor'
|
|
33
|
+
spec.add_dependency 'dotenv'
|
|
34
|
+
|
|
35
|
+
# For more information and examples about making a new gem, checkout our
|
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
37
|
+
end
|
data/exe/copyist
ADDED
data/lib/copyist.rb
ADDED
data/lib/copyist/job.rb
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Copyist
|
|
2
|
+
class Job
|
|
3
|
+
IssueTicket = Struct.new(:title, :description, :labels)
|
|
4
|
+
|
|
5
|
+
attr_accessor :title_identifire, :skip_identifires, :label_identifire, :global_labels, :template_file_path
|
|
6
|
+
|
|
7
|
+
def initialize(argv)
|
|
8
|
+
@source_md_file_path = argv
|
|
9
|
+
|
|
10
|
+
env_path = ENV['ENVFILE_PATH']
|
|
11
|
+
Dotenv.load(env_path) if env_path && !env_path.empty?
|
|
12
|
+
|
|
13
|
+
raise 'set GITHUB_USER_NAME and GITHUB_REPO_NAME to .env file' if (ENV['GITHUB_USER_NAME'].empty? || ENV['GITHUB_REPO_NAME'].empty?)
|
|
14
|
+
raise 'set TITLE_IDENTIFIRE to .env file' if ENV['TITLE_IDENTIFIRE'].empty?
|
|
15
|
+
|
|
16
|
+
@title_identifire = "#{ENV['TITLE_IDENTIFIRE']} "
|
|
17
|
+
@skip_identifires = ENV['SKIP_IDENTIFIRES']&.size&.nonzero? ? Regexp.new("^#{ENV['SKIP_IDENTIFIRES'].split(',').join(' |')}") : nil
|
|
18
|
+
@label_identifire = ENV['LABEL_IDENTIFIRE']&.size&.nonzero? ? "#{ENV['LABEL_IDENTIFIRE']} " : nil
|
|
19
|
+
|
|
20
|
+
@global_labels = ENV['GLOBAL_LABELS']&.size&.nonzero? ? ENV['GLOBAL_LABELS'] : nil
|
|
21
|
+
@template_file_path = ENV['TEMPLATE_FILE_PATH']&.size&.nonzero? ? ENV['TEMPLATE_FILE_PATH'] : nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run
|
|
25
|
+
puts 'make tickets to Github from markdown'
|
|
26
|
+
|
|
27
|
+
tickets_from_markdown.each do |ticket|
|
|
28
|
+
response = request_to_github(ticket)
|
|
29
|
+
puts response.message
|
|
30
|
+
end
|
|
31
|
+
puts 'process finished'
|
|
32
|
+
rescue => e
|
|
33
|
+
puts ['fatal error.', '-------', e.backtrace, '------'].flatten.join("\n")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def tickets_from_markdown
|
|
37
|
+
tickets = []
|
|
38
|
+
get_markdown.each do |line|
|
|
39
|
+
next if skip_identifires && line.match?(skip_identifires)
|
|
40
|
+
|
|
41
|
+
if line.match?(/^#{title_identifire}/)
|
|
42
|
+
tickets << IssueTicket.new(line.gsub(/#{title_identifire}|\*|\*\*|`/, ''), [], [])
|
|
43
|
+
|
|
44
|
+
elsif label_identifire && line.match?(/^#{label_identifire}/)
|
|
45
|
+
(tickets&.last&.labels || []) << line.gsub(label_identifire, '').chomp.split(',').map(&:strip)
|
|
46
|
+
|
|
47
|
+
else
|
|
48
|
+
(tickets&.last&.description || []) << line
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
tickets.each{ |i| i.description = make_description(i.description) }
|
|
53
|
+
tickets
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def make_description(description_text_array)
|
|
59
|
+
description = description_text_array.join
|
|
60
|
+
|
|
61
|
+
if template_file_path
|
|
62
|
+
template = File.open(template_file_path, "r") { |f| f.read }
|
|
63
|
+
description = template.gsub('{ticket_description_block}', description)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
description
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def request_to_github(ticket)
|
|
70
|
+
uri = get_uri
|
|
71
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
72
|
+
http.use_ssl = uri.scheme === "https"
|
|
73
|
+
|
|
74
|
+
headers = { Authorization: "token #{ENV['GITHUB_PERSONAL_TOKEN']}" }
|
|
75
|
+
body = make_request_body(ticket)
|
|
76
|
+
|
|
77
|
+
http.post(uri.path, body.to_json, headers)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def make_request_body(ticket)
|
|
81
|
+
{
|
|
82
|
+
title: ticket.title,
|
|
83
|
+
body: ticket.description,
|
|
84
|
+
labels: (global_labels&.split(',')&.map(&:strip) + ticket.labels).flatten.uniq
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get_uri
|
|
89
|
+
URI.parse("https://api.github.com/repos/#{ENV['GITHUB_USER_NAME']}/#{ENV['GITHUB_REPO_NAME']}/issues")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def get_markdown
|
|
93
|
+
File.new(@source_md_file_path).readlines
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: copyist
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ymstshinichiro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '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'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dotenv
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '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'
|
|
41
|
+
description: ''
|
|
42
|
+
email:
|
|
43
|
+
- yamashitashinichirou@gmail.com
|
|
44
|
+
executables:
|
|
45
|
+
- copyist
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".env.sample"
|
|
50
|
+
- ".env.test"
|
|
51
|
+
- ".gitignore"
|
|
52
|
+
- ".rubocop.yml"
|
|
53
|
+
- CHANGELOG.md
|
|
54
|
+
- CODE_OF_CONDUCT.md
|
|
55
|
+
- Gemfile
|
|
56
|
+
- Gemfile.lock
|
|
57
|
+
- LICENSE.txt
|
|
58
|
+
- README.md
|
|
59
|
+
- Rakefile
|
|
60
|
+
- bin/console
|
|
61
|
+
- bin/setup
|
|
62
|
+
- copyist.gemspec
|
|
63
|
+
- exe/copyist
|
|
64
|
+
- lib/copyist.rb
|
|
65
|
+
- lib/copyist/application.rb
|
|
66
|
+
- lib/copyist/job.rb
|
|
67
|
+
- lib/copyist/version.rb
|
|
68
|
+
homepage: https://github.com/ymstshinichiro/copyist
|
|
69
|
+
licenses:
|
|
70
|
+
- MIT
|
|
71
|
+
metadata:
|
|
72
|
+
homepage_uri: https://github.com/ymstshinichiro/copyist
|
|
73
|
+
source_code_uri: https://github.com/ymstshinichiro/copyist
|
|
74
|
+
changelog_uri: https://github.com/ymstshinichiro/copyist/blob/master/CHANGELOG.md
|
|
75
|
+
post_install_message:
|
|
76
|
+
rdoc_options: []
|
|
77
|
+
require_paths:
|
|
78
|
+
- lib
|
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: 2.4.0
|
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
requirements: []
|
|
90
|
+
rubygems_version: 3.0.3
|
|
91
|
+
signing_key:
|
|
92
|
+
specification_version: 4
|
|
93
|
+
summary: parse markdown to create github issues
|
|
94
|
+
test_files: []
|