Module: Bitcat

Defined in:
lib/bitcat.rb,
lib/bitcat/app.rb,
lib/bitcat/version.rb

Defined Under Namespace

Classes: App

Constant Summary collapse

MAJOR =
0
MINOR =
1
PATCH =
0
VERSION =
[MAJOR,MINOR,PATCH].join('.')

Class Method Summary collapse

Class Method Details



15
16
17
# File 'lib/bitcat/version.rb', line 15

def self.banner
  "bitcat/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end

.mainObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bitcat.rb', line 28

def self.main
  p banner
  ##  p root   #=> e.g. "C:/Sites/openblockchains/bitcat"

  database = './kitties.db'

  unless File.exist?( database )
    puts "*** error - no SQLite database found - expected >#{database}<"
    puts
    puts "  note: for how to setup a database,"
    puts "        see <https://github.com/openblockchains/copycats#database-setup>"
    puts
    exit 1
  end


  ## connect to local kitties.db database
  connect( adapter:  'sqlite3',
           database:  database )

  ## print some (record) stats
  puts "kitties: #{Copycats::Model::Kitty.count}"
  puts "genes:   #{Copycats::Model::Gene.count}"
  puts "traits:  #{Copycats::Model::Trait.count}"

  run!
end

.rootObject



19
20
21
# File 'lib/bitcat/version.rb', line 19

def self.root
  "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
end

.run!Object

convenience method



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

def self.run!
  app    = App
  port   = 4567
  Rack::Handler::WEBrick.run( app, Port:port ) do |server|
    ## todo: add traps here - why, why not??
  end
end

.versionObject



11
12
13
# File 'lib/bitcat/version.rb', line 11

def self.version
  VERSION
end