i18n-assets 0.0.5 → 0.0.6

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NmViNjBlODE1MzZiNjZlYzllN2ViYTZlMTJlYzdhNGVjMWI0OTk5OQ==
5
- data.tar.gz: !binary |-
6
- ZWIwODk5ZjU1M2RkMmIxNjNmZWEzNzk5Y2ViMmVlODcyMmE2MDdlOA==
2
+ SHA1:
3
+ metadata.gz: 00157c3e777370b46da22829e00102ae84f7ae0f
4
+ data.tar.gz: efcc67fba24d6533ebed8fbee1ac48c9ac6bd9a3
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NTEyNDdhMWVmOTQ3ZWRmMTEwZjgyMGViMTJhZTFjZWEyN2NjNjE2ZmZhZDUx
10
- MzE5Y2ZlOGViZWZkMzFkOTNhNDRjZjY2YjU3ODQwOThjYmFmMjRjNTVkNTBl
11
- ZThkOTNlYzE0YTYzMzdkN2Y1NjEzMDI2OGY1MjRmNmQzYTc0ZmM=
12
- data.tar.gz: !binary |-
13
- ODlkM2ZlZDEwMzA0YzAyNjBkNTZiOTI2YWFlZTU4MDdjNGEyODM5ZmJiZDNj
14
- MjMwOWE5YTJiNWM5N2U3ZWQ4ZWM3NGU1N2ZiODgxMzcyYTA3M2U0ZTRkMzQ0
15
- ZDUyYmUxYjgyYmU2ZWFmOTg5NmMyZTRkZjUxMTRkN2NiZjlhMDg=
6
+ metadata.gz: dc76ba76f244f06eecb838705091774cb318625265c274954d181e06a79f37a33d5a2534c7581b9d5ed53e32d9769f90f3fb47fc9ebcfcccb6c1834fea4c313a
7
+ data.tar.gz: 8280626f61eebb626e3cd68baf2c2e3cd57154ae6d0eaa3a98897a5ae9148232aa055f2d5b44821abd469f6a35fbf0d94b17ab8a41d03b390f613643c03183a4
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n-assets (0.0.5)
4
+ i18n-assets (0.0.6)
5
5
  actionpack (~> 3.2.18)
