qrcode_intent 0.1.1 → 0.2.0

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: be662e459d07f4ace6a2223e21fb997385425fddf65f5ebf49999320dc8ab07c
4
- data.tar.gz: 35e9cd10c512a6a9435715278dbfba20a68b818a1c6dbf2a6a77e5b32451d67e
3
+ metadata.gz: 2d2a3f66a3807fc23d05aa253011b15e7a37ff3fb19c178d9699cc49b45183d6
4
+ data.tar.gz: 122e368420826c11d08b6ddf4bab6c920e7915e028c9657e9efbc31938cd0013
5
5
  SHA512:
6
- metadata.gz: 22036d99d476eba0572a719f718aa40acc560d8e9e088d26917d367481f6747d0e39582828642888f8763a3cdb35ee52712db36f2959a5ab1f0d69bf02146867
7
- data.tar.gz: 2d10f92fe472c718ff45cd96678f6a2bb1361d9939ee14346c78aef6c14cdcc298c0505875ecfb4c491fdae8ea1ff9e8dadc14d234573ddc1af366d75e3596fc
6
+ metadata.gz: 7677bb0f0c68160ed2870059aa5d21e87c212a224cdb4b1ccbc0167250ed7af55f3ae4f6b637999e67259e569c439683505371544b783cb825a459f3d470a4e8
7
+ data.tar.gz: 4a6fdd11c07a4449d1e954c8934c16df0aed902834c4f87a4b40429635f5e5d8f4e4ab64e289ff695c9cf11d5eb9f987ec5f556f14cf4f1aae1a481daa091dff
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/qrcode_intent.rb CHANGED
@@ -6,14 +6,66 @@ require 'rqrcode'
6
6
  require 'simplevpim'
7
7
 
8
8
 
9
+ # # Intents covered
10
+ #
11
+ # ## Cryptocurrency
12
+ #
13
+ # * type
14
+ # * receiver
15
+ # * amount
16
+ # * msg (optional)
17
+ #
18
+ # ## Email
19
+ #
20
+ # * subject
21
+ # * body
22
+ #
23
+ # ## Location
24
+ #
25
+ # * longitude
26
+ # * latitude
27
+ #
28
+ # # Phone
29
+ #
30
+ # * number
31
+ #
32
+ # ## SMS
33
+ #
34
+ # * number
35
+ # * msg
36
+ #
37
+ # ## Twitter
38
+ #
39
+ # * username
40
+ # * msg
41
+ #
42
+ # ## WiFi
43
+ #
44
+ # * ssid
45
+ # * type; options: none, wep, wpa/wpa2
46
+ # * password
47
+ #
48
+ # ## Zoom
49
+ #
50
+ # * meetingid
51
+ # * password
52
+
53
+
9
54
  class QRCodeIntent
10
55
 
11
56
  attr_reader :to_s
12
-
57
+
58
+ Cryptocurrency = Struct.new(*%i(type receiver amount msg))
59
+ Email = Struct.new(*%i(to subject body))
60
+ Sms = Struct.new(*%i(number msg))
61
+ Twitter = Struct.new(*%i(username msg))
13
62
  WiFi = Struct.new(*%i(ssid type password))
63
+ Zoom = Struct.new(*%i(meetingid password))
14
64
 
15
65
  def initialize(obj=nil, event: nil, contact: nil, website: nil,
16
- wifi: nil, location: nil, debug: false)
66
+ wifi: nil, location: nil, sms: nil, phone: nil,
67
+ email: nil, bitcoin: nil, twitter: nil,
68
+ zoom: nil, debug: false)
17
69
 
18
70
  @debug = debug
19
71
 
@@ -25,6 +77,10 @@ class QRCodeIntent
25
77
 
26
78
  add_location location
27
79
 
80
+ elsif email
81
+
82
+ add_email email
83
+
28
84
  elsif event
29
85
 
30
86
  add_event event
@@ -37,6 +93,26 @@ class QRCodeIntent
37
93
 
38
94
  add_wifi wifi
39
95
 
96
+ elsif sms
97
+
98
+ add_sms sms
99
+
100
+ elsif phone
101
+
102
+ add_tel phone
103
+
104
+ elsif bitcoin
105
+
106
+ add_cryptocurrency bitcoin
107
+
108
+ elsif twitter
109
+
110
+ add_twitter twitter
111
+
112
+ elsif zoom
113
+
114
+ add_zoom zoom
115
+
40
116
  else
