labimotion 2.3.0.rc1 → 2.3.0.rc3
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/lib/labimotion/apis/converter_api.rb +98 -23
- data/lib/labimotion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0961f712ff20e446cf716475b209f77990f76aceb5c96865fe0c499346e8e9c
|
|
4
|
+
data.tar.gz: f2e699a236095280fed0a264da3ec973e189a1e97721a641132e107bab030b3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65b886fcb89fc1eec184337c0ab4779b40a3cac97f2f3c801ff6d8479d1dd80195c738fe0a07241edb1cc3cae50061920c52c7e43f8f07036887f69bf117e58a
|
|
7
|
+
data.tar.gz: aa4a29222063fa59aeb2e2f9c06e1d64c481c58b9e4c9ff33d334718531225ca091986d573e3caec03ac42022240a170224d1af4f7619475edbc0b6ad65246bb
|
|
@@ -2,39 +2,103 @@
|
|
|
2
2
|
|
|
3
3
|
module Labimotion
|
|
4
4
|
class ConverterAPI < Grape::API
|
|
5
|
+
helpers Labimotion::DatasetHelpers
|
|
5
6
|
helpers do
|
|
7
|
+
def load_converter_config!
|
|
8
|
+
@conf = Rails.configuration.converter&.url
|
|
9
|
+
@profile = Rails.configuration.converter&.profile
|
|
10
|
+
error!(406) unless @conf && @profile
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def require_converter_admin!
|
|
14
|
+
error!(401) unless current_user.profile&.data&.fetch('converter_admin', false)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def uploaded_file
|
|
18
|
+
params[:file].is_a?(Array) ? params[:file][0] : params[:file]
|
|
19
|
+
end
|
|
6
20
|
end
|
|
21
|
+
|
|
7
22
|
resource :converter do
|
|
23
|
+
resource :datasets do
|
|
24
|
+
desc 'list Generic Dataset Klass'
|
|
25
|
+
get do
|
|
26
|
+
list = klass_list(true, false)
|
|
27
|
+
list.map do |kl|
|
|
28
|
+
pr = kl.properties_release
|
|
29
|
+
pr['name'] = kl.label
|
|
30
|
+
pr['ols'] = kl.ols_term_id
|
|
31
|
+
pr
|
|
32
|
+
end || []
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
resource :datasets_units do
|
|
37
|
+
desc 'list Generic Dataset Klass'
|
|
38
|
+
get do
|
|
39
|
+
Labimotion::Units::FIELDS
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
8
43
|
resource :profiles do
|
|
44
|
+
|
|
9
45
|
before do
|
|
10
|
-
|
|
11
|
-
@profile = Rails.configuration.try(:converter).try(:profile)
|
|
12
|
-
error!(406) unless @conf && @profile
|
|
46
|
+
load_converter_config!
|
|
13
47
|
end
|
|
14
|
-
|
|
48
|
+
|
|
49
|
+
desc 'Fetch profiles (no admin required)'
|
|
15
50
|
get do
|
|
16
51
|
profiles = Labimotion::Converter.fetch_profiles
|
|
17
52
|
{ profiles: profiles, client: @profile }
|
|
18
53
|
end
|
|
19
|
-
|
|
54
|
+
|
|
55
|
+
desc 'Create profile'
|
|
20
56
|
post do
|
|
57
|
+
require_converter_admin!
|
|
21
58
|
Labimotion::Converter.create_profile(params)
|
|
22
59
|
end
|
|
23
|
-
|
|
60
|
+
|
|
24
61
|
route_param :id do
|
|
62
|
+
desc 'Update profile'
|
|
25
63
|
put do
|
|
64
|
+
require_converter_admin!
|
|
26
65
|
Labimotion::Converter.update_profile(params)
|
|
27
66
|
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
route_param :id do
|
|
67
|
+
|
|
68
|
+
desc 'Delete profile'
|
|
31
69
|
delete do
|
|
32
|
-
|
|
33
|
-
Labimotion::Converter.delete_profile(id)
|
|
70
|
+
require_converter_admin!
|
|
71
|
+
Labimotion::Converter.delete_profile(params[:id])
|
|
34
72
|
end
|
|
35
73
|
end
|
|
36
|
-
end
|
|
37
74
|
|
|
75
|
+
resource :restore do
|
|
76
|
+
route_param :profile_id,
|
|
77
|
+
requirements: {
|
|
78
|
+
profile_id: /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
|
|
79
|
+
} do
|
|
80
|
+
|
|
81
|
+
route_param :profile_version,
|
|
82
|
+
requirements: {
|
|
83
|
+
profile_version: /\d+\.\d+/
|
|
84
|
+
} do
|
|
85
|
+
get do
|
|
86
|
+
{test_version: params[:profile_id], version: params[:profile_version]}
|
|
87
|
+
end
|
|
88
|
+
desc 'Restore profile'
|
|
89
|
+
post do
|
|
90
|
+
require_converter_admin!
|
|
91
|
+
|
|
92
|
+
Labimotion::Converter.restore(
|
|
93
|
+
params[:profile_id],
|
|
94
|
+
params[:profile_version],
|
|
95
|
+
params[:hard]
|
|
96
|
+
)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
38
102
|
resource :structure do
|
|
39
103
|
helpers do
|
|
40
104
|
def convert_structure(molfile)
|
|
@@ -66,10 +130,8 @@ module Labimotion
|
|
|
66
130
|
|
|
67
131
|
resource :options do
|
|
68
132
|
before do
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@profile = Rails.configuration.try(:converter).try(:profile)
|
|
72
|
-
error!(406) unless @conf && @profile
|
|
133
|
+
load_converter_config!
|
|
134
|
+
require_converter_admin!
|
|
73
135
|
end
|
|
74
136
|
desc 'fetch options'
|
|
75
137
|
get do
|
|
@@ -80,18 +142,31 @@ module Labimotion
|
|
|
80
142
|
|
|
81
143
|
resource :tables do
|
|
82
144
|
before do
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@profile = Rails.configuration.try(:converter).try(:profile)
|
|
86
|
-
error!(406) unless @conf && @profile
|
|
145
|
+
load_converter_config!
|
|
146
|
+
require_converter_admin!
|
|
87
147
|
end
|
|
88
148
|
desc 'create tables'
|
|
89
149
|
post do
|
|
90
|
-
|
|
91
|
-
res
|
|
150
|
+
file = uploaded_file
|
|
151
|
+
res = Labimotion::Converter.create_tables(file['tempfile']) unless file.nil?
|
|
152
|
+
res['metadata']['file_name'] = file['filename']
|
|
92
153
|
res
|
|
93
154
|
end
|
|
94
155
|
end
|
|
156
|
+
|
|
157
|
+
resource :conversions do
|
|
158
|
+
before do
|
|
159
|
+
load_converter_config!
|
|
160
|
+
require_converter_admin!
|
|
161
|
+
end
|
|
162
|
+
desc 'convert file'
|
|
163
|
+
post do
|
|
164
|
+
file = uploaded_file
|
|
165
|
+
res = Labimotion::Converter.test_conversions(file['tempfile'], params[:format]) unless file.nil?
|
|
166
|
+
res
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
95
170
|
end
|
|
96
171
|
end
|
|
97
|
-
end
|
|
172
|
+
end
|
data/lib/labimotion/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: labimotion
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.0.
|
|
4
|
+
version: 2.3.0.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chia-Lin Lin
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-07-
|
|
12
|
+
date: 2026-07-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: caxlsx
|