conjoin 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conjoin.rb +1 -0
- data/lib/conjoin/seeds.rb +32 -0
- data/lib/conjoin/tasks.rb +3 -3
- data/lib/conjoin/tasks/migrate.rb +1 -1
- data/lib/conjoin/version.rb +1 -1
- data/lib/conjoin/widgets.rb +20 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fe8160a5ff9fb8655e7b3c944f300357ae391c1
|
4
|
+
data.tar.gz: 53063407f2e17bf2d67228f05c674d654bbd26f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8e6e38e7d4ba6b74089305f1695116ff3340e5956a5d64452e938eff3fba15af34901896a459835fdd780c0a5da44f7216a867e657b902aa9652f1485afc704
|
7
|
+
data.tar.gz: df9a4372d22c4aeec4874f6fb9c89c9222ba8cf165a2bd5143bb9c7a36acdec630f0969624ad9298e172850850969e3bb72821efd6d4cc674f5c30198761fa38
|
data/lib/conjoin.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Conjoin
|
2
|
+
module Seeds
|
3
|
+
class << self
|
4
|
+
def root
|
5
|
+
File.expand_path(File.dirname(__FILE__))
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
Dir["#{root}/seeds/**/*.rb"].each { |rb| require rb }
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_sql_dump_for dump
|
13
|
+
connection = ActiveRecord::Base.connection
|
14
|
+
|
15
|
+
connection.execute("TRUNCATE #{dump};")
|
16
|
+
|
17
|
+
# - IMPORTANT: SEED DATA ONLY
|
18
|
+
# - DO NOT EXPORT TABLE STRUCTURES
|
19
|
+
# - DO NOT EXPORT DATA FROM `schema_migrations`
|
20
|
+
sql = File.read("db/dumps/#{dump}.sql")
|
21
|
+
statements = sql.split(/;$/)
|
22
|
+
statements.pop # the last empty statement
|
23
|
+
|
24
|
+
ActiveRecord::Base.transaction do
|
25
|
+
statements.each do |statement|
|
26
|
+
connection.execute(statement)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/conjoin/tasks.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
dir = Gem::Specification.find_by_name('
|
1
|
+
dir = Gem::Specification.find_by_name('conjoin').gem_dir
|
2
2
|
|
3
|
-
Dir.glob("#{dir}/lib/
|
4
|
-
Dir.glob("#{dir}/lib/
|
3
|
+
Dir.glob("#{dir}/lib/conjoin/tasks/**/*.rb").each { |r| require r }
|
4
|
+
Dir.glob("#{dir}/lib/conjoin/tasks/**/*.rake").each { |r| import r }
|
data/lib/conjoin/version.rb
CHANGED
data/lib/conjoin/widgets.rb
CHANGED
@@ -132,16 +132,17 @@ module Conjoin
|
|
132
132
|
|
133
133
|
class Base
|
134
134
|
JS_ESCAPE = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
|
135
|
-
attr_accessor :app, :res, :req, :settings, :event, :folder, :options
|
135
|
+
attr_accessor :app, :res, :req, :settings, :event, :folder, :options, :widget_state
|
136
136
|
|
137
137
|
def initialize app, res, req, settings, event, folder, options
|
138
|
-
@app
|
139
|
-
@res
|
140
|
-
@req
|
141
|
-
@settings
|
142
|
-
@event
|
143
|
-
@folder
|
144
|
-
@options
|
138
|
+
@app = app
|
139
|
+
@res = res
|
140
|
+
@req = req
|
141
|
+
@settings = settings
|
142
|
+
@event = event
|
143
|
+
@folder = folder
|
144
|
+
@options = options
|
145
|
+
@widget_state = false
|
145
146
|
|
146
147
|
# add the widget to the req widgets
|
147
148
|
req.env[:widgets] ||= {}
|
@@ -169,6 +170,7 @@ module Conjoin
|
|
169
170
|
@options[:replace] = true
|
170
171
|
|
171
172
|
if !state.is_a? String
|
173
|
+
opts[:state] = state
|
172
174
|
content = render state, opts
|
173
175
|
selector = '#' + id_for(state)
|
174
176
|
else
|
@@ -223,6 +225,14 @@ module Conjoin
|
|
223
225
|
end
|
224
226
|
end
|
225
227
|
|
228
|
+
def set_state state
|
229
|
+
@widget_state = state
|
230
|
+
end
|
231
|
+
|
232
|
+
def render_state
|
233
|
+
render state: widget_state
|
234
|
+
end
|
235
|
+
|
226
236
|
def render *args
|
227
237
|
if args.first.kind_of? Hash
|
228
238
|
locals = args.first
|
@@ -232,6 +242,7 @@ module Conjoin
|
|
232
242
|
state = view = args.first
|
233
243
|
locals = args.length > 1 ? args.last : {}
|
234
244
|
end
|
245
|
+
state = @widget_state if widget_state
|
235
246
|
|
236
247
|
unless view
|
237
248
|
state = view = caller[0][/`.*'/][1..-2]
|
@@ -241,7 +252,7 @@ module Conjoin
|
|
241
252
|
end
|
242
253
|
end
|
243
254
|
|
244
|
-
if locals.key?(:state) and state.to_s == view
|
255
|
+
if locals.key?(:state) and state.to_s == view.to_s
|
245
256
|
return send state
|
246
257
|
end
|
247
258
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuba
|
@@ -342,6 +342,7 @@ files:
|
|
342
342
|
- lib/conjoin/inputs/time.rb
|
343
343
|
- lib/conjoin/middleware.rb
|
344
344
|
- lib/conjoin/recursive_ostruct.rb
|
345
|
+
- lib/conjoin/seeds.rb
|
345
346
|
- lib/conjoin/tasks.rb
|
346
347
|
- lib/conjoin/tasks/migrate.rake
|
347
348
|
- lib/conjoin/tasks/migrate.rb
|