flutterby 0.0.16 → 0.0.17

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: 78586bd3d1eedcc69f7930f0085e70a1fab7ca8d
4
- data.tar.gz: d237d120d8ff04886174bea1b3b79c45084f9241
3
+ metadata.gz: d8ec47d6e879ee1b0b7bc5d36b512d676fabc12c
4
+ data.tar.gz: 63ba7c9c302c8819b928792fb688b919fda9ed6a
5
5
  SHA512:
6
- metadata.gz: 4915a538cea2c6ee6ba35f44d4f35cad2377df0541c99a461e65867a5f51f3801c4995c01d41618dd8ae8850f19cea33845932e0ed718b8f870c43e81fcb85d1
7
- data.tar.gz: '069bb50722079b73986c60d54f316a313b6fe3bae2f26531864ef949b06c76090c6a03ab447e310f4f5be0ab47ed2686b1e3ae9be9671f2dee60089381f227c7'
6
+ metadata.gz: 5887dcc9beb924087c15df334529cb9661c43765236f3dcb40e449ef2911d2e703ce67e5a8d639373a3c214d7a868f57be1402c784d3b2db24f03630aeb62a19
7
+ data.tar.gz: a7f3da8b6b221501271352a7ed9cc1ab18583c68c6dc404349c64fe9b0cb65808e595ba795e9b3b1dc565e42bd5bf0043c0b38388800bc84c799c46421aff007
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.6
5
4
  - 2.3.3
6
5
  - 2.4.0
7
6
  before_install: gem install bundler -v 1.13.6
data/lib/flutterby.rb CHANGED
@@ -17,18 +17,6 @@ module Flutterby
17
17
 
18
18
  attr_writer :logger
19
19
 
20
- def from(fs_path, name: nil, parent: nil)
21
- name ||= ::File.basename(fs_path)
22
-
23
- if ::File.exist?(fs_path)
24
- Node.new(name, fs_path: fs_path, parent: parent).tap do |node|
25
- node.preprocess!
26
- end
27
- else
28
- raise "Path #{fs_path} could not be found."
29
- end
30
- end
31
-
32
20
  def logger
33
21
  @logger ||= Logger.new(STDOUT)
34
22
  end
data/lib/flutterby/cli.rb CHANGED
@@ -30,7 +30,8 @@ Commander.configure do
30
30
  time = Benchmark.realtime do
31
31
  # Import site
32
32
  say color("📚 Importing site...", :bold)
33
- root = Flutterby.from(options.in, name: "/")
33
+ root = Flutterby::Node.new("/", fs_path: options.in)
34
+ root.preprocess!
34
35
  say color("🌲 Read #{root.tree_size} nodes.", :green, :bold)
35
36
 
36
37
  # Export site
@@ -54,7 +55,8 @@ Commander.configure do
54
55
  options.default in: "./site/", port: 4004
55
56
 
56
57
  say color("📚 Importing site...", :bold)
57
- root = Flutterby.from(options.in, name: "/")
58
+ root = Flutterby::Node.new("/", fs_path: options.in)
59
+ root.preprocess!
58
60
  say color("🌲 Read #{root.tree_size} nodes.", :green, :bold)
59
61
 
60
62
  say color("🌤 Serving your site on port #{options.port}. Enjoy!", :bold)
@@ -1,6 +1,6 @@
1
1
  module Flutterby
2
2
  module Filters
3
- def apply!(node)
3
+ def self.apply!(node)
4
4
  node.body = node.source
5
5
 
6
6
  # Apply all filters
@@ -13,34 +13,34 @@ module Flutterby
13
13
  end
14
14
  end
15
15
 
16
- def process_rb!(node)
17
- # extend the node
18
- mod = Module.new
19
- mod.class_eval(node.body)
20
- node.extend(mod)
21
- node.filter! if node.respond_to?(:filter!)
16
+ def self.add(fmts, &blk)
17
+ Array(fmts).each do |fmt|
18
+ define_singleton_method("process_#{fmt}!", &blk)
19
+ end
22
20
  end
23
21
 
24
- def process_erb!(node)
25
- node.body = tilt("erb", node.body).render(node.view)
22
+ def self.tilt(format, body)
23
+ Tilt[format].new { body }
26
24
  end
25
+ end
26
+ end
27
27
 
28
- def process_slim!(node)
29
- node.body = tilt("slim", node.body).render(node.view)
30
- end
28
+ Flutterby::Filters.add("rb") do |node|
29
+ node.instance_eval(node.body)
30
+ end
31
31
 
32
- def process_md!(node)
33
- node.body = Slodown::Formatter.new(node.body).complete.to_s
34
- end
32
+ Flutterby::Filters.add("erb") do |node|
33
+ node.body = tilt("erb", node.body).render(node.view)
34
+ end
35
35
 
36
- def process_scss!(node)
37
- node.body = Sass::Engine.new(node.body, syntax: :scss).render
38
- end
36
+ Flutterby::Filters.add("slim") do |node|
37
+ node.body = tilt("slim", node.body).render(node.view)
38
+ end
39
39
 
40
- def tilt(format, body)
41
- Tilt[format].new { body }
42
- end
40
+ Flutterby::Filters.add(["md", "markdown"]) do |node|
41
+ node.body = Slodown::Formatter.new(node.body).complete.to_s
42
+ end
43
43
 
44
- extend self
45
- end
44
+ Flutterby::Filters.add("scss") do |node|
45
+ node.body = Sass::Engine.new(node.body, syntax: :scss).render
46
46
  end
@@ -27,8 +27,8 @@ module Flutterby
27
27
  # Children
28
28
  #
29
29
 
30
- def register!
31
- if file?
30
+ def register_url!
31
+ if file? && should_publish?
32
32
  root.paths[url] = self
33
33
  end
34
34
  end
@@ -168,7 +168,7 @@ module Flutterby
168
168
  #
169
169
  walk_tree do |node|
170
170
  node.render_body! if node.should_prerender?
171
- node.register! if node.should_publish?
171
+ node.register_url! if node.should_publish?
172
172
  end
173
173
  end
174
174
 
@@ -195,7 +195,7 @@ module Flutterby
195
195
 
196
196
  # Extract date from name
197
197
  if name =~ %r{^(\d\d\d\d\-\d\d?\-\d\d?)\-}
198
- @data['date'] = Time.parse($1)
198
+ @data['date'] = Date.parse($1)
199
199
  end
200
200
 
201
201
  # Read remaining data from frontmatter. Data in frontmatter
@@ -209,9 +209,7 @@ module Flutterby
209
209
 
210
210
  def load_extension!
211
211
  if extension = sibling("_node.rb")
212
- mod = Module.new
213
- mod.class_eval(extension.body)
214
- extend mod
212
+ instance_eval(extension.body)
215
213
  end
216
214
  end
217
215
 
@@ -1,3 +1,3 @@
1
1
  module Flutterby
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -29,9 +29,7 @@ module Flutterby
29
29
  if view_node = e.sibling("_view.rb")
30
30
  case view_node.ext
31
31
  when "rb" then
32
- mod = Module.new
33
- mod.class_eval(view_node.source)
34
- view.extend mod
32
+ view.instance_eval(view_node.source)
35
33
  else
36
34
  raise "Unknown view extension #{view_node.full_name}"
37
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flutterby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Mans
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler