takelage 0.20.2 → 0.21.0

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: 2f755a130345b2343101f6ad38a711d11b8d15413506465534737b09ddd0459f
4
- data.tar.gz: 75fd7eb711147a14896a635751e0d544fc57e490b11546d90cb82ce1858aec43
3
+ metadata.gz: eb34019e556b714fcd893cf3141e23a1fbf63aad8bb695e2b205cfffb657a2ee
4
+ data.tar.gz: a0a2b8c6b6987f52057042ef410b2a94fb5628d519aa9f3c7ede9d4831d04a0d
5
5
  SHA512:
6
- metadata.gz: a8e3e1a324bfeade0a331f89de454de9909b8ad564d16849d56e5dc624dacf69d7c79c46547bee630f6fef9ad89f3275b5811203c93288dcdf5548c975e26ab7
7
- data.tar.gz: 5f4bcd4c8f6a688f78add975c78cfcb6995b0777ab73f38beae6f4f2760b70816a39fc9af56952c43c81ba691e9336a51745fe4ddb2745cafc999d084794cb38
6
+ metadata.gz: 0ef2f83567050eaf5578f793417ca4f65de20ce9d1409bef4503793a58b0ba0b8ad9fac6e889c19f33ebb3d20617519714a93e7db92b6e06283520281690ccab
7
+ data.tar.gz: ba45ccafbddeeda014a74eed0fcad687ad6d2287773cadb7d0aafde9854bc381d8003aea47965196f7faf5f7b3c8205daef0c03696eb0b0328d18838093f030f
data/README.md CHANGED
@@ -186,8 +186,11 @@ source <(tau completion bash)
186
186
 
187
187
  ### Software Tests
188
188
 
