sample-template-generator-gem 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1156
- data/jars/sample-template-generator-0.3.jar +0 -0
- data/lib/seek/sample_templates.rb +22 -0
- data/lib/seek/sample_templates/column.rb +19 -0
- data/lib/seek/sample_templates/generator.rb +13 -48
- data/lib/seek/sample_templates/version.rb +1 -1
- data/sample-template-generator-gem.gemspec +4 -11
- metadata +33 -10
- data/jars/sample-template-generator-0.2.jar +0 -0
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'seek/sample_templates/column'
|
2
|
+
require 'seek/sample_templates/generator'
|
3
|
+
|
4
|
+
module Seek
|
5
|
+
# Main entry point for generating templates
|
6
|
+
module SampleTemplates
|
7
|
+
# generates a template at the specific path
|
8
|
+
def self.generate(sheet_name, sheet_index, columns, path)
|
9
|
+
Seek::SampleTemplates::Generator.new(
|
10
|
+
path, create_json(columns, sheet_index, sheet_name)
|
11
|
+
).generate
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create_json(columns, sheet_index, sheet_name)
|
15
|
+
{ sheet_name: sheet_name,
|
16
|
+
sheet_index: sheet_index,
|
17
|
+
columns: columns.collect(&:as_json) }.to_json
|
18
|
+
end
|
19
|
+
|
20
|
+
private_class_method :create_json
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Seek
|
2
|
+
module SampleTemplates
|
3
|
+
# Describes a column in the template.
|
4
|
+
# The name is the text put in the top row,
|
5
|
+
# and contents will create a dropdown in the row below unless empty
|
6
|
+
class Column
|
7
|
+
attr_reader :name, :contents
|
8
|
+
|
9
|
+
def initialize(name, contents = [])
|
10
|
+
@name = name
|
11
|
+
@contents = contents
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json
|
15
|
+
{ @name => @contents }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,44 +1,27 @@
|
|
1
|
-
require '
|
1
|
+
require 'cocaine'
|
2
2
|
|
3
3
|
module Seek
|
4
4
|
module SampleTemplates
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def self.create_json(columns, sheet_index, sheet_name)
|
10
|
-
{ sheet_name: sheet_name, sheet_index: sheet_index, columns: columns.collect(&:as_json) }.to_json
|
11
|
-
end
|
12
|
-
|
13
|
-
class Column
|
14
|
-
attr_accessor :name, :contents
|
15
|
-
def initialize(name, contents = [])
|
16
|
-
@name = name
|
17
|
-
@contents = contents
|
18
|
-
end
|
19
|
-
|
20
|
-
def as_json
|
21
|
-
{ @name => @contents }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
5
|
+
# Generator class for creating templates.
|
6
|
+
# Generally this shouldn't be used directly, but instead should be used
|
7
|
+
# through Seek::SampleTemplates.generate(..)
|
25
8
|
class Generator
|
26
|
-
JAR_VERSION = '0.
|
27
|
-
JAR_PATH = File.dirname(__FILE__) +
|
9
|
+
JAR_VERSION = '0.3'.freeze
|
10
|
+
JAR_PATH = File.dirname(__FILE__) +
|
11
|
+
"/../../../jars/sample-template-generator-#{JAR_VERSION}.jar"
|
28
12
|
DEFAULT_MEMORY_ALLOCATION = '512M'.freeze
|
29
13
|
BUFFER_SIZE = 250_000 # 1/4 a megabyte
|
30
14
|
|
31
|
-
|
15
|
+
attr_reader :json, :path, :memory_allocation
|
32
16
|
|
33
17
|
def initialize(path, json, memory_allocation = DEFAULT_MEMORY_ALLOCATION)
|
34
18
|
@path = path
|
35
19
|
@json = json
|
36
20
|
@memory_allocation = memory_allocation
|
37
|
-
raise Exception, 'Windows is not currently supported' if windows?
|
38
21
|
end
|
39
22
|
|
40
23
|
def generate
|
41
|
-
|
24
|
+
run_with_cocaine
|
42
25
|
end
|
43
26
|
|
44
27
|
private
|
@@ -50,29 +33,11 @@ module Seek
|
|
50
33
|
command
|
51
34
|
end
|
52
35
|
|
53
|
-
def
|
54
|
-
output =
|
55
|
-
err_message = ''
|
56
|
-
command = command()
|
57
|
-
status = Open4.popen4(command) do |_pid, _stdin, stdout, stderr|
|
58
|
-
until (line = stdout.gets(BUFFER_SIZE)).nil?
|
59
|
-
output << line
|
60
|
-
end
|
61
|
-
stdout.close
|
62
|
-
|
63
|
-
until (line = stderr.gets(BUFFER_SIZE)).nil?
|
64
|
-
err_message << line
|
65
|
-
end
|
66
|
-
stderr.close
|
67
|
-
end
|
68
|
-
|
69
|
-
raise err_message if status.to_i.nonzero?
|
70
|
-
|
36
|
+
def run_with_cocaine
|
37
|
+
output = Cocaine::CommandLine.new(command).run
|
71
38
|
output.strip
|
72
|
-
|
73
|
-
|
74
|
-
def windows?
|
75
|
-
!(RUBY_PLATFORM =~ /mswin32/ || RUBY_PLATFORM =~ /mingw32/).nil?
|
39
|
+
rescue Cocaine::ExitStatusError => exception
|
40
|
+
raise exception.message
|
76
41
|
end
|
77
42
|
end
|
78
43
|
end
|
@@ -9,29 +9,22 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Stuart Owen']
|
10
10
|
spec.email = ['stuart.owen@manchester.ac.uk']
|
11
11
|
|
12
|
-
spec.summary = '
|
12
|
+
spec.summary = 'Bespoke tool for generating spreadsheet templates from Sample Types for use with SEEK.'
|
13
13
|
spec.homepage = 'http://seek4science.org'
|
14
|
-
spec.license = 'BSD-3-Clause'
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
# if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
# else
|
21
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
-
# end
|
14
|
+
spec.license = 'BSD-3-Clause'
|
23
15
|
|
24
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
17
|
spec.bindir = 'exe'
|
26
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
19
|
spec.require_paths = ['lib']
|
28
20
|
|
29
|
-
spec.add_dependency('open4', ['= 1.3.0'])
|
30
21
|
spec.add_dependency('rdoc', ['>= 0'])
|
22
|
+
spec.add_dependency('cocaine', ['>= 0'])
|
31
23
|
|
32
24
|
spec.add_development_dependency('rubocop', ['>= 0'])
|
33
25
|
spec.add_development_dependency('rubycritic', ['>= 0'])
|
34
26
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
35
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
36
28
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
29
|
+
spec.add_development_dependency('activesupport', ">= 3.0.0", "< 5.0")
|
37
30
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sample-template-generator-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rdoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: cocaine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -108,6 +108,26 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '5.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.0.0
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '5.0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 3.0.0
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '5.0'
|
111
131
|
description:
|
112
132
|
email:
|
113
133
|
- stuart.owen@manchester.ac.uk
|
@@ -137,7 +157,9 @@ files:
|
|
137
157
|
- jars/lib/poi-ooxml-schemas-3.14.jar
|
138
158
|
- jars/lib/stax-api-1.0.1.jar
|
139
159
|
- jars/lib/xmlbeans-2.6.0.jar
|
140
|
-
- jars/sample-template-generator-0.
|
160
|
+
- jars/sample-template-generator-0.3.jar
|
161
|
+
- lib/seek/sample_templates.rb
|
162
|
+
- lib/seek/sample_templates/column.rb
|
141
163
|
- lib/seek/sample_templates/generator.rb
|
142
164
|
- lib/seek/sample_templates/version.rb
|
143
165
|
- sample-template-generator-gem.gemspec
|
@@ -164,5 +186,6 @@ rubyforge_project:
|
|
164
186
|
rubygems_version: 2.4.8
|
165
187
|
signing_key:
|
166
188
|
specification_version: 4
|
167
|
-
summary:
|
189
|
+
summary: Bespoke tool for generating spreadsheet templates from Sample Types for use
|
190
|
+
with SEEK.
|
168
191
|
test_files: []
|
Binary file
|