llt-db_handler 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/llt/db_handler/prometheus/db/prometheus_stems.dump +0 -0
- data/lib/llt/db_handler/tasks.rb +1 -1
- data/lib/llt/db_handler/version.rb +1 -1
- data/llt-db_handler.gemspec +3 -0
- metadata +16 -6
- data/lib/llt/db_handler/stub.rb +0 -61
- data/lib/llt/db_handler/stub/stub_entries.rb +0 -90
- data/spec/lib/llt/db_handler/stub_spec.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cc718fecd6ac4a57695656193d0cdd1e96110ae
|
4
|
+
data.tar.gz: 859d0dc77ca0e4f648773caf9a98bac4d58a060a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79bf40c2ae4eb534f446bdaf4b29387a5cc9a181b4194dc2df6353ea1b40455665becf6882f233b825d3060c46cde4316ec4960867fb0d7cb1e2b48eefb958b
|
7
|
+
data.tar.gz: b14306513551b5436bd6bc3f9d6b077604b4f26bb5c34c2393867535c2698af170af39232adf530078419062891050052e2d177bcdd4e85deca66dacd962811b
|
data/Gemfile
CHANGED
@@ -5,6 +5,7 @@ gemspec
|
|
5
5
|
gem 'coveralls', require: false
|
6
6
|
gem 'llt-core_extensions', git: 'git@github.com:latin-language-toolkit/llt-core_extensions.git'
|
7
7
|
gem 'llt-constants', git: 'git@github.com:latin-language-toolkit/llt-constants.git'
|
8
|
+
gem 'llt-db_handler-stub', git: 'git@github.com:latin-language-toolkit/llt-db_handler-stub.git'
|
8
9
|
gem 'llt-form_builder', git: 'git@github.com:latin-language-toolkit/llt-form_builder.git'
|
9
10
|
gem 'llt-helpers', git: 'git@github.com:latin-language-toolkit/llt-helpers.git'
|
10
11
|
|
Binary file
|
data/lib/llt/db_handler/tasks.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :db do
|
2
2
|
namespace :prometheus do
|
3
|
-
DUMP_FILE = '
|
3
|
+
DUMP_FILE = File.expand_path('../prometheus/db/prometheus_stems.dump', __FILE__)
|
4
4
|
|
5
5
|
desc 'Opens a pry console with a prometheus instance preloaded as db'
|
6
6
|
task :console do
|
data/llt-db_handler.gemspec
CHANGED
@@ -24,6 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rspec"
|
25
25
|
spec.add_development_dependency "simplecov", "~> 0.7"
|
26
26
|
spec.add_development_dependency "yard"
|
27
|
+
|
28
|
+
spec.add_development_dependency "llt-db_handler-stub"
|
29
|
+
|
27
30
|
spec.add_dependency 'activerecord', "~> 3.2"
|
28
31
|
spec.add_dependency "llt-core_extensions"
|
29
32
|
spec.add_dependency "llt-constants"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llt-db_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LFDM
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: llt-db_handler-stub
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: activerecord
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,15 +199,12 @@ files:
|
|
185
199
|
- lib/llt/db_handler/prometheus/db/prometheus_stems.dump
|
186
200
|
- lib/llt/db_handler/prometheus/db_to_lemma.rb
|
187
201
|
- lib/llt/db_handler/prometheus/stats.rb
|
188
|
-
- lib/llt/db_handler/stub.rb
|
189
|
-
- lib/llt/db_handler/stub/stub_entries.rb
|
190
202
|
- lib/llt/db_handler/tasks.rb
|
191
203
|
- lib/llt/db_handler/version.rb
|
192
204
|
- llt-db_handler.gemspec
|
193
205
|
- spec/lib/llt/db_handler/prometheus/db_to_lemma_spec.rb
|
194
206
|
- spec/lib/llt/db_handler/prometheus/stats_spec.rb
|
195
207
|
- spec/lib/llt/db_handler/prometheus_spec.rb
|
196
|
-
- spec/lib/llt/db_handler/stub_spec.rb
|
197
208
|
- spec/lib/llt/db_handler_spec.rb
|
198
209
|
- spec/spec_helper.rb
|
199
210
|
homepage: ''
|
@@ -224,7 +235,6 @@ test_files:
|
|
224
235
|
- spec/lib/llt/db_handler/prometheus/db_to_lemma_spec.rb
|
225
236
|
- spec/lib/llt/db_handler/prometheus/stats_spec.rb
|
226
237
|
- spec/lib/llt/db_handler/prometheus_spec.rb
|
227
|
-
- spec/lib/llt/db_handler/stub_spec.rb
|
228
238
|
- spec/lib/llt/db_handler_spec.rb
|
229
239
|
- spec/spec_helper.rb
|
230
240
|
has_rdoc:
|
data/lib/llt/db_handler/stub.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'llt/db_handler/common_db'
|
2
|
-
|
3
|
-
module LLT
|
4
|
-
module DbHandler
|
5
|
-
class Stub < CommonDb
|
6
|
-
require 'llt/db_handler/stub/stub_entries'
|
7
|
-
|
8
|
-
@stems = {}
|
9
|
-
|
10
|
-
class << self
|
11
|
-
include Helpers::Normalizer
|
12
|
-
|
13
|
-
attr_reader :stems
|
14
|
-
|
15
|
-
def create_stem_stub(return_val, args)
|
16
|
-
args = normalize_args(args)
|
17
|
-
@stems[args] = return_val
|
18
|
-
end
|
19
|
-
alias :create :create_stem_stub
|
20
|
-
|
21
|
-
def setup
|
22
|
-
StubEntries.setup
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def type
|
27
|
-
:stub
|
28
|
-
end
|
29
|
-
|
30
|
-
def look_up_stem(args)
|
31
|
-
super
|
32
|
-
stems.select do |stored_args|
|
33
|
-
if stored_args.merge(args_to_query) == stored_args
|
34
|
-
if restr = @args[:restrictions]
|
35
|
-
restr[:values].include?(stored_args[restr[:type]])
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end.values
|
39
|
-
end
|
40
|
-
|
41
|
-
def direct_lookup(type, string)
|
42
|
-
args = dl_to_query(type, string)
|
43
|
-
stems.select do |stored|
|
44
|
-
stored.merge(args) == stored
|
45
|
-
end.values
|
46
|
-
end
|
47
|
-
|
48
|
-
def dl_to_query(type, string)
|
49
|
-
{ type: type, word: string}
|
50
|
-
end
|
51
|
-
|
52
|
-
def args_to_query
|
53
|
-
{type: @args[:type], @args[:stem_type] => @args[:stem] }
|
54
|
-
end
|
55
|
-
|
56
|
-
def stems
|
57
|
-
self.class.stems
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
class LLT::DbHandler::Stub::StubEntries
|
4
|
-
class << self
|
5
|
-
def setup(size = :medium)
|
6
|
-
db_stub.stems.clear
|
7
|
-
|
8
|
-
medium_setup
|
9
|
-
# not implemented yet
|
10
|
-
#case size
|
11
|
-
#when :big then big_setup
|
12
|
-
#when :small then small_setup
|
13
|
-
#else medium_setup
|
14
|
-
#end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def small_setup
|
20
|
-
end
|
21
|
-
|
22
|
-
def medium_setup
|
23
|
-
wsr(type: :noun, nom: "homo", stem: "homin", itype: 3, sexus: :m)
|
24
|
-
wsr(type: :noun, nom: "vir", stem: "vir", itype: 2, sexus: :m)
|
25
|
-
wsr(type: :noun, nom: "ratio", stem: "ration", itype: 3, sexus: :f)
|
26
|
-
wsr(type: :noun, nom: "magnitudo", stem: "magnitudin", itype: 3, sexus: :f)
|
27
|
-
wsr(type: :noun, nom: "libido", stem: "libidin", itype: 3, sexus: :f)
|
28
|
-
wsr(type: :noun, nom: "nox", stem: "noct", itype: 3, sexus: :f)
|
29
|
-
wsr(type: :noun, nom: "filius", stem: "fili", itype: 2, sexus: :m)
|
30
|
-
wsr(type: :noun, nom: "servus", stem: "serv", itype: 2, sexus: :m)
|
31
|
-
wsr(type: :noun, nom: "dominus", stem: "domin", itype: 2, sexus: :m)
|
32
|
-
|
33
|
-
wsr(type: :noun, nom: "flumen", stem: "flumin", itype: 3, sexus: :n)
|
34
|
-
wsr(type: :noun, nom: "arma", stem: "arm", itype: 2, sexus: :n) # this might actually be wrong?
|
35
|
-
|
36
|
-
wsr(type: :persona, nom: "Plato", stem: "Platon", itype: 3)
|
37
|
-
wsr(type: :persona, nom: "Solon", stem: "Solon", itype: 3)
|
38
|
-
wsr(type: :persona, nom: "Paulinus", stem: "Paulin", itype: 2)
|
39
|
-
|
40
|
-
wsr(type: :adjective, nom: "communis", stem: "commun", itype: 3, number_of_endings: 1)
|
41
|
-
wsr(type: :adjective, nom: "diligens", stem: "diligent", itype: 3, number_of_endings: 1)
|
42
|
-
wsr(type: :adjective, nom: "laetus", stem: "laet", itype: 1, number_of_endings: 3)
|
43
|
-
wsr(type: :adjective, nom: "ferus", stem: "fer", itype: 1, number_of_endings: 3)
|
44
|
-
wsr(type: :adjective, nom: "bonus", stem: "bon", itype: 1, number_of_endings: 3)
|
45
|
-
|
46
|
-
wsr(type: :adjective, nom: "aestivus", stem: "aestiv", itype: 1, number_of_endings: 3)
|
47
|
-
wsr(type: :adjective, nom: "suavis", stem: "suav", itype: 3, number_of_endings: 2)
|
48
|
-
|
49
|
-
|
50
|
-
wsr(type: :ethnic, stem: "Haedu", inflection_class: 1)
|
51
|
-
wsr(type: :ethnic, stem: "Redon", inflection_class: 3)
|
52
|
-
|
53
|
-
wsr(type: :verb, pr: "ita", pf: "itav", pf_composition: "v", itype: 1, dep: false, dir_objs: "", indir_objs: "")
|
54
|
-
wsr(type: :verb, pr: "cana", pf: "canav", ppp: "canat", pf_composition: "v", itype: 1, dep: false, dir_objs: "", indir_objs: "")
|
55
|
-
wsr(type: :verb, pr: "mone", pf: "monu", ppp: "monit", pf_composition: "u", itype: 2, dep: false, dir_objs: "", indir_objs: "")
|
56
|
-
wsr(type: :verb, pr: "move", pf: "movi", ppp: "mot", pf_composition: "ablaut", itype: 2, dep: false, dir_objs: "", indir_objs: "")
|
57
|
-
wsr(type: :verb, pr: "mitt", pf: "mis", ppp: "miss", pf_composition: "s", itype: 3, dep: false, dir_objs: "", indir_objs: "")
|
58
|
-
wsr(type: :verb, pr: "viv", pf: "vix", ppp: "-", pf_composition: "s", itype: 3, dep: false, dir_objs: "", indir_objs: "")
|
59
|
-
wsr(type: :verb, pr: "audi", pf: "audiv", ppp: "audit", pf_composition: "v", itype: 4, dep: false, dir_objs: "", indir_objs: "")
|
60
|
-
wsr(type: :verb, pr: "horta", ppp: "hortat", itype: 1, dep: true , dir_objs: "", indir_objs: "")
|
61
|
-
|
62
|
-
dl(type: :adverb, word: "ita")
|
63
|
-
dl(type: :adverb, word: "iam")
|
64
|
-
dl(type: :adverb, word: "subito")
|
65
|
-
end
|
66
|
-
|
67
|
-
def big_setup
|
68
|
-
end
|
69
|
-
|
70
|
-
def db_stub
|
71
|
-
LLT::DbHandler::Stub
|
72
|
-
end
|
73
|
-
|
74
|
-
def factory(type, args)
|
75
|
-
LLT::StemBuilder.build(type, args, "stub")
|
76
|
-
end
|
77
|
-
|
78
|
-
# with_single_return
|
79
|
-
def wsr(args)
|
80
|
-
ret_val = factory(args[:type], args.reject { |k, _| k == :type })
|
81
|
-
db_stub.create(ret_val, args)
|
82
|
-
end
|
83
|
-
|
84
|
-
# direct_lookup
|
85
|
-
def dl(args)
|
86
|
-
ret_val = OpenStruct.new(word: args[:word])
|
87
|
-
db_stub.create(ret_val, args)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'llt/db_handler/stub'
|
3
|
-
|
4
|
-
describe LLT::DbHandler::Stub do
|
5
|
-
let(:db_stub) { LLT::DbHandler::Stub }
|
6
|
-
|
7
|
-
describe "#type" do
|
8
|
-
it "identifies the db_stub as stub" do
|
9
|
-
db_stub.new.type.should == :stub
|
10
|
-
end
|
11
|
-
end
|
12
|
-
describe ".create_stem_stub" do
|
13
|
-
it "creates a new stem stub" do
|
14
|
-
db_stub.stems.clear
|
15
|
-
db_stub.create_stem_stub("test", test: "val")
|
16
|
-
db_stub.stems.should have(1).item
|
17
|
-
end
|
18
|
-
|
19
|
-
it "has alias create" do
|
20
|
-
db_stub.stems.clear
|
21
|
-
db_stub.create("test", test: "val")
|
22
|
-
db_stub.stems.should have(1).item
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#look_up_stem" do
|
27
|
-
it "returns an array of db entries" do
|
28
|
-
db_stub.create_stem_stub("test", type: :noun, nom: "rosa", stem: "ros", inflection_class: 1)
|
29
|
-
result = db_stub.new.look_up_stem(type: :noun, stem_type: :stem, stem: "ros", restrictions: { type: :inflection_class, values: [1] })
|
30
|
-
result2 = db_stub.new.look_up_stem(type: :noun, stem_type: :stem, stem: "ros", restrictions: { type: :inflection_class, values: [2] })
|
31
|
-
result.should have(1).item
|
32
|
-
result.first.should == "test"
|
33
|
-
|
34
|
-
result2.should be_empty
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#direct_lookup" do
|
39
|
-
it "returns an array of db entries" do
|
40
|
-
db_stub.create(:success, type: :adverb, word: "ita")
|
41
|
-
result = db_stub.new.direct_lookup(:adverb, "ita")
|
42
|
-
result.should have(1).item
|
43
|
-
result.first.should == :success
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe ".setup" do
|
48
|
-
it "creates stub entries as defined in stub_entries.rb" do
|
49
|
-
db_stub.stems.clear
|
50
|
-
db_stub.setup
|
51
|
-
db_stub.stems.should_not be_empty
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|