labimotion 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labimotion/helpers/element_helpers.rb +4 -6
- data/lib/labimotion/helpers/generic_helpers.rb +7 -7
- data/lib/labimotion/libs/converter.rb +8 -2
- data/lib/labimotion/libs/export_dataset.rb +13 -3
- data/lib/labimotion/libs/nmr_mapper.rb +14 -2
- data/lib/labimotion/libs/nmr_mapper_repo.rb +20 -5
- 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: 387a4b4a47a140008970b10f005472e8ba882c80ddaab99863ced5acdb0dfa29
|
4
|
+
data.tar.gz: 90f5839a92d045e45861a2354354bf5ef1542799a484cda94fa9c1263c206d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cca4c43074754aefbe3f2b3ca09b55af69d25ebf2a4b7f456990bc692ee7ab19905020aed4505d6360b720d94e497e91ab5910b8c50d4b5b914a01d23e840796
|
7
|
+
data.tar.gz: 5280180e034e2bd2a38000b62e8001ebee247cae2dd29e30f5b66eb3292d11e0e9f0566986c5eb918e6f6dcfc9d95024553204d834da44e7a1aee2b13500d454
|
@@ -20,12 +20,10 @@ module Labimotion
|
|
20
20
|
uuid = SecureRandom.uuid
|
21
21
|
template = { uuid: uuid, layers: {}, select_options: {} }
|
22
22
|
attributes = declared(params, include_missing: false)
|
23
|
-
if attributes[:properties_template].
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attributes[:properties_template]['klass'] = 'ElementKlass'
|
28
|
-
end
|
23
|
+
attributes[:properties_template] = template if attributes[:properties_template].nil?
|
24
|
+
attributes[:properties_template]['uuid'] = uuid
|
25
|
+
attributes[:properties_template]['pkg'] = Labimotion::Utils.pkg(attributes[:properties_template]['pkg'])
|
26
|
+
attributes[:properties_template]['klass'] = 'ElementKlass'
|
29
27
|
attributes[:is_active] = false
|
30
28
|
attributes[:uuid] = uuid
|
31
29
|
attributes[:released_at] = DateTime.now
|
@@ -46,10 +46,9 @@ module Labimotion
|
|
46
46
|
uuid = SecureRandom.uuid
|
47
47
|
properties = params[:properties_template]
|
48
48
|
properties['uuid'] = uuid
|
49
|
-
|
50
49
|
klz.version = Labimotion::Utils.next_version(params[:release], klz.version)
|
51
50
|
properties['version'] = klz.version
|
52
|
-
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || klz.properties_template['pkg'])
|
51
|
+
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || (klz.properties_template && klz.properties_template['pkg']))
|
53
52
|
properties['klass'] = klz.class.name.split('::').last
|
54
53
|
properties['identifier'] = klz.identifier
|
55
54
|
properties.delete('eln') if properties['eln'].present?
|
@@ -189,9 +188,9 @@ module Labimotion
|
|
189
188
|
raise e
|
190
189
|
end
|
191
190
|
|
192
|
-
def create_attachments(files, del_files, type, id, user_id)
|
191
|
+
def create_attachments(files, del_files, type, id, identifier, user_id)
|
193
192
|
attach_ary = []
|
194
|
-
(files || []).
|
193
|
+
(files || []).each_with_index do |file, index|
|
195
194
|
next unless (tempfile = file[:tempfile])
|
196
195
|
|
197
196
|
a = Attachment.new(
|
@@ -201,13 +200,14 @@ module Labimotion
|
|
201
200
|
file_path: file[:tempfile],
|
202
201
|
created_by: user_id,
|
203
202
|
created_for: user_id,
|
203
|
+
identifier: identifier[index],
|
204
204
|
content_type: file[:type],
|
205
205
|
attachable_type: type,
|
206
206
|
attachable_id: id,
|
207
207
|
)
|
208
|
-
|
209
|
-
|
210
|
-
attach_ary.push(
|
208
|
+
ActiveRecord::Base.transaction do
|
209
|
+
att.save!
|
210
|
+
attach_ary.push(att.id)
|
211
211
|
ensure
|
212
212
|
tempfile.close
|
213
213
|
tempfile.unlink
|
@@ -4,6 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
require 'date'
|
7
|
+
require 'labimotion/version'
|
7
8
|
require 'labimotion/utils/utils'
|
8
9
|
|
9
10
|
# rubocop: disable Metrics/AbcSize
|
@@ -116,7 +117,7 @@ module Labimotion
|
|
116
117
|
)
|
117
118
|
# att.attachment_attacher.attach(tmp_file)
|
118
119
|
if att.valid? && Labimotion::IS_RAILS5 == false
|
119
|
-
att.attachment_attacher.create_derivatives
|
120
|
+
## att.attachment_attacher.create_derivatives
|
120
121
|
att.save!
|
121
122
|
end
|
122
123
|
if att.valid? && Labimotion::IS_RAILS5 == true
|
@@ -148,7 +149,12 @@ module Labimotion
|
|
148
149
|
response = nil
|
149
150
|
begin
|
150
151
|
ofile = Rails.root.join(data[:f], data[:a].filename)
|
151
|
-
|
152
|
+
if Labimotion::IS_RAILS5 == true
|
153
|
+
FileUtils.cp(data[:a].store.path, ofile)
|
154
|
+
else
|
155
|
+
FileUtils.cp(data[:a].attachment_url, ofile)
|
156
|
+
end
|
157
|
+
|
152
158
|
File.open(ofile, 'r') do |f|
|
153
159
|
body = { file: f }
|
154
160
|
response = HTTParty.post(
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'export_table'
|
3
|
+
require 'labimotion/version'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
## ExportDataset
|
@@ -101,9 +102,18 @@ module Labimotion
|
|
101
102
|
cds.attachments.where(aasm_state: 'csv').each do |att|
|
102
103
|
name = File.basename(att.filename, '.csv')
|
103
104
|
sheet = @xfile.workbook.add_worksheet(name: name)
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
if Labimotion::IS_RAILS5 == true
|
107
|
+
File.open(att.store.path) do |fi|
|
108
|
+
fi.each_line do |line|
|
109
|
+
sheet.add_row(line.split(','))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
else
|
113
|
+
File.open(att.attachment_url) do |fi|
|
114
|
+
fi.each_line do |line|
|
115
|
+
sheet.add_row(line.split(','))
|
116
|
+
end
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/version'
|
3
4
|
require 'labimotion/utils/utils'
|
4
5
|
|
5
6
|
module Labimotion
|
@@ -7,8 +8,8 @@ module Labimotion
|
|
7
8
|
class NmrMapper
|
8
9
|
def self.is_brucker_binary(id)
|
9
10
|
att = Attachment.find(id)
|
10
|
-
if
|
11
|
-
Zip::File.open(att.
|
11
|
+
if Labimotion::IS_RAILS5 == true
|
12
|
+
Zip::File.open(att.store.path) do |zip_file|
|
12
13
|
zip_file.each do |entry|
|
13
14
|
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
14
15
|
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
@@ -16,6 +17,17 @@ module Labimotion
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
20
|
+
else
|
21
|
+
if att&.attachment_attacher&.file&.url
|
22
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
23
|
+
zip_file.each do |entry|
|
24
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
25
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
26
|
+
return metadata
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
19
31
|
end
|
20
32
|
nil
|
21
33
|
end
|
@@ -1,18 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'labimotion/version'
|
2
3
|
require 'labimotion/utils/utils'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
class NmrMapperRepo
|
6
7
|
def self.is_brucker_binary(id)
|
7
8
|
att = Attachment.find(id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if Labimotion::IS_RAILS5 == true
|
10
|
+
Zip::File.open(att.store.path) do |zip_file|
|
11
|
+
zip_file.each do |entry|
|
12
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
13
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
14
|
+
return metadata
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
if att&.attachment_attacher&.file&.url
|
20
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
21
|
+
zip_file.each do |entry|
|
22
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
23
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
24
|
+
return metadata
|
25
|
+
end
|
26
|
+
end
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
30
|
+
|
16
31
|
nil
|
17
32
|
end
|
18
33
|
|
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: 0.
|
4
|
+
version: 1.0.0
|
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: 2023-08-
|
12
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|