Module: Autowow::Features::Gem
Instance Method Summary
collapse
#cmd, #info, #migrate, #pb_reset
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, #current_ref, #fetch, #git_status, #hard_reset, #merge, #pull, #push, #rebase, #remotes, #set_upstream, #show_ref, #stash, #stash_pop, #terminal_options, #upstream_tracking
#be, #build, #bump, #bundle_install, #clean, #rake, #rake_db_migrate_reset, #rake_db_schema, #rake_db_structure, #release, #rubocop_autocorrect, #rubocop_parallel
Instance Method Details
#app_name ⇒ Object
9
10
11
|
# File 'lib/autowow/features/heroku.rb', line 9
def app_name
quiet.run(info).out.clean_lines.select { |line| line.start_with?("===") }.first.split(" ").last
end
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/autowow/features/gem.rb', line 102
def bump_readme_version_information(version)
readme = "README.md"
return unless File.exists?(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.chomp)\n File.write(readme, text)\nend\n"
|
#bundle_exec(cmd) ⇒ Object
73
74
75
|
# File 'lib/autowow/features/gem.rb', line 73
def bundle_exec(cmd)
Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
end
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/autowow/features/gem.rb', line 125
def change_readme_version_information_to_development(version)
readme = "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.chomp)\n File.write(readme, text)\n true\nend\n"
|
146
147
148
|
# File 'lib/autowow/features/gem.rb', line 146
def contains_version_information?(text)
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m).length > 0
end
|
#db_migrate ⇒ Object
13
14
15
16
17
18
|
# File 'lib/autowow/features/heroku.rb', line 13
def db_migrate
current_app_name = app_name
pretty_with_output.run(pb_reset(current_app_name))
pretty_with_output.run(migrate(current_app_name))
end
|
#db_migrate_reset ⇒ Object
90
91
92
|
# File 'lib/autowow/features/gem.rb', line 90
def db_migrate_reset
pretty_with_output.run(rake_db_migrate_reset)
end
|
#db_schema ⇒ Object
94
95
96
|
# File 'lib/autowow/features/gem.rb', line 94
def db_schema
pretty_with_output.run(rake_db_schema)
end
|
#db_structure ⇒ Object
98
99
100
|
# File 'lib/autowow/features/gem.rb', line 98
def db_structure
pretty_with_output.run(rake_db_structure)
end
|
#gem_clean ⇒ Object
57
58
59
|
# File 'lib/autowow/features/gem.rb', line 57
def gem_clean
pretty_with_output.run(clean)
end
|
#gem_install_source ⇒ Object
85
86
87
88
|
# File 'lib/autowow/features/gem.rb', line 85
def gem_install_source
pretty_with_output.run("gem build *.gemspec")
pretty_with_output.run("gem install *.gem")
end
|
#gem_release(version_bump = 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
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/autowow/features/gem.rb', line 14
def gem_release(version_bump = nil)
unless rubygems_credentials_set?
logger.error("Set RubyGems credentials first via `gem push`")
return
end
pretty_with_output.run(git_status)
pretty_with_output.run(bundle_install)
start_branch = Vcs.working_branch
logger.error("Not on master.") and return unless start_branch.eql?("master")
pretty.run(pull)
version = nil
if version_bump
version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping|bump/) }.first.split("to ").last
bump_readme_version_information(version)
pretty.run("git add README.md *version.rb")
pretty.run("git commit -m \"Bumps version to v#{version}\"")
end
pretty.run(push)
Vcs.on_branch("release") do
result = pretty.run!(pull)
pretty_with_output.run(set_upstream("origin", "release")) unless result.success?
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("git commit -m \"Changes README to development version\"")
pretty.run(push)
end
pretty_with_output.run(git_status)
end
|
150
151
152
|
# File 'lib/autowow/features/gem.rb', line 150
def get_version_information(text)
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m)[0]
end
|
#rubocop_parallel_autocorrect ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/autowow/features/gem.rb', line 61
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
|
#ruby_check ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/autowow/features/gem.rb', line 77
def ruby_check
rubocop_parallel_autocorrect
bundle_exec(["rspec"])
db_migrate_reset
pretty_with_output.run(rake + ["db:seed"])
pretty_with_output.run(git_status)
end
|
#rubygems_credentials_set? ⇒ Boolean
53
54
55
|
# File 'lib/autowow/features/gem.rb', line 53
def rubygems_credentials_set?
!quiet.run!("gem push --silent").err.clean_lines.blank?
end
|