41
117
 
42
118
  if obj.is_a? String then
@@ -61,7 +137,52 @@ class QRCodeIntent
61
137
 
62
138
  end
63
139
 
140
+ end
141
+
142
+ def add_cryptocurrency(obj=nil, &blk)
143
+
144
+ h = if block_given? then
145
+
146
+ c = Cryptocurrency.new
147
+ yield c
148
+ c.to_h
149
+
150
+
151
+ elsif obj.is_a? Hash
152
+
153
+ obj
154
+
155
+ end
156
+
157
+ # a type can be bitcoin, bitcoincash, ethereum, litecoin, dash etc.
158
+ #
159
+ type = h[:type] || 'bitcoin'
160
+
161
+ s = "%s:%s?%s" % [type, h[:receiver], h[:amount]]
162
+ s += "&message=%s" % h[:msg] if h[:msg]
163
+
164
+ @to_s = s
165
+
64
166
  end
167
+
168
+ def add_email(obj=nil, &blk)
169
+
170
+ h = if block_given? then
171
+
172
+ email = Email.new
173
+ yield email
174
+ email.to_h
175
+
176
+
177
+ elsif obj.is_a? Hash
178
+
179
+ obj
180
+
181
+ end
182
+
183
+ @to_s = "MATMSG:TO:%s;SUB:%s;BODY:%s;;" % [h[:to], h[:subject], h[:body]]
184
+
185
+ end
65
186
 
66
187
  def add_event(obj=nil, &blk)
67
188
 
@@ -89,6 +210,75 @@ class QRCodeIntent
89
210
  @to_s = s
90
211
  end
91
212
 
213
+ def add_sms(obj=nil, &blk)
214
+
215
+ h = if block_given? then
216
+
217
+ sms = Sms.new
218
+ yield sms
219
+ sms.to_h
220
+
221
+
222
+ elsif obj.is_a? Hash
223
+
224
+ obj
225
+
226
+ end
227
+
228
+ @to_s = "SMSTO:%s:%s" % [h[:number], h[:msg]]
229
+
230
+ end
231
+
232
+ # e.g. add_tel '0131 542 4923'
233
+ #
234
+ def add_tel(s=nil, number: s)
235
+ @to_s = 'tel:' + number
236
+ end
237
+
238
+ def add_twitter(obj=nil, &blk)
239
+
240
+ h = if block_given? then
241
+
242
+ c = Twitter.new
243
+ yield c
244
+ c.to_h
245
+
246
+
247
+ elsif obj.is_a? Hash
248
+
249
+ obj
250
+
251
+ end
252
+
253
+ @to_s = if h[:msg] then
254
+ "https://twitter.com/intent/tweet?text=" % URI.encode(h[:msg])
255
+ elsif h[:username]
256
+ "https://twitter.com/%s" % h[:username]
257
+ end
258
+
259
+ @to_s = s
260
+
261
+ end
262
+
263
+ def add_zoom(obj=nil, &blk)
264
+
265
+ h = if block_given? then
266
+
267
+ c = Zoom.new
268
+ yield c
269
+ c.to_h
270
+
271
+
272
+ elsif obj.is_a? Hash
273
+
274
+ obj
275
+
276
+ end
277
+
278
+ @to_s = "https://zoom.us/j/%s?pwd=%s" % [h[:meetingid], h[:password]]
279
+
280
+ end
281
+
92
282
  def add_wifi(obj=nil, &blk)
93
283
 
94
284
  h = if block_given? then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrcode_intent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  CKmWN+kpdbPOLk9BPe+zHcOiLQPVpsxlbQiUE8EbZL9mwfjXKRoc8NPVGl5dNINp
36
36
  4Flko+JjHRqNlMRox3vA6Y0G
37
37
  -----END CERTIFICATE-----
38
- date: 2021-06-22 00:00:00.000000000 Z
38
+ date: 2021-06-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: simplevpim
@@ -87,5 +87,5 @@ rubygems_version: 3.1.2
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: An rqrcode wrapper for adding a website, a contact, wi-fi settings, location,
90
- or event.
90
+ event, cryptocurrency and more
91
91
  test_files: []
metadata.gz.sig CHANGED
Binary file