trenni 1.4.1 → 1.4.3

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: 3c2a33d255bc9d2ed30d0e54ee6b0b95f3800ba8
4
- data.tar.gz: 49d50142db0d3621ca2b95c81c475dea3616d89d
3
+ metadata.gz: 7b7bbd098228bcbec7f60dd080ae58a1fce57092
4
+ data.tar.gz: a759d347ef7d1aea336874e6659ecc09a125d665
5
5
  SHA512:
6
- metadata.gz: f788a9552f2ef0590292acf3fee2104db05958cd166d44c761051b23ffd8d915b10159f4ab0254a1ae776e52be607a95c9d40a339e711abaadf9ff9fb67216da
7
- data.tar.gz: 7f96731a0c1cc4594a6398ca6d8c8bb0437710085d0ed4da29d1f12be5615a3512bce3da75215a9e294dce1a45f447f8cbafd55704bcebe196b9bf4bffe02aa6
6
+ metadata.gz: 3fa46a62bfeab0e19d5bc798f1eed8189f81a1d03563251ebed0a17900a7c509c5349d3bfe5d8fd9f9b34fc5958b167aac86612d6e053fdf51e4a52b5befa03e
7
+ data.tar.gz: 4441c66c6e044736268b1f73e73dd2c7104e6f161d6282a6b566a4211b2fce3201360036c82679511f1b73ef80e38a835a2285d991518a28a5fb039335c39a47
data/.simplecov ADDED
@@ -0,0 +1,9 @@
1
+
2
+ SimpleCov.start do
3
+ add_filter "/spec/"
4
+ end
5
+
6
+ if ENV['TRAVIS']
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+ end
data/.travis.yml CHANGED
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - "2.0"
4
4
  - "2.1"
5
+ env: COVERAGE=true
data/Gemfile CHANGED
@@ -6,3 +6,8 @@ gemspec
6
6
  group :development do
7
7
  gem "ruby-prof"
8
8
  end
9
+
10
+ group :test do
11
+ gem 'simplecov'
12
+ gem 'coveralls', require: false
13
+ end
data/README.md CHANGED
@@ -8,23 +8,27 @@ In addition, Trenni includes an SGML/XML builder to assist with the generation
8
8
  of pleasantly formatted markup.
9
9
 
10
10
  [![Build Status](https://secure.travis-ci.org/ioquatix/trenni.png)](http://travis-ci.org/ioquatix/trenni)
11
+ [![Code Climate](https://codeclimate.com/github/ioquatix/trenni.png)](https://codeclimate.com/github/ioquatix/trenni)
12
+ [![Coverage Status](https://coveralls.io/repos/ioquatix/trenni/badge.svg)](https://coveralls.io/r/ioquatix/trenni)
11
13
 
12
14
  ## Installation
13
15
 
14
16
  Add this line to your application's Gemfile:
15
17
 
16
- gem 'trenni'
18
+ gem 'trenni'
17
19
 
18
20
  And then execute:
19
21
 
20
- $ bundle
22
+ $ bundle
21
23
 
22
24
  Or install it yourself as:
23
25
 
24
- $ gem install trenni
26
+ $ gem install trenni
25
27
 
26
28
  ## Usage
27
29
 
30
+ ### Templates
31
+
28
32
  Trenni templates work essentially the same way as all other templating systems:
29
33
 
30
34
  template = Trenni::Template.new('<?r items.each do |item| ?>#{item}<?r end ?>')
@@ -37,6 +41,23 @@ The code above demonstrate the only two constructs, `<?r expression ?>` and `#{
37
41
 
38
42
  Trenni provides a slightly higher performance API using objects rather than bindings. If you provide an object instance, `instance_eval` would be used instead.
39
43
 
44
+ ### Builder
45
+
46
+ Trenni can help construct XML/HTML using a simple DSL:
47
+
48
+ Trenni::Builder.fragment do |builder|
49
+ builder.inline 'p' do
50
+ builder.tag 'strong' do
51
+ builder.text 'Hello'
52
+ end
53
+ builder.text ' World'
54
+ end
55
+ builder.tag 'script', type: 'text/html' do
56
+ builder.text 'console.log("Hello World")'
57
+ end
58
+ end
59
+ # => "<p><strong>Hello</strong> World</p>\n<script type=\"text/html\">\n\tconsole.log(\"Hello World\")\n</script>"
60
+
40
61
  ## Contributing
41
62
 
42
63
  1. Fork it
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.rspec_opts = ["--require", "simplecov"] if ENV['COVERAGE']
6
+ end
5
7
 
6
8
  task :default => :spec
@@ -21,7 +21,6 @@
21
21
  require 'trenni/strings'
22
22
 
23
23
  module Trenni
24
-
25
24
  INSTRUCT_ATTRIBUTES = [
26
25
  ['version', '1.0'],
27
26
  ['encoding', 'UTF-8']
@@ -180,6 +179,9 @@ module Trenni
180
179
 
181
180
  @output.write "</#{name}>"
182
181
  else
182
+ # The parent has one more child:
183
+ @level[-1] += 1
184
+
183
185
  @output.write indentation + "<#{name}#{tag_attributes(attributes)}/>"
184
186
  end
185
187
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Trenni
22
- VERSION = "1.4.1"
22
+ VERSION = "1.4.3"
23
23
  end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env rspec
2
2
 
3
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
4
  #
@@ -52,6 +52,14 @@ module Trenni::BuilderSpec
52
52
  expect(builder.output.string).to be == "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<title>Hello World</title>\n\t</head>\n\t<body>\n\t</body>\n</html>"
53
53
  end
54
54
 
55
+ it "should indent self-closing tag correctly" do
56
+ builder = Trenni::Builder.new
57
+
58
+ builder.tag('foo') { builder.tag('bar') }
59
+
60
+ expect(builder.output.string).to be == "<foo>\n\t<bar/>\n</foo>"
61
+ end
62
+
55
63
  it "should produce inline html" do
56
64
  builder = Trenni::Builder.new(:indent => true)
57
65
 
@@ -92,6 +100,14 @@ module Trenni::BuilderSpec
92
100
  expect(builder.output.string).to be == %Q{<option required/>}
93
101
  end
94
102
 
103
+ it "should output without changing escaped characters" do
104
+ builder = Trenni::Builder.new(:strict => false)
105
+
106
+ builder.tag "section", :'data-text' => 'foo\nbar'
107
+
108
+ expect(builder.output.string).to be == '<section data-text="foo\nbar"/>'
109
+ end
110
+
95
111
  it "should order attributes as specified" do
96
112
  builder = Trenni::Builder.new(:strict => true)
97
113
  builder.tag :t, [[:a, 10], [:b, 20]]
data/trenni.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.3"
28
- spec.add_development_dependency "rspec", "~> 3.0.0.rc1"
28
+ spec.add_development_dependency "rspec", "~> 3.4.0"
29
29
  spec.add_development_dependency "rake"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trenni
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.0.rc1
33
+ version: 3.4.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.0.rc1
40
+ version: 3.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +63,7 @@ extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
65
  - ".gitignore"
66
+ - ".simplecov"
66
67
  - ".travis.yml"
67
68
  - Gemfile
68
69
  - README.md
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.4.6
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: A fast native templating system that compiles directly to Ruby code.