station 0.0.96 → 0.0.103

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +6 -5
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/bin/nexmo-developer +1 -44
  6. data/lib/nexmo_developer/.rubocop.yml +3 -0
  7. data/lib/nexmo_developer/.ruby-version +1 -1
  8. data/lib/nexmo_developer/Dockerfile +1 -1
  9. data/lib/nexmo_developer/Gemfile +5 -5
  10. data/lib/nexmo_developer/Gemfile.lock +20 -20
  11. data/lib/nexmo_developer/Guardfile +2 -2
  12. data/lib/nexmo_developer/app/controllers/dashboard_controller.rb +1 -1
  13. data/lib/nexmo_developer/app/presenters/sidenav_item.rb +2 -2
  14. data/lib/nexmo_developer/app/presenters/tutorial_list_item.rb +3 -3
  15. data/lib/nexmo_developer/app/services/translator/file_translator.rb +18 -12
  16. data/lib/nexmo_developer/app/services/translator/smartling/api/upload_file.rb +4 -2
  17. data/lib/nexmo_developer/app/services/translator/translation_request.rb +3 -2
  18. data/lib/nexmo_developer/app/services/translator/utils.rb +28 -1
  19. data/lib/nexmo_developer/app/views/contribute/guides/markdown-guide.md +70 -48
  20. data/lib/nexmo_developer/app/views/tutorial/list.html.erb +1 -1
  21. data/lib/nexmo_developer/app/views/use_case/_index.html.erb +1 -1
  22. data/lib/nexmo_developer/app/webpacker/javascript/volta/volta.js +108 -21
  23. data/lib/nexmo_developer/app/webpacker/stylesheets/application.scss +1 -1
  24. data/lib/nexmo_developer/app/webpacker/stylesheets/layout/_api.scss +1 -0
  25. data/lib/nexmo_developer/app/webpacker/stylesheets/objects/_use_cases.scss +1 -1
  26. data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
  27. data/lib/nexmo_developer/nexmo_developer.rb +44 -0
  28. data/lib/nexmo_developer/version.rb +1 -1
  29. data/package.json +14 -14
  30. data/station.gemspec +5 -5
  31. data/yarn.lock +372 -290
  32. metadata +38 -156
  33. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css +0 -14950
  34. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css.map +0 -1
  35. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css +0 -15085
  36. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css.map +0 -1
  37. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css +0 -13
  38. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css.map +0 -1
  39. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css +0 -13
  40. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css.map +0 -1
  41. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js +0 -59763
  42. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js.map +0 -1
  43. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js +0 -6405
  44. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js.map +0 -1
  45. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js +0 -7839
  46. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js.map +0 -1
  47. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js +0 -6405
  48. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js.map +0 -1
  49. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js +0 -6619
  50. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js.map +0 -1
  51. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js +0 -6405
  52. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js.map +0 -1
  53. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js +0 -155
  54. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js.map +0 -1
  55. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js +0 -61849
  56. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js.map +0 -1
  57. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js +0 -59077
  58. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js.map +0 -1
  59. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js +0 -61843
  60. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js.map +0 -1
  61. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js +0 -62431
  62. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js.map +0 -1
  63. data/lib/nexmo_developer/public/packs-test/manifest.json +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a6afa3f7d7c40dc3822c7a5fab7c29a04ebb8f681055a4718a453fd0eea5ee5
4
- data.tar.gz: 7b46e9ddd4841aae9a87637a2686757d71fb0c07ed2d3c502803785ac4702d8a
3
+ metadata.gz: 83274e9df9e58a2f14ad94ec74c5de0e94d0742d4d4766c816b16d380c2004fd
4
+ data.tar.gz: c190e452b0a4d33f4398233e970c1c014831683e973883ad16e4cc6454a7d74e
5
5
  SHA512:
