t1k 0.0.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -8
  3. data/lib/t1k.rb +21 -64
  4. data/lib/t1k/engine.rb +2 -2
  5. data/lib/t1k/repositories/bitbucket.rb +23 -0
  6. data/lib/t1k/repositories/github.rb +46 -0
  7. data/lib/t1k/repository.rb +20 -0
  8. data/lib/t1k/tracker.rb +20 -0
  9. data/lib/t1k/trackers/pivotal.rb +23 -0
  10. data/lib/t1k/trackers/trello.rb +54 -0
  11. data/lib/t1k/version.rb +2 -2
  12. data/lib/tasks/commit.rake +1 -1
  13. data/lib/tasks/hack.rake +1 -1
  14. data/lib/tasks/ship.rake +1 -1
  15. data/lib/tasks/sink.rake +1 -1
  16. data/test/dummy/README.rdoc +28 -0
  17. data/test/dummy/Rakefile +6 -0
  18. data/{app/assets/javascripts/t1k → test/dummy/app/assets/javascripts}/application.js +0 -0
  19. data/{app/assets/stylesheets/t1k → test/dummy/app/assets/stylesheets}/application.css +0 -0
  20. data/test/dummy/app/controllers/application_controller.rb +5 -0
  21. data/test/dummy/app/helpers/application_helper.rb +2 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/bin/bundle +3 -0
  24. data/test/dummy/bin/rails +4 -0
  25. data/test/dummy/bin/rake +4 -0
  26. data/test/dummy/bin/setup +29 -0
  27. data/test/dummy/config.ru +4 -0
  28. data/test/dummy/config/application.rb +26 -0
  29. data/test/dummy/config/boot.rb +5 -0
  30. data/test/dummy/config/database.yml +25 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +41 -0
  33. data/test/dummy/config/environments/production.rb +79 -0
  34. data/test/dummy/config/environments/test.rb +42 -0
  35. data/test/dummy/config/initializers/assets.rb +11 -0
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/test/dummy/config/initializers/inflections.rb +16 -0
  40. data/test/dummy/config/initializers/mime_types.rb +4 -0
  41. data/test/dummy/config/initializers/session_store.rb +3 -0
  42. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  43. data/test/dummy/config/locales/en.yml +23 -0
  44. data/test/dummy/config/routes.rb +56 -0
  45. data/test/dummy/config/secrets.yml +22 -0
  46. data/test/dummy/public/404.html +67 -0
  47. data/test/dummy/public/422.html +67 -0
  48. data/test/dummy/public/500.html +66 -0
  49. data/test/dummy/public/favicon.ico +0 -0
  50. data/test/test_helper.rb +19 -0
  51. data/test/tk1_test.rb +36 -0
  52. metadata +99 -13
  53. data/app/controllers/t1k/application_controller.rb +0 -4
  54. data/app/helpers/t1k/application_helper.rb +0 -4
  55. data/app/views/layouts/t1k/application.html.erb +0 -14
  56. data/config/routes.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52764ce988279c8999475978814120f9fd821f02
4
- data.tar.gz: f49c1768bd400989d382fc31a43f1b76895ae8ef
3
+ metadata.gz: 4e0106184b19bc3354aaa110c345d1697e83cae3
4
+ data.tar.gz: 5617aa9c735bbf65344e7a0db88a9a8e4588930b
5
5
  SHA512:
6
- metadata.gz: 466bd53b2461f61e3289781341cb88a580df55acc200555e36bad3c88bb5fb7533d707863e12a2adad59fb95ee51cf74af752115e2a28ba8f7acc519beb0ef6b
7
- data.tar.gz: 53666d123dd7a6ec5adf78a75cb1b72185adc5c058929fdba246a5cb7988ce6e0e27d34fc56b347510a8b44c5055382302a944b7b05cb0b1f97c65bc17362f9a
6
+ metadata.gz: 3d6185418e175014deb8a1d489a82c9975d61d60ba511359314f9828efe85c4aef3e9baf4928a080841e185b83a9820b016d9cefadc7b11ff090e5fbc6fb64cd
7
+ data.tar.gz: 20b78b6644732410b078c3f3e5a1c163c843c41fa79d9d289aa9306149a2cc29687f16ad0985494c0f3f291f3fbe57aa36213313519b9e1a415d2b2099b92154
data/Rakefile CHANGED
@@ -14,14 +14,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
- load 'rails/tasks/statistics.rake'
22
-
23
-
24
-
25
17
  Bundler::GemHelper.install_tasks
