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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63e3f97142ec8fbf49c1b753986ca84d80a5e9fc8069d9168b0f927bc22a3e2d
4
- data.tar.gz: 41ee3b0215e955d565a10293d3fecd8c14aaf704f6403c5757051cd10c79d06a
3
+ metadata.gz: 337297c4c2bddafbc782a8a1241b70b276959717258d8d7d6a365c4df2523a38
4
+ data.tar.gz: f17a44b356298c310ea70b07b2ed689bb191cbbe87595a469e5519e7fb8ba360
5
5
  SHA512:
6
- metadata.gz: 5d4c7d1c8041ea86afb80d64c1db124ebae6c5d067afef21d8d9ed9f4a2c42176047df7014c152cd3123b1c28570d59ccd2d371180ef5683513422081305a7c9
7
- data.tar.gz: f6abded50f6115a53c9da2e16bfd5a59e3450fa99e9ae57538011d69fa4bd9284b1454e2783bd2f923a22a4de087ffc0220dd3951099d0125a61aa41594ddac5
6
+ metadata.gz: 15b06d0393821300f660ce4ef12337d1431207db7d47c7a3ea466d0794554adf32b37f1d478e7b4d363c9a9ee11adcb567b4fa311661e20242f5e3a8201374be
7
+ data.tar.gz: baf0b65c9a25f5c1e16bb6d00f149921c95cfee379eb641d6a637b46c2784fa7e8cd36d8194d09edc18d8b73b41f2e2939d0eed207c4b6d5868424caeb25da51
@@ -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) || Hash.new
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) || Hash.new
36
+ @@project.private = read_yaml_file(private_file) || {}
40
37
  @@project.private = @@project.private.sort.to_h
41
38
  end
42
39
 
@@ -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, namespace = nil, subcommand = false)
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
- self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| " #{match[0].downcase}" }
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
@@ -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
- return nil.to_yaml
13
- end
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 existenc
22
- unless File.exists? 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 = File.read file
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.load 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, realtime=false)
58
+ def run(command)
60
59
  log.debug "Running command \"#{command}\""
61
- stdout_str, stderr_str, status = Open3.capture3 command
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
- stdout_str, stderr_str, status = Open3.capture3 command
84
+ _, _, status = Open3.capture3 command
86
85
  log.debug "Command \"#{command}\" has exit status \"#{status.exitstatus}\""
87
86
  status
88
87
  end
@@ -1,11 +1,9 @@
1
1
  module Takelage
2
-
3
2
  # semantic version number
4
3
  VERSION = (File.read "#{File.dirname(__FILE__)}/../version").chomp
5
4
 
6
5
  # takelage self
7
6
  class Self < SubCommandBase
8
-
9
7
  include LoggingModule
10
8
  include SelfModule
11
9
 
@@ -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.
@@ -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
- "thor list" +
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.gsub! "takelage\n", ''
19
- thor_list.gsub! "------\n", ''
20
- thor_list.gsub! 'thor ', 'tau '
21
- thor_list.gsub! /(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3'
22
- thor_list.gsub! /.*COMMAND.*\n/, ''
16
+ _manipulate_output_(thor_list)
17
+ end
18
+
19
+ private
23
20
 
24
- thor_list
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
1
+ 0.13.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takelage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin