Module: Gem::Micro

Extended by:
Utils
Defined in:
lib/microgem.rb,
lib/microgem/utils.rb,
lib/microgem/config.rb,
lib/microgem/source.rb,
lib/microgem/unpacker.rb,
lib/microgem/yamlable.rb,
lib/microgem/installer.rb,
lib/microgem/dependency.rb,
lib/microgem/downloader.rb,
lib/microgem/options_parser.rb,
lib/microgem/bare_specification.rb,
lib/microgem/bin_wrapper_emitter.rb,
lib/microgem/specification_emitter.rb

Defined Under Namespace

Modules: Utils Classes: BareSpecification, BinWrapperEmitter, Config, Downloader, GemSpecMissingError, Installer, OptionsParser, Source, SpecificationEmitter, Unpacker, YAMLable

Class Method Summary collapse

Methods included from Utils

config, ensure_dir, log, replace, tmpdir

Class Method Details

.installed_gem_dirnames(name = nil) ⇒ Object

Returns an array of all installed gems their directory names, optionally limited to gems matching the given name.



48
49
50
51
52
53
# File 'lib/microgem.rb', line 48

def installed_gem_dirnames(name = nil)
  directories = Dir.glob(File.join(Config.gems_path, '*')).sort
  directories = directories.map { |dir| File.basename(dir) }
  
  name.nil? ? directories : directories.select { |dirname| dirname =~ /^#{name}-[\d\.]+/ }
end

.run(arguments) ⇒ Object

The main run method which is used by the µgem script to perform the actions specified by the user.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/microgem.rb', line 25

def run(arguments)
  parser = OptionsParser.new
  parser.parse(arguments)
  Config.merge!(parser.options)
  
  case parser.command
  when 'install'
    gem_spec = Source.gem_spec(parser.arguments.first, Gem::Version[:version => '0'])
    gem_spec.install!
    
  when 'sources'
    case parser.arguments.first
    when 'update'
      Source.update!
      
    end
  else
    puts parser.banner
  end
end