wovnrb 3.1.0 → 3.2.0

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
  SHA256:
3
- metadata.gz: 4d23f8ac05cb8fbefe04b2c8ae96f9932b280762e2491c80552bd20314d17e6d
4
- data.tar.gz: 44118f0db0276085f492b631eeba2af8fe349f6b9d7ef96627590dda63793d80
3
+ metadata.gz: b81d287414c2bec2a702a64f26f3bb7d17af912b558e420f5483b1adea3319e7
4
+ data.tar.gz: 638c81c1d8935753526b11a0a5d36b4d661fbb9cc7739054b121e66f6000c142
5
5
  SHA512:
6
- metadata.gz: a71cbbd14782608c0c445d146bc262d5dfcf6bd7fca9cbfb467aad6f62caf9f979a98ae29a3e0fee38d77202217960b39e5ac9755975ba1fbd5e3899d5d7e69b
7
- data.tar.gz: 9576ec7bd9d7053be56a116286ee9fe45df7a1f0c9e826dc114b0c77963d5e7c4ae53245655269fa8287cb45aa2ea0e56fdeecdf4cb81e4ce397d7f5595c31ef
6
+ metadata.gz: f801b9ea2a61e7b1a0192d521ffcaac701262b277e732ab618aadc5fcfb41a2d812493a7e42c326726884a5b811d61763dbb5db9bc9c7bf6f7d6e47bcbfd52c1
7
+ data.tar.gz: f5ae170d54ac362dd74710ef05660e00f914f1cca8b1b13aeb0177478bd5d89fe472b4735df26cfd95ff854c88198f6e698c1ea33772734c52f3403af3ecbe75
@@ -53,4 +53,4 @@ end
53
53
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
54
54
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
55
55
 
56
- gem 'wovnrb', path: './wovnrb'
56
+ gem 'wovnrb', path: './wovnrb'
@@ -5,6 +5,7 @@ rm /usr/local/bin/bundle
5
5
  rm /usr/local/bin/bundler
6
6
  gem install bundler:2.1.4
7
7
  update --bundler
8
+ bundle update
8
9
  bundle install
9
10
  apt update
10
11
  apt install npm -y
@@ -5,9 +5,10 @@ require 'zlib'
5
5
 
6
6
  module Wovnrb
7
7
  class ApiTranslator
8
- def initialize(store, headers)
8
+ def initialize(store, headers, uuid)
9
9
  @store = store
10
10
  @headers = headers
11
+ @uuid = uuid
11
12
  end
12
13
 
13
14
  def translate(body)
@@ -55,7 +56,8 @@ module Wovnrb
55
56
  headers = {
56
57
  'Accept-Encoding' => 'gzip',
57
58
  'Content-Type' => 'application/octet-stream',
58
- 'Content-Length' => data.bytesize.to_s
59
+ 'Content-Length' => data.bytesize.to_s,
60
+ 'X-Request-Id' => @uuid
59
61
  }
60
62
  request = Net::HTTP::Post.new(generate_request_path(body), headers)
61
63
 
@@ -3,15 +3,22 @@ require 'logger' unless defined?(Logger)
3
3
 
4
4
  module Wovnrb
5
5
  class WovnLogger
6
+ attr_reader :uuid
7
+
6
8
  include Singleton
7
9
 
8
10
  class << self
9
11
  def error(message)
10
12
  instance.error(message)
11
13
  end
14
+
15
+ def uuid
16
+ instance.uuid
17
+ end
12
18
  end
13
19
 
14
20
  def initialize
21
+ @uuid = SecureRandom.uuid
15
22
  path = Store.instance.settings['log_path']
16
23
  if path
17
24
  begin
@@ -40,9 +47,9 @@ module Wovnrb
40
47
 
41
48
  def error(message)
42
49
  if @logger == $stderr
43
- @logger.puts "Wovnrb Error: #{message}"
50
+ @logger.puts "[#{@uuid}] Wovnrb Error: #{message}"
44
51
  else
