ikku 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: b3096ad7728dd91f17e2176eed31a6a5cf7b9666
4
- data.tar.gz: a9a26afdf48c5a96da3e4e963442aefe19744916
3
+ metadata.gz: 0fad5f8882e7062dc3e4cdd954a07a07c332a86d
4
+ data.tar.gz: 886dfe82a320a73477f9dfff09717823e7c80cda
5
5
  SHA512:
6
- metadata.gz: 0b455889d0947433f9124f57ec84d4198e284d2e9e273a24b33aa3039e879bc8c811073beacb6951a865f58e8e1444ea83489c83fdf0015b662922731e9f5cfd
7
- data.tar.gz: 91ecfbb73a4a8cd7186443d3f4adebdb933ddcab0cbc06e7a2239144092727469400eb14e450fd01de6708f028a76497d748715cd14f743fbeeae9a35d02656e
6
+ metadata.gz: 2a1bf91e575a441add860f54a169fc4b8e8831561ade68488e9fb0535326c7005b31ba6f0c14a934dce8e9595d7a43c17cf85709d75a5e627825a3e896e979db
7
+ data.tar.gz: cee5602f834f94b46077e570ec3788353e7c88b6b6bbe023938d26a5fd4f6951f9e0ba92a4ae01aa5276cc8b29629fae3f5ee5d3a9739be9afd5a8540c07ddb3
@@ -1,3 +1,6 @@
1
+ ## 0.1.1
2
+ - Fix bracket bug
3
+
1
4
  ## 0.1.0
2
5
  - Change some reviewer methods to return `Ikku::Song`
3
6
  - Don't allow song with odd parentheses
@@ -1,24 +1,36 @@
1
1
  module Ikku
2
2
  class BracketState
3
- TABLE = {
4
- "" => "",
5
- "" => "",
6
- "" => "",
7
- ")" => "(",
8
- "" => "",
9
- "]" => "[",
10
- "}" => "{",
11
- "" => "",
12
- "" => "",
13
- "" => "",
14
- "" => "",
15
- "" => "",
16
- "" => "",
17
- "" => "",
18
- ">" => "<",
19
- "" => "",
3
+ BRACKETS_TABLE = {
4
+ "" => "",
5
+ "" => "",
6
+ "" => "",
7
+ "(" => ")",
8
+ "" => "",
9
+ "[" => "]",
10
+ "{" => "}",
11
+ "" => "",
12
+ "" => "",
13
+ "" => "",
14
+ "" => "",
15
+ "" => "",
16
+ "" => "",
17
+ "" => "",
18
+ "<" => ">",
19
+ "" => "",
20
20
  }
21
21
 
22
+ class << self
23
+ def brackets_index
24
+ @brackets_index ||= BRACKETS_TABLE.to_a.flatten.inject({}) do |hash, bracket|
25
+ hash.merge(bracket => true)
26
+ end
27
+ end
28
+
29
+ def inverted_brackets_table
30
+ @inverted_brackets_table ||= BRACKETS_TABLE.invert
31
+ end
32
+ end
33
+
22
34
  def consume_all(surfaces)
23
35
  surfaces.each do |surface|
24
36
  consume(surface)
@@ -34,10 +46,10 @@ module Ikku
34
46
 
35
47
  def consume(surface)
36
48
  case
37
- when TABLE.values.include?(surface)
38
- stack.push(surface)
39
- when TABLE.include?(surface) && stack.last == TABLE[surface]
49
+ when !stack.last.nil? && self.class.inverted_brackets_table[surface] == stack.last
40
50
  stack.pop
51
+ when self.class.brackets_index.include?(surface)
52
+ stack.push(surface)
41
53
  end
42
54
  end
43
55
 
@@ -1,3 +1,3 @@
1
1
  module Ikku
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ikku
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
  - Ryo Nakamura