class Kamaze::Project::Tools::Gemspec::Packager

Provide a specialized packager, for “gemspec“ based projects

A “gemspec“ reader class is used, it can be retrieved through “project“ tools. This dynamic behaviour is the default one, but a specific reader or a “project“ can be defined during initialization.

Gem “specification“ (“Gem::Specification“) is retrieved through the gemspec reader. The gemspec reader can be dynamically retrieved through the project.

@abstract

Public Instance Methods

mutable_attributes() click to toggle source
# File lib/kamaze/project/tools/gemspec/packager.rb, line 26
def mutable_attributes
  [:gemspec_reader]
end
ready?() click to toggle source

Denote ready

Test to detect if specification seems to be complete, incomplete specification denotes a missing gemspec file

@return [Boolean]

# File lib/kamaze/project/tools/gemspec/packager.rb, line 36
def ready?
  gemspec_reader.read(Hash).include?(:full_name)
end

Protected Instance Methods

package_files() click to toggle source

Get package(d) files

@return [Array<String>]

# File lib/kamaze/project/tools/gemspec/packager.rb, line 45
def package_files
  # @formatter: off
  (gemspec_reader.read&.files).to_a.yield_self do |files| # rubocop:disable Style/RedundantParentheses
    Dir.glob(%w[*.gemspec Gemfile Gemfile.lock gems.rb gems.locked])
       .concat(files)
  end.sort
  # @formatter: on
end
setup() click to toggle source
# File lib/kamaze/project/tools/gemspec/packager.rb, line 54
def setup
  @gemspec_reader ||= Kamaze::Project.instance.tools.fetch(:gemspec_reader)

  self.verbose = false
  self.source_files = package_files if self.source_files.to_a.empty?
end
specification() click to toggle source

Get specification

@return [Gem::Specification]

# File lib/kamaze/project/tools/gemspec/packager.rb, line 64
def specification
  gemspec_reader.read
end