copy_tuner_client 0.0.15 → 0.1.0.beta

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.
Files changed (37) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +0 -1
  3. data/.travis.yml +5 -5
  4. data/Appraisals +10 -7
  5. data/Gemfile.lock +33 -34
  6. data/README.md +2 -16
  7. data/Rakefile +3 -1
  8. data/app/assets/javascripts/copyray.js.coffee +285 -0
  9. data/app/assets/stylesheets/copyray.css +349 -0
  10. data/copy_tuner_client.gemspec +3 -3
  11. data/features/rails.feature +2 -16
  12. data/features/step_definitions/copycopter_server_steps.rb +1 -1
  13. data/features/step_definitions/rails_steps.rb +11 -20
  14. data/features/support/rails_server.rb +4 -30
  15. data/gemfiles/{4.0.gemfile → 2.3.gemfile} +2 -2
  16. data/gemfiles/2.3.gemfile.lock +108 -0
  17. data/gemfiles/{4.1.gemfile → 3.0.gemfile} +2 -2
  18. data/gemfiles/3.0.gemfile.lock +153 -0
  19. data/gemfiles/3.1.gemfile +11 -0
  20. data/gemfiles/3.1.gemfile.lock +191 -0
  21. data/lib/copy_tuner_client/cache.rb +0 -2
  22. data/lib/copy_tuner_client/configuration.rb +4 -4
  23. data/lib/copy_tuner_client/copyray.rb +29 -0
  24. data/lib/copy_tuner_client/copyray_middleware.rb +65 -0
  25. data/lib/copy_tuner_client/engine.rb +29 -0
  26. data/lib/copy_tuner_client/i18n_backend.rb +1 -2
  27. data/lib/copy_tuner_client/rails.rb +1 -1
  28. data/lib/copy_tuner_client/simple_form_extention.rb +19 -0
  29. data/lib/copy_tuner_client/version.rb +1 -1
  30. data/spec/copy_tuner_client/cache_spec.rb +3 -15
  31. data/spec/copy_tuner_client/configuration_spec.rb +1 -1
  32. data/spec/copy_tuner_client/request_sync_spec.rb +4 -4
  33. data/spec/support/fake_copy_tuner_app.rb +11 -14
  34. metadata +25 -60
  35. data/.ruby-version +0 -1
  36. data/gemfiles/3.2.gemfile +0 -7
  37. data/lib/copy_tuner_client/railtie.rb +0 -12
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
+ specs:
4
+ copy_tuner_client (0.1.0.beta)
5
+ i18n (>= 0.5.0)
6
+ json
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (2.3.16)
12
+ actionpack (= 2.3.16)
13
+ actionpack (2.3.16)
14
+ activesupport (= 2.3.16)
15
+ rack (~> 1.1.0)
16
+ activerecord (2.3.16)
17
+ activesupport (= 2.3.16)
18
+ activeresource (2.3.16)
19
+ activesupport (= 2.3.16)
20
+ activesupport (2.3.16)
21
+ addressable (2.3.2)
22
+ ansi (1.4.3)
23
+ appraisal (0.5.1)
24
+ bundler
25
+ rake
26
+ aruba (0.3.7)
27
+ childprocess (>= 0.1.9)
28
+ cucumber (>= 0.10.5)
29
+ rspec (>= 2.6.0)
30
+ bourne (1.3.0)
31
+ mocha (= 0.13.0)
32
+ builder (3.1.4)
33
+ childprocess (0.3.7)
34
+ ffi (~> 1.0, >= 1.0.6)
35
+ crack (0.3.2)
36
+ cucumber (0.10.7)
37
+ builder (>= 2.1.2)
38
+ diff-lcs (>= 1.1.2)
39
+ gherkin (~> 2.4.0)
40
+ json (>= 1.4.6)
41
+ term-ansicolor (>= 1.0.5)
42
+ daemons (1.1.9)
43
+ diff-lcs (1.1.3)
44
+ eventmachine (1.0.0)
45
+ ffi (1.3.1)
46
+ gherkin (2.4.21)
47
+ json (>= 1.4.6)
48
+ i18n (0.6.1)
49
+ json (1.7.6)
50
+ metaclass (0.0.1)
51
+ mocha (0.13.0)
52
+ metaclass (~> 0.0.1)
53
+ rack (1.1.5)
54
+ rails (2.3.16)
55
+ actionmailer (= 2.3.16)
56
+ actionpack (= 2.3.16)
57
+ activerecord (= 2.3.16)
58
+ activeresource (= 2.3.16)
59
+ activesupport (= 2.3.16)
60
+ rake (>= 0.8.3)
61
+ rake (10.0.3)
62
+ rspec (2.12.0)
63
+ rspec-core (~> 2.12.0)
64
+ rspec-expectations (~> 2.12.0)
65
+ rspec-mocks (~> 2.12.0)
66
+ rspec-core (2.12.2)
67
+ rspec-expectations (2.12.1)
68
+ diff-lcs (~> 1.1.3)
69
+ rspec-mocks (2.12.2)
70
+ sham_rack (1.3.4)
71
+ rack
72
+ sinatra (1.2.8)
73
+ rack (~> 1.1)
74
+ tilt (>= 1.2.2, < 2.0)
75
+ sqlite3 (1.3.7)
76
+ term-ansicolor (1.0.7)
77
+ thin (1.5.0)
78
+ daemons (>= 1.0.9)
79
+ eventmachine (>= 0.12.6)
80
+ rack (>= 1.0.0)
81
+ tilt (1.3.3)
82
+ turn (0.9.6)
83
+ ansi
84
+ webmock (1.9.0)
85
+ addressable (>= 2.2.7)
86
+ crack (>= 0.1.7)
87
+ yard (0.8.4.1)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ appraisal (~> 0.4)
94
+ aruba (~> 0.3.2)
95
+ bourne
96
+ copy_tuner_client!
97
+ cucumber (~> 0.10.0)
98
+ i18n
99
+ rails (= 2.3.16)
100
+ rake
101
+ rspec (~> 2.3)
102
+ sham_rack
103
+ sinatra
104
+ sqlite3
105
+ thin
106
+ turn
107
+ webmock
108
+ yard
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "4.1.4"
5
+ gem "rails", "3.0.20"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec :path=>"../"
@@ -0,0 +1,153 @@
1
+ PATH
2
+ remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
+ specs:
4
+ copy_tuner_client (0.0.13)
5
+ i18n (>= 0.5.0)
6
+ json
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.20)
13
+ actionpack (= 3.0.20)
14
+ mail (~> 2.2.19)
15
+ actionpack (3.0.20)
16
+ activemodel (= 3.0.20)
17
+ activesupport (= 3.0.20)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.5.0)
21
+ rack (~> 1.2.5)
22
+ rack-mount (~> 0.6.14)
23
+ rack-test (~> 0.5.7)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.20)
26
+ activesupport (= 3.0.20)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.5.0)
29
+ activerecord (3.0.20)
30
+ activemodel (= 3.0.20)
31
+ activesupport (= 3.0.20)
32
+ arel (~> 2.0.10)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.20)
35
+ activemodel (= 3.0.20)
36
+ activesupport (= 3.0.20)
37
+ activesupport (3.0.20)
38
+ addressable (2.3.2)
39
+ ansi (1.4.3)
40
+ appraisal (0.5.1)
41
+ bundler
42
+ rake
43
+ arel (2.0.10)
44
+ aruba (0.3.7)
45
+ childprocess (>= 0.1.9)
46
+ cucumber (>= 0.10.5)
47
+ rspec (>= 2.6.0)
48
+ bourne (1.3.0)
49
+ mocha (= 0.13.0)
50
+ builder (2.1.2)
51
+ childprocess (0.3.7)
52
+ ffi (~> 1.0, >= 1.0.6)
53
+ crack (0.3.2)
54
+ cucumber (0.10.7)
55
+ builder (>= 2.1.2)
56
+ diff-lcs (>= 1.1.2)
57
+ gherkin (~> 2.4.0)
58
+ json (>= 1.4.6)
59
+ term-ansicolor (>= 1.0.5)
60
+ daemons (1.1.9)
61
+ diff-lcs (1.1.3)
62
+ erubis (2.6.6)
63
+ abstract (>= 1.0.0)
64
+ eventmachine (1.0.0)
65
+ ffi (1.3.1)
66
+ gherkin (2.4.21)
67
+ json (>= 1.4.6)
68
+ i18n (0.5.0)
69
+ json (1.7.6)
70
+ mail (2.2.19)
71
+ activesupport (>= 2.3.6)
72
+ i18n (>= 0.4.0)
73
+ mime-types (~> 1.16)
74
+ treetop (~> 1.4.8)
75
+ metaclass (0.0.1)
76
+ mime-types (1.20.1)
77
+ mocha (0.13.0)
78
+ metaclass (~> 0.0.1)
79
+ polyglot (0.3.3)
80
+ rack (1.2.7)
81
+ rack-mount (0.6.14)
82
+ rack (>= 1.0.0)
83
+ rack-test (0.5.7)
84
+ rack (>= 1.0)
85
+ rails (3.0.20)
86
+ actionmailer (= 3.0.20)
87
+ actionpack (= 3.0.20)
88
+ activerecord (= 3.0.20)
89
+ activeresource (= 3.0.20)
90
+ activesupport (= 3.0.20)
91
+ bundler (~> 1.0)
92
+ railties (= 3.0.20)
93
+ railties (3.0.20)
94
+ actionpack (= 3.0.20)
95
+ activesupport (= 3.0.20)
96
+ rake (>= 0.8.7)
97
+ rdoc (~> 3.4)
98
+ thor (~> 0.14.4)
99
+ rake (10.0.3)
100
+ rdoc (3.12)
101
+ json (~> 1.4)
102
+ rspec (2.12.0)
103
+ rspec-core (~> 2.12.0)
104
+ rspec-expectations (~> 2.12.0)
105
+ rspec-mocks (~> 2.12.0)
106
+ rspec-core (2.12.2)
107
+ rspec-expectations (2.12.1)
108
+ diff-lcs (~> 1.1.3)
109
+ rspec-mocks (2.12.2)
110
+ sham_rack (1.3.4)
111
+ rack
112
+ sinatra (1.2.8)
113
+ rack (~> 1.1)
114
+ tilt (>= 1.2.2, < 2.0)
115
+ sqlite3 (1.3.7)
116
+ term-ansicolor (1.0.7)
117
+ thin (1.5.0)
118
+ daemons (>= 1.0.9)
119
+ eventmachine (>= 0.12.6)
120
+ rack (>= 1.0.0)
121
+ thor (0.14.6)
122
+ tilt (1.3.3)
123
+ treetop (1.4.12)
124
+ polyglot
125
+ polyglot (>= 0.3.1)
126
+ turn (0.9.6)
127
+ ansi
128
+ tzinfo (0.3.35)
129
+ webmock (1.9.0)
130
+ addressable (>= 2.2.7)
131
+ crack (>= 0.1.7)
132
+ yard (0.8.4.1)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ appraisal (~> 0.4)
139
+ aruba (~> 0.3.2)
140
+ bourne
141
+ copy_tuner_client!
142
+ cucumber (~> 0.10.0)
143
+ i18n
144
+ rails (= 3.0.20)
145
+ rake
146
+ rspec (~> 2.3)
147
+ sham_rack
148
+ sinatra
149
+ sqlite3
150
+ thin
151
+ turn
152
+ webmock
153
+ yard
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.1.10"
6
+ gem "jquery-rails"
7
+ gem "uglifier"
8
+ gem "sass-rails"
9
+ gem "coffee-rails"
10
+
11
+ gemspec :path=>"../"
@@ -0,0 +1,191 @@
1
+ PATH
2
+ remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
+ specs:
4
+ copy_tuner_client (0.0.13)
5
+ i18n (>= 0.5.0)
6
+ json
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.10)
12
+ actionpack (= 3.1.10)
13
+ mail (~> 2.3.3)
14
+ actionpack (3.1.10)
15
+ activemodel (= 3.1.10)
16
+ activesupport (= 3.1.10)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.6)
21
+ rack-cache (~> 1.2)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.4)
25
+ activemodel (3.1.10)
26
+ activesupport (= 3.1.10)
27
+ builder (~> 3.0.0)
28
+ i18n (~> 0.6)
29
+ activerecord (3.1.10)
30
+ activemodel (= 3.1.10)
31
+ activesupport (= 3.1.10)
32
+ arel (~> 2.2.3)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.10)
35
+ activemodel (= 3.1.10)
36
+ activesupport (= 3.1.10)
37
+ activesupport (3.1.10)
38
+ multi_json (>= 1.0, < 1.3)
39
+ addressable (2.3.2)
40
+ ansi (1.4.3)
41
+ appraisal (0.5.1)
42
+ bundler
43
+ rake
44
+ arel (2.2.3)
45
+ aruba (0.3.7)
46
+ childprocess (>= 0.1.9)
47
+ cucumber (>= 0.10.5)
48
+ rspec (>= 2.6.0)
49
+ bourne (1.3.0)
50
+ mocha (= 0.13.0)
51
+ builder (3.0.4)
52
+ childprocess (0.3.7)
53
+ ffi (~> 1.0, >= 1.0.6)
54
+ coffee-rails (3.1.1)
55
+ coffee-script (>= 2.2.0)
56
+ railties (~> 3.1.0)
57
+ coffee-script (2.2.0)
58
+ coffee-script-source
59
+ execjs
60
+ coffee-script-source (1.4.0)
61
+ crack (0.3.2)
62
+ cucumber (0.10.7)
63
+ builder (>= 2.1.2)
64
+ diff-lcs (>= 1.1.2)
65
+ gherkin (~> 2.4.0)
66
+ json (>= 1.4.6)
67
+ term-ansicolor (>= 1.0.5)
68
+ daemons (1.1.9)
69
+ diff-lcs (1.1.3)
70
+ erubis (2.7.0)
71
+ eventmachine (1.0.0)
72
+ execjs (1.4.0)
73
+ multi_json (~> 1.0)
74
+ ffi (1.3.1)
75
+ gherkin (2.4.21)
76
+ json (>= 1.4.6)
77
+ hike (1.2.1)
78
+ i18n (0.6.1)
79
+ jquery-rails (2.2.0)
80
+ railties (>= 3.0, < 5.0)
81
+ thor (>= 0.14, < 2.0)
82
+ json (1.7.6)
83
+ mail (2.3.3)
84
+ i18n (>= 0.4.0)
85
+ mime-types (~> 1.16)
86
+ treetop (~> 1.4.8)
87
+ metaclass (0.0.1)
88
+ mime-types (1.20.1)
89
+ mocha (0.13.0)
90
+ metaclass (~> 0.0.1)
91
+ multi_json (1.2.0)
92
+ polyglot (0.3.3)
93
+ rack (1.3.9)
94
+ rack-cache (1.2)
95
+ rack (>= 0.4)
96
+ rack-mount (0.8.3)
97
+ rack (>= 1.0.0)
98
+ rack-protection (1.3.2)
99
+ rack
100
+ rack-ssl (1.3.3)
101
+ rack
102
+ rack-test (0.6.2)
103
+ rack (>= 1.0)
104
+ rails (3.1.10)
105
+ actionmailer (= 3.1.10)
106
+ actionpack (= 3.1.10)
107
+ activerecord (= 3.1.10)
108
+ activeresource (= 3.1.10)
109
+ activesupport (= 3.1.10)
110
+ bundler (~> 1.0)
111
+ railties (= 3.1.10)
112
+ railties (3.1.10)
113
+ actionpack (= 3.1.10)
114
+ activesupport (= 3.1.10)
115
+ rack-ssl (~> 1.3.2)
116
+ rake (>= 0.8.7)
117
+ rdoc (~> 3.4)
118
+ thor (~> 0.14.6)
119
+ rake (10.0.3)
120
+ rdoc (3.12)
121
+ json (~> 1.4)
122
+ rspec (2.12.0)
123
+ rspec-core (~> 2.12.0)
124
+ rspec-expectations (~> 2.12.0)
125
+ rspec-mocks (~> 2.12.0)
126
+ rspec-core (2.12.2)
127
+ rspec-expectations (2.12.1)
128
+ diff-lcs (~> 1.1.3)
129
+ rspec-mocks (2.12.2)
130
+ sass (3.2.5)
131
+ sass-rails (3.1.7)
132
+ actionpack (~> 3.1.0)
133
+ railties (~> 3.1.0)
134
+ sass (>= 3.1.10)
135
+ tilt (~> 1.3.2)
136
+ sham_rack (1.3.4)
137
+ rack
138
+ sinatra (1.3.3)
139
+ rack (~> 1.3, >= 1.3.6)
140
+ rack-protection (~> 1.2)
141
+ tilt (~> 1.3, >= 1.3.3)
142
+ sprockets (2.0.4)
143
+ hike (~> 1.2)
144
+ rack (~> 1.0)
145
+ tilt (~> 1.1, != 1.3.0)
146
+ sqlite3 (1.3.7)
147
+ term-ansicolor (1.0.7)
148
+ thin (1.5.0)
149
+ daemons (>= 1.0.9)
150
+ eventmachine (>= 0.12.6)
151
+ rack (>= 1.0.0)
152
+ thor (0.14.6)
153
+ tilt (1.3.3)
154
+ treetop (1.4.12)
155
+ polyglot
156
+ polyglot (>= 0.3.1)
157
+ turn (0.9.6)
158
+ ansi
159
+ tzinfo (0.3.35)
160
+ uglifier (1.3.0)
161
+ execjs (>= 0.3.0)
162
+ multi_json (~> 1.0, >= 1.0.2)
163
+ webmock (1.9.0)
164
+ addressable (>= 2.2.7)
165
+ crack (>= 0.1.7)
166
+ yard (0.8.4.1)
167
+
168
+ PLATFORMS
169
+ ruby
170
+
171
+ DEPENDENCIES
172
+ appraisal (~> 0.4)
173
+ aruba (~> 0.3.2)
174
+ bourne
175
+ coffee-rails
176
+ copy_tuner_client!
177
+ cucumber (~> 0.10.0)
178
+ i18n
179
+ jquery-rails
180
+ rails (= 3.1.10)
181
+ rake
182
+ rspec (~> 2.3)
183
+ sass-rails
184
+ sham_rack
185
+ sinatra
186
+ sqlite3
187
+ thin
188
+ turn
189
+ uglifier
190
+ webmock
191
+ yard
@@ -20,7 +20,6 @@ module CopyTunerClient
20
20
  @mutex = Mutex.new
