Class: Turbotlib
- Inherits:
-
Object
- Object
- Turbotlib
- Extended by:
- ScraperWiki
- Defined in:
- lib/turbotlib.rb,
lib/turbotlib/ftp.rb,
lib/turbotlib/client.rb,
lib/turbotlib/logger.rb,
lib/turbotlib/processor.rb
Defined Under Namespace
Classes: Client, FTP, FTPDelegator, Logger, Processor
Class Method Summary collapse
-
.data_dir ⇒ String
Returns the path to the data directory.
-
.get_var(key) ⇒ Object
Returns the value of a variable.
-
.in_production? ⇒ Boolean
Returns whether the environment is production.
-
.log(message) ⇒ Object
Logs a message to STDERR.
-
.save_var(key, val) ⇒ Object
Saves and returns the value of a variable.
-
.sources_dir ⇒ String
Returns the path to the sources directory.
-
.sqlite_magic_connection ⇒ SqliteMagic::Connection
Override default in ScraperWiki gem.
Class Method Details
.data_dir ⇒ String
Returns the path to the data directory.
26 27 28 |
# File 'lib/turbotlib.rb', line 26 def data_dir path_to('data') end |
.get_var(key) ⇒ Object
Returns the value of a variable.
57 58 59 |
# File 'lib/turbotlib.rb', line 57 def get_var(key) get_vars[key] end |
.in_production? ⇒ Boolean
Returns whether the environment is production.
72 73 74 |
# File 'lib/turbotlib.rb', line 72 def in_production? !!ENV['MORPH_URL'] end |
.log(message) ⇒ Object
Logs a message to STDERR.
19 20 21 |
# File 'lib/turbotlib.rb', line 19 def log() $stderr.puts end |
.save_var(key, val) ⇒ Object
Saves and returns the value of a variable.
46 47 48 49 50 51 |
# File 'lib/turbotlib.rb', line 46 def save_var(key, val) vars = get_vars vars[key] = val save_vars(vars) val end |
.sources_dir ⇒ String
Returns the path to the sources directory.
33 34 35 36 37 38 39 |
# File 'lib/turbotlib.rb', line 33 def sources_dir if in_production? && !is_admin? raise 'Only admins are permitted to write to `sources_dir`' else path_to('sources') end end |
.sqlite_magic_connection ⇒ SqliteMagic::Connection
Override default in ScraperWiki gem.
64 65 66 67 |
# File 'lib/turbotlib.rb', line 64 def sqlite_magic_connection db = "#{data_dir}/data.sqlite" @sqlite_magic_connection ||= SqliteMagic::Connection.new(db) end |