rabl 0.6.3 → 0.6.5
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.
- data/.travis.yml +0 -2
- data/CHANGELOG.md +9 -0
- data/Gemfile +0 -2
- data/README.md +8 -8
- data/Rakefile +18 -3
- data/lib/rabl/partials.rb +54 -24
- data/lib/rabl/version.rb +1 -1
- data/rabl.gemspec +1 -1
- data/test/engine_test.rb +2 -2
- data/test/plist_engine_test.rb +21 -21
- metadata +8 -8
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.6.5
|
4
|
+
|
5
|
+
* Fixed issue with multi_json version use ~> 1.0 (Thanks @sferik)
|
6
|
+
|
7
|
+
## 0.6.4
|
8
|
+
|
9
|
+
* Further improvements to template path resolution for Rails (Thanks @radar)
|
10
|
+
* Change multi_json to be > 1.1.0 to support 1.2.0 with Oj support (Thanks @jherdman)
|
11
|
+
|
3
12
|
## 0.6.3
|
4
13
|
|
5
14
|
* Adds Rails 3.2 Integration Test
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -78,12 +78,12 @@ node(:read) { |post| post.read_by?(@user) }
|
|
78
78
|
|
79
79
|
Which would output the following JSON or XML when visiting `http://localhost:3000/posts.json`
|
80
80
|
|
81
|
-
```
|
82
|
-
[{ post :
|
81
|
+
```js
|
82
|
+
[{ "post" :
|
83
83
|
{
|
84
|
-
id : 5, title: "...", subject: "...",
|
85
|
-
user : { full_name : "..." },
|
86
|
-
read : true
|
84
|
+
"id" : 5, title: "...", subject: "...",
|
85
|
+
"user" : { full_name : "..." },
|
86
|
+
"read" : true
|
87
87
|
}
|
88
88
|
}]
|
89
89
|
```
|
@@ -463,7 +463,7 @@ Note that RABL can be nested arbitrarily deep within child nodes to allow for th
|
|
463
463
|
### Caching ###
|
464
464
|
|
465
465
|
Caching works by saving the entire template output to the configured cache_store in your application. Note that caching is currently **only available** for
|
466
|
-
Rails but support for other frameworks is planned in a future release.
|
466
|
+
Rails but support for other frameworks is planned in a future release.
|
467
467
|
|
468
468
|
For Rails, requires `action_controller.perform_caching` to be set to true in your environment, and for `cache` to be set to a key (object that responds to cache_key method, array or string).
|
469
469
|
|
@@ -568,8 +568,7 @@ See the [examples](https://github.com/nesquena/rabl/tree/master/examples) direct
|
|
568
568
|
|
569
569
|
Check out the [Issues](https://github.com/nesquena/rabl/issues) tab for a full list:
|
570
570
|
|
571
|
-
*
|
572
|
-
* Benchmarks and performance optimizations
|
571
|
+
* Rigorous benchmarking and performance optimizations
|
573
572
|
|
574
573
|
## Continuous Integration ##
|
575
574
|
|
@@ -595,6 +594,7 @@ Thanks to [Miso](http://gomiso.com) for allowing me to create this for our appli
|
|
595
594
|
* [Andrey Voronkov](https://github.com/Antiarchitect) - Added BSON format support
|
596
595
|
* [Alli Witheford](https://github.com/alzeih) - Added Plist format support
|
597
596
|
* [David Sommers](https://github.com/databyte) - Added template caching support for Rails
|
597
|
+
* [Ryan Bigg](https://github.com/radar) - Improved template resolution code
|
598
598
|
|
599
599
|
and many more contributors listed in the [CHANGELOG](https://github.com/nesquena/rabl/blob/master/CHANGELOG.md).
|
600
600
|
|
data/Rakefile
CHANGED
@@ -12,9 +12,24 @@ Rake::TestTask.new(:test) do |test|
|
|
12
12
|
test.ruby_opts = ['-rubygems']
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
# Running integration tests
|
16
|
+
# rake test:clean
|
17
|
+
# rake test:stup
|
18
|
+
# rake test:full
|
19
|
+
|
20
|
+
fixture_list = "{padrino_test,sinatra_test,rails2,rails3,rails3_2}"
|
21
|
+
|
22
|
+
desc "Clean up the fixtures being tested by cleaning and installing dependencies"
|
23
|
+
task "test:clean" do
|
24
|
+
Dir[File.dirname(__FILE__) + "/fixtures/#{fixture_list}"].each do |fixture|
|
25
|
+
puts "\n*** Cleaning up for #{File.basename(fixture)} tests ***\n"
|
26
|
+
puts `cd #{fixture}; rm Gemfile.lock`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Prepares the fixtures being tested by installing dependencies"
|
16
31
|
task "test:setup" do
|
17
|
-
Dir[File.dirname(__FILE__) + "/fixtures
|
32
|
+
Dir[File.dirname(__FILE__) + "/fixtures/#{fixture_list}"].each do |fixture|
|
18
33
|
puts "\n*** Setting up for #{File.basename(fixture)} tests ***\n"
|
19
34
|
`export BUNDLE_GEMFILE=#{fixture}/Gemfile` if ENV['TRAVIS']
|
20
35
|
puts `cd #{fixture}; bundle install;`
|
@@ -23,7 +38,7 @@ end
|
|
23
38
|
|
24
39
|
desc "Executes the fixture tests"
|
25
40
|
task "test:fixtures" do
|
26
|
-
Dir[File.dirname(__FILE__) + "/fixtures
|
41
|
+
Dir[File.dirname(__FILE__) + "/fixtures/#{fixture_list}"].each do |fixture|
|
27
42
|
puts "\n*** Running tests for #{File.basename(fixture)}... ***\n"
|
28
43
|
puts `cd #{fixture}; bundle check; bundle exec rake test:rabl`
|
29
44
|
end
|
data/lib/rabl/partials.rb
CHANGED
@@ -23,7 +23,7 @@ module Rabl
|
|
23
23
|
def object_to_hash(object, options={}, &block)
|
24
24
|
return object unless is_object?(object) || is_collection?(object)
|
25
25
|
return [] if is_collection?(object) && object.blank? # empty collection
|
26
|
-
engine_options = options.
|
26
|
+
engine_options = options.reverse_merge(:format => "hash", :root => (options[:root] || false))
|
27
27
|
Rabl::Engine.new(options[:source], engine_options).render(@_scope, :object => object, &block)
|
28
28
|
end
|
29
29
|
|
@@ -31,35 +31,65 @@ module Rabl
|
|
31
31
|
# fetch_source("show", :view_path => "...") => "...contents..."
|
32
32
|
def fetch_source(file, options={})
|
33
33
|
Rabl.source_cache(file, options[:view_path]) do
|
34
|
-
if defined? Padrino
|
35
|
-
|
36
|
-
# use Padrino's own template resolution mechanism
|
37
|
-
file_path, _ = context_scope.instance_eval { resolve_template(file) }
|
38
|
-
# Padrino chops the extension, stitch it back on
|
39
|
-
file_path = File.join(view_path.first.to_s, (file_path.to_s + ".rabl"))
|
34
|
+
file_path = if defined? Padrino
|
35
|
+
fetch_padrino_source(file, options)
|
40
36
|
elsif defined?(Rails) && context_scope
|
41
|
-
|
42
|
-
source_format = request_format if defined?(request_format)
|
43
|
-
view_path = Array(options[:view_path] || context_scope.view_paths.to_a)
|
44
|
-
if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
|
45
|
-
lookup_proc = lambda { |partial| context_scope.lookup_context.find_template(file, [], partial) }
|
46
|
-
template = lookup_proc.call(false) rescue lookup_proc.call(true)
|
47
|
-
file_path = template.identifier if template
|
48
|
-
elsif source_format && context_scope.respond_to?(:view_paths) # Rails 2
|
49
|
-
template = context_scope.view_paths.find_template(file, source_format, false)
|
50
|
-
file_path = template.filename if template
|
51
|
-
else # fallback to manual
|
52
|
-
file_path = Dir[File.join("{#{view_path.join(",")}}", file + ".{*.,}rabl")].first
|
53
|
-
end
|
37
|
+
fetch_rails_source(file, options)
|
54
38
|
elsif defined? Sinatra
|
55
|
-
|
56
|
-
file_path = Dir[File.join("{#{view_path.join(",")}}", file + ".{*.,}rabl")].first
|
39
|
+
fetch_sinatra_source(file, options)
|
57
40
|
end
|
58
41
|
|
59
|
-
raise "Cannot find rabl template '#{file}' within registered
|
42
|
+
raise "Cannot find rabl template '#{file}' within registered view paths!" unless File.exist?(file_path.to_s)
|
60
43
|
[File.read(file_path.to_s), file_path.to_s] if file_path
|
61
44
|
end
|
62
45
|
end
|
63
46
|
|
47
|
+
private
|
48
|
+
|
49
|
+
# Returns the rabl template path for padrino views using configured views
|
50
|
+
def fetch_padrino_source(file, options={})
|
51
|
+
view_path = Array(options[:view_path] || context_scope.settings.views)
|
52
|
+
# use Padrino's own template resolution mechanism
|
53
|
+
file_path, _ = context_scope.instance_eval { resolve_template(file) }
|
54
|
+
# Padrino chops the extension, stitch it back on
|
55
|
+
File.join(view_path.first.to_s, (file_path.to_s + ".rabl"))
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns the rabl template path for Rails, including special lookups for Rails 2 and 3
|
59
|
+
def fetch_rails_source(file, options={})
|
60
|
+
# use Rails template resolution mechanism if possible (find_template)
|
61
|
+
source_format = request_format if defined?(request_format)
|
62
|
+
view_path = Array(options[:view_path] || context_scope.view_paths.to_a)
|
63
|
+
if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
|
64
|
+
lookup_proc = lambda { |partial| context_scope.lookup_context.find_template(file, [], partial) }
|
65
|
+
template = lookup_proc.call(false) rescue lookup_proc.call(true)
|
66
|
+
template.identifier if template
|
67
|
+
elsif source_format && context_scope.respond_to?(:view_paths) # Rails 2
|
68
|
+
template = context_scope.view_paths.find_template(file, source_format, false)
|
69
|
+
template.filename if template
|
70
|
+
else # manual file lookup
|
71
|
+
fetch_manual_template(view_path, file)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns the rabl template path for sinatra views using configured views
|
76
|
+
def fetch_sinatra_source(file, options={})
|
77
|
+
view_path = Array(options[:view_path] || context_scope.settings.views)
|
78
|
+
fetch_manual_template(view_path, file)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns the rabl template by looking up files within the view_path and specified file path
|
82
|
+
def fetch_manual_template(view_path, file)
|
83
|
+
Dir[File.join("{#{view_path.join(",")}}", "{#{file},#{partialized(file)}}" + ".{*.,}rabl")].first
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns a partialized version of a file path
|
87
|
+
# partialized("v1/variants/variant") => "v1/variants/_variant"
|
88
|
+
def partialized(file)
|
89
|
+
partial_file = file.split(File::SEPARATOR)
|
90
|
+
partial_file[-1] = "_#{partial_file[-1]}" unless partial_file[-1].start_with?("_")
|
91
|
+
partial_file.join(File::SEPARATOR)
|
92
|
+
end
|
93
|
+
|
64
94
|
end # Partials
|
65
|
-
end # Rabl
|
95
|
+
end # Rabl
|
data/lib/rabl/version.rb
CHANGED
data/rabl.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'multi_json', '~> 1.1.0'
|
23
22
|
s.add_dependency 'activesupport', '>= 2.3.14'
|
23
|
+
s.add_dependency 'multi_json', '~> 1.0'
|
24
24
|
|
25
25
|
s.add_development_dependency 'riot', '~> 0.12.3'
|
26
26
|
s.add_development_dependency 'rr', '~> 1.0.2'
|
data/test/engine_test.rb
CHANGED
@@ -33,13 +33,13 @@ context "Rabl::Engine" do
|
|
33
33
|
context "with cache and options" do
|
34
34
|
setup do
|
35
35
|
template = rabl %q{
|
36
|
-
cache 'foo', expires_in
|
36
|
+
cache 'foo', :expires_in => 'bar'
|
37
37
|
}
|
38
38
|
template.render(Object.new)
|
39
39
|
template.instance_eval('@engine')
|
40
40
|
end
|
41
41
|
|
42
|
-
asserts_topic.assigns(:_cache) { ['foo', { expires_in
|
42
|
+
asserts_topic.assigns(:_cache) { ['foo', { :expires_in => 'bar' }] }
|
43
43
|
end
|
44
44
|
|
45
45
|
context "without cache" do
|
data/test/plist_engine_test.rb
CHANGED
@@ -32,8 +32,8 @@ context "Rabl::Engine" do
|
|
32
32
|
}
|
33
33
|
scope = Object.new
|
34
34
|
scope.instance_variable_set :@user, User.new
|
35
|
-
template.render(scope)
|
36
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>person</key>\n\t<dict/>\n</dict>\n</plist>\n"
|
35
|
+
template.render(scope).split("").sort
|
36
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>person</key>\n\t<dict/>\n</dict>\n</plist>\n".split("").sort
|
37
37
|
end
|
38
38
|
|
39
39
|
context "#collection" do
|
@@ -44,8 +44,8 @@ context "Rabl::Engine" do
|
|
44
44
|
}
|
45
45
|
scope = Object.new
|
46
46
|
scope.instance_variable_set :@users, [User.new, User.new]
|
47
|
-
template.render(scope)
|
48
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<array>\n\t<dict>\n\t\t<key>user</key>\n\t\t<dict/>\n\t</dict>\n\t<dict>\n\t\t<key>user</key>\n\t\t<dict/>\n\t</dict>\n</array>\n</plist>\n"
|
47
|
+
template.render(scope).split("").sort
|
48
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<array>\n\t<dict>\n\t\t<key>user</key>\n\t\t<dict/>\n\t</dict>\n\t<dict>\n\t\t<key>user</key>\n\t\t<dict/>\n\t</dict>\n</array>\n</plist>\n".split("").sort
|
49
49
|
|
50
50
|
asserts "that it sets root node for objects" do
|
51
51
|
template = rabl %{
|
@@ -53,8 +53,8 @@ context "Rabl::Engine" do
|
|
53
53
|
}
|
54
54
|
scope = Object.new
|
55
55
|
scope.instance_variable_set :@users, [User.new, User.new]
|
56
|
-
template.render(scope)
|
57
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>person</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>person</key>\n\t\t\t<dict/>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>person</key>\n\t\t\t<dict/>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n"
|
56
|
+
template.render(scope).split("").sort
|
57
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>person</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>person</key>\n\t\t\t<dict/>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>person</key>\n\t\t\t<dict/>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n".split("").sort
|
58
58
|
|
59
59
|
end
|
60
60
|
|
@@ -67,8 +67,8 @@ context "Rabl::Engine" do
|
|
67
67
|
}
|
68
68
|
scope = Object.new
|
69
69
|
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
70
|
-
template.render(scope)
|
71
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>name</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n"
|
70
|
+
template.render(scope).split("").sort
|
71
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>name</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n".split("").sort
|
72
72
|
|
73
73
|
asserts "that it can add attribute under a different key name through :as" do
|
74
74
|
template = rabl %{
|
@@ -77,8 +77,8 @@ context "Rabl::Engine" do
|
|
77
77
|
}
|
78
78
|
scope = Object.new
|
79
79
|
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
80
|
-
template.render(scope)
|
81
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n"
|
80
|
+
template.render(scope).split("").sort
|
81
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n".split("").sort
|
82
82
|
|
83
83
|
asserts "that it can add attribute under a different key name through hash" do
|
84
84
|
template = rabl %{
|
@@ -87,8 +87,8 @@ context "Rabl::Engine" do
|
|
87
87
|
}
|
88
88
|
scope = Object.new
|
89
89
|
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
90
|
-
template.render(scope)
|
91
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n"
|
90
|
+
template.render(scope).split("").sort
|
91
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>irvine</string>\n\t</dict>\n</dict>\n</plist>\n".split("").sort
|
92
92
|
|
93
93
|
end
|
94
94
|
|
@@ -98,15 +98,15 @@ context "Rabl::Engine" do
|
|
98
98
|
template = rabl %{
|
99
99
|
code(:foo) { 'bar' }
|
100
100
|
}
|
101
|
-
template.render(Object.new)
|
102
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>foo</key>\n\t<string>bar</string>\n</dict>\n</plist>\n"
|
101
|
+
template.render(Object.new).split("").sort
|
102
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>foo</key>\n\t<string>bar</string>\n</dict>\n</plist>\n".split("").sort
|
103
103
|
|
104
104
|
asserts "that it can be passed conditionals" do
|
105
105
|
template = rabl %{
|
106
106
|
code(:foo, :if => lambda { |i| false }) { 'bar' }
|
107
107
|
}
|
108
|
-
template.render(Object.new)
|
109
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict/>\n</plist>\n"
|
108
|
+
template.render(Object.new).split("").sort
|
109
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict/>\n</plist>\n".split("").sort
|
110
110
|
|
111
111
|
end
|
112
112
|
|
@@ -120,8 +120,8 @@ context "Rabl::Engine" do
|
|
120
120
|
}
|
121
121
|
scope = Object.new
|
122
122
|
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
123
|
-
template.render(scope)
|
124
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>name</key>\n\t\t<string>leo</string>\n\t\t<key>user</key>\n\t\t<dict>\n\t\t\t<key>city</key>\n\t\t\t<string>LA</string>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
|
123
|
+
template.render(scope).split("").sort
|
124
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>user</key>\n\t<dict>\n\t\t<key>name</key>\n\t\t<string>leo</string>\n\t\t<key>user</key>\n\t\t<dict>\n\t\t\t<key>city</key>\n\t\t\t<string>LA</string>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n".split("").sort
|
125
125
|
|
126
126
|
asserts "that it can create a child node with different key" do
|
127
127
|
template = rabl %{
|
@@ -269,7 +269,7 @@ context "Rabl::Engine" do
|
|
269
269
|
|
270
270
|
context "#code" do
|
271
271
|
|
272
|
-
asserts "that it can create an
|
272
|
+
asserts "that it can create an arbitrary code node" do
|
273
273
|
template = rabl %{
|
274
274
|
code(:foo) { 'bar' }
|
275
275
|
}
|
@@ -295,8 +295,8 @@ context "Rabl::Engine" do
|
|
295
295
|
}
|
296
296
|
scope = Object.new
|
297
297
|
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
298
|
-
template.render(scope)
|
299
|
-
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>name</key>\n\t<string>leo</string>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>LA</string>\n\t</dict>\n</dict>\n</plist>\n"
|
298
|
+
template.render(scope).split("").sort
|
299
|
+
end.equals "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>name</key>\n\t<string>leo</string>\n\t<key>user</key>\n\t<dict>\n\t\t<key>city</key>\n\t\t<string>LA</string>\n\t</dict>\n</dict>\n</plist>\n".split("").sort
|
300
300
|
|
301
301
|
asserts "that it can create a child node with different key" do
|
302
302
|
template = rabl %{
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nathan Esquenazi
|
@@ -10,28 +10,28 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-28 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: activesupport
|
17
17
|
prerelease: false
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 2.3.14
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: multi_json
|
28
28
|
prerelease: false
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: "1.0"
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|