26
18
 
27
19
  require 'rake/testtask'
data/lib/t1k.rb CHANGED
@@ -1,78 +1,35 @@
1
- require "t1k/engine"
2
- require "trello"
3
- require "github_api"
1
+ require 't1k/engine'
4
2
 
5
3
  module T1k
6
- @@config = {}
4
+ autoload :Repository, 't1k/repository'
5
+ autoload :Tracker, 't1k/tracker'
7
6
 
8
- def self.configure &block
9
- block.call @@config
10
- config_trello
11
- config_github
7
+ module Repositories
8
+ autoload :Github, 't1k/repositories/github'
9
+ autoload :Bitbucket, 't1k/repositories/bitbucket'
12
10
  end
13
11
 
14
- def self.hack url_card
15
- card = get_card url_card
16
- issue = create_issue card.name
17
- code_issue = get_issue_code issue
18
-
19
- update_card card, code_issue
20
- puts "Card ##{code_issue[:code]} created and tracked"
21
- code_issue[:code]
12
+ module Trackers
13
+ autoload :Trello, 't1k/trackers/trello'
14
+ autoload :Pivotal, 't1k/trackers/pivotal'
22
15
  end
23
16
 
24
- private
25
-
26
- def self.get_card url_card
27
- begin
28
- puts "Catching card"
29
- me = Trello::Member.find(@@config[:trello_user_name])
30
- board = me.boards.select{|x| x.name.upcase == @@config[:trello_board_name].upcase}.first
31
- card = board.cards.select{|x| x.url.index(url_card)}.first
32
- raise if card.nil?
17
+ mattr_accessor :repository
18
+ @@repository = T1k::Repository
33
19
 
34
- card
35
- rescue
36
- raise 'Card not found'
37
- end
38
- end
20
+ mattr_accessor :tracker
21
+ @@tracker = T1k::Tracker
39
22
 
40
- def self.update_card card, issue_code
41
- puts "Updating card"
42
- card.name = "[##{issue_code[:code]}] #{card.name}"
43
- card.desc = "#{issue_code[:link]} #{card.desc}"
44
- card.save
45
- end
46
23
 
47
- def self.create_issue title
48
- begin
49
- puts "Creating issue"
50
- github_auth = Github.new :oauth_token => @@config[:github_oauth_token]
51
- github_auth.issues.create user: @@config[:github_user], repo: @@config[:github_repo], title: title
52
- rescue
53
- raise 'Issue not created'
54
- end
24
+ def self.setup &block
25
+ yield(self) if block_given?
55
26
  end
56
27
 
57
- def self.get_issue_code issue
58
- url_issue = issue.html_url
59
- code = url_issue[url_issue.rindex('/')+1..url_issue.size]
60
- code_html_issue = {code: code,
61
- link: "Link to code: [#{code}](#{url_issue})"}
62
- end
63
-
64
- def self.config_trello
65
- # API key generated by visiting https://trello.com/1/appKey/generate
66
- # https://trello.com/app-key
67
- # https://trello.com/1/connect?key=YOUR_KEY&name=BOARD_NAME&expiration=never&response_type=token&scope=read,write
68
- Trello.configure do |config|
69
- config.developer_public_key = @@config[:trello_developer_public_key]
70
- config.member_token = @@config[:trello_member_token]
71
- end
72
- end
73
-
74
- def self.config_github
75
- # https://github.com/settings/applications
76
- # Personal access tokens
28
+ def self.hack url_card
29
+ card = tracker.get_card(url_card)
30
+ issue = repository.get_issue(repository.create_issue(card.name).html_url)
31
+ tracker.update_card(card, issue)
32
+ puts "Card ##{issue.code} created and tracked"
33
+ issue.code
77
34
  end
78
35
  end
data/lib/t1k/engine.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module T1k
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace T1k
3
+ isolate_namespace T1k
4
4
  end
