sibu_apidae 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 118110c471c72dffa4fd984bc201c53679ab5a06
4
- data.tar.gz: caecc0b682c36a2f615e3fd19fd136a8a9b78cc7
3
+ metadata.gz: 6636c3fe57cff4cb5f72c57bb5e19cbb75fc96fd
4
+ data.tar.gz: 66acecfc2f187acfd41963043d0ddff9665431fe
5
5
  SHA512:
6
- metadata.gz: 0d9d546f3506e102b9e5932b5dfc206c740897fc1c68c30caed84bcda6a9db25457625779a67f41551954d52c3afa067af54120a313b44de06a310f7474b14d7
7
- data.tar.gz: 90d5b52c05ba09d60a0713a152499e37b886a897150fbc411aa7082be26d3ea55eacb2ef4466530756ab527e2d0af2cbd75cdfeab0d365357dc9185ee4fe0c97
6
+ metadata.gz: a48d49ccaee693b05a3bc11d6f4010564e1276d6026aa7f3df261df5b9e4b0fd6c1ce582da921819fd0808d6504fef75f19920ba814d77f2ede7af0692b984b4
7
+ data.tar.gz: 69bb86d22b1e1141f3c4841e191323b8190705ede3ab37d0905f371ba088105b311c22ee4fb6f2d5f63c96663a7e268574949b3d9915eccadd1e3ff42902f49b
@@ -1,55 +1,60 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sibu_apidae (0.1.0)
4
+ sibu_apidae (0.2.0)
5
5
  apidae
6
6
  sibu
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.1.6)
12
- actionpack (= 5.1.6)
11
+ actioncable (5.2.0)
12
+ actionpack (= 5.2.0)
13
13
  nio4r (~> 2.0)
14
- websocket-driver (~> 0.6.1)
15
- actionmailer (5.1.6)
16
- actionpack (= 5.1.6)
17
- actionview (= 5.1.6)
18
- activejob (= 5.1.6)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.0)
16
+ actionpack (= 5.2.0)
17
+ actionview (= 5.2.0)
18
+ activejob (= 5.2.0)
19
19
  mail (~> 2.5, >= 2.5.4)
20
20
  rails-dom-testing (~> 2.0)
21
- actionpack (5.1.6)
22
- actionview (= 5.1.6)
23
- activesupport (= 5.1.6)
21
+ actionpack (5.2.0)
22
+ actionview (= 5.2.0)
23
+ activesupport (= 5.2.0)
24
24
  rack (~> 2.0)
25
25
  rack-test (>= 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.1.6)
29
- activesupport (= 5.1.6)
28
+ actionview (5.2.0)
29
+ activesupport (= 5.2.0)
30
30
  builder (~> 3.1)
31
31
  erubi (~> 1.4)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.1.6)
35
- activesupport (= 5.1.6)
34
+ activejob (5.2.0)
35
+ activesupport (= 5.2.0)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.1.6)
38
- activesupport (= 5.1.6)
39
- activerecord (5.1.6)
40
- activemodel (= 5.1.6)
41
- activesupport (= 5.1.6)
42
- arel (~> 8.0)
43
- activesupport (5.1.6)
37
+ activemodel (5.2.0)
38
+ activesupport (= 5.2.0)
39
+ activerecord (5.2.0)
40
+ activemodel (= 5.2.0)
41
+ activesupport (= 5.2.0)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.0)
44
+ actionpack (= 5.2.0)
45
+ activerecord (= 5.2.0)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.0)
44
48
  concurrent-ruby (~> 1.0, >= 1.0.2)
45
49
  i18n (>= 0.7, < 2)
46
50
  minitest (~> 5.1)
47
51
  tzinfo (~> 1.1)
