Module: AllGems

Defined in:
lib/allgems.rb,
lib/allgems/App.rb,
lib/allgems/Runner.rb,
lib/allgems/Specer.rb,
lib/allgems/Indexer.rb,
lib/allgems/GemWorker.rb,
lib/allgems/ViewHelpers.rb,
lib/allgems/IndexBuilder.rb

Defined Under Namespace

Modules: ViewHelpers Classes: App, GemWorker, IndexBuilder, Indexer, Runner, Specer

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.allgemsObject

Returns the value of attribute allgems.



4
5
6
# File 'lib/allgems.rb', line 4

def allgems
  @allgems
end

.data_directoryObject

Returns the value of attribute data_directory.



4
5
6
# File 'lib/allgems.rb', line 4

def data_directory
  @data_directory
end

.dbObject

Returns the value of attribute db.



4
5
6
# File 'lib/allgems.rb', line 4

def db
  @db
end

.loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/allgems.rb', line 4

def logger
  @logger
end

Class Method Details

.defaulterizeObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/allgems.rb', line 5

def defaulterize
    @data_directory = nil
    @doc_format = ['rdoc']
    @logger = Logger.new(nil)
    @db = nil
    @tg = nil
    @ti = nil
    @allgems = true
    @refresh = Time.now.to_i + 3600
end

.doc_formatObject

Format for documentation



24
25
26
# File 'lib/allgems.rb', line 24

def doc_format
    @doc_format
end

.doc_format=(f) ⇒ Object

f

format

Sets format for documentation. Should be one of: hanna, rdoc, sdoc



29
30
31
32
33
34
35
36
# File 'lib/allgems.rb', line 29

def doc_format=(f)
    @doc_format = []
    f.split(',').each do |type|
        type = type.to_sym
        raise ArgumentError.new("Valid types: hanna, sdoc, rdoc") unless [:hanna,:sdoc,:rdoc].include?(type)
        @doc_format << type
    end
end

.hanna_hackObject

Path to hanna hack



65
66
67
# File 'lib/allgems.rb', line 65

def hanna_hack
    File.expand_path("#{__FILE__}/../allgems/hanna_hack.rb")
end

.initialize_db(db) ⇒ Object

db: Sequel::Database Run any migrations needed NOTE: Call before using the database



18
19
20
21
22
# File 'lib/allgems.rb', line 18

def initialize_db(db)
    self.db = db
    require 'sequel/extensions/migration'
    Sequel::Migrator.apply(db, "#{File.expand_path(__FILE__).gsub(/\/[^\/]+$/, '')}/allgems/migrations")
end

.newest_gemObject

Newest gem based on release date



60
61
62
63
# File 'lib/allgems.rb', line 60

def newest_gem
    g = AllGems.db[:versions].join(:gems, :id => :gem_id).order(:release.desc).limit(1).select(:name, :release).first
    {:name => g[:name], :release => g[:release]}
end

.public_directoryObject

Location of public directory



38
39
40
# File 'lib/allgems.rb', line 38

def public_directory
    File.expand_path("#{__FILE__}/../../public")
end

.total_gemsObject

Total number of unique gem names installed



42
43
44
45
46
47
48
49
# File 'lib/allgems.rb', line 42

def total_gems
    return 0 if self.db.nil?
    if(@tg.nil? || Time.now.to_i > @refresh)
        @tg = self.db[:gems].count
        @refresh = Time.now.to_i + 3600
    end
    @tg
end

.total_installsObject

Total number of actual gems installed



51
52
53
54
55
56
57
58
# File 'lib/allgems.rb', line 51

def total_installs
    return 0 if self.db.nil?
    if(@ti.nil? || Time.now.to_i > @refresh)
        @ti = self.db[:versions].count
        @refresh = Time.now.to_i + 3600
    end
    @ti
end