tango-etl 0.0.1 → 0.1.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.
- checksums.yaml +4 -4
- data/{changelog.md → CHANGELOG.md} +5 -1
- data/{readme.md → README.md} +1 -1
- data/doc/Multidb/Balancer.html +202 -0
- data/doc/Multidb.html +184 -0
- data/doc/Tango/AbstractModel.html +608 -0
- data/doc/Tango/App.html +1334 -0
- data/doc/Tango/DatabaseLocker.html +541 -0
- data/doc/Tango/ETL/Dispatcher.html +465 -0
- data/doc/Tango/ETL/HandlerInterface.html +639 -0
- data/doc/Tango/ETL/OperatorInterface.html +494 -0
- data/doc/Tango/ETL.html +117 -0
- data/doc/Tango/Kernel.html +432 -0
- data/doc/Tango/LinkStack.html +737 -0
- data/doc/Tango/Resource/Buffer.html +565 -0
- data/doc/Tango/Resource/Cache.html +834 -0
- data/doc/Tango/Resource.html +117 -0
- data/doc/Tango.html +131 -0
- data/doc/_index.html +297 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +80 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +80 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +365 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/tango/abstract_model.rb +1 -0
- data/lib/tango/app.rb +4 -7
- data/lib/tango/database_locker.rb +23 -2
- data/lib/tango/etl/handler_interface.rb +12 -6
- data/lib/tango/resource/buffer.rb +7 -7
- data/lib/tango/resource/cache.rb +18 -13
- data/lib/tango/version.rb +1 -1
- data/test/support/lib/simple_handler.rb +5 -14
- data/test/unit/etl/test_dispatcher.rb +21 -5
- metadata +33 -6
- data/config/app.yml.sample +0 -6
- data/config/database.yml.sample +0 -27
data/lib/tango/resource/cache.rb
CHANGED
@@ -8,10 +8,10 @@ module Tango
|
|
8
8
|
|
9
9
|
attr_reader :buffer
|
10
10
|
|
11
|
-
# Constructor of the
|
11
|
+
# Constructor of the Cache
|
12
12
|
#
|
13
|
-
# @param
|
14
|
-
# @return
|
13
|
+
# @param buffer [Tango::Resources::Buffer]
|
14
|
+
# @return [Tango::Resources::Cache]
|
15
15
|
def initialize( buffer = nil )
|
16
16
|
# Set dependencies
|
17
17
|
@buffer = buffer || Buffer.new
|
@@ -21,20 +21,25 @@ module Tango
|
|
21
21
|
|
22
22
|
# Register new type of resource to be cached
|
23
23
|
#
|
24
|
-
# @param
|
25
|
-
# @param
|
24
|
+
# @param type [Symbol]
|
25
|
+
# @param release_callback [Proc]
|
26
|
+
# @return [Tango::Resource::Cache]
|
26
27
|
def register( type, &release_callback )
|
28
|
+
|
27
29
|
# Create container for cache of new resource
|
28
30
|
@storage[type] = {}
|
29
31
|
# Also register new type with buffer
|
30
32
|
@buffer.register( type, &release_callback )
|
33
|
+
|
34
|
+
self
|
35
|
+
|
31
36
|
end
|
32
37
|
|
33
|
-
# Get a resource or use given block to
|
38
|
+
# Get a cached resource or use given block to obtain resource and return it
|
34
39
|
#
|
35
40
|
# @param type [Symbol]
|
36
41
|
# @param resource [Object]
|
37
|
-
# @return [
|
42
|
+
# @return [Object]
|
38
43
|
def load( type, resource )
|
39
44
|
|
40
45
|
# Get resource from cache
|
@@ -58,9 +63,9 @@ module Tango
|
|
58
63
|
|
59
64
|
# Setter for the cache storage
|
60
65
|
#
|
61
|
-
# @param
|
62
|
-
# @param
|
63
|
-
# @return
|
66
|
+
# @param type [Symbol]
|
67
|
+
# @param resource [Object]
|
68
|
+
# @return [Object]
|
64
69
|
def set( type, resource )
|
65
70
|
raise ArgumentError, "Trying to set resource with unregistered type" unless @storage.keys.include?( type )
|
66
71
|
@storage[type][resource.cache_key] = resource
|
@@ -68,9 +73,9 @@ module Tango
|
|
68
73
|
|
69
74
|
# Getter for the cache storage
|
70
75
|
#
|
71
|
-
# @param
|
72
|
-
# @param
|
73
|
-
# @return
|
76
|
+
# @param type [Symbol]
|
77
|
+
# @param key [String]
|
78
|
+
# @return [Object]
|
74
79
|
def get( type, resource )
|
75
80
|
raise ArgumentError, "Trying to get resource with unregistered type" unless @storage.keys.include?( type )
|
76
81
|
@storage[type][resource.cache_key]
|
data/lib/tango/version.rb
CHANGED
@@ -1,18 +1,9 @@
|
|
1
|
-
|
1
|
+
require 'tango/etl/handler_interface'
|
2
|
+
|
3
|
+
class SimpleHandler < Tango::ETL::HandlerInterface
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@register_counter = 0
|
7
|
-
@fill_couter = 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def register( type )
|
11
|
-
@register_counter += 1
|
12
|
-
end
|
13
|
-
|
14
|
-
def fill( type, resource )
|
15
|
-
@fill_couter += 1
|
5
|
+
def self.applicable?( link )
|
6
|
+
link =~ /index\.html/
|
16
7
|
end
|
17
8
|
|
18
9
|
end
|
@@ -2,19 +2,35 @@ require "test/unit"
|
|
2
2
|
require 'shoulda'
|
3
3
|
require 'mocha/setup'
|
4
4
|
|
5
|
-
require 'tango/
|
5
|
+
require 'tango/etl/dispatcher'
|
6
6
|
require_relative '../../support/lib/simple_handler.rb'
|
7
7
|
|
8
8
|
class TestDispatcher < Test::Unit::TestCase
|
9
9
|
|
10
|
-
context "
|
10
|
+
context "handler dispatcher" do
|
11
11
|
|
12
12
|
setup do
|
13
|
-
@dispatcher
|
13
|
+
@dispatcher = Tango::ETL::Dispatcher.new
|
14
14
|
end
|
15
15
|
|
16
|
-
should "throw exception when trying to
|
17
|
-
|
16
|
+
should "throw exception when trying to register handler that does not implement HandlerInterface" do
|
17
|
+
assert_raise RuntimeError do
|
18
|
+
@dispatcher.register( Object )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
should "register handler and stay chainable" do
|
23
|
+
assert_equal @dispatcher, @dispatcher.register( SimpleHandler )
|
24
|
+
end
|
25
|
+
|
26
|
+
should "find handler for a suitable link" do
|
27
|
+
@dispatcher.register( SimpleHandler ) # SimpleHandler works only with '/index.html' link
|
28
|
+
assert_equal SimpleHandler, @dispatcher.find_handler( '/index.html' )
|
29
|
+
end
|
30
|
+
|
31
|
+
should "return nil if there is no handler suitable for a link" do
|
32
|
+
@dispatcher.register( SimpleHandler ) # SimpleHandler works only with '/index.html' link
|
33
|
+
assert_equal nil, @dispatcher.find_handler( '/picutres/1.html' )
|
18
34
|
end
|
19
35
|
|
20
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tango-etl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Komorowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -116,11 +116,39 @@ executables: []
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- CHANGELOG.md
|
119
120
|
- Gemfile
|
121
|
+
- README.md
|
120
122
|
- Rakefile
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
123
|
+
- doc/Multidb.html
|
124
|
+
- doc/Multidb/Balancer.html
|
125
|
+
- doc/Tango.html
|
126
|
+
- doc/Tango/AbstractModel.html
|
127
|
+
- doc/Tango/App.html
|
128
|
+
- doc/Tango/DatabaseLocker.html
|
129
|
+
- doc/Tango/ETL.html
|
130
|
+
- doc/Tango/ETL/Dispatcher.html
|
131
|
+
- doc/Tango/ETL/HandlerInterface.html
|
132
|
+
- doc/Tango/ETL/OperatorInterface.html
|
133
|
+
- doc/Tango/Kernel.html
|
134
|
+
- doc/Tango/LinkStack.html
|
135
|
+
- doc/Tango/Resource.html
|
136
|
+
- doc/Tango/Resource/Buffer.html
|
137
|
+
- doc/Tango/Resource/Cache.html
|
138
|
+
- doc/_index.html
|
139
|
+
- doc/class_list.html
|
140
|
+
- doc/css/common.css
|
141
|
+
- doc/css/full_list.css
|
142
|
+
- doc/css/style.css
|
143
|
+
- doc/file.README.html
|
144
|
+
- doc/file_list.html
|
145
|
+
- doc/frames.html
|
146
|
+
- doc/index.html
|
147
|
+
- doc/js/app.js
|
148
|
+
- doc/js/full_list.js
|
149
|
+
- doc/js/jquery.js
|
150
|
+
- doc/method_list.html
|
151
|
+
- doc/top-level-namespace.html
|
124
152
|
- lib/tango.rb
|
125
153
|
- lib/tango/abstract_model.rb
|
126
154
|
- lib/tango/app.rb
|
@@ -136,7 +164,6 @@ files:
|
|
136
164
|
- lib/tango/resource/buffer.rb
|
137
165
|
- lib/tango/resource/cache.rb
|
138
166
|
- lib/tango/version.rb
|
139
|
-
- readme.md
|
140
167
|
- tango.gemspec
|
141
168
|
- test/support/db/schema.rb
|
142
169
|
- test/support/lib/model/user.rb
|
data/config/app.yml.sample
DELETED
data/config/database.yml.sample
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
adapter: mysql2
|
3
|
-
database: tango_dev_master
|
4
|
-
username: root
|
5
|
-
password: pass
|
6
|
-
host: localhost
|
7
|
-
multidb:
|
8
|
-
databases:
|
9
|
-
slave:
|
10
|
-
database: tango_dev_slave
|
11
|
-
production:
|
12
|
-
adapter: mysql2
|
13
|
-
database: tango_prod_master
|
14
|
-
username: root
|
15
|
-
password: pass
|
16
|
-
host: localhost
|
17
|
-
multidb:
|
18
|
-
databases:
|
19
|
-
slave:
|
20
|
-
database: tango_prod_slave
|
21
|
-
test:
|
22
|
-
adapter: mysql2
|
23
|
-
database: tango_test
|
24
|
-
username: root
|
25
|
-
password: pass
|
26
|
-
host: localhost
|
27
|
-
|