gemsmith 15.0.0 → 15.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b93f0906b6ecc3a165d3afd1ff96476cae5796b1aa8a2ae821fbcc4411e79cc
4
- data.tar.gz: d5a430092023af8d54bd9f06e1cc8a9524998b247766e4bd35d73aa360d68f87
3
+ metadata.gz: 651c889805c8d1c0a08a214d6fa464ca66ee6ee8fa07c3ab6898eb017b325542
4
+ data.tar.gz: 2060034279e140f6706600e40a395c351cf3d6b121b295fda84b47ca17f564a1
5
5
  SHA512:
6
- metadata.gz: d89d23d15d231c203e3e990347f4345f35f8d2bc1194da76680f17a0a1a6793f659f98eb12dab1c485fcebd9e34dd1878cb11301889dfadbcf0659c0d6f89485
7
- data.tar.gz: 434780f815a7740bae28ebb2be05fc5a5a5707c752bc65c23ef82917e63da9e1a049b4f771db6da687a680e881055b39aaa2dec43998cefa5a32711490cebf37
6
+ metadata.gz: 531b44e972e654f5e5f53137ea5be17cb623df2da9200c572165612ec51368be7749ab4defb9d533a4063683d5d8db9568829ea120d4e1aefcdcc0e4ac28761b
7
+ data.tar.gz: e96043ee09c39cb908514dd0e047a45606022e592b361569baeaea2111865bbad88884efeff194874e7b9aae1921b0fbd5911362caae0d6f3a92625feaebb88f
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- ���u6FVl�˷���ޢ���\Y�tK��D��ٰdr* ۺ`йk�&����Q#����
2
- �.T;�xL
3
- lcY ���]�!?���Il�����_ �8���ZC���W��@m���
1
+ i&�%sT�Ȕ�(��y\�•�Ф������8MvxP6*�M�;��8&�,��`�p���6�#i��^>
2
+ �eK0�u�Ɂ�
3
+ |�͌=ȮYP *�u"����e�H`�8�tUɃ�w-�f��,�t�+Y)���J�]z��������`�^�+�왕����=F`�s� ���
@@ -94,7 +94,6 @@ For more gem generation options, type: `gemsmith --help --generate`
94
94
  [--circle-ci], [--no-circle-ci] # Add Circle CI support.
95
95
  [--cli], [--no-cli] # Add CLI support.
96
96
  [--engine], [--no-engine] # Add Rails Engine support.
97
- [--git-cop], [--no-git-cop] # Add Git Cop support. DEPRECATED: Use Git Lint instead.
98
97
  [--git-lint], [--no-git-lint] # Add Git Lint support.
99
98
  # Default: true
100
99
  [--git-hub], [--no-git-hub] # Add GitHub support.
@@ -1,9 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # TODO: Remove once the Pattern Matching feature is fully supported.
5
- Warning[:experimental] = false
6
-
7
4
  require "gemsmith"
8
5
  require "gemsmith/cli"
9
6
  require "gemsmith/identity"
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "gemsmith/identity"
4
- require "gemsmith/git"
5
4
  require "gemsmith/credentials"
6
5
  require "gemsmith/errors/base"
7
6
  require "gemsmith/errors/requirement_conversion"
@@ -19,7 +18,6 @@ require "gemsmith/generators/cli"
19
18
  require "gemsmith/generators/documentation"
20
19
  require "gemsmith/generators/gem"
21
20
  require "gemsmith/generators/git"
22
- require "gemsmith/generators/git_cop"
23
21
  require "gemsmith/generators/git_lint"
24
22
  require "gemsmith/generators/git_hub"
25
23
  require "gemsmith/generators/guard"
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "git_plus"
3
4
  require "thor"
4
5
  require "thor/actions"
5
6
  require "refinements/strings"
@@ -7,6 +8,7 @@ require "refinements/hashes"
7
8
  require "runcom"
8
9
  require "gemsmith/helpers/cli"
9
10
  require "gemsmith/helpers/template"
11
+ require "pathname"
10
12
 
11
13
  module Gemsmith
12
14
  # The Command Line Interface (CLI) for the gem.
@@ -23,27 +25,29 @@ module Gemsmith
23
25
 
24
26
  # Overwrites Thor's template source root.