21
21
  @queued = {}
22
22
  @started = false
23
- @exclude_key_regexp = options[:exclude_key_regexp]
24
23
  end
25
24
 
26
25
  # Returns content for the given blurb.
@@ -35,7 +34,6 @@ module CopyTunerClient
35
34
  # @param key [String] the key of the blurb to update
36
35
  # @param value [String] the new contents of the blurb
37
36
  def []=(key, value)
38
- return if key =~ @exclude_key_regexp
39
37
  lock { @queued[key] = value }
40
38
  end
41
39
 
@@ -6,6 +6,8 @@ require 'copy_tuner_client/process_guard'
6
6
  require 'copy_tuner_client/poller'
7
7
  require 'copy_tuner_client/prefixed_logger'
8
8
  require 'copy_tuner_client/request_sync'
9
+ require 'copy_tuner_client/copyray_middleware'
10
+ require 'copy_tuner_client/simple_form_extention'
9
11
 
10
12
  module CopyTunerClient
11
13
  # Used to set up and modify settings for the client.
@@ -17,7 +19,7 @@ module CopyTunerClient
17
19
  :client_version, :port, :protocol, :proxy_host, :proxy_pass,
18
20
  :proxy_port, :proxy_user, :secure, :polling_delay, :sync_interval,
19
21
  :sync_interval_staging, :sync_ignore_path_regex, :logger,
