gcmapper 0.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -44,8 +44,20 @@ another_route.gcmap # => Returns an image map URL for the layover route LFST-LSZ
44
44
  ```
45
45
 
46
46
  The resulting image size and look can be customized by passing an optional hash of arguments to the
47
- `.gcmap` method. Customizable attributes include *width, height* and *terrain* (toggle satelite terrain overlay).
48
- These options can be combined in any way or omitted entirely. Examples:
47
+ `.gcmap` method. Customizable attributes include *width, height, terrain (toggle satelite terrain
48
+ overlay), city label and airport name label*.
49
+ Width, height and terrain can be combined in any way or omitted entirely. City label ad Airport name
50
+ label are mutually exclusive.
51
+
52
+ ### Defaults
53
+
54
+ * width: 720px
55
+ * height: 360px
56
+ * terrain: off
57
+ * city label: on
58
+ * airport name label: off
59
+
60
+ ### Examples:
49
61
 
50
62
  ```ruby
51
63
  # Passing width only (default is 720px):
@@ -65,6 +77,17 @@ route.gcmap(:terrain => true) # => Returns an image map URL with terrain overlay
65
77
 
66
78
  # Setting width, height and enabling terrain overlay:
67
79
  "egll-lowi".gcmap(:width => 800, :height => 400, :terrain => true) # => Returns an image map URL with set width, height and terrain
