roda-opal_assets 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58c27c816f1eaea22d1c02658d2b463e4bb4bfd9
4
- data.tar.gz: f22fe5cc8ac5c4b3b2096880ea333dbf3f78c224
3
+ metadata.gz: cccf69690efc631f7a20ab500ad87d494cb871d5
4
+ data.tar.gz: 63bef0edc65e54e1c488b07d26dbf8c2aff73975
5
5
  SHA512:
6
- metadata.gz: ff3befbe676c913096bdfd22149924641757bf3e10debd56d9524a8dd0692f47ca914e4e759b38bb60d313b148be06b6991b4860ef96d943993154395a9b125d
7
- data.tar.gz: aa0b245de715c74453826b3a2caed82086a2a640027e283972d01a3a40bf62e5d24764c004fa90f222a2170f8c070d44d77fa73c1509ba3e72f28b51384cc8db
6
+ metadata.gz: dac68610e9b37726f83de1502a6bfd2c28be571efe837a24686444abe2e600e07cb63444a717e3ee9a4e11f793709ff69b619633c521c9d20e6b13c96e4e2f76
7
+ data.tar.gz: 38620aae23d1a814effcb79c12bf2cc487f0822f80f0e84ab7c9622b76f65334aefab64af872765aa9600b1a73a862ca56b6c63824799538bf2d44e745704805
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class OpalAssets
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -1,8 +1,17 @@
1
1
  require "roda/opal_assets/version"
2
2
  require "roda"
3
+ require "opal"
3
4
 
4
5
  class Roda
5
6
  class OpalAssets
7
+ def initialize env: ENV['RACK_ENV']
8
+ @env = env
9
+
10
+ Opal::Config.source_map_enabled = !production?
11
+ sprockets
12
+ source_maps
13
+ end
14
+
6
15
  def route r
7
16
  r.on source_map_prefix[1..-1] do
8
17
  r.run source_maps
@@ -20,7 +29,7 @@ class Roda
20
29
  file,
21
30
  sprockets: sprockets,
22
31
  prefix: '/assets/js',
23
- debug: ENV['RACK_ENV'] != 'production',
32
+ debug: !production?,
24
33
  )
25
34
  end
26
35
 
@@ -55,7 +64,9 @@ class Roda
55
64
  return @source_maps if defined? @source_maps
56
65
 
57
66
  source_maps = Opal::SourceMapServer.new(sprockets, source_map_prefix)
58
- ::Opal::Sprockets::SourceMapHeaderPatch.inject!(source_map_prefix)
67
+ unless production?
68
+ ::Opal::Sprockets::SourceMapHeaderPatch.inject!(p source_map_prefix)
69
+ end
59
70
 
60
71
  @source_maps = Rack::Builder.new do
61
72
  use Rack::ConditionalGet
@@ -64,5 +75,9 @@ class Roda
64
75
  run source_maps
65
76
  end
66
77
  end
78
+
79
+ def production?
80
+ @env == 'production'
81
+ end
67
82
  end
68
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-opal_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-03 00:00:00.000000000 Z
11
+ date: 2016-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal