Class: Middleman::Org::OrgData
- Inherits:
-
Object
- Object
- Middleman::Org::OrgData
- Defined in:
- lib/middleman-org/org_data.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #articles ⇒ Object
- #convert_to_article(resource) ⇒ Object
-
#initialize(app, controller, options) ⇒ OrgData
constructor
A new instance of OrgData.
- #manipulate_resource_list(resources) ⇒ Object
- #publishable?(article) ⇒ Boolean
- #tags ⇒ Object
Constructor Details
#initialize(app, controller, options) ⇒ OrgData
Returns a new instance of OrgData.
10 11 12 13 14 15 16 |
# File 'lib/middleman-org/org_data.rb', line 10 def initialize(app, controller, ) @app = app @options = @controller = controller @_articles = [] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
8 9 10 |
# File 'lib/middleman-org/org_data.rb', line 8 def controller @controller end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/middleman-org/org_data.rb', line 7 def @options end |
Instance Method Details
#articles ⇒ Object
18 19 20 |
# File 'lib/middleman-org/org_data.rb', line 18 def articles @_articles end |
#convert_to_article(resource) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/middleman-org/org_data.rb', line 47 def convert_to_article(resource) return resource if resource.is_a?(OrgArticle) resource.extend OrgArticle resource.org_controller = controller resource end |
#manipulate_resource_list(resources) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/middleman-org/org_data.rb', line 26 def manipulate_resource_list(resources) @_posts = [] resources.each do |resource| next unless resource.path =~ /^#{.root}/ resource.destination_path = resource.path.gsub(/^#{.root}/, .prefix) if File.extname(resource.source_file) == '.org' article = convert_to_article resource puts article.source_file next unless publishable?(article) @_articles << article end end end |
#publishable?(article) ⇒ Boolean
43 44 45 |
# File 'lib/middleman-org/org_data.rb', line 43 def publishable?(article) @app.environment == :development || article.published? end |
#tags ⇒ Object
22 23 24 |
# File 'lib/middleman-org/org_data.rb', line 22 def [] end |