midge 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,23 @@ require 'sprockets/engines'
3
3
 
4
4
  module Midge
5
5
  class Config
6
- attr_reader :js_null_processor_enabled
6
+ attr_reader :js_null_processor
7
+
8
+ ## Private API ##
7
9
 
8
10
  def initialize
9
11
  @processors = []
10
- set_js_null_processor_enabled(true)
12
+ set :js_null_processor, true
13
+ end
14
+
15
+ def configure!(sprockets=Sprockets)
16
+ @processors.each do |base_klass, extension, namespace|
17
+ sprockets.register_engine extension, create_processer(base_klass, namespace)
18
+ end
11
19
  end
12
20
 
21
+ ## Public API ##
22
+
13
23
  def jst_processor(extension, namespace=Rails.application.class.parent_name)
14
24
  @processors << [::Midge::JstProcessor, extension, namespace]
15
25
  end
@@ -18,14 +28,8 @@ module Midge
18
28
  @processors << [::Midge::JavascriptProcessor, extension, namespace]
19
29
  end
20
30
 
21
- def set_js_null_processor_enabled(value)
22
- @js_null_processor = value
23
- end
24
-
25
- def configure!(sprockets=Sprockets)
26
- @processors.each do |base_klass, extension, namespace|
27
- sprockets.register_engine extension, create_processer(base_klass, namespace)
28
- end
31
+ def set(property, value)
32
+ instance_variable_set("@#{property}", value)
29
33
  end
30
34
 
31
35
  private
@@ -6,7 +6,10 @@ module Midge
6
6
  require 'sprockets'
7
7
  require 'sprockets/engines'
8
8
 
9
- app.assets.register_engine '.js', ::Midge::JavascriptNullProcessor
9
+ if ::Midge.application_config.js_null_processor
10
+ app.assets.register_engine '.js', ::Midge::JavascriptNullProcessor
11
+ end
12
+
10
13
  ::Midge.application_config.configure!(app.assets)
11
14
  end
12
15
  end
@@ -1,3 +1,3 @@
1
1
  module Midge
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require "test_helper"
2
+
3
+ class ConfigTest < ActiveSupport::TestCase
4
+ attr_reader :config
5
+
6
+ def setup
7
+ @config = Midge::Config.new
8
+ end
9
+
10
+ test "js_null_processor is false by default" do
11
+ assert_equal config.js_null_processor, true
12
+ end
13
+
14
+ test "set js_null_processor to false" do
15
+ config.set :js_null_processor, false
16
+ assert_equal config.js_null_processor, false
17
+ end
18
+ end
@@ -83,3 +83,26 @@ Connecting to database specified by database.yml
83
83
   (0.2ms) rollback transaction
84
84
   (0.1ms) begin transaction
85
85
   (0.1ms) rollback transaction
86
+ Connecting to database specified by database.yml
87
+ Connecting to database specified by database.yml
88
+ Connecting to database specified by database.yml
89
+  (6.9ms) begin transaction
90
+  (0.2ms) rollback transaction
91
+  (0.1ms) begin transaction
92
+  (0.1ms) rollback transaction
93
+ Connecting to database specified by database.yml
94
+  (0.3ms) begin transaction
95
+  (0.0ms) rollback transaction
96
+  (0.1ms) begin transaction
97
+  (0.2ms) rollback transaction
98
+  (0.1ms) begin transaction
99
+  (0.1ms) rollback transaction
100
+ Connecting to database specified by database.yml
101
+  (0.4ms) begin transaction
102
+  (0.1ms) rollback transaction
103
+  (0.1ms) begin transaction
104
+  (0.0ms) rollback transaction
105
+  (0.0ms) begin transaction
106
+  (0.2ms) rollback transaction
107
+  (0.1ms) begin transaction
108
+  (0.2ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -96,6 +96,7 @@ files:
96
96
  - MIT-LICENSE
97
97
  - Rakefile
98
98
  - README.md
99
+ - test/config_test.rb
99
100
  - test/dummy/app/assets/javascripts/application.js
100
101
  - test/dummy/app/assets/javascripts/test1.midge.js
101
102
  - test/dummy/app/assets/javascripts/test2.midge_template.js
@@ -159,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
160
  version: '0'
160
161
  segments:
161
162
  - 0
162
- hash: 3582730657541668864
163
+ hash: 2223616656116482494
163
164
  required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  none: false
165
166
  requirements:
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  segments:
170
171
  - 0
171
- hash: 3582730657541668864
172
+ hash: 2223616656116482494
172
173
  requirements: []
173
174
  rubyforge_project:
174
175
  rubygems_version: 1.8.24
@@ -176,6 +177,7 @@ signing_key:
176
177
  specification_version: 3
177
178
  summary: Quick and cheap javascript modules for the rails asset pipeline.
178
179
  test_files:
180
+ - test/config_test.rb
179
181
  - test/dummy/app/assets/javascripts/application.js
180
182
  - test/dummy/app/assets/javascripts/test1.midge.js
181
183
  - test/dummy/app/assets/javascripts/test2.midge_template.js