Module: Marquetapage

Defined in:
lib/marquetapage.rb,
lib/marquetapage/runner.rb,
lib/marquetapage/version.rb

Overview

Version file

Defined Under Namespace

Classes: Runner

Constant Summary collapse

VERSION =

Version constant

'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.dbObject

Use DATABASE_URL env var or return sqlite connection string

Returns:

  • String



27
28
29
# File 'lib/marquetapage.rb', line 27

def self.db
  ENV['DATABASE_URL'] || "sqlite://#{db_path}"
end

.db_pathObject

Get places.sqlite from current env production will search first ‘.mozilla/firefox/xxx.default/places.sqlite` other environment will search current directory for `places.ENV.sqlite`

Returns:

  • String



16
17
18
19
20
21
22
23
# File 'lib/marquetapage.rb', line 16

def self.db_path
  if env == 'production'
    mozilla_path = "#{ENV['HOME']}/.mozilla/firefox/*.default/places.sqlite"
    Dir.glob(mozilla_path).first
  else
    File.expand_path("../../places.#{env}.sqlite", __FILE__)
  end
end

.envObject

Get current environment from MARQUETAPAGE_ENV Default: production

Returns:

  • String



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

def self.env
  ENV['MARQUETAPAGE_ENV'] || 'production'
end

.sequel_connectObject

Sequel connect

Returns:

  • Sequel::SQLite::Database



33
34
35
# File 'lib/marquetapage.rb', line 33

def self.sequel_connect
  @sequel_connect ||= Sequel.connect(db)
end