keybreak 0.1.0 → 0.1.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWE2ZTc3ZjI0YzBkZTZhNmMzMTBkMGYzNGY3OTFlMmQ1NTdjY2RiZQ==
4
+ NzllZjEwM2Q1ODQzN2JkN2FkZGZmMjU3ZTUzM2ViMzY5NWVmN2FiNg==
5
5
  data.tar.gz: !binary |-
6
- Y2QyMmE5MzllY2MyOTRkNGY2ZWZhYTU4ODc0NGI1MTgwYjNlNWI3Ng==
6
+ NDM4YWQyZDM3NDgyMDlkM2NlMWE4NGM0NGQzNWM2ZDg5YWJkNDIwZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGI3MjdiZTc2YzgyMzg3Zjg5NjhiNGU2NTNiNGI4NWVmMTI3MjlhZDZlNjI0
10
- MGY1NzU3YmZkMGE2MGE2ZmQ4NTk5MzRhN2IzNmIwYWU1MjBjY2YxYzA5YmY3
11
- YjM5YzAzNTFkODhjMGZmMmQzMWU0YTI2NzhlNzRjNzVmODNkY2E=
9
+ ZWYyNDMyMDU3ODA1ZDdmNzk2ZjY1NTZkZTUxMjk3Njg4NGNjYWFjYjU1ZmNi
10
+ NTgyNDMxM2U5NGYwZGZkNmE2NTFkMjNlNWEyYWYwOWYxNjMwMGVhNDhmMDlh
11
+ YjZiNzcyOTQwMTBjYTc5NjJkYjBiOGQwZTM4NmYyZWI0ODNhZWE=
12
12
  data.tar.gz: !binary |-
13
- ZjAwOWZmNzRhMzhkNjY2MzJjNmQwM2M1NzgzYWZiNzA0MDM0MWU1NTFlYmEy
14
- NmE2NTMyMGMyMzRiOTEzYmQ4YjQ5NWZjMWNmYjJjYWI4NmZlMjM3MzM3NGE5
15
- ZWE0ZTNmYzU4MGE1ZDQzZmFjZTM0MTQ4MTJhZGRkNzVkY2IwYjA=
13
+ ODM0ODkwNjk5MGIxNzMyMmU5ZWZhOWM0Mzc0N2QwOGZmZjkwZTExZmJkODRh
14
+ ZDViZTI4OGRjMmY0YmJiZTBkYTA1M2Q2ZTVjZDUxZDE1MTk1OGRiYTU4MmRm
15
+ NDJjZTBkMzRlNGNkNmRlYmQzNjU2MjBhZjY1Y2U1ODY3OGIxNGQ=
data/README.md CHANGED
@@ -8,6 +8,7 @@ Keybreak is a utility module for Key break processing in Ruby.
8
8
 
9
9
  The "key break processing" means, assuming a sorted sequence of column based records which can be grouped by a column,
10
10
  doing the same process for each group.
11
+
11
12
  The column used for the grouping is a "key".
12
13
  In processing the record sequence, when the key's value in a record changes from the previous record,
13
14
  it is called "key break".
@@ -160,6 +161,7 @@ e:8
160
161
  ### Print last values for each key
161
162
 
162
163
  Borrows DATA from above example.
164
+
163
165
  Register a keyend handler which prints the given key and value.
164
166
 
