Browse files

Get things to run:

* Add dependencies to gemspec
* Set up a subledata namespace
* Require all models and lib files
* Add an example to the readme
  • Loading branch information...
1 parent cab9f24 commit 8ff25d18e39a86dc1288c8ca3c5ec106fd48388d @milagre milagre committed May 18, 2013
Showing with 55 additions and 8 deletions.
  1. +19 −3 README.md
  2. +26 −0 lib/subtledata.rb
  3. +2 −1 lib/swagger/configuration.rb
  4. +4 −2 lib/swagger/request.rb
  5. +4 −2 subtledata.gemspec
View
22 README.md
@@ -1,4 +1,20 @@
-subtledata_ruby
-===============
+SubtleData Ruby Library
+=======================
+
+Ruby Library for SubtleData's SubtleJSON API
+
+Install
+=======
+
+ gem install subtledata
+
+Example
+=======
+
+ require 'subtledata'
+
+ key = 'S0YrNTJY'
+
+ puts SubtleData::Standard::Locations.get_all_locationst(key, false).inspect
+ puts SubtleData::Standard::Locations.get_location(959, key, false).inspect
-Ruby Library for SubtleData's SubtleJSON API
View
26 lib/subtledata.rb
@@ -0,0 +1,26 @@
+
+models = File.join(File.dirname(__FILE__), '..', 'models', '*.rb')
+Dir[models].each {|file| require file }
+
+require_relative './general_api.rb'
+require_relative './locations_api.rb'
+require_relative './monkey.rb'
+require_relative './swagger.rb'
+require_relative './users_api.rb'
+
+Swagger.configure do |config|
+ config.format = 'json'
+ config.scheme = 'https'
+ config.host = 'api.subtledata.com'
+ config.base_path = '/v1'
+ config.inject_format = false
+end
+
+module SubtleData
+ module Standard
+ Locations = ::Locations_api
+ Users = ::Users_api
+ General = ::General_api
+ end
+end
+
View
3 lib/swagger/configuration.rb
@@ -3,7 +3,7 @@ module Swagger
class Configuration
require 'swagger/version'
- attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger
+ attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format
# Defaults go in here..
def initialize
@@ -12,6 +12,7 @@ def initialize
@host = 'api.wordnik.com'
@base_path = '/v4'
@user_agent = "ruby-#{Swagger::VERSION}"
+ @inject_format = true
end
end
View
6 lib/swagger/request.rb
@@ -81,8 +81,10 @@ def interpreted_path
# Stick a .{format} placeholder into the path if there isn't
# one already or an actual format like json or xml
# e.g. /words/blah => /words.{format}/blah
- unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
- p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
+ if Swagger.configuration.inject_format
+ unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
+ p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
+ end
end
p = p.sub("{format}", self.format.to_s)
View
6 subtledata.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = "Ruby Client Library for SubtleData",
s.description = "Ruby Client Library for SubtleData",
s.rubyforge_project = "subtledata"
- s.files = `find lib -name "*.rb"`.split("\n")
+ s.files = `find lib -name "*.rb"`.split("\n") + `find models -name "*.rb"`.split("\n")
=begin
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib", "models"]
# specify any dependencies here; for example:
- # s.add_runtime_dependency "httparty"
+ %w{ addressable typhoeus }.each do |dep|
+ s.add_runtime_dependency dep
+ end
end

0 comments on commit 8ff25d1

Please sign in to comment.