20
- :framework, :middleware, :disable_middleware, :disable_test_translation, :ca_file, :exclude_key_regexp].freeze
22
+ :framework, :middleware, :disable_middleware, :disable_test_translation, :ca_file].freeze
21
23
 
22
24
  # @return [String] The API key for your project, found on the project edit form.
23
25
  attr_accessor :api_key
@@ -106,9 +108,6 @@ module CopyTunerClient
106
108
  # @return [Boolean] To enable inline-translation-mode, set true.
107
109
  attr_accessor :inline_translation
108
110
 
109
- # @return [Regexp] Regular expression to exclude keys.
110
- attr_accessor :exclude_key_regexp
111
-
112
111
  alias_method :secure?, :secure
113
112
 
114
113
  # Instantiated from {CopyTunerClient.configure}. Sets defaults.
@@ -197,6 +196,7 @@ module CopyTunerClient
197
196
  if middleware && development? && !disable_middleware
198
197
  logger.info "Using copytuner sync middleware"
199
198
  middleware.use RequestSync, :cache => cache, :interval => sync_interval, :ignore_regex => sync_ignore_path_regex
199
+ middleware.use CopyTunerClient::CopyrayMiddleware
200
200
  else
201
201
  logger.info "[[[Warn]]] Not useing copytuner sync middleware" unless middleware
