takelage 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takelage/lib/project.rb +3 -6
- data/lib/takelage/lib/subcmd.rb +4 -3
- data/lib/takelage/lib/system.rb +14 -15
- data/lib/takelage/self/cli.rb +0 -2
- data/lib/takelage/self/config/cli.rb +3 -5
- data/lib/takelage/self/module.rb +13 -11
- data/lib/takelage/version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 337297c4c2bddafbc782a8a1241b70b276959717258d8d7d6a365c4df2523a38
|
4
|
+
data.tar.gz: f17a44b356298c310ea70b07b2ed689bb191cbbe87595a469e5519e7fb8ba360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b06d0393821300f660ce4ef12337d1431207db7d47c7a3ea466d0794554adf32b37f1d478e7b4d363c9a9ee11adcb567b4fa311661e20242f5e3a8201374be
|
7
|
+
data.tar.gz: baf0b65c9a25f5c1e16bb6d00f149921c95cfee379eb641d6a637b46c2784fa7e8cd36d8194d09edc18d8b73b41f2e2939d0eed207c4b6d5868424caeb25da51
|
data/lib/takelage/lib/project.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# takelage project module
|
2
2
|
module ProjectModule
|
3
|
-
|
4
3
|
# takelage config class.
|
5
4
|
class TakelageProject
|
6
|
-
|
7
5
|
include LoggingModule
|
8
6
|
include SystemModule
|
9
7
|
include ConfigModule
|
@@ -22,21 +20,20 @@ module ProjectModule
|
|
22
20
|
|
23
21
|
# Initialze project
|
24
22
|
def initialize_project
|
25
|
-
|
26
|
-
rakefile, path = Rake.application.find_rakefile_location
|
23
|
+
_rakefile, path = Rake.application.find_rakefile_location
|
27
24
|
|
28
25
|
main_file = "#{path}/#{@@project.config.active['info_project_main']}"
|
29
26
|
private_file = "#{path}/#{@@project.config.active['info_project_private']}"
|
30
27
|
|
31
28
|
# read main project info
|
32
29
|
if File.exist? main_file
|
33
|
-
@@project.main = read_yaml_file(main_file) ||
|
30
|
+
@@project.main = read_yaml_file(main_file) || {}
|
34
31
|
@@project.main = @@project.main.sort.to_h
|
35
32
|
end
|
36
33
|
|
37
34
|
# read private project info
|
38
35
|
if File.exist? private_file
|
39
|
-
@@project.private = read_yaml_file(private_file) ||
|
36
|
+
@@project.private = read_yaml_file(private_file) || {}
|
40
37
|
@@project.private = @@project.private.sort.to_h
|
41
38
|
end
|
42
39
|
|
data/lib/takelage/lib/subcmd.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# Thor with subcommands that work correctly with help
|
2
2
|
class SubCommandBase < Thor
|
3
|
-
|
4
3
|
# Set the subcommand banner
|
5
|
-
def self.banner(command,
|
4
|
+
def self.banner(command, _namespace = nil, _subcommand = false)
|
6
5
|
"#{basename} #{subcommand_prefix} #{command.usage}"
|
7
6
|
end
|
8
7
|
|
9
8
|
# Set the subcommand prefix
|
10
9
|
def self.subcommand_prefix
|
11
|
-
|
10
|
+
name.gsub(/.*::/, '')
|
11
|
+
.gsub(/^[A-Z]/) { |match| match[0].downcase }
|
12
|
+
.gsub(/[A-Z]/) { |match| " #{match[0].downcase}" }
|
12
13
|
end
|
13
14
|
end
|
data/lib/takelage/lib/system.rb
CHANGED
@@ -2,40 +2,38 @@ require 'pathname'
|
|
2
2
|
require 'open3'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
|
6
5
|
# Interaction with the operating system
|
7
6
|
module SystemModule
|
8
|
-
|
9
7
|
# Print hash as yaml.
|
10
8
|
def hash_to_yaml(hash)
|
11
|
-
if hash == {}
|
12
|
-
|
13
|
-
|
14
|
-
hash.to_yaml(options = {:line_width => -1})
|
9
|
+
return nil.to_yaml if hash == {}
|
10
|
+
|
11
|
+
hash.to_yaml({ line_width: -1 })
|
15
12
|
end
|
16
13
|
|
17
14
|
# @return [Hash] content of yaml file
|
15
|
+
# rubocop:disable Metrics/MethodLength
|
18
16
|
def read_yaml_file(file)
|
19
17
|
log.debug "Reading YAML file \"#{file}\""
|
20
18
|
|
21
|
-
# Check file
|
22
|
-
unless File.
|
19
|
+
# Check file existence
|
20
|
+
unless File.exist? file
|
23
21
|
log.debug "File \"#{file}\" doesn't exist"
|
24
22
|
return nil
|
25
23
|
end
|
26
24
|
|
27
25
|
# Read file
|
28
26
|
begin
|
29
|
-
content_yaml =
|
30
|
-
rescue
|
27
|
+
content_yaml = File.read file
|
28
|
+
rescue SystemCallError
|
31
29
|
log.debug "Unable to read file \"#{file}\""
|
32
30
|
return nil
|
33
31
|
end
|
34
32
|
|
35
33
|
# Parse YAML
|
36
34
|
begin
|
37
|
-
content = YAML.
|
38
|
-
rescue
|
35
|
+
content = YAML.safe_load content_yaml
|
36
|
+
rescue Psych::SyntaxError
|
39
37
|
log.debug "Invalid YAML file \"#{file}\""
|
40
38
|
log.debug "Try: yamllint #{file}"
|
41
39
|
return nil
|
@@ -43,6 +41,7 @@ module SystemModule
|
|
43
41
|
|
44
42
|
content
|
45
43
|
end
|
44
|
+
# rubocop:enable Metrics/MethodLength
|
46
45
|
|
47
46
|
# Remove directory tree.
|
48
47
|
def rm_fr(directory)
|
@@ -56,9 +55,9 @@ module SystemModule
|
|
56
55
|
|
57
56
|
# Run a command and return the standard output.
|
58
57
|
# @return [String] stdout of command
|
59
|
-
def run(command
|
58
|
+
def run(command)
|
60
59
|
log.debug "Running command \"#{command}\""
|
61
|
-
stdout_str,
|
60
|
+
stdout_str, = Open3.capture3 command
|
62
61
|
log.debug "Command \"#{command}\" has stdout:\n\"\"\"\n#{stdout_str}\"\"\""
|
63
62
|
stdout_str
|
64
63
|
end
|
@@ -82,7 +81,7 @@ module SystemModule
|
|
82
81
|
# @return [Boolean] success of command run
|
83
82
|
def try(command)
|
84
83
|
log.debug "Running command \"#{command}\""
|
85
|
-
|
84
|
+
_, _, status = Open3.capture3 command
|
86
85
|
log.debug "Command \"#{command}\" has exit status \"#{status.exitstatus}\""
|
87
86
|
status
|
88
87
|
end
|
data/lib/takelage/self/cli.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Takelage
|
2
|
-
|
3
2
|
# takelage bit
|
4
3
|
class SelfConfig < SubCommandBase
|
5
|
-
|
6
4
|
include LoggingModule
|
7
5
|
include SystemModule
|
8
6
|
include ConfigModule
|
@@ -34,7 +32,7 @@ module Takelage
|
|
34
32
|
desc 'home', 'Print takelage home config file configuration'
|
35
33
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
36
34
|
Print takelage home config file configuration
|
37
|
-
This command will print the configuration read from the takelage
|
35
|
+
This command will print the configuration read from the takelage
|
38
36
|
configuration file in your home directory ~/.takelage.yml).
|
39
37
|
LONGDESC
|
40
38
|
# Print takelage home config file configuration.
|
@@ -51,7 +49,7 @@ module Takelage
|
|
51
49
|
desc 'project', 'Print takelage project config file configuration'
|
52
50
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
53
51
|
Print takelage project config file configuration
|
54
|
-
This command will print the configuration read from the takelage
|
52
|
+
This command will print the configuration read from the takelage
|
55
53
|
configuration file .takelage.yml in your home directory).
|
56
54
|
LONGDESC
|
57
55
|
# Print takelage home config file configuration.
|
@@ -68,7 +66,7 @@ module Takelage
|
|
68
66
|
desc 'active', 'Print active takelage configuration'
|
69
67
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
70
68
|
Print active takelage configuration
|
71
|
-
This command will print the configuration read from the takelage
|
69
|
+
This command will print the configuration read from the takelage
|
72
70
|
configuration file (which is by default ~/.takelage.yml).
|
73
71
|
LONGDESC
|
74
72
|
# Print active takelage configuration.
|
data/lib/takelage/self/module.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
# takelage self
|
2
2
|
module SelfModule
|
3
|
-
|
4
3
|
# Backend method for config self.
|
5
4
|
def self_list
|
6
|
-
|
7
5
|
# use Thorfile which requires relative takelage.rb
|
8
6
|
thorfile_dir = "#{File.dirname(__FILE__)}/../"
|
9
7
|
|
10
8
|
# use thor list to get the list of commands and subcommands
|
11
|
-
cmd_thor_list = "bash -c '"
|
12
|
-
"cd #{thorfile_dir} && "
|
13
|
-
|
9
|
+
cmd_thor_list = "bash -c '" \
|
10
|
+
"cd #{thorfile_dir} && " \
|
11
|
+
'thor list' \
|
14
12
|
"'"
|
15
13
|
thor_list = `#{cmd_thor_list}`
|
16
14
|
|
17
15
|
# manipulate thor list output
|
18
|
-
thor_list
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
thor_list.gsub! /.*COMMAND.*\n/, ''
|
16
|
+
_manipulate_output_(thor_list)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
23
20
|
|
24
|
-
|
21
|
+
def _manipulate_output_(thor_list)
|
22
|
+
thor_list.gsub!("takelage\n", '')
|
23
|
+
thor_list.gsub!("------\n", '')
|
24
|
+
thor_list.gsub!('thor ', 'tau ')
|
25
|
+
thor_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
|
26
|
+
thor_list.gsub!(/.*COMMAND.*\n/, '')
|
25
27
|
end
|
26
28
|
end
|
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.13.
|
1
|
+
0.13.2
|