45
- @logger.error message
52
+ @logger.error "[#{@uuid}] #{message}"
46
53
  end
47
54
  end
48
55
  end
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
data/lib/wovnrb.rb CHANGED
@@ -80,7 +80,7 @@ module Wovnrb
80
80
 
81
81
  if needs_api?(html_body, headers)
82
82
  converted_html, marker = html_converter.build_api_compatible_html
83
- translated_content = ApiTranslator.new(@store, headers).translate(converted_html)
83
+ translated_content = ApiTranslator.new(@store, headers, WovnLogger.uuid).translate(converted_html)
84
84
  translated_body.push(marker.revert(translated_content))
85
85
  else
86
86
  string_body = html_converter.build if html_body.html?
@@ -53,7 +53,7 @@ module Wovnrb
53
53
  Wovnrb.get_env('url' => 'http://fr.wovn.io/test'),
54
54
  Wovnrb.get_settings(settings)
55
55
  )
56
- api_translator = ApiTranslator.new(store, headers)
56
+ api_translator = ApiTranslator.new(store, headers, 'ABCD')
57
57
  translation_request_stub = stub_translation_api_request(store, headers, original_html, translated_html, response)
58
58
 
59
59
  actual_translated_html = api_translator.translate(original_html)
@@ -31,9 +31,11 @@ module Wovnrb
31
31
  end
32
32
 
33
33
  def test_error
34
- mock = LogMock.mock_log
35
- WovnLogger.instance.error('aaa')
36
- assert_equal(['aaa'], mock.errors)
34
+ SecureRandom.stub(:uuid, 'a') do
35
+ mock = LogMock.mock_log
36
+ WovnLogger.instance.error('aaa')
37
+ assert_equal(['[a] aaa'], mock.errors)
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -78,12 +78,14 @@ module Wovnrb
78
78
  end
79
79
 
80
80
  def test_invalid_settings
81
- mock = LogMock.mock_log
82
- store = Wovnrb::Store.instance
83
- valid = store.valid_settings?
81
+ SecureRandom.stub(:uuid, 'a') do
82
+ mock = LogMock.mock_log
83
+ store = Wovnrb::Store.instance
84
+ valid = store.valid_settings?
84
85
 
85
- assert_equal(false, valid)
86
- assert_equal(['Project token is not valid.'], mock.errors)
86
+ assert_equal(false, valid)
87
+ assert_equal(['[a] Project token is not valid.'], mock.errors)
88
+ end
87
89
  end
88
90
 
89
91
  def test_settings_ignore_paths
@@ -110,12 +112,14 @@ module Wovnrb
110
112
  end
111
113
 
112
114
  def test_settings_invalid_ignore_paths
113
- mock = LogMock.mock_log
114
- store = Wovnrb::Store.instance
115
- store.update_settings('ignore_paths' => 'aaaa')
116
-
117
- assert_equal(false, store.valid_settings?)
118
- assert_equal(['Project token is not valid.', 'Ignore Paths aaaa should be Array.'], mock.errors)
115
+ SecureRandom.stub(:uuid, 'a') do
116
+ mock = LogMock.mock_log
117
+ store = Wovnrb::Store.instance
118
+ store.update_settings('ignore_paths' => 'aaaa')
119
+
120
+ assert_equal(false, store.valid_settings?)
121
+ assert_equal(['[a] Project token is not valid.', '[a] Ignore Paths aaaa should be Array.'], mock.errors)
122
+ end
119
123
  end
120
124
 
121
125
  def test_settings_ignore_glob_injection
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wovnrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wovn Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -567,7 +567,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
567
567
  - !ruby/object:Gem::Version
568
568
  version: '0'
569
569
  requirements: []
570
- rubygems_version: 3.1.4
570
+ rubygems_version: 3.0.3
571
571
  signing_key:
572
572
  specification_version: 4
573
573
  summary: Gem for WOVN.io