european-carry-all 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/european-carry-all.gemspec +1 -1
- data/lib/{european.rb → european-carry-all.rb} +2 -0
- data/lib/european/build.rb +1 -1
- data/lib/european/build_system.rb +20 -8
- data/lib/european/carry_all.rb +126 -19
- data/lib/european/deploy_system.rb +57 -0
- data/lib/european/name_interpreter.rb +17 -0
- data/lib/european/named_carry_all_item.rb +9 -1
- data/lib/european/project.rb +21 -6
- data/lib/european/version.rb +1 -1
- data/spec/data/configs/build.rb +7 -0
- data/spec/data/configs/build_system-with-block.rb +4 -0
- data/spec/data/configs/build_system.rb +1 -0
- data/spec/data/configs/deploy.rb +8 -0
- data/spec/data/configs/deploy_system-with-block.rb +4 -0
- data/spec/data/configs/deploy_system.rb +1 -0
- data/spec/data/configs/jedcn.rb +3 -5
- data/spec/data/configs/project-with-block.rb +6 -0
- data/spec/data/configs/project.rb +1 -0
- data/spec/data/configs/project_defaults.rb +16 -0
- data/spec/data/configs/source_system-with-block.rb +3 -0
- data/spec/data/configs/source_system.rb +1 -0
- data/spec/data/configs/typical-example.rb +26 -0
- data/spec/dsl/build_spec.rb +41 -0
- data/spec/dsl/build_system_spec.rb +57 -0
- data/spec/dsl/deploy_spec.rb +38 -0
- data/spec/dsl/deploy_system_spec.rb +57 -0
- data/spec/dsl/project_defaults_spec.rb +37 -0
- data/spec/dsl/project_spec.rb +50 -0
- data/spec/dsl/source_system_spec.rb +53 -0
- data/spec/dsl/typical_example_spec.rb +109 -0
- data/spec/lib/european/carry_all_spec.rb +6 -47
- data/spec/lib/european/name_interpreter_spec.rb +22 -0
- data/spec/lib/european/project_spec.rb +36 -12
- data/spec/spec_helper.rb +1 -1
- metadata +48 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjM0MzAyMTNlMGJjMTZiZjIzNjQ3YmVjMzViMjJmYTU5ZjU2MGU1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzNiNDEyYjdmYTA3ODA5ZDM4N2Y0MmJlMjdlYmMwY2FjZTgyYzBmYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2UwYzQ1YzljZTgyOGUwZjFkYzQzNjk2NDdiN2E3NmY4YjgzZTRjNjE1ODI3
|
10
|
+
YmE3NzM1ZWRjOWI5ZjBiNWU0NDU2MGVmNjU3ZmViMTFkNDczNDlkMDBmMWIw
|
11
|
+
MGZkYjFkNjYzY2Y3ZTE3Yjg5NzM5YzRhZDYwNjcyN2YzMDQ3NDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzUzYWJjY2MwMzNkNjdmMzY5M2ExNzQ5NzE3ZDg1YWYwYzEwMjk5MDYwNzc0
|
14
|
+
MDI5MWM2NWVmNGVhM2IxZDgzMDllNTgxZDc2MmQ4NGY1NGIwMTZkN2ZlYmUw
|
15
|
+
Yjk1MjJiYzNiOGE1Y2NlNzdlNzM3OGI5NGZlYzMwODM1Y2RhMGM=
|
data/Gemfile.lock
CHANGED
data/european-carry-all.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ['northridge@gmail.com']
|
11
11
|
s.homepage = 'https://github.com/jedcn/european-carry-all'
|
12
12
|
s.summary = %q{A lightweight DSL for describing a project portfolio}
|
13
|
-
s.description = %q{A scheme for describing project portfolios.
|
13
|
+
s.description = %q{A scheme for describing project portfolios.}
|
14
14
|
|
15
15
|
s.add_development_dependency 'rspec'
|
16
16
|
s.add_development_dependency 'guard-rspec'
|
@@ -1,6 +1,8 @@
|
|
1
|
+
require_relative 'european/name_interpreter'
|
1
2
|
require_relative 'european/named_carry_all_item'
|
2
3
|
require_relative 'european/build'
|
3
4
|
require_relative 'european/source_system'
|
4
5
|
require_relative 'european/build_system'
|
6
|
+
require_relative 'european/deploy_system'
|
5
7
|
require_relative 'european/project'
|
6
8
|
require_relative 'european/carry_all'
|
data/lib/european/build.rb
CHANGED
@@ -5,7 +5,7 @@ module European
|
|
5
5
|
|
6
6
|
def initialize(args)
|
7
7
|
@build_system = args[:build_system] || raise(':build_system is required')
|
8
|
-
@project = args[:project]
|
8
|
+
@project = args[:project]
|
9
9
|
@name = args[:name] || raise(':name is required')
|
10
10
|
@url = args[:url] || raise(':url is required')
|
11
11
|
end
|
@@ -2,8 +2,6 @@ module European
|
|
2
2
|
|
3
3
|
class BuildSystem < NamedCarryAllItem
|
4
4
|
|
5
|
-
attr_reader :projects, :builds
|
6
|
-
|
7
5
|
attr_reader :url, :project_path
|
8
6
|
|
9
7
|
def initialize(args)
|
@@ -12,10 +10,6 @@ module European
|
|
12
10
|
@builds = {}
|
13
11
|
end
|
14
12
|
|
15
|
-
def to_s
|
16
|
-
"BuildSystem '#{name}'"
|
17
|
-
end
|
18
|
-
|
19
13
|
#
|
20
14
|
# Methods invoked by CarryAll
|
21
15
|
def url_for_project_named(name)
|
@@ -23,11 +17,29 @@ module European
|
|
23
17
|
end
|
24
18
|
|
25
19
|
def add_project(project)
|
26
|
-
projects[project.name] = project
|
20
|
+
@projects[project.name] = project
|
27
21
|
end
|
28
22
|
|
29
23
|
def add_build(build)
|
30
|
-
builds[build.name] = build
|
24
|
+
@builds[build.name] = build
|
25
|
+
end
|
26
|
+
|
27
|
+
def projects()
|
28
|
+
@projects.values
|
29
|
+
end
|
30
|
+
|
31
|
+
def project(args)
|
32
|
+
named = args[:named] || raise('named is required')
|
33
|
+
@projects[named]
|
34
|
+
end
|
35
|
+
|
36
|
+
def builds
|
37
|
+
@builds.values
|
38
|
+
end
|
39
|
+
|
40
|
+
def build(args)
|
41
|
+
named = args[:named] || raise('named is required')
|
42
|
+
@builds[named]
|
31
43
|
end
|
32
44
|
|
33
45
|
#
|
data/lib/european/carry_all.rb
CHANGED
@@ -2,48 +2,106 @@ module European
|
|
2
2
|
|
3
3
|
class CarryAll
|
4
4
|
|
5
|
-
attr_reader :projects, :build_systems, :source_systems
|
6
|
-
|
7
5
|
def initialize
|
8
6
|
@projects = {}
|
9
7
|
@build_systems = {}
|
8
|
+
@deploy_systems = {}
|
10
9
|
@source_systems = {}
|
10
|
+
@post_setup_procs = []
|
11
11
|
end
|
12
12
|
|
13
13
|
def setup
|
14
|
-
source_systems.values.each { |system| system.setup }
|
15
|
-
build_systems.values.each { |system| system.setup }
|
16
|
-
|
14
|
+
@source_systems.values.each { |system| system.setup }
|
15
|
+
@build_systems.values.each { |system| system.setup }
|
16
|
+
@deploy_systems.values.each { |system| system.setup }
|
17
|
+
default_project = @projects['defaults']
|
18
|
+
default_project.setup if default_project
|
19
|
+
@projects.delete 'defaults'
|
20
|
+
@projects.values.each do |project|
|
21
|
+
next if project == default_project
|
22
|
+
project.exec default_project.proc if default_project
|
23
|
+
project.setup
|
24
|
+
end
|
25
|
+
@post_setup_procs.each do |proc|
|
26
|
+
instance_eval &proc
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
def add_project(project)
|
20
|
-
projects[project.name] = project
|
31
|
+
@projects[project.name] = project
|
21
32
|
end
|
22
33
|
|
23
34
|
def add_build_system(build_system)
|
24
|
-
build_systems[build_system.name] = build_system
|
35
|
+
@build_systems[build_system.name] = build_system
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_deploy_system(deploy_system)
|
39
|
+
@deploy_systems[deploy_system.name] = deploy_system
|
25
40
|
end
|
26
41
|
|
27
42
|
def add_source_system(source_system)
|
28
|
-
source_systems[source_system.name] = source_system
|
43
|
+
@source_systems[source_system.name] = source_system
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_setup(&block)
|
47
|
+
@post_setup_procs << block
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO: Ack! This is shadowing the kernel defined 'project' from
|
51
|
+
# the DSL portion in load_file. Is there anyway to avoid globally
|
52
|
+
# defining 'project'?
|
53
|
+
def project(args)
|
54
|
+
named = args[:named] || raise(':named is required')
|
55
|
+
@projects[named]
|
56
|
+
end
|
57
|
+
|
58
|
+
def projects
|
59
|
+
@projects.values
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_system(args)
|
63
|
+
named = args[:named] || raise(':named is required')
|
64
|
+
@build_systems[named]
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_systems
|
68
|
+
@build_systems.values
|
69
|
+
end
|
70
|
+
|
71
|
+
def deploy_system(args)
|
72
|
+
named = args[:named] || raise(':named is required')
|
73
|
+
@deploy_systems[named]
|
74
|
+
end
|
75
|
+
|
76
|
+
def deploy_systems
|
77
|
+
@deploy_systems.values
|
78
|
+
end
|
79
|
+
|
80
|
+
def source_system(args)
|
81
|
+
named = args[:named] || raise(':named is required')
|
82
|
+
@source_systems[named]
|
83
|
+
end
|
84
|
+
|
85
|
+
def source_systems
|
86
|
+
@source_systems.values
|
29
87
|
end
|
30
88
|
|
31
89
|
def register(item, action, name)
|
32
90
|
if item.class == Project
|
33
91
|
project = item
|
34
|
-
if action == :
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
build_system.
|
39
|
-
|
40
|
-
|
41
|
-
if build_system.builds[name]
|
42
|
-
raise "#{build_system} already has a build named #{name}'"
|
92
|
+
if action == :has_build
|
93
|
+
ni = NameInterpreter.new name
|
94
|
+
build_system_name = ni.prefix
|
95
|
+
build_name = ni.name
|
96
|
+
build_system = build_systems.find { |bs| bs.name == build_system_name }
|
97
|
+
if build_system.build named: build_name
|
98
|
+
raise "#{build_system} already has a build named #{build_name}'"
|
43
99
|
end
|
44
|
-
url = build_system.url_for_project_named
|
45
|
-
build = Build.new build_system: build_system, project: project, name:
|
100
|
+
url = build_system.url_for_project_named build_name
|
101
|
+
build = Build.new build_system: build_system, project: project, name: build_name, url: url
|
46
102
|
build_system.add_build build
|
103
|
+
build_system.add_project project
|
104
|
+
project.add_build_system build_system
|
47
105
|
project.add_build build
|
48
106
|
elsif action == :is_hosted_on
|
49
107
|
source_system = @source_systems[name]
|
@@ -52,6 +110,23 @@ module European
|
|
52
110
|
source_system.add_project project
|
53
111
|
url = source_system.src_url_for_project_named project.name
|
54
112
|
project.src_url = url
|
113
|
+
elsif action == :deploys_from
|
114
|
+
deploy_system = @deploy_systems[name]
|
115
|
+
raise "Unknown DeploySystem '#{name}'" unless deploy_system
|
116
|
+
project.deploy_systems << deploy_system
|
117
|
+
deploy_system.add_project project
|
118
|
+
elsif action == :has_deploy
|
119
|
+
ni = NameInterpreter.new name
|
120
|
+
deploy_system_name = ni.prefix
|
121
|
+
build_name = ni.name
|
122
|
+
deploy_system = deploy_systems.find { |ds| ds.name == deploy_system_name }
|
123
|
+
if deploy_system.build named: build_name
|
124
|
+
raise "#{deploy_system} already has a deploy named '#{build_name}'"
|
125
|
+
end
|
126
|
+
url = deploy_system.url_for_project_named build_name
|
127
|
+
deploy = Build.new build_system: deploy_system, project: project, name: build_name, url: url
|
128
|
+
deploy_system.add_build deploy
|
129
|
+
project.add_deploy deploy
|
55
130
|
end
|
56
131
|
end
|
57
132
|
end
|
@@ -64,17 +139,49 @@ module European
|
|
64
139
|
|
65
140
|
class CarryAll
|
66
141
|
|
142
|
+
require 'tempfile'
|
143
|
+
require 'open-uri'
|
144
|
+
|
145
|
+
def self.load_url(url)
|
146
|
+
file = Tempfile.new 'carry_all'
|
147
|
+
url_content = open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
|
148
|
+
file.write url_content
|
149
|
+
file.close
|
150
|
+
load_file file.path
|
151
|
+
end
|
152
|
+
|
67
153
|
def self.load_file(file)
|
68
154
|
carry_all = CarryAll.new
|
69
155
|
lambda {
|
156
|
+
# TODO: Is there any way to define this.. just on an object..
|
157
|
+
# and have that DSL file be loaded in the context of that object?
|
70
158
|
Kernel.send :define_method, :project do |name, &block|
|
71
159
|
carry_all.add_project(European::Project.new({name: name, proc: block, carry_all: carry_all}))
|
72
160
|
end
|
73
161
|
|
162
|
+
Kernel.send :define_method, :build do |name|
|
163
|
+
carry_all.after_setup do
|
164
|
+
ni = NameInterpreter.new name
|
165
|
+
build_system_name = ni.prefix
|
166
|
+
build_name = ni.name
|
167
|
+
build_system = @build_systems[build_system_name]
|
168
|
+
if build_system.build named: name
|
169
|
+
raise "#{build_system} already has a build named #{name}'"
|
170
|
+
end
|
171
|
+
url = build_system.url_for_project_named build_name
|
172
|
+
build = Build.new build_system: build_system, project: nil, name: build_name, url: url
|
173
|
+
build_system.add_build build
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
74
177
|
Kernel.send :define_method, :build_system do |name, &block|
|
75
178
|
carry_all.add_build_system(European::BuildSystem.new({name: name, proc: block, carry_all: carry_all}))
|
76
179
|
end
|
77
180
|
|
181
|
+
Kernel.send :define_method, :deploy_system do |name, &block|
|
182
|
+
carry_all.add_deploy_system(European::DeploySystem.new({name: name, proc: block, carry_all: carry_all}))
|
183
|
+
end
|
184
|
+
|
78
185
|
Kernel.send :define_method, :source_system do |name, &block|
|
79
186
|
carry_all.add_source_system(European::SourceSystem.new({name: name, proc: block, carry_all: carry_all}))
|
80
187
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module European
|
2
|
+
|
3
|
+
class DeploySystem < NamedCarryAllItem
|
4
|
+
|
5
|
+
attr_reader :url, :project_path
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
super args
|
9
|
+
@projects = {}
|
10
|
+
@builds = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Methods invoked by CarryAll
|
15
|
+
def url_for_project_named(name)
|
16
|
+
eval project_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_project(project)
|
20
|
+
@projects[project.name] = project
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_build(build)
|
24
|
+
@builds[build.name] = build
|
25
|
+
end
|
26
|
+
|
27
|
+
def projects()
|
28
|
+
@projects.values
|
29
|
+
end
|
30
|
+
|
31
|
+
def project(args)
|
32
|
+
named = args[:named] || raise('named is required')
|
33
|
+
@projects[named]
|
34
|
+
end
|
35
|
+
|
36
|
+
def builds
|
37
|
+
@builds.values
|
38
|
+
end
|
39
|
+
|
40
|
+
def build(args)
|
41
|
+
named = args[:named] || raise('named is required')
|
42
|
+
@builds[named]
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# DSL
|
47
|
+
def url_is(url)
|
48
|
+
@url = url
|
49
|
+
end
|
50
|
+
|
51
|
+
def hosts_projects_at(project_path)
|
52
|
+
@project_path = project_path
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -2,7 +2,7 @@ module European
|
|
2
2
|
|
3
3
|
class NamedCarryAllItem
|
4
4
|
|
5
|
-
attr_reader :name
|
5
|
+
attr_reader :name, :proc
|
6
6
|
|
7
7
|
def initialize(args)
|
8
8
|
@name = args[:name] || raise(':name is required')
|
@@ -13,5 +13,13 @@ module European
|
|
13
13
|
instance_eval &@proc if @proc
|
14
14
|
end
|
15
15
|
|
16
|
+
def exec(proc)
|
17
|
+
instance_eval &proc
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
"#{self.class} '#{name}'"
|
22
|
+
end
|
23
|
+
|
16
24
|
end
|
17
25
|
end
|
data/lib/european/project.rb
CHANGED
@@ -3,13 +3,16 @@ module European
|
|
3
3
|
|
4
4
|
attr_reader :carry_all
|
5
5
|
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :build_systems, :source_system, :deploy_systems
|
7
7
|
|
8
|
-
attr_accessor :builds, :src_url
|
8
|
+
attr_accessor :builds, :deploys, :src_url
|
9
9
|
|
10
10
|
def initialize(args)
|
11
11
|
@carry_all = args[:carry_all] || raise(':carry_all is required')
|
12
12
|
@builds = {}
|
13
|
+
@deploys = {}
|
14
|
+
@deploy_systems = []
|
15
|
+
@build_systems = []
|
13
16
|
super args
|
14
17
|
end
|
15
18
|
|
@@ -23,15 +26,27 @@ module European
|
|
23
26
|
builds[build.name] = build
|
24
27
|
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
def add_build_system(build_system)
|
30
|
+
build_systems << build_system
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_deploy(name)
|
34
|
+
carry_all.register self, :has_deploy, name
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_deploy(deploy)
|
38
|
+
deploys[deploy.name] = deploy
|
30
39
|
end
|
31
40
|
|
41
|
+
#
|
42
|
+
# DSL
|
32
43
|
def is_hosted_on(name)
|
33
44
|
carry_all.register self, :is_hosted_on, name
|
34
45
|
end
|
35
46
|
|
47
|
+
def deploys_from(name)
|
48
|
+
carry_all.register self, :deploys_from, name
|
49
|
+
end
|
50
|
+
|
36
51
|
end
|
37
52
|
end
|