thread_io 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/thread_io.rb +17 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ddae2ee6000eeb036b0ed8bccf23ca56dd80823ba7d4e86b8075b0751a1daa3
4
- data.tar.gz: 012364aed013a8381c6755b0e3e1b60e1ba640dae28cdb05ac3f09b54631bb59
3
+ metadata.gz: d83017966c70bad04d23df7017a90a50309872dee44297641e350ced951f3bab
4
+ data.tar.gz: 3098c3abd0813f490cfdc0df65186d9fe6cf1cd4640e9aa0405013e167810b79
5
5
  SHA512:
6
- metadata.gz: a71ac3aab6e4f7f8a66d11cb62da0c4fe5ab45a0bbd37e6f041e87f6d70468dfa6a38e80028e60bf0237d5cd05e4edd69c1b2f927cfa4aafe4f789ed40c21961
7
- data.tar.gz: 2da2efb69a9e4780c62116585e911cdb6d242b5a68dda37c45679e6c858a66209e1317a10629817306f013dddffc170b3e7ccc02ca552b431178b186c45d2b4c
6
+ metadata.gz: b0475b6f748d8da583806957f50f8c6a9ccb5de88306ec5d46d477e37dde3761935f37341af374a0672ef11b76c9112af4634a19eccdd7991bb10903d0dd363a
7
+ data.tar.gz: '0899c30a42eb6f9c8cedc65c2d5c8d43fc8e7753c9f4fe85df5276e8674e03784e0431b5957b7276564e0f80cf8aa39e1e5e6a0993d7df6ac03d18e8056484ee'
data/lib/thread_io.rb CHANGED
@@ -7,17 +7,19 @@
7
7
  #
8
8
  # # optional loop until the file is read
9
9
  # loop do
10
- # breadk if tio.ready?
10
+ # break if tio.ready?
11
11
  # sleep 1
12
12
  # end
13
13
  #
14
14
  # tio.string # contains the contents of the file as one large String
15
15
  class ThreadIO
16
- attr_reader :string
16
+ attr_reader :string,
17
+ :lines
17
18
 
18
19
  def initialize
19
20
  @ready = false
20
21
  @string = nil
22
+ @lines = nil
21
23
  end
22
24
 
23
25
  # this method returns immediately and loads the file in the background
@@ -36,6 +38,19 @@ class ThreadIO
36
38
  nil
37
39
  end
38
40
 
41
+ def read_lines(path)
42
+ @ready = false
43
+ Thread.new do
44
+ @lines = []
45
+ File.open(path, 'r') {|f| f.each_line{|l| @lines << l.chomp } }
46
+ @ready = true
47
+
48
+ nil
49
+ end
50
+
51
+ nil
52
+ end
53
+
39
54
  def ready?
40
55
  @ready
41
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-01 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a small class that loads files in the background via a Thread
14
14
  email: jefflunt@gmail.com