t1k 1.2.0 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +113 -0
- data/Rakefile +1 -29
- data/T1000 +24 -0
- data/bin/t1k +8 -0
- data/lib/t1k/command.rb +50 -0
- data/lib/t1k/commands/commit.rb +37 -0
- data/lib/t1k/commands/hack.rb +26 -0
- data/lib/t1k/commands/init.rb +22 -0
- data/lib/t1k/commands/ship.rb +23 -0
- data/lib/t1k/commands/sink.rb +20 -0
- data/lib/t1k/repositories/bitbucket.rb +15 -15
- data/lib/t1k/repositories/github.rb +54 -54
- data/lib/t1k/repository.rb +18 -13
- data/lib/t1k/tracker.rb +18 -13
- data/lib/t1k/trackers/pivotal.rb +15 -15
- data/lib/t1k/trackers/trello.rb +51 -49
- data/lib/t1k/version.rb +1 -1
- data/lib/t1k.rb +44 -30
- data/resources/T1000 +24 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/t1k_spec.rb +11 -0
- data/t1k.gemspec +27 -0
- metadata +61 -107
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -3
- data/lib/t1k/engine.rb +0 -5
- data/lib/t1k/trackers/nothing.rb +0 -18
- data/lib/tasks/commit.rake +0 -12
- data/lib/tasks/hack.rake +0 -20
- data/lib/tasks/ship.rake +0 -15
- data/lib/tasks/sink.rake +0 -14
- data/lib/tasks/t1k_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config/application.rb +0 -26
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/config.ru +0 -4
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/test_helper.rb +0 -19
- data/test/tk1_test.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b96b74479f3ee077f668e24ea6349f2c6e4cedeb
|
4
|
+
data.tar.gz: b046a9d6730e25a55b015e752ce8ba8b1acbd8b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2561a612aea91a0960a4927982379eeb791949a97f27d533adf7fb86c47bffde9a5e1eebadae89683c24788b23bb7aaaf2521710c62a93111e0733864d447039
|
7
|
+
data.tar.gz: 6fdc77bca049bb2afb01bd6ef68b24e370b35389e3e73872bd587bb59cdc6d3e73b1187db7cafbc8feba69f0acba5af7b89a4b70d15d47ffd8521f5276719fa2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Fernando Martínez
|
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,113 @@
|
|
1
|
+
# T1K [![Code Climate](https://codeclimate.com/github/fortesinformatica/t1k/badges/gpa.svg)](https://codeclimate.com/github/fortesinformatica/t1k)
|
2
|
+
|
3
|
+
T1K - Automated Git and Trello Workflow
|
4
|
+
|
5
|
+
Use those scripts to automatically create branchs associated with issues and tracked commits with cards on Trello.
|
6
|
+
|
7
|
+
T1k allow you from command line to use some tasks to make easy to create brach, commit, create an issue and track it down in a Trello's card.
|
8
|
+
|
9
|
+
- [T1K](#t1k)
|
10
|
+
- [Getting started](#getting-started)
|
11
|
+
- [T1000 Configuration File](#t1000-configuration-file)
|
12
|
+
- [Commands](#commands)
|
13
|
+
- [Init](#init)
|
14
|
+
- [Commit](#commit)
|
15
|
+
- [Sink](#sink)
|
16
|
+
- [Ship](#ship)
|
17
|
+
- [License](#license)
|
18
|
+
|
19
|
+
## Getting started
|
20
|
+
|
21
|
+
Install in your system T1k's gem
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
$ gem install t1k
|
25
|
+
```
|
26
|
+
|
27
|
+
Start using t1k into your project directory
|
28
|
+
|
29
|
+
```shell
|
30
|
+
$ t1k init
|
31
|
+
```
|
32
|
+
|
33
|
+
It creates the T1000 configuration file inside your project folder.
|
34
|
+
|
35
|
+
### T1000 Configuration File
|
36
|
+
Here is a possible configuration for `github` and `trello`.
|
37
|
+
Your `T1000` should look like this:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
T1k.setup do |config|
|
41
|
+
# Change the repository adapter. Default is github.
|
42
|
+
# config.repository.adapter = :github
|
43
|
+
|
44
|
+
# Change the tracker adapter. Default is trello.
|
45
|
+
# config.tracker.adapter = :trello
|
46
|
+
|
47
|
+
# Configuring your repository
|
48
|
+
config.repository.setup do |c|
|
49
|
+
# https://github.com/settings/applications
|
50
|
+
# Personal access tokens
|
51
|
+
c.oauth_token = 'PERSONAL_ACCESS_TOKEN'
|
52
|
+
c.user = 'YOUR_REPOSITORY_USERNAME'
|
53
|
+
c.repo = 'YOUR_REPOSITORY_NAME'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Configuring your tracker
|
57
|
+
config.tracker.setup do |c|
|
58
|
+
# https://trello.com/app-key
|
59
|
+
# https://trello.com/1/connect?key=YOUR_KEY&name=BOARD_NAME&expiration=never&response_type=token&scope=read,write
|
60
|
+
c.developer_public_key = 'PUBLIC_KEY'
|
61
|
+
c.member_token = 'APP_MEMBER_TOKEN'
|
62
|
+
c.user_name = 'YOUR_TRELLO_USER'
|
63
|
+
c.board_name = 'BOARD_NAME'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
When using `:github` as your repository, you must define `:oauth_token`, `:user`, `:repo`.
|
69
|
+
|
70
|
+
When using `:trello` as your tracker, you must define `:developer_public_key`, `:member_token`, `:user_name` and `:board_name`.
|
71
|
+
|
72
|
+
## Commands
|
73
|
+
|
74
|
+
Basic workflow:
|
75
|
+
|
76
|
+
```shell
|
77
|
+
$ t1k commit -m 'commit message'
|
78
|
+
$ t1k commit -m 'finish issue and close it' -c
|
79
|
+
$ t1k sink
|
80
|
+
$ t1k ship
|
81
|
+
```
|
82
|
+
|
83
|
+
### Init
|
84
|
+
|
85
|
+
Just adds to your project folder a T1000 config file template
|
86
|
+
|
87
|
+
### Commit
|
88
|
+
|
89
|
+
Commit has to params options, -m and -c.
|
90
|
+
|
91
|
+
1. `t1k commit` : just commits your staged changes (no message is added) *not recommended*
|
92
|
+
2. `t1k commit -m 'message'` : commits your staged changes with a custom message
|
93
|
+
2. `t1k commit -c -m 'message'` : -c is used to close your issue.
|
94
|
+
|
95
|
+
### Sink
|
96
|
+
|
97
|
+
Just _sync_ with master your current branch
|
98
|
+
|
99
|
+
### Ship
|
100
|
+
|
101
|
+
It deliveries to master (local and remote) your branch and changes current branch to master
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
MIT License (MIT)
|
106
|
+
|
107
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
108
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
109
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
110
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
111
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
112
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
113
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,29 +1 @@
|
|
1
|
-
|
2
|
-
require 'bundler/setup'
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'T1k'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
Bundler::GemHelper.install_tasks
|
18
|
-
|
19
|
-
require 'rake/testtask'
|
20
|
-
|
21
|
-
Rake::TestTask.new(:test) do |t|
|
22
|
-
t.libs << 'lib'
|
23
|
-
t.libs << 'test'
|
24
|
-
t.pattern = 'test/**/*_test.rb'
|
25
|
-
t.verbose = false
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
task default: :test
|
1
|
+
require "bundler/gem_tasks"
|
data/T1000
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
T1k.setup do |config|
|
2
|
+
|
3
|
+
# Setup Github repository credentials
|
4
|
+
#
|
5
|
+
# config.repository.adapter = :github
|
6
|
+
# config.repository.setup do |c|
|
7
|
+
# c.user = "GITHUB_USER"
|
8
|
+
# c.oauth_token = "GITHUB_AUTH_TOKEN"
|
9
|
+
# c.repo = "REPOSITORY_NAME"
|
10
|
+
# end
|
11
|
+
|
12
|
+
# Setup Trello board credentials
|
13
|
+
#
|
14
|
+
# T1k.setup do |config|
|
15
|
+
# config.tracker.adapter = :trello
|
16
|
+
# config.tracker.setup do |c|
|
17
|
+
# c.user_name = "TRELLO_USER"
|
18
|
+
# c.member_token = "TRELLO_MEMBER_TOKEN"
|
19
|
+
# c.board_name = "TRELLO_BOARD_NAME"
|
20
|
+
# c.developer_public_key = "TRELLO_DEVELOPER_PUB_KEY"
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
|
24
|
+
end
|
data/bin/t1k
ADDED
data/lib/t1k/command.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 't1k/commands/init'
|
2
|
+
require 't1k/commands/hack'
|
3
|
+
require 't1k/commands/commit'
|
4
|
+
require 't1k/commands/sink'
|
5
|
+
require 't1k/commands/ship'
|
6
|
+
|
7
|
+
module T1k
|
8
|
+
INIT = "init"
|
9
|
+
HACK = "hack"
|
10
|
+
COMMIT = "commit"
|
11
|
+
SINK = "sink"
|
12
|
+
SHIP = "ship"
|
13
|
+
|
14
|
+
class Command
|
15
|
+
|
16
|
+
def initialize(argv)
|
17
|
+
@args = argv
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
T1k.setup_credentials
|
22
|
+
|
23
|
+
@args.count == 0 ? help : parse_args(@args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def help
|
27
|
+
puts "T1K (T-100) Gem. It's a help and let's learn"
|
28
|
+
puts ""
|
29
|
+
puts "t1k [command] <params>"
|
30
|
+
puts ""
|
31
|
+
puts T1k::Commands::Init.help
|
32
|
+
puts T1k::Commands::Hack.help
|
33
|
+
puts T1k::Commands::Commit.help
|
34
|
+
puts T1k::Commands::Sink.help
|
35
|
+
puts T1k::Commands::Ship.help
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def parse_args(args)
|
41
|
+
command = args[0]
|
42
|
+
|
43
|
+
T1k::Commands::Init.run if command == INIT && args.count == 1
|
44
|
+
T1k::Commands::Hack.run(args[1]) if command == HACK && args.count == 2
|
45
|
+
T1k::Commands::Commit.run(args[1..args.count]) if command == COMMIT
|
46
|
+
T1k::Commands::Sink.run if command == SINK && args.count == 1
|
47
|
+
T1k::Commands::Ship.run if command == SHIP && args.count == 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module T1k
|
2
|
+
module Commands
|
3
|
+
class Commit
|
4
|
+
|
5
|
+
def self.run(args)
|
6
|
+
message, close = parse_args(args)
|
7
|
+
|
8
|
+
branch = `git branch | grep '*' | awk '{print $2}'`
|
9
|
+
system "git commit -m '[#{close} ##{branch.strip}] #{message}'"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.help
|
13
|
+
<<-DESC
|
14
|
+
commit - commit your staged changes.
|
15
|
+
|
16
|
+
-m <message> - send a commit with a custom message
|
17
|
+
-c - send a commit with close sentence. eg. [closes #320]
|
18
|
+
DESC
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.parse_args(args)
|
24
|
+
message = ""
|
25
|
+
close = ""
|
26
|
+
|
27
|
+
args.each_with_index do |arg, i|
|
28
|
+
|
29
|
+
message = args[i + 1] || message if arg == '-m'
|
30
|
+
close = "close" if arg == '-c'
|
31
|
+
end
|
32
|
+
|
33
|
+
return message, close
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module T1k
|
2
|
+
module Commands
|
3
|
+
class Hack
|
4
|
+
|
5
|
+
def self.run(path_card_part)
|
6
|
+
code_card = T1k::hack path_card_part
|
7
|
+
|
8
|
+
system 'git checkout master'
|
9
|
+
system 'git pull --rebase origin master'
|
10
|
+
existent_branch = `git branch --list #{code_card}`
|
11
|
+
|
12
|
+
if existent_branch.present?
|
13
|
+
system "git checkout #{code_card}"
|
14
|
+
else
|
15
|
+
system "git checkout -b #{code_card}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.help
|
20
|
+
<<-DESC
|
21
|
+
hack <card_identifier> - creates a branch associated with a card and checkout to it.
|
22
|
+
DESC
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module T1k
|
4
|
+
module Commands
|
5
|
+
class Init
|
6
|
+
|
7
|
+
def self.run
|
8
|
+
src = File.join(T1k::path_to_resources, "T1000")
|
9
|
+
dest = T1k::tthousand_path
|
10
|
+
|
11
|
+
FileUtils.cp src, dest
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
<<-DESC
|
16
|
+
init - Creates T1000 file into your project folder.
|
17
|
+
Setup your keys and other configurations in this file.
|
18
|
+
DESC
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module T1k
|
4
|
+
module Commands
|
5
|
+
class Ship
|
6
|
+
|
7
|
+
def self.run
|
8
|
+
branch = `git branch | grep '*' | awk '{print $2}'`
|
9
|
+
system "git checkout master"
|
10
|
+
system "git pull --rebase"
|
11
|
+
system "git merge #{branch.strip}"
|
12
|
+
system "git commit -v"
|
13
|
+
system "git push origin master"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.help
|
17
|
+
<<-DESC
|
18
|
+
ship - delivery your changes to local and remote master branch.
|
19
|
+
DESC
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module T1k
|
2
|
+
module Commands
|
3
|
+
class Sink
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
branch = `git branch | grep '*' | awk '{print $2}'`
|
7
|
+
system "git checkout master"
|
8
|
+
system "git pull --rebase origin master"
|
9
|
+
system "git checkout #{branch.strip}"
|
10
|
+
system "git rebase master #{branch.strip}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.help
|
14
|
+
<<-DESC
|
15
|
+
sink - update current branch with master (ie Sync with master).
|
16
|
+
DESC
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# bitbucket requirements
|
2
2
|
|
3
3
|
module T1k
|
4
|
-
|
5
|
-
|
4
|
+
module Repositories
|
5
|
+
class Bitbucket
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# bitbucket configurations
|
8
|
+
# cattr_accessor :config_name
|
9
|
+
# @@config_name = "default value"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# implement setup method
|
12
|
+
# def self.setup &block
|
13
|
+
# yield(self) if block_given?
|
14
|
+
# end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
# implement create_issue method
|
17
|
+
# def self.create_issue(title); end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# implement create_issue method
|
20
|
+
# def self.get_issue(html_url); end
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
@@ -1,57 +1,57 @@
|
|
1
|
-
require
|
1
|
+
require 'github_api'
|
2
2
|
|
3
3
|
module T1k
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
4
|
+
module Repositories
|
5
|
+
class Github
|
6
|
+
|
7
|
+
cattr_accessor :oauth_token
|
8
|
+
@@oauth_token = ""
|
9
|
+
|
10
|
+
cattr_accessor :user
|
11
|
+
@@user = ""
|
12
|
+
|
13
|
+
cattr_accessor :repo
|
14
|
+
@@repo = ""
|
15
|
+
|
16
|
+
Issue = Struct.new(:code, :link)
|
17
|
+
|
18
|
+
def self.setup &block
|
19
|
+
yield(self) if block_given?
|
20
|
+
self.config_keys
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.config_keys
|
24
|
+
# ::Github.configure do |config|
|
25
|
+
# your keys
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.create_issue title
|
30
|
+
begin
|
31
|
+
puts 'Creating issue'
|
32
|
+
github_auth = ::Github.new(oauth_token: self.oauth_token)
|
33
|
+
issue = github_auth.issues.create(user: self.user, repo: self.repo, title: title)
|
34
|
+
issue
|
35
|
+
rescue
|
36
|
+
raise 'Issue not created'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.get_issue issue_number
|
41
|
+
begin
|
42
|
+
puts 'Recovering existent issue'
|
43
|
+
github_auth = ::Github.new(oauth_token: self.oauth_token)
|
44
|
+
issue = github_auth.issues.get user: self.user, repo: self.repo, number: issue_number
|
45
|
+
issue
|
46
|
+
rescue
|
47
|
+
raise 'Issue not recovered'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.get_issue_number html_url
|
52
|
+
code = html_url[html_url.rindex('/')+1..html_url.size]
|
53
|
+
Issue.new(code, "Link to code: [#{code}](#{html_url})")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
57
|
end
|
data/lib/t1k/repository.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module T1k
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
class Repository
|
3
|
+
|
4
|
+
cattr_accessor :adapter
|
5
|
+
@@adapter = T1k::Repositories::Github
|
6
|
+
|
7
|
+
class << self
|
8
|
+
delegate :create_issue, :get_issue, :get_issue_number, to: @@adapter
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setup &block
|
12
|
+
self.adapter.setup(&block) if block_given?
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.adapter=(adapter_name)
|
16
|
+
raise "Invalid adapter name. Adapter name must be a Symbol." unless adapter_name.class.eql?(Symbol)
|
17
|
+
@@adapter = "T1k::Repositories::#{adapter_name.to_s.classify}".constantize
|
18
|
+
end
|
19
|
+
end
|
15
20
|
end
|
data/lib/t1k/tracker.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module T1k
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
class Tracker
|
3
|
+
|
4
|
+
cattr_accessor :adapter
|
5
|
+
@@adapter = T1k::Trackers::Trello # default adapter
|
6
|
+
|
7
|
+
class << self
|
8
|
+
delegate :get_card, :update_card, to: @@adapter
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setup &block
|
12
|
+
self.adapter.setup(&block) if block_given?
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.adapter=(adapter_name)
|
16
|
+
raise "Invalid adapter name. Adapter name must be a Symbol." unless adapter_name.class.eql?(Symbol)
|
17
|
+
@@adapter = "T1k::Trackers::#{adapter_name.to_s.classify}".constantize
|
18
|
+
end
|
19
|
+
end
|
15
20
|
end
|