yoga 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yoga/location.rb +19 -24
- data/lib/yoga/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07e30449516ea2a36d8b765b9da9d08d17b3677b
|
4
|
+
data.tar.gz: ca0b935fedcd9ebb0213e4650b5d6d9932c450ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0041c1f6f886b0218b7f4cb8f86f94a9c33e659ce81bd24c995755fcb872f08ee1c0b58d67be675ac71462aa8897c4d5a7fb336f7c3062ce1c597f8d96d35cf8
|
7
|
+
data.tar.gz: c7dea5a35e57f5490fcf4d5c93f0736276d44ce92dd7edd2b33261ea0fa8514c87777b8ce10a2cb309db8513f5056b7ccbe0dad2df05af411227065231d70ee8
|
data/lib/yoga/location.rb
CHANGED
@@ -91,6 +91,9 @@ module Yoga
|
|
91
91
|
@line == other.line && @column == other.column
|
92
92
|
end
|
93
93
|
|
94
|
+
# rubocop:disable Metrics/AbcSize
|
95
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
96
|
+
|
94
97
|
# Unions this location with another location. This creates a new location,
|
95
98
|
# with the two locations combined. A conflict in the file name causes an
|
96
99
|
# error to be raised.
|
@@ -117,36 +120,28 @@ module Yoga
|
|
117
120
|
# @raise [::ArgumentError] if other's file isn't the receiver's file.
|
118
121
|
# @param others [Location]
|
119
122
|
# @return [Location]
|
120
|
-
def union(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
line =
|
129
|
-
|
130
|
-
|
131
|
-
|
123
|
+
def union(other)
|
124
|
+
fail ArgumentError, "Expected #{self.class}, got #{other.class}" \
|
125
|
+
unless other.is_a?(Location)
|
126
|
+
|
127
|
+
oline = other.line
|
128
|
+
ocolumn = other.column
|
129
|
+
|
130
|
+
file = @file == other.file ? @file : "<unknown>"
|
131
|
+
line =
|
132
|
+
(@line.first < oline.first ? @line.first : oline.first)..
|
133
|
+
(@line.last > oline.last ? @line.last : oline.last)
|
134
|
+
column =
|
135
|
+
(@column.first < ocolumn.first ? @column.first : ocolumn.first)..
|
136
|
+
(@column.last > ocolumn.last ? @column.last : ocolumn.last)
|
137
|
+
|
138
|
+
Location.new(file, line, column)
|
132
139
|
end
|
133
140
|
|
134
141
|
alias_method :|, :union
|
135
142
|
|
136
143
|
private
|
137
144
|
|
138
|
-
# Creates a range from a list of ranges. This takes the lowest starting
|
139
|
-
# value, and the greatest ending value, and creates a new range from that.
|
140
|
-
#
|
141
|
-
# @param from [<::Range<::Numeric>>]
|
142
|
-
# @return [::Range<::Numeric>]
|
143
|
-
def construct_range(from)
|
144
|
-
first = from.map(&:first).min
|
145
|
-
last = from.map(&:last).max
|
146
|
-
|
147
|
-
first..last
|
148
|
-
end
|
149
|
-
|
150
145
|
# Ensures that the given value is a range. If it's numeric, it's turned
|
151
146
|
# into a range with the same starting and ending values. If it's a range,
|
152
147
|
# it's returned. Otherwise, it fails.
|
data/lib/yoga/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yoga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixture
|