rsgem 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/rsgem.rb +7 -1
- data/lib/rsgem/ci_providers/base.rb +7 -9
- data/lib/rsgem/cli/commands/new.rb +1 -1
- data/lib/rsgem/colors.rb +24 -0
- data/lib/rsgem/constants.rb +1 -1
- data/lib/rsgem/context.rb +7 -5
- data/lib/rsgem/dependencies/base.rb +0 -2
- data/lib/rsgem/dependencies/rubocop.rb +1 -1
- data/lib/rsgem/errors/base.rb +8 -0
- data/lib/rsgem/errors/missing_gem_name.rb +8 -0
- data/lib/rsgem/gem.rb +18 -11
- data/lib/rsgem/support/rubocop.yml +4 -75
- data/lib/rsgem/tasks/add_ci_provider.rb +17 -0
- data/lib/rsgem/tasks/add_code_analysis.rb +2 -0
- data/lib/rsgem/tasks/add_dependency.rb +6 -0
- data/lib/rsgem/tasks/base.rb +8 -0
- data/lib/rsgem/tasks/bundle_dependencies.rb +4 -8
- data/lib/rsgem/tasks/clean_gemfile.rb +2 -1
- data/lib/rsgem/tasks/clean_gemspec.rb +1 -0
- data/lib/rsgem/tasks/create_gem.rb +11 -12
- data/lib/rsgem/tasks/ensure_author.rb +50 -0
- data/lib/rsgem/tasks/ignore_gemfile_lock.rb +2 -1
- data/lib/rsgem/tasks/output.rb +47 -0
- data/lib/rsgem/tasks/run_rubocop.rb +5 -8
- data/lib/rsgem/tasks/set_bundled_files.rb +2 -2
- data/lib/rsgem/tasks/set_license_file.rb +2 -2
- data/lib/rsgem/tasks/simple_cov_post_install.rb +1 -0
- data/lib/rsgem/version.rb +2 -2
- metadata +14 -23
- data/lib/rsgem/errors/missing_gem_name_error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2230b13e7a126b63e3b2503bc001a7dad6df076cf3df37c96dee446ee8cac146
|
4
|
+
data.tar.gz: 1c113a69a2f1bb553b75f2c6f8b60d6d4809d03180e1d5737eee2ffbe9d83ba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7541baa2b59e62c7fb9f021380b658edc5e19bb3e7ad121da3f8b244d29f56cb704596e8a6e64a06b17aec8595f07e2c0c2127d58bba307376849b14e2a21aac
|
7
|
+
data.tar.gz: d2bf91f10b17fa9f0e48418bffba8801be391f66a2b2368950dceb001bfa1f8e8d019d8e8af64c9be1a1f10850214b38a3f40616eade77ae67623d6893f57ae7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# master
|
2
2
|
|
3
|
+
# 1.0.0
|
4
|
+
|
5
|
+
* Using Github Actions as the default CI provider
|
6
|
+
* Dropping Ruby 2.4 support
|
7
|
+
* New CLI output format
|
8
|
+
* Add rubocop-rootstrap
|
9
|
+
|
10
|
+
*Juan Manuel Ramallo*
|
11
|
+
|
12
|
+
* Add placeholder `email` and `name` when no git user is set, issuing a warning while doing so.
|
13
|
+
* Add colors to output during gem creation.
|
14
|
+
|
15
|
+
*Jake Yesbeck*
|
16
|
+
|
3
17
|
# 0.4.0
|
4
18
|
|
5
19
|
* Cache bundler directory for 24hs in Github Actions
|
data/lib/rsgem.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'date'
|
4
|
+
require 'fileutils'
|
4
5
|
require 'rsgem/version'
|
5
6
|
require 'rsgem/gem'
|
6
|
-
require 'rsgem/errors/
|
7
|
+
require 'rsgem/errors/base'
|
8
|
+
require 'rsgem/errors/missing_gem_name'
|
7
9
|
require 'rsgem/ci_providers/base'
|
8
10
|
require 'rsgem/ci_providers/github_actions'
|
9
11
|
require 'rsgem/ci_providers/travis'
|
12
|
+
require 'rsgem/tasks/output'
|
10
13
|
require 'rsgem/tasks/base'
|
14
|
+
require 'rsgem/tasks/add_ci_provider'
|
11
15
|
require 'rsgem/tasks/add_code_analysis'
|
12
16
|
require 'rsgem/tasks/add_dependency'
|
13
17
|
require 'rsgem/tasks/clean_gemfile'
|
14
18
|
require 'rsgem/tasks/create_gem'
|
19
|
+
require 'rsgem/tasks/ensure_author'
|
15
20
|
require 'rsgem/tasks/ignore_gemfile_lock'
|
16
21
|
require 'rsgem/tasks/clean_gemspec'
|
17
22
|
require 'rsgem/tasks/bundle_dependencies'
|
@@ -26,6 +31,7 @@ require 'rsgem/dependencies/rspec'
|
|
26
31
|
require 'rsgem/dependencies/rubocop'
|
27
32
|
require 'rsgem/dependencies/simplecov'
|
28
33
|
require 'rsgem/constants'
|
34
|
+
require 'rsgem/colors'
|
29
35
|
require 'rsgem/context'
|
30
36
|
require 'dry/cli'
|
31
37
|
require 'rsgem/cli/commands/new'
|
@@ -5,7 +5,7 @@ module RSGem
|
|
5
5
|
class Base
|
6
6
|
attr_reader :config_file_destination, :config_file_source, :name, :display_name
|
7
7
|
|
8
|
-
def initialize(config_file_source: nil, config_file_destination: nil
|
8
|
+
def initialize(display_name:, name:, config_file_source: nil, config_file_destination: nil)
|
9
9
|
@config_file_source = config_file_source
|
10
10
|
@config_file_destination = config_file_destination
|
11
11
|
@display_name = display_name
|
@@ -16,19 +16,17 @@ module RSGem
|
|
16
16
|
remove_travis(context)
|
17
17
|
destination = "#{context.folder_path}/#{config_file_destination}"
|
18
18
|
|
19
|
-
File.delete(destination) if File.exist?(destination)
|
20
|
-
FileUtils.mkdir_p(File.dirname(destination))
|
21
|
-
File.open(destination, 'w') do |file|
|
19
|
+
::File.delete(destination) if ::File.exist?(destination)
|
20
|
+
::FileUtils.mkdir_p(::File.dirname(destination))
|
21
|
+
::File.open(destination, 'w') do |file|
|
22
22
|
file.puts config_file_source_content
|
23
23
|
end
|
24
|
-
|
25
|
-
puts "\t#{display_name} CI configuration added"
|
26
24
|
end
|
27
25
|
|
28
26
|
private
|
29
27
|
|
30
28
|
def config_file_source_content
|
31
|
-
File.read(config_file_source)
|
29
|
+
::File.read(config_file_source)
|
32
30
|
end
|
33
31
|
|
34
32
|
#
|
@@ -36,9 +34,9 @@ module RSGem
|
|
36
34
|
#
|
37
35
|
def remove_travis(context)
|
38
36
|
travis_path = "#{context.folder_path}/.travis.yml"
|
39
|
-
return unless File.exist?(travis_path)
|
37
|
+
return unless ::File.exist?(travis_path)
|
40
38
|
|
41
|
-
File.delete(travis_path)
|
39
|
+
::File.delete(travis_path)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
@@ -17,7 +17,7 @@ module RSGem
|
|
17
17
|
|
18
18
|
example [
|
19
19
|
'foo # Creates a new gem called foo',
|
20
|
-
'bar --ci=
|
20
|
+
'bar --ci=travis # Creates a new gem called bar, with Travis as the '\
|
21
21
|
'CI provider',
|
22
22
|
'foo_bar --bundler=--ext # Creates a new gem called foo_bar passing the --ext flag to '\
|
23
23
|
'bundler'
|
data/lib/rsgem/colors.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
class Colors
|
5
|
+
MAPPING = {
|
6
|
+
default: 39,
|
7
|
+
red: 31,
|
8
|
+
green: 32,
|
9
|
+
yellow: 33,
|
10
|
+
blue: 34,
|
11
|
+
white: 97
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def colorize(string, color)
|
16
|
+
"\e[#{color_code(color)}m#{string}\e[0m"
|
17
|
+
end
|
18
|
+
|
19
|
+
def color_code(color)
|
20
|
+
MAPPING[color] || MAPPING[:default]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/rsgem/constants.rb
CHANGED
data/lib/rsgem/context.rb
CHANGED
@@ -7,7 +7,7 @@ module RSGem
|
|
7
7
|
def initialize(options:)
|
8
8
|
@options = options
|
9
9
|
|
10
|
-
raise
|
10
|
+
raise Errors::MissingGemName unless options[:gem_name]
|
11
11
|
end
|
12
12
|
|
13
13
|
def bundler_options
|
@@ -16,10 +16,12 @@ module RSGem
|
|
16
16
|
|
17
17
|
def ci_provider
|
18
18
|
@ci_provider ||= begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
if (name = options[:ci_provider])
|
20
|
+
RSGem::Constants::CI_PROVIDERS.detect do |provider|
|
21
|
+
provider.name == name
|
22
|
+
end
|
23
|
+
else
|
24
|
+
RSGem::Constants::DEFAULT_CI_PROVIDER
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/rsgem/gem.rb
CHANGED
@@ -9,7 +9,9 @@ module RSGem
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def create
|
12
|
+
puts 'Creating gem...'
|
12
13
|
create_gem
|
14
|
+
ensure_author
|
13
15
|
add_code_analysis
|
14
16
|
add_dependencies
|
15
17
|
clean_gemfile
|
@@ -20,16 +22,17 @@ module RSGem
|
|
20
22
|
set_license_file
|
21
23
|
bundle_dependencies
|
22
24
|
run_rubocop
|
25
|
+
puts "#{context.gem_name} created"
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
26
29
|
|
27
30
|
def add_ci_provider
|
28
|
-
|
31
|
+
Tasks::AddCIProvider.new(context: context).call
|
29
32
|
end
|
30
33
|
|
31
34
|
def add_code_analysis
|
32
|
-
Tasks::AddCodeAnalysis.new(context: context).
|
35
|
+
Tasks::AddCodeAnalysis.new(context: context).call
|
33
36
|
end
|
34
37
|
|
35
38
|
def add_dependencies
|
@@ -40,16 +43,16 @@ module RSGem
|
|
40
43
|
Dependencies::Rubocop,
|
41
44
|
Dependencies::Simplecov
|
42
45
|
].each do |dependency|
|
43
|
-
Tasks::AddDependency.new(context: context, dependency: dependency).
|
46
|
+
Tasks::AddDependency.new(context: context, dependency: dependency).call
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
50
|
def clean_gemfile
|
48
|
-
Tasks::CleanGemfile.new(context: context).
|
51
|
+
Tasks::CleanGemfile.new(context: context).call
|
49
52
|
end
|
50
53
|
|
51
54
|
def clean_gemspec
|
52
|
-
Tasks::CleanGemspec.new(context: context).
|
55
|
+
Tasks::CleanGemspec.new(context: context).call
|
53
56
|
end
|
54
57
|
|
55
58
|
def context
|
@@ -57,27 +60,31 @@ module RSGem
|
|
57
60
|
end
|
58
61
|
|
59
62
|
def create_gem
|
60
|
-
Tasks::CreateGem.new(context: context).
|
63
|
+
Tasks::CreateGem.new(context: context).call
|
64
|
+
end
|
65
|
+
|
66
|
+
def ensure_author
|
67
|
+
Tasks::EnsureAuthor.new(context: context).call
|
61
68
|
end
|
62
69
|
|
63
70
|
def ignore_gemfile_lock
|
64
|
-
Tasks::IgnoreGemfileLock.new(context: context).
|
71
|
+
Tasks::IgnoreGemfileLock.new(context: context).call
|
65
72
|
end
|
66
73
|
|
67
74
|
def run_rubocop
|
68
|
-
Tasks::RunRubocop.new(context: context).
|
75
|
+
Tasks::RunRubocop.new(context: context).call
|
69
76
|
end
|
70
77
|
|
71
78
|
def bundle_dependencies
|
72
|
-
Tasks::BundleDependencies.new(context: context).
|
79
|
+
Tasks::BundleDependencies.new(context: context).call
|
73
80
|
end
|
74
81
|
|
75
82
|
def set_bundled_files
|
76
|
-
Tasks::SetBundledFiles.new(context: context).
|
83
|
+
Tasks::SetBundledFiles.new(context: context).call
|
77
84
|
end
|
78
85
|
|
79
86
|
def set_license_file
|
80
|
-
Tasks::SetLicenseFile.new(context: context).
|
87
|
+
Tasks::SetLicenseFile.new(context: context).call
|
81
88
|
end
|
82
89
|
end
|
83
90
|
end
|
@@ -1,79 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Layout/SpaceBeforeFirstArg:
|
5
|
-
Exclude:
|
6
|
-
|
7
|
-
Layout/SpaceAroundMethodCallOperator:
|
8
|
-
Enabled: true
|
9
|
-
|
10
|
-
Lint/AmbiguousBlockAssociation:
|
11
|
-
Exclude:
|
12
|
-
- spec/**/*
|
13
|
-
|
14
|
-
Lint/RaiseException:
|
15
|
-
Enabled: true
|
16
|
-
|
17
|
-
Lint/StructNewOverride:
|
18
|
-
Enabled: true
|
19
|
-
|
20
|
-
Metrics/AbcSize:
|
21
|
-
# The ABC size is a calculated magnitude, so this number can be an Integer or
|
22
|
-
# a Float.
|
23
|
-
Max: 15
|
24
|
-
|
25
|
-
Metrics/BlockLength:
|
26
|
-
CountComments: false
|
27
|
-
Max: 25
|
28
|
-
Exclude:
|
29
|
-
- '*.gemspec'
|
30
|
-
- config/**/*
|
31
|
-
- spec/**/*
|
32
|
-
ExcludedMethods:
|
33
|
-
- class_methods
|
34
|
-
|
35
|
-
Metrics/BlockNesting:
|
36
|
-
Max: 4
|
37
|
-
|
38
|
-
Metrics/ClassLength:
|
39
|
-
CountComments: false
|
40
|
-
Max: 200
|
41
|
-
|
42
|
-
# Avoid complex methods.
|
43
|
-
Metrics/CyclomaticComplexity:
|
44
|
-
Max: 7
|
45
|
-
|
46
|
-
Metrics/MethodLength:
|
47
|
-
CountComments: false
|
48
|
-
Max: 24
|
49
|
-
|
50
|
-
Metrics/ModuleLength:
|
51
|
-
CountComments: false
|
52
|
-
Max: 200
|
53
|
-
|
54
|
-
Layout/LineLength:
|
55
|
-
Max: 100
|
56
|
-
# To make it possible to copy or click on URIs in the code, we allow lines
|
57
|
-
# containing a URI to be longer than Max.
|
58
|
-
AllowURI: true
|
59
|
-
URISchemes:
|
60
|
-
- http
|
61
|
-
- https
|
62
|
-
|
63
|
-
Metrics/ParameterLists:
|
64
|
-
Max: 5
|
65
|
-
CountKeywordArgs: true
|
66
|
-
|
67
|
-
Metrics/PerceivedComplexity:
|
68
|
-
Max: 12
|
69
|
-
|
70
|
-
Style/ExponentialNotation:
|
71
|
-
Enabled: true
|
72
|
-
|
73
|
-
Style/FrozenStringLiteralComment:
|
74
|
-
Enabled: true
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-rootstrap:
|
3
|
+
- config/default_edge.yml
|
75
4
|
|
76
|
-
|
5
|
+
Gemspec/RequiredRubyVersion:
|
77
6
|
Enabled: false
|
78
7
|
|
79
8
|
Style/RescueModifier:
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class AddCIProvider < Base
|
6
|
+
OUTPUT = OutputStruct.new(name: :output_name)
|
7
|
+
|
8
|
+
def perform
|
9
|
+
context.ci_provider.install(context)
|
10
|
+
end
|
11
|
+
|
12
|
+
def output_name
|
13
|
+
"Add CI configuration for #{context.ci_provider.display_name}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
5
|
class AddDependency < Base
|
6
|
+
OUTPUT = OutputStruct.new(name: :output_name)
|
7
|
+
|
6
8
|
def perform
|
7
9
|
return if already_installed?
|
8
10
|
|
@@ -35,6 +37,10 @@ module RSGem
|
|
35
37
|
@gemspec_file ||= File.read(context.gemspec_path)
|
36
38
|
end
|
37
39
|
|
40
|
+
def output_name
|
41
|
+
"Install #{dependency.name.capitalize}"
|
42
|
+
end
|
43
|
+
|
38
44
|
def write_to_gemspec
|
39
45
|
File.open(context.gemspec_path, 'w') do |file|
|
40
46
|
file.puts gemspec_file
|
data/lib/rsgem/tasks/base.rb
CHANGED
@@ -7,12 +7,20 @@ module RSGem
|
|
7
7
|
# Child classes must implement the instance method +perform+.
|
8
8
|
#
|
9
9
|
class Base
|
10
|
+
include Output
|
11
|
+
|
10
12
|
attr_reader :context, :args
|
11
13
|
|
12
14
|
def initialize(context:, **args)
|
13
15
|
@context = context
|
14
16
|
@args = args
|
15
17
|
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
with_output do
|
21
|
+
perform
|
22
|
+
end
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -3,16 +3,12 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
5
|
class BundleDependencies < Base
|
6
|
-
|
7
|
-
puts "\tRunning bundle install:"
|
8
|
-
@output = `cd #{context.folder_path} && bundle`
|
9
|
-
puts "\t\t#{last_line}"
|
10
|
-
end
|
6
|
+
OUTPUT = OutputStruct.new(name: 'Bundle dependencies')
|
11
7
|
|
12
|
-
|
8
|
+
def perform
|
9
|
+
return if system("cd #{context.folder_path} && bundle", out: '/dev/null')
|
13
10
|
|
14
|
-
|
15
|
-
@output.split("\n").last
|
11
|
+
raise RSGem::Errors::Base
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
@@ -14,11 +14,12 @@ module RSGem
|
|
14
14
|
# https://github.com/rootstrap/tech-guides/blob/master/open-source/developing_gems.md#gemfilegemfilelockgemspec
|
15
15
|
#
|
16
16
|
class CleanGemfile < Base
|
17
|
+
OUTPUT = OutputStruct.new(name: 'Clean gemfile')
|
18
|
+
|
17
19
|
def perform
|
18
20
|
gemfile.gsub!(/gem .+\n/, '') # Remove all gem definitions
|
19
21
|
gemfile.sub!(/\n\z/, '') # Remove last new line character
|
20
22
|
write_to_gemfile
|
21
|
-
puts "\tGemfile cleaned"
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -3,14 +3,16 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
5
|
class CreateGem < Base
|
6
|
+
OUTPUT = OutputStruct.new(
|
7
|
+
name: 'Create gem',
|
8
|
+
success: :success_message
|
9
|
+
)
|
10
|
+
|
6
11
|
def perform
|
7
|
-
if system(shell_command)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
"Check bundler is installed in your system, or install it with `gem install bundler'"
|
12
|
-
exit false
|
13
|
-
end
|
12
|
+
return if system(shell_command, out: '/dev/null')
|
13
|
+
|
14
|
+
raise RSGem::Errors::Base, "Failed to run `bundle gem'. Check bundler is installed in "\
|
15
|
+
"your system or install it with `gem install bundler'.`"
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
@@ -19,11 +21,8 @@ module RSGem
|
|
19
21
|
context.bundler_options
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
|
24
|
-
"\tGem created",
|
25
|
-
("with options: #{bundler_options}" if bundler_options)
|
26
|
-
].compact.join(' ')
|
24
|
+
def success_message
|
25
|
+
"Gem created with bundler options: #{bundler_options}" if bundler_options
|
27
26
|
end
|
28
27
|
|
29
28
|
def shell_command
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class EnsureAuthor < Base
|
6
|
+
OUTPUT = OutputStruct.new(
|
7
|
+
name: 'Ensure author',
|
8
|
+
warning: :warning_message
|
9
|
+
)
|
10
|
+
TEMP_USERNAME = 'change_me'
|
11
|
+
TEMP_EMAIL = 'change_me@notanemail.com'
|
12
|
+
|
13
|
+
def perform
|
14
|
+
ensure_author
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def gemspec
|
20
|
+
@gemspec ||= File.read(context.gemspec_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def write_gemspec
|
24
|
+
File.write(context.gemspec_path, gemspec)
|
25
|
+
end
|
26
|
+
|
27
|
+
def ensure_author
|
28
|
+
return unless missing_git_user?
|
29
|
+
|
30
|
+
gemspec.gsub!(/spec.email\s+=\s+.+/,
|
31
|
+
"spec.email = ['#{TEMP_EMAIL}']")
|
32
|
+
|
33
|
+
gemspec.gsub!(/spec.authors\s+=\s+.+/,
|
34
|
+
"spec.authors = ['#{TEMP_USERNAME}']")
|
35
|
+
write_gemspec
|
36
|
+
end
|
37
|
+
|
38
|
+
def missing_git_user?
|
39
|
+
`git config user.email`.strip.empty? || `git config user.name`.strip.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def warning_message
|
43
|
+
return unless missing_git_user?
|
44
|
+
|
45
|
+
"No git user set. Setting #{TEMP_EMAIL} and #{TEMP_USERNAME} in gemspec, "\
|
46
|
+
'please change this before publishing your gem.'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -8,10 +8,11 @@ module RSGem
|
|
8
8
|
# https://github.com/rootstrap/tech-guides/blob/master/open-source/developing_gems.md#gemfilegemfilelockgemspec
|
9
9
|
#
|
10
10
|
class IgnoreGemfileLock < Base
|
11
|
+
OUTPUT = OutputStruct.new(name: 'Ignore gemfile.lock')
|
12
|
+
|
11
13
|
def perform
|
12
14
|
gitignore << "\nGemfile.lock\n"
|
13
15
|
write_to_gitignore
|
14
|
-
puts "\tGemfile.lock added to .gitignore"
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
#
|
6
|
+
# Structure to bundle all messages from a task
|
7
|
+
#
|
8
|
+
OutputStruct = Struct.new(:name, :success, :warning, keyword_init: true)
|
9
|
+
|
10
|
+
module Output
|
11
|
+
def with_output
|
12
|
+
yield
|
13
|
+
puts "\t#{Colors.colorize('[OK]', :green)} #{name}"
|
14
|
+
puts "\t#{success}" if success
|
15
|
+
puts "\t#{Colors.colorize('Warning: ', :yellow)} #{warning}" if warning
|
16
|
+
rescue RSGem::Errors::Base => e
|
17
|
+
puts "\t#{Colors.colorize('[X]', :red)} #{e.message}"
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def deduce_output(value)
|
24
|
+
case value
|
25
|
+
when String
|
26
|
+
value
|
27
|
+
when Symbol
|
28
|
+
send(value)
|
29
|
+
when Proc
|
30
|
+
value.call
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
deduce_output(self.class::OUTPUT.name || self.class.name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def success
|
39
|
+
deduce_output(self.class::OUTPUT.success)
|
40
|
+
end
|
41
|
+
|
42
|
+
def warning
|
43
|
+
deduce_output(self.class::OUTPUT.warning)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -3,16 +3,13 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
5
|
class RunRubocop < Base
|
6
|
-
|
7
|
-
puts "\tRubocop:"
|
8
|
-
@output = `cd #{context.folder_path} && bundle exec rubocop -a`
|
9
|
-
puts "\t\t#{last_line}"
|
10
|
-
end
|
6
|
+
OUTPUT = OutputStruct.new(name: 'Run rubocop')
|
11
7
|
|
12
|
-
|
8
|
+
def perform
|
9
|
+
return if system("cd #{context.folder_path} && bundle exec rubocop -A",
|
10
|
+
%i[out err] => '/dev/null')
|
13
11
|
|
14
|
-
|
15
|
-
@output.split("\n").last
|
12
|
+
raise RSGem::Errors::Base, 'Failed to run `bundle exec rubocop -A\''
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -12,6 +12,8 @@ module RSGem
|
|
12
12
|
# - lib/**/* (everything inside lib)
|
13
13
|
#
|
14
14
|
class SetBundledFiles < Base
|
15
|
+
OUTPUT = OutputStruct.new(name: 'Set bundled files')
|
16
|
+
|
15
17
|
def perform
|
16
18
|
# Explaining the regular expression:
|
17
19
|
# [spec.files][one or more white spaces][=][one or more white spaces][anything until "do"]
|
@@ -22,8 +24,6 @@ module RSGem
|
|
22
24
|
"spec.files = Dir['LICENSE.txt', 'README.md', 'lib/**/*']"
|
23
25
|
)
|
24
26
|
write
|
25
|
-
|
26
|
-
puts "\tGemspec files config updated"
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -3,14 +3,14 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
5
|
class SetLicenseFile < Base
|
6
|
+
OUTPUT = OutputStruct.new(name: 'Set license file')
|
7
|
+
|
6
8
|
def perform
|
7
9
|
license.gsub!(
|
8
10
|
/.*Copyright.*/,
|
9
11
|
"Copyright (c) #{Date.today.year} Rootstrap"
|
10
12
|
)
|
11
13
|
write
|
12
|
-
|
13
|
-
puts "\tLICENSE file updated"
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
data/lib/rsgem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Manuel Ramallo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.13.
|
33
|
+
version: 0.13.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.13.
|
40
|
+
version: 0.13.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 13.0.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: reek
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 5.6.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 5.6.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +67,19 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: 3.9.0
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
70
|
+
name: rubocop-rootstrap
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
75
|
+
version: 1.0.0
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
82
|
+
version: 1.0.0
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: simplecov
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +115,7 @@ files:
|
|
129
115
|
- lib/rsgem/cli/commands.rb
|
130
116
|
- lib/rsgem/cli/commands/new.rb
|
131
117
|
- lib/rsgem/cli/commands/version.rb
|
118
|
+
- lib/rsgem/colors.rb
|
132
119
|
- lib/rsgem/constants.rb
|
133
120
|
- lib/rsgem/context.rb
|
134
121
|
- lib/rsgem/dependencies/base.rb
|
@@ -137,13 +124,15 @@ files:
|
|
137
124
|
- lib/rsgem/dependencies/rspec.rb
|
138
125
|
- lib/rsgem/dependencies/rubocop.rb
|
139
126
|
- lib/rsgem/dependencies/simplecov.rb
|
140
|
-
- lib/rsgem/errors/
|
127
|
+
- lib/rsgem/errors/base.rb
|
128
|
+
- lib/rsgem/errors/missing_gem_name.rb
|
141
129
|
- lib/rsgem/gem.rb
|
142
130
|
- lib/rsgem/support/Rakefile
|
143
131
|
- lib/rsgem/support/github_actions.yml
|
144
132
|
- lib/rsgem/support/reek.yml
|
145
133
|
- lib/rsgem/support/rubocop.yml
|
146
134
|
- lib/rsgem/support/travis.yml
|
135
|
+
- lib/rsgem/tasks/add_ci_provider.rb
|
147
136
|
- lib/rsgem/tasks/add_code_analysis.rb
|
148
137
|
- lib/rsgem/tasks/add_dependency.rb
|
149
138
|
- lib/rsgem/tasks/base.rb
|
@@ -151,7 +140,9 @@ files:
|
|
151
140
|
- lib/rsgem/tasks/clean_gemfile.rb
|
152
141
|
- lib/rsgem/tasks/clean_gemspec.rb
|
153
142
|
- lib/rsgem/tasks/create_gem.rb
|
143
|
+
- lib/rsgem/tasks/ensure_author.rb
|
154
144
|
- lib/rsgem/tasks/ignore_gemfile_lock.rb
|
145
|
+
- lib/rsgem/tasks/output.rb
|
155
146
|
- lib/rsgem/tasks/run_rubocop.rb
|
156
147
|
- lib/rsgem/tasks/set_bundled_files.rb
|
157
148
|
- lib/rsgem/tasks/set_license_file.rb
|
@@ -178,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
169
|
- !ruby/object:Gem::Version
|
179
170
|
version: '0'
|
180
171
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.2.0
|
182
173
|
signing_key:
|
183
174
|
specification_version: 4
|
184
175
|
summary: Generating gems the Rootstrap way
|