locu_wrapper 0.0.1

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 ADDED
@@ -0,0 +1,2 @@
1
+ This is a really simple locu wrapper I
2
+ created because we needed it for some hackathon
@@ -0,0 +1,31 @@
1
+ module Locu
2
+ class Client
3
+
4
+ API_VERSION = 'v1_0'
5
+
6
+ DEFAULTS = {
7
+ :host => 'http://api.locu.com'
8
+ }
9
+
10
+ # adding only a menu for now, should add
11
+ # venues later
12
+ attr_reader :menu, :venue
13
+
14
+ def initialize(api_key)
15
+ @api_key = api_key
16
+ @config = DEFAULTS
17
+ @host = @config[:host]
18
+ setup_attributes
19
+ end
20
+
21
+ private
22
+
23
+ def setup_attributes
24
+ menu_path = "/#{API_VERSION}/menu_item/search/"
25
+ venue_path = "/#{API_VERSION}/venue/search/"
26
+
27
+ @menu = Locu::Menu.new(@host, menu_path, @api_key)
28
+ @venue = Locu::Menu.new(@host, venue_path, @api_key)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ module Locu
2
+ class LocuObject
3
+
4
+ def initialize(host, path, api_key)
5
+ @api_key = api_key
6
+ @uri = URI(host+path)
7
+ end
8
+
9
+ private
10
+
11
+ def formulate_query(params_hash)
12
+ params_with_key = params_hash.merge({:api_key => @api_key})
13
+ URI.encode_www_form(params_with_key)
14
+ end
15
+
16
+ def parse_response(response)
17
+ JSON.parse(response.body) if response.is_a?(Net::HTTPSuccess)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Locu
2
+ class Menu < LocuObject
3
+
4
+ # a lot of the defaults are simply
5
+ # hardcoded for the techcrunch
6
+ # hackathon
7
+ DEFAULTS = {
8
+ :street_address => 'mission'
9
+ }
10
+
11
+ def initialize(host, path, api_key)
12
+ super(host, path, api_key)
13
+ end
14
+
15
+ def get_by_name(name)
16
+ @uri.query = formulate_query({:name => name})
17
+ response = Net::HTTP.get_response @uri
18
+ parse_response response
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module Locu
2
+ class Venue < LocuObject
3
+ def initialize(host, path, api_key)
4
+ super(host, path, api_key)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Locu
2
+ class Venue
3
+ # empty for now
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ require './locu_wrapper/locu_object.rb'
6
+ require './locu_wrapper/client.rb'
7
+ require './locu_wrapper/menu.rb'
8
+ require './locu_wrapper/venue.rb'
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: locu_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Nathaniel Escribano
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-08-09 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: LocuWraper - a really simple locu wrapper
22
+ email: nathanielescribano@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - README
31
+ - lib/locu_wrapper.rb
32
+ - lib/locu_wrapper/client.rb
33
+ - lib/locu_wrapper/locu_object.rb
34
+ - lib/locu_wrapper/menu.rb
35
+ - lib/locu_wrapper/venu.rb
36
+ - lib/locu_wrapper/venue.rb
37
+ has_rdoc: true
38
+ homepage: ""
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project: locu_wrapper
63
+ rubygems_version: 1.3.6
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: LocuWraper - a really simple locu wrapper
67
+ test_files: []
68
+