rakyll 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: f8f532a84a19c5f4e18fe9be45d2c87d56ecb20f
4
- data.tar.gz: b144be2f2d4aca77fd85d2b92476640cdf73a1de
3
+ metadata.gz: b367afe3181a3e338cb28e19a6b81cab9b4f32c2
4
+ data.tar.gz: e1e4b61c2fa3c85e61acc8995198c01705840459
5
5
  SHA512:
6
- metadata.gz: e3e8fa247b482fca8bb5f73b7f96602f70334f2b099a85946f72af0b39d6ad2764f2c9bbee041fab5634ef19b115b364f26bc7510abd84872135b1b44967f0c7
7
- data.tar.gz: 560333a5212ef6f27e462cb4c6b3883c1573bbc35399da4c9cb87d4ce7669f3b3e5cfb8ef57a06f3203d5c8ed2f162c782c479f0de0f18fbe27ad9b2ce6b628c
6
+ metadata.gz: 62a7d91403ff1f6fd7d7a385f7a0c9daf8515ae5a623abb79275118a2eeb8018372b7ee17fa274c6961b186a1e2ea5de17b17d830b4007f12e5ba578f398f6d5
7
+ data.tar.gz: 1fa64a7b0bf1bfa61437a737c2e613b1c3bc5cc5b1d9246f011e29d356544bd129576692fab46a3f9a970ed626015672392fd8039a56587d67525aeccb426379
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Rakyll
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rakyll`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ [Hakyll](https://jaspervdj.be/hakyll/)-inspied **static site generator**.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,15 +20,13 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
23
+ [This](https://github.com/genya0407/blog) is an example.
34
24
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rakyll. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
25
+ - You need `templates` directory.
26
+ - You write html template with erb, and place it in `templates`.
27
+ - You might need a directory to place markdown contents.
28
+ - In the example above, its name is `products`.
29
+ - You might need a directory to place static files(js, css, images).
30
+ - In the example above, its name is `assets`.
36
31
 
32
+ Then, write `site.rb`, execute `ruby site.rb`, and `_site` directory will be generated.
data/lib/rakyll.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'erb'
2
- require 'yaml'
2
+ require 'yaml/front-matter'
3
3
  require 'pathname'
4
4
  require 'fileutils'
5
5
  require 'redcarpet'
@@ -12,8 +12,8 @@ require 'rakyll/compiler/create'
12
12
  require 'rakyll/compiler/match'
13
13
 
14
14
  module Rakyll
15
- def self.dsl(&block)
16
- route = Rakyll::Route.new
15
+ def self.dsl(opts = {}, &block)
16
+ route = Rakyll::Route.new opts
17
17
  route.instance_eval &block
18
18
  route.save
19
19
  end
@@ -3,7 +3,7 @@ module Rakyll
3
3
  class Copy
4
4
  include SetFilename
5
5
 
6
- def initialize(source_filename)
6
+ def initialize(source_filename, opts)
7
7
  @source_filename = source_filename
8
8
  set_filename(source_filename)
9
9
  end
@@ -5,14 +5,14 @@ module Rakyll
5
5
  include SetFilename
6
6
  attr_reader :url
7
7
 
8
- def initialize(source_filename)
8
+ def initialize(source_filename, opts)
9
9
  @source_filename = source_filename
10
10
  set_filename(source_filename)
11
11
  end
12
12
 
13
- def load_all(pattern)
13
+ def load_all(pattern, opts = {})
14
14
  Dir.glob(pattern).map do |filename|
15
- Match.new filename
15
+ Match.new filename, opts
16
16
  end
17
17
  end
18
18
 
@@ -5,11 +5,11 @@ module Rakyll
5
5
  include SetFilename
6
6
  attr_reader :body, :url
7
7
 
8
- def initialize(source_filename)
8
+ def initialize(source_filename, opts)
9
9
  @source_filename = source_filename
10
- metadata_string, markdown_string = File.read(@source_filename).split("---\n")
11
- set_metadata_from_yaml(metadata_string)
12
- set_body_from_markdown(markdown_string)
10
+ metadatas, markdown_string = YAML::FrontMatter.extract(File.read(@source_filename))
11
+ set_metadatas(metadatas)
12
+ set_body_from_markdown(markdown_string, opts)
13
13
  set_filename(source_filename, '.html')
14
14
  end
15
15
 
@@ -18,15 +18,15 @@ module Rakyll
18
18
  end
19
19
 
20
20
  private
21
- def set_metadata_from_yaml(metadata_string)
22
- YAML.load(metadata_string).each do |key, value|
21
+ def set_metadatas(metadatas)
22
+ metadatas.each do |key, value|
23
23
  instance_variable_set(:"@#{key}", value)
24
24
  singleton_class.class_eval { attr_reader key }
25
25
  end
26
26
  end
27
27
 
28
- def set_body_from_markdown(markdown_string)
29
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
28
+ def set_body_from_markdown(markdown_string, opts)
29
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, opts[:redcarpet_extensions] || {})
30
30
  @body = markdown.render(markdown_string)
31
31
  end
32
32
  end
data/lib/rakyll/route.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  module Rakyll
2
2
  class Route
3
- def initialize
3
+ def initialize(opts)
4
+ @opts = opts
4
5
  @compilers = []
5
6
  end
6
7
 
7
8
  def match(pattern, &block)
8
9
  Dir.glob(pattern).each do |source_filename|
9
- compiler = Rakyll::Compiler::Match.new source_filename
10
+ compiler = Rakyll::Compiler::Match.new source_filename, @opts
10
11
  compiler.instance_eval &block
11
12
  @compilers.push compiler
12
13
  end
@@ -14,13 +15,13 @@ module Rakyll
14
15
 
15
16
  def copy(pattern)
16
17
  Dir.glob(pattern).each do |source_filename|
17
- compiler = Rakyll::Compiler::Copy.new source_filename
18
+ compiler = Rakyll::Compiler::Copy.new source_filename, @opts
18
19
  @compilers.push compiler
19
20
  end
20
21
  end
21
22
 
22
23
  def create(filename, &block)
23
- compiler = Rakyll::Compiler::Create.new filename
24
+ compiler = Rakyll::Compiler::Create.new filename, @opts
24
25
  compiler.instance_eval &block
25
26
  @compilers.push compiler
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module Rakyll
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/rakyll.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_dependency "redcarpet", "~> 3.4"
24
+ spec.add_dependency "yaml-front-matter", "~> 0.0.1"
24
25
  spec.add_development_dependency "bundler", "~> 1.14"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Sangenya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2017-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yaml-front-matter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement