Class: GemRepo

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/gemrepo.rb

Instance Method Summary collapse

Instance Method Details

#gem_repositoryObject



39
40
41
42
43
44
45
46
# File 'lib/gemrepo.rb', line 39

def gem_repository
  @gem_repository ||= (
    dir = File.join(settings.gemdir, "gems")
    FileUtils.mkdir_p(dir) unless File.directory?(dir)

    dir
  )
end

#indexerObject



48
49
50
# File 'lib/gemrepo.rb', line 48

def indexer
  @indexer = Gem::Indexer.new settings.gemdir
end

#pull_specObject



20
21
22
23
24
25
26
# File 'lib/gemrepo.rb', line 20

def pull_spec
  format = Gem::Format.from_io request.body
  @spec = format.spec
rescue Exception => ex
  puts ex.message
  false
end

#reindexObject



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

def reindex
  indexer.generate_index
end

#saveObject



28
29
30
31
32
33
# File 'lib/gemrepo.rb', line 28

def save
  path = "#{gem_repository}/#{@spec.original_name}.gem"
  File.open(path, "wb") { |io|
    io << request.body.string
  }
end