community_theatre 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6be6792fdeeade4fed8994338980b54e411be4cfb3d0fbea7d51591039269a9
4
- data.tar.gz: 73d37e9df72484ae3ff3b9e27d9661d312ecda6f1ec1e1b4e1966dd1b447d793
3
+ metadata.gz: 942c3432aa71b70d6195193ac48d43e69bbd3bb965d50313f392c0cda457922e
4
+ data.tar.gz: 2ce57da5dedc494916e607c13011c404cc51c5f0b442300aa76e5f4ef6f5ea8c
5
5
  SHA512:
6
- metadata.gz: 4d47bcaa510e069e06abbeb1836508b7b166afe78796b2a4126478a452abe7cebfed6b063ae473425eefc71f4216df5b2086603412bdc5d9901ec45ec006b2c9
7
- data.tar.gz: 4b675d498ed350f5413bcf9fee0629820e69548af591ae3da954eda0910e6f8860566c0f28853f7c2bb2d789bf56c6bdca275b8d05b141d5f45679b6cef960bc
6
+ metadata.gz: 844a6bc670e193cfbf373c9ab317f071bb76c080223daeb7ac3e0cc3cfbb438410ad7d40dea5c3a4e3a40bfed3ba1508f6f0507891bf906bea9e0ac2f9a027cb
7
+ data.tar.gz: 22f75fa53e89bff511d70773bce51b689158f98026b2bf73a6e78ab9f95233816f25af84457a07ccfd882dae4cf5e2bec5203ba2e39a4ba9b9b7e789c77a3b1a
@@ -15,19 +15,21 @@ module CommunityTheatre
15
15
  packer = MessagePack::Packer.new(file)
16
16
  packer.write_array_header(page.size)
17
17
 
18
- page.each {|item| packer.write(item)}
18
+ page.each { |item| packer.write(item) }
19
19
 
20
20
  packer.flush
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
- def unspool
25
+ # implementation of "starting_at" is only to the page level
26
+ # (see #pages)
27
+ def unspool(starting_at = 0)
26
28
  Enumerator.new do |yielder|
27
- existing_pages.each do |page_no|
29
+ pages(starting_at).each do |page_no|
28
30
  file_for_page(page_no, 'r') do |file|
29
31
  page = MessagePack::Unpacker.new(file).unpack
30
- page.each {|item| yielder << item}
32
+ page.each { |item| yielder << item }
31
33
  end
32
34
  end
33
35
  end
@@ -35,13 +37,21 @@ module CommunityTheatre
35
37
 
36
38
  private
37
39
 
40
+ # implementation of "skip_items" is only to the page level
41
+ def pages(skip_items = nil)
42
+ skip_items ||= 0
43
+ skip_pages = (skip_items / @page_size).floor
44
+
45
+ existing_pages.drop(skip_pages)
46
+ end
47
+
38
48
  def existing_pages
39
49
  Dir.entries(@destination)
40
- .map{|n| File.join(@destination, n)}
41
- .filter {|n| File.file?(n)}
42
- .filter {|n| n =~ /\/\d+$/}
43
- .map {|n| /\/(\d+)$/.match(n)[1].to_i }
44
- .sort
50
+ .map{ |n| File.join(@destination, n) }
51
+ .filter { |n| File.file?(n) }
52
+ .filter { |n| n =~ /\/\d+$/ }
53
+ .map { |n| /\/(\d+)$/.match(n)[1].to_i }
54
+ .sort
45
55
  end
46
56
 
47
57
  def path_for_page(n)
@@ -15,10 +15,10 @@ module CommunityTheatre
15
15
 
16
16
  def process(item); end
17
17
 
18
- def project!
18
+ def project!(starting_at = 0)
19
19
  setup
20
20
 
21
- @spooler.unspool.each(&method(:process))
21
+ @spooler.unspool(starting_at).each(&method(:process))
22
22
 
23
23
  teardown
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommunityTheatre
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: community_theatre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Dawson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack