rsgem 0.1.1 → 0.1.2
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/README.md +16 -6
- data/lib/rsgem/ci_providers/base.rb +11 -0
- data/lib/rsgem/cli/commands/new.rb +15 -12
- data/lib/rsgem/context.rb +4 -0
- data/lib/rsgem/gem.rb +5 -2
- data/lib/rsgem/tasks/create_gem.rb +38 -0
- data/lib/rsgem/version.rb +1 -1
- data/lib/rsgem.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9be3268462b4a245d95582cf3fd92c04a278d6aef6ee940b4448ab58fb63c89
|
4
|
+
data.tar.gz: 85e2e9a5ccfa17da1a7c2ff07501c816bcb28af2c9136c1f4bfd263505427c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50caf0245b1c10042d870b7cb505f1eade8737ee41dd7fa6f6519e4865835d36457c7628fbd29a91f6b647c45be2d66dbe955b9b8005f5049de396c1c9773916
|
7
|
+
data.tar.gz: f00640edd086e97fd7ccfe251190138d4957b756f0a62a6440a762600e8f21181dc206a6cd14ad9b1e0039de2d84875f08ac48a82e7e558dc383c24d97967533
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# `rsgem` - Rootstrap's gem generator
|
2
2
|
|
3
|
-
](https://github.com/rootstrap/rsgem/actions?query=workflow%3Aci)
|
4
|
+
[](https://codeclimate.com/github/rootstrap/rsgem/maintainability)
|
5
|
+
[](https://codeclimate.com/github/rootstrap/rsgem/test_coverage)
|
6
6
|
|
7
7
|
`rsgem` is a tool to help you start developing gems with the defaults we use at Rootstrap.
|
8
8
|
|
@@ -11,12 +11,12 @@
|
|
11
11
|
$ gem install rsgem
|
12
12
|
|
13
13
|
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
|
14
|
+
`rsgem` is not a library, and should not affect the dependency tree of your project.
|
15
15
|
|
16
16
|
## Usage
|
17
17
|
|
18
18
|
```
|
19
|
-
rsgem new NAME
|
19
|
+
rsgem new NAME
|
20
20
|
```
|
21
21
|
|
22
22
|
RSGem will solve the following tasks for you:
|
@@ -48,10 +48,20 @@ rsgem new foo
|
|
48
48
|
Creates a new gem called foo.
|
49
49
|
|
50
50
|
```
|
51
|
-
rsgem new bar github_actions
|
51
|
+
rsgem new bar --ci=github_actions
|
52
52
|
```
|
53
53
|
Creates a new gem called bar that uses Github Actions as the CI provider.
|
54
54
|
|
55
|
+
```
|
56
|
+
rsgem new foo_bar --bundler=--ext
|
57
|
+
```
|
58
|
+
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).
|
59
|
+
|
60
|
+
```
|
61
|
+
rsgem new bar_foo --bundler='--several --flags'
|
62
|
+
```
|
63
|
+
Creates a new gem passing several flags to bundler.
|
64
|
+
|
55
65
|
#### Help
|
56
66
|
|
57
67
|
```
|
@@ -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])
|
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
|
@@ -56,6 +55,10 @@ module RSGem
|
|
56
55
|
@context ||= Context.new(options: options)
|
57
56
|
end
|
58
57
|
|
58
|
+
def create_gem
|
59
|
+
Tasks::CreateGem.new(context: context).create
|
60
|
+
end
|
61
|
+
|
59
62
|
def ignore_gemfile_lock
|
60
63
|
Tasks::IgnoreGemfileLock.new(context: context).ignore
|
61
64
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSGem
|
4
|
+
module Tasks
|
5
|
+
class CreateGem
|
6
|
+
attr_reader :context
|
7
|
+
|
8
|
+
def initialize(context:)
|
9
|
+
@context = context
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
`#{shell_command}`
|
14
|
+
puts message
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def bundler_options
|
20
|
+
context.bundler_options
|
21
|
+
end
|
22
|
+
|
23
|
+
def message
|
24
|
+
[
|
25
|
+
"\tGem created",
|
26
|
+
("with options: #{bundler_options}" if bundler_options)
|
27
|
+
].compact.join(' ')
|
28
|
+
end
|
29
|
+
|
30
|
+
def shell_command
|
31
|
+
[
|
32
|
+
"bundle gem #{context.gem_name}",
|
33
|
+
bundler_options
|
34
|
+
].compact.join(' ')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rsgem/version.rb
CHANGED
data/lib/rsgem.rb
CHANGED
@@ -9,6 +9,7 @@ require 'rsgem/ci_providers/travis'
|
|
9
9
|
require 'rsgem/tasks/add_code_analysis'
|
10
10
|
require 'rsgem/tasks/add_dependency'
|
11
11
|
require 'rsgem/tasks/clean_gemfile'
|
12
|
+
require 'rsgem/tasks/create_gem'
|
12
13
|
require 'rsgem/tasks/ignore_gemfile_lock'
|
13
14
|
require 'rsgem/tasks/clean_gemspec'
|
14
15
|
require 'rsgem/tasks/bundle_dependencies'
|
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.1.
|
4
|
+
version: 0.1.2
|
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-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/rsgem/tasks/bundle_dependencies.rb
|
149
149
|
- lib/rsgem/tasks/clean_gemfile.rb
|
150
150
|
- lib/rsgem/tasks/clean_gemspec.rb
|
151
|
+
- lib/rsgem/tasks/create_gem.rb
|
151
152
|
- lib/rsgem/tasks/ignore_gemfile_lock.rb
|
152
153
|
- lib/rsgem/tasks/run_rubocop.rb
|
153
154
|
- lib/rsgem/tasks/set_bundled_files.rb
|