rsgem 0.1.1 → 0.4.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 +27 -0
- data/LICENSE.txt +1 -1
- data/README.md +17 -6
- data/lib/rsgem.rb +5 -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 +18 -10
- data/lib/rsgem/support/github_actions.yml +21 -3
- 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 +2 -8
- 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 +2 -2
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ad88cbeee0dce25fc811974b5f22e451988013b120e8ff7bd070ebbc57d984d
|
4
|
+
data.tar.gz: 8b5af2dfea737d332e119abf472047a39357f33c604d57f4f731822d6f9bd77b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf866d216669b2cefd81efe24eb24801d776683ad49736bd8d377d924476eb8cf358232636a638a7acbc36ef498d978fd8e0333c21a56edc2244e9d6b88d1ad
|
7
|
+
data.tar.gz: ed0d4cd9c34b6ab9a85be7d4a81a260bc842b4ced79b3563c4c0c46c15a49721d0ab3b99ecf06442e47d7179bffdf72540457a9afd441b6b18ad253ebffa880d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# master
|
2
|
+
|
3
|
+
# 0.4.0
|
4
|
+
|
5
|
+
* Cache bundler directory for 24hs in Github Actions
|
6
|
+
|
7
|
+
*Martín Rubí*
|
8
|
+
|
9
|
+
# 0.3.0
|
10
|
+
|
11
|
+
* Add task to replace system user name in LICENSE.txt with Rootstrap name
|
12
|
+
|
13
|
+
*Juan Francisco Ferrari*
|
14
|
+
|
15
|
+
# 0.2.0
|
16
|
+
|
17
|
+
* Add default configuration for simplecov in spec_helper.rb
|
18
|
+
|
19
|
+
* Display an error message if bundler failed to run or is not present in the system
|
20
|
+
|
21
|
+
*Juan Manuel Ramallo*
|
22
|
+
|
23
|
+
# 0.1.3
|
24
|
+
|
25
|
+
* Fix gem creation task on Linux
|
26
|
+
|
27
|
+
*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,19 +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'
|
14
17
|
require 'rsgem/tasks/bundle_dependencies'
|
15
18
|
require 'rsgem/tasks/run_rubocop'
|
16
19
|
require 'rsgem/tasks/set_bundled_files'
|
20
|
+
require 'rsgem/tasks/set_license_file'
|
21
|
+
require 'rsgem/tasks/simple_cov_post_install'
|
17
22
|
require 'rsgem/dependencies/base'
|
18
23
|
require 'rsgem/dependencies/rake'
|
19
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,7 @@ module RSGem
|
|
18
17
|
add_ci_provider
|
19
18
|
clean_gemspec
|
20
19
|
set_bundled_files
|
20
|
+
set_license_file
|
21
21
|
bundle_dependencies
|
22
22
|
run_rubocop
|
23
23
|
end
|
@@ -29,7 +29,7 @@ module RSGem
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def add_code_analysis
|
32
|
-
Tasks::AddCodeAnalysis.new(context: context).
|
32
|
+
Tasks::AddCodeAnalysis.new(context: context).perform
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_dependencies
|
@@ -40,36 +40,44 @@ module RSGem
|
|
40
40
|
Dependencies::Rubocop,
|
41
41
|
Dependencies::Simplecov
|
42
42
|
].each do |dependency|
|
43
|
-
Tasks::AddDependency.new(context: context, dependency: dependency).
|
43
|
+
Tasks::AddDependency.new(context: context, dependency: dependency).perform
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def clean_gemfile
|
48
|
-
Tasks::CleanGemfile.new(context: context).
|
48
|
+
Tasks::CleanGemfile.new(context: context).perform
|
49
49
|
end
|
50
50
|
|
51
51
|
def clean_gemspec
|
52
|
-
Tasks::CleanGemspec.new(context: context).
|
52
|
+
Tasks::CleanGemspec.new(context: context).perform
|
53
53
|
end
|
54
54
|
|
55
55
|
def context
|
56
56
|
@context ||= Context.new(options: options)
|
57
57
|
end
|
58
58
|
|
59
|
+
def create_gem
|
60
|
+
Tasks::CreateGem.new(context: context).perform
|
61
|
+
end
|
62
|
+
|
59
63
|
def ignore_gemfile_lock
|
60
|
-
Tasks::IgnoreGemfileLock.new(context: context).
|
64
|
+
Tasks::IgnoreGemfileLock.new(context: context).perform
|
61
65
|
end
|
62
66
|
|
63
67
|
def run_rubocop
|
64
|
-
Tasks::RunRubocop.new(context: context).
|
68
|
+
Tasks::RunRubocop.new(context: context).perform
|
65
69
|
end
|
66
70
|
|
67
71
|
def bundle_dependencies
|
68
|
-
Tasks::BundleDependencies.new(context: context).
|
72
|
+
Tasks::BundleDependencies.new(context: context).perform
|
69
73
|
end
|
70
74
|
|
71
75
|
def set_bundled_files
|
72
|
-
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
|
73
81
|
end
|
74
82
|
end
|
75
83
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name: ci
|
2
2
|
|
3
|
-
on: push
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
build:
|
@@ -15,6 +15,11 @@ jobs:
|
|
15
15
|
uses: actions/setup-ruby@v1
|
16
16
|
with:
|
17
17
|
ruby-version: ${{ matrix.ruby_version }}
|
18
|
+
- name: Calculate variable dynamic values
|
19
|
+
id: dynamic_values
|
20
|
+
run: |
|
21
|
+
echo "::set-output name=installed_ruby_version::$(ruby -e 'print RUBY_VERSION')"
|
22
|
+
echo "::set-output name=cacheTimeAnchor::$(ruby -e 'require %Q{date}; cacheExpirationSeconds = 60*60*24; print (Time.now.to_i / cacheExpirationSeconds)')"
|
18
23
|
- name: Download CodeClimate reporter
|
19
24
|
run: |
|
20
25
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
@@ -22,12 +27,25 @@ jobs:
|
|
22
27
|
./cc-test-reporter before-build
|
23
28
|
env:
|
24
29
|
CC_TEST_REPORTER_ID: get_a_test_reporter_id_from_code_climate
|
25
|
-
- name:
|
30
|
+
- name: Install and config bundler
|
26
31
|
run: |
|
27
32
|
gem install bundler:1.17.3
|
28
|
-
|
33
|
+
- name: Generate 'Gemfile.lock' before caching gems
|
34
|
+
run: |
|
35
|
+
bundle lock --update
|
36
|
+
- uses: actions/cache@v2
|
37
|
+
with:
|
38
|
+
path: vendor/bundle
|
39
|
+
key: ${{ runner.os }}-ruby_v${{ steps.dynamic_values.outputs.installed_ruby_version }}-time_${{steps.dynamic_values.outputs.cacheTimeAnchor}}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
40
|
+
- name: Install dependencies
|
41
|
+
run: |
|
42
|
+
bundle config set path 'vendor/bundle'
|
29
43
|
bundle install --jobs 4 --retry 3
|
44
|
+
- name: Run code analysis
|
45
|
+
run: |
|
30
46
|
bundle exec rake code_analysis
|
47
|
+
- name: Run tests
|
48
|
+
run: |
|
31
49
|
bundle exec rspec
|
32
50
|
- name: Report to CodeClimate
|
33
51
|
run: |
|
@@ -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
|
@@ -2,14 +2,8 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class BundleDependencies
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(context:)
|
9
|
-
@context = context
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
5
|
+
class BundleDependencies < Base
|
6
|
+
def perform
|
13
7
|
puts "\tRunning bundle install:"
|
14
8
|
@output = `cd #{context.folder_path} && bundle`
|
15
9
|
puts "\t\t#{last_line}"
|
@@ -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.4.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-09-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,12 +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
|
148
150
|
- lib/rsgem/tasks/bundle_dependencies.rb
|
149
151
|
- lib/rsgem/tasks/clean_gemfile.rb
|
150
152
|
- lib/rsgem/tasks/clean_gemspec.rb
|
153
|
+
- lib/rsgem/tasks/create_gem.rb
|
151
154
|
- lib/rsgem/tasks/ignore_gemfile_lock.rb
|
152
155
|
- lib/rsgem/tasks/run_rubocop.rb
|
153
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
|
154
159
|
- lib/rsgem/version.rb
|
155
160
|
homepage: https://github.com/rootstrap/rsgem
|
156
161
|
licenses:
|