5
- end
5
+ end
@@ -0,0 +1,23 @@
1
+ # bitbucket requirements
2
+
3
+ module T1k
4
+ module Repositories
5
+ class Bitbucket
6
+
7
+ # bitbucket configurations
8
+ # cattr_accessor :config_name
9
+ # @@config_name = "default value"
10
+
11
+ # implement setup method
12
+ # def self.setup &block
13
+ # yield(self) if block_given?
14
+ # end
15
+
16
+ # implement create_issue method
17
+ # def self.create_issue(title); end
18
+
19
+ # implement create_issue method
20
+ # def self.get_issue(html_url); end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,46 @@
1
+ require "github_api"
2
+
3
+ module T1k
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 html_url
41
+ code = html_url[html_url.rindex('/')+1..html_url.size]
42
+ Issue.new(code, "Link to code: [#{code}](#{html_url})")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ module T1k
2
+ class Repository
3
+
4
+ cattr_accessor :adapter
5
+ @@adapter = T1k::Repositories::Github # default adapter
6
+
7
+ class << self
8
+ delegate :create_issue, :get_issue, 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
20
+ end
@@ -0,0 +1,20 @@
1
+ module T1k
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
20
+ end
@@ -0,0 +1,23 @@
1
+ # pivotal requirements
2
+
3
+ module T1k
4
+ module Trackers
5
+ class Pivotal
6
+
7
+ # pivotal configurations
8
+ # cattr_accessor :config_name
9
+ # @@config_name = "default value"
10
+
11
+ # implement setup method
12
+ # def self.setup &block
13
+ # yield(self) if block_given?
14
+ # end
15
+
16
+ # implement get_card method
17
+ # def self.get_card(url_card); end
18
+
19
+ # implement get_card method
20
+ # def self.update_card(card, issue); end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ require "trello"
2
+
3
+ module T1k
4
+ module Trackers
5
+ class Trello
6
+
7
+ cattr_accessor :developer_public_key
8
+ @@developer_public_key = ""
9
+
10
+ cattr_accessor :member_token
11
+ @@member_token = ""
12
+
13
+ cattr_accessor :user_name
14
+ @@user_name = ""
15
+
16
+ cattr_accessor :board_name
17
+ @@board_name = ""
18
+
19
+ def self.setup &block
20
+ yield(self) if block_given?
21
+ self.config_keys
22
+ end
23
+
24
+ def self.config_keys
25
+ ::Trello.configure do |config|
26
+ config.developer_public_key = self.developer_public_key
27
+ config.member_token = self.member_token
28
+ end
29
+ end
30
+
31
+ def self.get_card url_card
32
+ begin
33
+ puts "Catching card"
34
+
35
+ me = ::Trello::Member.find(self.user_name)
36
+ board = me.boards.select{|x| x.name.upcase == self.board_name.upcase}.first
37
+ card = board.cards.select{|x| x.url.index(url_card)}.first
38
+ raise if card.nil?
39
+
40
+ card
41
+ rescue
42
+ raise 'Card not found'
43
+ end
44
+ end
45
+
46
+ def self.update_card card, issue
47
+ puts "Updating card"
48
+ card.name = "[##{issue.code}] #{card.name}"
49
+ card.desc = "#{issue.link} #{card.desc}"
50
+ card.save
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/t1k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module T1k
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "1.0.1"
3
+ end
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  #rake t1k:commit['comentario do commit',close]
4
4
  namespace :t1k do
5
- desc "Commita com a info da issue para vincular ao github"
5
+ desc "Commit using issue's info to track it down with github"
6
6
 
7
7
  task :commit, [:comment, :close] do |t, args|
8
8
  closed = args[:close] == 'close' ? "close " : ""
data/lib/tasks/hack.rake CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  # rake t1k:hack['uD2GBBMf']
4
4
  namespace :t1k do
5
- desc "Cria issue e atualiza cartão do trello"
5
+ desc "Creates an issue and update the trello's card"
6
6
 
7
7
  task :hack, [:path_card_part] do |t, args|
8
8
  code_card = T1k::hack args[:path_card_part]
data/lib/tasks/ship.rake CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  #rake t1k:ship
4
4
  namespace :t1k do
5
- desc "Faz merge com o master e pusha"
5
+ desc "It merges the current branch with master and push"
6
6
 
7
7
  task :ship do |t, args|
8
8
  branch = `git branch | grep '*' | awk '{print $2}'`
data/lib/tasks/sink.rake CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  #rake t1k:sink
4
4
  namespace :t1k do
5
- desc "Sincroniza branch atual com o master"
5
+ desc "Sync current branch with master"
6
6
 
7
7
  task :sink do |t, args|
8
8
  branch = `git branch | grep '*' | awk '{print $2}'`
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>