js_vars 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f71b2c15cc0201d4ffcbdc17171abc365ee5c6d
4
- data.tar.gz: 5aff28da3fa50d61a2fae6b3ea44861af14039cc
3
+ metadata.gz: fbc7a3fec4d8399108ab2117b954f1fc6dbf960b
4
+ data.tar.gz: d3d254c47d654105fbf8b96d509727aaba520a11
5
5
  SHA512:
6
- metadata.gz: 0f3868ce7bbb482d4a5cd18c07230b6051953cb7e5f941c448cecc09adad450adf87b94f58ac4fd3356ca724f298666f076348b8ed7af872e26c04a853559341
7
- data.tar.gz: 133c2d5be7efa9cfbf4c6f09fb6202d580f82cd99364c305350cddb17801ca69e3643dcc18dd7e2b0aaffbdf22e265814e29ed8dad71e0d8377e9dadbefbec68
6
+ metadata.gz: 1335fa0fb2065f71f6cf208c24509a8353e60c7eb45f3c3c270a033cfe6e84b124ca7eab5c5b95aa613e4e2b40e5af323d0bb75b99a0860c0cd199d622235469
7
+ data.tar.gz: 0178c59e92e71bc7bfaae2761700206a57f6b52a54167ecb076a618326a4ec9d6ea07b96fef7e645f8af136c69428a3416fb7d0fb936224f833707ecdb03c5d5
data/README.md CHANGED
@@ -55,6 +55,19 @@ To solve this problems I have written gem `jsvars`.
55
55
  namespace: To change particular variable namespace
56
56
  json: To change rendering object fields.
57
57
 
58
+ ### Configuration - It is optional
59
+
60
+ To change default namespace add following code to your config initializers
61
+
62
+ i.e in `config/initializers/js_vars.rb`
63
+
64
+ JsVars.configure do |c|
65
+ c.namespace = 'MyNamespace'
66
+ end
67
+
68
+ So now by default all variables renders in `MyNamespace` namespace
69
+
70
+
58
71
  ## Installation
59
72
 
60
73
  Add this line to your application's Gemfile:
data/js_vars.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["jirenpatel@gmail.com"]
11
11
  spec.description = %q{Manage javascript variables in html templates}
12
12
  spec.summary = %q{Manage javascript variables in html templates}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/jiren/js_vars"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
data/lib/js_vars.rb CHANGED
@@ -9,8 +9,15 @@ module JsVars
9
9
 
10
10
  class << self
11
11
 
12
- def add(vars, namepsace = 'APP')
13
- VarMap.add(vars, namepsace) if vars.is_a?(Hash)
12
+ attr_accessor :namespace
13
+
14
+ def configure(&block)
15
+ self.namespace = 'APP'
16
+ yield(self) if block_given?
17
+ end
18
+
19
+ def add(vars, namespace = nil)
20
+ VarMap.add(vars, namespace || self.namespace) if vars.is_a?(Hash)
14
21
  end
15
22
 
16
23
  def clear
@@ -2,6 +2,7 @@ module JsVars
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
4
  initializer 'js_vars.view_helpers' do
5
+ JsVars.configure
5
6
  ActionView::Base.send(:include, JsVars::TagHelper)
6
7
  end
7
8
 
@@ -1,3 +1,3 @@
1
1
  module JsVars
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_vars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiren Patel
@@ -60,7 +60,7 @@ files:
60
60
  - lib/js_vars/var_map.rb
61
61
  - lib/js_vars/version.rb
62
62
  - vendor/assets/javascripts/js_vars.js
63
- homepage: ''
63
+ homepage: https://github.com/jiren/js_vars
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}