Class: Abak::Flow::Branch
- Inherits:
-
Object
- Object
- Abak::Flow::Branch
- Defined in:
- lib/abak-flow/branch.rb
Constant Summary collapse
- FOLDER_HOTFIX =
"hotfix".freeze
- FOLDER_FEATURE =
"feature".freeze
- TASK_FORMAT =
'\w+\-\d{1,}'.freeze
- MAGICK_WORDS =
%w{close closes closed fix fixes fixed resolve resolves resolved}.freeze
- DEVELOPMENT =
"develop".freeze
- MASTER =
"master".freeze
- MAPPING =
{ FOLDER_HOTFIX => MASTER, FOLDER_FEATURE => DEVELOPMENT }.freeze
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #compare_link(branch) ⇒ Object
- #current? ⇒ Boolean
- #delete_on_local ⇒ Object
- #delete_on_remote ⇒ Object
- #develop? ⇒ Boolean
- #extract_base_name(options = Hash.new) ⇒ Object
-
#extract_body ⇒ Object
TODO : Сделать настраевыемым трекер и формат задачи.
- #extract_title ⇒ Object
- #feature? ⇒ Boolean
- #hotfix? ⇒ Boolean
-
#initialize(branch) ⇒ Branch
constructor
A new instance of Branch.
- #mappable? ⇒ Boolean
- #master? ⇒ Boolean
- #message ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
- #tracker_task? ⇒ Boolean
- #update ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
19 20 21 |
# File 'lib/abak-flow/branch.rb', line 19 def folder @folder end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
20 21 22 |
# File 'lib/abak-flow/branch.rb', line 20 def task @task end |
Instance Method Details
#compare_link(branch) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/abak-flow/branch.rb', line 45 def compare_link(branch) diff = "#{@manager.repository.upstream.owner}:#{branch}...#{@branch}" File.join [ @manager.github.web_endpoint, @manager.repository.origin.to_s, "compare", diff ] end |
#current? ⇒ Boolean
112 113 114 |
# File 'lib/abak-flow/branch.rb', line 112 def current? @branch.current end |
#delete_on_local ⇒ Object
84 85 86 |
# File 'lib/abak-flow/branch.rb', line 84 def delete_on_local @branch.delete end |
#delete_on_remote ⇒ Object
79 80 81 82 |
# File 'lib/abak-flow/branch.rb', line 79 def delete_on_remote origin = @manager.repository.origin.repo @manager.git.push(origin, ":#{@branch}") end |
#develop? ⇒ Boolean
88 89 90 |
# File 'lib/abak-flow/branch.rb', line 88 def develop? name == DEVELOPMENT end |
#extract_base_name(options = Hash.new) ⇒ Object
55 56 57 58 |
# File 'lib/abak-flow/branch.rb', line 55 def extract_base_name( = Hash.new) mappable? ? MAPPING[folder] : .fetch(:if_undef, name) end |
#extract_body ⇒ Object
TODO : Сделать настраевыемым трекер и формат задачи
66 67 68 69 70 71 72 |
# File 'lib/abak-flow/branch.rb', line 66 def extract_body return I18n.t("commands.publish.nothing") if .empty? && !tracker_task? [, task].flatten .map { |x| "http://jira.railsc.ru/browse/#{x}" } * "\n" end |
#extract_title ⇒ Object
60 61 62 63 |
# File 'lib/abak-flow/branch.rb', line 60 def extract_title tracker_task? ? task : end |
#feature? ⇒ Boolean
100 101 102 |
# File 'lib/abak-flow/branch.rb', line 100 def feature? folder == FOLDER_FEATURE end |
#hotfix? ⇒ Boolean
96 97 98 |
# File 'lib/abak-flow/branch.rb', line 96 def hotfix? folder == FOLDER_HOTFIX end |
#mappable? ⇒ Boolean
108 109 110 |
# File 'lib/abak-flow/branch.rb', line 108 def mappable? hotfix? || feature? end |
#master? ⇒ Boolean
92 93 94 |
# File 'lib/abak-flow/branch.rb', line 92 def master? name == MASTER end |
#message ⇒ Object
34 35 36 37 38 39 |
# File 'lib/abak-flow/branch.rb', line 34 def content = @branch.gcommit..split("\n", 2).first return content if content.length < 72 content[0...72] << "..." end |
#name ⇒ Object
30 31 32 |
# File 'lib/abak-flow/branch.rb', line 30 def name @branch.full end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/abak-flow/branch.rb', line 41 def to_s @branch.to_s end |
#tracker_task? ⇒ Boolean
104 105 106 |
# File 'lib/abak-flow/branch.rb', line 104 def tracker_task? !(task =~ /^#{TASK_FORMAT}$/).nil? end |
#update ⇒ Object
74 75 76 77 |
# File 'lib/abak-flow/branch.rb', line 74 def update origin = @manager.repository.origin.repo @manager.git.push(origin, @branch) end |
#valid? ⇒ Boolean
116 117 118 |
# File 'lib/abak-flow/branch.rb', line 116 def valid? !@branch.name.empty? end |