25
27
  def self.source_root
26
- File.expand_path File.join(File.dirname(__FILE__), "templates")
28
+ Pathname(__dir__).join("templates").freeze
27
29
  end
28
30
 
29
31
  # rubocop:disable Metrics/MethodLength
30
32
  def self.configuration
33
+ repository = GitPlus::Repository.new
34
+
31
35
  Runcom::Config.new "#{Identity::NAME}/configuration.yml",
32
36
  defaults: {
33
37
  year: Time.now.year,
34
- github_user: Git.github_user,
38
+ github_user: repository.config_get("github.user"),
35
39
  gem: {
36
40
  label: "Undefined",
37
41
  name: "undefined",
38
42
  path: "undefined",
39
43
  class: "Undefined",
40
44
  platform: "Gem::Platform::RUBY",
41
- url: Git.github_url("undefined"),
45
+ url: "",
42
46
  license: "MIT"
43
47
  },
44
48
  author: {
45
- name: Git.config_value("user.name"),
46
- email: Git.config_value("user.email"),
49
+ name: repository.config_get("user.name"),
50
+ email: repository.config_get("user.email"),
47
51
  url: ""
48
52
  },
49
53
  organization: {
@@ -52,7 +56,7 @@ module Gemsmith
52
56
  },
53
57
  versions: {
54
58
  ruby: RUBY_VERSION,
55
- rails: "5.1"
59
+ rails: "6.1"
56
60
  },
57
61
  generate: {
58
62
  bundler_audit: true,
@@ -87,7 +91,6 @@ module Gemsmith
87
91
  Generators::Engine,
88
92
  Generators::Rspec,
89
93
  Generators::BundlerAudit,
90
- Generators::GitCop,
91
94
  Generators::GitLint,
92
95
  Generators::Reek,
93
96
  Generators::Guard,
@@ -127,10 +130,6 @@ module Gemsmith
127
130
  desc: "Add Rails Engine support.",
128
131
  type: :boolean,
129
132
  default: configuration.to_h.dig(:generate, :engine)
130
- method_option :git_cop,
131
- desc: "Add Git Cop support. DEPRECATED: Use Git Lint instead.",
132
- type: :boolean,
133
- default: false
134
133
  method_option :git_lint,
135
134
  desc: "Add Git Lint support.",
136
135
  type: :boolean,
@@ -232,6 +231,8 @@ module Gemsmith
232
231
  # :reek:FeatureEnvy
233
232
  # rubocop:disable Metrics/MethodLength
234
233
  def setup_configuration name:, options: {}
234
+ repository = GitPlus::Repository.new
235
+
235
236
  @configuration = configuration.to_h.merge(
236
237
  gem: {
237
238
  label: name.titleize,
@@ -239,7 +240,7 @@ module Gemsmith
239
240
  path: name.snakecase,
240
241
  class: name.camelcase,
241
242
  platform: "Gem::Platform::RUBY",
242
- url: Git.github_url(name),
243
+ url: %(https://github.com/#{repository.config_get "github.user"}/#{name}),
243
244
  license: "MIT"
244
245
  },
245
246
  generate: options.symbolize_keys
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "yaml"
4
- require "fileutils"
4
+ require "refinements/pathnames"
5
5
  require "gemsmith/authenticators/basic"
6
6
  require "gemsmith/authenticators/ruby_gems"
7
7
 
@@ -11,10 +11,12 @@ module Gemsmith
11
11
  DEFAULT_KEY = :rubygems_api_key
12
12
  DEFAULT_URL = "https://rubygems.org"
13
13
 
14
+ using Refinements::Pathnames
15
+
14
16
  attr_reader :key, :url
15
17
 
16
18
  def self.file_path
17
- File.join ENV.fetch("HOME"), ".gem", "credentials"
19
+ Pathname(ENV.fetch("HOME")).join ".gem", "credentials"
18
20
  end
19
21
 
20
22
  def self.authenticators
@@ -52,7 +54,7 @@ module Gemsmith
52
54
  attr_reader :credentials, :shell
53
55
 
54
56
  def exist?
55
- File.exist? self.class.file_path
57
+ self.class.file_path.exist?
56
58
  end
57
59
 
58
60
  def read
@@ -62,11 +64,11 @@ module Gemsmith
62
64
  end
63
65
 
64
66
  def write
65
- file_path = self.class.file_path
66
-
67
- FileUtils.mkdir_p File.dirname file_path
68
- File.open(file_path, "w") { |file| file << YAML.dump(update) }
69
- FileUtils.chmod 0o600, file_path
67
+ self.class
68
+ .file_path
69
+ .tap { |path| path.parent.make_path }
70
+ .write(YAML.dump(update))
71
+ .chmod 0o600
70
72
  end
71
73
 
72
74
  def update
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pathname"
3
4
  require "versionaire"
4
5
 
5
6
  module Gemsmith
@@ -26,7 +27,7 @@ module Gemsmith
26
27
 
27
28
  def initialize file_path
28
29
  @file_path = file_path
29
- @spec = self.class.specification.load file_path
30
+ @spec = self.class.specification.load file_path.to_s
30
31
  validate
31
32
  @version = Versionaire::Version @spec.version.to_s
32
33
  end
@@ -56,7 +57,7 @@ module Gemsmith
56
57
  end
57
58
 
58
59
  def package_path
59
- File.join "pkg", package_file_name
60
+ Pathname("pkg").join package_file_name
60
61
  end
61
62
 
62
63
  private
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pathname"
4
+
3
5
  module Gemsmith
4
6
  module Generators
5
7
  # Abstract class from which all generators inherit from.
6
8
  class Base
7
- LIB_ROOT = File.join("%gem_name%", "lib").freeze
8
- LIB_ROOT_GEM = File.join(LIB_ROOT, "%gem_path%").freeze
9
+ LIB_ROOT = Pathname("%gem_name%/lib").freeze
10
+ LIB_ROOT_GEM = LIB_ROOT.join("%gem_path%").freeze
9
11
 
10
12
  def self.run cli, configuration: {}
11
13
  new(cli, configuration: configuration).run
@@ -33,7 +35,7 @@ module Gemsmith
33
35
  end
34
36
 
35
37
  def gem_root
36
- File.join cli.destination_root, gem_name
38
+ Pathname(cli.destination_root).join gem_name
37
39
  end
38
40
 
39
41
  def template path
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/pathnames"
4
+
3
5
  module Gemsmith
4
6
  module Generators
5
7
  # Generates Bundler support.
6
8
  class Bundler < Base
9
+ using Refinements::Pathnames
10
+
7
11
  def run
8
- Dir.chdir gem_root do
12
+ gem_root.change_dir do
9
13
  cli.say_status :info, "Installing gem dependencies...", :green
10
14
  cli.run "bundle install"
11
15
  end
@@ -22,8 +22,7 @@ module Gemsmith
22
22
  end
23
23
 
24
24
  def update_readme
25
- File.join(gem_root, "README.md")
26
- .then { |readme| Tocer::Writer.new(readme).call }
25
+ gem_root.join("README.md").then { |path| Tocer::Writer.new(path).call }
27
26
  end
28
27
  end
29
28
  end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "open3"
4
+ require "refinements/pathnames"
4
5
 
5
6
  module Gemsmith
6
7
  module Generators
7
8
  # Generates Git support.
8
9
  class Git < Base
10
+ using Refinements::Pathnames
11
+
9
12
  def initialize cli, configuration: {}, shell: Open3
10
13
  super cli, configuration: configuration
11
14
  @shell = shell
@@ -31,7 +34,7 @@ module Gemsmith
31
34
  end
32
35
 
33
36
  def create_commit subject, body
34
- Dir.chdir gem_root do
37
+ gem_root.change_dir do
35
38
  shell.capture3 "git init"
36
39
  shell.capture3 "git add ."
37
40
  shell.capture3 %(git commit --all --no-verify --message "#{subject}" --message "#{body}")
@@ -5,7 +5,7 @@ module Gemsmith
5
5
  module Identity
6
6
  NAME = "gemsmith"
7
7
  LABEL = "Gemsmith"
8
- VERSION = "15.0.0"
8
+ VERSION = "15.1.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  URL = "https://www.alchemists.io/projects/gemsmith"
11
11
  end
@@ -1,19 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/ui/shell"
4
- require "fileutils"
4
+ require "refinements/pathnames"
5
5
 
6
6
  module Gemsmith
7
7
  module Rake
8
8
  # Provides gem build functionality. Meant to be wrapped in Rake tasks.
9
9
  class Builder
10
- def initialize shell: Bundler::UI::Shell.new, kernel: Kernel
10
+ using Refinements::Pathnames
11
+
12
+ def initialize root: Pathname("pkg"), shell: Bundler::UI::Shell.new, kernel: Kernel
13
+ @root = root
11
14
  @shell = shell
12
15
  @kernel = kernel
13
16
  end
14
17
 
15
18
  def clean
16
- FileUtils.rm_rf "pkg"
19
+ root.remove_tree
17
20
  shell.confirm "Cleaned gem artifacts."
18
21
  end
19
22
 
@@ -28,8 +31,8 @@ module Gemsmith
28
31
  path = gem_spec.package_path
29
32
 
30
33
  if kernel.system "gem build #{gem_spec.name}.gemspec"
31
- FileUtils.mkdir_p "pkg"
32
- FileUtils.mv gem_spec.package_file_name, path
34
+ root.make_path
35
+ Pathname(gem_spec.package_file_name).copy path
33
36
  shell.confirm "Built: #{path}."
34
37
  else
35
38
  shell.error "Unable to build: #{path}."
@@ -48,7 +51,7 @@ module Gemsmith
48
51
 
49
52
  private
50
53
 
51
- attr_reader :shell, :kernel
54
+ attr_reader :root, :shell, :kernel
52
55
  end
53
56
  end
54
57
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "milestoner"
4
+ require "refinements/pathnames"
4
5
  require "gemsmith/identity"
5
6
  require "gemsmith/credentials"
6
- require "gemsmith/git"
7
7
  require "gemsmith/cli"
8
8
 
9
9
  module Gemsmith
@@ -11,13 +11,15 @@ module Gemsmith
11
11
  # Provides gem release functionality. Meant to be wrapped in Rake tasks.
12
12
  # :reek:TooManyInstanceVariables
13
13
  class Publisher
14
+ using Refinements::Pathnames
15
+
14
16
  def self.gem_spec_path
15
- String Dir["#{Dir.pwd}/*.gemspec"].first
17
+ Pathname.pwd.files("*.gemspec").first.to_s
16
18
  end
17
19
 
18
20
  # rubocop:disable Metrics/ParameterLists
19
21
  # :reek:LongParameterList
20
- def initialize gem_spec: Gemsmith::Gem::Specification.new(self.class.gem_spec_path),
22
+ def initialize gem_spec: Gemsmith::Gem::Specification.new(self.class.gem_spec_path.to_s),
21
23
  gem_config: Gemsmith::CLI.configuration.to_h,
22
24
  credentials: Gemsmith::Credentials,
23
25
  publisher: Milestoner::Publisher.new,
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rake"
4
+ require "refinements/pathnames"
4
5
  require "tocer/rake/tasks"
5
6
  require "gemsmith/gem/specification"
6
7
  require "gemsmith/errors/base"
@@ -14,15 +15,17 @@ module Gemsmith
14
15
  class Tasks
15
16
  include ::Rake::DSL
16
17
 
18
+ using Refinements::Pathnames
19
+
17
20
  def self.default_gem_spec
18
- Dir.glob("#{Dir.pwd}/*.gemspec").first
21
+ Pathname.pwd.files("*.gemspec").first
19
22
  end
20
23
 
21
24
  def self.setup
22
25
  new.install
23
26
  end
24
27
 
25
- def initialize gem_spec: Gem::Specification.new(self.class.default_gem_spec),
28
+ def initialize gem_spec: Gem::Specification.new(self.class.default_gem_spec.to_s),
26
29
  builder: Rake::Builder.new,
27
30
  publisher: Rake::Publisher.new
28
31
  @gem_spec = gem_spec
@@ -11,9 +11,10 @@ Gem::Specification.new do |spec|
11
11
  spec.license = "MIT"
12
12
 
13
13
  spec.metadata = {
14
- "source_code_uri" => "<%= config.dig(:gem, :url) %>",
14
+ "bug_tracker_uri" => "<%= config.dig(:gem, :url) %>/issues",
15
15
  "changelog_uri" => "<%= config.dig(:gem, :url) %>/blob/master/CHANGES.md",
16
- "bug_tracker_uri" => "<%= config.dig(:gem, :url) %>/issues"
16
+ "documentation_uri" => "<%= config.dig(:gem, :url) %>",
17
+ "source_code_uri" => "<%= config.dig(:gem, :url) %>"
17
18
  }
18
19
 
19
20
  <%- if config.dig(:generate, :security) -%>
@@ -1,7 +1,9 @@
1
+ require "pathname"
2
+
1
3
  <% render_namespace do %>
2
4
  # Generator for installing new files.
3
5
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.join(File.dirname(__FILE__), "..", "templates")
6
+ source_root Pathname(__dir__).join("../templates")
5
7
 
6
8
  desc "Installs additional <%= config.dig(:gem, :label) %> resources."
7
9
  def install
@@ -1,7 +1,7 @@
1
1
  <% render_namespace do %>
2
2
  # Generator for updating existing files.
3
3
  class UpgradeGenerator < Rails::Generators::Base
4
- source_root File.join(File.dirname(__FILE__), "..", "templates")
4
+ source_root Pathname(__dir__).join("../templates")
5
5
 
6
6
  desc "Upgrades previously installed <%= config.dig(:gem, :label) %> resources."
7
7
  def upgrade
@@ -3,11 +3,14 @@
3
3
  require "spec_helper"
4
4
 
5
5
  RSpec.describe <%= config.dig(:gem, :class) %>::CLI do
6
+ subject(:cli) { described_class.start command_line }
7
+
8
+ include_context "with temporary directory"
9
+
6
10
  let(:options) { [] }
7
11
  let(:command_line) { Array(command).concat options }
8
- let(:cli) { described_class.start command_line }
9
12
 
10
- shared_examples_for "a config command", :temp_dir do
13
+ shared_examples_for "a config command" do
11
14
  context "with no options" do
12
15
  it "prints help text" do
13
16
  result = -> { cli }
@@ -1,4 +1,4 @@
1
- RSpec.shared_context "with temporary directory", :temp_dir do
1
+ RSpec.shared_context "with temporary directory" do
2
2
  let(:temp_dir) { Bundler.root.join "tmp", "rspec" }
3
3
 
4
4
  around do |example|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.0.0
4
+ version: 15.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,8 +28,22 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-12-30 00:00:00.000000000 Z
31
+ date: 2021-01-01 00:00:00.000000000 Z
32
32
  dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: git_plus
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.1'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.1'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: milestoner
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +191,6 @@ files:
177
191
  - lib/gemsmith/generators/engine.rb
178
192
  - lib/gemsmith/generators/gem.rb
179
193
  - lib/gemsmith/generators/git.rb
180
- - lib/gemsmith/generators/git_cop.rb
181
194
  - lib/gemsmith/generators/git_hub.rb
182
195
  - lib/gemsmith/generators/git_lint.rb
183
196
  - lib/gemsmith/generators/guard.rb
@@ -187,7 +200,6 @@ files:
187
200
  - lib/gemsmith/generators/rspec.rb
188
201
  - lib/gemsmith/generators/rubocop.rb
189
202
  - lib/gemsmith/generators/ruby.rb
190
- - lib/gemsmith/git.rb
191
203
  - lib/gemsmith/helpers/cli.rb
192
204
  - lib/gemsmith/helpers/template.rb
193
205
  - lib/gemsmith/identity.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Generators
5
- # Generates Git Cop support.
6
- class GitCop < Base
7
- def run
8
- return unless configuration.dig :generate, :git_cop
9
-
10
- warn "[DEPRECATION]: Git Cop is deprecated, use Git Lint instead."
11
- end
12
- end
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- # A thin wrapper to Git.
5
- # rubocop:disable Style/StaticClass
6
- class Git
7
- def self.config_value key
8
- `git config #{key}`.chomp
9
- end
10
-
11
- def self.github_user
12
- config_value "github.user"
13
- end
14
-
15
- def self.github_url project
16
- return "" if github_user.empty?
17
-
18
- "https://github.com/#{github_user}/#{project}"
19
- end
20
- end
21
- # rubocop:enable Style/StaticClass
22
- end