phrase_assembler 1.0.5 → 1.0.6
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/lib/PAProxies/PAAutomateProxy.rb +26 -0
- data/lib/PAProxies/PACompositeProxy.rb +5 -5
- data/lib/phrase_assembler.rb +10 -0
- metadata +4 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'PAProxies/PAAssembleProxy'
|
2
|
+
class PAAutomateProxy < PAAssembleProxy
|
3
|
+
attr_accessor :automate_data
|
4
|
+
|
5
|
+
def new_instance(p_data)
|
6
|
+
return self.class.new(p_data, self.logger, self.grammar, false, false, self.max_tokens_level, self.automate_data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(p_data = {}, logger = nil, grammar = {}, init_grammar = true, init_data = true, p_max_tokens_level = 5, p_automate_data = [])
|
10
|
+
self.automate_data = p_automate_data
|
11
|
+
|
12
|
+
super(p_data, logger, grammar, init_grammar, init_data, p_max_tokens_level)
|
13
|
+
end
|
14
|
+
|
15
|
+
def automate(p_params = {})
|
16
|
+
if automate_data.length < 1
|
17
|
+
raise 'No automate data root'
|
18
|
+
else
|
19
|
+
proxy = self.send(automate_data[0])
|
20
|
+
for i in 1...automate_data.length
|
21
|
+
proxy = proxy.send(p_params[automate_data[i]].to_sym)
|
22
|
+
end
|
23
|
+
return proxy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'PAProxies/
|
1
|
+
require 'PAProxies/PAAutomateProxy'
|
2
2
|
require 'PAProxies/PAStringProxy'
|
3
3
|
require 'PAProxies/PACacheProxy'
|
4
|
-
class PACompositeProxy <
|
4
|
+
class PACompositeProxy < PAAutomateProxy
|
5
5
|
include PAStringProxy
|
6
6
|
include PACacheProxy
|
7
7
|
|
8
8
|
def new_instance(p_data)
|
9
|
-
return self.class.new(p_data, self.logger, self.grammar, false, false, self.max_tokens_level)
|
9
|
+
return self.class.new(p_data, self.logger, self.grammar, false, false, self.max_tokens_level, self.automate_data)
|
10
10
|
end
|
11
11
|
|
12
12
|
@@proxy_cache = {}
|
@@ -14,14 +14,14 @@ class PACompositeProxy < PAAssembleProxy
|
|
14
14
|
@@proxy_cache
|
15
15
|
end
|
16
16
|
|
17
|
-
def set_uncacheable_args(p_data = {}, p_logger = nil, p_grammar = {}, init_grammar = true, init_data = true, max_tokens_level = 5)
|
17
|
+
def set_uncacheable_args(p_data = {}, p_logger = nil, p_grammar = {}, init_grammar = true, init_data = true, max_tokens_level = 5, p_automate_data = [])
|
18
18
|
end
|
19
19
|
|
20
20
|
def get_default_options
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.cache_id(p_data = {}, logger = nil, options = {}, grammar = {}, init_grammar = true, init_data = true, max_tokens_level = 5)
|
24
|
+
def self.cache_id(p_data = {}, logger = nil, options = {}, grammar = {}, init_grammar = true, init_data = true, max_tokens_level = 5, p_automate_data = [])
|
25
25
|
if p_data.nil?
|
26
26
|
return nil
|
27
27
|
else
|
data/lib/phrase_assembler.rb
CHANGED
@@ -67,6 +67,14 @@ module PhraseAssembler
|
|
67
67
|
def self._proxies=(value)
|
68
68
|
self.send(:class_variable_set, :@@_proxies, value)
|
69
69
|
end
|
70
|
+
|
71
|
+
def self._automate_data
|
72
|
+
self.send(:class_variable_get, :@@_automate_data)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self._automate_data=(value)
|
76
|
+
self.send(:class_variable_set, :@@_automate_data, value)
|
77
|
+
end
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
@@ -79,6 +87,7 @@ module PhraseAssembler
|
|
79
87
|
self._grammars = (options[:grammars] || {'hr' => 'croatian_grammar.yml', 'rs' => 'serbian_grammar.yml', 'si' => 'slovenian_grammar.yml'})
|
80
88
|
self._languages_files_path = (options[:languages_files_path] || File.join(::Rails.root.to_s, 'app', 'yaml', 'languages'))
|
81
89
|
self._logger = (options[:logger] || RAILS_DEFAULT_LOGGER)
|
90
|
+
self._automate_data = (options[:automate_data] || [:pages, "controller", "action"])
|
82
91
|
|
83
92
|
self._proxies = {}
|
84
93
|
|
@@ -96,6 +105,7 @@ module PhraseAssembler
|
|
96
105
|
self.class._proxies[t_pref_language] = PACompositeProxy.new(nil, self.class._logger)
|
97
106
|
self.class._proxies[t_pref_language].load(File.join(self.class._languages_files_path, self.class._languages[t_pref_language]) )
|
98
107
|
self.class._proxies[t_pref_language].load_grammar(File.join(self.class._languages_files_path, self.class._grammars[t_pref_language]))
|
108
|
+
self.class._proxies[t_pref_language].automate_data = self.class._automate_data
|
99
109
|
end
|
100
110
|
self.class._proxies[t_pref_language]
|
101
111
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phrase_assembler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Lovro \xC5\xBDmak, Radan Skori\xC4\x87, Drap"
|
@@ -43,6 +43,7 @@ extra_rdoc_files: []
|
|
43
43
|
files:
|
44
44
|
- lib/hash_add_on.rb
|
45
45
|
- lib/PAProxies/PAAssembleProxy.rb
|
46
|
+
- lib/PAProxies/PAAutomateProxy.rb
|
46
47
|
- lib/PAProxies/PACacheProxy.rb
|
47
48
|
- lib/PAProxies/PACompositeProxy.rb
|
48
49
|
- lib/PAProxies/PALangProxy.rb
|