189
+ *takelage-cli* uses
190
+ [minitest](https://github.com/seattlerb/minitest) unit tests.
191
+
189
192
  *takelage-cli* ships with
190
- [cucumber](https://github.com/cucumber/cucumber) ruby tests.
193
+ [cucumber](https://github.com/cucumber/cucumber) ruby system tests.
191
194
  It uses cucumber's
192
195
  [aruba](https://github.com/cucumber/aruba) extension and especially its
193
196
  [filesystem](https://relishapp.com/cucumber/aruba/v/0-11-0/docs/filesystem)
@@ -93,9 +93,7 @@ module ConfigModule
93
93
 
94
94
  return {} unless File.exist? home_file
95
95
 
96
- home_yaml = read_yaml_file(home_file) || {}
97
-
98
- home_yaml.sort.to_h
96
+ (read_yaml_file(home_file) || {}).sort.to_h
99
97
  end
100
98
 
101
99
  # Read custom config file in project root.
@@ -104,9 +102,7 @@ module ConfigModule
104
102
 
105
103
  return {} unless File.exist? project_file
106
104
 
107
- project_yaml = read_yaml_file(project_file) || {}
108
-
109
- project_yaml.sort.to_h
105
+ (read_yaml_file(project_file) || {}).sort.to_h
110
106
  end
111
107
 
112
108
  # Merge active config.
@@ -34,24 +34,24 @@ module ProjectModule
34
34
 
35
35
  # Read main YAML file.
36
36
  def _project_read_main
37
- @path = TakelageProject.instance.config.active['project_root_dir']
38
- main_file = "#{@path}/" \
37
+ path = TakelageProject.instance.config.active['project_root_dir']
38
+ main_file = "#{path}/" \
39
39
  "#{TakelageProject.instance.config.active['info_project_main']}"
40
40
 
41
41
  return {} unless File.exist? main_file
42
42
 
43
- read_yaml_file(main_file).sort.to_h || {}
43
+ (read_yaml_erb_file(main_file) || {}).sort.to_h
44
44
  end
45
45
 
46
46
  # Read private YAML file.
47
47
  def _project_read_private
48
- @path = TakelageProject.instance.config.active['project_root_dir']
49
- private_file = "#{@path}/" \
48
+ path = TakelageProject.instance.config.active['project_root_dir']
49
+ private_file = "#{path}/" \
50
50
  "#{TakelageProject.instance.config.active['info_project_private']}"
51
51
 
52
52
  return {} unless File.exist? private_file
53
53
 
54
- private_yaml = read_yaml_file(private_file) || {}
54
+ private_yaml = read_yaml_erb_file(private_file) || {}
55
55
 
56
56
  private_yaml.sort.to_h
57
57
  end
@@ -20,7 +20,19 @@ module SystemModule
20
20
  log.debug "Reading YAML file \"#{file}\""
21
21
  return nil unless _file_exists? file
22
22
  return nil unless _file_read file
23
- return nil unless _parse_yaml @content_yaml
23
+ return nil unless _parse_yaml file, @content_file
24
+
25
+ @content
26
+ end
27
+
28
+ # Read yaml file with erb templates.
29
+ # @return [Hash] content of yaml file
30
+ def read_yaml_erb_file(file)
31
+ log.debug "Reading YAML ERB file \"#{file}\""
32
+ return nil unless _file_exists? file
33
+ return nil unless _file_read file
34
+ return nil unless _parse_erb file, @content_file
35
+ return nil unless _parse_yaml file, @content_yaml
24
36
 
25
37
  @content
26
38
  end
@@ -82,7 +94,7 @@ module SystemModule
82
94
  # Read yaml file.
83
95
  def _file_read(file)
84
96
  begin
85
- @content_yaml = File.read file
97
+ @content_file = File.read file
86
98
  rescue SystemCallError
87
99
  log.debug "Unable to read file \"#{file}\""
88
100
  return false
@@ -90,8 +102,21 @@ module SystemModule
90
102
  true
91
103
  end
92
104
 
105
+ # Parse erb file.
106
+ def _parse_erb(file, content_erb)
107
+ begin
108
+ @content_yaml = ERB.new(content_erb).result
109
+ rescue StandardError => e
110
+ log.debug e.class
111
+ log.debug "Invalid ERB in YAML file \"#{file}\". " \
112
+ "#{e.class}: \"#{e.message}\""
113
+ return false
114
+ end
115
+ true
116
+ end
117
+
93
118
  # Parse yaml file.
94
- def _parse_yaml(content_yaml)
119
+ def _parse_yaml(file, content_yaml)
95
120
  begin
96
121
  @content = YAML.safe_load content_yaml
97
122
  rescue Psych::SyntaxError
@@ -4,6 +4,13 @@
4
4
  module SelfList
5
5
  # Backend method for config self.
6
6
  def self_list
7
+ _manipulate_output_(_get_thor_list_)
8
+ end
9
+
10
+ private
11
+
12
+ # Get output of thor list command.
13
+ def _get_thor_list_
7
14
  # use Thorfile which requires relative takelage.rb
8
15
  thorfile_dir = "#{File.dirname(__FILE__)}/../"
9
16
 
@@ -12,20 +19,17 @@ module SelfList
12
19
  "cd #{thorfile_dir} && " \
13
20
  'thor list' \
14
21
  "'"
15
- thor_list = `#{cmd_thor_list}`
16
22
 
17
- # manipulate thor list output
18
- _manipulate_output_(thor_list)
23
+ # call thor list command
24
+ `#{cmd_thor_list}`
19
25
  end
20
26
 
21
- private
22
-
23
27
  # Manipulate output of thor list command.
24
28
  def _manipulate_output_(thor_list)
25
- thor_list.gsub!("takelage\n", '')
26
- thor_list.gsub!("------\n", '')
27
- thor_list.gsub!('thor ', 'tau ')
28
- thor_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
29
- thor_list.gsub!(/.*COMMAND.*\n/, '')
29
+ tau_list = thor_list.gsub("takelage\n", '')
30
+ tau_list.gsub!("------\n", '')
31
+ tau_list.gsub!('thor ', 'tau ')
32
+ tau_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
33
+ tau_list.gsub!(/.*COMMAND.*\n/, '')
30
34
  end
31
35
  end
@@ -1 +1 @@
1
- 0.20.2
1
+ 0.21.0
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.20.2
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin