rsgem 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a421d0c4843d47689c5ed6abfee7a62bb80faf138511f040aa66e71b6bc0dead
4
- data.tar.gz: 23e38c5b9906a6ee8b154dba9457b3b33d0e230c967bfa51c28f641ca80774b1
3
+ metadata.gz: d9be3268462b4a245d95582cf3fd92c04a278d6aef6ee940b4448ab58fb63c89
4
+ data.tar.gz: 85e2e9a5ccfa17da1a7c2ff07501c816bcb28af2c9136c1f4bfd263505427c92
5
5
  SHA512:
6
- metadata.gz: 57b35be169c76d2033c7665a9a1b6b6ec4ef2ccca72860f2215c00a877364c6878a74e3e0094c867124d741582f2c6767b5a7abdc72e4f0b7294831a7899a1a3
7
- data.tar.gz: acef7494cdb8735d7ea885b399925b2545b999896c5a5d03e5d6d2245059f1d25460e0513c07f1590f14c1f7a1b2dbb4b602e16dfde0158c32b0ba298befb7ae
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
- ![build](https://github.com/rootstrap/rsgem/workflows/build/badge.svg)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/c22da1693543a6eac7e9/maintainability)](https://codeclimate.com/github/rootstrap/rsgem/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/c22da1693543a6eac7e9/test_coverage)](https://codeclimate.com/github/rootstrap/rsgem/test_coverage)
3
+ [![ci](https://github.com/rootstrap/rsgem/workflows/ci/badge.svg)](https://github.com/rootstrap/rsgem/actions?query=workflow%3Aci)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d956ef2db5e9d02db891/maintainability)](https://codeclimate.com/github/rootstrap/rsgem/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d956ef2db5e9d02db891/test_coverage)](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 application.
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 [CI_PROVIDER]
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
- argument :ci_provider, type: :string, required: false,
15
- desc: 'CI provider to use. '\
16
- "Available options are: #{ci_provider_options}. "\
17
- "Default option is 'travis'"
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 # Creates a new gem called 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], ci_provider: options[:ci_provider]).create
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
- `bundle gem #{context.gem_name}`
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
@@ -3,6 +3,6 @@
3
3
  module RSGem
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 1
6
+ PATCH = 2
7
7
  VERSION = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
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.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-04-29 00:00:00.000000000 Z
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