volt 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +24 -4
- data/VERSION +1 -1
- data/app/volt/tasks/live_query/data_store.rb +1 -2
- data/app/volt/tasks/store_tasks.rb +1 -2
- data/lib/volt.rb +6 -0
- data/lib/volt/boot.rb +3 -0
- data/lib/volt/config.rb +31 -0
- data/lib/volt/data_stores/data_store.rb +13 -0
- data/lib/volt/data_stores/mongo_driver.rb +14 -0
- data/lib/volt/server.rb +4 -2
- data/lib/volt/volt/environment.rb +4 -0
- data/templates/project/app/main/views/main/{main.html → main.html.tt} +1 -1
- data/templates/project/config/app.rb.tt +20 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3901f1ded564b432e705d7e1a024c3928c78d47a
|
4
|
+
data.tar.gz: 28af2588df6aefc650102f363e24f1ec92a28359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0259a07ecc92434d0c840c58323326ff7d0af81816c43dc3d13b7fced08656bdfd012231d2e88d6b4df01996dedf7529725a18e11d1fa4faacac2772dcdf4aa7
|
7
|
+
data.tar.gz: 6fe287443de67207d5e91a9e5739479454ff12750f6ae5b86533a36cfe899a6893dddffb09a9a2150326072a3377448b11970e587ba8cc43224d786a4c2cb961
|
data/Readme.md
CHANGED
@@ -99,6 +99,7 @@ You can access the Volt console with:
|
|
99
99
|
10. [Testing](#testing)
|
100
100
|
11. [Volt Helpers](#volt-helpers)
|
101
101
|
1. [Logging](#logging)
|
102
|
+
2. [App Configuration](#app-configuration)
|
102
103
|
|
103
104
|
# Getting Help
|
104
105
|
|
@@ -480,15 +481,18 @@ To convert a Model or an ArrayModel back to a normal hash, call .to_h or .to_a r
|
|
480
481
|
user = Model.new
|
481
482
|
user._name = 'Ryan'
|
482
483
|
user._profiles = {
|
483
|
-
|
484
|
-
|
484
|
+
_twitter: 'http://www.twitter.com/ryanstout',
|
485
|
+
_dribbble: 'http://dribbble.com/ryanstout'
|
485
486
|
}
|
486
487
|
|
487
488
|
user._profiles.to_h
|
488
|
-
# => {
|
489
|
+
# => {_twitter: 'http://www.twitter.com/ryanstout', _dribbble: 'http://dribbble.com/ryanstout'}
|
489
490
|
|
490
491
|
items = ArrayModel.new([1,2,3,4])
|
491
|
-
|
492
|
+
# => #<ArrayModel:70226521081980 [1, 2, 3, 4]>
|
493
|
+
|
494
|
+
items.to_a
|
495
|
+
# => [1,2,3,4]
|
492
496
|
```
|
493
497
|
|
494
498
|
You can get a normal array again by calling .to_a on an ArrayModel.
|
@@ -834,6 +838,22 @@ You can change the logger with:
|
|
834
838
|
Volt.logger = Logger.new
|
835
839
|
```
|
836
840
|
|
841
|
+
## App Configuration
|
842
|
+
|
843
|
+
Like many frameworks, Volt changes some default settings based on an environment flag. You can set the volt environment with the VOLT_ENV environment variable.
|
844
|
+
|
845
|
+
All files in the app's ```config``` folder are loaded when Volt boots. This is similar to the ```initializers``` folder in Rails.
|
846
|
+
|
847
|
+
Volt does its best to start with useful defaults. You can configure things like your database and app name in the config/app.rb file. The following are the current configuration options:
|
848
|
+
|
849
|
+
| name | default | description |
|
850
|
+
|-----------|---------------------------|---------------------------------------------------------------|
|
851
|
+
| app_name | the current folder name | This is used internally for things like logging. |
|
852
|
+
| db_driver | 'mongo' | Currently mongo is the only supported driver, more coming soon|
|
853
|
+
| db_name | "#{app_name}_#{Volt.env} | The name of the mongo database. |
|
854
|
+
| db_host | 'localhost' | The hostname for the mongo database. |
|
855
|
+
| db_port | 27017 | The port for the mongo database. |
|
856
|
+
| compress_deflate | false | If true, will run deflate in the app server, its better to let something like nginx do this though |
|
837
857
|
|
838
858
|
## Accessing DOM section in a controller
|
839
859
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.3
|
@@ -3,8 +3,7 @@ require 'query_tasks'
|
|
3
3
|
|
4
4
|
class StoreTasks
|
5
5
|
def initialize(channel=nil, dispatcher=nil)
|
6
|
-
@@
|
7
|
-
@@db ||= @@mongo_db.db("development")
|
6
|
+
@@db = Volt::DataStore.fetch
|
8
7
|
|
9
8
|
@channel = channel
|
10
9
|
@dispatcher = dispatcher
|
data/lib/volt.rb
CHANGED
@@ -2,6 +2,11 @@ require 'volt/volt/environment'
|
|
2
2
|
require 'volt/extra_core/extra_core'
|
3
3
|
require 'volt/reactive/computation'
|
4
4
|
require 'volt/reactive/dependency'
|
5
|
+
if RUBY_PLATFORM == 'opal'
|
6
|
+
else
|
7
|
+
require 'volt/config'
|
8
|
+
require 'volt/data_stores/data_store'
|
9
|
+
end
|
5
10
|
|
6
11
|
class Volt
|
7
12
|
if RUBY_PLATFORM == 'opal'
|
@@ -45,4 +50,5 @@ class Volt
|
|
45
50
|
def self.in_browser?
|
46
51
|
@@in_browser
|
47
52
|
end
|
53
|
+
|
48
54
|
end
|
data/lib/volt/boot.rb
CHANGED
data/lib/volt/config.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Config lets a user set global config options for Volt.
|
2
|
+
class Volt
|
3
|
+
|
4
|
+
def self.setup
|
5
|
+
yield self.config
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.config
|
9
|
+
@config || self.reset_config!
|
10
|
+
end
|
11
|
+
|
12
|
+
# Resets the configuration to the default (empty hash)
|
13
|
+
def self.reset_config!
|
14
|
+
app_name = File.basename(Dir.pwd)
|
15
|
+
|
16
|
+
@config = OpenStruct.new({
|
17
|
+
app_name: app_name,
|
18
|
+
db_name: ENV['DB_NAME'] || (app_name + '_' + Volt.env.to_s),
|
19
|
+
db_host: ENV['DB_HOST'] || 'localhost',
|
20
|
+
db_port: (ENV['DB_PORT'] || 27017).to_i,
|
21
|
+
db_driver: ENV['DB_DRIVER'] || 'mongo'
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
# Load in all .rb files in the config folder
|
26
|
+
def self.run_files_in_config_folder
|
27
|
+
Dir[Dir.pwd + '/config/*.rb'].each do |config_file|
|
28
|
+
require(config_file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
class Volt
|
4
|
+
class DataStore
|
5
|
+
class MongoDriver
|
6
|
+
def self.fetch
|
7
|
+
@@mongo_db ||= Mongo::MongoClient.new(Volt.config.db_host, Volt.config.db_path)
|
8
|
+
@@db ||= @@mongo_db.db(Volt.config.db_name)
|
9
|
+
|
10
|
+
return @@db
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/volt/server.rb
CHANGED
@@ -80,9 +80,11 @@ class Server
|
|
80
80
|
@app = Rack::Builder.new
|
81
81
|
|
82
82
|
# Should only be used in production
|
83
|
-
|
83
|
+
if Volt.config.deflate
|
84
|
+
@app.use Rack::Deflater
|
85
|
+
@app.use Rack::Chunked
|
86
|
+
end
|
84
87
|
|
85
|
-
# @app.use Rack::Chunked
|
86
88
|
@app.use Rack::ContentLength
|
87
89
|
|
88
90
|
@app.use Rack::KeepAlive
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Volt.setup do |config|
|
2
|
+
# Setup your global app config here.
|
3
|
+
|
4
|
+
# The app name defaults to the folder it is run in.
|
5
|
+
# config.app_name = '<%= config[:name] %>'
|
6
|
+
|
7
|
+
# Database config all start with db_ and can be set either in the config
|
8
|
+
# file or with an environment variable (DB_NAME for example).
|
9
|
+
|
10
|
+
# config.db_driver = 'mongo'
|
11
|
+
# config.db_name = (config.app_name + '_' + Volt.env.to_s)
|
12
|
+
# config.db_host = 'localhost'
|
13
|
+
# config.db_port = 27017
|
14
|
+
|
15
|
+
# Compression options
|
16
|
+
|
17
|
+
# If you are not running behind something like nginx in production, you can
|
18
|
+
# have rack deflate all files.
|
19
|
+
# config.deflate = true
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -377,8 +377,11 @@ files:
|
|
377
377
|
- lib/volt/cli.rb
|
378
378
|
- lib/volt/cli/asset_compile.rb
|
379
379
|
- lib/volt/cli/new_gem.rb
|
380
|
+
- lib/volt/config.rb
|
380
381
|
- lib/volt/console.rb
|
381
382
|
- lib/volt/controllers/model_controller.rb
|
383
|
+
- lib/volt/data_stores/data_store.rb
|
384
|
+
- lib/volt/data_stores/mongo_driver.rb
|
382
385
|
- lib/volt/extra_core/array.rb
|
383
386
|
- lib/volt/extra_core/blank.rb
|
384
387
|
- lib/volt/extra_core/extra_core.rb
|
@@ -566,8 +569,9 @@ files:
|
|
566
569
|
- templates/project/app/main/models/.empty_directory
|
567
570
|
- templates/project/app/main/views/main/about.html
|
568
571
|
- templates/project/app/main/views/main/index.html
|
569
|
-
- templates/project/app/main/views/main/main.html
|
572
|
+
- templates/project/app/main/views/main/main.html.tt
|
570
573
|
- templates/project/config.ru
|
574
|
+
- templates/project/config/app.rb.tt
|
571
575
|
- templates/project/lib/.empty_directory
|
572
576
|
- templates/project/public/index.html
|
573
577
|
- templates/project/spec/sample_spec.rb
|