ci_config_generator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ci_config_generator.gemspec +1 -0
- data/lib/ci_config_generator.rb +13 -0
- data/lib/ci_config_generator/tasks.rb +4 -14
- data/lib/ci_config_generator/version.rb +1 -1
- data/spec/acceptance_spec.rb +11 -1
- metadata +25 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4201b85c80983b5db511f9843902c5aad8c39feea4d275c699a01924af66a760
|
4
|
+
data.tar.gz: 41dc5afaecf7d9cec64fdde1fcab997e6876b2438406708792b34ef767559ccc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 067838e7a330eb5b9e15595af4afc54c0fa596a5c63d42a3f8223d410b6c80c4dc87db0426e5a75fc6389a218a836db8d6da6be5860610161bfa3e022c6fe1ee
|
7
|
+
data.tar.gz: 0a508d3e2519333da409f40c1e5ad6a3ac3bda3734a4ce8c3b361a775cbe4724dd8908e539ad8ec86a134c889c5efb94e71049e49e1f33a014d423a7a203d3cd
|
data/ci_config_generator.gemspec
CHANGED
data/lib/ci_config_generator.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
require "ci_config_generator/version"
|
2
2
|
|
3
3
|
module CiConfigGenerator
|
4
|
+
|
5
|
+
def self.interpolate(file_name, variables)
|
6
|
+
File.read(file_name).gsub(/%{[^}]+}/) do |match|
|
7
|
+
key = match.gsub(/^%{([^}]+)}/, '\1')
|
8
|
+
variables[key] || error("Cannot interpolate unknown environment variable '#{key}' in '#{file_name}'")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.error(message)
|
13
|
+
STDERR.puts("Error: #{message}")
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
4
17
|
end
|
@@ -1,30 +1,20 @@
|
|
1
|
+
require 'ci_config_generator'
|
2
|
+
|
1
3
|
namespace :ci do
|
2
4
|
namespace :config do
|
3
5
|
desc 'Generate config files from *.ci templates'
|
4
6
|
task :generate do
|
5
|
-
Dir.glob('
|
7
|
+
Dir.glob('**/{.,}*.ci') do |file_name|
|
6
8
|
target_file_name = file_name.gsub(/.ci$/, '')
|
7
9
|
|
8
10
|
if File.exist?(target_file_name)
|
9
11
|
error "#{target_file_name} already exists."
|
10
|
-
# STDERR.puts("Skipping #{target_file_name} - file exists")
|
11
12
|
else
|
12
13
|
STDERR.puts("Creating #{target_file_name} from #{file_name}")
|
13
|
-
File.write(target_file_name, interpolate(file_name, ENV))
|
14
|
+
File.write(target_file_name, CiConfigGenerator.interpolate(file_name, ENV))
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
def interpolate(file_name, variables)
|
19
|
-
File.read(file_name).gsub(/%{[^}]+}/) do |match|
|
20
|
-
key = match.gsub(/^%{([^}]+)}/, '\1')
|
21
|
-
variables[key] || error("Cannot interpolate unknown environment variable '#{key}' in '#{file_name}'")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def error(message)
|
26
|
-
STDERR.puts("Error: #{message}")
|
27
|
-
exit 1
|
28
|
-
end
|
29
19
|
end
|
30
20
|
end
|
data/spec/acceptance_spec.rb
CHANGED
@@ -11,6 +11,16 @@ describe 'rake ci:config:generate' do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
it 'creates files from template files ending with .ci' do
|
15
|
+
in_tmpdir do
|
16
|
+
File.write('.env.ci', 'FOO=bar')
|
17
|
+
|
18
|
+
rake 'ci:config:generate'
|
19
|
+
|
20
|
+
expect(File.read('.env')).to eq('FOO=bar')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
14
24
|
it 'interpolates environment variables' do
|
15
25
|
in_tmpdir do
|
16
26
|
File.write('database.yml.ci', 'db: "%{DB_NAME}"')
|
@@ -43,7 +53,7 @@ describe 'rake ci:config:generate' do
|
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
46
|
-
it 'does not touch files named exactly .ci'
|
56
|
+
it 'does not touch files named exactly .ci' do
|
47
57
|
in_tmpdir do
|
48
58
|
File.write('.ci', 'db: "ci"')
|
49
59
|
|
metadata
CHANGED
@@ -1,30 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_config_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Fischbach
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-11-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rspec
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
30
|
requirements:
|
19
|
-
- - ~>
|
31
|
+
- - "~>"
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '2.11'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
36
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
37
|
requirements:
|
27
|
-
- - ~>
|
38
|
+
- - "~>"
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '2.11'
|
30
41
|
description: Generate config files for continious integration.
|
@@ -34,8 +45,8 @@ executables: []
|
|
34
45
|
extensions: []
|
35
46
|
extra_rdoc_files: []
|
36
47
|
files:
|
37
|
-
- .gitignore
|
38
|
-
- .rspec
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
39
50
|
- Gemfile
|
40
51
|
- LICENSE
|
41
52
|
- README.md
|
@@ -48,27 +59,26 @@ files:
|
|
48
59
|
- spec/spec_helper.rb
|
49
60
|
homepage: http://github.com/codevise/ci_config_generator
|
50
61
|
licenses: []
|
62
|
+
metadata: {}
|
51
63
|
post_install_message:
|
52
64
|
rdoc_options: []
|
53
65
|
require_paths:
|
54
66
|
- lib
|
55
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
68
|
requirements:
|
58
|
-
- -
|
69
|
+
- - ">="
|
59
70
|
- !ruby/object:Gem::Version
|
60
71
|
version: '0'
|
61
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
73
|
requirements:
|
64
|
-
- -
|
74
|
+
- - ">="
|
65
75
|
- !ruby/object:Gem::Version
|
66
76
|
version: '0'
|
67
77
|
requirements: []
|
68
78
|
rubyforge_project:
|
69
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.7.5
|
70
80
|
signing_key:
|
71
|
-
specification_version:
|
81
|
+
specification_version: 4
|
72
82
|
summary: Generate config files for continious integration from templates inside the
|
73
83
|
repository.
|
74
84
|
test_files:
|