gon 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gon might be problematic. Click here for more details.

data/README.md CHANGED
@@ -9,9 +9,8 @@ If you need to send some data to your js files and you don't want to do this wit
9
9
  ``` erb
10
10
  <head>
11
11
  <title>some title</title>
12
- <%= gon_variables %>
13
- <%= javascript_include_tag 'http://code.jquery.com/jquery-1.6.min.js' %> <!-- include jquery -->
14
- <%= include_gon_js %> <!-- http://gaziev.com/files/gon.js -->
12
+ <%= include_gon %>
13
+ <!-- include your action js code -->
15
14
  ...
16
15
  ```
17
16
 
@@ -35,13 +34,13 @@ alert(Gon.your_other_variable)
35
34
  Puts this line into `Gemfile` then run `$ bundle`:
36
35
 
37
36
  ``` ruby
38
- gem 'gon', '0.1.0'
37
+ gem 'gon', '0.2.0'
39
38
  ```
40
39
 
41
40
  Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
42
41
 
43
42
  ``` ruby
44
- config.gem 'gon', :version => '0.1.0'
43
+ config.gem 'gon', :version => '0.2.0'
45
44
  ```
46
45
 
47
46
  Or manually install gon gem: `$ gem install gon`
@@ -5,15 +5,15 @@ module Gon
5
5
  end
6
6
 
7
7
  module InstanceMethods
8
- def include_gon_js
9
- javascript_include_tag 'http://gaziev.com/files/gon.js'
10
- end
11
-
12
- def gon_variables
8
+ def include_gon
13
9
  data = Rails.cache.read('gon_variables') || {}
14
10
 
15
- '<gon style="display:none">' + data.to_s.gsub('=>', ' : ') +
16
- '</gon>'
11
+ script = "<script>function Gon(){"
12
+ data.each do |key, val|
13
+ script += "this." + key.to_s + "'" + val.to_s + "';"
14
+ end
15
+ script += "}; var Gon = new Gon()</script>"
16
+ script.html_safe
17
17
  end
18
18
  end
19
19
 
@@ -1,3 +1,3 @@
1
1
  module Gon
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: