jit 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/lib/config.rb +16 -6
  3. data/lib/index.rb +9 -4
  4. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aa9a39f5359292f9749f7103c29f3a6eadf1dfc1
4
- data.tar.gz: 061d790a80ac6f7307a749527c4683f95c28b7d3
2
+ SHA256:
3
+ metadata.gz: 3456259298664412f5d90d68ba0a102320bd6b59a9ace12b3817b76cdd553a89
4
+ data.tar.gz: 57d5cec5ebd3150ccc5abd83a458d60ed59cc1065b0a0dc8a6fd4df40153ea53
5
5
  SHA512:
6
- metadata.gz: 47ae83e85a0b9f76e57d61dd76acca5402665b98ffd44f085ada67a2c49d9ae69ed81d43059d3d8aca824ccb084714b55f629b1af51992256ddce1eeeac3701e
7
- data.tar.gz: 6207ab63be2d26bb76d97451b98212c7f1e37c014cc200698643bb7921139dc80cddc890211d40cd0480399b78db2bc7b5cecb09ccb24a818e99ad90b424923d
6
+ metadata.gz: bca4b9acaec9bc125b22adbcfe0179794a0f2f27e196c70be266cb1081296bda1a18c740e274cb17fa1f676499cd1d2bdd4187cfa751f8a380ffabdc7d529a50
7
+ data.tar.gz: 074d431d5f9a5b1b66e1fcb72223aa92a457fdd08be43d6f3361b7ecf2c3184fb1b3c13dd0437960b0763e604a673fb7114aaff140a613c0574808113f57fb89
@@ -1,10 +1,10 @@
1
1
  require_relative "./lockfile"
2
2
 
3
3
  class Config
4
- SECTION_LINE = /^\s*\[([a-z0-9-]+)( "(.+)")?\]\s*($|#|;)/i
5
- VARIABLE_LINE = /^\s*([a-z][a-z0-9-]*)\s*=\s*(.*?)\s*($|#|;)/i
6
- BLANK_LINE = /^\s*($|#|;)/
7
- INTEGER = /^-?[1-9][0-9]*$/
4
+ SECTION_LINE = /\A\s*\[([a-z0-9-]+)( "(.+)")?\]\s*(\Z|#|;)/i
5
+ VARIABLE_LINE = /\A\s*([a-z][a-z0-9-]*)\s*=\s*(.*?)\s*(\Z|#|;)/im
6
+ BLANK_LINE = /\A\s*(\Z|#|;)/
7
+ INTEGER = /\A-?[1-9][0-9]*\Z/
8
8
 
9
9
  VALID_SECTION = /^[a-z0-9-]+$/i
10
10
  VALID_VARIABLE = /^[a-z][a-z0-9-]*$/i
@@ -207,7 +207,7 @@ class Config
207
207
 
208
208
  File.open(@path, File::RDONLY) do |file|
209
209
  until file.eof?
210
- line = parse_line(section, file.readline)
210
+ line = parse_line(section, read_line(file))
211
211
  section = line.section
212
212
 
213
213
  lines_for(section).push(line)
@@ -216,6 +216,15 @@ class Config
216
216
  rescue Errno::ENOENT
217
217
  end
218
218
 
219
+ def read_line(file)
220
+ buffer = ""
221
+
222
+ loop do
223
+ buffer.concat(file.readline)
224
+ return buffer unless buffer.end_with?("\\\n")
225
+ end
226
+ end
227
+
219
228
  def parse_line(section, line)
220
229
  if match = SECTION_LINE.match(line)
221
230
  section = Section.new([match[1], match[3]].compact)
@@ -236,7 +245,8 @@ class Config
236
245
  when "yes", "on", "true" then true
237
246
  when "no", "off", "false" then false
238
247
  when INTEGER then value.to_i
239
- else value
248
+ else
249
+ value.gsub(/\\\n/, "")
240
250
  end
241
251
  end
242
252
  end
@@ -92,8 +92,8 @@ class Index
92
92
  end
93
93
 
94
94
  def remove(pathname)
95
- @parents[pathname.to_s].each { |child| remove_entry(child) }
96
95
  remove_entry(pathname)
96
+ remove_children(pathname.to_s)
97
97
  @changed = true
98
98
  end
99
99
 
@@ -146,9 +146,7 @@ class Index
146
146
 
147
147
  def discard_conflicts(entry)
148
148
  entry.parent_directories.each { |parent| remove_entry(parent) }
149
-
150
- set = @parents.fetch(entry.path, [])
151
- set.each { |child| remove_entry(child) }
149
+ remove_children(entry.path)
152
150
  end
153
151
 
154
152
  def remove_entry(pathname)
@@ -169,6 +167,13 @@ class Index
169
167
  end
170
168
  end
171
169
 
170
+ def remove_children(path)
171
+ return unless @parents.has_key?(path)
172
+
173
+ children = @parents[path].clone
174
+ children.each { |child| remove_entry(child) }
175
+ end
176
+
172
177
  def store_entry(entry)
173
178
  @keys.add(entry.key)
174
179
  @entries[entry.key] = entry
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: jcoglan@gmail.com
@@ -130,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.5.2.3
133
+ rubygems_version: 3.1.2
135
134
  signing_key:
136
135
  specification_version: 4
137
136
  summary: The information manager from London