stream_lines 0.4.0 → 0.4.1

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: 9e832d9790c71431c43722f116cca885d3fee985001b12f5d0c53cc17e78c7b8
4
- data.tar.gz: 76338bc7e203bfa59f3aed2469db3694951dfd5905c6bcfe416b08f1512f3289
3
+ metadata.gz: d12669d8a8c0f786d731b6fb98374e4105b483379e6ad9b0cb346a62289c5481
4
+ data.tar.gz: 67607b92517c8b6151e576258314ed4896344893b1a5160602e018aa0aae7d28
5
5
  SHA512:
6
- metadata.gz: 3d980bdddd41227418da10447e57599ee94cea52b7ea926e1cb3f0efd8a3b71b7e8f44c70ed7a62dc37ea31ac97e84a1f5d20677ecb933bd26be7c2348e533c5
7
- data.tar.gz: 721610a59f59862772b0ea259b6f22c0e84f058d458538ae993478324e9e315dc6fa0b469eaebb56fd630f59bd43b3bb43956f2111855c22cb00bb744296018c
6
+ metadata.gz: 178c5fc570b8dba9330efcd6493b2437fdbd6ed277e3ec653d7c6e436fcb959fea89110781059e5a6acf3e821fa5cb098afcee35664dbac028469baf3542f5cf
7
+ data.tar.gz: a9e08b3b01ad37fd2daf0e1e10ed729fb8ceabe0e151c2e147c0d131216bf2f1cca2562240890db816a869fc2c7f8c52618796769b20cb8c92e920b16cf11ff0
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ time: "10:00"
8
+ open-pull-requests-limit: 10
9
+ ignore:
10
+ - dependency-name: rubocop
11
+ versions:
12
+ - 1.12.0
@@ -0,0 +1,32 @@
1
+ name: Tests (Ruby)
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby_version:
17
+ - 2.6
18
+ - 2.7
19
+ - 3.0
20
+ - 3.1
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby_version }}
27
+ - name: Ruby version
28
+ run: ruby -v
29
+ - name: Install dependencies
30
+ run: bundle install
31
+ - name: Run tests
32
+ run: bundle exec rake
@@ -5,7 +5,7 @@
5
5
  # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
6
  # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
7
 
8
- name: Tests
8
+ name: Style Check
9
9
 
10
10
  on:
11
11
  push:
@@ -16,15 +16,15 @@ on:
16
16
  - '*'
17
17
 
18
18
  jobs:
19
- test:
19
+ rubocop:
20
20
  runs-on: ubuntu-latest
21
21
  steps:
22
22
  - uses: actions/checkout@v2
23
23
  - name: Set up Ruby
24
24
  uses: ruby/setup-ruby@v1
25
25
  with:
26
- ruby-version: 2.6
26
+ ruby-version: 3.0
27
27
  - name: Install dependencies
28
28
  run: bundle install
29
- - name: Run tests
30
- run: bundle exec rake
29
+ - name: Run Rubocop
30
+ run: bundle exec rubocop -D
data/.rubocop.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  AllCops:
2
+ NewCops: 'enable'
3
+ TargetRubyVersion: 2.5
2
4
  Exclude:
3
5
  - '*.gemspec'
4
6
  - 'vendor/bundle/**/*'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.0
1
+ 3.1.2
data/Gemfile.lock CHANGED
@@ -1,84 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stream_lines (0.4.0)
4
+ stream_lines (0.4.1)
5
5
  httparty (~> 0.14)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.7.0)
10
+ addressable (2.8.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.1)
13
- awesome_print (1.8.0)
12
+ ast (2.4.2)
13
+ awesome_print (1.9.2)
14
14
  backports (3.17.2)
15
- bundler-audit (0.7.0.1)
15
+ bundler-audit (0.9.0.1)
16
16
  bundler (>= 1.2.0, < 3)
17
- thor (>= 0.18, < 2)
17
+ thor (~> 1.0)
18
18
  bundler-gem_version_tasks (0.2.1)
19
19
  byebug (11.1.3)
20
20
  charlock_holmes (0.7.7)
21
- crack (0.4.3)
22
- safe_yaml (~> 1.0.0)
23
- diff-lcs (1.3)
24
- docile (1.3.2)
25
- ffi (1.13.0)
26
- get_process_mem (0.2.5)
21
+ crack (0.4.5)
22
+ rexml
23
+ diff-lcs (1.5.0)
24
+ docile (1.3.4)
25
+ ffi (1.13.1)
26
+ get_process_mem (0.2.7)
27
27
  ffi (~> 1.0)
28
28
  hashdiff (1.0.1)
29
- httparty (0.18.1)
29
+ httparty (0.20.0)
30
30
  mime-types (~> 3.0)
31
31
  multi_xml (>= 0.5.2)
32
- memory_profiler (0.9.14)
32
+ memory_profiler (1.0.0)
33
33
  mime-types (3.3.1)
34
34
  mime-types-data (~> 3.2015)
35
- mime-types-data (3.2020.0512)
35
+ mime-types-data (3.2021.0901)
36
36
  multi_json (1.14.1)
