acrosslite 0.2.1 → 0.3.0

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.
data/lib/acrosslite.rb CHANGED
@@ -6,7 +6,7 @@ class Acrosslite
6
6
  attr_accessor :copyright, :title, :author
7
7
  attr_reader :across, :down, :solution, :diagram, :filepath
8
8
 
9
- VERSION = '0.2.1'
9
+ VERSION = '0.3.0'
10
10
 
11
11
  ACROSSLITE = 2
12
12
  ROWS = 44
@@ -53,7 +53,7 @@ class Acrosslite
53
53
 
54
54
  def rows
55
55
  unless @rows
56
- @content_io.seek(ROWS)
56
+ @content_io.seek(ROWS, 0)
57
57
  @rows = @content_io.read(1).unpack('C').first
58
58
  end
59
59
  @rows
@@ -61,7 +61,7 @@ class Acrosslite
61
61
 
62
62
  def columns
63
63
  unless @columns
64
- @content_io.seek(COLUMNS)
64
+ @content_io.seek(COLUMNS, 0)
65
65
  @columns = @content_io.read(1).unpack('C').first
66
66
  end
67
67
  @columns
@@ -69,12 +69,12 @@ class Acrosslite
69
69
 
70
70
  def solution
71
71
  width = columns
72
+ height = rows
72
73
 
73
- # if @solution.empty?
74
- unless @solution.size == rows
75
- @content_io.seek(SOLUTION)
74
+ if @solution.empty?
75
+ @content_io.seek(SOLUTION, 0)
76
76
 
77
- rows.times do |r|
77
+ height.times do |r|
78
78
  @solution << @content_io.read(width).unpack("C#{width}").map {|c| c.chr}
79
79
  end
80
80
  end
@@ -83,11 +83,12 @@ class Acrosslite
83
83
 
84
84
  def diagram
85
85
  width = columns
86
+ height = rows
86
87
 
87
88
  if @diagram.empty?
88
- @content_io.seek(SOLUTION + rows * width)
89
+ @content_io.seek(SOLUTION + height * width, 0)
89
90
 
90
- rows.times do |r|
91
+ height.times do |r|
91
92
  @diagram << @content_io.read(width).unpack("C#{width}").map {|c| c.chr}
92
93
  end
93
94
  end
@@ -177,7 +178,7 @@ following attributes: rows, columns, solution, diagram, title, author, copyright
177
178
  def parse
178
179
  clues = Array.new
179
180
 
180
- @content_io.seek(SOLUTION + area + area)
181
+ @content_io.seek(SOLUTION + area + area, 0)
181
182
 
182
183
  @title = next_field
183
184
  @author = next_field
@@ -191,11 +192,11 @@ following attributes: rows, columns, solution, diagram, title, author, copyright
191
192
  #----- determine answers -----#
192
193
  across_clue = down_clue = 1 # clue_number: incremented only in "down" area
193
194
 
194
- 0.upto(rows - 1) do |r|
195
- 0.upto(columns - 1) do |c|
196
- next if solution[r][c] =~ /[.:]/
195
+ rows.times do |r|
196
+ columns.times do |c|
197
+ next if diagram[r][c] =~ /[.:]/
197
198
 
198
- if c - 1 < 0 || solution[r][c - 1] == "."
199
+ if (c - 1 < 0 || diagram[r][c - 1] == ".") && (c + 1 < columns && diagram[r][c + 1] != ".")
199
200
  entry = Acrosslite::Entry.new
200
201
  answer = ''
201
202
 
@@ -223,7 +224,7 @@ following attributes: rows, columns, solution, diagram, title, author, copyright
223
224
  end
224
225
  end
225
226
 
226
- if r - 1 < 0 || solution[r - 1][c] == "."
227
+ if (r - 1 < 0 || diagram[r - 1][c] == ".") && (r + 1 < rows && diagram[r + 1][c] != ".")
227
228
  entry = Acrosslite::Entry.new
228
229
  answer = ''
229
230
 
@@ -8,7 +8,7 @@ describe Acrosslite do
8
8
  @example_files[:halloween] = File.join(basedir, "files/halloween2009.puz")
9
9
  @example_files[:crnet] = File.join(basedir, "files/crnet100306.puz")
10
10
  @example_files[:tmcal] = File.join(basedir, "files/tmcal100306.puz")
11
- @example_files[:xp] = File.join(basedir, "files/xp100306.puz")
11
+ @example_files[:xp] = File.join(basedir, "files/xp110316.puz")
12
12
  @example_files[:ydx] = File.join(basedir, "files/ydx100515.puz")
13
13
  end
14
14
 
@@ -21,7 +21,6 @@ describe Acrosslite do
21
21
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
22
22
  # Builder Tests
23
23
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
24
-
25
24
  it "should instantiate the puzzle with passing of file" do
26
25
  ac = Acrosslite.new(:filepath => @example_files[:halloween])
27
26
  ac.should be_an_instance_of Acrosslite
Binary file
Binary file
Binary file
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Samuel Mullen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-15 00:00:00 -05:00
17
+ date: 2010-06-17 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -46,9 +46,11 @@ files:
46
46
  - spec/acrosslite_spec.rb
47
47
  - spec/files/tmcal100306.puz
48
48
  - spec/files/crnet100306.puz
49
+ - spec/files/xp110316.puz
49
50
  - spec/files/halloween2009.puz
51
+ - spec/files/jnz100601.puz
50
52
  - spec/files/ydx100515.puz
51
- - spec/files/xp100306.puz
53
+ - spec/files/can100607.puz
52
54
  has_rdoc: true
53
55
  homepage: http://github.com/samullen/acrosslite
54
56
  licenses: []
@@ -83,6 +85,8 @@ test_files:
83
85
  - spec/acrosslite_spec.rb
84
86
  - spec/files/tmcal100306.puz
85
87
  - spec/files/crnet100306.puz
88
+ - spec/files/xp110316.puz
86
89
  - spec/files/halloween2009.puz
90
+ - spec/files/jnz100601.puz
87
91
  - spec/files/ydx100515.puz
88
- - spec/files/xp100306.puz
92
+ - spec/files/can100607.puz
Binary file