aipp 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +26 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +9 -0
  5. data/README.md +59 -7
  6. data/aipp.gemspec +3 -2
  7. data/lib/aipp.rb +2 -0
  8. data/lib/aipp/aip.rb +4 -12
  9. data/lib/aipp/downloader.rb +21 -21
  10. data/lib/aipp/executable.rb +4 -1
  11. data/lib/aipp/parser.rb +58 -5
  12. data/lib/aipp/regions/LF/AD-1.3.rb +27 -13
  13. data/lib/aipp/regions/LF/AD-1.6.rb +2 -2
  14. data/lib/aipp/regions/LF/AD-2.rb +30 -6
  15. data/lib/aipp/regions/LF/AD-3.1.rb +2 -2
  16. data/lib/aipp/regions/LF/ENR-2.1.rb +1 -1
  17. data/lib/aipp/regions/LF/ENR-4.1.rb +20 -78
  18. data/lib/aipp/regions/LF/ENR-4.3.rb +1 -1
  19. data/lib/aipp/regions/LF/ENR-5.1.rb +44 -26
  20. data/lib/aipp/regions/LF/ENR-5.5.rb +1 -1
  21. data/lib/aipp/regions/LF/helpers/{common.rb → base.rb} +2 -2
  22. data/lib/aipp/regions/LF/helpers/navigational_aid.rb +104 -0
  23. data/lib/aipp/regions/LF/helpers/{AD_radio.rb → radio_AD.rb} +24 -12
  24. data/lib/aipp/version.rb +1 -1
  25. data/lib/core_ext/object.rb +1 -1
  26. data/spec/fixtures/{archive.zip → source.zip} +0 -0
  27. data/spec/lib/aipp/airac_spec.rb +18 -18
  28. data/spec/lib/aipp/border_spec.rb +19 -19
  29. data/spec/lib/aipp/downloader_spec.rb +25 -25
  30. data/spec/lib/aipp/patcher_spec.rb +4 -4
  31. data/spec/lib/aipp/pdf_spec.rb +23 -23
  32. data/spec/lib/aipp/t_hash_spec.rb +6 -6
  33. data/spec/lib/aipp/version_spec.rb +1 -1
  34. data/spec/lib/core_ext/enumberable_spec.rb +15 -15
  35. data/spec/lib/core_ext/hash_spec.rb +4 -4
  36. data/spec/lib/core_ext/integer_spec.rb +2 -2
  37. data/spec/lib/core_ext/nil_class_spec.rb +1 -1
  38. data/spec/lib/core_ext/string_spec.rb +28 -28
  39. data/spec/spec_helper.rb +1 -0
  40. metadata +27 -12
  41. data/.travis.yml +0 -8
@@ -1,7 +1,7 @@
1
1
  module AIPP
2
2
  module LF
3
3
  module Helpers
4
- module ADRadio
4
+ module RadioAD
5
5
 
6
6
  # Service types to be ignored
7
7
  IGNORED_TYPES = %w(D-ATIS).freeze
@@ -15,16 +15,8 @@ module AIPP
15
15
  'SRE' => { type: :other, remarks: "SRE (elément radar de surveillance du PAR / surveillance radar element of PAR)" }
16
16
  }.freeze
17
17
 
18
- def parts_from(tds)
19
- {
20
- f: AIXM.f(tds[2].css('span').first.text.to_f, tds[2].css('span').last.text),
21
- callsign: tds[1].text.strip,
22
- timetable: tds[3].text.strip,
23
- remarks: tds[4].text.strip.sub(/Canal (8.33|25)/i, '') # TEMP: ignore canal spacing warnings
24
- }
25
- end
26
-
27
18
  def addresses_from(trs)
19
+ return [] if trs.text.blank?
28
20
  trs.map do |tr|
29
21
  tds = tr.css('td')
30
22
  type = tds[0].text.strip
@@ -43,11 +35,20 @@ module AIPP
43
35
  end
44
36
 
45
37
  def units_from(trs)
38
+ return [] if trs.text.blank?
46
39
  trs.each_with_object({}) do |tr, services|
47
40
  tds = tr.css('td')
48
41
  type = tds[0].text.strip
