textmerge 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/textmerge/merge.rb +4 -4
- data/lib/textmerge/version.rb +1 -1
- data/rebuild.sh +4 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4339a1f304a6a25ed22708bd27449c8ee661197a
|
4
|
+
data.tar.gz: e75100fb783fdbc3f76d65374247ceb51d630d05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a07e8f213e3a41a58b8b69008f1b6b301227cbda6b1e23d74f226bac85aa67f629191213d4eb471699a0799cedccc7a42dcaef1a339d819b32bad639f5e3eb2
|
7
|
+
data.tar.gz: a267eae29a47019319ea0eb35244440e6bc20fd69eb0b93b34f9060ec1e1b46e5c7e3bed770a591ddc2e24197f4edc6de6600e10b9c3c21afe2860bd0c94a3e0
|
data/lib/textmerge/merge.rb
CHANGED
@@ -19,15 +19,14 @@ module Textmerge
|
|
19
19
|
File.open(data_file, 'r') do |file|
|
20
20
|
collection = file.map { |line| line.chomp.split(':') }
|
21
21
|
end
|
22
|
-
collection.sort!
|
22
|
+
# collection.sort!
|
23
23
|
array_to_hash(collection)
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_requests(data)
|
27
27
|
regex = /\{(\d{1,3})\:(.*?)\}/
|
28
28
|
collection = data.scan(regex)
|
29
|
-
|
30
|
-
array_to_hash(sorted)
|
29
|
+
array_to_hash(collection)
|
31
30
|
end
|
32
31
|
|
33
32
|
def get_responses(requests)
|
@@ -39,7 +38,7 @@ module Textmerge
|
|
39
38
|
|
40
39
|
def merge_responses(responses,data)
|
41
40
|
responses.each do |k,v|
|
42
|
-
data.gsub!(/\{#{k}
|
41
|
+
data.gsub!(/\{#{k}\:.*?\}/,v)
|
43
42
|
end
|
44
43
|
data
|
45
44
|
end
|
@@ -56,6 +55,7 @@ module Textmerge
|
|
56
55
|
|
57
56
|
def array_to_hash(array)
|
58
57
|
array.inject({}) {|m,e| m[e[0].to_i] = e[1]; m}
|
58
|
+
# array.sort_by { | num,value | num}
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
data/lib/textmerge/version.rb
CHANGED
data/rebuild.sh
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textmerge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Simpson
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/textmerge.rb
|
115
115
|
- lib/textmerge/merge.rb
|
116
116
|
- lib/textmerge/version.rb
|
117
|
+
- rebuild.sh
|
117
118
|
- spec/lib/test_input.txt
|
118
119
|
- spec/lib/textmerge_spec.rb
|
119
120
|
- spec/spec_helper.rb
|