37
37
  multi_xml (0.6.0)
38
38
  mustermann (1.1.1)
39
39
  ruby2_keywords (~> 0.0.1)
40
- parallel (1.19.2)
41
- parser (2.7.1.4)
40
+ parallel (1.22.1)
41
+ parser (3.1.1.0)
42
42
  ast (~> 2.4.1)
43
- public_suffix (4.0.5)
43
+ public_suffix (4.0.6)
44
44
  rack (2.2.3)
45
45
  rack-protection (2.0.8.1)
46
46
  rack
47
- rainbow (3.0.0)
48
- rake (13.0.1)
49
- regexp_parser (1.7.1)
50
- rexml (3.2.4)
51
- rspec (3.9.0)
52
- rspec-core (~> 3.9.0)
53
- rspec-expectations (~> 3.9.0)
54
- rspec-mocks (~> 3.9.0)
55
- rspec-core (3.9.2)
56
- rspec-support (~> 3.9.3)
57
- rspec-expectations (3.9.2)
47
+ rainbow (3.1.1)
48
+ rake (13.0.6)
49
+ regexp_parser (2.3.0)
50
+ rexml (3.2.5)
51
+ rspec (3.11.0)
52
+ rspec-core (~> 3.11.0)
53
+ rspec-expectations (~> 3.11.0)
54
+ rspec-mocks (~> 3.11.0)
55
+ rspec-core (3.11.0)
56
+ rspec-support (~> 3.11.0)
57
+ rspec-expectations (3.11.0)
58
58
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.9.0)
60
- rspec-mocks (3.9.1)
59
+ rspec-support (~> 3.11.0)
60
+ rspec-mocks (3.11.0)
61
61
  diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.9.0)
63
- rspec-support (3.9.3)
64
- rubocop (0.87.1)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-support (3.11.0)
64
+ rubocop (1.27.0)
65
65
  parallel (~> 1.10)
66
- parser (>= 2.7.1.1)
66
+ parser (>= 3.1.0.0)
67
67
  rainbow (>= 2.2.2, < 4.0)
68
- regexp_parser (>= 1.7)
68
+ regexp_parser (>= 1.8, < 3.0)
69
69
  rexml
70
- rubocop-ast (>= 0.1.0, < 1.0)
70
+ rubocop-ast (>= 1.16.0, < 2.0)
71
71
  ruby-progressbar (~> 1.7)
72
- unicode-display_width (>= 1.4.0, < 2.0)
73
- rubocop-ast (0.1.0)
74
- parser (>= 2.7.0.1)
75
- ruby-progressbar (1.10.1)
72
+ unicode-display_width (>= 1.4.0, < 3.0)
73
+ rubocop-ast (1.17.0)
74
+ parser (>= 3.1.1.0)
75
+ ruby-progressbar (1.11.0)
76
76
  ruby2_keywords (0.0.2)
77
- safe_yaml (1.0.5)
78
- simplecov (0.18.5)
77
+ simplecov (0.21.2)
79
78
  docile (~> 1.1)
80
79
  simplecov-html (~> 0.11)
81
- simplecov-html (0.12.2)
80
+ simplecov_json_formatter (~> 0.1)
81
+ simplecov-html (0.12.3)
82
+ simplecov_json_formatter (0.1.2)
82
83
  sinatra (2.0.8.1)
83
84
  mustermann (~> 1.0)
84
85
  rack (~> 2.0)
@@ -91,13 +92,14 @@ GEM
91
92
  rack-protection (= 2.0.8.1)
92
93
  sinatra (= 2.0.8.1)
93
94
  tilt (~> 2.0)
94
- thor (1.0.1)
95
+ thor (1.1.0)
95
96
  tilt (2.0.10)
96
- unicode-display_width (1.7.0)
97
- webmock (3.8.3)
98
- addressable (>= 2.3.6)
97
+ unicode-display_width (2.1.0)
98
+ webmock (3.14.0)
99
+ addressable (>= 2.8.0)
99
100
  crack (>= 0.3.2)
100
101
  hashdiff (>= 0.4.0, < 2.0.0)
102
+ webrick (1.7.0)
101
103
 
102
104
  PLATFORMS
103
105
  ruby
@@ -113,12 +115,13 @@ DEPENDENCIES
113
115
  memory_profiler
114
116
  rake (~> 13.0)
115
117
  rspec (~> 3.0)
116
- rubocop (~> 0.87.1)
118
+ rubocop (~> 1.27.0)
117
119
  simplecov (~> 0.17)
118
120
  sinatra (~> 2.0)
119
121
  sinatra-contrib (~> 2.0)
120
122
  stream_lines!
121
123
  webmock (~> 3.0)
124
+ webrick (~> 1.7)
122
125
 
123
126
  BUNDLED WITH
