copy_tuner_client 0.4.0 → 0.4.1

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: 4361ccce3ca459c59cce845b2dcd51fb3fdb4a80
4
- data.tar.gz: cda2e1366b4a19985c97bff1e1d9cda1363e8074
3
+ metadata.gz: c098cb6d7890bf5a323384b2d54c93b003cd1970
4
+ data.tar.gz: 6173b84b9849c4287d60383c001c7d8bec529b6d
5
5
  SHA512:
6
- metadata.gz: 192a9c5167a77aed0aaf0967b4ea7b27644ffebce0c38baf3606d339e9858c148213fd16bbd898f0b30f1656e98b4f697b2ae68d55cc7c98a6e2f8d9cf3ff22d
7
- data.tar.gz: 28ecce1a14681689c2b2c9d19e3a66b67ac71ff41d2307b440774320636aea33e0c34f121bf3128db2b74a244f492cc7991bb5e0af4a36ac86b86ab4b54baee0
6
+ metadata.gz: e0fa49fa3e7d61bc70f9c0f850545152662ea373af0e4b01e25ab9831ca08e489a04c7812d0f7a3b70ba8529a0bf0668373405c54b5641cc3f9458f1bcee8834
7
+ data.tar.gz: ce85993d4cc05cd4cf46b186d1667d490e9679a9d6e0f5853ed5d3cd624a582ddc399266fc4170d97e4f8764f7b91e0830f2a4e03dd06ba7fca59f3d9bcf3a4a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.4.1
2
+ - bug fixes
3
+ - js injection failed if jquery is not used. #33
4
+ - Fix some js error. #34
5
+ - Wrong key is displayed if scoped option is used. #35
6
+
7
+ - deprecation
8
+ - config.copyray_js_injection_regexp_for_debug is no loger needed.
9
+ - config.copyray_js_injection_regexp_for_precompiled is no loger needed.
10
+
1
11
  ## 0.4.0
2
12
  - Remove jQuery dependency.
3
13
 
@@ -13,7 +23,7 @@
13
23
 
14
24
  ## 0.3.2
15
25
  - Support I18n.t :scope option.
16
- - Update copyray_js_injection_regexp_for_debug.
26
+ - Update copyray_js_injection_regexp_for_debug.
17
27
 
18
28
  ## 0.3.1
19
29
  - Add search box to copyray bar.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copy_tuner_client (0.4.0)
4
+ copy_tuner_client (0.4.1)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ Create config/initializers/copy_tuner.rb
17
17
  CopyTunerClient.configure do |config|
18
18
  config.api_key = 'YOUR-API-KEY'
19
19
  config.host = 'COPY-TUNER-HOST-NAME'
20
-
20
+
21
21
  # I18n keys and messages will be sent to server if the locale matches
22
22
  config.locales = [:ja, :en]
23
23
  end
@@ -33,6 +33,16 @@ bundle exec rake copy_tuner:export
33
33
 
34
34
  これで、`config/locales/copy_tuner.yml` に翻訳ファイルが作成されます。
35
35
 
36
+ ## IE等のレガシーブラウザ対応が必要な場合
37
+
38
+ 以下のスクリプトタグを追加する。(必要なpolyfillを個別に読み込んでも可)
39
+
40
+ ```
41
+ <script src="https://ft-polyfill-service.herokuapp.com/v2/polyfill.min.js"></script>
42
+ ```
43
+
44
+ [Polyfill service](https://cdn.polyfill.io/v2/docs/)
45
+
36
46
  Development
37
47
  =================
38
48
 
@@ -53,3 +63,9 @@ Development
53
63
  $ bundle exec rake install # install to local gem
54
64
  $ bundle exec rake release # release gem to rubygems.org
55
65
 
66
+ ## CoffeeScript
67
+
68
+ ```
69
+ $ npm run watch # Watch files for changes, rerunning the specified command when any file is updated.
70
+ $ npm run build # Compile a .coffee script into a .js JavaScript file of the same name.
71
+ ```
@@ -304,7 +304,7 @@
304
304
  right: Number.NEGATIVE_INFINITY,
305
305
  bottom: Number.NEGATIVE_INFINITY
306
306
  };
