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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ee88f214503285bd912da7c26c2e9212dc4506f
4
- data.tar.gz: 55294fc368dcf01a1f67b09b000f73c9f2364e6b
3
+ metadata.gz: 5fe8160a5ff9fb8655e7b3c944f300357ae391c1
4
+ data.tar.gz: 53063407f2e17bf2d67228f05c674d654bbd26f5
5
5
  SHA512:
6
- metadata.gz: 88b21dda0547389e6a176e81e63096ba891d3b1865aa8791bbbb88e40bebf65d813d6c58fba37b57b88d63702ae0ca2b98b618d8d81d3ff412cd1fb6020d4c46
7
- data.tar.gz: d54d302414f432eb1e61b07422b86b6dfa2af07df7bdded141c802e08fac06baff12489fecff3e2b6cff2cb2ba919fbe7648cca739198ea845dec061b34ea02d
6
+ metadata.gz: b8e6e38e7d4ba6b74089305f1695116ff3340e5956a5d64452e938eff3fba15af34901896a459835fdd780c0a5da44f7216a867e657b902aa9652f1485afc704
7
+ data.tar.gz: df9a4372d22c4aeec4874f6fb9c89c9222ba8cf165a2bd5143bb9c7a36acdec630f0969624ad9298e172850850969e3bb72821efd6d4cc674f5c30198761fa38
data/lib/conjoin.rb CHANGED
@@ -4,6 +4,7 @@ require "conjoin/middleware"
4
4
  require "conjoin/env_string"
5
5
  require "conjoin/class_methods"
6
6
  require "conjoin/cuba"
7
+ require "conjoin/seeds"
7
8
 
8
9
  module Conjoin
9
10
  extend ClassMethods
@@ -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('cuba-tracks').gem_dir
1
+ dir = Gem::Specification.find_by_name('conjoin').gem_dir
2
2
 
3
- Dir.glob("#{dir}/lib/cuba/tasks/**/*.rb").each { |r| require r }
4
- Dir.glob("#{dir}/lib/cuba/tasks/**/*.rake").each { |r| import r }
3
+ Dir.glob("#{dir}/lib/conjoin/tasks/**/*.rb").each { |r| require r }
4
+ Dir.glob("#{dir}/lib/conjoin/tasks/**/*.rake").each { |r| import r }
@@ -29,7 +29,7 @@ module ActiveRecordTasks
29
29
  silence_activerecord do
30
30
  load("db/seeds.rb")
31
31
  if not file
32
- Seeds.run
32
+ Conjoin::Seeds.run
33
33
  else
34
34
  load("db/seeds/#{file}.rb")
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Conjoin
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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 = app
139
- @res = res
140
- @req = req
141
- @settings = settings
142
- @event = event
143
- @folder = folder
144
- @options = 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
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-04 00:00:00.000000000 Z
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