cog 0.3.3 → 0.3.4

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: e1f8ad2d26be0b178e872bf2bb7f4b19e5500c35
4
- data.tar.gz: 88a8343d3f76b4c2f26c44d77a2b643e760a5973
3
+ metadata.gz: 9392f9ee781234cef958cb8b7458004e8a2ab0fb
4
+ data.tar.gz: 4899e407f4b12b3b982fdbb9014eb0c6383f7b96
5
5
  SHA512:
6
- metadata.gz: a20bef1a00a8a084a0fc3274f59ecd4a7e8cb9cceb58ea4a3a23f27533e508b03fb8449e541c95bea886339eefd5aba097dc82934946c93c1ea3509836d83e6c
7
- data.tar.gz: 564cc0f972a33830b20223727e733456ba7fb4ec3ec4836faecbf77b0c8ae734b564f4c5718738b1beb7317ea24cb36bed9e43b7a786d2ef27d4569ca67b695b
6
+ metadata.gz: 482cc203a950afbbacb2c1d678e4c67ef4bd2d68fcea165bc54f466db1e3df0cd726fccb27cea665ad7acbc6f47bae22ff41a6004c8ae9f686cc671c6c7d7af9
7
+ data.tar.gz: f54a5fbf5482b805407560bcf4f6bf020f8289a869536cd8bb1113958fe43a9501f34e747e4a80b3a79c75e92064824f999323f603bc52d26889b3951ab0d3be
@@ -29,11 +29,6 @@ module Cog
29
29
  feature :destructor, &block
30
30
  end
31
31
 
32
- # @api_developer
33
- def respond_to?(meth)
34
- meth.to_s.end_with?('_feature') || super(meth)
35
- end
36
-
37
32
  # @api developer
38
33
  def method_missing(meth, *args, &block)
39
34
  meth = meth.to_s
@@ -48,7 +43,7 @@ module Cog
48
43
  args << opt
49
44
  feature(*args, &block)
50
45
  else
51
- super(meth, *args, &block)
46
+ super
52
47
  end
53
48
  end
54
49
 
@@ -1,6 +1,6 @@
1
1
  class String
2
2
  def normalize_eol
3
- gsub /(\r|\n|\r\n)/, "\n"
3
+ gsub(/\r\n/, "\n").gsub(/\r/, "\n")
4
4
  end
5
5
  end
6
6
 
@@ -18,14 +18,17 @@ module Cog
18
18
  def initialize(filename)
19
19
  @filename = filename
20
20
  @f = File.open filename, 'r'
21
+ @f = @f.binmode if @f.respond_to?(:binmode)
21
22
  @lines = []
22
23
  @mark = nil
23
24
  @cap_begin_pos = nil
24
25
  @cap_end_pos = nil
26
+ @cap_end_lineno = nil
25
27
  @match = nil # The last match object
26
28
  @win_fudge = if RUBY_PLATFORM =~ /(mswin|mingw)/
27
- x = @f.readline.end_with? '\r\n'
29
+ x = @f.readline.end_with? "\r\n"
28
30
  @f.seek 0
31
+ @f.lineno = 0
29
32
  x ? 0 : 1
30
33
  else
31
34
  0
@@ -120,6 +123,7 @@ module Cog
120
123
  return true if line =~ pattern
121
124
  @lines << line
122
125
  @cap_end_pos = @f.pos # win_fudge not needed here
126
+ @cap_end_lineno = @f.lineno
123
127
  end
124
128
  rescue EOFError
125
129
  false
@@ -137,11 +141,13 @@ module Cog
137
141
  def replace_captured_text(value, opt={})
138
142
  return false if @cap_begin_pos.nil? || @cap_end_pos.nil?
139
143
  @f.seek 0
140
- tmp.write @f.read(opt[:once] ? @mark : @cap_begin_pos).normalize_eol
141
- tmp.write value.normalize_eol
144
+ @f.lineno = 0
145
+ tmp.write @f.read(opt[:once] ? @mark : @cap_begin_pos)
146
+ tmp.write value
142
147
  @f.seek @cap_end_pos
148
+ @f.lineno = @cap_end_lineno
143
149
  @f.readline if opt[:once]
144
- tmp.write @f.read.normalize_eol
150
+ tmp.write @f.read
145
151
  tmp.close
146
152
  close
147
153
  FileUtils.mv tmp_filename, @filename
@@ -153,10 +159,11 @@ module Cog
153
159
  def insert_at_mark(value)
154
160
  return false if @mark.nil?
155
161
  @f.seek 0
156
- tmp.write @f.read(@mark).normalize_eol
157
- tmp.write value.normalize_eol
162
+ @f.lineno = 0
163
+ tmp.write @f.read(@mark)
164
+ tmp.write value
158
165
  @f.readline # discard original
159
- tmp.write @f.read.normalize_eol
166
+ tmp.write @f.read
160
167
  tmp.close
161
168
  close
162
169
  FileUtils.mv tmp_filename, @filename
@@ -170,7 +177,11 @@ module Cog
170
177
  end
171
178
 
172
179
  def tmp
173
- @tmp ||= File.open(tmp_filename, 'w')
180
+ unless @tmp
181
+ @tmp = File.open(tmp_filename, 'w')
182
+ @tmp = @tmp.binmode if @tmp.respond_to?(:binmode)
183
+ end
184
+ @tmp
174
185
  end
175
186
  end
176
187
 
@@ -1,5 +1,5 @@
1
1
  module Cog
2
2
  unless const_defined? :VERSION
3
- VERSION = '0.3.3'
3
+ VERSION = '0.3.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Tonon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-18 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_support