rsgem 0.1.0 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +1 -1
- data/README.md +17 -6
- data/lib/rsgem.rb +6 -0
- data/lib/rsgem/ci_providers/base.rb +11 -0
- data/lib/rsgem/cli/commands/new.rb +15 -12
- data/lib/rsgem/context.rb +12 -0
- data/lib/rsgem/dependencies/base.rb +10 -6
- data/lib/rsgem/dependencies/simplecov.rb +2 -1
- data/lib/rsgem/gem.rb +22 -9
- data/lib/rsgem/support/rubocop.yml +12 -0
- data/lib/rsgem/tasks/add_code_analysis.rb +2 -8
- data/lib/rsgem/tasks/add_dependency.rb +6 -9
- data/lib/rsgem/tasks/base.rb +18 -0
- data/lib/rsgem/tasks/bundle_dependencies.rb +19 -0
- data/lib/rsgem/tasks/clean_gemfile.rb +2 -8
- data/lib/rsgem/tasks/clean_gemspec.rb +2 -8
- data/lib/rsgem/tasks/create_gem.rb +37 -0
- data/lib/rsgem/tasks/ignore_gemfile_lock.rb +2 -8
- data/lib/rsgem/tasks/run_rubocop.rb +2 -8
- data/lib/rsgem/tasks/set_bundled_files.rb +2 -8
- data/lib/rsgem/tasks/set_license_file.rb +29 -0
- data/lib/rsgem/tasks/simple_cov_post_install.rb +37 -0
- data/lib/rsgem/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad493db4ccc39d3453ed0f1dd0d4e4b594809c2c322b8907c187e53a01e33425
|
4
|
+
data.tar.gz: 59855a9d4d9efc2d2d28849bbafa1f172634ae5e9d84ec88d2569e7c0698bdb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 223a728398f98c295676a9ca723149a01668df08582eb686fb4cebac2255cf12ce0e632406836f6d784db474c515523d85fab30049ef142530400280ca7a1e7e
|
7
|
+
data.tar.gz: 26ffb08fe6eea56092c4eca3976e42cde0bdeac8ac3f14b9e15a9aa737819ca4e5430f6f1826c19a29352dc5eb910ecb8679fa33568b4dfa14ca898e4f375237
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# master
|
2
|
+
|
3
|
+
# 0.3.0
|
4
|
+
|
5
|
+
* Add task to replace system user name in LICENSE.txt with Rootstrap name
|
6
|
+
|
7
|
+
*Juan Francisco Ferrari*
|
8
|
+
|
9
|
+
# 0.2.0
|
10
|
+
|
11
|
+
* Add default configuration for simplecov in spec_helper.rb
|
12
|
+
|
13
|
+
* Display an error message if bundler failed to run or is not present in the system
|
14
|
+
|
15
|
+
*Juan Manuel Ramallo*
|
16
|
+
|
17
|
+
# 0.1.3
|
18
|
+
|
19
|
+
* Fix gem creation task on Linux
|
20
|
+
|
21
|
+
*Juan Aparicio*
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# `rsgem` - Rootstrap's gem generator
|
2
2
|
|
3
|
-
](https://badge.fury.io/rb/rsgem)
|
4
|
+
[](https://github.com/rootstrap/rsgem/actions?query=workflow%3Aci)
|
5
|
+
[](https://codeclimate.com/github/rootstrap/rsgem/maintainability)
|
6
|
+
[](https://codeclimate.com/github/rootstrap/rsgem/test_coverage)
|
6
7
|
|
7
8
|
`rsgem` is a tool to help you start developing gems with the defaults we use at Rootstrap.
|
8
9
|
|
@@ -11,12 +12,12 @@
|
|
11
12
|
$ gem install rsgem
|
12
13
|
|
13
14
|
We highly suggest to not include `rsgem` in your Gemfile.
|
14
|
-
`rsgem` is not a library, and should not affect the dependency tree of your
|
15
|
+
`rsgem` is not a library, and should not affect the dependency tree of your project.
|
15
16
|
|
16
17
|
## Usage
|
17
18
|
|
18
19
|
```
|
19
|
-
rsgem new NAME
|
20
|
+
rsgem new NAME
|
20
21
|
```
|
21
22
|
|
22
23
|
RSGem will solve the following tasks for you:
|
@@ -48,10 +49,20 @@ rsgem new foo
|
|
48
49
|
Creates a new gem called foo.
|
49
50
|
|
50
51
|
```
|
51
|
-
rsgem new bar github_actions
|
52
|
+
rsgem new bar --ci=github_actions
|
52
53
|
```
|
53
54
|
Creates a new gem called bar that uses Github Actions as the CI provider.
|
54
55
|
|
56
|
+
```
|
57
|
+
rsgem new foo_bar --bundler=--ext
|
58
|
+
```
|
59
|
+
Creates a new gem called foo_bar and passes the [--ext flag to bundler](https://bundler.io/v2.0/man/bundle-gem.1.html#OPTIONS).
|
60
|
+
|
61
|
+
```
|
62
|
+
rsgem new bar_foo --bundler='--several --flags'
|
63
|
+
```
|
64
|
+
Creates a new gem passing several flags to bundler.
|
65
|
+
|
55
66
|
#### Help
|
56
67
|
|
57
68
|
```
|
data/lib/rsgem.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'date'
|
3
4
|
require 'rsgem/version'
|
4
5
|
require 'rsgem/gem'
|
5
6
|
require 'rsgem/errors/missing_gem_name_error'
|
6
7
|
require 'rsgem/ci_providers/base'
|
7
8
|
require 'rsgem/ci_providers/github_actions'
|
8
9
|
require 'rsgem/ci_providers/travis'
|
10
|
+
require 'rsgem/tasks/base'
|
9
11
|
require 'rsgem/tasks/add_code_analysis'
|
10
12
|
require 'rsgem/tasks/add_dependency'
|
11
13
|
require 'rsgem/tasks/clean_gemfile'
|
14
|
+
require 'rsgem/tasks/create_gem'
|
12
15
|
require 'rsgem/tasks/ignore_gemfile_lock'
|
13
16
|
require 'rsgem/tasks/clean_gemspec'
|
17
|
+
require 'rsgem/tasks/bundle_dependencies'
|
14
18
|
require 'rsgem/tasks/run_rubocop'
|
15
19
|
require 'rsgem/tasks/set_bundled_files'
|
20
|
+
require 'rsgem/tasks/set_license_file'
|
21
|
+
require 'rsgem/tasks/simple_cov_post_install'
|
16
22
|
require 'rsgem/dependencies/base'
|
17
23
|
require 'rsgem/dependencies/rake'
|
18
24
|
require 'rsgem/dependencies/reek'
|
@@ -13,6 +13,7 @@ module RSGem
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def install(context)
|
16
|
+
remove_travis(context)
|
16
17
|
destination = "#{context.folder_path}/#{config_file_destination}"
|
17
18
|
|
18
19
|
File.delete(destination) if File.exist?(destination)
|
@@ -29,6 +30,16 @@ module RSGem
|
|
29
30
|
def config_file_source_content
|
30
31
|
File.read(config_file_source)
|
31
32
|
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# `bundle gem` adds travis by default
|
36
|
+
#
|
37
|
+
def remove_travis(context)
|
38
|
+
travis_path = "#{context.folder_path}/.travis.yml"
|
39
|
+
return unless File.exist?(travis_path)
|
40
|
+
|
41
|
+
File.delete(travis_path)
|
42
|
+
end
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
@@ -4,26 +4,29 @@ module RSGem
|
|
4
4
|
module CLI
|
5
5
|
module Commands
|
6
6
|
class New < Dry::CLI::Command
|
7
|
-
def self.ci_provider_options
|
8
|
-
RSGem::Constants::CI_PROVIDERS.map { |ci| "'#{ci.name}'" }.join(', ')
|
9
|
-
end
|
10
|
-
|
11
7
|
desc 'Create a new gem'
|
12
8
|
|
13
9
|
argument :gem_name, type: :string, required: true, desc: 'Name of your new gem'
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
option :bundler, type: :string,
|
11
|
+
default: nil,
|
12
|
+
desc: 'Bundler options to use'
|
13
|
+
option :ci, type: :string,
|
14
|
+
default: RSGem::Constants::DEFAULT_CI_PROVIDER.name,
|
15
|
+
values: RSGem::Constants::CI_PROVIDERS.map(&:name),
|
16
|
+
desc: 'CI provider to use'
|
18
17
|
|
19
18
|
example [
|
20
|
-
'foo
|
21
|
-
'bar github_actions # Creates a new gem called bar, with GitHub Actions as the '\
|
22
|
-
'CI provider'
|
19
|
+
'foo # Creates a new gem called foo',
|
20
|
+
'bar --ci=github_actions # Creates a new gem called bar, with GitHub Actions as the '\
|
21
|
+
'CI provider',
|
22
|
+
'foo_bar --bundler=--ext # Creates a new gem called foo_bar passing the --ext flag to '\
|
23
|
+
'bundler'
|
23
24
|
]
|
24
25
|
|
25
26
|
def call(**options)
|
26
|
-
RSGem::Gem.new(gem_name: options[:gem_name],
|
27
|
+
RSGem::Gem.new(gem_name: options[:gem_name],
|
28
|
+
ci_provider: options[:ci],
|
29
|
+
bundler_options: options[:bundler]).create
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
data/lib/rsgem/context.rb
CHANGED
@@ -10,6 +10,10 @@ module RSGem
|
|
10
10
|
raise MissingGemNameError unless options[:gem_name]
|
11
11
|
end
|
12
12
|
|
13
|
+
def bundler_options
|
14
|
+
@bundler_options ||= options[:bundler_options]
|
15
|
+
end
|
16
|
+
|
13
17
|
def ci_provider
|
14
18
|
@ci_provider ||= begin
|
15
19
|
return RSGem::Constants::DEFAULT_CI_PROVIDER unless (name = options[:ci_provider])
|
@@ -32,6 +36,10 @@ module RSGem
|
|
32
36
|
"#{folder_path}/#{gem_name}.gemspec"
|
33
37
|
end
|
34
38
|
|
39
|
+
def license_path
|
40
|
+
"#{folder_path}/LICENSE.txt"
|
41
|
+
end
|
42
|
+
|
35
43
|
def folder_path
|
36
44
|
`pwd`.sub("\n", '/') + gem_name
|
37
45
|
end
|
@@ -43,5 +51,9 @@ module RSGem
|
|
43
51
|
def rakefile_path
|
44
52
|
"#{folder_path}/Rakefile"
|
45
53
|
end
|
54
|
+
|
55
|
+
def spec_helper_path
|
56
|
+
"#{folder_path}/spec/spec_helper.rb"
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
@@ -3,14 +3,16 @@
|
|
3
3
|
module RSGem
|
4
4
|
module Dependencies
|
5
5
|
class Base
|
6
|
-
attr_reader :config_file_destination, :config_file_source, :mode, :name, :
|
6
|
+
attr_reader :config_file_destination, :config_file_source, :mode, :name, :post_install_task,
|
7
|
+
:version
|
7
8
|
|
8
|
-
def initialize(
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@mode = mode # Either `development' or `runtime'
|
9
|
+
def initialize(name:, **args)
|
10
|
+
@config_file_source = args[:config_file_source]
|
11
|
+
@config_file_destination = args[:config_file_destination]
|
12
|
+
@mode = args[:mode] || 'development' # Either `development' or `runtime'
|
13
13
|
@name = name
|
14
|
+
@post_install_task = args[:post_install_task]
|
15
|
+
version = args[:version]
|
14
16
|
@version = version ? "'#{version}'" : nil
|
15
17
|
end
|
16
18
|
|
@@ -21,6 +23,8 @@ module RSGem
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
26
|
+
post_install_task&.new(context: context)&.perform
|
27
|
+
|
24
28
|
puts "\t#{name.capitalize} installed"
|
25
29
|
end
|
26
30
|
|
@@ -4,6 +4,7 @@ module RSGem
|
|
4
4
|
module Dependencies
|
5
5
|
# This is the latest stable version working correctly with codeclimate
|
6
6
|
# 0.18+ does not work currently https://github.com/codeclimate/test-reporter/issues/413
|
7
|
-
Simplecov = Base.new(name: 'simplecov', version: '~> 0.17.1'
|
7
|
+
Simplecov = Base.new(name: 'simplecov', version: '~> 0.17.1',
|
8
|
+
post_install_task: RSGem::Tasks::SimpleCovPostInstall)
|
8
9
|
end
|
9
10
|
end
|
data/lib/rsgem/gem.rb
CHANGED
@@ -9,8 +9,7 @@ module RSGem
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def create
|
12
|
-
|
13
|
-
|
12
|
+
create_gem
|
14
13
|
add_code_analysis
|
15
14
|
add_dependencies
|
16
15
|
clean_gemfile
|
@@ -18,6 +17,8 @@ module RSGem
|
|
18
17
|
add_ci_provider
|
19
18
|
clean_gemspec
|
20
19
|
set_bundled_files
|
20
|
+
set_license_file
|
21
|
+
bundle_dependencies
|
21
22
|
run_rubocop
|
22
23
|
end
|
23
24
|
|
@@ -28,7 +29,7 @@ module RSGem
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def add_code_analysis
|
31
|
-
Tasks::AddCodeAnalysis.new(context: context).
|
32
|
+
Tasks::AddCodeAnalysis.new(context: context).perform
|
32
33
|
end
|
33
34
|
|
34
35
|
def add_dependencies
|
@@ -39,32 +40,44 @@ module RSGem
|
|
39
40
|
Dependencies::Rubocop,
|
40
41
|
Dependencies::Simplecov
|
41
42
|
].each do |dependency|
|
42
|
-
Tasks::AddDependency.new(context: context, dependency: dependency).
|
43
|
+
Tasks::AddDependency.new(context: context, dependency: dependency).perform
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
def clean_gemfile
|
47
|
-
Tasks::CleanGemfile.new(context: context).
|
48
|
+
Tasks::CleanGemfile.new(context: context).perform
|
48
49
|
end
|
49
50
|
|
50
51
|
def clean_gemspec
|
51
|
-
Tasks::CleanGemspec.new(context: context).
|
52
|
+
Tasks::CleanGemspec.new(context: context).perform
|
52
53
|
end
|
53
54
|
|
54
55
|
def context
|
55
56
|
@context ||= Context.new(options: options)
|
56
57
|
end
|
57
58
|
|
59
|
+
def create_gem
|
60
|
+
Tasks::CreateGem.new(context: context).perform
|
61
|
+
end
|
62
|
+
|
58
63
|
def ignore_gemfile_lock
|
59
|
-
Tasks::IgnoreGemfileLock.new(context: context).
|
64
|
+
Tasks::IgnoreGemfileLock.new(context: context).perform
|
60
65
|
end
|
61
66
|
|
62
67
|
def run_rubocop
|
63
|
-
Tasks::RunRubocop.new(context: context).
|
68
|
+
Tasks::RunRubocop.new(context: context).perform
|
69
|
+
end
|
70
|
+
|
71
|
+
def bundle_dependencies
|
72
|
+
Tasks::BundleDependencies.new(context: context).perform
|
64
73
|
end
|
65
74
|
|
66
75
|
def set_bundled_files
|
67
|
-
Tasks::SetBundledFiles.new(context: context).
|
76
|
+
Tasks::SetBundledFiles.new(context: context).perform
|
77
|
+
end
|
78
|
+
|
79
|
+
def set_license_file
|
80
|
+
Tasks::SetLicenseFile.new(context: context).perform
|
68
81
|
end
|
69
82
|
end
|
70
83
|
end
|
@@ -4,10 +4,19 @@ Style/Documentation:
|
|
4
4
|
Layout/SpaceBeforeFirstArg:
|
5
5
|
Exclude:
|
6
6
|
|
7
|
+
Layout/SpaceAroundMethodCallOperator:
|
8
|
+
Enabled: true
|
9
|
+
|
7
10
|
Lint/AmbiguousBlockAssociation:
|
8
11
|
Exclude:
|
9
12
|
- spec/**/*
|
10
13
|
|
14
|
+
Lint/RaiseException:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Lint/StructNewOverride:
|
18
|
+
Enabled: true
|
19
|
+
|
11
20
|
Metrics/AbcSize:
|
12
21
|
# The ABC size is a calculated magnitude, so this number can be an Integer or
|
13
22
|
# a Float.
|
@@ -58,6 +67,9 @@ Metrics/ParameterLists:
|
|
58
67
|
Metrics/PerceivedComplexity:
|
59
68
|
Max: 12
|
60
69
|
|
70
|
+
Style/ExponentialNotation:
|
71
|
+
Enabled: true
|
72
|
+
|
61
73
|
Style/FrozenStringLiteralComment:
|
62
74
|
Enabled: true
|
63
75
|
|
@@ -2,14 +2,8 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class AddCodeAnalysis
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(context:)
|
9
|
-
@context = context
|
10
|
-
end
|
11
|
-
|
12
|
-
def add
|
5
|
+
class AddCodeAnalysis < Base
|
6
|
+
def perform
|
13
7
|
File.open(context.rakefile_path, 'w') do |file|
|
14
8
|
file.puts rakefile
|
15
9
|
end
|
@@ -2,15 +2,8 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class AddDependency
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(context:, dependency:)
|
9
|
-
@context = context
|
10
|
-
@dependency = dependency
|
11
|
-
end
|
12
|
-
|
13
|
-
def add
|
5
|
+
class AddDependency < Base
|
6
|
+
def perform
|
14
7
|
return if already_installed?
|
15
8
|
|
16
9
|
add_dependency
|
@@ -34,6 +27,10 @@ module RSGem
|
|
34
27
|
text.compact.join(', ')
|
35
28
|
end
|
36
29
|
|
30
|
+
def dependency
|
31
|
+
args[:dependency]
|
32
|
+
end
|
33
|
+
|
37
34
|
def gemspec_file
|
38
35
|
@gemspec_file ||= File.read(context.gemspec_path)
|
39
36
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
#
|
6
|
+
# Base class for task objects.
|
7
|
+
# Child classes must implement the instance method +perform+.
|
8
|
+
#
|
9
|
+
class Base
|
10
|
+
attr_reader :context, :args
|
11
|
+
|
12
|
+
def initialize(context:, **args)
|
13
|
+
@context = context
|
14
|
+
@args = args
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class BundleDependencies < Base
|
6
|
+
def perform
|
7
|
+
puts "\tRunning bundle install:"
|
8
|
+
@output = `cd #{context.folder_path} && bundle`
|
9
|
+
puts "\t\t#{last_line}"
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def last_line
|
15
|
+
@output.split("\n").last
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -13,14 +13,8 @@ module RSGem
|
|
13
13
|
#
|
14
14
|
# https://github.com/rootstrap/tech-guides/blob/master/open-source/developing_gems.md#gemfilegemfilelockgemspec
|
15
15
|
#
|
16
|
-
class CleanGemfile
|
17
|
-
|
18
|
-
|
19
|
-
def initialize(context:)
|
20
|
-
@context = context
|
21
|
-
end
|
22
|
-
|
23
|
-
def clean
|
16
|
+
class CleanGemfile < Base
|
17
|
+
def perform
|
24
18
|
gemfile.gsub!(/gem .+\n/, '') # Remove all gem definitions
|
25
19
|
gemfile.sub!(/\n\z/, '') # Remove last new line character
|
26
20
|
write_to_gemfile
|
@@ -2,16 +2,10 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class CleanGemspec
|
6
|
-
attr_reader :context
|
7
|
-
|
5
|
+
class CleanGemspec < Base
|
8
6
|
KEYS_TO_EMPTY = %w[summary description homepage].freeze
|
9
7
|
|
10
|
-
def
|
11
|
-
@context = context
|
12
|
-
end
|
13
|
-
|
14
|
-
def clean
|
8
|
+
def perform
|
15
9
|
comment_metadata!
|
16
10
|
empty_keys!
|
17
11
|
write
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class CreateGem < Base
|
6
|
+
def perform
|
7
|
+
if system(shell_command)
|
8
|
+
puts message
|
9
|
+
else
|
10
|
+
puts "Failed to run `bundle gem'. "\
|
11
|
+
"Check bundler is installed in your system, or install it with `gem install bundler'"
|
12
|
+
exit false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def bundler_options
|
19
|
+
context.bundler_options
|
20
|
+
end
|
21
|
+
|
22
|
+
def message
|
23
|
+
[
|
24
|
+
"\tGem created",
|
25
|
+
("with options: #{bundler_options}" if bundler_options)
|
26
|
+
].compact.join(' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def shell_command
|
30
|
+
[
|
31
|
+
"bundle gem #{context.gem_name} --test=rspec --coc --mit",
|
32
|
+
bundler_options
|
33
|
+
].compact.join(' ')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -7,14 +7,8 @@ module RSGem
|
|
7
7
|
#
|
8
8
|
# https://github.com/rootstrap/tech-guides/blob/master/open-source/developing_gems.md#gemfilegemfilelockgemspec
|
9
9
|
#
|
10
|
-
class IgnoreGemfileLock
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(context:)
|
14
|
-
@context = context
|
15
|
-
end
|
16
|
-
|
17
|
-
def ignore
|
10
|
+
class IgnoreGemfileLock < Base
|
11
|
+
def perform
|
18
12
|
gitignore << "\nGemfile.lock\n"
|
19
13
|
write_to_gitignore
|
20
14
|
puts "\tGemfile.lock added to .gitignore"
|
@@ -2,14 +2,8 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class RunRubocop
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(context:)
|
9
|
-
@context = context
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
5
|
+
class RunRubocop < Base
|
6
|
+
def perform
|
13
7
|
puts "\tRubocop:"
|
14
8
|
@output = `cd #{context.folder_path} && bundle exec rubocop -a`
|
15
9
|
puts "\t\t#{last_line}"
|
@@ -11,14 +11,8 @@ module RSGem
|
|
11
11
|
# - README.md
|
12
12
|
# - lib/**/* (everything inside lib)
|
13
13
|
#
|
14
|
-
class SetBundledFiles
|
15
|
-
|
16
|
-
|
17
|
-
def initialize(context:)
|
18
|
-
@context = context
|
19
|
-
end
|
20
|
-
|
21
|
-
def set
|
14
|
+
class SetBundledFiles < Base
|
15
|
+
def perform
|
22
16
|
# Explaining the regular expression:
|
23
17
|
# [spec.files][one or more white spaces][=][one or more white spaces][anything until "do"]
|
24
18
|
# [new line][anything until new line]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class SetLicenseFile < Base
|
6
|
+
def perform
|
7
|
+
license.gsub!(
|
8
|
+
/.*Copyright.*/,
|
9
|
+
"Copyright (c) #{Date.today.year} Rootstrap"
|
10
|
+
)
|
11
|
+
write
|
12
|
+
|
13
|
+
puts "\tLICENSE file updated"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def license
|
19
|
+
@license ||= File.read(context.license_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def write
|
23
|
+
File.open(context.license_path, 'w') do |file|
|
24
|
+
file.puts license
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class SimpleCovPostInstall < Base
|
6
|
+
def perform
|
7
|
+
spec_helper.sub!("require \"#{gem_name}\"", <<~RUBY)
|
8
|
+
require 'simplecov'
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/'
|
12
|
+
end
|
13
|
+
|
14
|
+
require '#{gem_name}'
|
15
|
+
RUBY
|
16
|
+
|
17
|
+
write
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def gem_name
|
23
|
+
context.gem_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def spec_helper
|
27
|
+
@spec_helper ||= File.read(context.spec_helper_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def write
|
31
|
+
File.open(context.spec_helper_path, 'w') do |file|
|
32
|
+
file.puts spec_helper
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
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: 0.3.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-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.82.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.82.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +116,7 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- CHANGELOG.md
|
119
120
|
- LICENSE.txt
|
120
121
|
- README.md
|
121
122
|
- bin/console
|
@@ -145,11 +146,16 @@ files:
|
|
145
146
|
- lib/rsgem/support/travis.yml
|
146
147
|
- lib/rsgem/tasks/add_code_analysis.rb
|
147
148
|
- lib/rsgem/tasks/add_dependency.rb
|
149
|
+
- lib/rsgem/tasks/base.rb
|
150
|
+
- lib/rsgem/tasks/bundle_dependencies.rb
|
148
151
|
- lib/rsgem/tasks/clean_gemfile.rb
|
149
152
|
- lib/rsgem/tasks/clean_gemspec.rb
|
153
|
+
- lib/rsgem/tasks/create_gem.rb
|
150
154
|
- lib/rsgem/tasks/ignore_gemfile_lock.rb
|
151
155
|
- lib/rsgem/tasks/run_rubocop.rb
|
152
156
|
- lib/rsgem/tasks/set_bundled_files.rb
|
157
|
+
- lib/rsgem/tasks/set_license_file.rb
|
158
|
+
- lib/rsgem/tasks/simple_cov_post_install.rb
|
153
159
|
- lib/rsgem/version.rb
|
154
160
|
homepage: https://github.com/rootstrap/rsgem
|
155
161
|
licenses:
|