Module: Nugem

Defined in:
lib/nugem/cli.rb,
lib/util.rb,
lib/nugem.rb,
lib/nugem/git.rb,
lib/nugem/version.rb,
lib/nugem/repository.rb,
lib/nugem/cli/cli_gem.rb,
lib/nugem/cli/cli_rails.rb,
lib/nugem/cli/cli_jekyll.rb,
lib/nugem/cli/jekyll_demo.rb

Overview

Nugem::Repository contains informations about the git repository and the git user

Defined Under Namespace

Classes: Cli, Repository

Constant Summary collapse

VERSION =
'0.8.3'.freeze

Class Method Summary collapse

Class Method Details

.camel_case(str) ⇒ Object



2
3
4
# File 'lib/util.rb', line 2

def self.camel_case(str)
  Thor::Util.camel_case str.tr('-', '_')
end

.current_spec(file) ⇒ Object

Returns Gem::Specification of gem that file points into, or nil if not called from a gem.

Parameters:

  • file

    must be a fully qualified file name

Returns:

  • Gem::Specification of gem that file points into, or nil if not called from a gem



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/util.rb', line 16

def self.current_spec(file)
  return nil unless File.file?(file)

  searcher = if Gem::Specification.respond_to?(:find)
               Gem::Specification
             elsif Gem.respond_to?(:searcher)
               Gem.searcher.init_gemspecs
             end

  searcher&.find do |spec|
    file.start_with? spec.full_gem_path
  end
end

.dest_root(gem_name) ⇒ Object

Returns Path to the generated gem.

Returns:

  • Path to the generated gem



8
9
10
# File 'lib/nugem.rb', line 8

def self.dest_root(gem_name)
  File.expand_path "generated/#{gem_name}"
end

.expand_env(str) ⇒ Object



6
7
8
9
10
# File 'lib/util.rb', line 6

def self.expand_env(str)
  str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
    ENV.fetch(Regexp.last_match(1), nil)
  end
end

.gem_path(file) ⇒ Object



30
31
32
33
# File 'lib/util.rb', line 30

def self.gem_path(file)
  spec = self.current_spec(file)
  spec&.full_gem_path
end

.template_directoryObject



35
36
37
# File 'lib/util.rb', line 35

def self.template_directory
  File.join gem_path(__FILE__), 'templates'
end