Permalink
Browse files

minor cleanup

  • Loading branch information...
1 parent 6b2c5aa commit 5a1fb48088c5147625fc21fe18cda78ad7f42cb5 @schorsch schorsch committed May 8, 2010
Showing with 103 additions and 17 deletions.
  1. +11 −8 lib/king_soa.rb
  2. +71 −0 sk-hoth.gemspec
  3. +17 −7 spec/king_soa/rack/middleware_spec.rb
  4. +4 −2 spec/server/app.rb
View
@@ -31,23 +31,26 @@ module KingSoa
class << self
- def init_from_yaml(loc)
+ def init_from_hash(services)
+ # create service
end
+
# Locate service by a given name
# ==== Params
# service<String|Symbol>:: the name to lookup
def find(service)
Registry[service]
end
- # this is where the services get called
- def method_missing(meth, *args, &blk) # :nodoc:
- if service = Registry[meth]
- service.execute(*args)
- else
- super
- end
+
+ # this is where the services get called
+ def method_missing(meth, *args, &blk) # :nodoc:
+ if service = Registry[meth]
+ service.execute(*args)
+ else
+ super
end
end
+ end
end
View
@@ -0,0 +1,71 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{sk-hoth}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Georg Leciejewski"]
+ s.date = %q{2010-05-08}
+ s.description = %q{Creating a SOA requires a centralized location to define all services within the
+SOA. Furthermore you want to know where to deploy those services.
+}
+ s.email = %q{gl@salesking.eu}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ "README.rdoc",
+ "lib/king_soa.rb",
+ "lib/king_soa/rack/middleware.rb",
+ "lib/king_soa/registry.rb",
+ "lib/king_soa/service.rb",
+ "spec/king_soa/rack/middleware_spec.rb",
+ "spec/king_soa/registry_spec.rb",
+ "spec/king_soa/service_spec.rb",
+ "spec/server/app.rb",
+ "spec/spec_helper.rb"
+ ]
+ s.homepage = %q{http://github.com/salesking/king_soa}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.6}
+ s.summary = %q{Registry and deployment description abstraction for SOA-Services. Tweaked by SalesKing}
+ s.test_files = [
+ "spec/spec_helper.rb",
+ "spec/king_soa/registry_spec.rb",
+ "spec/king_soa/service_spec.rb",
+ "spec/king_soa/rack/middleware_spec.rb",
+ "spec/server/app.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<curb>, [">= 0"])
+ s.add_runtime_dependency(%q<json>, [">= 0"])
+ s.add_runtime_dependency(%q<king_hmac>, [">= 0"])
+ s.add_development_dependency(%q<rspec>, [">= 0"])
+ s.add_development_dependency(%q<webmock>, [">= 0"])
+ else
+ s.add_dependency(%q<curb>, [">= 0"])
+ s.add_dependency(%q<json>, [">= 0"])
+ s.add_dependency(%q<king_hmac>, [">= 0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
+ s.add_dependency(%q<webmock>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<curb>, [">= 0"])
+ s.add_dependency(%q<json>, [">= 0"])
+ s.add_dependency(%q<king_hmac>, [">= 0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
+ s.add_dependency(%q<webmock>, [">= 0"])
+ end
+end
+
@@ -1,26 +1,36 @@
require File.dirname(__FILE__) + '/../../spec_helper.rb'
-#set :environment, :test
-
describe KingSoa::Rack::Middleware do
include Rack::Test::Methods
before(:each) do
@service = KingSoa::Service.new(:url=>'localhost', :name=>'a_method')
KingSoa::Registry << @service
end
-
- def app
- dummy_app = lambda { |env| puts "in dummy"; [200, {}, ""] }
- KingSoa::Rack::Middleware.new(dummy_app)
+ it "should be able to handle exceptions" do
+ app = stub("ApplicationStub").as_null_object
+ middleware = KingSoa::Rack::Middleware.new(app)
+ env = {"PATH_INFO" => "/soa", "name" => 'a_method'}
+
+ rack_response = middleware.call env
+ rack_response.first.should == 500 #status code
+ rack_response.last.should be_a_kind_of(Array)
+ rack_response.last.first.should == "{\"error\":\"An error occurred! (Missing rack.input)\"}"
end
- it "says hello" do
+ xit "says hello" do
+ app = stub("ApplicationStub").as_null_object
+ middleware = Hoth::Providers::RackProvider.new(app)
+
get '/soa', :name=>'a_method', :params=> "#{{:number=>1}.to_json}"
last_response.should == 'ads'#be_ok
last_response.body.should == 'Hello World'
end
+# def app
+# dummy_app = lambda { |env| puts "in dummy"; [200, {}, ""] }
+# KingSoa::Rack::Middleware.new(dummy_app)
+# end
end
View
@@ -2,19 +2,21 @@
require 'rubygems'
require 'sinatra'
require "#{File.dirname(__FILE__)}/../../lib/king_soa"
-#require "#{File.dirname(__FILE__)}/../../lib/king_soa/rack/middleware"
use KingSoa::Rack::Middleware
+###################################################
+# method to kill this server instance
+#'/die'
#######################################
# Somewhere in you app
#
# setup test registry
service = KingSoa::Service.new(:name=>'soa_test_service', :auth_key=>'12345')
KingSoa::Registry << service
-# the class beeing called lokally
+# the class beeing called localy
class SoaTestService
def self.perform(param1, param2, param3)

0 comments on commit 5a1fb48

Please sign in to comment.