49
42
  next if IGNORED_TYPES.include?(type) || ADDRESS_TYPES.include?(type)
50
- f, callsign, timetable, remarks = parts_from(tds).values
43
+ f, callsigns, timetable, remarks = parts_from(tds).values
44
+ callsigns = if callsigns.match?(/\(\w{2}\)/)
45
+ callsigns.cleanup.split("\n").each_with_object({}) do |callsign, hash|
46
+ callsign =~ /^(.*)\s+\((\w{2})\)/
47
+ hash[$2.downcase.to_sym] = $1
48
+ end
49
+ else
50
+ { fr: callsigns }
51
+ end
51
52
  if SERVICE_TYPES.include? type
52
53
  type = SERVICE_TYPES.dig(type, :type)
53
54
  remarks = [SERVICE_TYPES.dig(type, :remarks), remarks.blank_to_nil].compact.join("\n")
@@ -62,7 +63,7 @@ module AIPP
62
63
  services[type].add_frequency(
63
64
  AIXM.frequency(
64
65
  transmission_f: f,
65
- callsigns: { fr: callsign }
66
+ callsigns: callsigns
66
67
  ).tap do |frequency|
67
68
  frequency.type = :standard
68
69
  frequency.type = :alternative if remarks.sub!(%r{fréquence supplétive/auxiliary frequency\S*}i, '')
@@ -84,6 +85,17 @@ module AIPP
84
85
  end
85
86
  end
86
87
 
88
+ private
89
+
90
+ def parts_from(tds)
91
+ {
92
+ f: AIXM.f(tds[2].css('span').first.text.to_f, tds[2].css('span').last.text),
93
+ callsign: tds[1].text.strip,
94
+ timetable: tds[3].text.strip,
95
+ remarks: tds[4].text.strip.sub(/Canal (8.33|25)/i, '') # TEMP: ignore canal spacing warnings
96
+ }
97
+ end
98
+
87
99
  end
88
100
  end
89
101
  end
@@ -1,3 +1,3 @@
1
1
  module AIPP
2
- VERSION = "0.2.4".freeze
2
+ VERSION = "0.2.5".freeze
3
3
  end
@@ -15,7 +15,7 @@ class Object
15
15
  # @param message [String] warning message
16
16
  # @param pry [Exception, Binding, nil] attach the Pry session to this error
17
17
  # or binding
18
- def warn(message, pry:)
18
+ def warn(message, pry: nil)
19
19
  $WARN_COUNTER = $WARN_COUNTER.to_i + 1
20
20
  Kernel.warn "WARNING #{$WARN_COUNTER}: #{message}".red
21
21
  if $PRY_ON_WARN == true || $PRY_ON_WARN == $WARN_COUNTER
@@ -3,8 +3,8 @@ require_relative '../../spec_helper'
3
3
  describe AIPP::AIRAC do
4
4
  describe :initialize do
5
5
  it "won't accept invalid arguments" do
6
- -> { AIPP::AIRAC.new(0) }.must_raise ArgumentError
7
- -> { AIPP::AIRAC.new(AIPP::AIRAC::ROOT_DATE - 1) }.must_raise ArgumentError
6
+ _{ AIPP::AIRAC.new(0) }.must_raise ArgumentError
7
+ _{ AIPP::AIRAC.new(AIPP::AIRAC::ROOT_DATE - 1) }.must_raise ArgumentError
8
8
  end
9
9
  end
10
10
 
@@ -14,19 +14,19 @@ describe AIPP::AIRAC do
14
14
  end
15
15
 
16
16
  it "must calculate correct #date" do
17
- subject.date.must_equal Date.parse('2018-01-04')
17
+ _(subject.date).must_equal Date.parse('2018-01-04')
18
18
  end
19
19
 
20
20
  it "must calculate correct #id" do
21
- subject.id.must_equal 1801
21
+ _(subject.id).must_equal 1801
22
22
  end
23
23
 
24
24
  it "must calculate correct #next_date" do
25
- subject.next_date.must_equal Date.parse('2018-02-01')
25
+ _(subject.next_date).must_equal Date.parse('2018-02-01')
26
26
  end
27
27
 
28
28
  it "must calculate correct #next_id" do
29
- subject.next_id.must_equal 1802
29
+ _(subject.next_id).must_equal 1802
30
30
  end
31
31
  end
32
32
 
@@ -36,19 +36,19 @@ describe AIPP::AIRAC do
36
36
  end
37
37
 
38
38
  it "must calculate correct #date" do
39
- subject.date.must_equal Date.parse('2017-12-07')
39
+ _(subject.date).must_equal Date.parse('2017-12-07')
40
40
  end
41
41
 
42
42
  it "must calculate correct #id" do
43
- subject.id.must_equal 1713
43
+ _(subject.id).must_equal 1713
44
44
  end
45
45
 
46
46
  it "must calculate correct #next_date" do
47
- subject.next_date.must_equal Date.parse('2018-01-04')
47
+ _(subject.next_date).must_equal Date.parse('2018-01-04')
48
48
  end
49
49
 
50
50
  it "must calculate correct #next_id" do
51
- subject.next_id.must_equal 1801
51
+ _(subject.next_id).must_equal 1801
52
52
  end
53
53
  end
54
54
 
@@ -58,19 +58,19 @@ describe AIPP::AIRAC do
58
58
  end
59
59
 
60
60
  it "must calculate correct #date" do
61
- subject.date.must_equal Date.parse('2018-01-04')
61
+ _(subject.date).must_equal Date.parse('2018-01-04')
62
62
  end
63
63
 
64
64
  it "must calculate correct #id" do
65
- subject.id.must_equal 1801
65
+ _(subject.id).must_equal 1801
66
66
  end
67
67
 
68
68
  it "must calculate correct #next_date" do
69
- subject.next_date.must_equal Date.parse('2018-02-01')
69
+ _(subject.next_date).must_equal Date.parse('2018-02-01')
70
70
  end
71
71
 
72
72
  it "must calculate correct #next_id" do
73
- subject.next_id.must_equal 1802
73
+ _(subject.next_id).must_equal 1802
74
74
  end
75
75
  end
76
76
 
@@ -80,19 +80,19 @@ describe AIPP::AIRAC do
80
80
  end
81
81
 
82
82
  it "must calculate correct #date" do
83
- subject.date.must_equal Date.parse('2020-12-31')
83
+ _(subject.date).must_equal Date.parse('2020-12-31')
84
84
  end
85
85
 
86
86
  it "must calculate correct #id" do
87
- subject.id.must_equal 2014
87
+ _(subject.id).must_equal 2014
88
88
  end
89
89
 
90
90
  it "must calculate correct #next_date" do
91
- subject.next_date.must_equal Date.parse('2021-01-28')
91
+ _(subject.next_date).must_equal Date.parse('2021-01-28')
92
92
  end
93
93
 
94
94
  it "must calculate correct #next_id" do
95
- subject.next_id.must_equal 2101
95
+ _(subject.next_id).must_equal 2101
96
96
  end
97
97
  end
98
98
  end
@@ -14,15 +14,15 @@ describe AIPP::Border::Position do
14
14
 
15
15
  describe :xy do
16
16
  it "returns the coordinates" do
17
- subject.xy.must_equal AIXM.xy(long: 0, lat: 0)
17
+ _(subject.xy).must_equal AIXM.xy(long: 0, lat: 0)
18
18
  end
19
19
 
20
20
  it "returns nil if the geometry index is out of bounds" do
21
- subject.tap { |s| s.geometry_index = 2 }.xy.must_be_nil
21
+ _(subject.tap { |s| s.geometry_index = 2 }.xy).must_be_nil
22
22
  end
23
23
 
24
24
  it "returns nil if the coordinates index is out of bounds" do
25
- subject.tap { |s| s.coordinates_index = 3 }.xy.must_be_nil
25
+ _(subject.tap { |s| s.coordinates_index = 3 }.xy).must_be_nil
26
26
  end
27
27
  end
28
28
  end
@@ -43,25 +43,25 @@ describe AIPP::Border do
43
43
 
44
44
  describe :initialize do
45
45
  it "fails for files unless the extension is .geojson" do
46
- -> { AIPP::Border.new("/path/to/another.txt") }.must_raise ArgumentError
46
+ _{ AIPP::Border.new("/path/to/another.txt") }.must_raise ArgumentError
47
47
  end
48
48
  end
49
49
 
50
50
  describe :name do
51
51
  it "returns the upcased file name" do
52
- subject.name.must_equal 'BORDER'
52
+ _(subject.name).must_equal 'BORDER'
53
53
  end
54
54
  end
55
55
 
56
56
  describe :closed? do
57
57
  it "returns true for closed geometries" do
58
- subject.closed?(geometry_index: 0).must_equal true
59
- subject.closed?(geometry_index: 1).must_equal true
58
+ _(subject.closed?(geometry_index: 0)).must_equal true
59
+ _(subject.closed?(geometry_index: 1)).must_equal true
60
60
  end
61
61
 
62
62
  it "returns false for unclosed geometries" do
63
- subject.closed?(geometry_index: 2).must_equal false
64
- subject.closed?(geometry_index: 3).must_equal false
63
+ _(subject.closed?(geometry_index: 2)).must_equal false
64
+ _(subject.closed?(geometry_index: 3)).must_equal false
65
65
  end
66
66
  end
67
67
 
@@ -72,16 +72,16 @@ describe AIPP::Border do
72
72
 
73
73
  it "finds the nearest position on any geometry" do
74
74
  position = subject.nearest(xy: point)
75
- position.geometry_index.must_equal 1
76
- position.coordinates_index.must_equal 12
77
- position.xy.must_equal AIXM.xy(lat: 44.01065725159039, long: 4.760427474975586)
75
+ _(position.geometry_index).must_equal 1
76
+ _(position.coordinates_index).must_equal 12
77
+ _(position.xy).must_equal AIXM.xy(lat: 44.01065725159039, long: 4.760427474975586)
78
78
  end
79
79
 
80
80
  it "finds the nearest postition on a given geometry" do
81
81
  position = subject.nearest(xy: point, geometry_index: 0)
82
- position.geometry_index.must_equal 0
83
- position.coordinates_index.must_equal 2
84
- position.xy.must_equal AIXM.xy(lat: 44.00269350325321, long: 4.7519731521606445)
82
+ _(position.geometry_index).must_equal 0
83
+ _(position.coordinates_index).must_equal 2
84
+ _(position.xy).must_equal AIXM.xy(lat: 44.00269350325321, long: 4.7519731521606445)
85
85
  end
86
86
  end
87
87
 
@@ -89,13 +89,13 @@ describe AIPP::Border do
89
89
  it "fails if positions are not on the same geometry" do
90
90
  from_position = AIPP::Border::Position.new(geometries: subject.geometries, geometry_index: 0, coordinates_index: 0)
91
91
  to_position = AIPP::Border::Position.new(geometries: subject.geometries, geometry_index: 1, coordinates_index: 0)
92
- -> { subject.segment(from_position: from_position, to_position: to_position) }.must_raise ArgumentError
92
+ _{ subject.segment(from_position: from_position, to_position: to_position) }.must_raise ArgumentError
93
93
  end
94
94
 
95
95
  it "returns shortest segment on an unclosed I-shaped geometry" do
96
96
  from_position = subject.nearest(xy: AIXM.xy(lat: 44.002940457248556, long: 4.734249114990234))
97
97
  to_position = subject.nearest(xy: AIXM.xy(lat: 44.07155380033749, long: 4.7687530517578125), geometry_index: from_position.geometry_index)
98
- subject.segment(from_position: from_position, to_position: to_position).must_equal [
98
+ _(subject.segment(from_position: from_position, to_position: to_position)).must_equal [
99
99
  AIXM.xy(lat: 44.00516299694704, long: 4.7371673583984375),
100
100
  AIXM.xy(lat: 44.02195282780904, long: 4.743347167968749),
101
101
  AIXM.xy(lat: 44.037503870182896, long: 4.749870300292969),
@@ -107,7 +107,7 @@ describe AIPP::Border do
107
107
  it "returns shortest segment on an unclosed U-shaped geometry" do
108
108
  from_position = subject.nearest(xy: AIXM.xy(lat: 43.96563876212758, long: 4.8126983642578125))
109
109
  to_position = subject.nearest(xy: AIXM.xy(lat: 43.956989327857265, long: 4.83123779296875), geometry_index: from_position.geometry_index)
110
- subject.segment(from_position: from_position, to_position: to_position).must_equal [
110
+ _(subject.segment(from_position: from_position, to_position: to_position)).must_equal [
111
111
  AIXM.xy(lat: 43.9646503190861, long: 4.815788269042969),
112
112
  AIXM.xy(lat: 43.98614524381678, long: 4.82025146484375),
113
113
  AIXM.xy(lat: 43.98491011404692, long: 4.840850830078125),
@@ -122,7 +122,7 @@ describe AIPP::Border do
122
122
  it "returns shortest segment ignoring endings on a closed geometry" do
123
123
  from_position = subject.nearest(xy: AIXM.xy(lat: 44.00022390676026, long: 4.789009094238281))
124
124
  to_position = subject.nearest(xy: AIXM.xy(lat: 43.99800118202362, long: 4.765834808349609), geometry_index: from_position.geometry_index)
125
- subject.segment(from_position: from_position, to_position: to_position).must_equal [
125
+ _(subject.segment(from_position: from_position, to_position: to_position)).must_equal [
126
126
  AIXM.xy(lat: 44.00077957493397, long: 4.787635803222656),
127
127
  AIXM.xy(lat: 43.99818641226534, long: 4.784030914306641),
128
128
  AIXM.xy(lat: 43.994111213373934, long: 4.78205680847168),
@@ -7,8 +7,8 @@ describe AIPP::Downloader do
7
7
 
8
8
  let :tmp_dir do
9
9
  Pathname(Dir.mktmpdir).tap do |tmp_dir|
10
- (archives_dir = tmp_dir.join('archives')).mkpath
11
- FileUtils.cp(fixtures_dir.join('archive.zip'), archives_dir)
10
+ (sources_dir = tmp_dir.join('sources')).mkpath
11
+ FileUtils.cp(fixtures_dir.join('source.zip'), sources_dir)
12
12
  end
13
13
  end
14
14
 
@@ -17,58 +17,58 @@ describe AIPP::Downloader do
17
17
  end
18
18
 
19
19
  describe :read do
20
- context "archive does not exist" do
21
- it "creates the archive" do
20
+ context "source archive does not exist" do
21
+ it "creates the source archive" do
22
22
  Spy.on(Kernel, open: File.open(fixtures_dir.join('new.html')))
23
- subject = AIPP::Downloader.new(storage: tmp_dir, archive: 'new-archive') do |downloader|
24
- File.exist?(tmp_dir.join('work')).must_equal true
23
+ subject = AIPP::Downloader.new(storage: tmp_dir, source: 'new-source') do |downloader|
24
+ _(File.exist?(tmp_dir.join('work'))).must_equal true
25
25
  downloader.read(document: 'new', url: 'http://localhost/new.html')
26
26
  end
27
- zip_entries(subject.archive_file).must_equal %w(new.html)
28
- subject.send(:archives_path).children.count.must_equal 2
27
+ _(zip_entries(subject.source_file)).must_equal %w(new.html)
28
+ _(subject.send(:sources_path).children.count).must_equal 2
29
29
  end
30
30
  end
31
31
 
32
- context "archive does exist" do
33
- it "unzips and uses the archive" do
32
+ context "source archive does exist" do
33
+ it "unzips and uses the source archive" do
34
34
  Spy.on(Kernel, open: File.open(fixtures_dir.join('new.html')))
35
- subject = AIPP::Downloader.new(storage: tmp_dir, archive: 'archive') do |downloader|
36
- File.exist?(tmp_dir.join('work')).must_equal true
35
+ subject = AIPP::Downloader.new(storage: tmp_dir, source: 'source') do |downloader|
36
+ _(File.exist?(tmp_dir.join('work'))).must_equal true
37
37
  downloader.read(document: 'new', url: 'http://localhost/new.html').tap do |content|
38
- content.must_be_instance_of Nokogiri::HTML5::Document
39
- content.text.must_match /fixture-html-new/
38
+ _(content).must_be_instance_of Nokogiri::HTML5::Document
39
+ _(content.text).must_match /fixture-html-new/
40
40
  end
41
41
  end
42
- zip_entries(subject.archive_file).must_equal %w(new.html one.html two.html)
43
- subject.send(:archives_path).children.count.must_equal 1
42
+ _(zip_entries(subject.source_file)).must_equal %w(new.html one.html two.html)
43
+ _(subject.send(:sources_path).children.count).must_equal 1
44
44
  end
45
45
 
46
46
  it "downloads HTML documents to Nokogiri::HTML5::Document" do
47
47
  Spy.on(Kernel, open: File.open(fixtures_dir.join('new.html')))
48
- AIPP::Downloader.new(storage: tmp_dir, archive: 'archive') do |downloader|
48
+ AIPP::Downloader.new(storage: tmp_dir, source: 'source') do |downloader|
49
49
  downloader.read(document: 'new', url: 'http://localhost/new.html').tap do |content|
50
- content.must_be_instance_of Nokogiri::HTML5::Document
51
- content.text.must_match /fixture-html-new/
50
+ _(content).must_be_instance_of Nokogiri::HTML5::Document
51
+ _(content.text).must_match /fixture-html-new/
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
56
  it "downloads and caches PDF documents to AIPP::PDF" do
57
57
  Spy.on(Kernel, open: File.open(fixtures_dir.join('new.pdf')))
58
- AIPP::Downloader.new(storage: tmp_dir, archive: 'archive') do |downloader|
58
+ AIPP::Downloader.new(storage: tmp_dir, source: 'source') do |downloader|
59
59
  downloader.read(document: 'new', url: 'http://localhost/new.pdf').tap do |content|
60
- content.must_be_instance_of AIPP::PDF
61
- content.text.must_match /fixture-pdf-new/
60
+ _(content).must_be_instance_of AIPP::PDF
61
+ _(content.text).must_match /fixture-pdf-new/
62
62
  end
63
63
  end
64
64
  end
65
65
 
66
66
  it "downloads explicitly specified type" do
67
67
  Spy.on(Kernel, open: File.open(fixtures_dir.join('new.pdf')))
68
- AIPP::Downloader.new(storage: tmp_dir, archive: 'archive') do |downloader|
68
+ AIPP::Downloader.new(storage: tmp_dir, source: 'source') do |downloader|
69
69
  downloader.read(document: 'new', url: 'http://localhost/new', type: :pdf).tap do |content|
70
- content.must_be_instance_of AIPP::PDF
71
- content.text.must_match /fixture-pdf-new/
70
+ _(content).must_be_instance_of AIPP::PDF
71
+ _(content.text).must_match /fixture-pdf-new/
72
72
  end
73
73
  end
74
74
  end
@@ -25,22 +25,22 @@ describe AIPP::Patcher do
25
25
  end
26
26
 
27
27
  it "overwrites with non-nil values" do
28
- subject.tap { |s| s.size = 'S' }.size.must_equal 36
28
+ _(subject.tap { |s| s.size = 'S' }.size).must_equal 36
29
29
  end
30
30
 
31
31
  it "overwrite with nil values" do
32
- subject.tap { |s| s.size = 'one-size-fits-all' }.size.must_be_nil
32
+ _(subject.tap { |s| s.size = 'one-size-fits-all' }.size).must_be_nil
33
33
  end
34
34
 
35
35
  it "skips overwrite if abort is thrown" do
36
- subject.tap { |s| s.size = 42 }.size.must_equal 42
36
+ _(subject.tap { |s| s.size = 42 }.size).must_equal 42
37
37
  end
38
38
  end
39
39
 
40
40
  context "with patches detached" do
41
41
  it "removes patches" do
42
42
  subject.detach_patches
43
- subject.tap { |s| s.size = 'S' }.size.must_equal 'S'
43
+ _(subject.tap { |s| s.size = 'S' }.size).must_equal 'S'
44
44
  end
45
45
  end
46
46
  end
@@ -11,47 +11,47 @@ describe AIPP::PDF do
11
11
 
12
12
  describe :@page_ranges do
13
13
  it "returns an array of page end positions" do
14
- subject.instance_variable_get(:@page_ranges).must_equal [74, 149, 225]
14
+ _(subject.instance_variable_get(:@page_ranges)).must_equal [74, 149, 225]
15
15
  end
16
16
  end
17
17
 
18
18
  describe :page_for do
19
19
  it "finds the page for any given position" do
20
- subject.send(:page_for, index: 0).must_equal 1
21
- subject.send(:page_for, index: 50).must_equal 1
22
- subject.send(:page_for, index: 74).must_equal 1
23
- subject.send(:page_for, index: 75).must_equal 2
24
- subject.send(:page_for, index: 149).must_equal 2
25
- subject.send(:page_for, index: 150).must_equal 3
26
- subject.send(:page_for, index: 223).must_equal 3
20
+ _(subject.send(:page_for, index: 0)).must_equal 1
21
+ _(subject.send(:page_for, index: 50)).must_equal 1
22
+ _(subject.send(:page_for, index: 74)).must_equal 1
23
+ _(subject.send(:page_for, index: 75)).must_equal 2
24
+ _(subject.send(:page_for, index: 149)).must_equal 2
25
+ _(subject.send(:page_for, index: 150)).must_equal 3
26
+ _(subject.send(:page_for, index: 223)).must_equal 3
27
27
  end
28
28
  end
29
29
 
30
30
  describe :from do
31
31
  it "fences beginning to any position" do
32
- subject.from(100).range.must_equal (100..223)
32
+ _(subject.from(100).range).must_equal (100..223)
33
33
  end
34
34
 
35
35
  it "fences beginning to first existing position" do
36
- subject.from(:begin).range.must_equal (0..223)
36
+ _(subject.from(:begin).range).must_equal (0..223)
37
37
  end
38
38
  end
39
39
 
40
40
  describe :to do
41
41
  it "fences beginning to any position" do
42
- subject.to(100).range.must_equal (0..100)
42
+ _(subject.to(100).range).must_equal (0..100)
43
43
  end
44
44
 
45
45
  it "fences beginning to first existing position" do
46
- subject.to(:end).range.must_equal (0..223)
46
+ _(subject.to(:end).range).must_equal (0..223)
47
47
  end
48
48
  end
49
49
 
50
50
  context "without boundaries" do
51
51
  describe :text do
52
52
  it "returns the entire text" do
53
- subject.text.must_match /\Apage 1, line 1/
54
- subject.text.must_match /page 3, line 5\z/
53
+ _(subject.text).must_match /\Apage 1, line 1/
54
+ _(subject.text).must_match /page 3, line 5\z/
55
55
  end
56
56
  end
57
57
 
@@ -76,14 +76,14 @@ describe AIPP::PDF do
76
76
  ]
77
77
  subject.each_line do |line, page, last|
78
78
  target_line, target_page, target_last = target.shift
79
- line.must_equal target_line
80
- page.must_equal target_page
81
- last.must_equal target_last
79
+ _(line).must_equal target_line
80
+ _(page).must_equal target_page
81
+ _(last).must_equal target_last
82
82
  end
83
83
  end
84
84
 
85
85
  it "returns an enumerator if no block is given" do
86
- subject.each_line.must_be_instance_of Enumerator
86
+ _(subject.each_line).must_be_instance_of Enumerator
87
87
  end
88
88
  end
89
89
  end
@@ -95,8 +95,8 @@ describe AIPP::PDF do
95
95
 
96
96
  describe :text do
97
97
  it "returns the entire text" do
98
- subject.text.must_match /\Ane 2/
99
- subject.text.must_match /page 3\z/
98
+ _(subject.text).must_match /\Ane 2/
99
+ _(subject.text).must_match /page 3\z/
100
100
  end
101
101
  end
102
102
 
@@ -114,9 +114,9 @@ describe AIPP::PDF do
114
114
  ]
115
115
  subject.each_line do |line, page, last|
116
116
  target_line, target_page, target_last = target.shift
117
- line.must_equal target_line
118
- page.must_equal target_page
119
- last.must_equal target_last
117
+ _(line).must_equal target_line
118
+ _(page).must_equal target_page
119
+ _(last).must_equal target_last
120
120
  end
121
121
  end
122
122
  end