124
- 2.0.2
127
+ 2.3.11
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # StreamLines
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/stream_lines.svg)](https://badge.fury.io/rb/stream_lines)
4
- ![](https://github.com/jdlubrano/stream_lines/workflows/Tests/badge.svg)
4
+ [![Tests (Ruby)](https://github.com/jdlubrano/stream_lines/actions/workflows/ruby-tests.yml/badge.svg)](https://github.com/jdlubrano/stream_lines/actions/workflows/ruby-tests.yml)
5
5
 
6
6
  An API for streaming files from remote locations one line at a time.
7
7
 
@@ -55,6 +55,37 @@ stream.each_slice(100) do |lines|
55
55
  end
56
56
  ```
57
57
 
58
+ ##### Caveats
59
+
60
+ This library strives to provide streamed data via an `Enumerable` interface.
61
+ In order to be memory-efficient, however, each time the stream is iterated over,
62
+ a new GET request is made to fetch the data from its remote URL. For example,
63
+
64
+ ```ruby
65
+ url = 'https://my.remote.file/file.txt'
66
+ stream = StreamLines::Reading::Stream.new(url)
67
+ do_something_with_first_row(stream.first) # GET request made
68
+
69
+ stream.each do |line| # same GET request made
70
+ # Do something with the line of data (the line will be a String)
71
+ end
72
+ ```
73
+
74
+ makes two GET requests. The call to `first` makes a GET request to fetch
75
+ the first row of data. The subsequent call to `each` makes the same GET
76
+ request. To avoid unnecessary requests, I recommend a slightly different
77
+ approach, which may not be intuitive but does make only one network request:
78
+
79
+ ```
80
+ url = 'https://my.remote.file/file.txt'
81
+ stream = StreamLines::Reading::Stream.new(url)
82
+
83
+ stream.each_with_index do |line, i|
84
+ do_something_with_first_row(line) if i.zero?
85
+ # Do something with the line of data (the line will be a String)
86
+ end
87
+ ```
88
+
58
89
  ##### CSVs
59
90
 
60
91
  This gem provides first-class support for streaming CSVs from a remote URL.
@@ -23,6 +23,7 @@ module StreamLines
23
23
  def initialize(url, **csv_options)
24
24
  @url = url
25
25
  @csv_options = accepted_csv_options(csv_options)
26
+ @first_row_headers = @csv_options[:headers] == true
26
27
 
27
28
  encoding = @csv_options[:encoding] || Encoding.default_external
28
29
  @stream = Stream.new(url, encoding: encoding)
@@ -41,7 +42,7 @@ module StreamLines
41
42
  attr_reader :url
42
43
 
43
44
  def first_row_headers?
44
- @csv_options[:headers] == true
45
+ @first_row_headers
45
46
  end
46
47
 
47
48
  def assign_first_row_headers(first_line)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StreamLines
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
data/stream_lines.gemspec CHANGED
@@ -38,9 +38,10 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency 'memory_profiler'
39
39
  spec.add_development_dependency 'rake', '~> 13.0'
40
40
  spec.add_development_dependency 'rspec', '~> 3.0'
41
- spec.add_development_dependency 'rubocop', '~> 0.87.1'
41
+ spec.add_development_dependency 'rubocop', '~> 1.27.0'
42
42
  spec.add_development_dependency 'simplecov', '~> 0.17'
43
43
  spec.add_development_dependency 'sinatra', '~> 2.0'
44
44
  spec.add_development_dependency 'sinatra-contrib', '~> 2.0'
45
+ spec.add_development_dependency 'webrick', '~> 1.7'
45
46
  spec.add_development_dependency 'webmock', '~> 3.0'
46
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream_lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Lubrano
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-19 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.87.1
173
+ version: 1.27.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.87.1
180
+ version: 1.27.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '2.0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: webrick
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '1.7'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '1.7'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: webmock
225
239
  requirement: !ruby/object:Gem::Requirement
@@ -234,14 +248,16 @@ dependencies:
234
248
  - - "~>"
235
249
  - !ruby/object:Gem::Version
236
250
  version: '3.0'
237
- description:
251
+ description:
238
252
  email:
239
253
  - joel.lubrano@gmail.com
240
254
  executables: []
241
255
  extensions: []
242
256
  extra_rdoc_files: []
243
257
  files:
244
- - ".github/workflows/ci-tests.yml"
258
+ - ".github/dependabot.yml"
259
+ - ".github/workflows/ruby-tests.yml"
260
+ - ".github/workflows/style-check.yml"
245
261
  - ".gitignore"
246
262
  - ".rspec"
247
263
  - ".rubocop.yml"
@@ -270,7 +286,7 @@ metadata:
270
286
  homepage_uri: https://github.com/jdlubrano/stream_lines
271
287
  source_code_uri: https://github.com/jdlubrano/stream_lines
272
288
  changelog_uri: https://github.com/jdlubrano/stream_lines/releases
273
- post_install_message:
289
+ post_install_message:
274
290
  rdoc_options: []
275
291
  require_paths:
276
292
  - lib
@@ -285,8 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
301
  - !ruby/object:Gem::Version
286
302
  version: '0'
287
303
  requirements: []
288
- rubygems_version: 3.1.2
289
- signing_key:
304
+ rubygems_version: 3.3.7
305
+ signing_key:
290
306
  specification_version: 4
291
307
  summary: A utility to stream lines of a file over HTTP
292
308
  test_files: []