nli_pipeline 0.0.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 +7 -0
- data/bin/setup_pipeline +14 -0
- data/lib/nli_pipeline.rb +48 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01614a3ab29fb84f8c2f15d17f93ffb1c29ed55a
|
4
|
+
data.tar.gz: 0cf4ad87b1a541b88a18b57ae5e30d1951d9d1d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f11c2ff157f1429f72f47a2b8a0ee78174ce408bd471f3a62dbceddeffd15c55ffc33d27df202f0e3162c5f4934d54836ba750da97a91ecf2106b0ff22c53a2
|
7
|
+
data.tar.gz: edc571570dc7d250bd1b272870a004ff26904c4b9bd2d2a27cafe6ec6d323b492a25bbb5e167e2b0ba5dc7615e6ea445472b3dde6d097d212b8165c9f6d5365f
|
data/bin/setup_pipeline
ADDED
data/lib/nli_pipeline.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
class FileManager
|
2
|
+
attr_accessor :backup
|
3
|
+
attr_accessor :extension
|
4
|
+
|
5
|
+
def initialize(backup=true, extension="\.EXAMPLE")
|
6
|
+
@backup = backup
|
7
|
+
@extension = extension
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_latest_backup_number(backup_files)
|
11
|
+
backup_dates = backup_files.map {|x| x.split(".backup").last.to_i}
|
12
|
+
return "#{backup_dates.max}"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def copy_example_files(path, command="cp")
|
17
|
+
example_file_path = "#{path}/**/*.EXAMPLE"
|
18
|
+
example_files = Dir.glob(example_file_path)
|
19
|
+
if example_files.empty?
|
20
|
+
raise "No Example Files found at #{example_file_path}"
|
21
|
+
else
|
22
|
+
puts("Moving #{example_files.count} example files")
|
23
|
+
end
|
24
|
+
|
25
|
+
example_files.each do |example_file|
|
26
|
+
target_file = example_file.gsub("\.EXAMPLE", "")
|
27
|
+
# backup configuration if it already exists
|
28
|
+
if File.exists?(target_file)
|
29
|
+
puts("backing up #{target_file}")
|
30
|
+
system("#{command} #{target_file} #{target_file}.backup#{Time.now.strftime("%Y%m%d%H%M")}")
|
31
|
+
end
|
32
|
+
# convert the example file to real config
|
33
|
+
system("#{command} #{example_file} #{target_file}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# to remove backup, use mv
|
39
|
+
# to keep backup, use cp
|
40
|
+
def undo_latest_copy_example_files(path, command="cp")
|
41
|
+
latest_backup_date = get_latest_backup_number(Dir.glob("./**/*.backup*"))
|
42
|
+
Dir.glob("#{path}/**/*.backup#{latest_backup_date}").each do |backup_file|
|
43
|
+
target_file = backup_file.gsub("\.backup#{latest_backup_date}", "")
|
44
|
+
system("#{command} #{backup_file} #{target_file}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nli_pipeline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Conor Sheehan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem for manging .EXAMPLE files
|
14
|
+
email: csheehan@nli.ie
|
15
|
+
executables:
|
16
|
+
- setup_pipeline
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/setup_pipeline
|
21
|
+
- lib/nli_pipeline.rb
|
22
|
+
homepage:
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Pipeline manager for NLireland
|
46
|
+
test_files: []
|