flora 0.6.1 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cda53926c0506b06a0b7cca0ebcdb2864bd7a12ccc8975c4cc2dc4ff0338b6c
4
- data.tar.gz: b0e0583176436b230c4bf48bf17f6a8c038f0ce16384e40e90ca53a5b10c8f6c
3
+ metadata.gz: 84a83e09611588abf3ede492aa734a168aa8d611eb7b33e503243df4bbe13d89
4
+ data.tar.gz: 5aeb14cbae18ad40c725c8fcf88c814daf150a48491ff3594708b843cb80f200
5
5
  SHA512:
6
- metadata.gz: 6dc9df7c9b65062f47a2c38bd2af801d2bf54f074e98e64a1cc4ca424116a2ae1cf72745620d479cca937eef561e5747e93f5cd786996678c3b39698020e6402
7
- data.tar.gz: 710c07c6e3dcbee42606a571c74006ec02c26eb134c090268bdf84016097312da0daa1fab0ef08d3155ef620ebffc2570c0bbee4d0c46322c5b0aa20cf20a84d
6
+ metadata.gz: 14084b4863fe3223d99ac2da8f3b1281ad6649f23501f150a13b73add8b451112a8f15607734b2750dd872214e40f579c51e46bf7aff2ba22f91a11e1db24c77
7
+ data.tar.gz: 155da839cd37104784aea6da12760c8d342b6d25c8b4eda9f6dfb2a5d192a76f9e29c0dd4f5c8f6470ee9ba3eb8bdccd9f16189a3f20e5a9bf74ca90aa5649a2
@@ -1,7 +1,7 @@
1
- # A page is something can be turned into HTML.
1
+ # A page is something can be turned into an HTML file.
2
2
  class Flora::Blueprint::Page
3
3
 
4
- attr_reader(:blueprint, :file, :route)
4
+ attr_reader(:file)
5
5
 
6
6
 
7
7
  def self.for(file)
@@ -16,10 +16,10 @@ class Flora::Blueprint::Page
16
16
  end
17
17
 
18
18
 
19
- def initialize(blueprint, file, route)
20
- @blueprint = blueprint
19
+ def initialize(file, blueprint)
21
20
  @file = file
22
- @route = route
21
+ @blueprint = blueprint
22
+
23
23
  @layout = find_layouts
24
24
  end
25
25
 
@@ -42,8 +42,7 @@ class Flora::Blueprint
42
42
  next if file.directory?
43
43
  next unless supported_file_type?(file)
44
44
 
45
- route = file.relative_path_from(@dir).sub_ext('.html').to_s
46
- page = Page.for(file).new(self, file, route)
45
+ page = Page.for(file).new(file, self)
47
46
  @page_modules.each { |mod| page.extend(mod) }
48
47
  pages << page
49
48
  end
@@ -52,6 +51,7 @@ class Flora::Blueprint
52
51
  end
53
52
 
54
53
 
54
+ # TODO: this is duplicating logic from Page::for.
55
55
  def supported_file_type?(file)
56
56
  file.extname == '.rb' || file.extname == '.md'
57
57
  end
data/lib/flora/factory.rb CHANGED
@@ -11,7 +11,8 @@ class Flora::Factory
11
11
  out_dir.mkdir unless out_dir.exist?
12
12
 
13
13
  @blueprint.each_page do |page|
14
- out_filename = out_dir.join(page.route)
14
+ relative_path = page.file.relative_path_from(@blueprint.dir)
15
+ out_filename = out_dir.join(relative_path).sub_ext('.html')
15
16
  out_filename.dirname.mkdir unless out_filename.dirname.exist?
16
17
  out_filename.write(page.render)
17
18
  end
@@ -1,9 +1,18 @@
1
1
  module Flora::Plugins::Blog
2
2
 
3
+ module BlueprintMethods
4
+
5
+ def posts
6
+ @dir.glob('posts/**').map { Post.new(it, @dir) }
7
+ end
8
+
9
+ end
10
+
11
+
3
12
  module PageMethods
4
13
 
5
14
  def posts
6
- @blueprint.dir.glob('posts/**').map { Post.new(it, @blueprint.dir) }
15
+ @blueprint.posts
7
16
  end
8
17
 
9
18
  end
data/lib/flora/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Flora
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
data/lib/flora.rb CHANGED
@@ -20,13 +20,14 @@ class Flora
20
20
  # with other instances of Flora in the same process. This is mostly for the
21
21
  # unit tests. Maybe one day we can use Ruby::Box or something here instead.
22
22
  @config_class = Class.new(Config)
23
+ @blueprint_class = Class.new(Blueprint)
23
24
  @factory_class = Class.new(Factory)
24
25
 
25
26
  # Page plugins get mixed in directly to the page instances by Blueprint.
26
27
  @page_modules = []
27
28
 
28
29
  @config = @config_class.new(dir.join('_config.rb'), self)
29
- @blueprint = Blueprint.new(dir, @config, @page_modules)
30
+ @blueprint = @blueprint_class.new(dir, @config, @page_modules)
30
31
  @factory = @factory_class.new(@blueprint, @config)
31
32
  end
32
33
 
@@ -43,8 +44,9 @@ class Flora
43
44
 
44
45
  # TODO: it would be nice if this wasn't exposed here. It's just for Config#plugin.
45
46
  def load_plugin(mod)
46
- @factory_class.include(mod::FactoryMethods) if defined?(mod::FactoryMethods)
47
47
  @config_class.include(mod::Config) if defined?(mod::Config)
48
+ @blueprint_class.include(mod::BlueprintMethods) if defined?(mod::BlueprintMethods)
49
+ @factory_class.include(mod::FactoryMethods) if defined?(mod::FactoryMethods)
48
50
 
49
51
  @page_modules << mod::PageMethods if defined?(mod::PageMethods)
50
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Vladimiroff