google_maps_embed 0.1.0 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6caec73f275aafc064663b8a3a8936defd2d5804ad7ac4514cbb701d74fec733
4
- data.tar.gz: 91d8df4dd4f903ddc6c68f35f53ac05c5bb080ab2f6d11ec6c5bacd909f07a77
3
+ metadata.gz: dc9cb730f98c930e4572531f4eb5f8d8ce20600986c2b343e2e783c729c82deb
4
+ data.tar.gz: 97fac49f3818a86b91298f046333892e3ea8e1d3ea5ff2e35746aa37ab67c8a1
5
5
  SHA512:
6
- metadata.gz: e5a49618f2475e39bdce01ba40f9ebfc5b01814a8b70fe49a560f9f7d8e2bcabefe8e42fcd537fab9b147ed99c89f65206d4b70beeddf40ae2957475ec413b1f
7
- data.tar.gz: f5854d12038810dd15af9c670d438cf231af46b304216f5d48ead5fe2a11eee95fd9c060a1c7e293afe7a6d15953d7926d02e4201e4175dd2d5d03e21298949e
6
+ metadata.gz: de6052ebef107a688dcfb4f8f852608a7c6fa43a6078da3b78ea1fc0fbfffc16c3674e897f3b51806db102728dea704f5a8fda9f040574c9668639dbed7f1dbb
7
+ data.tar.gz: 7c5e94a10171d8b79e0a41984d80e284bac2cb292f42cc4151f58ad1a94a9018d08f51f7dde092cf5196cbf57489f6a035807b9e3cb111b4b3a7d9c1386dc3c9
data/.rubocop.yml CHANGED
@@ -1,5 +1,9 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.0
3
+ SuggestExtensions: false
4
+
5
+ Style/Documentation:
6
+ Enabled: false
3
7
 
4
8
  Style/StringLiterals:
5
9
  EnforcedStyle: double_quotes
@@ -7,6 +11,9 @@ Style/StringLiterals:
7
11
  Style/StringLiteralsInInterpolation:
8
12
  EnforcedStyle: double_quotes
9
13
 
14
+ Style/GuardClause:
15
+ Enabled: false
16
+
10
17
  Metrics/MethodLength:
11
18
  Enabled: false
12
19
 
@@ -18,3 +25,210 @@ Metrics/PerceivedComplexity:
18
25
 
19
26
  Metrics/AbcSize:
20
27
  Enabled: false