80
+
81
+ # Setting width, height, enabling terrain overlay and disabling the city labels:
82
+ "egll-lowi".gcmap(:width => 800, :height=>400, :terrain=>true, :city=>false) # => Returns an image map URL with set width, height and terrain, with city labels disabled
83
+
84
+ # Setting the map to display the airports' names instead of the ICAO/IATA codes
85
+ route = "egll-lowi"
86
+ route.gcmap(:airport_name => true) # => Returns an image map URL with airport names displayed
87
+
88
+ # Setting the map to display the airports' names and a terrain overlay
89
+ route = "egll-lowi"
90
+ route.gcmap(:airport_name => true, :terrain => true) # => Returns an image map URL with airport names and terrain displayed
68
91
  ```
69
92
 
70
93
  Finally, here's an example of how to use the gem in a Rails application:
@@ -86,6 +109,17 @@ Finally, here's an example of how to use the gem in a Rails application:
86
109
  * layover routes that chain multiple airports (more than 2) are also supported
87
110
  * default image parameters are: width 720px, width: 360px, terrain not shown
88
111
  * when passing the `width` and `height` hash options the values can be put in quotes or not, either way works
112
+ * `city` label and `airport_name` label options are mutually exclusive, i.e. you can either have the ICAO/IATA code with optional city name OR the Airport name
113
+
114
+ ## Changelog
115
+
116
+ ### v. 0.2 July 2nd 2012
117
+
118
+ * [Enhancement] Maps now show the user input code (ICAO or IATA) instead of ICAO only
119
+ * [Feature] New hash option `:city` to toggle city labels on or off (see [Usage](#usage))
120
+ * [Feature] New hash option `:airport_name` to toggle airport name labels on or off (see [Usage](#usage))
121
+
122
+
89
123
 
90
124
  ## Contributing
91
125
 
@@ -11,8 +11,20 @@ module Gcmapper
11
11
  args[:terrain].nil? || args[:terrain] == false ? tr="wls" : tr="bm"
12
12
  args[:width].nil? ? width="720" : width=args[:width]
13
13
  args[:height].nil? ? height="360" : height=args[:height]
14
+ style = parse_styles(args)
15
+ url = "http://www.gcmap.com/map?P=#{route}%0d%0a&MS=#{tr}&MR=120&MX=#{width}x#{height}&PM=#{style}"
16
+ end
17
+
18
+ private
19
+ # disc + user code b:disc7%2b%25U
20
+ # disc + user_code + city b:disc7%2b\"%25U%25+%28N\"
21
+ # disc + airport_name b:disc7+%A
14
22
 
15
- url = "http://www.gcmap.com/map?P=#{route}%0d%0a&MS=#{tr}&MR=120&MX=#{width}x#{height}&PM=b:disc7%2b%22%25i%25+%28N%22"
23
+ def self.parse_styles(args)
24
+ style = 'b:disc7%2b' #basic
25
+ args[:city] == false ? style += '%25U' : style += '"%25U%25+%28N"'
26
+ style = 'b:disc7+%A' if args[:airport_name] == true
27
+ return style
16
28
  end
17
29
  end
18
30
 
@@ -1,3 +1,3 @@
1
1
  module Gcmapper
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -18,73 +18,99 @@ describe String do
18
18
 
19
19
  it "should integrate the route correctly in the url" do
20
20
  route = "egll-lowi"
21
- route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
21
+ route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
22
22
  end
23
23
 
24
24
  it "should interpret default width" do
25
25
  route = "egll-lowi"
26
- route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
26
+ route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
27
27
  end
28
28
 
29
29
  it "should interpret default height" do
30
30
  route = "egll-lowi"
31
- route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
31
+ route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
32
32
  end
33
33
 
34
34
  it "should be applicable directly to a string" do
35
- "egll-lowi".gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
35
+ "egll-lowi".gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
36
36
  end
37
37
 
38
38
  it "should interpret non-default width" do
39
39
  route = "egll-lowi"
40
- route.gcmap(:width=>"600").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=600x360&PM=b:disc7%2b%22%25i%25+%28N%22")
40
+ route.gcmap(:width=>"600").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=600x360&PM=b:disc7%2b\"%25U%25+%28N\"")
41
41
  end
42
42
 
43
43
  it "should interpret simplified non-default width" do
44
44
  route = "egll-lowi"
45
- route.gcmap(:width=>600).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=600x360&PM=b:disc7%2b%22%25i%25+%28N%22")
45
+ route.gcmap(:width=>600).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=600x360&PM=b:disc7%2b\"%25U%25+%28N\"")
46
46
  end
47
47
 
48
48
  it "should interpret non-default height" do
49
49
  route = "egll-lowi"
50
- route.gcmap(:height=>"600").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x600&PM=b:disc7%2b%22%25i%25+%28N%22")
50
+ route.gcmap(:height=>"600").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x600&PM=b:disc7%2b\"%25U%25+%28N\"")
51
51
  end
52
52
 
53
53
  it "should interpret simplified non-default height" do
54
54
  route = "egll-lowi"
55
- route.gcmap(:height=>600).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x600&PM=b:disc7%2b%22%25i%25+%28N%22")
55
+ route.gcmap(:height=>600).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x600&PM=b:disc7%2b\"%25U%25+%28N\"")
56
56
  end
57
57
 
58
58
  it "should interpret non-default width and height" do
59
59
  route = "egll-lowi"
60
- route.gcmap(:width=>"800", :height=>"400").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=800x400&PM=b:disc7%2b%22%25i%25+%28N%22")
60
+ route.gcmap(:width=>"800", :height=>"400").should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=800x400&PM=b:disc7%2b\"%25U%25+%28N\"")
61
61
  end
62
62
 
63
63
  it "should interpret non-default simplified width and height" do
64
64
  route = "egll-lowi"
65
- route.gcmap(:width => 800, :height => 400).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=800x400&PM=b:disc7%2b%22%25i%25+%28N%22")
65
+ route.gcmap(:width => 800, :height => 400).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=800x400&PM=b:disc7%2b\"%25U%25+%28N\"")
66
66
  end
67
67
 
68
68
  it "should support layover routes" do
69
69
  route = "egll-lowi-lqsa"
70
- route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi-lqsa%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
70
+ route.gcmap.should eq("http://www.gcmap.com/map?P=egll-lowi-lqsa%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
71
71
  end
72
72
 
73
73
  it "should display terrain if needed" do
74
74
  route = "egll-lowi"
75
- route.gcmap(:terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
75
+ route.gcmap(:terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
76
76
  end
77
77
 
78
78
  it "should accept false option for terrain" do
79
79
  route = "egll-lowi"
80
- route.gcmap(:terrain=>false).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%22%25i%25+%28N%22")
80
+ route.gcmap(:terrain=>false).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
81
+ end
82
+
83
+ it "should disable the city label when requested" do
84
+ route = "egll-lowi"
85
+ route.gcmap(:city=>false).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b%25U")
86
+ end
87
+
88
+ it "should handle the city true option" do
89
+ route = "egll-lowi"
90
+ route.gcmap(:city=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
91
+ end
92
+
93
+ it "should handle the airport_name option" do
94
+ route = "egll-lowi"
95
+ route.gcmap(:airport_name=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7+%A")
96
+ end
97
+
98
+ it "should disable the airport name when requested" do
99
+ route = "egll-lowi"
100
+ route.gcmap(:airport_name=>false).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
101
+ end
102
+
103
+ it "should display terrain and airport names" do
104
+ route = "egll-lowi"
105
+ route.gcmap(:airport_name => true, :terrain => true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=720x360&PM=b:disc7+%A")
81
106
  end
82
107
 
83
108
  it "should allow random combination of arguments" do
84
109
  route = "egll-lowi"
85
- route.gcmap(:width=>800, :height=>400, :terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=800x400&PM=b:disc7%2b%22%25i%25+%28N%22")
86
- route.gcmap(:width=>800, :terrain => true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=800x360&PM=b:disc7%2b%22%25i%25+%28N%22")
87
- route.gcmap(:height=>800, :terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=720x800&PM=b:disc7%2b%22%25i%25+%28N%22")
110
+ route.gcmap(:width => 800, :height=>400, :terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=800x400&PM=b:disc7%2b\"%25U%25+%28N\"")
111
+ route.gcmap(:width => 800, :height=>400, :terrain=>true, :city=>false).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=800x400&PM=b:disc7%2b%25U")
112
+ route.gcmap(:width=>800, :terrain => true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=800x360&PM=b:disc7%2b\"%25U%25+%28N\"")
113
+ route.gcmap(:height=>800, :terrain=>true).should eq("http://www.gcmap.com/map?P=egll-lowi%0d%0a&MS=bm&MR=120&MX=720x800&PM=b:disc7%2b\"%25U%25+%28N\"")
88
114
  end
89
115
 
90
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcmapper
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
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: 2012-07-01 00:00:00.000000000 Z
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec