Module: Autowow::Features::Gem
Instance Method Summary
collapse
Methods included from Executor
#pretty, #pretty_with_output, #quiet, #tty_params
#add, #add_remote, #branch, #branch_force_delete, #branch_list, #changes_not_on_remote, #checkout, #cmd, #commit, #create, #current_branch, #fetch, #git_status, #merge, #pull, #push, #rebase, #remotes, #set_upstream, #stash, #stash_pop, #terminal_options
#be, #bump, #clean, #release, #rubocop_autocorrect, #rubocop_parallel
Instance Method Details
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/autowow/features/gem.rb', line 63
def bump_readme_version_information(version)
readme = File.new("README.md")
return unless File.file?(readme)
text = File.read(readme)
return unless contains_version_information?(text)
version_information = get_version_information(text)
new_version_information = if version_information.include?("development version")
releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
"<!--- Version informartion -->\n*You are viewing the README of version [v\#{version}](\#{releases_link}/tag/v\#{version}). You can find other releases [here](\#{releases_link}).*\n<!--- Version informartion end -->\n HEREDOC\n else\n version_information.gsub(/[0-9]\\.[0-9]\\.[0-9]/, version)\n end\n \n text.gsub!(version_information, new_version_information)\n File.write(readme, text)\nend\n"
|
#bundle_exec(cmd) ⇒ Object
59
60
61
|
# File 'lib/autowow/features/gem.rb', line 59
def bundle_exec(cmd)
Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
end
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/autowow/features/gem.rb', line 86
def change_readme_version_information_to_development(version)
readme = File.new("README.md")
return false unless File.file?(readme)
text = File.read(readme)
return false unless contains_version_information?(text)
version_information = get_version_information(text)
return false if version_information.include?("development version")
releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
new_version_information = "<!--- Version informartion -->\n*You are viewing the README of the development version. You can find the README of the latest release (v\#{version}) [here](\#{releases_link}/tag/v\#{version}).*\n<!--- Version informartion end -->\n HEREDOC\n\n text.gsub!(version_information, new_version_information)\n File.write(readme, text)\n true\nend\n"
|
107
108
109
|
# File 'lib/autowow/features/gem.rb', line 107
def contains_version_information?(text)
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m).length > 0
end
|
#gem_clean ⇒ Object
43
44
45
|
# File 'lib/autowow/features/gem.rb', line 43
def gem_clean
pretty_with_output.run(clean)
end
|
#gem_release(version = nil) ⇒ Object
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
|
# File 'lib/autowow/features/gem.rb', line 14
def gem_release(version = nil)
pretty_with_output.run(git_status)
start_branch = Vcs.working_branch
logger.error("Not on master.") and return unless start_branch.eql?("master")
pretty.run(pull)
if version
pretty_with_output.run(bump(version))
bump_readme_version_information(version)
pretty.run(add(["README.md", "*version.rb"]))
pretty.run(commit("Bumps version to v#{version}"))
end
pretty.run(push)
Vcs.on_branch("release") do
pretty.run(pull)
pretty.run(rebase(start_branch))
pretty_with_output.run(release)
end
if version && change_readme_version_information_to_development(version)
pretty.run(add(["README.md"]))
pretty.run(commit("Changes README to development version"))
end
pretty_with_output.run(git_status)
end
|
111
112
113
|
# File 'lib/autowow/features/gem.rb', line 111
def get_version_information(text)
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m)[0]
end
|
#rubocop_parallel_autocorrect ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/autowow/features/gem.rb', line 47
def rubocop_parallel_autocorrect
pastel = Pastel.new
result = pretty_with_output.run!(rubocop_parallel)
if result.failed?
filtered = result.out.each_line.select { |line| line.match(%r{(.*):([0-9]*):([0-9]*):}) }
.map { |line| line.split(":")[0] }
.uniq
.map { |line| pastel.strip(line) }
pretty_with_output.run(rubocop_autocorrect(filtered)) if filtered.any?
end
end
|