6
- metadata.gz: 5f20dba8010c8b024bcec15521b467a54635b4b3966182b29c995581db099fc70b448b439b8f1330df30886a16466e3711ff86e2db294f6b0b7257d7b7811f9e
7
- data.tar.gz: c4b374a0246a0f932586e2d61ba1fc0c45c50427d04a76d7e9d4b10efc81454cdafb9f0eb90860f7b2e0fff196416d19bb7c72f66352102ef95c26f0d8e00202
6
+ metadata.gz: 6595905dc9ef4194076d6e83e53bd6eb61ca1ed6d9dda1631c83681cc76803c2b85753a4612974995da1fb33cc3b6d9051567aefddd90381f7f7c8b9cbc0467b
7
+ data.tar.gz: 65bc330edcbd32286fcc85ab8614ced827418852380aa21a44b0286f8b565db310ca9feb72f1b525297f56e38c731f56ee3f12a3e65f581a73e9749f49d5194d
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.5.8-alpine AS build-env
1
+ FROM ruby:2.7.2-alpine AS build-env
2
2
  ARG RAILS_ROOT=/station
3
3
  ARG BUILD_PACKAGES="build-base curl-dev git"
4
4
  ARG DEV_PACKAGES="postgresql-dev yaml-dev zlib-dev nodejs yarn"
@@ -19,11 +19,12 @@ COPY lib/nexmo_developer/Gemfile* package.json yarn.lock $RAILS_ROOT/
19
19
  RUN bundle config --global frozen 1 \
20
20
  && gem update --system \
21
21
  && gem install bundler
22
+
22
23
  RUN bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle \
23
24
  # Remove unneeded files (cached *.gem, *.o, *.c)