48
- apidae (0.4.5)
49
- pg (~> 0.20)
50
- rails (~> 5.1.4)
51
- rubyzip (~> 1.0.0)
52
- arel (8.0.0)
52
+ apidae (0.6.0)
53
+ jbuilder
54
+ pg (~> 0.2)
55
+ rails (~> 5.1)
56
+ rubyzip (~> 1.0)
57
+ arel (9.0.0)
53
58
  builder (3.2.3)
54
59
  concurrent-ruby (1.0.5)
55
60
  crass (1.0.4)
@@ -61,6 +66,9 @@ GEM
61
66
  i18n (1.1.0)
62
67
  concurrent-ruby (~> 1.0)
63
68
  image_processing (0.11.2)
69
+ jbuilder (2.7.0)
70
+ activesupport (>= 4.2.0)
71
+ multi_json (>= 1.2)
64
72
  jquery-rails (4.3.3)
65
73
  rails-dom-testing (>= 1, < 3)
66
74
  railties (>= 4.2.0)
@@ -70,11 +78,15 @@ GEM
70
78
  nokogiri (>= 1.5.9)
71
79
  mail (2.7.0)
72
80
  mini_mime (>= 0.1.1)
81
+ marcel (0.3.2)
82
+ mimemagic (~> 0.3.2)
73
83
  method_source (0.9.0)
84
+ mimemagic (0.3.2)
74
85
  mini_magick (4.8.0)
75
86
  mini_mime (1.0.1)
76
87
  mini_portile2 (2.3.0)
77
88
  minitest (5.8.5)
89
+ multi_json (1.13.1)
78
90
  nio4r (2.3.1)
79
91
  nokogiri (1.8.4)
80
92
  mini_portile2 (~> 2.3.0)
@@ -82,26 +94,27 @@ GEM
82
94
  rack (2.0.5)
83
95
  rack-test (1.1.0)
84
96
  rack (>= 1.0, < 3)
85
- rails (5.1.6)
86
- actioncable (= 5.1.6)
87
- actionmailer (= 5.1.6)
88
- actionpack (= 5.1.6)
89
- actionview (= 5.1.6)
90
- activejob (= 5.1.6)
91
- activemodel (= 5.1.6)
92
- activerecord (= 5.1.6)
93
- activesupport (= 5.1.6)
97
+ rails (5.2.0)
98
+ actioncable (= 5.2.0)
99
+ actionmailer (= 5.2.0)
100
+ actionpack (= 5.2.0)
101
+ actionview (= 5.2.0)
102
+ activejob (= 5.2.0)
103
+ activemodel (= 5.2.0)
104
+ activerecord (= 5.2.0)
105
+ activestorage (= 5.2.0)
106
+ activesupport (= 5.2.0)
94
107
  bundler (>= 1.3.0)
95
- railties (= 5.1.6)
108
+ railties (= 5.2.0)
96
109
  sprockets-rails (>= 2.0.0)
97
110
  rails-dom-testing (2.0.3)
98
111
  activesupport (>= 4.2.0)
99
112
  nokogiri (>= 1.6)
100
113
  rails-html-sanitizer (1.0.4)
101
114
  loofah (~> 2.2, >= 2.2.2)
102
- railties (5.1.6)
103
- actionpack (= 5.1.6)
104
- activesupport (= 5.1.6)
115
+ railties (5.2.0)
116
+ actionpack (= 5.2.0)
117
+ activesupport (= 5.2.0)
105
118
  method_source
106
119
  rake (>= 0.8.7)
107
120
  thor (>= 0.18.1, < 2.0)
@@ -109,7 +122,7 @@ GEM
109
122
  rb-fsevent (0.10.3)
110
123
  rb-inotify (0.9.10)
111
124
  ffi (>= 0.5.0, < 2)
112
- rubyzip (1.0.0)
125
+ rubyzip (1.2.2)
113
126
  sass (3.5.7)
114
127
  sass-listen (~> 4.0.0)
115
128
  sass-listen (4.0.0)
@@ -143,7 +156,7 @@ GEM
143
156
  tilt (2.0.8)
