client_variable 0.0.2 → 0.0.3

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: 1b85d71ba87d5046e5f0417785e4f07a999ce8e9
4
- data.tar.gz: 6702fc165ac316407db2c1eb0e1a2424c76fcd6a
3
+ metadata.gz: 94d0c9ee41377b46876a345e273f048bde3be5b1
4
+ data.tar.gz: d49028dba0fdc43f0e29571f0a9d10b2b609189d
5
5
  SHA512:
6
- metadata.gz: 6e075763da4abeb67738a3f7813e3bc7f3aab6f528290db65eccb983ab9f9508ee1eab2fd13c098fe02bb867d4f6dd3a30bde5938d5ffafb238a5168a0bf3752
7
- data.tar.gz: 34552e0195ef3d3bbbcadc5fdd78b495e0a9b1f5c5c1a3c57d9db91987bee1b2782a0b81278a7b4fe157c2cdfdd60f021a914343e32d3e3dec1fedf81ddcff22
6
+ metadata.gz: 5643aaa782229097bfbc9179b6089c9b460414f5b8c2c6ae2b2d8da967b427d8e09cb39d12094f72f371fe8b8d4c22257ba9374ee7066c24e348b5d8cf30df7d
7
+ data.tar.gz: ad95e6cd2a9a338c4614c2c9de466d67c23d5ae2a9b6782cc50d6033b5fff836892c5bbc26265a947a5a862c997eb349496596fbad01e49eefed7ac1783a0f6d
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_dependency "rails"
24
25
  end
@@ -43,7 +43,7 @@ module Client
43
43
  end
44
44
 
45
45
  def values
46
- [Global.values, Request.values].inject(:merge)
46
+ Client.generate.merge([Global.values, Request.values].inject(:merge))
47
47
  end
48
48
  end
49
49
  end
@@ -0,0 +1,35 @@
1
+ require 'sprockets/engines'
2
+ require 'tilt/template'
3
+
4
+ module Client
5
+ class Engine < Rails::Engine
6
+ initializer "sprockets.mquy", :after => "sprockets.environment", :group => :all do |app|
7
+ app.assets.register_engine('.mquy', TiltHandlebars)
8
+ end
9
+ end
10
+
11
+ class TiltHandlebars < Tilt::Template
12
+ def self.default_mime_type
13
+ 'application/javascript'
14
+ end
15
+
16
+ def initialize_engine; end
17
+
18
+ def prepare; end
19
+
20
+ # Generates Javascript code from a HandlebarsJS template.
21
+ # The SC template name is derived from the lowercase logical asset path
22
+ # by replacing non-alphanum characheters by underscores.
23
+ def evaluate(scope, locals, &block)
24
+ binding.pry
25
+ template = data.dup
26
+ template.gsub!(/"/, '\\"')
27
+ template.gsub!(/\r?\n/, '\\n')
28
+ template.gsub!(/\t/, '\\t')
29
+ return 'console.log(1223);'
30
+ end
31
+ end
32
+ end
33
+
34
+ Tilt.register 'mquy', Client::TiltHandlebars
35
+ Sprockets.register_engine '.mquy', Client::TiltHandlebars
@@ -0,0 +1,9 @@
1
+ require "action_controller/railtie"
2
+
3
+ module Client
4
+ class Railtie < ::Rails::Railtie
5
+ rake_tasks do
6
+ load "client_variable/rails/task.rake"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require "fileutils"
2
+
3
+ namespace :assets do
4
+ desc "Compile all the assets named in config.assets.precompile"
5
+ task :precompile do
6
+ Rake::Task["assets:clobber"].invoke
7
+ Rake::Task["assets:precompile"].invoke
8
+ end
9
+ end
@@ -19,7 +19,7 @@ module Client
19
19
  end
20
20
 
21
21
  def values
22
- env['client'] if env
22
+ env.blank? ? {} : env['client']
23
23
  end
24
24
 
25
25
  def clear
@@ -1,3 +1,3 @@
1
1
  module ClientVariable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -47,10 +47,10 @@ module Client
47
47
 
48
48
  def self.generate
49
49
  data = YAML.load(ERB.new(File.new("#{Rails.root}/config/client_variable.yml").read).result)
50
- data[Rails.env].to_json
50
+ data[Rails.env]
51
51
  end
52
52
 
53
- class Engine < ::Rails::Engine; end
53
+ class Engine < Rails::Engine; end
54
54
 
55
55
  require 'client_variable/request'
56
56
  require 'client_variable/global'
@@ -1,5 +1,5 @@
1
1
  development:
2
- x: 1
2
+ app_name: <%= Rails.application.class.parent_name%>
3
3
 
4
4
  production:
5
- x:1
5
+ app_name: <%= Rails.application.class.parent_name%>
@@ -1,5 +1,5 @@
1
1
  rails = (function(exports, global) {
2
- var datum = deepMerge(exports, <%= Client.generate%>);
2
+ var datum = exports;
3
3
  var defaultSeparator = '.';
4
4
 
5
5
  function lookup(query, track) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_variable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MQuy
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: export variable in rails to client-side
42
56
  email:
43
57
  - sugiacupit@gmail.com
@@ -56,13 +70,16 @@ files:
56
70
  - lib/client_variable/global.rb
57
71
  - lib/client_variable/helper/controller.rb
58
72
  - lib/client_variable/helper/view.rb
73
+ - lib/client_variable/rails/engine.rb
74
+ - lib/client_variable/rails/railtie.rb
75
+ - lib/client_variable/rails/task.rake
59
76
  - lib/client_variable/request.rb
60
77
  - lib/client_variable/version.rb
61
78
  - lib/generators/client_variable/install/install_generator.rb
62
79
  - lib/generators/client_variable/install/templates/config.yml
63
80
  - spec/client_variable_spec.rb
64
81
  - spec/spec_helper.rb
65
- - vendor/assets/javascripts/variable.js.erb
82
+ - vendor/assets/javascripts/variable.js
66
83
  homepage: https://github.com/MQuy
67
84
  licenses:
68
85
  - MIT