bade 0.1.3 → 0.1.4

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: 77771024dceda938d8320695d2acbd5731588cbb
4
- data.tar.gz: 6c0b8f8c0f7cb9d17053599a754f0d28e25ea11c
3
+ metadata.gz: 7fce9a16c6a092fa176cd6adf94f87f09dc805ef
4
+ data.tar.gz: dd198f4a76c878eac584c0a03c5269f6174055c2
5
5
  SHA512:
6
- metadata.gz: 260bd643d97374af1e3209d25d3ad3c98090808191c8f13482e910e10e707f5fa41cf8160007325bf02066eeb0af01ccd603f93a84746bb6f26a8b95286c4259
7
- data.tar.gz: 6d9fbcf48c636f38c608bbb37b7096c2e2aadfc208d4bf749fc9e74c87fc2314765752b93fb7124a4a8d663de82749e310bfb12afae38052b26ed4353ef1c78d
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/samnung/bade'
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
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
 
2
2
  # Bade
3
3
 
4
- [![Build Status](https://semaphoreci.com/api/v1/projects/61441d8f-9c6b-41c2-b677-1ef8516649e5/559728/badge.svg)](https://semaphoreci.com/samnung/bade)
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/samnung/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
+ 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
- file_obj = if file.is_a?(String)
39
- File.new(file, 'r')
40
- else
41
- file
42
- end
38
+ path = if file.is_a?(File)
39
+ file.path
40
+ else
41
+ file
42
+ end
43
43
 
44
- from_source(file_obj.read, file_obj.path)
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 _parse_document_from_file(file_path)
112
- parser = Parser.new(file_path: file_path)
113
-
114
- new_path = if File.exists?(file_path)
115
- file_path
116
- elsif File.exists?("#{file_path}.bade")
117
- "#{file_path}.bade"
118
- end
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
- raise "Not existing file with path #{file_path}" if new_path.nil?
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
- document = parser.parse(File.read(new_path))
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(new_path))
129
- document.sub_documents << _parse_document_from_file(sub_path)
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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Bade
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
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.3
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-10-04 00:00:00.000000000 Z
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/samnung/bade
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.5.1
103
+ rubygems_version: 2.4.8
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Minimalistic template engine for Ruby.