Class: Volt
- Inherits:
-
Object
show all
- Defined in:
- lib/volt/config.rb,
lib/volt.rb,
lib/volt/boot.rb,
lib/volt/spec/setup.rb,
lib/volt/volt/environment.rb,
lib/volt/data_stores/data_store.rb,
lib/volt/data_stores/mongo_driver.rb,
app/volt/controllers/notices_controller.rb
Overview
Config lets a user set global config options for Volt.
Defined Under Namespace
Classes: DataStore, Environment, NoticesController
Constant Summary
collapse
- @@in_browser =
false
Class Method Summary
collapse
Class Method Details
30
31
32
|
# File 'lib/volt.rb', line 30
def self.client?
!ENV['SERVER']
end
|
8
9
10
|
# File 'lib/volt/config.rb', line 8
def self.config
@config || self.reset_config!
end
|
.in_browser? ⇒ Boolean
50
51
52
|
# File 'lib/volt.rb', line 50
def self.in_browser?
@@in_browser
end
|
42
43
44
|
# File 'lib/volt.rb', line 42
def self.logger
@logger ||= Logger.new
end
|
.logger=(val) ⇒ Object
46
47
48
|
# File 'lib/volt.rb', line 46
def self.logger=(val)
@logger = val
end
|
.reset_config! ⇒ Object
Resets the configuration to the default (empty hash)
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/volt/config.rb', line 13
def self.reset_config!
app_name = File.basename(Dir.pwd)
@config = OpenStruct.new({
app_name: app_name,
db_name: ENV['DB_NAME'] || (app_name + '_' + Volt.env.to_s),
db_host: ENV['DB_HOST'] || 'localhost',
db_port: (ENV['DB_PORT'] || 27017).to_i,
db_driver: ENV['DB_DRIVER'] || 'mongo'
})
end
|
18
19
20
|
# File 'lib/volt.rb', line 18
def self.root
@root ||= File.expand_path(Dir.pwd)
end
|
.root=(val) ⇒ Object
22
23
24
|
# File 'lib/volt.rb', line 22
def self.root=(val)
@root = val
end
|
.run_files_in_config_folder ⇒ Object
Load in all .rb files in the config folder
26
27
28
29
30
|
# File 'lib/volt/config.rb', line 26
def self.run_files_in_config_folder
Dir[Dir.pwd + '/config/*.rb'].each do |config_file|
require(config_file)
end
end
|
26
27
28
|
# File 'lib/volt.rb', line 26
def self.server?
!!ENV['SERVER']
end
|
.setup {|self.config| ... } ⇒ Object
4
5
6
|
# File 'lib/volt/config.rb', line 4
def self.setup
yield self.config
end
|
.source_maps? ⇒ Boolean
34
35
36
|
# File 'lib/volt.rb', line 34
def self.source_maps?
!!ENV['MAPS']
end
|
.spec_setup(app_path = '.') ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
55
56
57
58
59
|
# File 'lib/volt/spec/setup.rb', line 2
def self.spec_setup(app_path='.')
if RUBY_PLATFORM == 'opal'
require 'volt'
else
ENV['SERVER'] = 'true'
if ENV['BROWSER']
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require 'capybara/poltergeist'
end
require 'volt'
require 'volt/boot'
Volt.boot(Dir.pwd)
if ENV['BROWSER']
require 'volt/server'
Capybara.server do |app, port|
require 'rack/handler/thin'
Rack::Handler::Thin.run(app, :Port => port)
end
Capybara.app = Server.new(app_path).app
if ENV['BROWSER'] == 'phantom'
Capybara.default_driver = :poltergeist
elsif ENV['BROWSER'] == 'chrome'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.default_driver = :chrome
elsif ENV['BROWSER'] == 'firefox'
Capybara.default_driver = :selenium
elsif ENV['BROWSER'] == 'safari'
Capybara.register_driver :safari do |app|
Capybara::Selenium::Driver.new(app, :browser => :safari)
end
Capybara.default_driver = :safari
end
end
end
end
|