singularity_dsl 1.2.9 → 1.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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/singularity_dsl.rb +30 -0
- data/lib/singularity_dsl/dsl/dsl.rb +6 -0
- data/lib/singularity_dsl/version.rb +1 -1
- data/spec/singularity_dsl/dsl/dsl_spec.rb +3 -0
- data/spec/singularity_dsl_spec.rb +26 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmFiYjBhODAxOGNjZmQxYzMwNmMyZjM4ODk0ODI1ZjE2MTBjZjgxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjBhZmUzODYxYTEzZGNjNmViNzdmYWFjNjIwYWU2Yzc5ZDg5MTdkYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDEyMmI2OTE5YzFlMTRmNGNkYzYwM2RhNGZmZGMzOWE0YzY1MDYxZDIwOTM3
|
10
|
+
MWM5OWJjMjY0MjZjN2RjNDEzNzViMWU2MTNkODJmMTUwYmZlYTkwM2IyMjUy
|
11
|
+
M2QwNjJjMjRjNTIyMTgyYjAxYzk3NGZmMmZhZDEzM2FlNzk5YjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWU2NmE3NjUxZTk0MDNiNGViZTI1YWE3MTVkZDhmYTE2YzNmYzk1NmRkZTZj
|
14
|
+
NTA5OTQ3YjU3NjcwNzY2MmUxN2I5ZmViZjQ4YTYxN2UxNmQ5MWU1NGY1MjNl
|
15
|
+
ZThmMDI0ZjEyN2FhOWQxYjI2YWQyMWI5NDcxZjU2ZWJmODI1NGQ=
|
data/Gemfile.lock
CHANGED
data/lib/singularity_dsl.rb
CHANGED
@@ -5,5 +5,35 @@ if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
|
5
5
|
throw 'Sorry, wont run on mswin|mingw32|windows'
|
6
6
|
end
|
7
7
|
|
8
|
+
# SingularityDsl Module
|
9
|
+
# logic for task -> file mapping
|
10
|
+
# ==== WARNING: HERE THERE BE DRAGONS ====
|
11
|
+
module SingularityDsl
|
12
|
+
class << self
|
13
|
+
attr_reader :task_map
|
14
|
+
end
|
15
|
+
|
16
|
+
@task_map = {}
|
17
|
+
|
18
|
+
def self.map_task_file(obj, file)
|
19
|
+
@task_map[map_key obj] = file
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.task_file(obj)
|
23
|
+
return false unless @task_map.key? map_key(obj)
|
24
|
+
@task_map[map_key obj]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.reset_map
|
28
|
+
@task_map = {}
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.map_key(obj)
|
34
|
+
obj.class.to_s.to_sym
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
8
38
|
require 'singularity_dsl/application'
|
9
39
|
require 'singularity_dsl/dsl/components'
|
@@ -34,8 +34,14 @@ module SingularityDsl
|
|
34
34
|
|
35
35
|
def load_tasks_in_path(path)
|
36
36
|
base_tasks = task_list
|
37
|
+
updated_tasks = task_list
|
37
38
|
files_in_path(path, 'rb').each do |file|
|
38
39
|
SingularityDsl.module_eval(::File.read file)
|
40
|
+
# keep a list of class => file mappings
|
41
|
+
(task_list - updated_tasks).each do |klass|
|
42
|
+
SingularityDsl.map_task_file klass, file
|
43
|
+
end
|
44
|
+
updated_tasks = task_list
|
39
45
|
end
|
40
46
|
load_tasks(task_list - base_tasks)
|
41
47
|
end
|
@@ -40,6 +40,9 @@ describe 'Dsl' do
|
|
40
40
|
path = ::File.dirname(__FILE__) + '/stubs/tasks'
|
41
41
|
dsl.load_tasks_in_path path
|
42
42
|
expect(dsl.singleton_methods).to include :dummytask
|
43
|
+
# IMPORTANT: do this to prevent the singleton
|
44
|
+
# from having this task in the map
|
45
|
+
SingularityDsl.reset_map
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'singularity_dsl'
|
4
|
+
|
5
|
+
# WARNING: HERE THERE BE DRAGONS
|
6
|
+
describe 'SingularityDsl' do
|
7
|
+
after(:all) { SingularityDsl.reset_map }
|
8
|
+
|
9
|
+
context '#map_task_file' do
|
10
|
+
it 'saves class as sym, maps it to file' do
|
11
|
+
SingularityDsl.map_task_file 'string', 'foo'
|
12
|
+
expect(SingularityDsl.task_map).to include(String: 'foo')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context '#task_file' do
|
17
|
+
it 'returns false when no such class' do
|
18
|
+
expect(SingularityDsl.task_file 1).to eql false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns the correct mapping for a class' do
|
22
|
+
# THIS VALUE IS FROM THE RUN IN '#map_task_file'
|
23
|
+
expect(SingularityDsl.task_file 'foo').to eql('foo')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singularity_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chr0n1x
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- spec/singularity_dsl/runstate_spec.rb
|
193
193
|
- spec/singularity_dsl/task_spec.rb
|
194
194
|
- spec/singularity_dsl/tasks/shell_task_spec.rb
|
195
|
+
- spec/singularity_dsl_spec.rb
|
195
196
|
homepage: ''
|
196
197
|
licenses:
|
197
198
|
- MIT
|
@@ -231,3 +232,4 @@ test_files:
|
|
231
232
|
- spec/singularity_dsl/runstate_spec.rb
|
232
233
|
- spec/singularity_dsl/task_spec.rb
|
233
234
|
- spec/singularity_dsl/tasks/shell_task_spec.rb
|
235
|
+
- spec/singularity_dsl_spec.rb
|