desmoservice 0.1.0 → 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/desmoservice.gemspec +2 -2
- data/lib/desmoservice.rb +1 -0
- data/lib/edition.rb +9 -0
- data/lib/error.rb +15 -0
- data/lib/get_params.rb +11 -3
- data/lib/sector.rb +14 -0
- data/lib/term.rb +13 -1
- data/lib/ventilation.rb +26 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1c3e6944ff6ae401ffcab53b2f0b2532e9d9b13
|
|
4
|
+
data.tar.gz: f86922c7995c9e9edbad514971b79f0882bb0e97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76da1504d2b654f262cc91d1ecb03e02dfd9558b554fe752629bea7d8b1748a2e6a786a0ba305f8d1efcdb40f21ad7bfc05597c74b0486ba54df93eb4694d6fd
|
|
7
|
+
data.tar.gz: 3131af34125ef66347323ed720ffbcc78774ad2d7d532565db4e52ad95a7ca1770564f1e5d595ac1c0a7e225082dd912acecfc3e3d42bdcb519e21111234a2fa
|
data/desmoservice.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'desmoservice'
|
|
3
|
-
s.version = '0.1.
|
|
4
|
-
s.date = '2015-09-
|
|
3
|
+
s.version = '0.1.1'
|
|
4
|
+
s.date = '2015-09-25'
|
|
5
5
|
s.license = 'Ruby'
|
|
6
6
|
s.summary = 'Read and write access to Desmoservice API'
|
|
7
7
|
s.description = 'Manage the connection to Desmoservice server, convert JSON to ruby objects and build XML for edition'
|
data/lib/desmoservice.rb
CHANGED
data/lib/edition.rb
CHANGED
|
@@ -21,6 +21,15 @@ class Edition
|
|
|
21
21
|
@xml << '</lienhierarchique-creation>'
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
#arg peut être un entier (id) ou une chaine (localkey)
|
|
25
|
+
def remove_ligature(inferior_arg=nil)
|
|
26
|
+
@xml << '<lienhierarchique-remove'
|
|
27
|
+
Edition.to_attribute(@xml, inferior_arg, 'fils')
|
|
28
|
+
@xml << '>'
|
|
29
|
+
yield(LigatureEdit.new(@xml))
|
|
30
|
+
@xml << '</lienhierarchique-remove>'
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
def change_term(term_arg)
|
|
25
34
|
@xml << '<terme-change'
|
|
26
35
|
Edition.to_attribute(@xml, term_arg)
|
data/lib/error.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Desmoservice
|
|
2
|
+
class Error
|
|
3
|
+
attr_reader :key, :parameter, :value
|
|
4
|
+
|
|
5
|
+
def initialize(key, parameter = nil, value = nil)
|
|
6
|
+
@key = key
|
|
7
|
+
@parameter = parameter
|
|
8
|
+
@value = value
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.from_json_hash(json_hash)
|
|
12
|
+
Error.new(json_hash['key'], json_hash['parameter'], json_hash['value'])
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/get_params.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module Desmoservice
|
|
2
2
|
class GetParams
|
|
3
3
|
|
|
4
|
-
attr_accessor :with_keys, :with_attrs,
|
|
5
|
-
:family_filter,
|
|
4
|
+
attr_accessor :with_keys, :with_attrs, :with_parent,
|
|
5
|
+
:family_filter, :inferiors_only,
|
|
6
6
|
:ventilation_root_id, :ventilation_root_uri, :ventilation_name,
|
|
7
7
|
:ignore_empty_sectors
|
|
8
8
|
|
|
@@ -14,6 +14,7 @@ class GetParams
|
|
|
14
14
|
@ventilation_root_uri = nil
|
|
15
15
|
@ignore_empty_sectors = nil
|
|
16
16
|
@ventilation_name = 'ventilation:naturelle'
|
|
17
|
+
@inferiors_only = false
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def to_h(type)
|
|
@@ -22,14 +23,21 @@ class GetParams
|
|
|
22
23
|
fields = 'libelles,famille-color'
|
|
23
24
|
fields += ',idctxt,iddesc,grille-name' if @with_keys
|
|
24
25
|
fields += ',attrs' if @with_attrs
|
|
26
|
+
fields += ',famille-code,parent-code' if @with_parent
|
|
27
|
+
fields += ',famille-idctxt,parent-idctxt' if (@with_parent and @with_keys)
|
|
25
28
|
result['fields'] = fields
|
|
26
29
|
if not @family_filter.nil?
|
|
27
30
|
if type == 'ventilation'
|
|
28
|
-
|
|
31
|
+
result['conf:limitation.familles'] = 'true'
|
|
32
|
+
result['conf:limitation.familles.idctxtarray'] = @family_filter
|
|
29
33
|
else
|
|
30
34
|
result['selection_idctxt'] = @family_filter
|
|
31
35
|
end
|
|
32
36
|
end
|
|
37
|
+
if @inferiors_only
|
|
38
|
+
result['conf:limitation.liens'] = 'true'
|
|
39
|
+
result['conf:limitation.liens.typearray'] = 'lh_av'
|
|
40
|
+
end
|
|
33
41
|
if not @ignore_empty_sectors.nil?
|
|
34
42
|
if @ignore_empty_sectors
|
|
35
43
|
result['conf:ignore.empty.secteur'] = 'true'
|
data/lib/sector.rb
CHANGED
|
@@ -6,12 +6,26 @@ class Sector < Term
|
|
|
6
6
|
|
|
7
7
|
def initialize(data)
|
|
8
8
|
super(data['terme'])
|
|
9
|
+
@subsectors = Array.new
|
|
9
10
|
@members = Array.new
|
|
10
11
|
if data.has_key?('liaisonArray')
|
|
11
12
|
data['liaisonArray'].each {|v| @members << SectorTerm.new(v)}
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def get_subsector_by_id(id)
|
|
17
|
+
subsectors.each do |subsector|
|
|
18
|
+
if subsector.id == id
|
|
19
|
+
return subsector
|
|
20
|
+
end
|
|
21
|
+
subsubsector = subsector.get_subsector_by_id(id)
|
|
22
|
+
if not subsubsector.nil?
|
|
23
|
+
return subsubsector
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
return nil
|
|
27
|
+
end
|
|
28
|
+
|
|
15
29
|
end
|
|
16
30
|
|
|
17
31
|
class SectorTerm < Term
|
data/lib/term.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Desmoservice
|
|
2
2
|
|
|
3
3
|
class Term
|
|
4
|
-
attr_reader :id, :localkey, :text, :color, :attrs
|
|
4
|
+
attr_reader :id, :localkey, :text, :color, :attrs, :parent_id, :parent_localkey
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@id = data['code']
|
|
@@ -26,6 +26,18 @@ class Term
|
|
|
26
26
|
if data.has_key?('attrs')
|
|
27
27
|
@attrs = data['attrs']
|
|
28
28
|
end
|
|
29
|
+
@parent_id = nil
|
|
30
|
+
if data.has_key?('parentCode')
|
|
31
|
+
@parent_id = data['parentCode'].to_i
|
|
32
|
+
elsif data.has_key?('familleCode')
|
|
33
|
+
@parent_id = data['familleCode'].to_i
|
|
34
|
+
end
|
|
35
|
+
@parent_localkey = nil
|
|
36
|
+
if data.has_key?('parentCode')
|
|
37
|
+
@parent_localkey = data['parentIdctxt']
|
|
38
|
+
elsif data.has_key?('familleCode')
|
|
39
|
+
@parent_localkey = data['familleIdctxt']
|
|
40
|
+
end
|
|
29
41
|
end
|
|
30
42
|
|
|
31
43
|
def localkey?
|
data/lib/ventilation.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Desmoservice
|
|
2
2
|
class Ventilation
|
|
3
3
|
|
|
4
|
-
attr_reader :root, :sectors
|
|
4
|
+
attr_reader :root, :sectors, :error
|
|
5
5
|
|
|
6
6
|
def initialize
|
|
7
7
|
@sectors = Array.new
|
|
@@ -10,6 +10,7 @@ class Ventilation
|
|
|
10
10
|
def parse_json(json_string)
|
|
11
11
|
data = JSON.parse(json_string)
|
|
12
12
|
if data.has_key?('ventilation')
|
|
13
|
+
@error = nil
|
|
13
14
|
ventilation = data['ventilation']
|
|
14
15
|
if ventilation.has_key?('secteurArray')
|
|
15
16
|
ventilation['secteurArray'].each {|v| @sectors << Sector.new(v)}
|
|
@@ -17,8 +18,32 @@ class Ventilation
|
|
|
17
18
|
if ventilation.has_key?('root')
|
|
18
19
|
@root = Term.new(ventilation['root'])
|
|
19
20
|
end
|
|
21
|
+
else
|
|
22
|
+
if data.has_key?('error')
|
|
23
|
+
@error = Error.from_json_hash(data['error'])
|
|
24
|
+
else
|
|
25
|
+
@error = Error.new("responseError", "response", json_string)
|
|
26
|
+
end
|
|
20
27
|
end
|
|
21
28
|
end
|
|
29
|
+
|
|
30
|
+
def has_error?
|
|
31
|
+
return (not error.nil?)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_sector_by_id(id)
|
|
35
|
+
@sectors.each do |sector|
|
|
36
|
+
if sector.id == id
|
|
37
|
+
return sector
|
|
38
|
+
end
|
|
39
|
+
subsector = sector.get_subsector_by_id(id)
|
|
40
|
+
if not subsector.nil?
|
|
41
|
+
return subsector
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
|
|
22
47
|
end
|
|
23
48
|
|
|
24
49
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: desmoservice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vincent Calame
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-09-
|
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Manage the connection to Desmoservice server, convert JSON to ruby objects
|
|
14
14
|
and build XML for edition
|
|
@@ -29,6 +29,7 @@ files:
|
|
|
29
29
|
- lib/log_handler.rb
|
|
30
30
|
- lib/desmoservice.rb
|
|
31
31
|
- lib/sector.rb
|
|
32
|
+
- lib/error.rb
|
|
32
33
|
- lib/post.rb
|
|
33
34
|
- lib/word_distribution.rb
|
|
34
35
|
- LICENSE
|