cigale 0.2.0 → 0.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 +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +50 -0
- data/lib/cigale/macro_context.rb +56 -11
- data/lib/cigale/version.rb +1 -1
- data/spec/fixtures/macros/splats001.expanded.yml +9 -0
- data/spec/fixtures/macros/splats001.yml +11 -0
- data/spec/fixtures/macros/splats002.expanded.yml +9 -0
- data/spec/fixtures/macros/splats002.yml +11 -0
- data/spec/fixtures/macros/splats003.expanded.yml +8 -0
- data/spec/fixtures/macros/splats003.yml +10 -0
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8da52824902b0708fadf47bfc2518f011e8e22
|
4
|
+
data.tar.gz: e538664eeb77c7764ad2da5d4942385e3ca74e0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2db3a64ecbb2c7e84f22faded75e2221152f9c1f0e6614cdf90fc837f8bac5ceb9d42765b1f1aa80bdf09f35da2e6b90f09c29734eabba0f8f04b5becf9f296
|
7
|
+
data.tar.gz: cf9f8e9df365065e69379772766b90194cfe1c4636910efdc7fd1a4bf6bcc911cbf424eebfed1bec5f45ec10d4ca4105d2b213f0db684d629d1d26cb20d69f87
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
# 0.3.0
|
4
|
+
|
5
|
+
* Add support for splats, see [issue #2](https://github.com/itchio/cigale/issues/2)
|
6
|
+
|
7
|
+
# 0.2.0
|
8
|
+
|
9
|
+
* Add support for `skip-tag` in scm/git
|
10
|
+
|
11
|
+
# 0.1.0
|
12
|
+
|
13
|
+
* Initial release
|
14
|
+
* Compatibility with most jenkins-job-builder fixtures
|
data/README.md
CHANGED
@@ -99,6 +99,56 @@ If you're unsure what something will expand to, you can use the `dump` command:
|
|
99
99
|
cigale dump my-def.yml -o tmp
|
100
100
|
```
|
101
101
|
|
102
|
+
## Splats
|
103
|
+
|
104
|
+
Sometimes you want to do this:
|
105
|
+
|
106
|
+
```yaml
|
107
|
+
- :cool-wrappers:
|
108
|
+
- ansi-color
|
109
|
+
- inject
|
110
|
+
|
111
|
+
- job:
|
112
|
+
name: foobar
|
113
|
+
wrappers:
|
114
|
+
- .cool-wrappers:
|
115
|
+
- xvfb
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
But that will expand to:
|
120
|
+
|
121
|
+
```yaml
|
122
|
+
- job:
|
123
|
+
name: foobar
|
124
|
+
wrappers:
|
125
|
+
- - ansi-color
|
126
|
+
- inject
|
127
|
+
- xvfb
|
128
|
+
```
|
129
|
+
|
130
|
+
Which isn't valid. What you want instead is use a splat when calling
|
131
|
+
cool-wrappers (see [issue #2](https://github.com/itchio/cigale/issues/2))
|
132
|
+
|
133
|
+
```yaml
|
134
|
+
- job:
|
135
|
+
name: foobar
|
136
|
+
wrappers:
|
137
|
+
- ..cool-wrappers:
|
138
|
+
- xvfb
|
139
|
+
```
|
140
|
+
|
141
|
+
Which will expand to the expected result:
|
142
|
+
|
143
|
+
```yaml
|
144
|
+
- job:
|
145
|
+
name: foobar
|
146
|
+
wrappers:
|
147
|
+
- ansi-color
|
148
|
+
- inject
|
149
|
+
- xvfb
|
150
|
+
```
|
151
|
+
|
102
152
|
## Contributing
|
103
153
|
|
104
154
|
1. Fork it ( https://github.com/itchio/cigale/fork )
|
data/lib/cigale/macro_context.rb
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
require "cigale/exts"
|
3
3
|
|
4
4
|
module Cigale
|
5
|
+
class Splat
|
6
|
+
def initialize (elems)
|
7
|
+
@elems = elems
|
8
|
+
end
|
9
|
+
|
10
|
+
def elems
|
11
|
+
@elems
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
class MacroContext < Exts
|
6
16
|
def initialize (options)
|
7
17
|
@library = options[:library]
|
@@ -21,34 +31,69 @@ module Cigale
|
|
21
31
|
case entity
|
22
32
|
when Array
|
23
33
|
# list of things, need to expand each individually
|
24
|
-
|
25
|
-
|
34
|
+
array = []
|
35
|
+
|
36
|
+
entity.each do |x|
|
37
|
+
case child = expand(x)
|
38
|
+
when Splat
|
39
|
+
array += child.elems
|
40
|
+
else
|
41
|
+
array << child
|
42
|
+
end
|
26
43
|
end
|
44
|
+
|
45
|
+
array
|
27
46
|
when Hash
|
28
|
-
|
47
|
+
pairs = []
|
48
|
+
|
49
|
+
entity.each do |k, v|
|
29
50
|
case k
|
30
51
|
when /^\.(.*)$/
|
31
52
|
# macro call
|
32
53
|
if expanding?
|
33
54
|
# keep child macro as-is for later expansion
|
34
|
-
[k, expand(v)]
|
55
|
+
pairs << [k, expand(v)]
|
35
56
|
else
|
36
|
-
|
57
|
+
splat = false
|
58
|
+
mname = $1
|
59
|
+
|
60
|
+
# cf. https://github.com/itchio/cigale/issues/2 for 'spec'
|
61
|
+
if mname =~ /^\./
|
62
|
+
mname = mname[1..-1]
|
63
|
+
splat = true
|
64
|
+
end
|
65
|
+
|
66
|
+
mdef = lookup(mname)
|
37
67
|
|
38
68
|
res = self.with_params(v).expand(mdef)
|
39
69
|
case res
|
40
70
|
when Hash
|
41
|
-
|
42
|
-
|
43
|
-
|
71
|
+
if splat
|
72
|
+
raise "Unnecessary use of splat: #{entity.inspect}"
|
73
|
+
end
|
74
|
+
res.each_pair { |p| pairs << p }
|
75
|
+
when Array
|
76
|
+
if splat
|
77
|
+
if entity.size > 1
|
78
|
+
raise "Invalid array splat (needs to be single-pair hash): #{entity.inspect}"
|
79
|
+
end
|
80
|
+
return Splat.new(res)
|
81
|
+
else
|
82
|
+
return res
|
83
|
+
end
|
44
84
|
else
|
45
|
-
|
85
|
+
if splat
|
86
|
+
raise "Invalid macro expansion result for splat: #{res.inspect}"
|
87
|
+
end
|
88
|
+
return res
|
46
89
|
end
|
47
90
|
end
|
48
91
|
else
|
49
|
-
[k, expand(v)]
|
92
|
+
pairs << [k, expand(v)]
|
50
93
|
end
|
51
|
-
end
|
94
|
+
end
|
95
|
+
|
96
|
+
pairs.to_h
|
52
97
|
else
|
53
98
|
# not a list, not a hash
|
54
99
|
interpolate(entity)
|
data/lib/cigale/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cigale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Wenger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- Gemfile
|
136
137
|
- LICENSE.txt
|
137
138
|
- README.md
|
@@ -333,6 +334,12 @@ files:
|
|
333
334
|
- spec/fixtures/macros/macro-scm001.yml
|
334
335
|
- spec/fixtures/macros/macro-scm002.expanded.yml
|
335
336
|
- spec/fixtures/macros/macro-scm002.yml
|
337
|
+
- spec/fixtures/macros/splats001.expanded.yml
|
338
|
+
- spec/fixtures/macros/splats001.yml
|
339
|
+
- spec/fixtures/macros/splats002.expanded.yml
|
340
|
+
- spec/fixtures/macros/splats002.yml
|
341
|
+
- spec/fixtures/macros/splats003.expanded.yml
|
342
|
+
- spec/fixtures/macros/splats003.yml
|
336
343
|
- spec/fixtures/parity/builders/__init__.py
|
337
344
|
- spec/fixtures/parity/builders/fixtures/ant001.xml
|
338
345
|
- spec/fixtures/parity/builders/fixtures/ant001.yaml
|
@@ -1331,6 +1338,12 @@ test_files:
|
|
1331
1338
|
- spec/fixtures/macros/macro-scm001.yml
|
1332
1339
|
- spec/fixtures/macros/macro-scm002.expanded.yml
|
1333
1340
|
- spec/fixtures/macros/macro-scm002.yml
|
1341
|
+
- spec/fixtures/macros/splats001.expanded.yml
|
1342
|
+
- spec/fixtures/macros/splats001.yml
|
1343
|
+
- spec/fixtures/macros/splats002.expanded.yml
|
1344
|
+
- spec/fixtures/macros/splats002.yml
|
1345
|
+
- spec/fixtures/macros/splats003.expanded.yml
|
1346
|
+
- spec/fixtures/macros/splats003.yml
|
1334
1347
|
- spec/fixtures/parity/builders/__init__.py
|
1335
1348
|
- spec/fixtures/parity/builders/fixtures/ant001.xml
|
1336
1349
|
- spec/fixtures/parity/builders/fixtures/ant001.yaml
|