quick_response 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # QuickResponse
2
+
3
+ QuickResponse is a **QR Code Generator**. It doesn't rely on any image manipulation library. Instead it's thin wrapper around the **Google Chart API**.
4
+
5
+ ## Installation
6
+
7
+ gem install quick_response
8
+
9
+ ## Usage
10
+
11
+ ### Initialization
12
+
13
+ First you need to create a QuickResponse object. For example to create a simple textual QR code:
14
+
15
+ QuickResponse::Text.new("Hello World!")
16
+
17
+ …or for a url:
18
+
19
+ QuickResponse::Url.new("robinclart.com")
20
+
21
+ You can also specify a size option:
22
+
23
+ QuickResponse::Url.new("robinclart.com", :size => 512)
24
+
25
+ ### Shorthand
26
+
27
+ You can also use one of the shorthand versions:
28
+
29
+ QuickResponse.new(:text, "Hello World!")
30
+
31
+ …or:
32
+
33
+ QuickResponse.text("Hello World!")
34
+
35
+ ### Methods
36
+
37
+ Once you have your QR object you have two methods available:
38
+
39
+ * The first one is `image_url`. This method will return the image url as you can guess.
40
+ * The second one is `save`. This method takes one argument that must be a string representing the local path where to save the image.
41
+
42
+ Examples:
43
+
44
+ qr = QuickResponse.url("robinclart.com")
45
+
46
+ qr.image_url
47
+ => "http://chart.apis.google.com/chart?cht=qr&chs=256x256&chl=http%3A%2F%2Frobinclart.com"
48
+
49
+ qr.save("/tmp/qr/robinclart_com.png")
50
+
51
+ ### Types
52
+
53
+ Available types are:
54
+
55
+ * Text (Takes many arguments that will be joined by a space)
56
+ * Url (Takes an url as first argument)
57
+ * Email (The first argument is a mail address)
58
+ * Call (The first argument is a phone number)
59
+ * Sms (The first argument is a phone number, the second (optional) is the message)
60
+ * Geo (Takes two arguments `longitude` and `lattitude`)
61
+ * Maps (Take an address as first argument and return a link to Google Maps)
62
+
63
+
@@ -22,7 +22,7 @@ module QuickResponse
22
22
  uri.to_s
23
23
  end
24
24
 
25
- def save(location = "./qr.png")
25
+ def save(location)
26
26
  Net::HTTP.start(uri.host) do |http|
27
27
  resp = http.get(image_url)
28
28
  open(location, 'wb') do |file|
@@ -1,5 +1,5 @@
1
1
  module QuickResponse
2
2
  class Call < ::QuickResponse::Base
3
- format "tel:(.*)"
3
+ format "tel:(.*)", :limit => 1
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module QuickResponse
2
2
  class Email < ::QuickResponse::Base
3
- format "mailto:(.*)"
3
+ format "mailto:(.*)", :limit => 1
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  module QuickResponse
2
2
  class Maps < ::QuickResponse::Base
3
- format "http://maps.google.com/maps?q=(.*)"
3
+ format "http://maps.google.com/maps?q=(.*)", :limit => 1
4
4
 
5
5
  def initialize(*args)
6
6
  args = args.map { |a| CGI.escape(a) }
@@ -1,5 +1,5 @@
1
1
  module QuickResponse
2
2
  class Text < ::QuickResponse::Base
3
- format "(.*)"
3
+ format "(.*)", :join => " "
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module QuickResponse
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robin Clart
@@ -46,6 +46,7 @@ extra_rdoc_files: []
46
46
  files:
47
47
  - .gitignore
48
48
  - Gemfile
49
+ - README.md
49
50
  - Rakefile
50
51
  - lib/quick_response.rb
51
52
  - lib/quick_response/base.rb