copy_tuner_client 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/Appraisals +2 -6
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +93 -80
- data/app/assets/javascripts/copyray.js.coffee +38 -0
- data/app/assets/stylesheets/copyray.css +70 -0
- data/app/views/_copy_tuner_bar.html.erb +11 -0
- data/copy_tuner_client.gemspec +1 -2
- data/features/step_definitions/rails_steps.rb +1 -0
- data/gemfiles/4.1.gemfile +1 -1
- data/gemfiles/4.2.gemfile +1 -1
- data/lib/copy_tuner_client/client.rb +8 -8
- data/lib/copy_tuner_client/configuration.rb +10 -4
- data/lib/copy_tuner_client/copyray_middleware.rb +28 -4
- data/lib/copy_tuner_client/engine.rb +2 -0
- data/lib/copy_tuner_client/translation_log.rb +37 -0
- data/lib/copy_tuner_client/version.rb +1 -1
- data/spec/copy_tuner_client/client_spec.rb +1 -0
- data/spec/copy_tuner_client/configuration_spec.rb +12 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/client_spec_helpers.rb +1 -0
- data/spec/support/fake_copy_tuner_app.rb +2 -2
- metadata +7 -19
- data/gemfiles/3.2.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfc2b0438d95dfd78e642cbd01634341a49dda1
|
4
|
+
data.tar.gz: 3404e74efd31b4fb22bfa9d7e2d07f40508fd170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1766da6789da799a6b657f711244009c702ac078421b3fe14e69c827bc33643a7a39017bda3f8264965f03ddc399ceb01c9a20234671e3409a965e315de539d
|
7
|
+
data.tar.gz: 58c5aa8d6ab6c6af3b400f4171303e485a30acd2bc43c1f9779d1f3651435e5cbe960dbdede61135436c9924f87f33274cc4b13fbf7eda128505c3a764add976
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
appraise '3.2' do
|
2
|
-
gem 'rails', '3.2.22'
|
3
|
-
end
|
4
|
-
|
5
1
|
appraise '4.0' do
|
6
2
|
gem 'rails', '4.0.13'
|
7
3
|
end
|
8
4
|
|
9
5
|
appraise '4.1' do
|
10
|
-
gem 'rails', '4.1.
|
6
|
+
gem 'rails', '4.1.15'
|
11
7
|
end
|
12
8
|
|
13
9
|
appraise '4.2' do
|
14
|
-
gem 'rails', '4.2.
|
10
|
+
gem 'rails', '4.2.6'
|
15
11
|
end
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,57 +1,64 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
copy_tuner_client (0.
|
4
|
+
copy_tuner_client (0.3.0)
|
5
5
|
i18n (>= 0.5.0)
|
6
6
|
json
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionmailer (
|
12
|
-
actionpack (=
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
actionmailer (4.2.6)
|
12
|
+
actionpack (= 4.2.6)
|
13
|
+
actionview (= 4.2.6)
|
14
|
+
activejob (= 4.2.6)
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
16
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
+
actionpack (4.2.6)
|
18
|
+
actionview (= 4.2.6)
|
19
|
+
activesupport (= 4.2.6)
|
20
|
+
rack (~> 1.6)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
+
actionview (4.2.6)
|
25
|
+
activesupport (= 4.2.6)
|
26
|
+
builder (~> 3.1)
|
18
27
|
erubis (~> 2.7.0)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
activesupport (3.1.12)
|
38
|
-
multi_json (~> 1.0)
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
30
|
+
activejob (4.2.6)
|
31
|
+
activesupport (= 4.2.6)
|
32
|
+
globalid (>= 0.3.0)
|
33
|
+
activemodel (4.2.6)
|
34
|
+
activesupport (= 4.2.6)
|
35
|
+
builder (~> 3.1)
|
36
|
+
activerecord (4.2.6)
|
37
|
+
activemodel (= 4.2.6)
|
38
|
+
activesupport (= 4.2.6)
|
39
|
+
arel (~> 6.0)
|
40
|
+
activesupport (4.2.6)
|
41
|
+
i18n (~> 0.7)
|
42
|
+
json (~> 1.7, >= 1.7.7)
|
43
|
+
minitest (~> 5.1)
|
44
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
45
|
+
tzinfo (~> 1.1)
|
39
46
|
addressable (2.4.0)
|
40
|
-
ansi (1.5.0)
|
41
47
|
appraisal (2.1.0)
|
42
48
|
bundler
|
43
49
|
rake
|
44
50
|
thor (>= 0.14.0)
|
45
|
-
arel (
|
51
|
+
arel (6.0.3)
|
46
52
|
aruba (0.6.2)
|
47
53
|
childprocess (>= 0.3.6)
|
48
54
|
cucumber (>= 1.1.1)
|
49
55
|
rspec-expectations (>= 2.7.0)
|
50
56
|
bourne (1.6.0)
|
51
57
|
mocha (~> 1.1)
|
52
|
-
builder (3.
|
58
|
+
builder (3.2.2)
|
53
59
|
childprocess (0.5.9)
|
54
60
|
ffi (~> 1.0, >= 1.0.11)
|
61
|
+
concurrent-ruby (1.0.2)
|
55
62
|
crack (0.4.3)
|
56
63
|
safe_yaml (~> 1.0.0)
|
57
64
|
cucumber (1.3.20)
|
@@ -67,51 +74,59 @@ GEM
|
|
67
74
|
ffi (1.9.10)
|
68
75
|
gherkin (2.12.2)
|
69
76
|
multi_json (~> 1.3)
|
77
|
+
globalid (0.3.6)
|
78
|
+
activesupport (>= 4.1.0)
|
70
79
|
hashdiff (0.3.0)
|
71
|
-
hike (1.2.3)
|
72
80
|
i18n (0.7.0)
|
73
81
|
json (1.8.3)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
82
|
+
loofah (2.0.3)
|
83
|
+
nokogiri (>= 1.5.9)
|
84
|
+
mail (2.6.4)
|
85
|
+
mime-types (>= 1.16, < 4)
|
78
86
|
metaclass (0.0.4)
|
79
|
-
mime-types (
|
80
|
-
|
87
|
+
mime-types (3.1)
|
88
|
+
mime-types-data (~> 3.2015)
|
89
|
+
mime-types-data (3.2016.0521)
|
90
|
+
mini_portile2 (2.1.0)
|
91
|
+
minitest (5.9.0)
|
81
92
|
mocha (1.1.0)
|
82
93
|
metaclass (~> 0.0.1)
|
83
|
-
multi_json (1.
|
94
|
+
multi_json (1.12.1)
|
84
95
|
multi_test (0.1.2)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
rack
|
90
|
-
rack (>= 1.0.0)
|
96
|
+
nokogiri (1.6.8)
|
97
|
+
mini_portile2 (~> 2.1.0)
|
98
|
+
pkg-config (~> 1.1.7)
|
99
|
+
pkg-config (1.1.7)
|
100
|
+
rack (1.6.4)
|
91
101
|
rack-protection (1.5.3)
|
92
102
|
rack
|
93
|
-
rack-ssl (1.3.4)
|
94
|
-
rack
|
95
103
|
rack-test (0.6.3)
|
96
104
|
rack (>= 1.0)
|
97
|
-
rails (
|
98
|
-
actionmailer (=
|
99
|
-
actionpack (=
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
rails (4.2.6)
|
106
|
+
actionmailer (= 4.2.6)
|
107
|
+
actionpack (= 4.2.6)
|
108
|
+
actionview (= 4.2.6)
|
109
|
+
activejob (= 4.2.6)
|
110
|
+
activemodel (= 4.2.6)
|
111
|
+
activerecord (= 4.2.6)
|
112
|
+
activesupport (= 4.2.6)
|
113
|
+
bundler (>= 1.3.0, < 2.0)
|
114
|
+
railties (= 4.2.6)
|
115
|
+
sprockets-rails
|
116
|
+
rails-deprecated_sanitizer (1.0.3)
|
117
|
+
activesupport (>= 4.2.0.alpha)
|
118
|
+
rails-dom-testing (1.0.7)
|
119
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
120
|
+
nokogiri (~> 1.6.0)
|
121
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
122
|
+
rails-html-sanitizer (1.0.3)
|
123
|
+
loofah (~> 2.0)
|
124
|
+
railties (4.2.6)
|
125
|
+
actionpack (= 4.2.6)
|
126
|
+
activesupport (= 4.2.6)
|
109
127
|
rake (>= 0.8.7)
|
110
|
-
|
111
|
-
|
112
|
-
rake (11.1.2)
|
113
|
-
rdoc (3.12.2)
|
114
|
-
json (~> 1.4)
|
128
|
+
thor (>= 0.18.1, < 2.0)
|
129
|
+
rake (11.2.2)
|
115
130
|
rspec (2.99.0)
|
116
131
|
rspec-core (~> 2.99.0)
|
117
132
|
rspec-expectations (~> 2.99.0)
|
@@ -127,24 +142,23 @@ GEM
|
|
127
142
|
rack (~> 1.3, >= 1.3.6)
|
128
143
|
rack-protection (~> 1.2)
|
129
144
|
tilt (~> 1.3, >= 1.3.3)
|
130
|
-
sprockets (
|
131
|
-
|
132
|
-
rack (
|
133
|
-
|
145
|
+
sprockets (3.6.3)
|
146
|
+
concurrent-ruby (~> 1.0)
|
147
|
+
rack (> 1, < 3)
|
148
|
+
sprockets-rails (3.1.1)
|
149
|
+
actionpack (>= 4.0)
|
150
|
+
activesupport (>= 4.0)
|
151
|
+
sprockets (>= 3.0.0)
|
134
152
|
sqlite3 (1.3.11)
|
135
|
-
thin (1.
|
153
|
+
thin (1.7.0)
|
136
154
|
daemons (~> 1.0, >= 1.0.9)
|
137
155
|
eventmachine (~> 1.0, >= 1.0.4)
|
138
|
-
rack (
|
139
|
-
thor (0.
|
156
|
+
rack (>= 1, < 3)
|
157
|
+
thor (0.19.1)
|
158
|
+
thread_safe (0.3.5)
|
140
159
|
tilt (1.4.1)
|
141
|
-
|
142
|
-
|
143
|
-
polyglot (>= 0.3.1)
|
144
|
-
turn (0.9.7)
|
145
|
-
ansi
|
146
|
-
minitest (~> 4)
|
147
|
-
tzinfo (0.3.49)
|
160
|
+
tzinfo (1.2.2)
|
161
|
+
thread_safe (~> 0.1)
|
148
162
|
webmock (2.0.0)
|
149
163
|
addressable (>= 2.3.6)
|
150
164
|
crack (>= 0.3.2)
|
@@ -160,14 +174,13 @@ DEPENDENCIES
|
|
160
174
|
bourne
|
161
175
|
copy_tuner_client!
|
162
176
|
cucumber (~> 1.3.16)
|
163
|
-
rails (~>
|
177
|
+
rails (~> 4.2.6)
|
164
178
|
rake
|
165
179
|
rspec (~> 2.3)
|
166
180
|
sham_rack
|
167
181
|
sinatra
|
168
182
|
sqlite3
|
169
183
|
thin
|
170
|
-
turn
|
171
184
|
webmock
|
172
185
|
yard
|
173
186
|
|
@@ -26,6 +26,7 @@ Copyray.init = do ->
|
|
26
26
|
Copyray.findBlurbs()
|
27
27
|
|
28
28
|
Copyray.addToggleButton()
|
29
|
+
|
29
30
|
# Ready to rock.
|
30
31
|
console?.log "Ready to Copyray. Press #{if is_mac then 'cmd+shift+k' else 'ctrl+shift+k'} to scan your UI."
|
31
32
|
|
@@ -71,10 +72,12 @@ Copyray.open = (url) ->
|
|
71
72
|
# Show the Copyray overlay
|
72
73
|
Copyray.show = (type = null) ->
|
73
74
|
Copyray.Overlay.instance().show(type)
|
75
|
+
Copyray.showBar()
|
74
76
|
|
75
77
|
# Hide the Copyray overlay
|
76
78
|
Copyray.hide = ->
|
77
79
|
Copyray.Overlay.instance().hide()
|
80
|
+
Copyray.hideBar()
|
78
81
|
|
79
82
|
Copyray.toggleSettings = ->
|
80
83
|
Copyray.Overlay.instance().settings.toggle()
|
@@ -172,6 +175,7 @@ class Copyray.Overlay
|
|
172
175
|
Copyray.isShowing = false
|
173
176
|
@$overlay.detach()
|
174
177
|
@reset()
|
178
|
+
Copyray.hideBar()
|
175
179
|
|
176
180
|
# Utility methods.
|
177
181
|
util =
|
@@ -213,3 +217,37 @@ util =
|
|
213
217
|
width : boxFrame.right - boxFrame.left
|
214
218
|
height : boxFrame.bottom - boxFrame.top
|
215
219
|
}
|
220
|
+
|
221
|
+
Copyray.showBar = ->
|
222
|
+
$('#copy-tuner-bar').show()
|
223
|
+
$('.copyray-toggle-button').hide()
|
224
|
+
|
225
|
+
Copyray.hideBar = ->
|
226
|
+
$('#copy-tuner-bar').hide()
|
227
|
+
$('.copyray-toggle-button').show()
|
228
|
+
$('#copy-tuner-bar-log-menu').hide()
|
229
|
+
|
230
|
+
Copyray.createLogMenu = ->
|
231
|
+
$tbody = $('#copy-tuner-bar-log-menu__tbody.is-not-initialized')
|
232
|
+
return if $tbody.length == 0
|
233
|
+
$tbody.removeClass('is-not-initialized')
|
234
|
+
baseUrl = $('[data-copy-tuner-url]').data('copy-tuner-url')
|
235
|
+
log = $('[data-copy-tuner-translation-log').data('copy-tuner-translation-log')
|
236
|
+
$.each log, (k, v) ->
|
237
|
+
if v != ''
|
238
|
+
url = "#{baseUrl}/blurbs/#{k}/edit"
|
239
|
+
$a = $("<a href='#{url}' class='js-copy-tuner-blurb-link'>").text k
|
240
|
+
$td1 = $('<td>').append $a
|
241
|
+
$td2 = $('<td>').text v
|
242
|
+
$tr = $("<tr class='js-copy-tuner-blurb-row'>")
|
243
|
+
$tr.append $td1, $td2
|
244
|
+
$tbody.append $tr
|
245
|
+
$tbody.on 'click', '.js-copy-tuner-blurb-link', (e) ->
|
246
|
+
e.preventDefault()
|
247
|
+
$tbody.on 'click', '.js-copy-tuner-blurb-row', ->
|
248
|
+
Copyray.open $(@).find('a').attr('href')
|
249
|
+
|
250
|
+
$(document).on 'click', '.copy-tuner-bar-open-log', (e) ->
|
251
|
+
e.preventDefault()
|
252
|
+
Copyray.createLogMenu()
|
253
|
+
$('#copy-tuner-bar-log-menu').toggle()
|
@@ -96,3 +96,73 @@ a.copyray-toggle-button {
|
|
96
96
|
a.copyray-toggle-button:hover {
|
97
97
|
opacity: 1;
|
98
98
|
}
|
99
|
+
|
100
|
+
#copy-tuner-bar {
|
101
|
+
position: fixed;
|
102
|
+
left: 0;
|
103
|
+
right: 0;
|
104
|
+
bottom: 0;
|
105
|
+
height: 40px;
|
106
|
+
padding: 0 8px;
|
107
|
+
background: #222;
|
108
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
109
|
+
font-weight: 200;
|
110
|
+
color: #fff;
|
111
|
+
z-index: 2147483647;
|
112
|
+
box-shadow: 0 -1px 0 rgba(255,255,255,0.1), inset 0 2px 6px rgba(0,0,0,0.8);
|
113
|
+
background-image: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.3));
|
114
|
+
}
|
115
|
+
|
116
|
+
#copy-tuner-bar-log-menu {
|
117
|
+
position: fixed;
|
118
|
+
left: 0;
|
119
|
+
right: 0;
|
120
|
+
bottom: 40px;
|
121
|
+
max-height: calc(100vh - 40px);
|
122
|
+
background: #222;
|
123
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
124
|
+
color: #fff;
|
125
|
+
z-index: 2147483647;
|
126
|
+
overflow-y: auto;
|
127
|
+
}
|
128
|
+
|
129
|
+
#copy-tuner-bar-log-menu__tbody td {
|
130
|
+
padding: 2px 8px;
|
131
|
+
}
|
132
|
+
|
133
|
+
#copy-tuner-bar-log-menu__tbody tr:hover {
|
134
|
+
background: #444
|
135
|
+
}
|
136
|
+
|
137
|
+
#copy-tuner-bar-log-menu__tbody a {
|
138
|
+
color: #fff
|
139
|
+
}
|
140
|
+
|
141
|
+
#copy-tuner-bar-log-menu__tbody a:hover, #copy-tuner-bar-log-menu__tbody a:focus {
|
142
|
+
color: #fff;
|
143
|
+
text-decoration: underline;
|
144
|
+
}
|
145
|
+
|
146
|
+
.copy-tuner-bar-button {
|
147
|
+
position: relative;
|
148
|
+
display: inline-block;
|
149
|
+
color: #fff;
|
150
|
+
margin: 8px 1px;
|
151
|
+
height: 24px;
|
152
|
+
line-height: 24px;
|
153
|
+
padding: 0 8px;
|
154
|
+
font-size: 14px;
|
155
|
+
cursor: pointer;
|
156
|
+
vertical-align: middle;
|
157
|
+
background-color: #444;
|
158
|
+
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2));
|
159
|
+
border-radius: 2px;
|
160
|
+
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 0 2px rgba(255, 255, 255, 0.2);
|
161
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
|
162
|
+
}
|
163
|
+
|
164
|
+
.copy-tuner-bar-button:hover, .copy-tuner-bar-button:focus {
|
165
|
+
color: #fff;
|
166
|
+
text-decoration: none;
|
167
|
+
background-color: #555;
|
168
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div id="copy-tuner-bar" style="display:none">
|
2
|
+
<%= link_to 'CopyTuner', CopyTunerClient.configuration.project_url, class: 'copy-tuner-bar-button', target: '_blank' %>
|
3
|
+
<a href="/copytuner" target="_blank" class="copy-tuner-bar-button">Sync</a>
|
4
|
+
<a href="javascript:void(0)" class="copy-tuner-bar-open-log copy-tuner-bar-button">Translations in this page</a>
|
5
|
+
</div>
|
6
|
+
<div id="copy-tuner-bar-log-menu" style="display:none">
|
7
|
+
<table>
|
8
|
+
<tbody id="copy-tuner-bar-log-menu__tbody" class="is-not-initialized">
|
9
|
+
</tbody>
|
10
|
+
</table>
|
11
|
+
</div>
|
data/copy_tuner_client.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.add_development_dependency 'aruba', '~> 0.6.0'
|
10
10
|
s.add_development_dependency 'bourne'
|
11
11
|
s.add_development_dependency 'cucumber', '~> 1.3.16'
|
12
|
-
s.add_development_dependency 'rails', '~>
|
12
|
+
s.add_development_dependency 'rails', '~> 4.2.6'
|
13
13
|
s.add_development_dependency 'rake'
|
14
14
|
s.add_development_dependency 'rspec', '~> 2.3'
|
15
15
|
s.add_development_dependency 'sham_rack'
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency 'thin'
|
19
19
|
s.add_development_dependency 'webmock'
|
20
20
|
s.add_development_dependency 'yard'
|
21
|
-
s.add_development_dependency 'turn'
|
22
21
|
s.authors = ['SonicGarden']
|
23
22
|
s.email = 'info@sonicgarden.jp'
|
24
23
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
@@ -37,6 +37,7 @@ When /^I configure the copy_tuner client with api key "([^"]*)"$/ do |api_key|
|
|
37
37
|
config.api_key = "#{api_key}"
|
38
38
|
config.polling_delay = 1
|
39
39
|
config.host = 'localhost'
|
40
|
+
config.s3_host = 'localhost'
|
40
41
|
config.secure = false
|
41
42
|
config.sync_interval = 0
|
42
43
|
config.port = #{FakeCopyTunerApp.port}
|
data/gemfiles/4.1.gemfile
CHANGED
data/gemfiles/4.2.gemfile
CHANGED
@@ -28,7 +28,7 @@ module CopyTunerClient
|
|
28
28
|
# @option options [String] :ca_file path to root certificate file for ssl verification
|
29
29
|
def initialize(options)
|
30
30
|
[:api_key, :host, :port, :public, :http_read_timeout,
|
31
|
-
:http_open_timeout, :secure, :logger, :ca_file].each do |option|
|
31
|
+
:http_open_timeout, :secure, :logger, :ca_file, :s3_host].each do |option|
|
32
32
|
instance_variable_set "@#{option}", options[option]
|
33
33
|
end
|
34
34
|
end
|
@@ -44,7 +44,7 @@ module CopyTunerClient
|
|
44
44
|
# @yield [Hash] downloaded blurbs
|
45
45
|
# @raise [ConnectionError] if the connection fails
|
46
46
|
def download
|
47
|
-
connect do |http|
|
47
|
+
connect(s3_host) do |http|
|
48
48
|
request = Net::HTTP::Get.new(uri(download_resource))
|
49
49
|
request['If-None-Match'] = @etag
|
50
50
|
response = http.request(request)
|
@@ -64,7 +64,7 @@ module CopyTunerClient
|
|
64
64
|
# @param data [Hash] the blurbs to upload
|
65
65
|
# @raise [ConnectionError] if the connection fails
|
66
66
|
def upload(data)
|
67
|
-
connect do |http|
|
67
|
+
connect(host) do |http|
|
68
68
|
response = http.post(uri('draft_blurbs'), data.to_json, 'Content-Type' => 'application/json')
|
69
69
|
check response
|
70
70
|
log 'Uploaded missing translations'
|
@@ -74,7 +74,7 @@ module CopyTunerClient
|
|
74
74
|
# Issues a deploy, marking all draft content as published for this project.
|
75
75
|
# @raise [ConnectionError] if the connection fails
|
76
76
|
def deploy
|
77
|
-
connect do |http|
|
77
|
+
connect(host) do |http|
|
78
78
|
response = http.post(uri('deploys'), '')
|
79
79
|
check response
|
80
80
|
log 'Deployed'
|
@@ -84,7 +84,7 @@ module CopyTunerClient
|
|
84
84
|
private
|
85
85
|
|
86
86
|
attr_reader :host, :port, :api_key, :http_read_timeout,
|
87
|
-
:http_open_timeout, :secure, :logger, :ca_file
|
87
|
+
:http_open_timeout, :secure, :logger, :ca_file, :s3_host
|
88
88
|
|
89
89
|
def public?
|
90
90
|
@public
|
@@ -96,13 +96,13 @@ module CopyTunerClient
|
|
96
96
|
|
97
97
|
def download_resource
|
98
98
|
if public?
|
99
|
-
'published_blurbs'
|
99
|
+
'published_blurbs.json'
|
100
100
|
else
|
101
|
-
'draft_blurbs'
|
101
|
+
'draft_blurbs.json'
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
def connect
|
105
|
+
def connect(host)
|
106
106
|
http = Net::HTTP.new(host, port)
|
107
107
|
http.open_timeout = http_open_timeout
|
108
108
|
http.read_timeout = http_read_timeout
|
@@ -18,7 +18,7 @@ module CopyTunerClient
|
|
18
18
|
:client_version, :port, :protocol, :proxy_host, :proxy_pass,
|
19
19
|
:proxy_port, :proxy_user, :secure, :polling_delay, :sync_interval,
|
20
20
|
:sync_interval_staging, :sync_ignore_path_regex, :logger,
|
21
|
-
:framework, :middleware, :disable_middleware, :disable_test_translation, :ca_file, :exclude_key_regexp].freeze
|
21
|
+
:framework, :middleware, :disable_middleware, :disable_test_translation, :ca_file, :exclude_key_regexp, :s3_host].freeze
|
22
22
|
|
23
23
|
# @return [String] The API key for your project, found on the project edit form.
|
24
24
|
attr_accessor :api_key
|
@@ -110,6 +110,9 @@ module CopyTunerClient
|
|
110
110
|
# @return [Regexp] Regular expression to exclude keys.
|
111
111
|
attr_accessor :exclude_key_regexp
|
112
112
|
|
113
|
+
# @return [String] The S3 host to connect to (defaults to +copy-tuner-us.s3.amazonaws.com+).
|
114
|
+
attr_accessor :s3_host
|
115
|
+
|
113
116
|
# @return [Regexp] Copyray js injection pattern for debug
|
114
117
|
attr_accessor :copyray_js_injection_regexp_for_debug
|
115
118
|
|
@@ -131,20 +134,23 @@ module CopyTunerClient
|
|
131
134
|
self.polling_delay = 300
|
132
135
|
self.sync_interval = 60
|
133
136
|
self.sync_interval_staging = 0
|
134
|
-
self.secure =
|
137
|
+
self.secure = true
|
135
138
|
self.test_environments = %w(test cucumber)
|
139
|
+
self.s3_host = 'copy-tuner-data-prod.s3.amazonaws.com'
|
136
140
|
|
137
141
|
# Matches:
|
138
142
|
# <script src="/assets/jquery.js"></script>
|
139
143
|
# <script src="/assets/jquery-min.js"></script>
|
140
144
|
# <script src="/assets/jquery.min.1.9.1.js"></script>
|
141
145
|
# <script src="/assets/jquery.self-xxxxxx.js"></script>
|
142
|
-
self.
|
146
|
+
# <script src="/assets/jquery2.self-a4777c1acac0a74340755725342901a54ed000955bf6f5320491b8b2514c86ec.js?body=1" data-turbolinks-track="true"></script>
|
147
|
+
self.copyray_js_injection_regexp_for_debug = /<script[^>]+\/jquery[23]?([-.]{1}[\d\.]+)?([-.]{1}min(\.[\d\.]+)?)?(\.self\-[\da-f]+)?\.js[^>]+><\/script>/
|
143
148
|
|
144
149
|
# Matches:
|
145
150
|
# <script src="/application-xxxxxxx.js"></script>
|
146
151
|
# <script src="/application.js"></script>
|
147
152
|
self.copyray_js_injection_regexp_for_precompiled = /<script[^>]+\/application.*\.js[^>]+><\/script>/
|
153
|
+
|
148
154
|
@applied = false
|
149
155
|
end
|
150
156
|
|
@@ -226,7 +232,7 @@ module CopyTunerClient
|
|
226
232
|
end
|
227
233
|
|
228
234
|
@applied = true
|
229
|
-
logger.info "Client #{VERSION} ready"
|
235
|
+
logger.info "Client #{VERSION} ready (s3_download)"
|
230
236
|
logger.info "Environment Info: #{environment_info}"
|
231
237
|
|
232
238
|
unless test?
|
@@ -7,10 +7,13 @@ module CopyTunerClient
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
CopyTunerClient::TranslationLog.clear
|
10
11
|
status, headers, response = @app.call(env)
|
11
12
|
if html_headers?(status, headers) && body = response_body(response)
|
12
|
-
body = append_css
|
13
|
-
body = append_js
|
13
|
+
body = append_css(body)
|
14
|
+
body = append_js(body)
|
15
|
+
body = append_translation_logs(body)
|
16
|
+
body = inject_copy_tuner_bar(body)
|
14
17
|
content_length = body.bytesize.to_s
|
15
18
|
if ActionDispatch::Response === response
|
16
19
|
response.body = [body]
|
@@ -31,11 +34,32 @@ module CopyTunerClient
|
|
31
34
|
ActionController::Base.helpers
|
32
35
|
end
|
33
36
|
|
34
|
-
def
|
37
|
+
def append_translation_logs(html)
|
38
|
+
json = CopyTunerClient::TranslationLog.translations.to_json
|
39
|
+
# Use block to avoid back reference \?
|
40
|
+
html.sub('</body>') { "<div data-copy-tuner-translation-log='#{ERB::Util.html_escape json}' data-copy-tuner-url='#{CopyTunerClient.configuration.project_url}'></div></body>" }
|
41
|
+
end
|
42
|
+
|
43
|
+
def inject_copy_tuner_bar(html)
|
44
|
+
html.sub(/<body[^>]*>/) { "#{$~}\n#{render_copy_tuner_bar}" }
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_copy_tuner_bar
|
48
|
+
if ApplicationController.respond_to?(:render)
|
49
|
+
# Rails 5
|
50
|
+
ApplicationController.render(:partial => "/copy_tuner_bar").html_safe
|
51
|
+
else
|
52
|
+
# Rails <= 4.2
|
53
|
+
ac = ActionController::Base.new
|
54
|
+
ac.render_to_string(:partial => '/copy_tuner_bar').html_safe
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def append_css(html)
|
35
59
|
html.sub(/<body[^>]*>/) { "#{$~}\n#{css_tag}" }
|
36
60
|
end
|
37
61
|
|
38
|
-
def append_js
|
62
|
+
def append_js(html)
|
39
63
|
regexp = if ::Rails.application.config.assets.debug
|
40
64
|
CopyTunerClient.configuration.copyray_js_injection_regexp_for_debug
|
41
65
|
else
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'copy_tuner_client/copyray'
|
2
|
+
require 'copy_tuner_client/translation_log'
|
2
3
|
|
3
4
|
module CopyTunerClient
|
4
5
|
# Connects to integration points for Rails 3 applications
|
@@ -19,6 +20,7 @@ module CopyTunerClient
|
|
19
20
|
if CopyTunerClient.configuration.enable_middleware?
|
20
21
|
alias_method_chain :translate, :copyray_comment
|
21
22
|
alias :t :translate
|
23
|
+
CopyTunerClient::TranslationLog.install_hook
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module CopyTunerClient
|
2
|
+
class TranslationLog
|
3
|
+
def self.translations
|
4
|
+
Thread.current[:translations] ||= {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.clear
|
8
|
+
Thread.current[:translations] = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.add(key, result)
|
12
|
+
translations[key] = result unless translations.key? key
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.install_hook
|
16
|
+
I18n.class_eval do
|
17
|
+
class << self
|
18
|
+
def translate_with_copy_tuner_hook(*args)
|
19
|
+
key = args[0]
|
20
|
+
result = translate_without_copy_tuner_hook(*args)
|
21
|
+
|
22
|
+
if key.is_a?(Array)
|
23
|
+
key.zip(result).each { |k, v| CopyTunerClient::TranslationLog.add(k, v) unless v.is_a?(Array) }
|
24
|
+
else
|
25
|
+
CopyTunerClient::TranslationLog.add(key, result) unless result.is_a?(Array)
|
26
|
+
end
|
27
|
+
result
|
28
|
+
end
|
29
|
+
if CopyTunerClient.configuration.enable_middleware?
|
30
|
+
alias_method_chain :translate, :copy_tuner_hook
|
31
|
+
alias :t :translate
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -4,6 +4,7 @@ describe CopyTunerClient do
|
|
4
4
|
def build_client(config = {})
|
5
5
|
config[:logger] ||= FakeLogger.new
|
6
6
|
default_config = CopyTunerClient::Configuration.new.to_hash
|
7
|
+
default_config[:s3_host] = 'copy-tuner.com'
|
7
8
|
CopyTunerClient::Client.new(default_config.update(config))
|
8
9
|
end
|
9
10
|
|
@@ -33,7 +33,7 @@ describe CopyTunerClient::Configuration do
|
|
33
33
|
it { should have_config_option(:client_version).overridable.default(CopyTunerClient::VERSION) }
|
34
34
|
it { should have_config_option(:client_name).overridable.default('CopyTuner Client') }
|
35
35
|
it { should have_config_option(:client_url).overridable.default('https://rubygems.org/gems/copy_tuner_client') }
|
36
|
-
it { should have_config_option(:secure).overridable.default(
|
36
|
+
it { should have_config_option(:secure).overridable.default(true) }
|
37
37
|
it { should have_config_option(:host).overridable.default('copy-tuner.com') }
|
38
38
|
it { should have_config_option(:http_open_timeout).overridable.default(5) }
|
39
39
|
it { should have_config_option(:http_read_timeout).overridable.default(5) }
|
@@ -190,6 +190,17 @@ describe CopyTunerClient::Configuration do
|
|
190
190
|
prefixed_logger.should be_a(CopyTunerClient::PrefixedLogger)
|
191
191
|
prefixed_logger.original_logger.should == 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
|
+
end
|
193
204
|
end
|
194
205
|
|
195
206
|
shared_examples_for 'applied configuration' do
|
data/spec/spec_helper.rb
CHANGED
@@ -15,7 +15,7 @@ Dir.glob(File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')).each do |file
|
|
15
15
|
end
|
16
16
|
|
17
17
|
WebMock.disable_net_connect!
|
18
|
-
ShamRack.mount FakeCopyTunerApp.new, 'copy-tuner.com',
|
18
|
+
ShamRack.mount FakeCopyTunerApp.new, 'copy-tuner.com', 443
|
19
19
|
|
20
20
|
RSpec.configure do |config|
|
21
21
|
config.include ClientSpecHelpers
|
@@ -43,14 +43,14 @@ class FakeCopyTunerApp < Sinatra::Base
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
get '/api/v2/projects/:api_key/published_blurbs' do |api_key|
|
46
|
+
get '/api/v2/projects/:api_key/published_blurbs.json' do |api_key|
|
47
47
|
with_project(api_key) do |project|
|
48
48
|
etag project.etag
|
49
49
|
project.published.to_json
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
get '/api/v2/projects/:api_key/draft_blurbs' do |api_key|
|
53
|
+
get '/api/v2/projects/:api_key/draft_blurbs.json' do |api_key|
|
54
54
|
with_project(api_key) do |project|
|
55
55
|
etag project.etag
|
56
56
|
project.draft.to_json
|
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
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 4.2.6
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 4.2.6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,20 +220,6 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: turn
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
223
|
description:
|
238
224
|
email: info@sonicgarden.jp
|
239
225
|
executables: []
|
@@ -245,19 +231,20 @@ files:
|
|
245
231
|
- ".ruby-version"
|
246
232
|
- ".travis.yml"
|
247
233
|
- Appraisals
|
234
|
+
- CHANGELOG.md
|
248
235
|
- Gemfile
|
249
236
|
- Gemfile.lock
|
250
237
|
- README.md
|
251
238
|
- Rakefile
|
252
239
|
- app/assets/javascripts/copyray.js.coffee
|
253
240
|
- app/assets/stylesheets/copyray.css
|
241
|
+
- app/views/_copy_tuner_bar.html.erb
|
254
242
|
- copy_tuner_client.gemspec
|
255
243
|
- features/rails.feature
|
256
244
|
- features/step_definitions/copycopter_server_steps.rb
|
257
245
|
- features/step_definitions/rails_steps.rb
|
258
246
|
- features/support/env.rb
|
259
247
|
- features/support/rails_server.rb
|
260
|
-
- gemfiles/3.2.gemfile
|
261
248
|
- gemfiles/4.0.gemfile
|
262
249
|
- gemfiles/4.1.gemfile
|
263
250
|
- gemfiles/4.2.gemfile
|
@@ -277,6 +264,7 @@ files:
|
|
277
264
|
- lib/copy_tuner_client/rails.rb
|
278
265
|
- lib/copy_tuner_client/request_sync.rb
|
279
266
|
- lib/copy_tuner_client/simple_form_extention.rb
|
267
|
+
- lib/copy_tuner_client/translation_log.rb
|
280
268
|
- lib/copy_tuner_client/version.rb
|
281
269
|
- lib/tasks/copy_tuner_client_tasks.rake
|
282
270
|
- spec/copy_tuner_client/cache_spec.rb
|