28
+
29
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
30
+ Enabled: true
31
+ Gemspec/DevelopmentDependencies: # new in 1.44
32
+ Enabled: true
33
+ Gemspec/RequireMFA: # new in 1.23
34
+ Enabled: false
35
+ Layout/LineContinuationLeadingSpace: # new in 1.31
36
+ Enabled: true
37
+ Layout/LineContinuationSpacing: # new in 1.31
38
+ Enabled: true
39
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
40
+ Enabled: true
41
+ Layout/SpaceBeforeBrackets: # new in 1.7
42
+ Enabled: true
43
+ Lint/AmbiguousAssignment: # new in 1.7
44
+ Enabled: true
45
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
46
+ Enabled: true
47
+ Lint/AmbiguousRange: # new in 1.19
48
+ Enabled: true
49
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
50
+ Enabled: true
51
+ Lint/DeprecatedConstants: # new in 1.8
52
+ Enabled: true
53
+ Lint/DuplicateBranch: # new in 1.3
54
+ Enabled: true
55
+ Lint/DuplicateMagicComment: # new in 1.37
56
+ Enabled: true
57
+ Lint/DuplicateMatchPattern: # new in 1.50
58
+ Enabled: true
59
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
60
+ Enabled: true
61
+ Lint/EmptyBlock: # new in 1.1
62
+ Enabled: true
63
+ Lint/EmptyClass: # new in 1.3
64
+ Enabled: true
65
+ Lint/EmptyInPattern: # new in 1.16
66
+ Enabled: true
67
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
68
+ Enabled: true
69
+ Lint/ItWithoutArgumentsInBlock: # new in 1.59
70
+ Enabled: true
71
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
72
+ Enabled: true
73
+ Lint/LiteralAssignmentInCondition: # new in 1.58
74
+ Enabled: true
75
+ Lint/MixedCaseRange: # new in 1.53
76
+ Enabled: true
77
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
78
+ Enabled: true
79
+ Lint/NonAtomicFileOperation: # new in 1.31
80
+ Enabled: true
81
+ Lint/NumberedParameterAssignment: # new in 1.9
82
+ Enabled: true
83
+ Lint/OrAssignmentToConstant: # new in 1.9
84
+ Enabled: true
85
+ Lint/RedundantDirGlobSort: # new in 1.8
86
+ Enabled: true
87
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
88
+ Enabled: true
89
+ Lint/RefinementImportMethods: # new in 1.27
90
+ Enabled: true
91
+ Lint/RequireRangeParentheses: # new in 1.32
92
+ Enabled: true
93
+ Lint/RequireRelativeSelfPath: # new in 1.22
94
+ Enabled: true
95
+ Lint/SymbolConversion: # new in 1.9
96
+ Enabled: true
97
+ Lint/ToEnumArguments: # new in 1.1
98
+ Enabled: true
99
+ Lint/TripleQuotes: # new in 1.9
100
+ Enabled: true
101
+ Lint/UnexpectedBlockArity: # new in 1.5
102
+ Enabled: true
103
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
104
+ Enabled: true
105
+ Lint/UselessRescue: # new in 1.43
106
+ Enabled: true
107
+ Lint/UselessRuby2Keywords: # new in 1.23
108
+ Enabled: true
109
+ Metrics/CollectionLiteralLength: # new in 1.47
110
+ Enabled: true
111
+ Naming/BlockForwarding: # new in 1.24
112
+ Enabled: true
113
+ Security/CompoundHash: # new in 1.28
114
+ Enabled: true
115
+ Security/IoMethods: # new in 1.22
116
+ Enabled: true
117
+ Style/ArgumentsForwarding: # new in 1.1
118
+ Enabled: true
119
+ Style/ArrayIntersect: # new in 1.40
120
+ Enabled: true
121
+ Style/CollectionCompact: # new in 1.2
122
+ Enabled: true
123
+ Style/ComparableClamp: # new in 1.44
124
+ Enabled: true
125
+ Style/ConcatArrayLiterals: # new in 1.41
126
+ Enabled: true
127
+ Style/DataInheritance: # new in 1.49
128
+ Enabled: true
129
+ Style/DirEmpty: # new in 1.48
130
+ Enabled: true
131
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
132
+ Enabled: true
133
+ Style/EmptyHeredoc: # new in 1.32
134
+ Enabled: true
135
+ Style/EndlessMethod: # new in 1.8
136
+ Enabled: true
137
+ Style/EnvHome: # new in 1.29
138
+ Enabled: true
139
+ Style/ExactRegexpMatch: # new in 1.51
140
+ Enabled: true
141
+ Style/FetchEnvVar: # new in 1.28
142
+ Enabled: true
143
+ Style/FileEmpty: # new in 1.48
144
+ Enabled: true
145
+ Style/FileRead: # new in 1.24
146
+ Enabled: true
147
+ Style/FileWrite: # new in 1.24
148
+ Enabled: true
149
+ Style/HashConversion: # new in 1.10
150
+ Enabled: true
151
+ Style/HashExcept: # new in 1.7
152
+ Enabled: false
153
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
154
+ Enabled: true
155
+ Style/InPatternThen: # new in 1.16
156
+ Enabled: true
157
+ Style/MagicCommentFormat: # new in 1.35
158
+ Enabled: true
159
+ Style/MapCompactWithConditionalBlock: # new in 1.30
160
+ Enabled: true
161
+ Style/MapIntoArray: # new in 1.63
162
+ Enabled: true
163
+ Style/MapToHash: # new in 1.24
164
+ Enabled: true
165
+ Style/MapToSet: # new in 1.42
166
+ Enabled: true
167
+ Style/MinMaxComparison: # new in 1.42
168
+ Enabled: true
169
+ Style/MultilineInPatternThen: # new in 1.16
170
+ Enabled: true
171
+ Style/NegatedIfElseCondition: # new in 1.2
172
+ Enabled: true
173
+ Style/NestedFileDirname: # new in 1.26
174
+ Enabled: true
175
+ Style/NilLambda: # new in 1.3
176
+ Enabled: true
177
+ Style/NumberedParameters: # new in 1.22
178
+ Enabled: true
179
+ Style/NumberedParametersLimit: # new in 1.22
180
+ Enabled: true
181
+ Style/ObjectThen: # new in 1.28
182
+ Enabled: true
183
+ Style/OpenStructUse: # new in 1.23
184
+ Enabled: true
185
+ Style/OperatorMethodCall: # new in 1.37
186
+ Enabled: true
187
+ Style/QuotedSymbols: # new in 1.16
188
+ Enabled: true
189
+ Style/RedundantArgument: # new in 1.4
190
+ Enabled: true
191
+ Style/RedundantArrayConstructor: # new in 1.52
192
+ Enabled: true
193
+ Style/RedundantConstantBase: # new in 1.40
194
+ Enabled: true
195
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
196
+ Enabled: true
197
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
198
+ Enabled: true
199
+ Style/RedundantEach: # new in 1.38
200
+ Enabled: true
201
+ Style/RedundantFilterChain: # new in 1.52
202
+ Enabled: true
203
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
204
+ Enabled: true
205
+ Style/RedundantInitialize: # new in 1.27
206
+ Enabled: true
207
+ Style/RedundantLineContinuation: # new in 1.49
208
+ Enabled: true
209
+ Style/RedundantRegexpArgument: # new in 1.53
210
+ Enabled: true
211
+ Style/RedundantRegexpConstructor: # new in 1.52
212
+ Enabled: true
213
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
214
+ Enabled: true
215
+ Style/RedundantStringEscape: # new in 1.37
216
+ Enabled: true
217
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
218
+ Enabled: true
219
+ Style/SelectByRegexp: # new in 1.22
220
+ Enabled: true
221
+ Style/SendWithLiteralMethodName: # new in 1.64
222
+ Enabled: true
223
+ Style/SingleLineDoEndBlock: # new in 1.57
224
+ Enabled: true
225
+ Style/StringChars: # new in 1.12
226
+ Enabled: true
227
+ Style/SuperArguments: # new in 1.64
228
+ Enabled: true
229
+ Style/SuperWithArgsParentheses: # new in 1.58
230
+ Enabled: true
231
+ Style/SwapValues: # new in 1.1
232
+ Enabled: true
233
+ Style/YAMLFileRead: # new in 1.53
234
+ Enabled: true
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Google_Maps_Embed
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/google_maps_embed.svg)](https://badge.fury.io/rb/google_maps_embed)
4
+
3
5
  ## Currently a Work in Progress
4
6
 
5
7
  ## Installation
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # frozen_string_literal: true
4
+
5
+ module GoogleMapsEmbed
6
+ module IframeGenerator
7
+ def self.generate(src_url, options = {})
8
+ ["<iframe",
9
+ "width=\"#{options[:width] || "450"}\"",
10
+ "height=\"#{options[:height] || "250"}\"",
11
+ "frameborder=\"#{options[:frameborder] || "0"}\"",
12
+ "style=\"#{options[:style] || "border:0"}\"",
13
+ "loading=\"#{options[:loading] || "lazy"}\"",
14
+ "referrerpolicy=\"#{options[:referrer_policy] || "no-referrer-when-downgrade"}\"",
15
+ "src=\"#{src_url}\"",
16
+ "allowfullscreen",
17
+ ">",
18
+ "</iframe>"].join(" ")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+
5
+ class PlaceMap
6
+ BASE_URL = "https://www.google.com/maps/embed/v1/place"
7
+
8
+ def self.create(options = {})
9
+ unless options.key?(:q)
10
+ raise ArgumentError "Maps API for a place requires a 'q' parameter for a map marker location"
11
+ end
12
+
13
+ api_key = [options[:api_key], GoogleMapsEmbed.configuration.dynamic_key,
14
+ GoogleMapsEmbed.configuration.api_key].compact.first
15
+
16
+ exclude_keys = %i[api_key width height frameborder style loading referrer_policy]
17
+
18
+ filtered_options = options.reject { |key, _| exclude_keys.include?(key) }
19
+ extra_url = filtered_options.map do |key, value|
20
+ "#{key}=#{URI.encode_www_form_component(value)}"
21
+ end.join("&").gsub("%2C", ",")
22
+
23
+ src_url = "#{BASE_URL}?key=#{api_key}&#{extra_url}"
24
+
25
+ GoogleMapsEmbed::IframeGenerator.generate(src_url, options)
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "google_maps_embed"
4
+
5
+ module GoogleMapsEmbed
6
+ class Railtie < Rails::Railtie
7
+ initializer "google_maps_embed.view_helpers" do
8
+ ActiveSupport.on_load(:action_view) do
9
+ include GoogleMapsEmbed::ViewHelpers
10
+ end
11
+ end
12
+ end
13
+ end
@@ -22,9 +22,9 @@ class StaticMap
22
22
 
23
23
  coords = options.key?(:latitude) && options.key?(:longitude) ? "#{options[:latitude]},#{options[:longitude]}" : ""
24
24
  center = if coords.empty? && options.key?(:address)
25
- coords
25
+ "center=#{URI.encode_www_form_component(options[:address])}"
26
26
  else
27
- "center=" << URI.encode_www_form_component(options[:address])
27
+ "center=#{coords}"
28
28
  end
29
29
 
30
30
  api_key = [options[:api_key], GoogleMapsEmbed.configuration.static_key,
@@ -76,7 +76,7 @@ class StaticMap
76
76
  current << "#{k}:#{URI.encode_www_form_component(v)}" if v.is_a? String
77
77
  current << URI.encode_www_form_component(v.join("|")) if v.is_a? Array
78
78
  end
79
- options_url << "#{option_type}=" + current.join("%7C")
79
+ options_url << ("#{option_type}=" + current.join("%7C"))
80
80
  end
81
81
 
82
82
  options_url.join("&").gsub("%2C", ",")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleMapsEmbed
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoogleMapsEmbed
4
+ module ViewHelpers
5
+ def google_maps_embed(type: :static, **options)
6
+ GoogleMapsEmbed.map(type: type, **options)
7
+ end
8
+ end
9
+ end
@@ -3,6 +3,9 @@
3
3
  require_relative "google_maps_embed/version"
4
4
  require_relative "google_maps_embed/configuration"
5
5
  require_relative "google_maps_embed/static_map"
6
+ require_relative "google_maps_embed/place_map"
7
+ require_relative "google_maps_embed/iframe_generator"
8
+ require "google_maps_embed/railtie" if defined?(Rails)
6
9
 
7
10
  module GoogleMapsEmbed
8
11
  class Error < StandardError; end
@@ -16,12 +19,18 @@ module GoogleMapsEmbed
16
19
  yield(configuration)
17
20
  end
18
21
 
19
- def self.url(type: :static, **options)
22
+ def self.map(type: :static, **options)
20
23
  case type
21
24
  when :static
22
25
  StaticMap.url(options)
26
+ when :place
27
+ PlaceMap.create(options)
23
28
  else
24
29
  raise ArgumentError, "Unknown map type: #{type}"
25
30
  end
26
31
  end
27
32
  end
33
+
34
+ def google_maps_embed(type: :static, **options)
35
+ GoogleMapsEmbed.map(type: type, **options)
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Nazworth
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-30 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Google_Maps_Embed is a versatile Ruby gem designed to simplify the generation of Google Maps URLs
@@ -38,9 +38,13 @@ files:
38
38
  - lib/generators/google_maps_embed/install/templates/google_maps_embed.rb
39
39
  - lib/google_maps_embed.rb
40
40
  - lib/google_maps_embed/configuration.rb
41
+ - lib/google_maps_embed/iframe_generator.rb
42
+ - lib/google_maps_embed/place_map.rb
43
+ - lib/google_maps_embed/railtie.rb
41
44
  - lib/google_maps_embed/static_map.rb
42
45
  - lib/google_maps_embed/url_signer.rb
43
46
  - lib/google_maps_embed/version.rb
47
+ - lib/google_maps_embed/view_helpers.rb
44
48
  - sig/google_maps_embed.rbs
45
49
  homepage: https://github.com/anazworth/google_maps_embed
46
50
  licenses: