bade 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Bade.gemspec +1 -1
- data/Gemfile +1 -0
- data/README.md +3 -2
- data/lib/bade/renderer.rb +27 -40
- data/lib/bade/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fce9a16c6a092fa176cd6adf94f87f09dc805ef
|
4
|
+
data.tar.gz: dd198f4a76c878eac584c0a03c5269f6174055c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c57022d6ababf11353a754bf99890fab414b21b6e4e64542f2543a8f79a74b53f1548555ffee7bfb0757932d651290bdf7b4b464889c11bbd8e105f1d755e1
|
7
|
+
data.tar.gz: 4fc5473929741d309c794671c2508dea40a60f42ea2f8910756f8fcbc42c32aa1accf9bfd4fa9d41501ec3cef2324e9bb0a669a483be19a21739bd41062051e7
|
data/Bade.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.authors = ['Roman Kříž']
|
13
13
|
spec.email = ['samnung@gmail.com']
|
14
14
|
spec.summary = %q{Minimalistic template engine for Ruby.}
|
15
|
-
spec.homepage = 'https://github.com/
|
15
|
+
spec.homepage = 'https://github.com/epuber-io/bade'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = Dir['bin/**/*'] + Dir['lib/**/*'] + %w(Bade.gemspec Gemfile README.md)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
2
|
# Bade
|
3
3
|
|
4
|
-
[![
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/bade.svg)](http://badge.fury.io/rb/bade) [![Build Status](https://travis-ci.org/epuber-io/bade.svg?branch=master)](https://travis-ci.org/epuber-io/bade) [![Coverage Status](https://coveralls.io/repos/epuber-io/bade/badge.svg?branch=master&service=github)](https://coveralls.io/github/epuber-io/bade?branch=master) [![Inline docs](http://inch-ci.org/github/epuber-io/bade.svg?branch=master)](http://inch-ci.org/github/epuber-io/bade)
|
5
|
+
|
5
6
|
|
6
7
|
Minimalistic template engine written in Ruby for Ruby. Developed mainly to help with creating e-books. Highly influenced by [Jade](http://jade-lang.com) and [Slim](http://slim-lang.com).
|
7
8
|
|
@@ -34,7 +35,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
34
35
|
|
35
36
|
## Contributing
|
36
37
|
|
37
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/epuber-io/bade. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
38
39
|
|
39
40
|
|
40
41
|
## TODO
|
data/lib/bade/renderer.rb
CHANGED
@@ -35,13 +35,13 @@ module Bade
|
|
35
35
|
# @return [self]
|
36
36
|
#
|
37
37
|
def self.from_file(file)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
path = if file.is_a?(File)
|
39
|
+
file.path
|
40
|
+
else
|
41
|
+
file
|
42
|
+
end
|
43
43
|
|
44
|
-
from_source(
|
44
|
+
from_source(nil, path)
|
45
45
|
end
|
46
46
|
|
47
47
|
|
@@ -71,13 +71,7 @@ module Bade
|
|
71
71
|
# @return [Bade::Node]
|
72
72
|
#
|
73
73
|
def root_document
|
74
|
-
@parsed ||= (
|
75
|
-
if file_path.nil?
|
76
|
-
_parse_document_from_text(source_text)
|
77
|
-
else
|
78
|
-
_parse_document_from_file(file_path)
|
79
|
-
end
|
80
|
-
)
|
74
|
+
@parsed ||= _parsed_document(source_text, file_path)
|
81
75
|
end
|
82
76
|
|
83
77
|
# @return [String]
|
@@ -108,41 +102,34 @@ module Bade
|
|
108
102
|
#
|
109
103
|
# @return [Bade::Document]
|
110
104
|
#
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
105
|
+
def _parsed_document(content, file_path)
|
106
|
+
content = if file_path.nil? && content.nil?
|
107
|
+
raise LoadError, "Don't know what to do with nil values for both content and path"
|
108
|
+
elsif !file_path.nil? && content.nil?
|
109
|
+
File.read(file_path)
|
110
|
+
else
|
111
|
+
content
|
112
|
+
end
|
119
113
|
|
120
|
-
|
121
|
-
|
122
|
-
parsed_document = @parsed_documents[new_path]
|
114
|
+
parsed_document = @parsed_documents[file_path]
|
123
115
|
return parsed_document unless parsed_document.nil?
|
124
116
|
|
125
|
-
|
117
|
+
parser = Parser.new(file_path: file_path)
|
118
|
+
|
119
|
+
document = parser.parse(content)
|
126
120
|
|
127
121
|
parser.dependency_paths.each do |path|
|
128
|
-
sub_path = File.expand_path(path, File.dirname(
|
129
|
-
|
122
|
+
sub_path = File.expand_path(path, File.dirname(file_path))
|
123
|
+
new_path = if File.exists?(sub_path)
|
124
|
+
sub_path
|
125
|
+
elsif File.exists?("#{sub_path}.bade")
|
126
|
+
"#{sub_path}.bade"
|
127
|
+
end
|
128
|
+
|
129
|
+
document.sub_documents << _parsed_document(nil, new_path)
|
130
130
|
end
|
131
131
|
|
132
132
|
document
|
133
133
|
end
|
134
|
-
|
135
|
-
# @param text [String]
|
136
|
-
#
|
137
|
-
# @return [Bade::Document]
|
138
|
-
#
|
139
|
-
def _parse_document_from_text(text)
|
140
|
-
parser = Parser.new
|
141
|
-
document = parser.parse(text)
|
142
|
-
|
143
|
-
raise 'You cannot use import when it is loaded from source text' if parser.dependency_paths.length > 0
|
144
|
-
|
145
|
-
document
|
146
|
-
end
|
147
134
|
end
|
148
135
|
end
|
data/lib/bade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kříž
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ files:
|
|
80
80
|
- lib/bade/runtime/block.rb
|
81
81
|
- lib/bade/runtime/render_binding.rb
|
82
82
|
- lib/bade/version.rb
|
83
|
-
homepage: https://github.com/
|
83
|
+
homepage: https://github.com/epuber-io/bade
|
84
84
|
licenses:
|
85
85
|
- MIT
|
86
86
|
metadata: {}
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.4.
|
103
|
+
rubygems_version: 2.4.8
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Minimalistic template engine for Ruby.
|