lingodotdev 0.1.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 +7 -0
- data/.env.example +1 -0
- data/.github/workflows/publish.yml +63 -0
- data/README.md +485 -0
- data/Rakefile +4 -0
- data/lib/lingodotdev/version.rb +8 -0
- data/lib/lingodotdev.rb +938 -0
- data/sig/sdk/ruby.rbs +6 -0
- data/spec/lingo_dot_dev/configuration_spec.rb +146 -0
- data/spec/lingo_dot_dev/engine_spec.rb +688 -0
- data/spec/spec_helper.rb +36 -0
- metadata +112 -0
data/sig/sdk/ruby.rbs
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe LingoDotDev::Configuration do
|
|
6
|
+
describe 'initialization' do
|
|
7
|
+
it 'creates a configuration with valid api_key' do
|
|
8
|
+
config = described_class.new(api_key: 'test-key')
|
|
9
|
+
expect(config.api_key).to eq('test-key')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'uses default api_url' do
|
|
13
|
+
config = described_class.new(api_key: 'test-key')
|
|
14
|
+
expect(config.api_url).to eq('https://engine.lingo.dev')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'uses default batch_size' do
|
|
18
|
+
config = described_class.new(api_key: 'test-key')
|
|
19
|
+
expect(config.batch_size).to eq(25)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'uses default ideal_batch_item_size' do
|
|
23
|
+
config = described_class.new(api_key: 'test-key')
|
|
24
|
+
expect(config.ideal_batch_item_size).to eq(250)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'allows customizing api_url' do
|
|
28
|
+
config = described_class.new(
|
|
29
|
+
api_key: 'test-key',
|
|
30
|
+
api_url: 'https://custom.example.com'
|
|
31
|
+
)
|
|
32
|
+
expect(config.api_url).to eq('https://custom.example.com')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'allows customizing batch_size' do
|
|
36
|
+
config = described_class.new(
|
|
37
|
+
api_key: 'test-key',
|
|
38
|
+
batch_size: 50
|
|
39
|
+
)
|
|
40
|
+
expect(config.batch_size).to eq(50)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'allows customizing ideal_batch_item_size' do
|
|
44
|
+
config = described_class.new(
|
|
45
|
+
api_key: 'test-key',
|
|
46
|
+
ideal_batch_item_size: 500
|
|
47
|
+
)
|
|
48
|
+
expect(config.ideal_batch_item_size).to eq(500)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'validation' do
|
|
53
|
+
it 'raises ValidationError when api_key is nil' do
|
|
54
|
+
expect {
|
|
55
|
+
described_class.new(api_key: nil)
|
|
56
|
+
}.to raise_error(LingoDotDev::ValidationError, /API key is required/)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'raises ValidationError when api_key is empty' do
|
|
60
|
+
expect {
|
|
61
|
+
described_class.new(api_key: '')
|
|
62
|
+
}.to raise_error(LingoDotDev::ValidationError, /API key is required/)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'raises ValidationError when api_url does not start with http/https' do
|
|
66
|
+
expect {
|
|
67
|
+
described_class.new(
|
|
68
|
+
api_key: 'test-key',
|
|
69
|
+
api_url: 'ftp://example.com'
|
|
70
|
+
)
|
|
71
|
+
}.to raise_error(LingoDotDev::ValidationError, /valid HTTP\/HTTPS URL/)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'raises ValidationError when batch_size is less than 1' do
|
|
75
|
+
expect {
|
|
76
|
+
described_class.new(
|
|
77
|
+
api_key: 'test-key',
|
|
78
|
+
batch_size: 0
|
|
79
|
+
)
|
|
80
|
+
}.to raise_error(LingoDotDev::ValidationError, /between 1 and 250/)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'raises ValidationError when batch_size is greater than 250' do
|
|
84
|
+
expect {
|
|
85
|
+
described_class.new(
|
|
86
|
+
api_key: 'test-key',
|
|
87
|
+
batch_size: 251
|
|
88
|
+
)
|
|
89
|
+
}.to raise_error(LingoDotDev::ValidationError, /between 1 and 250/)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'raises ValidationError when ideal_batch_item_size is less than 1' do
|
|
93
|
+
expect {
|
|
94
|
+
described_class.new(
|
|
95
|
+
api_key: 'test-key',
|
|
96
|
+
ideal_batch_item_size: 0
|
|
97
|
+
)
|
|
98
|
+
}.to raise_error(LingoDotDev::ValidationError, /between 1 and 2500/)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'raises ValidationError when ideal_batch_item_size is greater than 2500' do
|
|
102
|
+
expect {
|
|
103
|
+
described_class.new(
|
|
104
|
+
api_key: 'test-key',
|
|
105
|
+
ideal_batch_item_size: 2501
|
|
106
|
+
)
|
|
107
|
+
}.to raise_error(LingoDotDev::ValidationError, /between 1 and 2500/)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'accepts valid batch_size and ideal_batch_item_size values' do
|
|
111
|
+
config = described_class.new(
|
|
112
|
+
api_key: 'test-key',
|
|
113
|
+
batch_size: 100,
|
|
114
|
+
ideal_batch_item_size: 1000
|
|
115
|
+
)
|
|
116
|
+
expect(config.batch_size).to eq(100)
|
|
117
|
+
expect(config.ideal_batch_item_size).to eq(1000)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe 'attribute accessors' do
|
|
122
|
+
it 'allows setting api_key after initialization' do
|
|
123
|
+
config = described_class.new(api_key: 'initial-key')
|
|
124
|
+
config.api_key = 'new-key'
|
|
125
|
+
expect(config.api_key).to eq('new-key')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'allows setting api_url after initialization' do
|
|
129
|
+
config = described_class.new(api_key: 'test-key')
|
|
130
|
+
config.api_url = 'https://new-url.com'
|
|
131
|
+
expect(config.api_url).to eq('https://new-url.com')
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'allows setting batch_size after initialization' do
|
|
135
|
+
config = described_class.new(api_key: 'test-key')
|
|
136
|
+
config.batch_size = 100
|
|
137
|
+
expect(config.batch_size).to eq(100)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'allows setting ideal_batch_item_size after initialization' do
|
|
141
|
+
config = described_class.new(api_key: 'test-key')
|
|
142
|
+
config.ideal_batch_item_size = 1500
|
|
143
|
+
expect(config.ideal_batch_item_size).to eq(1500)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|