refreshingmenus_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RefreshingmenusApi
2
2
 
3
- Ruby API to use the Refreshing Menus REST API.
3
+ Ruby API to use the Refreshing Menus REST API and Javascript Widget.
4
4
 
5
5
  ## Installation
6
6
 
@@ -48,12 +48,22 @@ Because sometimes multiple places have the same phone number we can do more spec
48
48
 
49
49
  ## Widget usage
50
50
 
51
- RefreshingmenusApi::Widget.tag(:place_id => 'some_place_id', :widget_token => 'some_token')
51
+ RefreshingmenusApi::Widget.script_tag(:place_id => 'some_place_id', :widget_token => 'some_token')
52
52
 
53
53
  This will result in a script tag like:
54
54
 
55
55
  <script id='rm-menuwidget' src='http://www.refreshingmenus.com/api/v1/widget.js?dom_id=rm-menuwidget&place_id=some_place_id&widget_token=some_token'></script>"
56
56
 
57
+ If you just want the src of the script use:
58
+
59
+ RefreshingmenusApi::Widget.script_src(:place_id => 'some_place_id', :widget_token => 'some_token')
60
+ # => "http://www.refreshingmenus.com/api/v1/widget.js?dom_id=rm-menuwidget&place_id=some_place_id&widget_token=some_token"
61
+
62
+ Other supported options:
63
+
64
+ * locale - the language of the menu and other texts (disclaimer), defaults to 'nl'.
65
+ * style - the CSS style to apply, defaults to 'default'. Use 'none' if you don't want any style to be applied and you include your own.
66
+
57
67
  ## Contributing
58
68
 
59
69
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module RefreshingmenusApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -6,15 +6,20 @@ module RefreshingmenusApi
6
6
  # * place_id (required) - The RefreshingMenus Place ID (UUID)
7
7
  # * secure - Boolean, we'll use https if true
8
8
  # * style - The style name we should use (default: 'default'), use 'none' for no styling (if you embed your own styling)
9
- def self.tag(options)
9
+ def self.script_tag(options)
10
+ return "<script id='#{options[:dom_id]}' src='#{self.src(options)}'></script>"
11
+ end
12
+
13
+ def self.script_src(options)
14
+ options = options.clone # Don't fuck up Hash we don't own..
10
15
  raise ArgumentError, "Expected options argument to be a Hash, got #{options.inspect}." if not options.is_a?(Hash)
11
16
  options[:dom_id] = 'rm-menuwidget'
12
17
  raise ArgumentError, "Expected a :place_id as option but got #{options[:place_id].inspect}." if not options[:place_id].is_a?(String)
13
18
  raise ArgumentError, "Expected a :widget_token as option but got #{options[:widget_token].inspect}." if not options[:widget_token].is_a?(String)
14
19
  secure = options.delete(:secure)
15
20
  version = options.delete(:version) || '1'
16
- src = "#{secure ? 'https' : 'http'}://www.refreshingmenus.com/api/v#{version}/widget.js?#{options.to_param}"
17
- return "<script id='#{options[:dom_id]}' src='#{src}'></script>"
21
+ base_uri = options.delete(:base_uri) || 'www.refreshingmenus.com'
22
+ "#{secure ? 'https' : 'http'}://#{base_uri}/api/v#{version}/widget.js?#{options.to_param}"
18
23
  end
19
24
 
20
25
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joost Hietbrink