optipipe 0.4.3 → 0.4.4

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: 85492f3aeccad8a655259c18a3dacfea5b68944b
4
- data.tar.gz: 525e89e4da9b61eca8c8e179664f208624f17449
3
+ metadata.gz: e934634eec7b8b742655a7d7a7fdc6bab110e324
4
+ data.tar.gz: af7f6028b8c35d384a70554d26b35ec80ae60a25
5
5
  SHA512:
6
- metadata.gz: 4001b43c9690715a1539e60b2c231607fba61cff2816c88c87791b456b03b8a61a2f67888aec8ca04ed23ad07ba6c02d212fd28acf09c62ff66c73681679bdc7
7
- data.tar.gz: 7767ae51b75fb9a4eb00fdc67bb4b0c13df9e4be4a8ddf0fc1a41a6201523c70153ed8eb84322a980fde8bf8c7bfbaa4f8d231595c6ef165c6f057045e7ba571
6
+ metadata.gz: 2cc1285a4696f09eba8ae8f3a940197e17aafdca339fa8e21107f27de6219394f052f2580f5ca9208018bd5b0640452e1cc4bca6a6f3d6717fe9beb4fa07ffe2
7
+ data.tar.gz: ff1b610312dfda6631d10f578ae215336b41a4069bcefab785c5d5b19a9bb5e114223d73dc1124887be6a045618af010e0334498fb7d5a79e8b67755871dd89d
@@ -29,7 +29,7 @@ module Optipipe
29
29
  end
30
30
 
31
31
  # Add helpers
32
- initializer 'gtm_on_rails.action_view_helpers' do
32
+ initializer 'optipipe.action_view_helpers' do
33
33
  ActiveSupport.on_load :action_view do
34
34
  include Optipipe::TagHelper
35
35
  end
@@ -58,7 +58,7 @@ module Optipipe
58
58
  return if mappers.blank?
59
59
 
60
60
  conditions.each do |key, value|
61
- mappers.select! do |mapper|
61
+ mappers = mappers.select do |mapper|
62
62
  mapper[key.to_s] == value
63
63
  end
64
64
  end
@@ -1,9 +1,4 @@
1
1
  module Optipipe
2
- def self.initial_load!
3
- Mapper.load_yaml_data('javascripts')
4
- Mapper.load_yaml_data('stylesheets')
5
- end
6
-
7
2
  class Mapper
8
3
  class << self
9
4
  def get_javascript_mappers(controller_path)
@@ -14,21 +9,34 @@ module Optipipe
14
9
  get_yaml_data('stylesheets')[controller_path]
15
10
  end
16
11
 
17
- def load_yaml_data(type)
18
- const_name = :"#{type.upcase}_YAML_DATA"
19
- yaml_data = {}
20
- Dir.glob(Rails.root.join('app', 'assets', type, 'optipipe', 'mappers', '*')).each do |mapper_yaml|
21
- data = YAML.load(File.open(mapper_yaml))
22
- yaml_data[data['controller_path']] ||= []
23
- yaml_data[data['controller_path']] << data
12
+ def load_yamls!
13
+ javascript_files = Dir.glob(Rails.root.join('app', 'assets', 'javascripts', 'optipipe', 'mappers', '*'))
14
+ stylesheet_files = Dir.glob(Rails.root.join('app', 'assets', 'stylesheets', 'optipipe', 'mappers', '*'))
15
+
16
+ mapper_data = {
17
+ javascripts: {},
18
+ stylesheets: {}
19
+ }
20
+ javascript_files.sort.each do |yaml_path|
21
+ data = YAML.load(File.open(yaml_path))
22
+ mapper_data[:javascripts][data['controller_path']] ||= []
23
+ mapper_data[:javascripts][data['controller_path']] << data
24
+ end
25
+ stylesheet_files.sort.each do |yaml_path|
26
+ data = YAML.load(File.open(yaml_path))
27
+ mapper_data[:stylesheets][data['controller_path']] ||= []
28
+ mapper_data[:stylesheets][data['controller_path']] << data
24
29
  end
25
- self.const_set(const_name, yaml_data)
30
+
31
+ Kernel.send(:remove_const, :OPTIPIPE_MAPPER_DATA) if Kernel.const_defined?(:OPTIPIPE_MAPPER_DATA)
32
+ Kernel.const_set(:OPTIPIPE_MAPPER_DATA, Marshal.load(Marshal.dump(mapper_data)))
26
33
  end
27
34
 
28
35
  private
29
36
 
30
37
  def get_yaml_data(type)
31
- self.const_get(:"#{type.upcase}_YAML_DATA")
38
+ data = Kernel.const_get(:OPTIPIPE_MAPPER_DATA)
39
+ Marshal.load(Marshal.dump(data))[type.to_sym]
32
40
  end
33
41
  end
34
42
  end
@@ -0,0 +1,10 @@
1
+ module Optipipe
2
+ if defined?(Rails::Railtie)
3
+ class Railtie < Rails::Railtie
4
+ # Parse the mappers before any of the initializers
5
+ initializer :load_optipipe_mappers, :before => :load_environment_config do
6
+ Optipipe::Mapper.load_yamls!
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Optipipe
2
- VERSION = '0.4.3'
2
+ VERSION = '0.4.4'
3
3
  end
data/lib/optipipe.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "optipipe/engine"
2
+ require "optipipe/railtie"
2
3
 
3
4
  module Optipipe
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optipipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ykogure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/optipipe/engine.rb
67
67
  - lib/optipipe/helpers/tag_helper.rb
68
68
  - lib/optipipe/models/mapper.rb
69
+ - lib/optipipe/railtie.rb
69
70
  - lib/optipipe/version.rb
70
71
  - lib/tasks/optipipe_tasks.rake
71
72
  homepage: https://github.com/ZIGExN/optipipe