skiddle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d69dc09ff5e173a1f89e267ad690bee707dbdd2
4
+ data.tar.gz: 81f8ce3cdda3a5f69810f4efa88f81152b258b9d
5
+ SHA512:
6
+ metadata.gz: 59aec42b8580c1edfecabda5a3ee3cc668d42d067546230cdc46b887a3d602980a261e002da97c238b182b7a36c4cee18211981e9c05d99408c8464e837643ac
7
+ data.tar.gz: fb71b35fba7deccbfb7330eb9e3b09bdcdcc68f6b1c2cdf9083a6a8008ab48911ba1a2597807f3565bc9f5d5cc2e6f22e7ebca4349bc3b54997fc71714e29212
@@ -0,0 +1 @@
1
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skiddle.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+ require 'httparty'
3
+ require 'ostruct'
4
+ require 'uri'
5
+ require 'pry'
6
+
7
+ require_relative 'skiddle/document'
8
+ require_relative 'skiddle/client'
9
+ require_relative 'skiddle/event'
10
+ require_relative 'skiddle/venue'
11
+ require_relative 'skiddle/artist'
12
+ require_relative 'skiddle/version'
13
+
14
+ module Skiddle
15
+ end
@@ -0,0 +1,7 @@
1
+ module Skiddle
2
+ class Artist < Document
3
+ def self.search(params = {})
4
+ Client.make_request(Artist, "/artists", params)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ module Skiddle
2
+ module Client
3
+ include HTTParty
4
+
5
+ base_uri "http://www.skiddle.com/api/v1/"
6
+ format :json
7
+
8
+ def self.convert_query_to_url(params)
9
+ params.map do |k,v|
10
+ "&#{k}=#{v}"
11
+ end.join
12
+ end
13
+
14
+ def self.make_request(klass, endpoint, params = {})
15
+ query_url = convert_query_to_url(params)
16
+ result = get("#{endpoint}?api_key=#{ENV['SKIDDLE_API_KEY']}#{query_url}")
17
+ parsed_result = JSON.parse(result.body)
18
+ if parsed_result["error"] == 1
19
+ parsed_result
20
+ else
21
+ if parsed_result["results"].class == Array
22
+ objects = parsed_result["results"].map do |result|
23
+ klass.new(result)
24
+ end
25
+ objects.length == 1 ? objects.first : objects
26
+ else
27
+ klass.new(result)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ module Skiddle
2
+ class Document < OpenStruct
3
+
4
+ def self.demodulize(class_name_in_module)
5
+ class_name_in_module.to_s.gsub(/^.*::/, '')
6
+ end
7
+
8
+ def fields
9
+ @table.keys.map{|k| k.to_s}
10
+ end
11
+
12
+ def initialize(data = {})
13
+ raise ArgumentError, "Invalid data passed to Document.new: #{data.inspect}" unless data.is_a?(Hash)
14
+ super(data)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module Skiddle
2
+ class Event < Document
3
+ def self.find_by_event_id(event_id)
4
+ Client.make_request(Event, "/events/#{event_id}")
5
+ end
6
+
7
+ def self.search(params = {})
8
+ Client.make_request(Event, "/events", params)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Skiddle
2
+ class Venue < Document
3
+ def self.find_by_venue_id(venue_id)
4
+ Client.make_request(Venue, "/venues/#{venue_id}")
5
+ end
6
+
7
+ def self.search(params = {})
8
+ Client.make_request(Venue, "/venues", params)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Skiddle
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skiddle/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'skiddle'
8
+ gem.version = Skiddle::VERSION
9
+ gem.authors = ["Creo Mark"]
10
+ gem.email = 'contact@7precisions.com'
11
+ gem.description = %q{A Ruby gem for accessing the skiddle api}
12
+ gem.summary = %q{A Ruby gem for accessing the skiddle api}
13
+ gem.homepage = "https://github.com/CreoMark/skiddle-ruby"
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.require_paths = ["lib"]
17
+ gem.add_development_dependency 'httparty', '~> 0', '0.13.5'
18
+ gem.license = 'GNU'
19
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skiddle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Creo Mark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.13.5
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.5
33
+ description: A Ruby gem for accessing the skiddle api
34
+ email: contact@7precisions.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".gitignore"
40
+ - ".rspec"
41
+ - Gemfile
42
+ - Rakefile
43
+ - lib/skiddle.rb
44
+ - lib/skiddle/artist.rb
45
+ - lib/skiddle/client.rb
46
+ - lib/skiddle/document.rb
47
+ - lib/skiddle/event.rb
48
+ - lib/skiddle/venue.rb
49
+ - lib/skiddle/version.rb
50
+ - skiddle.gemspec
51
+ homepage: https://github.com/CreoMark/skiddle-ruby
52
+ licenses:
53
+ - GNU
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.4.8
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: A Ruby gem for accessing the skiddle api
75
+ test_files: []
76
+ has_rdoc: