autowow 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +1,49 @@
1
- require_relative "../time_difference"
2
-
3
- module Autowow
4
- module Features
5
- module Fs
6
- using RefinedTimeDifference
7
-
8
- def ls_dirs
9
- Dir.glob(File.expand_path("./*/")).select { |f| File.directory? f }
10
- end
11
-
12
- def latest(files)
13
- files.sort_by { |f| File.mtime(f) }.reverse!.first
14
- end
15
-
16
- def older_than(files, quantity, unit)
17
- files.select do |dir|
18
- TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
19
- end
20
- end
21
-
22
- def for_dirs(dirs)
23
- dirs.each do |working_dir|
24
- # TODO: add handling of directories via extra param to popen3
25
- # https://stackoverflow.com/a/10148084/2771889
26
- Dir.chdir(working_dir) do
27
- yield working_dir
28
- end
29
- end
30
- end
31
-
32
- def in_place_or_subdirs(in_place)
33
- if in_place
34
- yield
35
- else
36
- for_dirs(ls_dirs) do
37
- yield
38
- end
39
- end
40
- end
41
-
42
- def git_folder_present
43
- File.exist?(".git")
44
- end
45
-
46
- include ReflectionUtils::CreateModuleFunctions
47
- end
48
- end
49
- end
1
+ require_relative "../time_difference"
2
+
3
+ module Autowow
4
+ module Features
5
+ module Fs
6
+ using RefinedTimeDifference
7
+
8
+ def ls_dirs
9
+ Dir.glob(File.expand_path("./*/")).select { |f| File.directory? f }
10
+ end
11
+
12
+ def latest(files)
13
+ files.sort_by { |f| File.mtime(f) }.reverse!.first
14
+ end
15
+
16
+ def older_than(files, quantity, unit)
17
+ files.select do |dir|
18
+ TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
19
+ end
20
+ end
21
+
22
+ def for_dirs(dirs)
23
+ dirs.each do |working_dir|
24
+ # TODO: add handling of directories via extra param to popen3
25
+ # https://stackoverflow.com/a/10148084/2771889
26
+ Dir.chdir(working_dir) do
27
+ yield working_dir
28
+ end
29
+ end
30
+ end
31
+
32
+ def in_place_or_subdirs(in_place)
33
+ if in_place
34
+ yield
35
+ else
36
+ for_dirs(ls_dirs) do
37
+ yield
38
+ end
39
+ end
40
+ end
41
+
42
+ def git_folder_present
43
+ File.exist?(".git")
44
+ end
45
+
46
+ include ReflectionUtils::CreateModuleFunctions
47
+ end
48
+ end
49
+ end
@@ -1,132 +1,138 @@
1
- require "pastel"
2
-
3
- require_relative "../commands/gem"
4
- require_relative "vcs"
5
-
6
- module Autowow
7
- module Features
8
- module Gem
9
- include EasyLogging
10
- include Commands::Gem
11
- include Commands::Vcs
12
- include Executor
13
-
14
- def gem_release(version_bump = nil)
15
- pretty_with_output.run(git_status)
16
- start_branch = Vcs.working_branch
17
- logger.error("Not on master.") and return unless start_branch.eql?("master")
18
- pretty.run(pull)
19
- version = nil
20
-
21
- if version_bump
22
- version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping/) }.first.split(" ").last
23
- bump_readme_version_information(version)
24
- pretty.run(add(["README.md", "*version.rb"]))
25
- pretty.run(commit("Bumps version to v#{version}"))
26
- end
27
-
28
- pretty.run(push)
29
-
30
- Vcs.on_branch("release") do
31
- pretty.run(pull)
32
- pretty.run(rebase(start_branch))
33
- pretty_with_output.run(release)
34
- end
35
-
36
- if version && change_readme_version_information_to_development(version)
37
- pretty.run(add(["README.md"]))
38
- pretty.run(commit("Changes README to development version"))
39
- pretty.run(push)
40
- end
41
-
42
- pretty_with_output.run(git_status)
43
- end
44
-
45
- def gem_clean
46
- pretty_with_output.run(clean)
47
- end
48
-
49
- def rubocop_parallel_autocorrect
50
- pastel = Pastel.new
51
- result = pretty_with_output.run!(rubocop_parallel)
52
- if result.failed?
53
- filtered = result.out.each_line.select { |line| line.match(%r{(.*):([0-9]*):([0-9]*):}) }
54
- .map { |line| line.split(":")[0] }
55
- .uniq
56
- .map { |line| pastel.strip(line) }
57
- pretty_with_output.run(rubocop_autocorrect(filtered)) if filtered.any?
58
- end
59
- end
60
-
61
- def bundle_exec(cmd)
62
- Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
63
- end
64
-
65
- def db_migrate
66
- pretty_with_output.run(rake_db_migrate)
67
- end
68
-
69
- def db_schema
70
- pretty_with_output.run(rake_db_schema)
71
- end
72
-
73
- def db_structure
74
- pretty_with_output.run(rake_db_structure)
75
- end
76
-
77
- def bump_readme_version_information(version)
78
- readme = File.new("README.md")
79
- return unless File.file?(readme)
80
- text = File.read(readme)
81
- return unless contains_version_information?(text)
82
-
83
- version_information = get_version_information(text)
84
-
85
- new_version_information = if version_information.include?("development version")
86
- releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
87
- <<-HEREDOC
88
- <!--- Version informartion -->
89
- *You are viewing the README of version [v#{version}](#{releases_link}/tag/v#{version}). You can find other releases [here](#{releases_link}).*
90
- <!--- Version informartion end -->
91
- HEREDOC
92
- else
93
- version_information.gsub(/[0-9]\.[0-9]\.[0-9]/, version)
94
- end
95
-
96
- text.gsub!(version_information, new_version_information.chomp)
97
- File.write(readme, text)
98
- end
99
-
100
- def change_readme_version_information_to_development(version)
101
- readme = File.new("README.md")
102
- return false unless File.file?(readme)
103
- text = File.read(readme)
104
- return false unless contains_version_information?(text)
105
- version_information = get_version_information(text)
106
- return false if version_information.include?("development version")
107
-
108
- releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
109
-
110
- new_version_information = <<-HEREDOC
111
- <!--- Version informartion -->
112
- *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}).*
113
- <!--- Version informartion end -->
114
- HEREDOC
115
-
116
- text.gsub!(version_information, new_version_information.chomp)
117
- File.write(readme, text)
118
- true
119
- end
120
-
121
- def contains_version_information?(text)
122
- text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m).length > 0
123
- end
124
-
125
- def get_version_information(text)
126
- text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m)[0]
127
- end
128
-
129
- include ReflectionUtils::CreateModuleFunctions
130
- end
131
- end
132
- end
1
+ require "pastel"
2
+
3
+ require_relative "../commands/gem"
4
+ require_relative "vcs"
5
+
6
+ module Autowow
7
+ module Features
8
+ module Gem
9
+ include EasyLogging
10
+ include Commands::Gem
11
+ include Commands::Vcs
12
+ include Executor
13
+
14
+ def gem_release(version_bump = nil)
15
+ if quiet.run!("gem push").out.clean_lines.select { |line| line.match(/Enter your RubyGems.org credentials/) }.any?
16
+ logger.error("Set RubyGems credentials first via `gem push`")
17
+ return
18
+ end
19
+ pretty_with_output.run(git_status)
20
+ start_branch = Vcs.working_branch
21
+ logger.error("Not on master.") and return unless start_branch.eql?("master")
22
+ pretty.run(pull)
23
+ version = nil
24
+
25
+ if version_bump
26
+ version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping|bump/) }.first.split(" ").last
27
+ bump_readme_version_information(version)
28
+ # Full command is needed because of faulty escaping otherwise
29
+ pretty.run("git add README.md *version.rb")
30
+ pretty.run("git commit -m \"Bumps version to v#{version}\"")
31
+ end
32
+
33
+ pretty.run(push)
34
+
35
+ Vcs.on_branch("release") do
36
+ pretty.run(pull)
37
+ pretty.run(rebase(start_branch))
38
+ pretty_with_output.run(release)
39
+ end
40
+
41
+ if version && change_readme_version_information_to_development(version)
42
+ pretty.run(add(["README.md"]))
43
+ # Full command is needed because of faulty escaping otherwise
44
+ pretty.run("git commit -m \"Changes README to development version\"")
45
+ pretty.run(push)
46
+ end
47
+
48
+ pretty_with_output.run(git_status)
49
+ end
50
+
51
+ def gem_clean
52
+ pretty_with_output.run(clean)
53
+ end
54
+
55
+ def rubocop_parallel_autocorrect
56
+ pastel = Pastel.new
57
+ result = pretty_with_output.run!(rubocop_parallel)
58
+ if result.failed?
59
+ filtered = result.out.each_line.select { |line| line.match(%r{(.*):([0-9]*):([0-9]*):}) }
60
+ .map { |line| line.split(":")[0] }
61
+ .uniq
62
+ .map { |line| pastel.strip(line) }
63
+ pretty_with_output.run(rubocop_autocorrect(filtered)) if filtered.any?
64
+ end
65
+ end
66
+
67
+ def bundle_exec(cmd)
68
+ Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
69
+ end
70
+
71
+ def db_migrate
72
+ pretty_with_output.run(rake_db_migrate)
73
+ end
74
+
75
+ def db_schema
76
+ pretty_with_output.run(rake_db_schema)
77
+ end
78
+
79
+ def db_structure
80
+ pretty_with_output.run(rake_db_structure)
81
+ end
82
+
83
+ def bump_readme_version_information(version)
84
+ readme = File.new("README.md")
85
+ return unless File.file?(readme)
86
+ text = File.read(readme)
87
+ return unless contains_version_information?(text)
88
+
89
+ version_information = get_version_information(text)
90
+
91
+ new_version_information = if version_information.include?("development version")
92
+ releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
93
+ <<-HEREDOC
94
+ <!--- Version informartion -->
95
+ *You are viewing the README of version [v#{version}](#{releases_link}/tag/v#{version}). You can find other releases [here](#{releases_link}).*
96
+ <!--- Version informartion end -->
97
+ HEREDOC
98
+ else
99
+ version_information.gsub(/[0-9]\.[0-9]\.[0-9]/, version)
100
+ end
101
+
102
+ text.gsub!(version_information, new_version_information.chomp)
103
+ File.write(readme, text)
104
+ end
105
+
106
+ def change_readme_version_information_to_development(version)
107
+ readme = File.new("README.md")
108
+ return false unless File.file?(readme)
109
+ text = File.read(readme)
110
+ return false unless contains_version_information?(text)
111
+ version_information = get_version_information(text)
112
+ return false if version_information.include?("development version")
113
+
114
+ releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
115
+
116
+ new_version_information = <<-HEREDOC
117
+ <!--- Version informartion -->
118
+ *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}).*
119
+ <!--- Version informartion end -->
120
+ HEREDOC
121
+
122
+ text.gsub!(version_information, new_version_information.chomp)
123
+ File.write(readme, text)
124
+ true
125
+ end
126
+
127
+ def contains_version_information?(text)
128
+ text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m).length > 0
129
+ end
130
+
131
+ def get_version_information(text)
132
+ text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m)[0]
133
+ end
134
+
135
+ include ReflectionUtils::CreateModuleFunctions
136
+ end
137
+ end
138
+ end
@@ -1,16 +1,16 @@
1
- require_relative "../commands/os"
2
-
3
- module Autowow
4
- module Features
5
- module Os
6
- include Commands::Os
7
- include Executor
8
-
9
- def exists?(cmd)
10
- quiet.run!(which(cmd)).success?
11
- end
12
-
13
- include ReflectionUtils::CreateModuleFunctions
14
- end
15
- end
16
- end
1
+ require_relative "../commands/os"
2
+
3
+ module Autowow
4
+ module Features
5
+ module Os
6
+ include Commands::Os
7
+ include Executor
8
+
9
+ def exists?(cmd)
10
+ quiet.run!(which(cmd)).success?
11
+ end
12
+
13
+ include ReflectionUtils::CreateModuleFunctions
14
+ end
15
+ end
16
+ end
@@ -1,50 +1,50 @@
1
- require_relative "../commands/rbenv"
2
- require_relative "../commands/vcs"
3
-
4
- require_relative "fs"
5
- require_relative "vcs"
6
-
7
- module Autowow
8
- module Features
9
- module Rbenv
10
- include EasyLogging
11
- include Commands::Rbenv
12
- include Executor
13
- include StringDecorator
14
-
15
- def ruby_versions
16
- logger.info(used_versions)
17
- end
18
-
19
- def used_versions
20
- rubies = []
21
- Fs.in_place_or_subdirs(Vcs.is_git?) do
22
- result = quiet.run!(version)
23
- rubies.concat(result.out.clean_lines) if result.success?
24
- end
25
- rubies.uniq
26
- end
27
-
28
- def ruby_aliases
29
- ret = {}
30
- result = quiet.run!(aliases)
31
- return ret unless result.success?
32
- result.out.clean_lines.each do |line|
33
- ret[line.split(" => ")[0]] = line.split(" => ")[1]
34
- end
35
- ret
36
- end
37
-
38
- def obsolete_versions
39
- alias_map = ruby_aliases
40
- used_versions_and_aliases = used_versions
41
- used_versions.each do |v|
42
- used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
43
- end
44
- quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
45
- end
46
-
47
- include ReflectionUtils::CreateModuleFunctions
48
- end
49
- end
50
- end
1
+ require_relative "../commands/rbenv"
2
+ require_relative "../commands/vcs"
3
+
4
+ require_relative "fs"
5
+ require_relative "vcs"
6
+
7
+ module Autowow
8
+ module Features
9
+ module Rbenv
10
+ include EasyLogging
11
+ include Commands::Rbenv
12
+ include Executor
13
+ include StringDecorator
14
+
15
+ def ruby_versions
16
+ logger.info(used_versions)
17
+ end
18
+
19
+ def used_versions
20
+ rubies = []
21
+ Fs.in_place_or_subdirs(Vcs.is_git?) do
22
+ result = quiet.run!(version)
23
+ rubies.concat(result.out.clean_lines) if result.success?
24
+ end
25
+ rubies.uniq
26
+ end
27
+
28
+ def ruby_aliases
29
+ ret = {}
30
+ result = quiet.run!(aliases)
31
+ return ret unless result.success?
32
+ result.out.clean_lines.each do |line|
33
+ ret[line.split(" => ")[0]] = line.split(" => ")[1]
34
+ end
35
+ ret
36
+ end
37
+
38
+ def obsolete_versions
39
+ alias_map = ruby_aliases
40
+ used_versions_and_aliases = used_versions
41
+ used_versions.each do |v|
42
+ used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
43
+ end
44
+ quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
45
+ end
46
+
47
+ include ReflectionUtils::CreateModuleFunctions
48
+ end
49
+ end
50
+ end