autowow 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,59 +1,59 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "logger"
4
- @logger = Logger.new(STDOUT)
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- desc "Check if source can be required and is correctly required"
9
- task :require do
10
- dir = File.dirname(__FILE__)
11
- gemspec = load_gemspec(dir)
12
-
13
- # Order is important, assert_can_be_required should be run first
14
- assert_can_be_required(dir, gemspec)
15
- check_source_files_required(dir, gemspec)
16
- check_source_files_included(dir, gemspec)
17
- end
18
-
19
- def load_gemspec(dir)
20
- require "bundler/setup"
21
- Gem::Specification.find do |spec|
22
- spec.full_gem_path.include?(File.dirname(__FILE__))
23
- end
24
- end
25
-
26
- def check_source_files_required(dir, gemspec)
27
- require_gem(gemspec)
28
- ruby_files = Dir.glob("#{dir}/**/*.rb").reject { |f| f.include?("/spec/") }
29
- required_ruby_files = $LOADED_FEATURES.select { |f| f.include?(dir) }
30
- (ruby_files - required_ruby_files).each do |file|
31
- @logger.warn("Source file not required when loading gem: #{file.sub("#{dir}/", '')}")
32
- end
33
- end
34
-
35
- def check_source_files_included(dir, gemspec)
36
- ruby_files_relative = Dir.glob("#{dir}/**/*.rb").reject { |f| f.include?("/spec/") }.map { |f| f.sub("#{dir}/", "") }
37
- (ruby_files_relative - gemspec.files.select { |f| f.end_with?(".rb") }).each do |file|
38
- @logger.warn("File ignored when building gem because it's not added to git: #{file}")
39
- end
40
- end
41
-
42
- def assert_can_be_required(dir, gemspec)
43
- local_load_paths = $LOAD_PATH.select { |path| path.include?(dir) }
44
- $LOAD_PATH.reject! { |path| local_load_paths.include?(path) }
45
- begin
46
- require_gem(gemspec)
47
- rescue LoadError => e
48
- @logger.error("Gem source cannot be required relatively: #{e}")
49
- raise
50
- ensure
51
- $LOAD_PATH.push(*local_load_paths)
52
- end
53
- end
54
-
55
- def require_gem(gemspec)
56
- require_relative "lib/#{gemspec.name.gsub('-', '/')}"
57
- end
58
-
59
- task default: [:require, :spec]
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "logger"
4
+ @logger = Logger.new(STDOUT)
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc "Check if source can be required and is correctly required"
9
+ task :require do
10
+ dir = File.dirname(__FILE__)
11
+ gemspec = load_gemspec(dir)
12
+
13
+ # Order is important, assert_can_be_required should be run first
14
+ assert_can_be_required(dir, gemspec)
15
+ check_source_files_required(dir, gemspec)
16
+ check_source_files_included(dir, gemspec)
17
+ end
18
+
19
+ def load_gemspec(dir)
20
+ require "bundler/setup"
21
+ Gem::Specification.find do |spec|
22
+ spec.full_gem_path.include?(File.dirname(__FILE__))
23
+ end
24
+ end
25
+
26
+ def check_source_files_required(dir, gemspec)
27
+ require_gem(gemspec)
28
+ ruby_files = Dir.glob("#{dir}/**/*.rb").reject { |f| f.include?("/spec/") }
29
+ required_ruby_files = $LOADED_FEATURES.select { |f| f.include?(dir) }
30
+ (ruby_files - required_ruby_files).each do |file|
31
+ @logger.warn("Source file not required when loading gem: #{file.sub("#{dir}/", '')}")
32
+ end
33
+ end
34
+
35
+ def check_source_files_included(dir, gemspec)
36
+ ruby_files_relative = Dir.glob("#{dir}/**/*.rb").reject { |f| f.include?("/spec/") }.map { |f| f.sub("#{dir}/", "") }
37
+ (ruby_files_relative - gemspec.files.select { |f| f.end_with?(".rb") }).each do |file|
38
+ @logger.warn("File ignored when building gem because it's not added to git: #{file}")
39
+ end
40
+ end
41
+
42
+ def assert_can_be_required(dir, gemspec)
43
+ local_load_paths = $LOAD_PATH.select { |path| path.include?(dir) }
44
+ $LOAD_PATH.reject! { |path| local_load_paths.include?(path) }
45
+ begin
46
+ require_gem(gemspec)
47
+ rescue LoadError => e
48
+ @logger.error("Gem source cannot be required relatively: #{e}")
49
+ raise
50
+ ensure
51
+ $LOAD_PATH.push(*local_load_paths)
52
+ end
53
+ end
54
+
55
+ def require_gem(gemspec)
56
+ require_relative "lib/#{gemspec.name.gsub('-', '/')}"
57
+ end
58
+
59
+ task default: [:require, :spec]
data/autowow.gemspec CHANGED
@@ -1,41 +1,42 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "autowow/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "autowow"
8
- spec.version = Autowow::VERSION
9
- spec.authors = ["thisismydesign"]
10
- spec.email = ["thisismydesign@users.noreply.github.com"]
11
-
12
- spec.summary = %q{Set of commands to AUTOmate Way Of Working}
13
- spec.homepage = "https://github.com/thisismydesign/autowow"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = "bin"
20
- spec.executables << 'autowow'
21
- spec.executables << 'aw'
22
- spec.require_paths = ["lib"]
23
-
24
- spec.add_dependency "easy_logging", ">= 0.3.0" # Include logger easily, without redundancy
25
- spec.add_dependency "thor" # CLI
26
- spec.add_dependency "pastel" # Colorize output of own logger
27
- spec.add_dependency "time_difference", "= 0.5.0" # Calculate project age. Fixed version because of refinements :(
28
- spec.add_dependency "launchy" # Open project in browser
29
- spec.add_dependency "tty-command", "~> 0.8" # Execute system commands nicely
30
- spec.add_dependency "reflection_utils", ">= 0.3.0" # Invoke module methods without including the module
31
- spec.add_dependency "rubocop" # Style check
32
- spec.add_dependency "rubocop-rspec" # Style check
33
-
34
- spec.add_development_dependency "bundler", "~> 1.15"
35
- spec.add_development_dependency "rake", "~> 10.0"
36
- spec.add_development_dependency "rspec", "~> 3.0"
37
- spec.add_development_dependency "guard"
38
- spec.add_development_dependency "guard-bundler"
39
- spec.add_development_dependency "guard-rspec"
40
- spec.add_development_dependency "coveralls"
41
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "autowow/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "autowow"
8
+ spec.version = Autowow::VERSION
9
+ spec.authors = ["thisismydesign"]
10
+ spec.email = ["thisismydesign@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{Set of commands to AUTOmate Way Of Working}
13
+ spec.homepage = "https://github.com/thisismydesign/autowow"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "bin"
20
+ spec.executables << 'autowow'
21
+ spec.executables << 'aw'
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "easy_logging", ">= 0.3.0" # Include logger easily, without redundancy
25
+ spec.add_dependency "thor" # CLI
26
+ spec.add_dependency "pastel" # Colorize output of own logger
27
+ spec.add_dependency "time_difference", "= 0.5.0" # Calculate project age. Fixed version because of refinements :(
28
+ spec.add_dependency "launchy" # Open project in browser
29
+ spec.add_dependency "tty-command", "~> 0.8" # Execute system commands nicely
30
+ spec.add_dependency "reflection_utils", ">= 0.3.0" # Invoke module methods without including the module
31
+ spec.add_dependency "rubocop" # Style check
32
+ spec.add_dependency "rubocop-rspec" # Style check
33
+ spec.add_dependency "gem-release" # Bump gem versions
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.15"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_development_dependency "guard"
39
+ spec.add_development_dependency "guard-bundler"
40
+ spec.add_development_dependency "guard-rspec"
41
+ spec.add_development_dependency "coveralls"
42
+ end
data/bin/autowow CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "autowow"
4
-
5
- Autowow::CLI.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "autowow"
4
+
5
+ Autowow::CLI.start
data/bin/aw CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "autowow"
4
-
5
- Autowow::CLI.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "autowow"
4
+
5
+ Autowow::CLI.start
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "autowow"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "autowow"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/autowow.rb CHANGED
@@ -1,13 +1,13 @@
1
- require "easy_logging"
2
- require "reflection_utils"
3
-
4
- require_relative "autowow/log_formatter"
5
-
6
- EasyLogging.level = Logger::DEBUG
7
- EasyLogging.formatter = proc do |severity, datetime, progname, msg|
8
- Autowow::LogFormatter.beautify(severity, msg)
9
- end
10
-
11
- require_relative "autowow/cli"
12
-
13
- module Autowow; end
1
+ require "easy_logging"
2
+ require "reflection_utils"
3
+
4
+ require_relative "autowow/log_formatter"
5
+
6
+ EasyLogging.level = Logger::DEBUG
7
+ EasyLogging.formatter = proc do |severity, datetime, progname, msg|
8
+ Autowow::LogFormatter.beautify(severity, msg)
9
+ end
10
+
11
+ require_relative "autowow/cli"
12
+
13
+ module Autowow; end
data/lib/autowow/cli.rb CHANGED
@@ -1,115 +1,121 @@
1
- require "thor"
2
-
3
- require_relative "executor"
4
- require_relative "decorators/string_decorator"
5
-
6
- require_relative "features/rbenv"
7
- require_relative "features/gem"
8
- require_relative "features/vcs"
9
- require_relative "features/os"
10
- require_relative "features/fs"
11
-
12
- require_relative "commands/gem"
13
-
14
- module Autowow
15
- class CLI < Thor
16
- map %w[bm] => :branch_merged
17
- map %w[grls] => :gem_release
18
- map %w[up] => :update_projects
19
- map %w[cb] => :clear_branches
20
- map %w[au] => :add_upstream
21
- map %w[gc] => :gem_clean
22
- map %w[rv] => :ruby_versions
23
- map %w[gr] => :greet
24
- map %w[rpa] => :rubocop_parallel_autocorrect
25
- map %w[be] => :bundle_exec
26
- map %w[dbm] => :db_migrate
27
- map %w[dbsch] => :db_schema
28
- map %w[dbstr] => :db_structure
29
-
30
- desc "branch_merged", "clean working branch and return to master"
31
- def branch_merged
32
- Autowow::Features::Vcs.branch_merged
33
- end
34
-
35
- desc "gem_release", "release gem and return to master"
36
- def gem_release(version_bump = nil)
37
- Autowow::Features::Gem.gem_release(version_bump)
38
- end
39
-
40
- desc "update_projects", "updates idle projects"
41
- def update_projects
42
- Autowow::Features::Vcs.update_projects
43
- end
44
-
45
- desc "clear_branches", "removes unused branches"
46
- def clear_branches
47
- Autowow::Features::Vcs.clear_branches
48
- end
49
-
50
- desc "add_upstream", "adds upstream branch if available"
51
- def add_upstream
52
- Autowow::Features::Vcs.add_upstream
53
- end
54
-
55
- desc "hi", "day starter routine"
56
- def hi
57
- Autowow::Features::Vcs.hi
58
- end
59
-
60
- desc "hi!", "day starter routine for a new start"
61
- def hi!
62
- Autowow::Features::Vcs.hi!
63
- end
64
-
65
- desc "open", "opens project URL in browser"
66
- def open
67
- Autowow::Features::Vcs.open
68
- end
69
-
70
- desc "gem_clean", "cleans unused gems"
71
- def gem_clean
72
- Autowow::Features::Gem.gem_clean
73
- end
74
-
75
- desc "ruby_versions", "shows ruby versions in use"
76
- def ruby_versions
77
- Autowow::Features::Rbenv.ruby_versions
78
- end
79
-
80
- desc "greet", "shows report of repos"
81
- def greet
82
- Autowow::Features::Vcs.greet
83
- end
84
-
85
- desc "rubocop_parallel_autocorrect", "runs rubocop in parallel mode, autocorrects offenses on single thread"
86
- def rubocop_parallel_autocorrect
87
- Autowow::Features::Gem.rubocop_parallel_autocorrect
88
- end
89
-
90
- desc "exec", "runs command"
91
- def exec(*cmd)
92
- Autowow::Executor.pretty_with_output.run(cmd)
93
- end
94
-
95
- desc "bundle_exec", "runs command with `bundle exec` prefixed"
96
- def bundle_exec(*cmd)
97
- Autowow::Features::Gem.bundle_exec(cmd)
98
- end
99
-
100
- desc "db_migrate", "sets up DB via migration"
101
- def db_migrate
102
- Autowow::Features::Gem.db_migrate
103
- end
104
-
105
- desc "db_schema", "sets up DB via loading schema"
106
- def db_schema
107
- Autowow::Features::Gem.db_schema
108
- end
109
-
110
- desc "db_structure", "sets up DB via loading structure"
111
- def db_structure
112
- Autowow::Features::Gem.db_structure
113
- end
114
- end
115
- end
1
+ require "thor"
2
+
3
+ require_relative "executor"
4
+ require_relative "decorators/string_decorator"
5
+
6
+ require_relative "features/rbenv"
7
+ require_relative "features/gem"
8
+ require_relative "features/vcs"
9
+ require_relative "features/os"
10
+ require_relative "features/fs"
11
+
12
+ require_relative "commands/gem"
13
+
14
+ module Autowow
15
+ class CLI < Thor
16
+ map %w[bm] => :branch_merged
17
+ map %w[grls] => :gem_release
18
+ map %w[up] => :update_projects
19
+ map %w[cb] => :clear_branches
20
+ map %w[au] => :add_upstream
21
+ map %w[gc] => :gem_clean
22
+ map %w[rv] => :ruby_versions
23
+ map %w[gr] => :greet
24
+ map %w[rpa] => :rubocop_parallel_autocorrect
25
+ map %w[be] => :bundle_exec
26
+ map %w[dbm] => :db_migrate
27
+ map %w[dbsch] => :db_schema
28
+ map %w[dbstr] => :db_structure
29
+ map %w[fp] => :force_pull
30
+
31
+ desc "branch_merged", "clean working branch and return to master"
32
+ def branch_merged
33
+ Autowow::Features::Vcs.branch_merged
34
+ end
35
+
36
+ desc "gem_release", "release gem and return to master"
37
+ def gem_release(version_bump = nil)
38
+ Autowow::Features::Gem.gem_release(version_bump)
39
+ end
40
+
41
+ desc "update_projects", "updates idle projects"
42
+ def update_projects
43
+ Autowow::Features::Vcs.update_projects
44
+ end
45
+
46
+ desc "clear_branches", "removes unused branches"
47
+ def clear_branches
48
+ Autowow::Features::Vcs.clear_branches
49
+ end
50
+
51
+ desc "add_upstream", "adds upstream branch if available"
52
+ def add_upstream
53
+ Autowow::Features::Vcs.add_upstream
54
+ end
55
+
56
+ desc "hi", "day starter routine"
57
+ def hi
58
+ Autowow::Features::Vcs.hi
59
+ end
60
+
61
+ desc "hi!", "day starter routine for a new start"
62
+ def hi!
63
+ Autowow::Features::Vcs.hi!
64
+ end
65
+
66
+ desc "open", "opens project URL in browser"
67
+ def open
68
+ Autowow::Features::Vcs.open
69
+ end
70
+
71
+ desc "gem_clean", "cleans unused gems"
72
+ def gem_clean
73
+ Autowow::Features::Gem.gem_clean
74
+ end
75
+
76
+ desc "ruby_versions", "shows ruby versions in use"
77
+ def ruby_versions
78
+ Autowow::Features::Rbenv.ruby_versions
79
+ end
80
+
81
+ desc "greet", "shows report of repos"
82
+ def greet
83
+ Autowow::Features::Vcs.greet
84
+ end
85
+
86
+ desc "rubocop_parallel_autocorrect", "runs rubocop in parallel mode, autocorrects offenses on single thread"
87
+ def rubocop_parallel_autocorrect
88
+ Autowow::Features::Gem.rubocop_parallel_autocorrect
89
+ end
90
+
91
+ desc "exec", "runs command"
92
+ def exec(*cmd)
93
+ Autowow::Executor.pretty_with_output.run(cmd)
94
+ end
95
+
96
+ desc "bundle_exec", "runs command with `bundle exec` prefixed"
97
+ def bundle_exec(*cmd)
98
+ Autowow::Features::Gem.bundle_exec(cmd)
99
+ end
100
+
101
+ desc "db_migrate", "sets up DB via migration"
102
+ def db_migrate
103
+ Autowow::Features::Gem.db_migrate
104
+ end
105
+
106
+ desc "db_schema", "sets up DB via loading schema"
107
+ def db_schema
108
+ Autowow::Features::Gem.db_schema
109
+ end
110
+
111
+ desc "db_structure", "sets up DB via loading structure"
112
+ def db_structure
113
+ Autowow::Features::Gem.db_structure
114
+ end
115
+
116
+ desc "force_pull", "pulls branch from origin discarding local changes (including commits)"
117
+ def force_pull
118
+ Autowow::Features::Vcs.force_pull
119
+ end
120
+ end
121
+ end