tzispa_data 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/tzispa/data/repository.rb +37 -16
- data/lib/tzispa/data/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d93f8550dc521d79171ed9b7a38ea5b3cd130260
|
4
|
+
data.tar.gz: f984c6b25aa8f4dd2b6bc663a5099e98eaac68ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ef78463937d73e27ddf3cfa42546d243f4833e572161c52c437867517ec128720451570aa1336f821ca3178cb5898a8ad24ecb277ae0bd2fd75e82003755def
|
7
|
+
data.tar.gz: af14bd698ae4086476728169758bc7a4627e4bbe488deced716c3adcfea43f3376446bd59f342c3457ac20251bcbf7e7560a52a95e1ea0dfaa5df8ed5f745587
|
data/CHANGELOG.md
CHANGED
@@ -29,21 +29,34 @@ module Tzispa
|
|
29
29
|
|
30
30
|
def [](model, repo_id=nil)
|
31
31
|
selected_repo = repo_id || @adapters.default
|
32
|
-
raise UnknownModel.new("The '#{model}' model does not exists in the adapter '#{selected_repo}'") unless @pool.has_key?
|
33
|
-
@pool[
|
32
|
+
raise UnknownModel.new("The '#{model}' model does not exists in the adapter '#{selected_repo}'") unless @pool.has_key?(selected_repo) && @pool[selected_repo].has_key?(model.to_sym)
|
33
|
+
@pool[selected_repo][model.to_sym]
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def models(repo_id=nil)
|
37
|
+
@pool[repo_id || @adapters.default].values
|
38
|
+
end
|
39
|
+
|
40
|
+
def module_const(repo_id=nil)
|
41
|
+
selected_repo = repo_id || @adapters.default
|
42
|
+
@pool[selected_repo][:'__repository_module'] ||= repository_module(selected_repo)
|
43
|
+
end
|
44
|
+
|
45
|
+
def load!(domain)
|
37
46
|
@config.each { |id, cfg|
|
38
47
|
Mutex.new.synchronize {
|
48
|
+
@pool[id] = Hash.new
|
39
49
|
Sequel::Model.db = @adapters[id]
|
40
50
|
if cfg.local
|
41
|
-
|
51
|
+
load_local_helpers id, cfg
|
52
|
+
load_local_models id, cfg
|
42
53
|
else
|
43
54
|
require cfg.gem
|
44
|
-
|
55
|
+
repo_module = "#{id.to_s.camelize}".constantize
|
56
|
+
self.class.include repo_module
|
45
57
|
self.class.send "load_#{id}", self, id, cfg
|
46
58
|
end
|
59
|
+
domain.include module_const(id)
|
47
60
|
}
|
48
61
|
}
|
49
62
|
self
|
@@ -54,26 +67,34 @@ module Tzispa
|
|
54
67
|
config.extensions.split(',').each { |ext|
|
55
68
|
model_class.db.extension ext.to_sym
|
56
69
|
} if config.respond_to? :extensions
|
57
|
-
@pool[
|
70
|
+
@pool[repo_id][model_id.to_sym] = model_class
|
58
71
|
end
|
59
72
|
|
60
73
|
private
|
61
74
|
|
62
|
-
def
|
63
|
-
|
75
|
+
def repository_module(repo_id)
|
76
|
+
rm = @pool[repo_id].first[1].name.split('::')
|
77
|
+
rm.pop
|
78
|
+
rm.join('::').constantize
|
79
|
+
end
|
80
|
+
|
81
|
+
def load_local_models(repo_id, config)
|
82
|
+
models_path = "./#{root}/#{repo_id}/model"
|
83
|
+
repo_module = "#{repo_id.to_s.camelize}::Model".constantize
|
84
|
+
Dir["#{models_path}/*.rb"].each { |file|
|
64
85
|
model_id = file.split('/').last.split('.').first
|
65
|
-
require
|
66
|
-
model_class = "
|
86
|
+
require "#{models_path}/#{model_id}"
|
87
|
+
model_class = "#{repo_module}::#{model_id.camelize}".constantize
|
67
88
|
register model_id, model_class, repo_id, config
|
68
89
|
}
|
69
90
|
end
|
70
91
|
|
71
|
-
def
|
72
|
-
"./#{root
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
92
|
+
def load_local_helpers(repo_id, config)
|
93
|
+
helpers_path = "./#{root}/#{repo_id}/helpers"
|
94
|
+
Dir["#{helpers_path}/*.rb"].each { |file|
|
95
|
+
helper_id = file.split('/').last.split('.').first
|
96
|
+
require "#{helpers_path}/#{helper_id}"
|
97
|
+
}
|
77
98
|
end
|
78
99
|
|
79
100
|
end
|
data/lib/tzispa/data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.3'
|
41
41
|
description: Data access layer for Tzispa
|
42
42
|
email:
|
43
43
|
- japinero@area-integral.com
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.6.10
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Data access for Tzispa framework
|