165
167
  ```ruby
@@ -215,6 +217,7 @@ e:17
215
217
  ### Print sum of values for each key and sub key
216
218
 
217
219
  Nest Keybreak.execute_with_controller.
220
+
218
221
  Give sub key handlers a set of primary key and sub key (an array for instance)
219
222
  so that a primary key break is also detected as a sub key break.
220
223
 
data/keybreak.gemspec CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.11"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
+
25
+ spec.required_ruby_version = ">= 1.9.3"
24
26
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Keybreak
4
4
 
5
- # Controller of keybreak processing
5
+ # Controller of key break processing
6
6
  class Controller
7
7
 
8
- # Generate an instance
8
+ # Generates an instance.
9
9
  def initialize()
10
10
  clear
11
11
  @handlers = {}
@@ -14,8 +14,8 @@ module Keybreak
14
14
  end
15
15
 
16
16
 
17
- # Registers the given block as a keybreak event handler
18
- # Valid keybreak events are:
17
+ # Registers the given block as a key break event handler.
18
+ # Valid events are:
19
19
  # :keystart
20
20
  # :keyend
21
21
  def on(event, &block)
@@ -23,11 +23,11 @@ module Keybreak
23
23
  end
24
24
 
25
25
 
26
- # Detects keybreak and calls the registered handlers
27
- # When a new key comes, call the keyend handler with the last key and value,
28
- # then call the keystart handler with the new key and value
29
- # For the first key feed, does not call the keyend handler
30
- # Use flush() to call the keyend handler for the last fed key
26
+ # Detects a key break and calls the registered handlers.
27
+ # When a new key comes, calls the :keyend handler with the last key and value,
28
+ # then call the :keystart handler with the new key and value.
29
+ # For the first key feed, does not call the :keyend handler.
30
+ # Use flush() to call the :keyend handler for the last fed key.
31
31
  def feed(key, *values)
32
32
  if @is_fed
33
33
  if key != @key
@@ -45,17 +45,17 @@ module Keybreak
45
45
  end
46
46
 
47
47
 
48
- # Clears internal data to the status before key feed starts
48
+ # Clears internal data to the status before key feed starts.
49
49
  def clear()
50
50
  @is_fed = false
51
51
  @values = []
52
52
  end
53
53
 
54
54
 
55
- # Calls the keyend handler once with the last fed key and value,
56
- # then clears internal data to the status before key feed starts
57
- # Place this method after the last feed() to complete keybreak process
58
- # Does nothing when no key has been fed
55
+ # Calls the :keyend handler once with the last fed key and value,
56
+ # then clears internal data to the status before key feed starts.
57
+ # Place this method after the last feed() to complete key break process.
58
+ # Does nothing when no key has been fed.
59
59
  def flush()
60
60
  if @is_fed
61
61
  @handlers[:keyend].call(@key, *@values)
@@ -65,9 +65,9 @@ module Keybreak
65
65
  end
66
66
 
67
67
 
68
- # Executes the given block and calls flush() finally
69
- # Place feed() within the block so that the keybreak handlers are
70
- # called for all keys including the last key
68
+ # Executes the given block and calls flush() finally.
69
+ # Place feed() within the block so that the key break handlers are
70
+ # called for all keys including the last key.
71
71
  def execute(&block)
72
72
  instance_eval(&block)
73
73
  self.flush
@@ -1,5 +1,5 @@
1
1
  module Keybreak
2
- # Version
3
- # MAJOR.MINOR.PATCH
4
- VERSION = "0.1.0"
2
+ # Version.
3
+ # MAJOR.MINOR.PATCH
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/keybreak.rb CHANGED
@@ -2,16 +2,16 @@
2
2
  require "keybreak/version"
3
3
  require "keybreak/controller"
4
4
 
5
- # Utilities for keybreak (control-break) processing
5
+ # Utilities for key break (control-break) processing
6
6
  module Keybreak
7
7
 
8
- # The block which does nothing
8
+ # The block which does nothing.
9
9
  DO_NOTHING = Proc.new {}
10
10
 
11
11
 
12
- # Executes the given block with a Controller instance
13
- # Within the block, register your keybreak handlers and feed keys from your data
14
- # Then the handlers will be called for all keys including the last key
12
+ # Executes the given block with a Controller instance.
13
+ # Within the block, register your key break handlers and feed keys from your data.
14
+ # Then the handlers will be called for all keys including the last key.
15
15
  def execute_with_controller(&block)
16
16
  Controller.new.execute(&block)
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keybreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hashimoton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: 1.9.3
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ! '>='
@@ -100,3 +100,4 @@ signing_key:
100
100
  specification_version: 4
101
101
  summary: Keybreak is a utility module for key break processing in Ruby.
102
102
  test_files: []
103
+ has_rdoc: