t1k 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b2e07a23e43b7e1fcc356ee9072a5375a8034a1
4
- data.tar.gz: f6748165b70ae6e4f12356f0dedaf05e0f104b51
3
+ metadata.gz: bd67c338f8dc31847df15f7ab46c66ad2e1fa31c
4
+ data.tar.gz: 0d2a37c1d291b4e564a461cbf1b85f6403f91e7c
5
5
  SHA512:
6
- metadata.gz: b9900284a431c46e1fac3aeebda92f969632915dc1c467b6e79bb792696e69299118c313f32669809fe31f1b28ee2869446e9b5319db26550515fdcc60d4751a
7
- data.tar.gz: ed2bca3ab43b6d5824da46615fdd037f283889ed23a3cd6e6b745b4684f63635fb6d90cdc22e279ba5c87fb5dbb1c308e5dfce5d7414743ed0c82033573486ef
6
+ metadata.gz: acdf9104007415928cf95da616db85fb5efae9b76d7b0aecf03478a8cd7ed01ba2119a2b8229a6e787f7b23b8b0a2bbfadf02dab36cd99da74f60bf4a2e4c6f5
7
+ data.tar.gz: 4249fcafd949bc90d268615d060cc0a6b312ccd704ffb55bf5ad15db71c92d35cda2ae9e83c777465d13c3b78e1310b4043d506e57bdbab7eb6207575d8a7a9f
data/CODE_OF_CONDUCT.md CHANGED
@@ -6,7 +6,7 @@ We are committed to making participation in this project a harassment-free exper
6
6
 
7
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
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.
9
+ The T1k Core Team 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
10
 
11
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
12
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- t1k (2.1.0)
4
+ t1k (3.0.0)
5
5
  activesupport (~> 4.2)
6
+ bitbucket_rest_api
6
7
  clive (~> 1.2.1)
7
8
  github_api (~> 0.12)
8
9
  ruby-trello (~> 1.2.1)
@@ -19,13 +20,22 @@ GEM
19
20
  minitest (~> 5.1)
20
21
  thread_safe (~> 0.3, >= 0.3.4)
21
22
  tzinfo (~> 1.1)
22
- addressable (2.3.8)
23
+ addressable (2.4.0)
24
+ bitbucket_rest_api (0.1.7)
25
+ faraday (~> 0.9.0)
26
+ faraday_middleware (~> 0.9.0)
27
+ hashie
28
+ multi_json (>= 1.7.5, < 2.0)
29
+ nokogiri (>= 1.5.2)
30
+ simple_oauth
23
31
  builder (3.2.2)
24
32
  clive (1.2.1)
25
33
  descendants_tracker (0.0.4)
26
34
  thread_safe (~> 0.3, >= 0.3.1)
27
35
  faraday (0.9.1)
28
36
  multipart-post (>= 1.2, < 3)
37
+ faraday_middleware (0.9.2)
38
+ faraday (>= 0.7.4, < 0.10)
29
39
  github_api (0.12.3)
30
40
  addressable (~> 2.3)
31
41
  descendants_tracker (~> 0.0.4)
@@ -39,14 +49,14 @@ GEM
39
49
  json (1.8.3)
40
50
  jwt (1.5.0)
41
51
  mime-types (2.6.1)
42
- mini_portile (0.6.2)
52
+ mini_portile2 (2.0.0)
43
53
  minitest (5.7.0)
44
- multi_json (1.11.1)
54
+ multi_json (1.12.1)
45
55
  multi_xml (0.5.5)
46
56
  multipart-post (2.0.0)
47
- netrc (0.10.3)
48
- nokogiri (1.6.6.2)
49
- mini_portile (~> 0.6.0)
57
+ netrc (0.11.0)
58
+ nokogiri (1.6.7.2)
59
+ mini_portile2 (~> 2.0.0.rc2)
50
60
  oauth (0.4.7)
51
61
  oauth2 (1.0.0)
52
62
  faraday (>= 0.8, < 0.10)
@@ -55,7 +65,7 @@ GEM
55
65
  multi_xml (~> 0.5)
56
66
  rack (~> 1.2)
57
67
  rack (1.6.1)
58
- rake (10.4.2)
68
+ rake (10.5.0)
59
69
  rest-client (1.7.3)
60
70
  mime-types (>= 1.16, < 3.0)
61
71
  netrc (~> 0.7)