144
157
  tzinfo (1.2.5)
145
158
  thread_safe (~> 0.1)
146
- websocket-driver (0.6.5)
159
+ websocket-driver (0.7.0)
147
160
  websocket-extensions (>= 0.1.0)
148
161
  websocket-extensions (0.1.3)
149
162
 
@@ -30,24 +30,46 @@ module SibuApidae
30
30
  end
31
31
 
32
32
  class Helper
33
- def self.import_pages(site_id)
33
+
34
+ APIDAE_OBJ_SOURCE = 'Fiche Apidae'
35
+
36
+ def self.update_pages(site_id)
34
37
  conf = Rails.application.config.sibu_apidae
35
- if conf && conf.key?(:obj_path) && conf.key?(:obj_sections) && conf.key?(:supported_types)
38
+ if is_valid?(conf)
39
+ Sibu::Page.where(site_id: site_id).select(:id, :site_id, :name, :path, :metadata).to_a
40
+ .select {|p| p.source == APIDAE_OBJ_SOURCE}.each do |p|
41
+ obj = Apidae::Obj.find_by_apidae_id(p.external_id)
42
+ if obj
43
+ p.update(name: obj.title, title: obj.title, description: obj.short_desc,
44
+ path: conf[:obj_path].call(obj))
45
+ else
46
+ Rails.logger.info("Deleting page #{p.id} after object deletion (#{p.external_id})")
47
+ p.destroy
48
+ end
49
+ end
50
+
36
51
  Apidae::Obj.all.each do |obj|
37
52
  if conf[:supported_types].include?(obj.apidae_type)
38
- obj_path = Rails.application.config.sibu_apidae[:obj_path].call(obj)
39
- obj_page = Sibu::Page.where(site_id: site_id, path: obj_path).first
53
+ obj_page = Sibu::Page.where(site_id: site_id).select(:id, :metadata).to_a
54
+ .find {|p| p.source == APIDAE_OBJ_SOURCE && p.external_id == obj.apidae_id}
40
55
  unless obj_page
41
- p = Sibu::Page.new(name: obj.title, site_id: site_id, path: obj_path, title: obj.title,
42
- description: obj.short_desc)
43
- p.sections = Rails.application.config.sibu_apidae[:obj_sections].call(obj)
56
+ p = Sibu::Page.new(name: obj.title, site_id: site_id, path: conf[:obj_path].call(obj), title: obj.title,
57
+ description: obj.short_desc, source: APIDAE_OBJ_SOURCE,
58
+ external_id: conf[:page_external_id].call(obj))
59
+ p.sections = conf[:obj_sections].call(obj)
44
60
  p.save!
45
61
  end
46
62
  end
47
63
  end
48
64
  else
49
- puts "Please provide a valid configuration for the sibu_apidae gem (obj_path and obj_sections procs are required)"
65
+ Rails.logger.error "Please provide a valid configuration for the sibu_apidae gem " +
66
+ "(:page_external_id, :obj_path, :obj_sections and :supported_types are required)"
50
67
  end
68
+ 'SibuApidae pages update complete'
69
+ end
70
+
71
+ def self.is_valid?(conf)
72
+ conf && conf.key?(:obj_path) && conf.key?(:obj_sections) && conf.key?(:supported_types) && conf.key?(:page_external_id)
51
73
  end
52
74
  end
53
75
  end
@@ -1,3 +1,3 @@
1
1
  module SibuApidae
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
29
  spec.add_dependency "apidae"
30
- spec.add_dependency "sibu"
30
+ spec.add_dependency "sibu", "~> 0.7.2"
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu_apidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-09-04 00:00:00.000000000 Z
12
+ date: 2019-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -71,16 +71,16 @@ dependencies:
71
71
  name: sibu
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 0.7.2
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 0.7.2
84
84
  description: A set of utility classes for use with the Sibu and Apidae engines
85
85
  email:
86
86
  - jbvilain@gmail.com