202
202
  end
@@ -0,0 +1,29 @@
1
+ module CopyTunerClient
2
+ class Copyray
3
+ # Returns augmented HTML where the source is simply wrapped in an HTML
4
+ # comment with filepath info. Xray.js uses these comments to associate
5
+ # elements with the templates that rendered them.
6
+ #
7
+ # This:
8
+ # <div class=".my-element">
9
+ # ...
10
+ # </div>
11
+ #
12
+ # Becomes:
13
+ # <!-- XRAY START 123 /path/to/file.html -->
14
+ # <div class=".my-element">
15
+ # ...
16
+ # </div>
17
+ # <!-- XRAY END 123 -->
18
+ def self.augment_template(source, key)
19
+ id = next_id
20
+ # skim doesn't allow html comments, so use skim's comment syntax if it's skim
21
+ augmented = "<!--XRAY START #{id} #{key}-->\n<span>#{source}</span>\n<!--XRAY END #{id}-->"
22
+ ActiveSupport::SafeBuffer === source ? ActiveSupport::SafeBuffer.new(augmented) : augmented
23
+ end
24
+
25
+ def self.next_id
26
+ @id = (@id ||= 0) + 1
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,65 @@
1
+ # cf) xray-rails : xray/middleware.rb
2
+
3
+ module CopyTunerClient
4
+ class CopyrayMiddleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ status, headers, response = @app.call(env)
11
+ if should_inject_xray?(status, headers, response)
12
+ body = response.body.sub(/<body[^>]*>/) { "#{$~}\n#{css_tag}" }
13
+ # if Rails.application.config.assets.debug
14
+ append_js!(body, 'jquery', :copyray)
15
+ # end
16
+ headers['Content-Length'] = body.bytesize.to_s
17
+ end
18
+ [status, headers, (body ? [body] : response)]
19
+ end
20
+
21
+ private
22
+
23
+ def helpers
24
+ ActionController::Base.helpers
25
+ end
26
+
27
+ # Appends the given `script_name` after the `after_script_name`.
28
+ def append_js!(html, after_script_name, script_name)
29
+ # Matches:
30
+ # <script src="/assets/jquery.js"></script>
31
+ # <script src="/assets/jquery-min.js"></script>
32
+ # <script src="/assets/jquery.min.1.9.1.js"></script>
33
+ html.sub!(/<script[^>]+\/#{after_script_name}([-.]{1}[\d\.]+)?([-.]{1}min)?\.js[^>]+><\/script>/) do
34
+ "#{$~}\n" + helpers.javascript_include_tag(script_name)
35
+ end
36
+ end
37
+
38
+ def css_tag
39
+ h = ActionController::Base.helpers
40
+ helpers.stylesheet_link_tag :copyray
41
+ end
42
+
43
+ def should_inject_xray?(status, headers, response)
44
+ status == 200 &&
45
+ !empty?(response) &&
46
+ html_request?(headers, response) &&
47
+ !file?(headers) &&
48
+ !response.body.frozen?
49
+ end
50
+
51
+ def empty?(response)
52
+ # response may be ["Not Found"], ["Move Permanently"], etc.
53
+ (response.is_a?(Array) && response.size <= 1) ||
54
+ !response.respond_to?(:body) || response.body.empty?
55
+ end
56
+
57
+ def file?(headers)
58
+ headers["Content-Transfer-Encoding"] == "binary"
59
+ end
60
+
61
+ def html_request?(headers, response)
62
+ headers['Content-Type'] && headers['Content-Type'].include?('text/html') && response.body.include?("<html")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,29 @@
1
+ require 'copy_tuner_client/copyray'
2
+
3
+ module CopyTunerClient
4
+ # Connects to integration points for Rails 3 applications
5
+ class Engine < ::Rails::Engine
6
+ initializer :initialize_copy_tuner_rails, :before => :load_config_initializers do |app|
7
+ CopyTunerClient::Rails.initialize
8
+
9
+ ActiveSupport.on_load(:action_view) do
10
+ ActionView::Helpers::TranslationHelper.class_eval do
11
+ def translate_with_copyray_comment(key, options = {})
12
+ source = translate_without_copyray_comment(key, options)
13
+ if options[:rescue_format] == :html
14
+ CopyTunerClient::Copyray.augment_template(source, scope_key_by_partial(key))
15
+ else
16
+ source
17
+ end
18
+ end
19
+ alias_method_chain :translate, :copyray_comment
20
+ alias t translate
21
+ end
22
+ end
23
+ end
24
+
25
+ rake_tasks do
26
+ load "tasks/copy_tuner_client_tasks.rake"
27
+ end
28
+ end
29
+ end
@@ -38,9 +38,8 @@ module CopyTunerClient
38
38
  # Returns locales availabile for this CopyTuner project.
39
39
  # @return [Array<String>] available locales
40
40
  def available_locales
41
- return @available_locales if defined?(@available_locales)
42
41
  cached_locales = cache.keys.map { |key| key.split('.').first }
43
- @available_locales = (cached_locales + super).uniq.map { |locale| locale.to_sym }
42
+ (cached_locales + super).uniq.map { |locale| locale.to_sym }
44
43
  end
45
44
 
46
45
  # Stores the given translations.
@@ -15,7 +15,7 @@ module CopyTunerClient
15
15
  end
16
16
 
17
17
  if defined?(::Rails::Railtie)
18
- require 'copy_tuner_client/railtie'
18
+ require 'copy_tuner_client/engine'
19
19
  else
20
20
  CopyTunerClient::Rails.initialize
21
21
  end
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'copy_tuner_client/copyray'
3
+
4
+ begin
5
+ require "simple_form"
6
+ rescue LoadError
7
+ end
8
+
9
+ if defined?(SimpleForm)
10
+ module SimpleForm::Components::Labels
11
+ protected
12
+ def label_translation_with_copyray_comment
13
+ source = label_translation_without_copyray_comment
14
+ # どこのキーかは特定しにくい
15
+ CopyTunerClient::Copyray.augment_template(source, attribute_name)
16
+ end
17
+ alias_method_chain :label_translation, :copyray_comment
18
+ end
19
+ end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.0.15'
3
+ VERSION = '0.1.0.beta'
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze