Skip to content

Commit

Permalink
Get things to run:
Browse files Browse the repository at this point in the history
* Add dependencies to gemspec
* Set up a subledata namespace
* Require all models and lib files
* Add an example to the readme
  • Loading branch information
milagre committed May 18, 2013
1 parent cab9f24 commit 8ff25d1
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
22 changes: 19 additions & 3 deletions 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
26 changes: 26 additions & 0 deletions 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

3 changes: 2 additions & 1 deletion lib/swagger/configuration.rb
Expand Up @@ -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
Expand All @@ -12,6 +12,7 @@ def initialize
@host = 'api.wordnik.com'
@base_path = '/v4'
@user_agent = "ruby-#{Swagger::VERSION}"
@inject_format = true
end

end
Expand Down
6 changes: 4 additions & 2 deletions lib/swagger/request.rb
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions subtledata.gemspec
Expand Up @@ -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")
Expand All @@ -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.