trenni 3.0.0 → 3.0.3
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 +4 -4
- data/.travis.yml +6 -1
- data/Rakefile +5 -79
- data/ext/Rakefile +18 -0
- data/ext/trenni/extconf.rb +2 -0
- data/lib/trenni/version.rb +1 -1
- data/spec/spec_helper.rb +24 -0
- data/spec/trenni/parsers_performance_spec.rb +0 -16
- data/spec/trenni/template_performance_spec.rb +0 -2
- data/tasks/entities.rake +33 -0
- data/tasks/parsers.rake +38 -0
- data/trenni.gemspec +4 -4
- metadata +35 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb9c2bbe55c3fe6cf46a043cb242ad079c914ec
|
4
|
+
data.tar.gz: 489dfdf5ea722b9f6f0af82a97c9f374e2129462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd32df2fba19bb867d04da303ee5913fbf7e709805cbac31687c145c815578d0f6d800cf117606eaae91c8cc6ebe376d050d570ebd68c45889d97485656f2903
|
7
|
+
data.tar.gz: 76c1ef902dbc6174c426db011446af33b3a1f3d6c27eff97c1b1128a3f5ce39902a6368161cd91adb46f4db30146893cf1a3190f37bab7f232fd20d8c659e99f
|
data/.travis.yml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
+
before_install:
|
4
|
+
- gem install bundler
|
5
|
+
- gem update bundler
|
3
6
|
before_script:
|
4
|
-
- rake compile
|
7
|
+
- sh -c "cd ext && rake compile"
|
5
8
|
rvm:
|
6
9
|
- 2.1.8
|
7
10
|
- 2.2.4
|
8
11
|
- 2.3.0
|
9
12
|
- 2.4.0
|
10
13
|
- ruby-head
|
14
|
+
- jruby-head
|
11
15
|
- rbx-2
|
12
16
|
env:
|
13
17
|
- COVERAGE=true
|
@@ -16,3 +20,4 @@ matrix:
|
|
16
20
|
allow_failures:
|
17
21
|
- rvm: "rbx-2"
|
18
22
|
- rvm: "ruby-head"
|
23
|
+
- rvm: "jruby-head"
|
data/Rakefile
CHANGED
@@ -1,86 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
4
|
+
# Load all rake tasks:
|
5
|
+
import(*Dir.glob('tasks/**/*.rake'))
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
task :fetch_entities do
|
9
|
-
require 'open-uri'
|
10
|
-
require 'json'
|
11
|
-
|
12
|
-
entites_json_path = File.expand_path("entities.json", __dir__)
|
13
|
-
|
14
|
-
unless File.exist? entites_json_path
|
15
|
-
url = "https://www.w3.org/TR/html5/entities.json"
|
16
|
-
File.write(entites_json_path, open(url).read)
|
17
|
-
end
|
18
|
-
|
19
|
-
@entities = JSON.parse(File.read(entites_json_path)).delete_if{|string, _| !string.end_with? ';'}
|
20
|
-
end
|
21
|
-
|
22
|
-
task :update_entities => :fetch_entities do
|
23
|
-
require 'trenni/template'
|
24
|
-
|
25
|
-
paths = {
|
26
|
-
'ext/trenni/entities.rl' => 'ext/trenni/entities.trenni',
|
27
|
-
'lib/trenni/entities.rb' => 'lib/trenni/entities.trenni',
|
28
|
-
}
|
29
|
-
|
30
|
-
paths.each do |output_path, template_path|
|
31
|
-
template = Trenni::Template.load_file(template_path)
|
32
|
-
|
33
|
-
puts template.send(:code)
|
34
|
-
|
35
|
-
#output = template.to_string(@entities)
|
36
|
-
|
37
|
-
#File.write(output_path, output)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
require "rake/extensiontask"
|
42
|
-
|
43
|
-
Rake::ExtensionTask.new "trenni" do |ext|
|
44
|
-
ext.lib_dir = "lib/trenni"
|
45
|
-
end
|
46
|
-
|
47
|
-
PARSERS_DIRECTORY = File.expand_path("parsers", __dir__)
|
48
|
-
FALLBACK_DIRECTORY = File.expand_path("lib/trenni/fallback", __dir__)
|
49
|
-
NATIVE_DIRECTORY = File.expand_path("ext/trenni", __dir__)
|
50
|
-
|
51
|
-
task :generate_fallback_parsers do
|
52
|
-
Dir.chdir(FALLBACK_DIRECTORY) do
|
53
|
-
Dir.glob("*.rl").each do |parser_path|
|
54
|
-
sh("ragel", "-I", PARSERS_DIRECTORY, "-R", parser_path, "-F1")
|
55
|
-
end
|
56
|
-
|
57
|
-
sh("ruby-beautify", "--tabs", "--overwrite", *Dir.glob("*.rb"))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
task :generate_native_parsers do
|
62
|
-
Dir.chdir(NATIVE_DIRECTORY) do
|
63
|
-
Dir.glob("*.rl").each do |parser_path|
|
64
|
-
sh("ragel", "-I", PARSERS_DIRECTORY, "-C", parser_path, "-G2")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
task :generate_parsers => [:generate_native_parsers, :generate_fallback_parsers, :compile]
|
70
|
-
|
71
|
-
task :visualize_parsers do
|
72
|
-
Dir.chdir(FALLBACK_DIRECTORY) do
|
73
|
-
Dir.glob("*.rl").each do |parser_path|
|
74
|
-
dot_path = parser_path + ".dot"
|
75
|
-
sh("ragel", "-I", PARSERS_DIRECTORY, "-Vp", parser_path, "-o", dot_path)
|
76
|
-
|
77
|
-
pdf_path = parser_path + ".pdf"
|
78
|
-
sh("dot", "-Tpdf", "-o", pdf_path, dot_path)
|
79
|
-
|
80
|
-
sh("open", pdf_path) rescue nil
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
7
|
+
RSpec::Core::RakeTask.new(:test)
|
84
8
|
|
85
9
|
task :environment do
|
86
10
|
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
@@ -91,3 +15,5 @@ task :console => :environment do
|
|
91
15
|
|
92
16
|
Pry.start
|
93
17
|
end
|
18
|
+
|
19
|
+
task :default => :test
|
data/ext/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
spec_path = File.expand_path('../trenni.gemspec', Dir.pwd)
|
3
|
+
spec = Gem::Specification.load(spec_path)
|
4
|
+
|
5
|
+
require "rake/extensiontask"
|
6
|
+
|
7
|
+
unless RUBY_PLATFORM =~ /java/
|
8
|
+
Rake::ExtensionTask.new("trenni") do |ext|
|
9
|
+
ext.ext_dir = 'trenni'
|
10
|
+
ext.lib_dir = '../lib/trenni'
|
11
|
+
end
|
12
|
+
else
|
13
|
+
task :compile do
|
14
|
+
puts "Nothing to compile for this platform."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :compile
|
data/ext/trenni/extconf.rb
CHANGED
data/lib/trenni/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -19,6 +19,30 @@ end
|
|
19
19
|
require "bundler/setup"
|
20
20
|
require "trenni"
|
21
21
|
|
22
|
+
begin
|
23
|
+
require 'ruby-prof'
|
24
|
+
|
25
|
+
RSpec.shared_context "profile" do
|
26
|
+
before(:all) do
|
27
|
+
RubyProf.start
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:all) do
|
31
|
+
result = RubyProf.stop
|
32
|
+
|
33
|
+
# Print a flat profile to text
|
34
|
+
printer = RubyProf::FlatPrinter.new(result)
|
35
|
+
printer.print(STDOUT)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
RSpec.shared_context "profile" do
|
40
|
+
before(:all) do
|
41
|
+
puts "Profiling not supported on this platform."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
22
46
|
RSpec.configure do |config|
|
23
47
|
# Enable flags like --only-failures and --next-failure
|
24
48
|
config.example_status_persistence_file_path = ".rspec_status"
|
@@ -5,22 +5,6 @@ require 'trenni/entities'
|
|
5
5
|
|
6
6
|
require 'nokogiri'
|
7
7
|
|
8
|
-
require 'ruby-prof'
|
9
|
-
|
10
|
-
RSpec.shared_context "profile" do
|
11
|
-
before(:all) do
|
12
|
-
RubyProf.start
|
13
|
-
end
|
14
|
-
|
15
|
-
after(:all) do
|
16
|
-
result = RubyProf.stop
|
17
|
-
|
18
|
-
# Print a flat profile to text
|
19
|
-
printer = RubyProf::FlatPrinter.new(result)
|
20
|
-
printer.print(STDOUT)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
8
|
RSpec.describe Trenni::Parsers do
|
25
9
|
# include_context "profile"
|
26
10
|
|
data/tasks/entities.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
task :fetch_entities do
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
entites_json_path = File.expand_path("entities.json", __dir__)
|
7
|
+
|
8
|
+
unless File.exist? entites_json_path
|
9
|
+
url = "https://www.w3.org/TR/html5/entities.json"
|
10
|
+
File.write(entites_json_path, open(url).read)
|
11
|
+
end
|
12
|
+
|
13
|
+
@entities = JSON.parse(File.read(entites_json_path)).delete_if{|string, _| !string.end_with? ';'}
|
14
|
+
end
|
15
|
+
|
16
|
+
task :update_entities => :fetch_entities do
|
17
|
+
require 'trenni/template'
|
18
|
+
|
19
|
+
paths = {
|
20
|
+
'ext/trenni/entities.rl' => 'ext/trenni/entities.trenni',
|
21
|
+
'lib/trenni/entities.rb' => 'lib/trenni/entities.trenni',
|
22
|
+
}
|
23
|
+
|
24
|
+
paths.each do |output_path, template_path|
|
25
|
+
template = Trenni::Template.load_file(template_path)
|
26
|
+
|
27
|
+
puts template.send(:code)
|
28
|
+
|
29
|
+
#output = template.to_string(@entities)
|
30
|
+
|
31
|
+
#File.write(output_path, output)
|
32
|
+
end
|
33
|
+
end
|
data/tasks/parsers.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
PARSERS_DIRECTORY = File.expand_path("parsers", __dir__)
|
3
|
+
FALLBACK_DIRECTORY = File.expand_path("lib/trenni/fallback", __dir__)
|
4
|
+
NATIVE_DIRECTORY = File.expand_path("ext/trenni", __dir__)
|
5
|
+
|
6
|
+
task :generate_fallback_parsers do
|
7
|
+
Dir.chdir(FALLBACK_DIRECTORY) do
|
8
|
+
Dir.glob("*.rl").each do |parser_path|
|
9
|
+
sh("ragel", "-I", PARSERS_DIRECTORY, "-R", parser_path, "-F1")
|
10
|
+
end
|
11
|
+
|
12
|
+
sh("ruby-beautify", "--tabs", "--overwrite", *Dir.glob("*.rb"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :generate_native_parsers do
|
17
|
+
Dir.chdir(NATIVE_DIRECTORY) do
|
18
|
+
Dir.glob("*.rl").each do |parser_path|
|
19
|
+
sh("ragel", "-I", PARSERS_DIRECTORY, "-C", parser_path, "-G2")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :generate_parsers => [:generate_native_parsers, :generate_fallback_parsers, :compile]
|
25
|
+
|
26
|
+
task :visualize_parsers do
|
27
|
+
Dir.chdir(FALLBACK_DIRECTORY) do
|
28
|
+
Dir.glob("*.rl").each do |parser_path|
|
29
|
+
dot_path = parser_path + ".dot"
|
30
|
+
sh("ragel", "-I", PARSERS_DIRECTORY, "-Vp", parser_path, "-o", dot_path)
|
31
|
+
|
32
|
+
pdf_path = parser_path + ".pdf"
|
33
|
+
sh("dot", "-Tpdf", "-o", pdf_path, dot_path)
|
34
|
+
|
35
|
+
sh("open", pdf_path) rescue nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/trenni.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'trenni/version'
|
2
|
+
require_relative 'lib/trenni/version'
|
5
3
|
|
6
4
|
Gem::Specification.new do |spec|
|
7
5
|
spec.name = "trenni"
|
6
|
+
spec.platform = Gem::Platform::RUBY
|
8
7
|
spec.version = Trenni::VERSION
|
9
8
|
spec.authors = ["Samuel Williams"]
|
10
9
|
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
@@ -25,7 +24,8 @@ Gem::Specification.new do |spec|
|
|
25
24
|
|
26
25
|
spec.required_ruby_version = '~> 2.1'
|
27
26
|
|
28
|
-
spec.extensions = %w[ext/
|
27
|
+
spec.extensions = %w[ext/Rakefile]
|
28
|
+
spec.add_dependency "rake-compiler"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.3"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.4"
|
metadata
CHANGED
@@ -1,66 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trenni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: rake-compiler
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
16
29
|
requirements:
|
17
30
|
- - "~>"
|
18
31
|
- !ruby/object:Gem::Version
|
19
32
|
version: '1.3'
|
20
|
-
|
33
|
+
name: bundler
|
21
34
|
prerelease: false
|
35
|
+
type: :development
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
30
43
|
requirements:
|
31
44
|
- - "~>"
|
32
45
|
- !ruby/object:Gem::Version
|
33
46
|
version: '3.4'
|
34
|
-
|
47
|
+
name: rspec
|
35
48
|
prerelease: false
|
49
|
+
type: :development
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '3.4'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
44
57
|
requirements:
|
45
58
|
- - ">="
|
46
59
|
- !ruby/object:Gem::Version
|
47
60
|
version: '0'
|
48
|
-
|
61
|
+
name: rake
|
49
62
|
prerelease: false
|
63
|
+
type: :development
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
|
-
description: "\tTrenni is a templating system built on top of SGML/XML. It uses efficient\n\
|
56
|
-
parsers where possible and compiles templates into efficient Ruby.\n\t\n\
|
57
|
-
Trenni includes an SGML/XML builder to assist with the generation\n\
|
58
|
-
formatted markup which is compatible with the included parsers.\n"
|
69
|
+
description: "\tTrenni is a templating system built on top of SGML/XML. It uses efficient\n\
|
70
|
+
\tnative parsers where possible and compiles templates into efficient Ruby.\n\t\n\
|
71
|
+
\tIn addition, Trenni includes an SGML/XML builder to assist with the generation\n\
|
72
|
+
\tof pleasantly formatted markup which is compatible with the included parsers.\n"
|
59
73
|
email:
|
60
74
|
- samuel.williams@oriontransfer.co.nz
|
61
75
|
executables: []
|
62
76
|
extensions:
|
63
|
-
- ext/
|
77
|
+
- ext/Rakefile
|
64
78
|
extra_rdoc_files: []
|
65
79
|
files:
|
66
80
|
- ".gitignore"
|
@@ -74,6 +88,7 @@ files:
|
|
74
88
|
- benchmark/interpolation_vs_concat.rb
|
75
89
|
- benchmark/io_vs_string.rb
|
76
90
|
- entities.json
|
91
|
+
- ext/Rakefile
|
77
92
|
- ext/trenni/escape.c
|
78
93
|
- ext/trenni/escape.h
|
79
94
|
- ext/trenni/extconf.rb
|
@@ -129,11 +144,13 @@ files:
|
|
129
144
|
- spec/trenni/template_spec/interpolations.trenni
|
130
145
|
- spec/trenni/template_spec/large.trenni
|
131
146
|
- spec/trenni/template_spec/nested.trenni
|
147
|
+
- tasks/entities.rake
|
148
|
+
- tasks/parsers.rake
|
132
149
|
- trenni.gemspec
|
133
150
|
homepage: https://github.com/ioquatix/trenni
|
134
151
|
licenses: []
|
135
152
|
metadata: {}
|
136
|
-
post_install_message:
|
153
|
+
post_install_message:
|
137
154
|
rdoc_options: []
|
138
155
|
require_paths:
|
139
156
|
- lib
|
@@ -148,9 +165,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
165
|
- !ruby/object:Gem::Version
|
149
166
|
version: '0'
|
150
167
|
requirements: []
|
151
|
-
rubyforge_project:
|
152
|
-
rubygems_version: 2.6.
|
153
|
-
signing_key:
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.6.8
|
170
|
+
signing_key:
|
154
171
|
specification_version: 4
|
155
172
|
summary: A fast native templating system that compiles directly to Ruby code.
|
156
173
|
test_files:
|