open_gpx_2_kml 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/tf1_converter/config.rb +44 -42
- data/lib/tf1_converter/version.rb +1 -1
- data/spec/lib/tf1_converter/config_spec.rb +14 -0
- metadata +6 -4
data/Gemfile.lock
CHANGED
data/lib/tf1_converter/config.rb
CHANGED
@@ -4,48 +4,12 @@ module TF1Converter
|
|
4
4
|
class Config
|
5
5
|
|
6
6
|
def self.load(path)
|
7
|
-
last_key = nil
|
8
|
-
current_control = nil
|
7
|
+
@last_key = nil
|
8
|
+
@current_control = nil
|
9
9
|
@constant_color_switch = false
|
10
10
|
|
11
11
|
CSV.read(path).each do |row|
|
12
|
-
|
13
|
-
@input = row[0]
|
14
|
-
elsif last_key == 'OUTPUT'
|
15
|
-
@output = row[0]
|
16
|
-
elsif last_key == 'ICON_PATH'
|
17
|
-
@icon_path = row[0]
|
18
|
-
elsif last_key == 'ICONS'
|
19
|
-
@icons = {}
|
20
|
-
current_control = 'ICONS'
|
21
|
-
elsif last_key == 'COLORS'
|
22
|
-
@colors = {}
|
23
|
-
current_control = 'COLORS'
|
24
|
-
elsif last_key == 'USE_CONSTANT_COLOR'
|
25
|
-
@use_constant_color = row[0].strip.downcase == 'true'
|
26
|
-
elsif last_key == 'CONSTANT_COLOR'
|
27
|
-
@constant_color = row[0]
|
28
|
-
end
|
29
|
-
|
30
|
-
if current_control == 'ICONS'
|
31
|
-
if row.empty?
|
32
|
-
current_control = nil
|
33
|
-
else
|
34
|
-
@icons[row[0]] = {
|
35
|
-
'icon' => row[1],
|
36
|
-
'meaning' => row[2],
|
37
|
-
'name' => row[3]
|
38
|
-
}
|
39
|
-
end
|
40
|
-
elsif current_control == 'COLORS'
|
41
|
-
if row.empty?
|
42
|
-
current_control = nil
|
43
|
-
else
|
44
|
-
@colors[row[0]] = row[1]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
last_key = row[0] ? row[0].upcase : nil
|
12
|
+
parse_row(row)
|
49
13
|
end
|
50
14
|
end
|
51
15
|
|
@@ -55,9 +19,47 @@ module TF1Converter
|
|
55
19
|
end
|
56
20
|
end
|
57
21
|
|
58
|
-
|
22
|
+
def self.parse_row(row)
|
23
|
+
if @last_key == 'INPUT'
|
24
|
+
@input = row[0]
|
25
|
+
elsif @last_key == 'OUTPUT'
|
26
|
+
@output = row[0]
|
27
|
+
elsif @last_key == 'ICON_PATH'
|
28
|
+
@icon_path = row[0]
|
29
|
+
elsif @last_key == 'ICONS'
|
30
|
+
@icons = {}
|
31
|
+
@current_control = 'ICONS'
|
32
|
+
elsif @last_key == 'COLORS'
|
33
|
+
@colors = {}
|
34
|
+
@current_control = 'COLORS'
|
35
|
+
elsif @last_key == 'USE_CONSTANT_COLOR'
|
36
|
+
@use_constant_color = row[0].strip.downcase == 'true'
|
37
|
+
elsif @last_key == 'CONSTANT_COLOR'
|
38
|
+
@constant_color = row[0]
|
39
|
+
end
|
40
|
+
if @current_control == 'ICONS'
|
41
|
+
if row.compact.empty?
|
42
|
+
@current_control = nil
|
43
|
+
else
|
44
|
+
@icons[row[0]] = {
|
45
|
+
'icon' => row[1],
|
46
|
+
'meaning' => row[2],
|
47
|
+
'name' => row[3]
|
48
|
+
}
|
49
|
+
end
|
50
|
+
elsif @current_control == 'COLORS'
|
51
|
+
if row.compact.empty?
|
52
|
+
@current_control = nil
|
53
|
+
else
|
54
|
+
@colors[row[0]] = row[1]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
@last_key = row[0] ? row[0].upcase : nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.constant_color
|
61
|
+
colors[@constant_color]
|
62
|
+
end
|
59
63
|
|
60
|
-
def self.constant_color
|
61
|
-
colors[@constant_color]
|
62
64
|
end
|
63
65
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../../../lib/tf1_converter/config'
|
2
|
+
|
3
|
+
describe TF1Converter::Config do
|
4
|
+
it 'does not overwrite colors later' do
|
5
|
+
TF1Converter::Config.parse_row(['COLORS'])
|
6
|
+
TF1Converter::Config.parse_row(['Red', '00ff1155'])
|
7
|
+
TF1Converter::Config.parse_row(['Blue', '00ff1155'])
|
8
|
+
TF1Converter::Config.parse_row(['Green', '00ff1155'])
|
9
|
+
TF1Converter::Config.parse_row([nil, nil])
|
10
|
+
TF1Converter::Config.parse_row(['USE_CONSTANT_COLOR'])
|
11
|
+
TF1Converter::Config.parse_row(['Blue', nil])
|
12
|
+
TF1Converter::Config.colors['Blue'].should_not be_nil
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_gpx_2_kml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- spec/fixtures/ftwood2_expected.kml
|
195
195
|
- spec/fixtures/test.gpx
|
196
196
|
- spec/fixtures/waypoint-by-name.gpx
|
197
|
+
- spec/lib/tf1_converter/config_spec.rb
|
197
198
|
- spec/lib/tf1_converter/gpx/track_spec.rb
|
198
199
|
- spec/lib/tf1_converter/gpx/waypoint_spec.rb
|
199
200
|
- spec/lib/tf1_converter/kml/track_color_spec.rb
|
@@ -213,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
214
|
version: '0'
|
214
215
|
segments:
|
215
216
|
- 0
|
216
|
-
hash:
|
217
|
+
hash: 1970865931088980454
|
217
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
219
|
none: false
|
219
220
|
requirements:
|
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
223
|
version: '0'
|
223
224
|
segments:
|
224
225
|
- 0
|
225
|
-
hash:
|
226
|
+
hash: 1970865931088980454
|
226
227
|
requirements: []
|
227
228
|
rubyforge_project:
|
228
229
|
rubygems_version: 1.8.23
|
@@ -235,6 +236,7 @@ test_files:
|
|
235
236
|
- spec/fixtures/ftwood2_expected.kml
|
236
237
|
- spec/fixtures/test.gpx
|
237
238
|
- spec/fixtures/waypoint-by-name.gpx
|
239
|
+
- spec/lib/tf1_converter/config_spec.rb
|
238
240
|
- spec/lib/tf1_converter/gpx/track_spec.rb
|
239
241
|
- spec/lib/tf1_converter/gpx/waypoint_spec.rb
|
240
242
|
- spec/lib/tf1_converter/kml/track_color_spec.rb
|