Skip to content

Commit

Permalink
Style fixes and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
gazay committed Nov 4, 2014
1 parent 53e0d65 commit d361397
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.bundle/
Gemfile.lock
30 changes: 14 additions & 16 deletions lib/gon/sinatra/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@ module Gon
module Sinatra
module Helpers
def include_gon(options = {})
unless gon.all_variables.empty?
data = gon.all_variables
namespace = options[:namespace] || 'gon'
script = "<script>window." + namespace + " = {};"
unless options[:camel_case]
data.each do |key, val|
script += namespace + "." + key.to_s + '=' + val.to_json + ";"
end
else
data.each do |key, val|
script += namespace + "." + key.to_s.camelize(:lower) + '=' + val.to_json + ";"
end
return '' if gon.all_variables.empty?

data = gon.all_variables
namespace = options[:namespace] || 'gon'
script = "<script>window." + namespace + " = {};"
unless options[:camel_case]
data.each do |key, val|
script += namespace + "." + key.to_s + '=' + val.to_json + ";"
end
script += "</script>"
script
else
""
data.each do |key, val|
script += namespace + "." + key.to_s.camelize(:lower) + '=' + val.to_json + ";"
end
end
script += "</script>"
script
end
end

Expand All @@ -32,4 +30,4 @@ def gon
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/gon/sinatra/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def set_variable(name, value)
alias :set :set_variable

def rabl(view_path, options = {})
raise Exception.new("You must require rabl and register Gon::Sinatra::Rabl to use rabl") unless defined? Rabl
unless defined?(::Rabl)
raise Exception.new("You must require rabl and register Gon::Sinatra::Rabl to use rabl")
end

unless options[:instance]
raise ArgumentError.new("You should pass :instance in options: :instance => self")
Expand Down
2 changes: 1 addition & 1 deletion lib/gon/sinatra/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Gon
module Sinatra
VERSION = '0.1.0'
VERSION = '0.1.1'
end
end

0 comments on commit d361397

Please sign in to comment.