@@ -65,6 +75,7 @@ GEM
65
75
  json
66
76
  oauth (~> 0.4.5)
67
77
  rest-client (~> 1.7.2)
78
+ simple_oauth (0.3.1)
68
79
  thread_safe (0.3.5)
69
80
  tzinfo (1.2.2)
70
81
  thread_safe (~> 0.1)
data/README.md CHANGED
@@ -41,43 +41,42 @@ Your `T1000` should look like this:
41
41
 
42
42
  ```ruby
43
43
  T1k.setup do |config|
44
- # Change the repository adapter. Default is github.
45
- # config.repository.adapter = :github
46
-
47
- # Change the tracker adapter. Default is trello.
48
- # config.tracker.adapter = :trello
49
44
  # Setup Github repository credentials
50
-
51
45
  # Create an auth_token here: https://github.com/settings/applications
52
-
53
- config.repository.adapter = :github
54
- config.repository.setup do |c|
55
- c.user = "GITHUB_USER"
56
- c.repo = "REPOSITORY_NAME"
57
- c.oauth_token = "YOUR_GITHUB_AUTH_TOKEN"
58
- end
46
+ #
47
+ # config.repository.adapter = :github
48
+ # config.repository.setup do |c|
49
+ # c.user = "GITHUB_USER"
50
+ # c.repo = "REPOSITORY_NAME"
51
+ # c.oauth_token = "YOUR_GITHUB_AUTH_TOKEN"
52
+ # end
53
+
54
+ # If you'll use bitbucket as repository you should set a shell variable with
55
+ # your password as BITBUCKET_PWD in order to access bitbucket api
56
+ # config.repository.adapter = :bitbucket
57
+ # config.repository.setup do |c|
58
+ # c.user = "YOUR_BITBUCKET_USERNAME"
59
+ # c.repo = "REPOSITORY_NAME"
60
+ # c.password = "#{ENV['BITBUCKET_PWD']}"
61
+ # end
59
62
 
60
63
  # Setup Trello board credentials
61
64
  #
62
65
  # Trello APP_DEVELOPER_KEY: https://trello.com/app-key
63
66
  # Trello App permission key: https://trello.com/1/connect?key=YOUR_KEY&name=BOARD_NAME&expiration=never&response_type=token&scope=read,write
64
67
  #
65
- config.tracker.adapter = [:trello, :pivotal, :none]
66
- config.tracker.setup do |c|
67
- c.user_name = "TRELLO_USER"
68
- c.board_name = "TRELLO_BOARD_NAME"
69
- c.member_token = "TRELLO_APP_TOKEN"
70
- c.developer_public_key = "TRELLO_DEVELOPER_PUB_KEY"
71
- end
68
+ # config.tracker.adapter = [:trello, :pivotal, :none]
69
+ # config.tracker.setup do |c|
70
+ # c.user_name = "TRELLO_USER"
71
+ # c.board_name = "TRELLO_BOARD_NAME"
72
+ # c.member_token = "TRELLO_APP_TOKEN"
73
+ # c.developer_public_key = "TRELLO_DEVELOPER_PUB_KEY"
74
+ # end
72
75
  end
73
76
  ```
74
77
 
