myobie-turbine-core 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/turbine-core/post_type.rb +15 -8
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -6,7 +6,7 @@ class PostType
|
|
6
6
|
extend ClassLevelInheritableAttributes
|
7
7
|
include Extlib::Hook
|
8
8
|
|
9
|
-
DEFAULT_FIELDS = [:published_at, :status, :slug, :trackbacks, :type, :tags]
|
9
|
+
DEFAULT_FIELDS = [:published_at, :status, :slug, :trackbacks, :type, :tags, :__original]
|
10
10
|
|
11
11
|
# vars to inherit down
|
12
12
|
cattr_inheritable :fields_list, :allowed_fields_list, :required_fields_list, :primary_field, :heading_field,
|
@@ -202,12 +202,18 @@ class PostType
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def content=(stuff) # !> method redefined; discarding old content=
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
205
|
+
case stuff
|
206
|
+
when String
|
207
|
+
@content = { :type => self.class.name.to_s }
|
208
|
+
import(stuff)
|
209
|
+
eval_specials
|
210
|
+
eval_defaults
|
211
|
+
parse_tags unless blank_attr?(:tags)
|
212
|
+
generate_slug if get_attr?(:slug)
|
213
|
+
when Hash
|
214
|
+
@content = stuff.merge(:type => self.class.name.to_s)
|
215
|
+
end
|
216
|
+
|
211
217
|
@content
|
212
218
|
end#of content=
|
213
219
|
|
@@ -242,6 +248,7 @@ class PostType
|
|
242
248
|
|
243
249
|
# TODO: how to determine the type of stuff? (text, json, yaml, image, video, photo, pdf, generic download file (can lookup type of file for icon if needed))
|
244
250
|
def import(stuff, type = :text)
|
251
|
+
set_attr(:__original, stuff)
|
245
252
|
importer = Kernel.const_get(type.to_s.camel_case+'Importer').new(self.class)
|
246
253
|
|
247
254
|
# The result sent back by an importer is either:
|
@@ -249,7 +256,7 @@ class PostType
|
|
249
256
|
# [{ :one => 'stuff' }, { :two => 'stuff' }]
|
250
257
|
# Hash:
|
251
258
|
# { :one => 'stuff', :two => 'stuff' }
|
252
|
-
result = importer.import(stuff)
|
259
|
+
result = stuff.blank? ? {} : importer.import(stuff)
|
253
260
|
|
254
261
|
case result
|
255
262
|
when Array
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myobie-turbine-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Herald
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|