railsbros-thrift4rails 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -1
- data/Manifest.txt +3 -0
- data/README.rdoc +2 -1
- data/Rakefile +3 -1
- data/lib/thrift4rails.rb +4 -1
- data/lib/thrift4rails/client_stub_for_testing.rb +7 -0
- data/lib/thrift4rails/release_active_record_connection.rb +40 -0
- data/lib/thrift4rails/tasks/service.rake +5 -1
- data/lib/thrift4rails/thrift_client.rb +1 -1
- data/test/release_active_record_connection_test.rb +58 -0
- data/test/test_helper.rb +2 -0
- data/test/test_thrift4rails.rb +11 -11
- data/thrift4rails.gemspec +14 -8
- metadata +30 -8
data/History.txt
CHANGED
@@ -4,5 +4,7 @@
|
|
4
4
|
* Initial release
|
5
5
|
* created ThriftClient
|
6
6
|
* created first rake-tasks to generate thrift definitions
|
7
|
-
* Version 0.2.0
|
7
|
+
* 2 Version 0.2.0
|
8
8
|
* ThriftClient catches the Thrift::ProtocolException now
|
9
|
+
* Version 0.2.2
|
10
|
+
* ClientStubForTesting added, It catches all methods and returns true
|
data/Manifest.txt
CHANGED
@@ -4,6 +4,8 @@ PostInstall.txt
|
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
6
|
lib/thrift4rails.rb
|
7
|
+
lib/thrift4rails/client_stub_for_testing.rb
|
8
|
+
lib/thrift4rails/release_active_record_connection.rb
|
7
9
|
lib/thrift4rails/tasks.rb
|
8
10
|
lib/thrift4rails/tasks/generate.rake
|
9
11
|
lib/thrift4rails/tasks/service.rake
|
@@ -14,6 +16,7 @@ script/destroy
|
|
14
16
|
script/generate
|
15
17
|
tasks/Rakefile
|
16
18
|
tasks/thrift.rb
|
19
|
+
test/release_active_record_connection_test.rb
|
17
20
|
test/test_helper.rb
|
18
21
|
test/test_thrift4rails.rb
|
19
22
|
thrift4rails.gemspec
|
data/README.rdoc
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
7
|
+
module Thrift4Rails::ReleaseActiveRecordConnection ist in der Version 0.3.0 dazugekommen
|
8
|
+
Wenn das Modul inkludiert wird, wird nach jedem Methodenaufruf zusaetzlich ActiveRecord::Base.clear_active_connections! aufgerufen.
|
8
9
|
|
9
10
|
== FEATURES/PROBLEMS:
|
10
11
|
|
data/Rakefile
CHANGED
@@ -11,9 +11,11 @@ $hoe = Hoe.new('thrift4rails', Thrift4Rails::VERSION) do |p|
|
|
11
11
|
p.rubyforge_name = p.name # TODO this is default value
|
12
12
|
p.extra_deps = [
|
13
13
|
['activesupport','>= 2.3.2'],
|
14
|
+
['activerecord', '>= 2.3.2']
|
14
15
|
]
|
15
16
|
p.extra_dev_deps = [
|
16
|
-
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
['newgem', ">= #{::Newgem::VERSION}"],
|
18
|
+
['mocha']
|
17
19
|
]
|
18
20
|
|
19
21
|
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
data/lib/thrift4rails.rb
CHANGED
@@ -2,8 +2,11 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
require 'activesupport'
|
5
|
+
require "activerecord"
|
5
6
|
require 'thrift4rails/thrift_client'
|
7
|
+
require 'thrift4rails/client_stub_for_testing'
|
8
|
+
require 'thrift4rails/release_active_record_connection'
|
6
9
|
|
7
10
|
module Thrift4Rails
|
8
|
-
VERSION = '0.
|
11
|
+
VERSION = '0.3.1'
|
9
12
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Thrift4Rails
|
2
|
+
module ReleaseActiveRecordConnection
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def singleton_method_added(method_name)
|
9
|
+
@@class_singleton_methods ||= []
|
10
|
+
if !(method_name.to_s =~ /_execution_callback/) && !@@class_singleton_methods.include?(method_name)
|
11
|
+
@@class_singleton_methods << method_name
|
12
|
+
@@current_method_name = method_name
|
13
|
+
class << self
|
14
|
+
method_name = @@current_method_name
|
15
|
+
define_method "#{method_name}_with_execution_callback" do |*args|
|
16
|
+
return_value = self.send("#{method_name}_without_execution_callback", *args)
|
17
|
+
ActiveRecord::Base.clear_active_connections!
|
18
|
+
return return_value
|
19
|
+
end
|
20
|
+
alias_method_chain method_name, :execution_callback
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_added(method_name)
|
26
|
+
@@class_instance_methods ||= []
|
27
|
+
if !(method_name.to_s =~ /_execution_callback/) && !@@class_instance_methods.include?(method_name)
|
28
|
+
@@class_instance_methods << method_name
|
29
|
+
define_method "#{method_name}_with_execution_callback" do |*args|
|
30
|
+
return_value = self.send("#{method_name}_without_execution_callback", *args)
|
31
|
+
ActiveRecord::Base.clear_active_connections!
|
32
|
+
return return_value
|
33
|
+
end
|
34
|
+
alias_method_chain method_name, :execution_callback
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -2,7 +2,11 @@ namespace :service do
|
|
2
2
|
|
3
3
|
desc "Start server of service on port #{Service.port}"
|
4
4
|
task :start do
|
5
|
-
|
5
|
+
add_rails_env = ""
|
6
|
+
if ENV["RAILS_ENV"]
|
7
|
+
add_rails_env = " -e #{ENV["RAILS_ENV"]}"
|
8
|
+
end
|
9
|
+
system "script/server -p #{Service.port}#{add_rails_env}"
|
6
10
|
end
|
7
11
|
|
8
12
|
end
|
@@ -72,7 +72,7 @@ module Thrift4Rails
|
|
72
72
|
client_exception = ClientException.new("No connection to Provider: #{@url}. (Original Error: #{e.message})")
|
73
73
|
client_exception.set_backtrace(e.backtrace)
|
74
74
|
raise client_exception
|
75
|
-
rescue Errno::ETIMEDOUT => e
|
75
|
+
rescue Errno::ETIMEDOUT, Timeout::Error => e
|
76
76
|
client_exception = ClientException.new("Connection to Provider '#{@url}' timed out. (Original Error: #{e.message})")
|
77
77
|
client_exception.set_backtrace(e.backtrace)
|
78
78
|
raise client_exception
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/thrift4rails/release_active_record_connection'
|
3
|
+
|
4
|
+
|
5
|
+
# class definition
|
6
|
+
class TestClass
|
7
|
+
include Thrift4Rails::ReleaseActiveRecordConnection
|
8
|
+
|
9
|
+
def self.class_test1
|
10
|
+
Array.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.class_test2(arg)
|
14
|
+
Array.new
|
15
|
+
arg
|
16
|
+
end
|
17
|
+
|
18
|
+
def instance_test1
|
19
|
+
Array.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def instance_test2(arg)
|
23
|
+
Array.new
|
24
|
+
arg
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
# end class definition
|
29
|
+
|
30
|
+
class TestThrift4Rails < Test::Unit::TestCase
|
31
|
+
|
32
|
+
def test_should_code_after_class_method_calls_without_params
|
33
|
+
Array.expects(:new).times(2)
|
34
|
+
ActiveRecord::Base.expects(:clear_active_connections!)
|
35
|
+
assert_equal Array.new ,TestClass.class_test1
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_code_after_class_method_calls_with_params
|
39
|
+
Array.expects(:new)
|
40
|
+
ActiveRecord::Base.expects(:clear_active_connections!)
|
41
|
+
assert_equal "success",TestClass.class_test2("success")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_should_code_after_instance_method_calls_without_params
|
45
|
+
test_class = TestClass.new
|
46
|
+
Array.expects(:new).times(2)
|
47
|
+
ActiveRecord::Base.expects(:clear_active_connections!)
|
48
|
+
assert_equal Array.new ,test_class.instance_test1
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_should_code_after_instance_method_calls_with_params
|
52
|
+
test_class = TestClass.new
|
53
|
+
Array.expects(:new)
|
54
|
+
ActiveRecord::Base.expects(:clear_active_connections!)
|
55
|
+
assert_equal "success" ,test_class.instance_test2("success")
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/test/test_helper.rb
CHANGED
data/test/test_thrift4rails.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestThrift4Rails < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_truth
|
9
|
-
assert true
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestThrift4Rails < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_truth
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
end
|
data/thrift4rails.gemspec
CHANGED
@@ -2,41 +2,47 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{thrift4rails}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["pkw.de Development Team"]
|
9
|
-
s.date = %q{2009-
|
10
|
-
s.description = %q{
|
9
|
+
s.date = %q{2009-09-03}
|
10
|
+
s.description = %q{module Thrift4Rails::ReleaseActiveRecordConnection ist in der Version 0.3.0 dazugekommen
|
11
|
+
Wenn das Modul inkludiert wird, wird nach jedem Methodenaufruf zusaetzlich ActiveRecord::Base.clear_active_connections! aufgerufen.}
|
11
12
|
s.email = ["dev@pkw.de"]
|
12
13
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
13
|
-
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/thrift4rails.rb", "lib/thrift4rails/tasks.rb", "lib/thrift4rails/tasks/generate.rake", "lib/thrift4rails/tasks/service.rake", "lib/thrift4rails/tasks/tunnel.rake", "lib/thrift4rails/thrift_client.rb", "script/console", "script/destroy", "script/generate", "tasks/Rakefile", "tasks/thrift.rb", "test/test_helper.rb", "test/test_thrift4rails.rb", "thrift4rails.gemspec"]
|
14
|
-
s.has_rdoc = true
|
14
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/thrift4rails.rb", "lib/thrift4rails/client_stub_for_testing.rb", "lib/thrift4rails/release_active_record_connection.rb", "lib/thrift4rails/tasks.rb", "lib/thrift4rails/tasks/generate.rake", "lib/thrift4rails/tasks/service.rake", "lib/thrift4rails/tasks/tunnel.rake", "lib/thrift4rails/thrift_client.rb", "script/console", "script/destroy", "script/generate", "tasks/Rakefile", "tasks/thrift.rb", "test/release_active_record_connection_test.rb", "test/test_helper.rb", "test/test_thrift4rails.rb", "thrift4rails.gemspec"]
|
15
15
|
s.homepage = %q{http://github.com/#{github_username}/#{project_name}}
|
16
16
|
s.post_install_message = %q{PostInstall.txt}
|
17
17
|
s.rdoc_options = ["--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{thrift4rails}
|
20
|
-
s.rubygems_version = %q{1.3.
|
21
|
-
s.summary = %q{
|
20
|
+
s.rubygems_version = %q{1.3.5}
|
21
|
+
s.summary = %q{module Thrift4Rails::ReleaseActiveRecordConnection ist in der Version 0.3.0 dazugekommen Wenn das Modul inkludiert wird, wird nach jedem Methodenaufruf zusaetzlich ActiveRecord::Base.clear_active_connections! aufgerufen.}
|
22
22
|
s.test_files = ["test/test_helper.rb", "test/test_thrift4rails.rb"]
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
25
25
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
-
s.specification_version =
|
26
|
+
s.specification_version = 3
|
27
27
|
|
28
28
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
29
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
|
30
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.3.2"])
|
30
31
|
s.add_development_dependency(%q<newgem>, [">= 1.4.1"])
|
32
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
31
33
|
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
34
|
else
|
33
35
|
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
36
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.2"])
|
34
37
|
s.add_dependency(%q<newgem>, [">= 1.4.1"])
|
38
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
35
39
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
36
40
|
end
|
37
41
|
else
|
38
42
|
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
43
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.2"])
|
39
44
|
s.add_dependency(%q<newgem>, [">= 1.4.1"])
|
45
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
40
46
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
41
47
|
end
|
42
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsbros-thrift4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pkw.de Development Team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 2.3.2
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activerecord
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.2
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: newgem
|
27
37
|
type: :development
|
@@ -32,6 +42,16 @@ dependencies:
|
|
32
42
|
- !ruby/object:Gem::Version
|
33
43
|
version: 1.4.1
|
34
44
|
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: mocha
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
35
55
|
- !ruby/object:Gem::Dependency
|
36
56
|
name: hoe
|
37
57
|
type: :development
|
@@ -42,7 +62,7 @@ dependencies:
|
|
42
62
|
- !ruby/object:Gem::Version
|
43
63
|
version: 1.8.0
|
44
64
|
version:
|
45
|
-
description:
|
65
|
+
description: module Thrift4Rails::ReleaseActiveRecordConnection ist in der Version 0.3.0 dazugekommen Wenn das Modul inkludiert wird, wird nach jedem Methodenaufruf zusaetzlich ActiveRecord::Base.clear_active_connections! aufgerufen.
|
46
66
|
email:
|
47
67
|
- dev@pkw.de
|
48
68
|
executables: []
|
@@ -61,6 +81,8 @@ files:
|
|
61
81
|
- README.rdoc
|
62
82
|
- Rakefile
|
63
83
|
- lib/thrift4rails.rb
|
84
|
+
- lib/thrift4rails/client_stub_for_testing.rb
|
85
|
+
- lib/thrift4rails/release_active_record_connection.rb
|
64
86
|
- lib/thrift4rails/tasks.rb
|
65
87
|
- lib/thrift4rails/tasks/generate.rake
|
66
88
|
- lib/thrift4rails/tasks/service.rake
|
@@ -71,12 +93,12 @@ files:
|
|
71
93
|
- script/generate
|
72
94
|
- tasks/Rakefile
|
73
95
|
- tasks/thrift.rb
|
96
|
+
- test/release_active_record_connection_test.rb
|
74
97
|
- test/test_helper.rb
|
75
98
|
- test/test_thrift4rails.rb
|
76
99
|
- thrift4rails.gemspec
|
77
|
-
has_rdoc:
|
100
|
+
has_rdoc: false
|
78
101
|
homepage: http://github.com/#{github_username}/#{project_name}
|
79
|
-
licenses:
|
80
102
|
post_install_message: PostInstall.txt
|
81
103
|
rdoc_options:
|
82
104
|
- --main
|
@@ -98,10 +120,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
120
|
requirements: []
|
99
121
|
|
100
122
|
rubyforge_project: thrift4rails
|
101
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.2.0
|
102
124
|
signing_key:
|
103
|
-
specification_version:
|
104
|
-
summary:
|
125
|
+
specification_version: 3
|
126
|
+
summary: module Thrift4Rails::ReleaseActiveRecordConnection ist in der Version 0.3.0 dazugekommen Wenn das Modul inkludiert wird, wird nach jedem Methodenaufruf zusaetzlich ActiveRecord::Base.clear_active_connections! aufgerufen.
|
105
127
|
test_files:
|
106
128
|
- test/test_helper.rb
|
107
129
|
- test/test_thrift4rails.rb
|