75
- Get your [Trello APP_DEVELOPER_KEY](https://trello.com/app-key)
76
-
77
- Get your `member_token` - https://trello.com/1/connect?key=YOUR_KEY&name=BOARD_NAME&expiration=never&response_type=token&scope=read,write
78
-
79
78
  * When using `:github` as your repository, you must define `:oauth_token`, `:user`, `:repo`.
80
- * When using `:trello` as your tracker, you must define `:developer_public_key`, `:member_token`, `:user_name` and `:board_name`.
79
+ * When using `:trello` as your tracker, you must define `:developer_public_key`, `:member_token`, `:user_name` and `:board_name`. Get your `:developer_public_key` [here](https://trello.com/app-key) and the `:member_token` you must replace your developer key in the url `https://trello.com/1/authorize?key=YOURAPIKEY&response_type=token&expiration=never&scope=read,write`.
81
80
  * When using `:none` as your tracker, T1k will create issues with the name passed as argument on `t1k hack <issue-name>`
82
81
 
83
82
  ## Commands
@@ -152,6 +151,9 @@ Just _sync_ with master your current branch
152
151
 
153
152
  It deliveries to master (local and remote) your branch and changes current branch to master
154
153
 
154
+ ## Contributing
155
+ `#TODO`
156
+
155
157
  ## License
156
158
 
157
159
  MIT License (MIT)
data/T1000 CHANGED
@@ -3,11 +3,20 @@ T1k.setup do |config|
3
3
  # Setup Github repository credentials
4
4
  # Create an auth_token here: https://github.com/settings/applications
5
5
  #
6
- config.repository.adapter = :github
6
+ # config.repository.adapter = :github
7
+ # config.repository.setup do |c|
8
+ # c.user = "GITHUB_USER"
9
+ # c.repo = "REPOSITORY_NAME"
10
+ # c.oauth_token = "YOUR_GITHUB_AUTH_TOKEN"
11
+ # end
12
+
13
+ # If you'll use bitbucket as repository you should set a shell variable with
14
+ # your password as BITBUCKET_PWD in order to access bitbucket api
15
+ config.repository.adapter = :bitbucket
7
16
  config.repository.setup do |c|
8
- c.user = "rodrigomaia"
9
- c.repo = "matanza2"
10
- c.oauth_token = "422c8f00d80a7f3e679a0cf5542e22896bec8ba6"
17
+ c.user = "rodrigomaia"
18
+ c.repo = "teste_t1k"
19
+ c.password = "a1s2d3f4g5"
11
20
  end
12
21
 
13
22
  # Setup Trello board credentials
@@ -18,8 +27,8 @@ T1k.setup do |config|
18
27
  config.tracker.adapter = :trello
19
28
  config.tracker.setup do |c|
20
29
  c.user_name = "rudrige"
21
- c.board_name = "Maromba"
22
- c.member_token = "58a7067ef29083d327ecb5d7c5d71b9eca1a0b40a9c5c7f9291cf04dbf41e10f"
30
+ c.board_name = "maromba"
31
+ c.member_token = "9f89c7a381a603b291015180dda8a9ef6e5e91211e17d29415058a70d4b670b8"
23
32
  c.developer_public_key = "1a74ff76544bb0e5d9123e609478fb9a"
24
33
  end
25
34
  end
data/lib/t1k/command.rb CHANGED
@@ -23,13 +23,8 @@ module T1k
23
23
 
24
24
  desc 'Checkout to a new branch or existing branch associated with tracked card (issue)'
25
25
  command :hack, :hck, arg: '<card_url>' do
26
-
27
- opt :board, :b, 'Define the specified board to search the card', arg: '<board_name>' do
28
- @board = board_name
29
- end
30
-
31
26
  action do
32
- Commands::Hack.run card_url, @board
27
+ Commands::Hack.run card_url
33
28
  end
34
29
  end
35
30
 
@@ -4,12 +4,23 @@ module T1k
4
4
 
5
5
  def self.run(message, close, add, no_message)
6
6
  message ||= ""
7
+ skip_ci = ''
8
+ text_close = ''
7
9
 
8
10
  raise "Message can't be blank. Use --no-message to ignore this rule." if message.empty? && !no_message
9
11
  branch = `git branch | grep '*' | awk '{print $2}'`
12
+
10
13
  text_close = close ? 'close ' : ''
14
+
15
+ if close
16
+ text_close = 'close '
17
+ else
18
+ skip_ci = '[ci skip]'
19
+ end
20
+
11
21
  text_add = add ? 'a' : ''
12
- system "git commit -#{text_add}m '[#{text_close}##{branch.strip}] #{message.present?? message : ''}'"
22
+
23
+ system "git commit -#{text_add}m '[#{text_close}##{branch.strip}] #{message} #{skip_ci}' "
13
24
  end
14
25
  end
15
26
  end
@@ -2,9 +2,9 @@ module T1k
2
2
  module Commands
3
3
  class Hack
4
4
 
5
- def self.run(path_card_part, board=nil)
5
+ def self.run(path_card_part)
6
6
  T1k.setup_credentials
7
- code_card = T1k::hack path_card_part, board
7
+ code_card = T1k::hack path_card_part
8
8
 
9
9
  system 'git checkout master'
10
10
  system 'git pull --rebase origin master'
@@ -18,4 +18,4 @@ module T1k
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -6,17 +6,22 @@ module T1k
6
6
 
7
7
  def self.run
8
8
  if Validate.credentials?
9
- puts "There is T1000 file inside your directory. Remove it before do init".red
9
+ puts "There is T1000 file inside your directory. Remove it before do init.".red
10
10
  exit 1
11
11
  end
12
12
 
13
- src = File.join(T1k::path_to_resources, "T1000")
14
- dest = T1k::tthousand_path
15
-
16
- FileUtils.cp src, dest
13
+ self.create_T1000_file
17
14
 
18
15
  puts "Setup your T1000 file".blue
19
16
  end
17
+
18
+
19
+ def self.create_T1000_file
20
+ src = File.join(T1k::path_to_resources, "T1000")
21
+ dest = T1k::tthousand_path
22
+
23
+ FileUtils.cp(src, dest)
24
+ end
20
25
  end
21
26
  end
22
- end
27
+ end
@@ -14,10 +14,10 @@ module T1k
14
14
 
15
15
  c = Validate.credentials?
16
16
  t = Validate.trello?
17
- g = Validate.github?
17
+ g = Validate.valid_keys_on_repository?
18
18
 
19
- @@messages = @@messages + Trackers::Trello.messages + Repositories::Github.messages
20
- @@errors = @@errors + Trackers::Trello.errors + Repositories::Github.errors
19
+ @@messages = @@messages + Trackers::Trello.messages + self.default_repository.messages
20
+ @@errors = @@errors + Trackers::Trello.errors + self.default_repository.errors
21
21
 
22
22
  @@messages.each do |m| puts m.green end
23
23
 
@@ -26,6 +26,9 @@ module T1k
26
26
  end
27
27
 
28
28
  def self.credentials?
29
+ if self.password_from_bitbucket_is_avaliable?
30
+ @@messages << "Password is not avaliable"
31
+ end
29
32
  exist = File.exist?(T1k::tthousand_path)
30
33
  exist ? @@messages << "T1000 file was found" : @@errors << "T1000 file not found"
31
34
  exist
@@ -35,9 +38,17 @@ module T1k
35
38
  Trackers::Trello.valid_keys?
36
39
  end
37
40
 
38
- def self.github?
39
- Repositories::Github.valid_keys?
41
+ def self.valid_keys_on_repository?
42
+ self.default_repository.valid_keys?
43
+ end
44
+
45
+ def self.default_repository
46
+ Repository.default_repository
47
+ end
48
+
49
+ def self.password_from_bitbucket_is_avaliable?
50
+ self.default_repository == T1k::Repositories::Bitbucket and "#{ENV['BITBUCKET_PWD']}".nil?
40
51
  end
41
52
  end
42
53
  end
43
- end
54
+ end
@@ -1,23 +1,110 @@
1
- # bitbucket requirements
1
+ require 'bitbucket_rest_api'
2
2
 
3
3
  module T1k
4
4
  module Repositories
5
5
  class Bitbucket
6
6
 
7
- # bitbucket configurations
8
- # cattr_accessor :config_name
9
- # @@config_name = "default value"
7
+ cattr_accessor :user
8
+ @@user = ""
10
9
 
11
- # implement setup method
12
- # def self.setup &block
13
- # yield(self) if block_given?
14
- # end
10
+ cattr_accessor :repo
11
+ @@repo = ""
15
12
 
16
- # implement create_issue method
17
- # def self.create_issue(title); end
13
+ cattr_accessor :repo_owner
14
+ @@repo_owner = ""
18
15
 
19
- # implement create_issue method
20
- # def self.get_issue(html_url); end
16
+ cattr_accessor :password
17
+ @@password = ""
18
+
19
+ cattr_accessor :messages
20
+ @@messages = []
21
+
22
+ cattr_accessor :errors
23
+ @@errors = []
24
+
25
+ Issue = Struct.new(:code, :link)
26
+
27
+ def self.create_issue title
28
+ puts 'Creating issue'
29
+ me = self.login
30
+ self.repo_owner = Bitbucket.get_repo_owner_for me
31
+
32
+ issue = me.issues.create(self.repo_owner, self.repo, { title: title })
33
+ issue_number = self.send(:issue_url_from, issue)
34
+
35
+ issue_number
36
+ end
37
+
38
+ def self.login
39
+ BitBucket.new basic_auth: "#{self.user}:#{self.password}"
40
+ end
41
+
42
+ def self.get_issue number
43
+ if number.nil?
44
+ puts "You should pass a issue number"
45
+ exit 1
46
+ end
47
+
48
+ puts 'Recovering existent issue'
49
+ me = self.login
50
+ self.repo_owner = Bitbucket.get_repo_owner_for me
51
+
52
+ issue = me.issues.find(self.repo_owner, self.repo, number )
53
+ issue_number = self.send(:issue_url_from, issue)
54
+
55
+ issue_number
56
+ end
57
+
58
+ def self.get_issue_number html_url
59
+ exit 1 if html_url.nil?
60
+
61
+ code = html_url[html_url.rindex('/')+1..html_url.size]
62
+
63
+ Issue.new(code, "Link to code: [#{code}](#{html_url})")
64
+ end
65
+
66
+ def self.issue_url_from issue
67
+ issue_number = issue["resource_uri"].match(/issues\/\d+$/)[0] if issue["resource_uri"]
68
+ issue_url = "https://bitbucket.org/#{self.repo_owner}/#{self.repo}/#{issue_number}"
69
+
70
+ issue_url
71
+ end
72
+
73
+ def self.get_repo_owner_for me
74
+ unless me.kind_of? BitBucket::Client
75
+ puts "You should pass a valid user."
76
+ exit 1
77
+ end
78
+
79
+ project = me.repos.all.select {|hash| hash.name == self.repo }
80
+
81
+ # /1.0/repositories/OWNER/REPO
82
+ # > 1. /repositories/
83
+ # > 2. OWNER
84
+
85
+ project[0]['resource_uri'].match(/(\/\w+\/)(\w+)/)[2]
86
+ end
87
+
88
+ def self.setup &block
89
+ yield(self) if block_given?
90
+ end
91
+
92
+ def self.valid_keys?
93
+ me = Bitbucket.login
94
+
95
+ begin
96
+ has_project = me.repos.all.select {|hash| hash.name == self.repo }
97
+
98
+ unless has_project.empty?
99
+ @@messages << "Wecolme #{self.user} - BitBucket"
100
+ end
101
+
102
+ return not(has_project.empty?)
103
+ rescue Exception => e
104
+ @@errors << e.message
105
+ return false
106
+ end
107
+ end
21
108
  end
22
109
  end
23
- end
110
+ end
@@ -20,27 +20,13 @@ module T1k
20
20
 
21
21
  Issue = Struct.new(:code, :link)
22
22
 
23
- def self.setup &block
24
- yield(self) if block_given?
25
- end
26
-
27
- def self.valid_keys?
28
- begin
29
- me = ::Github.new(oauth_token: self.oauth_token).users.get
30
- @@messages << "Wecolme #{me.name} - Github"
31
- return true
32
- rescue Exception => e
33
- @@errors << e.message
34
- return false
35
- end
36
- end
37
-
38
23
  def self.create_issue title
39
24
  begin
40
25
  puts 'Creating issue'
41
- github_auth = ::Github.new(oauth_token: self.oauth_token)
42
- issue = github_auth.issues.create(user: self.user, repo: self.repo, title: title)
43
- issue
26
+ github_auth = self.login
27
+ issue = github_auth.issues.create(user: self.user, repo: self.repo, title: title)
28
+
29
+ issue.html_url
44
30
  rescue
45
31
  raise 'Issue not created'
46
32
  end
@@ -49,9 +35,10 @@ module T1k
49
35
  def self.get_issue issue_number
50
36
  begin
51
37
  puts 'Recovering existent issue'
52
- github_auth = ::Github.new(oauth_token: self.oauth_token)
53
- issue = github_auth.issues.get user: self.user, repo: self.repo, number: issue_number
54
- issue
38
+ github_auth = self.login
39
+ issue = github_auth.issues.get(user: self.user, repo: self.repo, number: issue_number)
40
+
41
+ issue.html_url
55
42
  rescue
56
43
  raise 'Issue not recovered'
57
44
  end
@@ -61,6 +48,25 @@ module T1k
61
48
  code = html_url[html_url.rindex('/')+1..html_url.size]
62
49
  Issue.new(code, "Link to code: [#{code}](#{html_url})")
63
50
  end
51
+
52
+ def self.login
53
+ ::Github.new(oauth_token: self.oauth_token)
54
+ end
55
+
56
+ def self.setup &block
57
+ yield(self) if block_given?
58
+ end
59
+
60
+ def self.valid_keys?
61
+ begin
62
+ me = self.login.users.get
63
+ @@messages << "Wecolme #{me.name} - Github"
64
+ return true
65
+ rescue Exception => e
66
+ @@errors << e.message
67
+ return false
68
+ end
69
+ end
64
70
  end
65
71
  end
66
- end
72
+ end
@@ -2,11 +2,8 @@ module T1k
2
2
  class Repository
3
3
 
4
4
  cattr_accessor :adapter
5
- @@adapter = T1k::Repositories::Github
6
5
 
7
- class << self
8
- delegate :create_issue, :get_issue, :get_issue_number, to: @@adapter
9
- end
6
+ @@adapter = nil
10
7
 
11
8
  def self.setup &block
12
9
  self.adapter.setup(&block) if block_given?
@@ -16,5 +13,9 @@ module T1k
16
13
  raise "Invalid adapter name. Adapter name must be a Symbol." unless adapter_name.class.eql?(Symbol)
17
14
  @@adapter = "T1k::Repositories::#{adapter_name.to_s.classify}".constantize
18
15
  end
16
+
17
+ def self.default_repository
18
+ @@adapter
19
+ end
19
20
  end
20
- end
21
+ end
@@ -7,7 +7,7 @@ module T1k
7
7
  def self.setup &block
8
8
  end
9
9
 
10
- def self.get_card title, board=nil
10
+ def self.get_card title
11
11
  Card.new title
12
12
  end
13
13
 
@@ -15,4 +15,4 @@ module T1k
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -30,7 +30,7 @@ module T1k
30
30
  def self.config_keys
31
31
  ::Trello.configure do |config|
32
32
  config.developer_public_key = self.developer_public_key
33
- config.member_token = self.member_token
33
+ config.member_token = self.member_token
34
34
  end
35
35
  end
36
36
 
@@ -45,15 +45,15 @@ module T1k
45
45
  end
46
46
  end
47
47
 
48
- def self.get_card url_card, board=nil
49
- my_board = board || self.board_name
50
-
51
- puts "Fetching card from #{my_board}"
48
+ def self.get_card url_card
49
+ puts "Fetching card"
52
50
  begin
53
51
  me = ::Trello::Member.find(self.user_name)
54
52
  raise "User not found" if me.nil?
55
- board = me.boards.select{|x| x.name.upcase == my_board.upcase}.first
53
+
54
+ board = me.boards.select{|x| x.name.upcase == self.board_name.upcase}.first
56
55
  raise "Board not found.\nBoards available: #{me.boards.map(&:name)}" if board.nil?
56
+
57
57
  card = board.cards.select{|x| x.url.index(url_card)}.first
58
58
  raise "Card not found" if card.nil?
59
59
 
data/lib/t1k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module T1k
2
- VERSION = "2.1.0"
2
+ VERSION = "3.0.0"
3
3
  end
data/lib/t1k.rb CHANGED
@@ -10,6 +10,9 @@ require 't1k/version'
10
10
  require 't1k/constants'
11
11
  require 't1k/command'
12
12
 
13
+
14
+ require_relative '../spec/support/kernel' if ENV["DEBUG"]
15
+
13
16
  module T1k
14
17
  autoload :Repository, 't1k/repository'
15
18
  autoload :Tracker, 't1k/tracker'
@@ -20,7 +23,7 @@ module T1k
20
23
  end
21
24
 
22
25
  module Trackers
23
- autoload :None, 't1k/trackers/none'
26
+ autoload :None, 't1k/trackers/none'
24
27
  autoload :Trello, 't1k/trackers/trello'
25
28
  autoload :Pivotal, 't1k/trackers/pivotal'
26
29
  end
@@ -38,18 +41,19 @@ module T1k
38
41
  yield(self) if block_given?
39
42
  end
40
43
 
41
- def self.hack url_card, board=nil
42
- card = tracker.get_card(url_card, board)
43
-
44
- existent_issue_match = card.name.match /^\[#([0-9]*)\]/
44
+ def self.hack url_card
45
+ card = tracker.get_card(url_card)
46
+ existent_issue_match = card.name.match /^\[#([0-9]*)\]/
45
47
  existent_issue_number = existent_issue_match[1] if existent_issue_match.present?
46
48
 
47
- issue = existent_issue_number.present? ? repository.get_issue(existent_issue_number).html_url : repository.create_issue(card.name).html_url
49
+ issue_url = existent_issue_number.present? ? repository.get_issue(existent_issue_number)
50
+ : repository.create_issue(card.name)
48
51
 
49
- issue_number = repository.get_issue_number(issue)
52
+ issue_number = repository.get_issue_number(issue_url)
50
53
  tracker.update_card(card, issue_number) if existent_issue_number.nil?
51
54
 
52
55
  puts "Card ##{issue_number.code} created and tracked"
56
+
53
57
  issue_number.code
54
58
  end
55
59
 
@@ -59,5 +63,12 @@ module T1k
59
63
 
60
64
  def self.setup_credentials
61
65
  eval(File.read(@@tthousand_path)) if File.exists? @@tthousand_path
66
+
67
+ Repository.instance_eval do
68
+ @@adapter = self.default_repository
69
+ class << self
70
+ delegate :create_issue, :get_issue, :get_issue_number, to: @@adapter
71
+ end
72
+ end
62
73
  end
63
74
  end
data/resources/T1000 CHANGED
@@ -3,13 +3,22 @@ T1k.setup do |config|
3
3
  # Setup Github repository credentials
4
4
  # Create an auth_token here: https://github.com/settings/applications
5
5
  #
6
- # config.repository.adapter = [:github, :bitbucket]
6
+ # config.repository.adapter = :github
7
7
  # config.repository.setup do |c|
8
8
  # c.user = "GITHUB_USER"
9
9
  # c.repo = "REPOSITORY_NAME"
10
10
  # c.oauth_token = "YOUR_GITHUB_AUTH_TOKEN"
11
11
  # end
12
12
 
13
+ # If you'll use bitbucket as repository you should set a shell variable with
14
+ # your password as BITBUCKET_PWD in order to access bitbucket api
15
+ # config.repository.adapter = :bitbucket
16
+ # config.repository.setup do |c|
17
+ # c.user = "YOUR_BITBUCKET_USERNAME"
18
+ # c.repo = "REPOSITORY_NAME"
19
+ # c.password = "#{ENV['BITBUCKET_PWD']}"
20
+ # end
21
+
13
22
  # Setup Trello board credentials
14
23
  #
15
24
  # Trello APP_DEVELOPER_KEY: https://trello.com/app-key
@@ -22,4 +31,4 @@ T1k.setup do |config|
22
31
  # c.member_token = "TRELLO_APP_TOKEN"
23
32
  # c.developer_public_key = "TRELLO_DEVELOPER_PUB_KEY"
24
33
  # end
25
- end
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'clive'
2
+
3
+ module Kernel
4
+ def system(cmd)
5
+ puts "#{cmd} was called".green.bold
6
+ end
7
+ end
data/t1k.gemspec CHANGED
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib", "resources"]
21
21
 
22
22
  spec.add_development_dependency 'bundler', '~> 1.9'
23
- spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rake' , '~> 10.0'
24
24
 
25
- spec.add_dependency 'ruby-trello', '~> 1.2.1'
26
- spec.add_dependency 'github_api', '~> 0.12'
25
+ spec.add_dependency 'ruby-trello' , '~> 1.2.1'
26
+ spec.add_dependency 'github_api' , '~> 0.12'
27
27
  spec.add_dependency 'activesupport', '~> 4.2'
28
- spec.add_dependency 'clive', '~> 1.2.1'
28
+ spec.add_dependency 'clive' , '~> 1.2.1'
29
+ spec.add_dependency 'bitbucket_rest_api'
29
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t1k
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Maia
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-09-01 00:00:00.000000000 Z
13
+ date: 2016-08-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -96,6 +96,20 @@ dependencies:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
98
  version: 1.2.1
99
+ - !ruby/object:Gem::Dependency
100
+ name: bitbucket_rest_api
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
99
113
  description: Use those scripts to create automatically branchs associated with issues
100
114
  and tracked commits.
101
115
  email:
@@ -134,8 +148,8 @@ files:
134
148
  - ./lib/t1k/version.rb
135
149
  - ./resources/T1000
136
150
  - ./spec/spec_helper.rb
151
+ - ./spec/support/kernel.rb
137
152
  - ./spec/t1k_spec.rb
138
- - ./t1k-2.1.0.gem
139
153
  - ./t1k.gemspec
140
154
  - README.md
141
155
  - Rakefile
data/t1k-2.1.0.gem DELETED
Binary file