6
6
  sprockets (~> 2.2.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (3.2.18)
12
- activemodel (= 3.2.18)
13
- activesupport (= 3.2.18)
11
+ actionpack (3.2.21)
12
+ activemodel (= 3.2.21)
13
+ activesupport (= 3.2.21)
14
14
  builder (~> 3.0.0)
15
15
  erubis (~> 2.7.0)
16
16
  journey (~> 1.0.4)
@@ -18,25 +18,25 @@ GEM
18
18
  rack-cache (~> 1.2)
19
19
  rack-test (~> 0.6.1)
20
20
  sprockets (~> 2.2.1)
21
- activemodel (3.2.18)
22
- activesupport (= 3.2.18)
21
+ activemodel (3.2.21)
22
+ activesupport (= 3.2.21)
23
23
  builder (~> 3.0.0)
24
- activesupport (3.2.18)
24
+ activesupport (3.2.21)
25
25
  i18n (~> 0.6, >= 0.6.4)
26
26
  multi_json (~> 1.0)
27
27
  builder (3.0.4)
28
28
  erubis (2.7.0)
29
29
  hike (1.2.3)
30
- i18n (0.6.9)
30
+ i18n (0.7.0)
31
31
  journey (1.0.4)
32
- multi_json (1.10.1)
32
+ multi_json (1.11.0)
33
33
  rack (1.4.5)
34
34
  rack-cache (1.2)
35
35
  rack (>= 0.4)
36
- rack-test (0.6.2)
36
+ rack-test (0.6.3)
37
37
  rack (>= 1.0)
38
38
  rake (10.3.2)
39
- sprockets (2.2.2)
39
+ sprockets (2.2.3)
40
40
  hike (~> 1.2)
41
41
  multi_json (~> 1.0)
42
42
  rack (~> 1.0)
@@ -50,3 +50,6 @@ DEPENDENCIES
50
50
  bundler (~> 1.5)
51
51
  i18n-assets!
52
52
  rake
53
+
54
+ BUNDLED WITH
55
+ 1.10.5
data/README.md CHANGED
@@ -24,6 +24,10 @@ On assets precompilation localized versions of your files will be generated.
24
24
 
25
25
  If you need to prevent `.js.erb` or `.css.erb` files from caching, you can add `config.assets.prevent_caching = true` to the `environments/development.rb` file.
26
26
 
27
+ ## Configuration
28
+
29
+ By default, `i18n-assets` localizes all js and css files. That might make your deploys turtle slow. In order to explicitly configure the files you want to localize, simply add `config.assets.localize = %w( *.js application.css )` to your environment configuration file.
30
+
27
31
  ## Example
28
32
 
29
33
  You can check an example usage here: https://github.com/maximgladkov/localized_assets_precompilation_example_app
@@ -2,11 +2,18 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
2
2
  require 'sprockets'
3
3
 
4
4
  module Sprockets
5
- LOCALIZABLE_ASSETS_EXT = %w( js css )
6
- LOCALIZABLE_ASSETS_REGEX = Regexp.new("\\.(?:#{ LOCALIZABLE_ASSETS_EXT * '|' })")
7
- LOCALIZABLE_COMPILABLE_ASSETS_REGEX = Regexp.new("\\.(?:#{ LOCALIZABLE_ASSETS_EXT * '|' })\\..+$")
5
+ DEFAULT_LOCALIZABLE_ASSETS_PATTERN = %w( *.js *.css )
8
6
  GLOBAL_ASSET_REGEX = /^(https?)?:\/\//
9
7
 
8
+ def self.localizable?(path)
9
+ path = path.gsub(Rails.root.to_s, '')
10
+
11
+ patterns = Rails.configuration.assets.localize || DEFAULT_LOCALIZABLE_ASSETS_PATTERN
12
+ patterns.any? do |pattern|
13
+ File.fnmatch?(pattern, path)
14
+ end
15
+ end
16
+
10
17
  module Helpers
11
18
  module RailsHelper
12
19
 
@@ -16,7 +23,7 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
16
23
  def asset_path(source, options = {})
17
24
  path = asset_path_without_locale(source, options)
18
25
 
19
- if !digest_assets? && path =~ LOCALIZABLE_ASSETS_REGEX
26
+ if !digest_assets? && Sprockets.localizable?(path)
20
27
  separator = path =~ /\?/ ? '&' : '?'
21
28
  "#{ path }#{ separator }t=#{ Time.now.to_i }"
22
29
  else
@@ -42,7 +49,7 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
42
49
  end
43
50
  end
44
51
 
45
- if logical_path =~ LOCALIZABLE_ASSETS_REGEX
52
+ if Sprockets.localizable?(logical_path)
46
53
  I18n.available_locales.each do |locale|
47
54
  I18n.locale = locale
48
55
  process.call
@@ -66,7 +73,7 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
66
73
  # add locale for css and js files
67
74
  def logical_path
68
75
  path = logical_path_without_locale
69
- if !Rails.env.development? && path =~ LOCALIZABLE_ASSETS_REGEX
76
+ if !Rails.env.development? && Sprockets.localizable?(path)
70
77
  "#{ I18n.locale }/#{ path }"
71
78
  else
72
79
  path
@@ -77,7 +84,7 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
77
84
 
78
85
  alias_method :dependency_fresh_without_check?, :dependency_fresh?
79
86
  def dependency_fresh?(environment, dep)
80
- return false if Rails.configuration.assets.prevent_caching && dep.pathname.to_s =~ LOCALIZABLE_COMPILABLE_ASSETS_REGEX
87
+ return false if Rails.configuration.assets.prevent_caching && Sprockets.localizable?(dep.pathname.to_s)
81
88
  dependency_fresh_without_check?(environment, dep)
82
89
  end
83
90
 
@@ -133,7 +140,9 @@ unless defined?(Sprockets::LOCALIZABLE_ASSETS_REGEX)
133
140
  end
134
141
 
135
142
  def file_localizable?(source, options)
136
- source =~ Sprockets::LOCALIZABLE_ASSETS_REGEX || Sprockets::LOCALIZABLE_ASSETS_EXT.include?(options.try(:[], :ext))
143
+ ext = options.try(:[], :ext)
144
+ source = "#{ source }.#{ ext }" if ext && !source.ends_with?(".#{ ext }")
145
+ Sprockets.localizable?(source)
137
146
  end
138
147
 
139
148
  def file_already_localized?(source)
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Assets
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Gladkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sprockets
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.2.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.2.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: actionpack
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.2.18
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.2.18
69
69
  description: Ever wanted to use rails localization helpers inside your assets? Your
@@ -74,7 +74,7 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - Gemfile
79
79
  - Gemfile.lock
80
80
  - LICENSE.txt
@@ -94,12 +94,12 @@ require_paths:
94
94
  - lib
95
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ! '>='
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ! '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []