rsgem 0.1.3 → 0.2.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 +8 -0
- data/lib/rsgem.rb +2 -0
- data/lib/rsgem/context.rb +4 -0
- data/lib/rsgem/dependencies/base.rb +10 -6
- data/lib/rsgem/dependencies/simplecov.rb +2 -1
- data/lib/rsgem/gem.rb +9 -9
- 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 +10 -11
- 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/simple_cov_post_install.rb +37 -0
- data/lib/rsgem/version.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 118dc51b1e8cef7481205fc789643bbb5e90e033eb84a20f18b20df73bca1efc
|
4
|
+
data.tar.gz: bc24898da5bd9b1047a67d24349e72aa6e7432aa15f040c2981e42790376991b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d280d17fb9f125345d21e4ebb1d1fbfc445ca69b063fff66c2c80a00c0c89767fe3b5afeec2f025b92a0136e7ab3df7642133d0abf6db692f8b6148a2824bbee
|
7
|
+
data.tar.gz: a90e71674a3613857b19867b79787ffdc41783103a517a776be9ec4a35ac159e19bbc8f2a81d50acd2ba91f325a4b69032ee9b8459e80c442f532765c46e8d1b
|
data/CHANGELOG.md
CHANGED
data/lib/rsgem.rb
CHANGED
@@ -6,6 +6,7 @@ require 'rsgem/errors/missing_gem_name_error'
|
|
6
6
|
require 'rsgem/ci_providers/base'
|
7
7
|
require 'rsgem/ci_providers/github_actions'
|
8
8
|
require 'rsgem/ci_providers/travis'
|
9
|
+
require 'rsgem/tasks/base'
|
9
10
|
require 'rsgem/tasks/add_code_analysis'
|
10
11
|
require 'rsgem/tasks/add_dependency'
|
11
12
|
require 'rsgem/tasks/clean_gemfile'
|
@@ -15,6 +16,7 @@ require 'rsgem/tasks/clean_gemspec'
|
|
15
16
|
require 'rsgem/tasks/bundle_dependencies'
|
16
17
|
require 'rsgem/tasks/run_rubocop'
|
17
18
|
require 'rsgem/tasks/set_bundled_files'
|
19
|
+
require 'rsgem/tasks/simple_cov_post_install'
|
18
20
|
require 'rsgem/dependencies/base'
|
19
21
|
require 'rsgem/dependencies/rake'
|
20
22
|
require 'rsgem/dependencies/reek'
|
data/lib/rsgem/context.rb
CHANGED
@@ -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
@@ -28,7 +28,7 @@ module RSGem
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_code_analysis
|
31
|
-
Tasks::AddCodeAnalysis.new(context: context).
|
31
|
+
Tasks::AddCodeAnalysis.new(context: context).perform
|
32
32
|
end
|
33
33
|
|
34
34
|
def add_dependencies
|
@@ -39,16 +39,16 @@ module RSGem
|
|
39
39
|
Dependencies::Rubocop,
|
40
40
|
Dependencies::Simplecov
|
41
41
|
].each do |dependency|
|
42
|
-
Tasks::AddDependency.new(context: context, dependency: dependency).
|
42
|
+
Tasks::AddDependency.new(context: context, dependency: dependency).perform
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def clean_gemfile
|
47
|
-
Tasks::CleanGemfile.new(context: context).
|
47
|
+
Tasks::CleanGemfile.new(context: context).perform
|
48
48
|
end
|
49
49
|
|
50
50
|
def clean_gemspec
|
51
|
-
Tasks::CleanGemspec.new(context: context).
|
51
|
+
Tasks::CleanGemspec.new(context: context).perform
|
52
52
|
end
|
53
53
|
|
54
54
|
def context
|
@@ -56,23 +56,23 @@ module RSGem
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def create_gem
|
59
|
-
Tasks::CreateGem.new(context: context).
|
59
|
+
Tasks::CreateGem.new(context: context).perform
|
60
60
|
end
|
61
61
|
|
62
62
|
def ignore_gemfile_lock
|
63
|
-
Tasks::IgnoreGemfileLock.new(context: context).
|
63
|
+
Tasks::IgnoreGemfileLock.new(context: context).perform
|
64
64
|
end
|
65
65
|
|
66
66
|
def run_rubocop
|
67
|
-
Tasks::RunRubocop.new(context: context).
|
67
|
+
Tasks::RunRubocop.new(context: context).perform
|
68
68
|
end
|
69
69
|
|
70
70
|
def bundle_dependencies
|
71
|
-
Tasks::BundleDependencies.new(context: context).
|
71
|
+
Tasks::BundleDependencies.new(context: context).perform
|
72
72
|
end
|
73
73
|
|
74
74
|
def set_bundled_files
|
75
|
-
Tasks::SetBundledFiles.new(context: context).
|
75
|
+
Tasks::SetBundledFiles.new(context: context).perform
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -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
|
@@ -2,16 +2,15 @@
|
|
2
2
|
|
3
3
|
module RSGem
|
4
4
|
module Tasks
|
5
|
-
class CreateGem
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
puts message
|
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
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
@@ -29,7 +28,7 @@ module RSGem
|
|
29
28
|
|
30
29
|
def shell_command
|
31
30
|
[
|
32
|
-
"bundle gem #{context.gem_name}",
|
31
|
+
"bundle gem #{context.gem_name} --test=rspec --coc --mit",
|
33
32
|
bundler_options
|
34
33
|
].compact.join(' ')
|
35
34
|
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,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.2.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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/rsgem/support/travis.yml
|
147
147
|
- lib/rsgem/tasks/add_code_analysis.rb
|
148
148
|
- lib/rsgem/tasks/add_dependency.rb
|
149
|
+
- lib/rsgem/tasks/base.rb
|
149
150
|
- lib/rsgem/tasks/bundle_dependencies.rb
|
150
151
|
- lib/rsgem/tasks/clean_gemfile.rb
|
151
152
|
- lib/rsgem/tasks/clean_gemspec.rb
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- lib/rsgem/tasks/ignore_gemfile_lock.rb
|
154
155
|
- lib/rsgem/tasks/run_rubocop.rb
|
155
156
|
- lib/rsgem/tasks/set_bundled_files.rb
|
157
|
+
- lib/rsgem/tasks/simple_cov_post_install.rb
|
156
158
|
- lib/rsgem/version.rb
|
157
159
|
homepage: https://github.com/rootstrap/rsgem
|
158
160
|
licenses:
|