307
- elements.forEach(function(element) {
307
+ Array.from(elements).forEach(function(element) {
308
308
  var frame;
309
309
  if (!isVisible(element)) {
310
310
  return;
@@ -128,6 +128,14 @@ module CopyTunerClient
128
128
 
129
129
  alias_method :secure?, :secure
130
130
 
131
+ def copyray_js_injection_regexp_for_debug=(value)
132
+ logger.warn 'DEPRECATION WARNING: copyray_js_injection_regexp_for_debug is deprecated'
133
+ end
134
+
135
+ def copyray_js_injection_regexp_for_precompiled=(value)
136
+ logger.warn 'DEPRECATION WARNING: copyray_js_injection_regexp_for_precompiled is deprecated'
137
+ end
138
+
131
139
  # Instantiated from {CopyTunerClient.configure}. Sets defaults.
132
140
  def initialize
133
141
  self.client_name = 'CopyTuner Client'
@@ -146,20 +154,6 @@ module CopyTunerClient
146
154
  self.s3_host = 'copy-tuner-data-prod.s3.amazonaws.com'
147
155
  self.disable_copyray_comment_injection = false
148
156
 
149
- # Matches:
150
- # <script src="/assets/jquery.js"></script>
151
- # <script src="/assets/jquery-min.js"></script>
152
- # <script src="/assets/jquery.min.1.9.1.js"></script>
153
- # <script src="/assets/jquery.self-xxxxxx.js"></script>
154
- # <script src="/assets/jquery2.self-a4777c1acac0a74340755725342901a54ed000955bf6f5320491b8b2514c86ec.js?body=1" data-turbolinks-track="true"></script>
155
- # <script src="/assets/jquery-09abf132254111788afa8aca28fc7872.js?body=1"></script>
156
- self.copyray_js_injection_regexp_for_debug = /<script[^>]+\/jquery[23]?([-.]{1}[\d\.]+)?([-.]{1}min(\.[\d\.]+)?)?(\.self)?(\-[\da-f]+)?\.js[^>]+><\/script>/
157
-
158
- # Matches:
159
- # <script src="/application-xxxxxxx.js"></script>
160
- # <script src="/application.js"></script>
161
- self.copyray_js_injection_regexp_for_precompiled = /<script[^>]+\/application.*\.js[^>]+><\/script>/
162
-
163
157
  @applied = false
164
158
  end
165
159
 
@@ -45,7 +45,7 @@ module CopyTunerClient
45
45
  end
46
46
 
47
47
  def inject_copy_tuner_bar(html)
48
- html.sub(/<body[^>]*>/) { "#{$~}\n#{render_copy_tuner_bar}" }
48
+ html.sub(/<body[^>]*>/) { "#{Regexp.last_match}\n#{render_copy_tuner_bar}" }
49
49
  end
50
50
 
51
51
  def render_copy_tuner_bar
@@ -60,17 +60,12 @@ module CopyTunerClient
60
60
  end
61
61
 
62
62
  def append_css(html)
63
- html.sub(/<body[^>]*>/) { "#{$~}\n#{css_tag}" }
63
+ html.sub(/<body[^>]*>/) { "#{Regexp.last_match}\n#{css_tag}" }
64
64
  end
65
65
 
66
66
  def append_js(html)
67
- regexp = if ::Rails.application.config.assets.debug
68
- CopyTunerClient.configuration.copyray_js_injection_regexp_for_debug
69
- else
70
- CopyTunerClient.configuration.copyray_js_injection_regexp_for_precompiled
71
- end
72
- html.sub(regexp) do
73
- "#{$~}\n" + helpers.javascript_include_tag(:copyray)
67
+ html.sub(%r{</body>}) do
68
+ "#{helpers.javascript_include_tag(:copyray)}\n#{Regexp.last_match}"
74
69
  end
75
70
  end
76
71
 
@@ -14,7 +14,15 @@ module CopyTunerClient
14
14
  def translate_with_copyray_comment(key, options = {})
15
15
  source = translate_without_copyray_comment(key, options)
16
16
  if !CopyTunerClient.configuration.disable_copyray_comment_injection && (options[:rescue_format] == :html || options[:rescue_format].nil?)
17
- CopyTunerClient::Copyray.augment_template(source, scope_key_by_partial(key))
17
+ separator = options[:separator] || I18n.default_separator
18
+ scope = options[:scope]
19
+ normalized_key =
20
+ if key.to_s.first == '.'
21
+ scope_key_by_partial(key)
22
+ else
23
+ I18n.normalize_keys(nil, key, scope, separator).join(separator)
24
+ end
25
+ CopyTunerClient::Copyray.augment_template(source, normalized_key)
18
26
  else
19
27
  source
20
28
  end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.4.1'.freeze
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
@@ -190,18 +190,6 @@ describe CopyTunerClient::Configuration do
190
190
  expect(prefixed_logger).to be_a(CopyTunerClient::PrefixedLogger)
191
191
  expect(prefixed_logger.original_logger).to eq(logger)
192
192
  end
193
-
194
- describe 'copyray_js_injection_regexp_for_debug' do
195
- let(:config) { CopyTunerClient::Configuration.new }
196
- subject { config.copyray_js_injection_regexp_for_debug }
197
-
198
- it { is_expected.to match '<script src="/assets/jquery.js"></script>' }
199
- it { is_expected.to match '<script src="/assets/jquery-min.js"></script>' }
200
- it { is_expected.to match '<script src="/assets/jquery.min.1.9.1.js"></script>' }
201
- it { is_expected.to match '<script src="/assets/jquery/jquery.self-a4777c1acac0a74340755725342901a54ed000955bf6f5320491b8b2514c86ec.js?body=1" data-turbolinks-track="true"></script>' }
202
- it { is_expected.to match '<script src="/assets/jquery2.self-a4777c1acac0a74340755725342901a54ed000955bf6f5320491b8b2514c86ec.js?body=1" data-turbolinks-track="true"></script>' }
203
- it { is_expected.to match '<script src="/assets/jquery-09abf132254111788afa8aca28fc7872.js?body=1"></script>' }
204
- end
205
193
  end
206
194
 
207
195
  shared_context 'stubbed configuration' do
data/src/copyray.coffee CHANGED
@@ -211,7 +211,7 @@ util =
211
211
  right : Number.NEGATIVE_INFINITY
212
212
  bottom : Number.NEGATIVE_INFINITY
213
213
 
214
- elements.forEach((element) ->
214
+ Array.from(elements).forEach((element) ->
215
215
  return unless isVisible(element)
216
216
  frame = getOffset(element)
217
217
  frame.right = frame.left + element.offsetWidth
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SonicGarden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n