kishu 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ RSpec.describe Kishu do
2
+ it "has a version number" do
3
+ expect(Kishu::VERSION).not_to be nil
4
+ end
5
+
6
+ it "does something useful" do
7
+ # expect(false).to eq(true)
8
+ end
9
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Kishu::Report, vcr: true, :order => :defined do
5
+ let(:report) {Kishu::Report.new()}
6
+ describe "report_period" do
7
+ context "when doi doesn't exist" do
8
+
9
+ it "should fail" do
10
+ # response = subject.get_events
11
+ # expect(response).to be({})
12
+ end
13
+ end
14
+ end
15
+
16
+
17
+ describe "get_events" do
18
+ context "" do
19
+ it "should return the data for one message" do
20
+
21
+ end
22
+ end
23
+ end
24
+
25
+ describe "generate_dataset_array" do
26
+ context "" do
27
+ it "" do
28
+
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "compress" do
34
+ context "when json arrives compresses it correctly" do
35
+
36
+ it "compresses" do
37
+
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ describe "generate_chunk_report" do
44
+ context "" do
45
+ it "" do
46
+
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "set_period" do
52
+ context "" do
53
+ it "" do
54
+
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "send_report" do
60
+ context "when the report is good" do
61
+ it "" do
62
+
63
+ end
64
+ end
65
+
66
+ context "when the report is bad" do
67
+ let(:report) {}
68
+ it "return error" do
69
+ # status = Report.send_report report
70
+ # expect(status).not_to eq("201")
71
+ end
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+
78
+
79
+
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Kishu::ResolutionEvent, vcr: true, :order => :defined do
5
+
6
+ describe "wrap_event" do
7
+ context "when doi exist" do
8
+ let(:event){create(:resolution_event)}
9
+ it "should wrap correctly" do
10
+ puts event.dig(:totale)
11
+ response = subject.wrap_event(event)
12
+ expect(response).to eq({})
13
+ end
14
+ end
15
+ context "when doi has not type assigned" do
16
+ let(:event) {{
17
+ "key": {
18
+ "doi": "10.13130//3192"
19
+ },
20
+ "doc_count": 2,
21
+ "totale": {
22
+ "doc_count_error_upper_bound": 0,
23
+ "sum_other_doc_count": 0,
24
+ "buckets": [
25
+ {
26
+ "key": "10.13130//3192_regular",
27
+ "doc_count": 2
28
+ }
29
+ ]
30
+ },
31
+ "unqiue": {
32
+ "doc_count_error_upper_bound": 0,
33
+ "sum_other_doc_count": 0,
34
+ "buckets": [
35
+ {
36
+ "key": "2018-04-15_12_10.13130//3192_5.168.132.15_Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-A520F Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/5.4 Chrome/51.0.2704.106 Mobile Safari/537.36_regular",
37
+ "doc_count": 1
38
+ },
39
+ {
40
+ "key": "2018-04-15_16_10.13130//3192_151.15.225.227_Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1_regular",
41
+ "doc_count": 1
42
+ }
43
+ ]
44
+ }
45
+ }}
46
+ it "should return an dataset event" do
47
+ response = ResolutionEvent.wrap_event(event)
48
+ expect(response).to eq({})
49
+ end
50
+ end
51
+ context "when event is empty" do
52
+ let(:event) {""}
53
+ it "should fail" do
54
+ response = ResolutionEvent.wrap_event(event)
55
+ expect(response).to eq({})
56
+ end
57
+ end
58
+ end
59
+
60
+
61
+ describe "" do
62
+ context "" do
63
+ it "should return the data for one message" do
64
+
65
+ end
66
+ end
67
+ end
68
+
69
+ describe "" do
70
+ context "" do
71
+ it "" do
72
+
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+
80
+
@@ -0,0 +1,93 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ require 'kishu'
8
+ require 'rspec'
9
+ require 'rack/test'
10
+ require 'webmock/rspec'
11
+ require 'vcr'
12
+ require 'factory_bot'
13
+
14
+ RSpec.configure do |config|
15
+ config.order = :random
16
+ config.include WebMock::API
17
+ config.include Rack::Test::Methods
18
+ config.expect_with :rspec do |c|
19
+ c.syntax = :expect
20
+ end
21
+
22
+ config.include FactoryBot::Syntax::Methods
23
+
24
+ config.before(:suite) do
25
+ FactoryBot.find_definitions
26
+ end
27
+
28
+
29
+ config.before do
30
+ ARGV.replace []
31
+ end
32
+ end
33
+
34
+ def fixture_path
35
+ File.expand_path("../fixtures", __FILE__) + '/'
36
+ end
37
+
38
+ # This code was adapted from Thor, available under MIT-LICENSE
39
+ # Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
40
+ def capture(stream)
41
+ begin
42
+ stream = stream.to_s
43
+ eval "$#{stream} = StringIO.new"
44
+ yield
45
+ result = eval("$#{stream}").string
46
+ ensure
47
+ eval("$#{stream} = #{stream.upcase}")
48
+ end
49
+
50
+ result
51
+ end
52
+
53
+ def capture_stdout(&block)
54
+ original_stdout = $stdout
55
+ $stdout = fake = StringIO.new
56
+ begin
57
+ yield
58
+ ensure
59
+ $stdout = original_stdout
60
+ end
61
+ fake.string
62
+ end
63
+
64
+ def capture_stderr(&block)
65
+ original_stderr = $stderr
66
+ $stderr = fake = StringIO.new
67
+ begin
68
+ yield
69
+ ensure
70
+ $stderr = original_stderr
71
+ end
72
+ fake.string
73
+ end
74
+
75
+ # This code was adapted from Ruby on Rails, available under MIT-LICENSE
76
+ # Copyright (c) 2004-2013 David Heinemeier Hansson
77
+ def silence_warnings
78
+ old_verbose, $VERBOSE = $VERBOSE, nil
79
+ yield
80
+ ensure
81
+ $VERBOSE = old_verbose
82
+ end
83
+
84
+ alias silence capture
85
+
86
+ VCR.configure do |c|
87
+
88
+ c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
89
+ c.hook_into :webmock
90
+ c.ignore_localhost = true
91
+ c.ignore_hosts 'codeclimate.com'
92
+ c.configure_rspec_metadata!
93
+ end
metadata ADDED
@@ -0,0 +1,400 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kishu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Garza
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.15.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.15.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: builder
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.2.2
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.2.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: dotenv
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.1.1
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.1.1
67
+ - !ruby/object:Gem::Dependency
68
+ name: thor
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.19'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.19'
81
+ - !ruby/object:Gem::Dependency
82
+ name: maremma
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '4.1'
88
+ - - "<"
89
+ - !ruby/object:Gem::Version
90
+ version: '5'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '4.1'
98
+ - - "<"
99
+ - !ruby/object:Gem::Version
100
+ version: '5'
101
+ - !ruby/object:Gem::Dependency
102
+ name: faraday_middleware-aws-sigv4
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: 0.2.4
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: 0.2.4
115
+ - !ruby/object:Gem::Dependency
116
+ name: bundler
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '1.16'
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '1.16'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rake
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: '10.0'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: '10.0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: rspec
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '3.0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '3.0'
157
+ - !ruby/object:Gem::Dependency
158
+ name: elasticsearch
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: 6.1.0
164
+ type: :development
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - "~>"
169
+ - !ruby/object:Gem::Version
170
+ version: 6.1.0
171
+ - !ruby/object:Gem::Dependency
172
+ name: thor
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '0.19'
178
+ type: :development
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: '0.19'
185
+ - !ruby/object:Gem::Dependency
186
+ name: faraday
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: 0.15.3
192
+ type: :development
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - "~>"
197
+ - !ruby/object:Gem::Version
198
+ version: 0.15.3
199
+ - !ruby/object:Gem::Dependency
200
+ name: rack-test
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ type: :development
207
+ prerelease: false
208
+ version_requirements: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - "~>"
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ - !ruby/object:Gem::Dependency
214
+ name: vcr
215
+ requirement: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: '3.0'
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 3.0.3
223
+ type: :development
224
+ prerelease: false
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '3.0'
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: 3.0.3
233
+ - !ruby/object:Gem::Dependency
234
+ name: webmock
235
+ requirement: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - "~>"
238
+ - !ruby/object:Gem::Version
239
+ version: '3.0'
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: 3.0.1
243
+ type: :development
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: '3.0'
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ version: 3.0.1
253
+ - !ruby/object:Gem::Dependency
254
+ name: simplecov
255
+ requirement: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - "~>"
258
+ - !ruby/object:Gem::Version
259
+ version: 0.14.1
260
+ type: :development
261
+ prerelease: false
262
+ version_requirements: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - "~>"
265
+ - !ruby/object:Gem::Version
266
+ version: 0.14.1
267
+ - !ruby/object:Gem::Dependency
268
+ name: factory_bot
269
+ requirement: !ruby/object:Gem::Requirement
270
+ requirements:
271
+ - - "~>"
272
+ - !ruby/object:Gem::Version
273
+ version: '4.0'
274
+ type: :development
275
+ prerelease: false
276
+ version_requirements: !ruby/object:Gem::Requirement
277
+ requirements:
278
+ - - "~>"
279
+ - !ruby/object:Gem::Version
280
+ version: '4.0'
281
+ - !ruby/object:Gem::Dependency
282
+ name: sucker_punch
283
+ requirement: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - "~>"
286
+ - !ruby/object:Gem::Version
287
+ version: '2.0'
288
+ type: :runtime
289
+ prerelease: false
290
+ version_requirements: !ruby/object:Gem::Requirement
291
+ requirements:
292
+ - - "~>"
293
+ - !ruby/object:Gem::Version
294
+ version: '2.0'
295
+ - !ruby/object:Gem::Dependency
296
+ name: bolognese
297
+ requirement: !ruby/object:Gem::Requirement
298
+ requirements:
299
+ - - "~>"
300
+ - !ruby/object:Gem::Version
301
+ version: '0.9'
302
+ - - ">="
303
+ - !ruby/object:Gem::Version
304
+ version: '0.10'
305
+ type: :runtime
306
+ prerelease: false
307
+ version_requirements: !ruby/object:Gem::Requirement
308
+ requirements:
309
+ - - "~>"
310
+ - !ruby/object:Gem::Version
311
+ version: '0.9'
312
+ - - ">="
313
+ - !ruby/object:Gem::Version
314
+ version: '0.10'
315
+ - !ruby/object:Gem::Dependency
316
+ name: elasticsearch
317
+ requirement: !ruby/object:Gem::Requirement
318
+ requirements:
319
+ - - "~>"
320
+ - !ruby/object:Gem::Version
321
+ version: 6.1.0
322
+ type: :runtime
323
+ prerelease: false
324
+ version_requirements: !ruby/object:Gem::Requirement
325
+ requirements:
326
+ - - "~>"
327
+ - !ruby/object:Gem::Version
328
+ version: 6.1.0
329
+ description: 'This client helps you to prepare logs to be consumed for the pipeline
330
+ as well as for creating DOI resolution reports using the COUNTER CoP '
331
+ email:
332
+ - kgarza@datacite.org
333
+ executables:
334
+ - kishu
335
+ extensions: []
336
+ extra_rdoc_files: []
337
+ files:
338
+ - ".gitignore"
339
+ - ".rspec"
340
+ - ".travis.yml"
341
+ - CODE_OF_CONDUCT.md
342
+ - Gemfile
343
+ - Gemfile.lock
344
+ - LICENSE.txt
345
+ - README.md
346
+ - Rakefile
347
+ - bin/kishu
348
+ - kishu.gemspec
349
+ - lib/kishu.rb
350
+ - lib/kishu/base.rb
351
+ - lib/kishu/cli.rb
352
+ - lib/kishu/client.rb
353
+ - lib/kishu/lagotto_job.rb
354
+ - lib/kishu/log.rb
355
+ - lib/kishu/merger.rb
356
+ - lib/kishu/pipeline.rb
357
+ - lib/kishu/report.rb
358
+ - lib/kishu/resolution_event.rb
359
+ - lib/kishu/s3.rb
360
+ - lib/kishu/sushi.rb
361
+ - lib/kishu/usage_event.rb
362
+ - lib/kishu/utils.rb
363
+ - lib/kishu/version.rb
364
+ - spec/factories/default.rb
365
+ - spec/fixtures/vcr_cassettes/Kishu_Sushi/wrap_event/when_doi_doesn_t_exist/should_fail.yml
366
+ - spec/kishu_spec.rb
367
+ - spec/report_spec.rb
368
+ - spec/resolution_event_spec.rb
369
+ - spec/spec_helper.rb
370
+ homepage: https://github.com/datacite/kishu
371
+ licenses:
372
+ - MIT
373
+ metadata: {}
374
+ post_install_message:
375
+ rdoc_options: []
376
+ require_paths:
377
+ - lib
378
+ required_ruby_version: !ruby/object:Gem::Requirement
379
+ requirements:
380
+ - - ">="
381
+ - !ruby/object:Gem::Version
382
+ version: '0'
383
+ required_rubygems_version: !ruby/object:Gem::Requirement
384
+ requirements:
385
+ - - ">="
386
+ - !ruby/object:Gem::Version
387
+ version: '0'
388
+ requirements: []
389
+ rubyforge_project:
390
+ rubygems_version: 2.7.6
391
+ signing_key:
392
+ specification_version: 4
393
+ summary: Client for DOI Resolution Logs processing pipeline
394
+ test_files:
395
+ - spec/factories/default.rb
396
+ - spec/fixtures/vcr_cassettes/Kishu_Sushi/wrap_event/when_doi_doesn_t_exist/should_fail.yml
397
+ - spec/kishu_spec.rb
398
+ - spec/report_spec.rb
399
+ - spec/resolution_event_spec.rb
400
+ - spec/spec_helper.rb