24
- && rm -rf vendor/bundle/ruby/2.5.0/cache/*.gem \
25
- && find vendor/bundle/ruby/2.5.0/gems/ -name "*.c" -delete \
26
- && find vendor/bundle/ruby/2.5.0/gems/ -name "*.o" -delete
25
+ && rm -rf vendor/bundle/ruby/2.7.0/cache/*.gem \
26
+ && find vendor/bundle/ruby/2.7.0/gems/ -name "*.c" -delete \
27
+ && find vendor/bundle/ruby/2.7.0/gems/ -name "*.o" -delete
27
28
 
28
29
  # Install node dependencies
29
30
  RUN yarn install --frozen-lockfile
@@ -36,7 +37,7 @@ RUN bundle exec rake assets:precompile
36
37
  RUN rm -rf node_modules tmp/cache vendor/assets spec
37
38
 
38
39
  ################ Build step done ###############
39
- FROM ruby:2.5.8-alpine
40
+ FROM ruby:2.7.2-alpine
40
41
  ARG RAILS_ROOT=/station
41
42
 
42
43
  ENV RACK_ENV production
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.5.8'
2
+ ruby '2.7.2'
@@ -8,7 +8,7 @@ PLATFORMS
8
8
  DEPENDENCIES
9
9
 
10
10
  RUBY VERSION
11
- ruby 2.5.8p224
11
+ ruby 2.7.2p137
12
12
 
13
13
  BUNDLED WITH
14
14
  2.1.4
@@ -44,50 +44,7 @@ end.parse!
44
44
  $LOAD_PATH.unshift(File.expand_path('../lib/nexmo_developer', __dir__))
45
45
  APP_PATH = File.expand_path('../lib/nexmo_developer/config/application', __dir__)
46
46
 
47
- require 'rails/all'
48
- require 'activeadmin'
49
- require 'bootsnap'
50
- require 'bugsnag'
51
- require 'devise'
52
- require 'geocoder'
53
- require 'gravatar_image_tag'
54
- require 'greenhouse_io'
55
- require 'recaptcha'
56
- require 'split/dashboard'
57
- require 'listen'
58
- require 'inherited_resources'
59
- require 'msgpack'
60
- require 'pg'
61
- require 'coffee-rails'
62
- require 'octokit'
63
- require 'webpacker'
64
- require 'clipboard/rails'
65
- require 'gmaps4rails'
66
- require 'nexmo_markdown_renderer'
67
- require 'truncato'
68
- require 'puma'
69
- require 'barnes'
70
- require 'woothee'
71
- require 'algoliasearch'
72
- require 'rest-client'
73
- require 'chartkick'
74
- require 'groupdate'
75
- require 'terminal-table'
76
- require 'lograge'
77
- require 'jbuilder'
78
- require 'nokogiri'
79
- require 'colorize'
80
- require 'neatjson'
81
- require 'slack-notifier'
82
- require 'autoprefixer-rails'
83
- require 'titleize'
84
- require 'countries'
85
- require 'country_select'
86
- require 'smartling'
87
- require 'newrelic_rpm'
88
- require 'redis'
89
- require 'rake'
90
-
47
+ require_relative '../lib/nexmo_developer/nexmo_developer'
91
48
  require 'config/application'
92
49
  require 'rails/command'
93
50
 
@@ -271,3 +271,6 @@ Rails/SquishedSQLHeredocs:
271
271
 
272
272
  Rails/WhereNot:
273
273
  Enabled: true
274
+
275
+ Lint/DuplicateBranch:
276
+ Enabled: false
@@ -1 +1 @@
1
- 2.5.8
1
+ 2.7.2
@@ -1,5 +1,5 @@
1
1
  # Base image:
2
- FROM ruby:2.5.8
2
+ FROM ruby:2.7.2
3
3
 
4
4
  # Install dependencies
5
5
  RUN apt-get update -qq && apt-get install -y build-essential libpq-dev lsof
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.5.8'
2
+ ruby '2.7.2'
3
3
 
4
4
  git_source(:github) do |repo_name|
5
5
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
@@ -74,7 +74,7 @@ gem 'icalendar', require: false
74
74
  gem 'neatjson'
75
75
 
76
76
  # Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.
77
- gem 'faker', '2.14.0', require: false
77
+ gem 'faker', '2.15.1', require: false
78
78
 
79
79
  # factory_girl_rails provides integration between factory_girl and rails 3 or newer (currently just automatic factory definition loading)
80
80
  gem 'factory_bot_rails', '6.1.0', require: false
@@ -110,7 +110,7 @@ gem 'bootsnap', require: false
110
110
  gem 'diffy', require: false
111
111
 
112
112
  # Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
113
- gem 'rubocop', '~> 1.2.0', require: false
113
+ gem 'rubocop', '~> 1.4.2', require: false
114
114
  gem 'rubocop-rails', '~> 2.8', require: false
115
115
 
116
116
  # Volta needs a CSS autoprefixer
@@ -129,9 +129,9 @@ gem 'lograge'
129
129
  gem 'countries'
130
130
  gem 'country_select', '~> 4.0'
131
131
 
132
- gem 'nexmo-oas-renderer', '~> 2.4.0', require: false
132
+ gem 'nexmo-oas-renderer', '~> 2.4.1', require: false
133
133
 
134
- gem 'nexmo_markdown_renderer', '~> 0.5'
134
+ gem 'nexmo_markdown_renderer', '~> 0.7'
135
135
 
136
136
  gem 'smartling'
137
137
 
@@ -93,7 +93,7 @@ GEM
93
93
  activesupport (>= 3.0.0, < 6.1)
94
94
  ruby2_keywords (>= 0.0.2, < 1.0)
95
95
  ast (2.4.1)
96
- autoprefixer-rails (10.0.2.0)
96
+ autoprefixer-rails (10.0.3.0)
97
97
  execjs
98
98
  awesome_print (1.8.0)
99
99
  banzai (0.1.3)
@@ -114,7 +114,7 @@ GEM
114
114
  concurrent-ruby (~> 1.0)
115
115
  builder (3.2.4)
116
116
  byebug (11.1.3)
117
- capybara (3.33.0)
117
+ capybara (3.34.0)
118
118
  addressable
119
119
  mini_mime (>= 0.1.3)
120
120
  nokogiri (~> 1.8)
@@ -163,7 +163,7 @@ GEM
163
163
  em-websocket (0.5.2)
164
164
  eventmachine (>= 0.12.9)
165
165
  http_parser.rb (~> 0.6.0)
166
- erubi (1.9.0)
166
+ erubi (1.10.0)
167
167
  eventmachine (1.2.7)
168
168
  execjs (2.7.0)
169
169
  factory_bot (6.1.0)
@@ -171,7 +171,7 @@ GEM
171
171
  factory_bot_rails (6.1.0)
172
172
  factory_bot (~> 6.1.0)
173
173
  railties (>= 5.0.0)
174
- faker (2.14.0)
174
+ faker (2.15.1)
175
175
  i18n (>= 1.6, < 2)
176
176
  faraday (1.1.0)
177
177
  multipart-post (>= 1.2, < 3)
@@ -258,7 +258,7 @@ GEM
258
258
  activerecord
259
259
  kaminari-core (= 1.2.1)
260
260
  kaminari-core (1.2.1)
261
- listen (3.3.0)
261
+ listen (3.3.1)
262
262
  rb-fsevent (~> 0.10, >= 0.10.3)
263
263
  rb-inotify (~> 0.9, >= 0.9.10)
264
264
  lograge (0.11.2)
@@ -266,7 +266,7 @@ GEM
266
266
  activesupport (>= 4)
267
267
  railties (>= 4)
268
268
  request_store (~> 1.0)
269
- loofah (2.7.0)
269
+ loofah (2.8.0)
270
270
  crass (~> 1.0.2)
271
271
  nokogiri (>= 1.5.9)
272
272
  lumberjack (1.2.8)
@@ -294,8 +294,8 @@ GEM
294
294
  neatjson (0.9)
295
295
  nenv (0.3.0)
296
296
  netrc (0.11.0)
297
- newrelic_rpm (6.13.1)
298
- nexmo-oas-renderer (2.4.0)
297
+ newrelic_rpm (6.14.0)
298
+ nexmo-oas-renderer (2.4.1)
299
299
  activemodel (~> 6.0)
300
300
  activesupport (~> 6.0)
301
301
  banzai (~> 0.1.2)
@@ -308,7 +308,7 @@ GEM
308
308
  sass (~> 3.1)
309
309
  shotgun (~> 0.9)
310
310
  sinatra (~> 2.0)
311
- nexmo_markdown_renderer (0.5.0)
311
+ nexmo_markdown_renderer (0.7.0)
312
312
  activemodel (~> 6.0)
313
313
  banzai (~> 0.1.2)
314
314
  i18n (~> 1.7)
@@ -340,7 +340,7 @@ GEM
340
340
  sawyer (~> 0.8.0, >= 0.5.3)
341
341
  oj (3.10.15)
342
342
  orm_adapter (0.5.0)
343
- parallel (1.19.2)
343
+ parallel (1.20.1)
344
344
  parser (2.7.2.0)
345
345
  ast (~> 2.4.1)
346
346
  pg (1.2.3)
@@ -398,7 +398,7 @@ GEM
398
398
  recaptcha (5.6.0)
399
399
  json
400
400
  redcarpet (3.4.0)
401
- redis (4.2.2)
401
+ redis (4.2.5)
402
402
  regexp_parser (1.8.2)
403
403
  request_store (1.5.0)
404
404
  rack (>= 1.4)
@@ -437,16 +437,16 @@ GEM
437
437
  rspec-snapshot (0.1.2)
438
438
  rspec (> 3.0.0)
439
439
  rspec-support (3.10.0)
440
- rubocop (1.2.0)
440
+ rubocop (1.4.2)
441
441
  parallel (~> 1.10)
442
442
  parser (>= 2.7.1.5)
443
443
  rainbow (>= 2.2.2, < 4.0)
444
444
  regexp_parser (>= 1.8)
445
445
  rexml
446
- rubocop-ast (>= 1.0.1)
446
+ rubocop-ast (>= 1.1.1)
447
447
  ruby-progressbar (~> 1.7)
448
448
  unicode-display_width (>= 1.4.0, < 2.0)
449
- rubocop-ast (1.1.1)
449
+ rubocop-ast (1.2.0)
450
450
  parser (>= 2.7.1.5)
451
451
  rubocop-rails (2.8.1)
452
452
  activesupport (>= 4.2.0)
@@ -529,7 +529,7 @@ GEM
529
529
  activemodel (>= 6.0.0)
530
530
  bindex (>= 0.4.0)
531
531
  railties (>= 6.0.0)
532
- webmock (3.9.5)
532
+ webmock (3.10.0)
533
533
  addressable (>= 2.3.6)
534
534
  crack (>= 0.3.2)
535
535
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -573,7 +573,7 @@ DEPENDENCIES
573
573
  diffy
574
574
  dotenv-rails
575
575
  factory_bot_rails (= 6.1.0)
576
- faker (= 2.14.0)
576
+ faker (= 2.15.1)
577
577
  ffi (>= 1.9.24)
578
578
  geocoder
579
579
  gmaps4rails
@@ -589,8 +589,8 @@ DEPENDENCIES
589
589
  lograge
590
590
  neatjson
591
591
  newrelic_rpm
592
- nexmo-oas-renderer (~> 2.4.0)
593
- nexmo_markdown_renderer (~> 0.5)
592
+ nexmo-oas-renderer (~> 2.4.1)
593
+ nexmo_markdown_renderer (~> 0.7)
594
594
  nokogiri (~> 1.10.9)
595
595
  octokit
596
596
  pg (~> 1.2)
@@ -605,7 +605,7 @@ DEPENDENCIES
605
605
  rspec-collection_matchers
606
606
  rspec-rails (~> 4.0)
607
607
  rspec-snapshot (~> 0.1.2)
608
- rubocop (~> 1.2.0)
608
+ rubocop (~> 1.4.2)
609
609
  rubocop-rails (~> 2.8)
610
610
  ruby-progressbar
611
611
  sassc-rails (~> 2.1)
@@ -624,7 +624,7 @@ DEPENDENCIES
624
624
  woothee
625
625
 
626
626
  RUBY VERSION
627
- ruby 2.5.8p224
627
+ ruby 2.7.2p137
628
628
 
629
629
  BUNDLED WITH
630
630
  2.1.4
@@ -5,7 +5,7 @@
5
5
  # directories %w(app lib config test spec features) \
6
6
  # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
7
 
8
- ## Note: if you are using the `directories` clause above and you are not
8
+ ## NOTE: if you are using the `directories` clause above and you are not
9
9
  ## watching the project directory ('.'), then you will want to move
10
10
  ## the Guardfile to a watched dir and symlink it back, e.g.
11
11
  #
@@ -54,7 +54,7 @@ guard 'livereload' do
54
54
  watch(%r{config/locales/.+\.yml})
55
55
  end
56
56
 
57
- # Note: The cmd option is now required due to the increasing number of ways
57
+ # NOTE: The cmd option is now required due to the increasing number of ways
58
58
  # rspec may be run, below are examples of the most common uses.
59
59
  # * bundler: 'bundle exec rspec'
60
60
  # * bundler binstubs: 'bin/rspec'
@@ -197,7 +197,7 @@ class DashboardController < ApplicationController
197
197
 
198
198
  parts.insert(1, 'top-level') if parts.count < 3
199
199
 
200
- parts = [parts[0], parts[1], parts[2..-1].join('/')] if parts.count > 3
200
+ parts = [parts[0], parts[1], parts[2..].join('/')] if parts.count > 3
201
201
  next if parts[0] == 'migrate'
202
202
 
203
203
  x = @complete_coverage
@@ -38,8 +38,8 @@ class SidenavItem
38
38
 
39
39
  def css_classes
40
40
  classes = ['Nxd-sidenav-badge Vlt-badge Vlt-badge--margin-left Vlt-badge--small']
41
- classes << 'Vlt-bg-green-lighter Vlt-green' if label.casecmp('beta').zero?
42
- classes << 'Vlt-bg-blue-lighter Vlt-blue' if label.casecmp('dev preview').zero?
41
+ classes << 'Vlt-badge--transparent Vlt-badge--green' if label.casecmp('beta').zero?
42
+ classes << 'Vlt-badge--transparent Vlt-badge--blue' if label.casecmp('dev preview').zero?
43
43
 
44
44
  classes.join(' ')
45
45
  end
@@ -62,11 +62,11 @@ class TutorialListItem
62
62
  end
63
63
 
64
64
  def product_url
65
- "/#{I18n.locale}/#{products.join('')}/tutorials"
65
+ "/#{I18n.locale}/#{products.join}/tutorials"
66
66
  end
67
67
 
68
68
  def url
69
- external_link || "/#{I18n.locale}/#{products.join('')}/tutorials/#{filename}/#{first_step}"
69
+ external_link || "/#{I18n.locale}/#{products.join}/tutorials/#{filename}/#{first_step}"
70
70
  end
71
71
 
72
72
  def available_languages
@@ -74,7 +74,7 @@ class TutorialListItem
74
74
  OpenStruct.new(
75
75
  language: language,
76
76
  label: Nexmo::Markdown::CodeLanguage.find(language).label,
77
- url: external_link || "/#{products.join('')}/tutorials/#{filename}/#{first_step}/#{language}"
77
+ url: external_link || "/#{products.join}/tutorials/#{filename}/#{first_step}/#{language}"
78
78
  )
79
79
  end
80
80
  end
@@ -1,5 +1,7 @@
1
1
  module Translator
2
2
  class FileTranslator
3
+ include Utils
4
+
3
5
  attr_reader :doc_path
4
6
 
5
7
  def initialize(doc_path)
@@ -12,41 +14,45 @@ module Translator
12
14
  Translator::TranslationRequest.new(
13
15
  locale: locale_with_region(locale),
14
16
  frequency: frequency,
15
- file_uri: doc_path
17
+ file_uri: uri,
18
+ file_path: full_path
16
19
  )
17
20
  end
18
21
  end
19
22
  end
20
23
 
24
+ def uri
25
+ @uri ||= file_uri(doc_path)
26
+ end
27
+
21
28
  def frontmatter
22
29
  @frontmatter ||= YAML.safe_load(File.read(full_path))
23
30
  end
24
31
 
25
32
  def full_path
26
- @full_path ||= "#{Rails.configuration.docs_base_path}/_documentation/en/#{doc_path}"
33
+ @full_path ||= "#{Rails.configuration.docs_base_path}/#{doc_path}"
27
34
  end
28
35
 
29
36
  def frequency
30
37
  @frequency ||= frontmatter['translation_frequency'] || product_translation_frequency
31
38
  end
32
39
 
33
- def locale_with_region(locale)
34
- case locale.to_s
35
- when 'ja', 'ja-JP'
36
- 'ja-JP'
37
- when 'cn', 'zh-CN'
38
- 'zh-CN'
39
- else
40
- locale.to_s
40
+ def product_from_path
41
+ @product_from_path ||= begin
42
+ Pathname.new(
43
+ doc_path.gsub(%r{(_documentation|_tutorials|_use_cases)/#{I18n.default_locale}/}, '')
44
+ ).dirname.to_s
41
45
  end
42
46
  end
43
47
 
44
48
  def product
45
49
  @product ||= begin
46
50
  products = YAML.safe_load(File.open("#{Rails.configuration.docs_base_path}/config/products.yml"))
47
- product = products['products'].detect { |p| doc_path.starts_with? p['path'] }
51
+ product = products['products'].detect do |p|
52
+ product_from_path.starts_with?(p['path']) || frontmatter['products']&.include?(p['path'])
53
+ end
48
54
 
49
- raise ArgumentError, 'Unable to match document with products list in config/products.yml' unless product
55
+ raise ArgumentError, "Unable to match document with products list in config/products.yml for #{full_path}" unless product
50
56
 
51
57
  product
52
58
  end
@@ -53,8 +53,10 @@ module Translator
53
53
  def file
54
54
  @file ||= begin
55
55
  file = Tempfile.new
56
- file.write Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
57
- File.read("#{Rails.configuration.docs_base_path}/_documentation/#{I18n.default_locale}/#{@translation_request.file_uri}")
56
+ file.write(
57
+ Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
58
+ File.read(@translation_request.file_path)
59
+ )
58
60
  )
59
61
  file.rewind
60
62
  file.close