cdn_tags 0.3.2 → 0.4.0

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: b08d1bf4fdac615d3bf56d4d708f7e885451fcf1
4
- data.tar.gz: e074ba62a0343638ef4fea402c8aa62177333a53
3
+ metadata.gz: 67f7daf2bf064f0a887c3b481cc30a20d8dc7fa9
4
+ data.tar.gz: cffa665ffa5e7020168ca31b53435fec4a164559
5
5
  SHA512:
6
- metadata.gz: a981efba3956b43b400daddd93a7fe10e104ceea6e3eedbba61ae14e1b06efb6fc1307e7ebfd8b0b632a4bfab9db3ca31b56b77879b72d48b606ca78f77e96bb
7
- data.tar.gz: f652f86948afcad7c90e63f5cbeba33d19a0e63dc6a73a5f9071bac916e6ffc40d1f8f6228d7d9ec831b3243067a1e895d746967c2beb9927bdf93f7c429e717
6
+ metadata.gz: 7e56816a2739f7a11642400e432eea2bbf10925e877cecf0808e61edf60697c2249ddb106055fda3756056924b19139683be7c76aa689f8f534d8b95946651d0
7
+ data.tar.gz: 9a83451dda24f3ca1b72953f793ac3299378af29404b8a0ce99e09058da3f048b476e4e55907188dc01ee07e3de7da9daa2491020b61c8151d1256dbc859ae8c
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # CdnTags
1
+ # CdnTags [![Build Status][travis-img]][travis-link] [![Coverage Status][coveralls-img]][coveralls-link]
2
+
2
3
 
3
4
  Using a CDN in development is kind of painful when the
4
5
  network is unstable, however in production common libraries
@@ -13,7 +14,12 @@ Add
13
14
  gem 'cdn_tags'
14
15
  ```
15
16
 
16
- to your Gemfile.
17
+ to your Gemfile and run
18
+
19
+ ```
20
+ bundle install
21
+ ```
22
+
17
23
 
18
24
  ## Configuration
19
25
 
@@ -40,6 +46,14 @@ end
40
46
  This will automatically add the files to `Rails.application.config.assets.precompile`. If you want to disable this behavior, you can set
41
47
  `add_to_precompile` to `false` in the configuration.
42
48
 
49
+ ### Configuration items
50
+
51
+ * `scripts_urls` (`Hash`, default: `{}`): The scripts that should be served from a CDN.
52
+ * `stylesheets_urls` (`Hash`, default: `{}`): The stylesheets that should be served from a CDN.
53
+ * `add_to_precompile` (`true`|`false`, default: `true`): Automatically add scripts to `Rails.application.config.assets` or not.
54
+ * `raise_on_missing` (`true`|`false`, default: `false`): Raise an exception or not if the asset used with CDN helper is not defined in `scripts_urls` or `stylesheets_urls`.
55
+ * `cdn_environments` (`Array`, default: `[:production]`): The environments in which CDN should be used instead of normal asset.
56
+
43
57
  ## Usage
44
58
 
45
59
  Just replace `javascript_include_tag` and `stylesheet_link_tag`
@@ -72,3 +86,9 @@ This will result in the following HTML output.
72
86
  ```html
73
87
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
74
88
  ```
89
+
90
+
91
+ [travis-link]: https://travis-ci.org/claude-tech/cdn-tags-rails
92
+ [travis-img]: https://travis-ci.org/claude-tech/cdn-tags-rails.svg?branch=master
93
+ [coveralls-link]: https://coveralls.io/r/claude-tech/cdn-tags-rails?branch=master
94
+ [coveralls-img]: https://img.shields.io/coveralls/claude-tech/cdn-tags-rails.svg
@@ -9,7 +9,7 @@ module CdnTags
9
9
 
10
10
  def self.configure
11
11
  yield self.configuration
12
- self.configuration.update_rails_precompile!
12
+ self.configuration.post_configure_hooks
13
13
  end
14
14
 
15
15
  def self.included(base)
@@ -3,7 +3,7 @@ require 'rails'
3
3
  module CdnTags
4
4
  class Configuration
5
5
  attr_accessor :scripts_urls, :stylesheets_urls, :environment
6
- attr_accessor :raise_on_missing, :add_to_precompile
6
+ attr_accessor :raise_on_missing, :add_to_precompile, :cdn_environments
7
7
 
8
8
  def initialize
9
9
  self.scripts_urls = {}
@@ -11,6 +11,16 @@ module CdnTags
11
11
  self.environment = Rails.env
12
12
  self.raise_on_missing = false
13
13
  self.add_to_precompile = true
14
+ self.cdn_environments = [:production]
15
+ end
16
+
17
+ def post_configure_hooks
18
+ self.update_rails_precompile!
19
+ self.fix_cdn_environments_keys!
20
+ end
21
+
22
+ def fix_cdn_environments_keys!
23
+ self.cdn_environments.map! { |s| s.to_sym }
14
24
  end
15
25
 
16
26
  def update_rails_precompile!
@@ -17,7 +17,7 @@ module CdnTags
17
17
 
18
18
  def self.map_sources(sources, config_key)
19
19
  config = CdnTags.configuration
20
- return sources unless config.environment.to_sym == :production
20
+ return sources unless config.cdn_environments.include? config.environment.to_sym
21
21
  sources.map do |s|
22
22
  src = config.send(config_key)[s]
23
23
  if src.nil?
@@ -1,3 +1,3 @@
1
1
  module CdnTags
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -16,4 +16,9 @@ CdnTags.configure do |c|
16
16
  # Set to false to avoid adding the above assets
17
17
  # to Rails.config.assets.precompile automatically
18
18
  # c.add_to_precompile = true
19
+
20
+
21
+ # Modify this array to set in which environments
22
+ # should CDN be used
23
+ # c.cdn_environments = [:production]
19
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdn_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Perez