rabl 0.0.2 → 0.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.
@@ -1,4 +1,4 @@
1
- module JRB
1
+ module Rabl
2
2
  class Builder
3
3
  # Constructs a new ejs hash based on given object and options
4
4
  def initialize(object, options, &block)
@@ -74,14 +74,14 @@ module JRB
74
74
  @_result.merge!(glued_attributes)
75
75
  end
76
76
 
77
- # Renders a partial hash based on another jrb template
77
+ # Renders a partial hash based on another rabl template
78
78
  # partial("users/show", :object => @user)
79
79
  def partial(file, options={}, &block)
80
- source = File.read(Rails.root.join("app/views/" + file + ".json.jrb"))
80
+ source = File.read(Rails.root.join("app/views/" + file + ".json.rabl"))
81
81
  self.object_to_hash(options[:object], source, &block)
82
82
  end
83
83
 
84
- # Extends an existing jrb template with additional attributes in the block
84
+ # Extends an existing rabl template with additional attributes in the block
85
85
  # extends("users/show") { attribute :full_name }
86
86
  def extends(file, options={}, &block)
87
87
  options = options.merge!(:object => @_object)
@@ -1,4 +1,4 @@
1
- module JRB
1
+ module Rabl
2
2
  class Engine
3
3
  # Constructs a new ejs engine based on given vars, handler and declarations
4
4
  def initialize(vars, handler, source_string=nil, &block)
@@ -52,17 +52,17 @@ module JRB
52
52
  @_options[:glue].push({ :data => data, :block => block })
53
53
  end
54
54
 
55
- # Extends an existing jrb template with additional attributes in the block
55
+ # Extends an existing rabl template with additional attributes in the block
56
56
  # extends("users/show", :object => @user) { attribute :full_name }
57
57
  def extends(file, options={}, &block)
58
58
  @_options[:extends] ||= []
59
59
  @_options[:extends].push({ :file => file, :options => options, :block => block })
60
60
  end
61
61
 
62
- # Renders a partial hash based on another jrb template
62
+ # Renders a partial hash based on another rabl template
63
63
  # partial("users/show", :object => @user)
64
64
  def partial(file, options={}, &block)
65
- source = File.read(Rails.root.join("app/views/" + file + ".json.jrb"))
65
+ source = File.read(Rails.root.join("app/views/" + file + ".json.rabl"))
66
66
  self.object_to_hash(options[:object], source, &block)
67
67
  end
68
68
 
@@ -70,9 +70,9 @@ module JRB
70
70
  # to_hash(:root => true)
71
71
  def to_hash(options={})
72
72
  if @_object.is_a?(ActiveRecord::Base)
73
- JRB::Builder.new(@_object, @_options).to_hash(options)
73
+ Rabl::Builder.new(@_object, @_options).to_hash(options)
74
74
  elsif @_object.respond_to?(:each)
75
- @_object.map { |object| JRB::Builder.new(object, @_options).to_hash(options) }
75
+ @_object.map { |object| Rabl::Builder.new(object, @_options).to_hash(options) }
76
76
  end
77
77
  end
78
78
 
@@ -3,11 +3,11 @@ require 'action_view/template'
3
3
 
4
4
  module ActionView
5
5
  module TemplateHandlers
6
- class JRBHandler < TemplateHandler
6
+ class RablHandler < TemplateHandler
7
7
  include Compilable
8
8
 
9
9
  def compile(template) %{
10
- ::JRB::Engine.new(assigns.merge(local_assigns), self) do
10
+ ::Rabl::Engine.new(assigns.merge(local_assigns), self) do
11
11
  #{template.source}
12
12
  end.to_#{template.format}
13
13
  } end
@@ -15,4 +15,4 @@ module ActionView
15
15
  end
16
16
  end
17
17
 
18
- ActionView::Template.register_template_handler :jrb, ActionView::TemplateHandlers::JRBHandler
18
+ ActionView::Template.register_template_handler :rabl, ActionView::TemplateHandlers::RablHandler
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan Esquenazi