myobie-turbine-core 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 3
4
- :patch: 7
3
+ :minor: 4
4
+ :patch: 0
@@ -15,6 +15,11 @@ class String
15
15
  def make_attr
16
16
  self.downcase.to_sym
17
17
  end
18
+
19
+ def indents(remove_blanks = false)
20
+ # clear blank lines and then clear left margin
21
+ reject { |line| line.blank? && remove_blanks }.map { |line| line.gsub(/^\s+$/, "\n") }.join.margin.strip
22
+ end
18
23
  end
19
24
 
20
25
  class Symbol
@@ -6,7 +6,8 @@ class PostType
6
6
  extend ClassLevelInheritableAttributes
7
7
  include Extlib::Hook
8
8
 
9
- DEFAULT_FIELDS = [:published_at, :status, :slug, :trackbacks, :type, :tags, :__original]
9
+ DEFAULT_FIELDS = [:published_at, :status, :slug, :trackbacks, :type, :tags]
10
+ NON_EDITABLE_FIELDS = [:trackbacks, :type, :published_at, :status] # don't show up in to_s
10
11
 
11
12
  # vars to inherit down
12
13
  cattr_inheritable :fields_list, :allowed_fields_list, :required_fields_list, :primary_field, :heading_field,
@@ -366,7 +367,7 @@ class PostType
366
367
  end
367
368
 
368
369
  def to_s
369
- fields_to_parse = self.class.fields_list - [self.class.primary_field]
370
+ fields_to_parse = self.class.fields_list - [self.class.primary_field] + DEFAULT_FIELDS - NON_EDITABLE_FIELDS
370
371
 
371
372
  result = fields_to_parse.map do |field|
372
373
  unless blank_attr?(field)
@@ -376,7 +377,7 @@ class PostType
376
377
  # TODO: make a way to override this like string_for :content { "hello" }
377
378
 
378
379
  end#unless
379
- end.join("\n") << "\n"
380
+ end.compact.join("\n") << "\n\n"
380
381
 
381
382
  unless self.class.primary_field.blank? || blank_attr?(self.class.primary_field)
382
383
  result << get_attr(self.class.primary_field, false)
@@ -0,0 +1,37 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper.rb')
2
+
3
+ describe PostType do
4
+
5
+ before do
6
+ class Yellow; end
7
+ Object.send(:remove_const, :Yellow)
8
+ end
9
+
10
+ should "to_s all fields" do
11
+ class Yellow < PostType
12
+ fields :one, :two, :title, :body
13
+ primary :body
14
+ heading :title
15
+ end
16
+
17
+ yellow = Yellow.new %Q{
18
+ One: hello1
19
+ Two: hello2
20
+
21
+ This is the title
22
+ =================
23
+
24
+ this is the body
25
+ }.indents
26
+
27
+ yellow.to_s.should == %Q{
28
+ one: hello1
29
+ two: hello2
30
+ title: This is the title
31
+ slug: this-is-the-title
32
+
33
+ this is the body
34
+ }.indents
35
+ end
36
+
37
+ end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper.rb')
1
+ require File.join(File.dirname(__FILE__), '../spec_helper.rb')
2
2
 
3
3
  describe PostType do
4
4
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "rubygems"
2
2
  require 'bacon'
3
- require 'mocha'
3
+ require 'facon'
4
4
 
5
5
  require File.expand_path(File.join(__FILE__.split('/spec').first, 'lib/turbine-core.rb'))
6
6
 
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.3.7
4
+ version: 0.4.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-15 00:00:00 -07:00
12
+ date: 2009-04-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -38,7 +38,8 @@ files:
38
38
  - lib/turbine-core/types/quote.rb
39
39
  - lib/turbine-core/types/review.rb
40
40
  - lib/turbine-core/types/video.rb
41
- - spec/post_type_spec.rb
41
+ - spec/general/formats_spec.rb
42
+ - spec/general/post_type_spec.rb
42
43
  - spec/post_types/chat_spec.rb
43
44
  - spec/post_types/link_spec.rb
44
45
  - spec/post_types/quote_spec.rb
@@ -73,7 +74,8 @@ signing_key:
73
74
  specification_version: 2
74
75
  summary: TODO
75
76
  test_files:
76
- - spec/post_type_spec.rb
77
+ - spec/general/formats_spec.rb
78
+ - spec/general/post_type_spec.rb
77
79
  - spec/post_types/chat_spec.rb
78
80
  - spec/post_types/link_spec.rb
79
81
  - spec/post_types/quote_spec.rb