Skip to content

Commit

Permalink
merge spore.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Sukrieh committed Oct 26, 2010
1 parent af07433 commit e75b84b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/spore.rb
Expand Up @@ -20,6 +20,7 @@ class Spore
attr_accessor :base_url, :format, :version
attr_accessor :methods
attr_accessor :middlewares
attr_reader :specs

class RequiredParameterExptected < Exception
end
Expand All @@ -30,6 +31,9 @@ class UnexpectedResponse < Exception
class UnsupportedSpec < Exception
end

class InvalidHeaders < Exception
end

##
# Initialize a Spore instance with a specification file<br/>
# Optionally a file to require the parser from and the custom bound Parser class
Expand All @@ -55,8 +59,6 @@ class UnsupportedSpec < Exception
# end
# end
#


def initialize(spec,options = {})
# Don't load gems that are not needed
# Only when it requires json, then json is loaded
Expand All @@ -66,7 +68,7 @@ def initialize(spec,options = {})
inititliaze_api_attrs(specs)
construct_client_class(self.methods)
self.middlewares = []
end
end

def enable(middleware, args={})
m = middleware.new(args)
Expand Down Expand Up @@ -95,7 +97,6 @@ def enable_if(middleware, args={}, &block)
# * :require is a file to require
# * :parser is a String to pass in Object.const_get
#

def self.load_parser(spec, options = {})
case spec
when /\.ya?ml/
Expand All @@ -110,7 +111,6 @@ def self.load_parser(spec, options = {})
if options.has_key?(:parser)
Object.const_get(options[:parser])
else
# Let use the same object as in require
Object.const_get(options[:require].to_s.capitalize)
end
else
Expand Down
3 changes: 3 additions & 0 deletions lib/spore/spec_parser/yaml.rb
Expand Up @@ -3,9 +3,12 @@
class Spore
module SpecParser
class Yaml
attr_reader :specs

def self.load_file(f)
YAML.load_file(f)
end

end
end
end
1 change: 1 addition & 0 deletions test/test_parser.rb
Expand Up @@ -28,6 +28,7 @@ def test_custom_parser
warn "Can not load XmlSimple gem. Please gem install xml-simple to run this test"
return
end

specs = parser.load_file(spec)
assert_instance_of Hash, specs
assert specs.has_key?('name')
Expand Down

0 comments on commit e75b84b

Please sign in to comment.