takelage 0.20.0 → 0.22.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 +4 -4
- data/README.md +64 -61
- data/lib/takelage/bit/clipboard/copy.rb +2 -0
- data/lib/takelage/bit/clipboard/lib.rb +9 -1
- data/lib/takelage/bit/clipboard/paste.rb +2 -0
- data/lib/takelage/bit/clipboard/pull.rb +3 -3
- data/lib/takelage/bit/clipboard/push.rb +3 -3
- data/lib/takelage/bit/require/export.rb +3 -1
- data/lib/takelage/bit/require/import.rb +5 -1
- data/lib/takelage/default.yml +1 -0
- data/lib/takelage/lib/config.rb +29 -15
- data/lib/takelage/lib/project.rb +6 -6
- data/lib/takelage/lib/system.rb +28 -3
- data/lib/takelage/self/list.rb +14 -10
- 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: bd37119ed7278082e62916cfc9c14086b719007ab746e58651647a95779ae96c
|
4
|
+
data.tar.gz: fe3fc46ef24bdb12a106f02c9c18c8ceddf3faa4683fa67bf805aea31aaef01a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dfaf046db1564a22555132cb6fea9974f397a86ea9a660877c2bcfc3fdccfa2f59e86a6bc0be7b42831254cdbeb7c1997b67a227488d1dd18e22a1386ed870b
|
7
|
+
data.tar.gz: 1598f3a2a4890118bb6a2b72e1c6a2be5e89391f6f20248ed5f0293479ce79e57c29203f4c60541acd66346353943235e575d9bac6637360f91848aa746dde30
|
data/README.md
CHANGED
@@ -42,68 +42,68 @@ You are encouraged to read the cucumber feature files
|
|
42
42
|
for the *tau* commands
|
43
43
|
to get an idea of how the commands work.
|
44
44
|
You can list the *tau* commands by running
|
45
|
-
*tau [self list](features/
|
45
|
+
*tau [self list](features/cucumber/features/self/self.list.feature)*
|
46
46
|
or *tau list*:
|
47
47
|
|
48
48
|
Command | Description
|
49
49
|
------- | -----------
|
50
|
-
tau [bit check workspace](features/
|
51
|
-
tau [bit clipboard copy](features/
|
52
|
-
tau [bit clipboard paste](features/
|
53
|
-
tau [bit clipboard pull](features/
|
54
|
-
tau [bit clipboard push](features/
|
55
|
-
tau [bit require export](features/
|
56
|
-
tau [bit require import](features/
|
57
|
-
tau [bit scope add](features/
|
58
|
-
tau [bit scope inbit](features/
|
59
|
-
tau [bit scope list](features/
|
60
|
-
tau [bit scope new](features/
|
61
|
-
tau [completion bash](features/
|
62
|
-
tau [docker check running](features/
|
63
|
-
tau [docker container check existing](features/
|
64
|
-
tau [docker container check network](features/
|
65
|
-
tau [docker container check orphaned](features/
|
66
|
-
tau [docker container command](features/
|
67
|
-
tau [docker container daemon](features/
|
68
|
-
tau [docker container login](features/
|
69
|
-
tau [docker container clean](features/
|
70
|
-
tau [docker container prune](features/
|
71
|
-
tau [docker image check outdated](features/
|
72
|
-
tau [docker image tag check local](features/
|
73
|
-
tau [docker image tag check remote](features/
|
74
|
-
tau [docker image tag latest local](features/
|
75
|
-
tau [docker image tag latest remote](features/
|
76
|
-
tau [docker image tag list local](features/
|
77
|
-
tau [docker image tag list remote](features/
|
78
|
-
tau [docker image update](features/
|
79
|
-
tau [docker socket host](features/
|
80
|
-
tau [docker socket scheme](features/
|
81
|
-
tau [docker socket start](features/
|
82
|
-
tau [docker socket stop](features/
|
83
|
-
tau [git check clean](features/
|
84
|
-
tau [git check master](features/
|
85
|
-
tau [git check workspace](features/
|
86
|
-
tau [info project active](features/
|
87
|
-
tau [info project main](features/
|
88
|
-
tau [info project private](features/
|
89
|
-
tau [self config active](features/
|
90
|
-
tau [self config default](features/
|
91
|
-
tau [self config home](features/
|
92
|
-
tau [self config project](features/
|
93
|
-
tau [self list](features/
|
94
|
-
tau [self version](features/
|
95
|
-
tau config | Alias for tau [self config active](features/
|
96
|
-
tau copy [DIR] [SCOPE] | Alias for tau [bit clipboard copy](features/
|
97
|
-
tau list | Alias for tau [self list](features/
|
98
|
-
tau login | Alias for tau [docker container login](features/
|
99
|
-
tau clean | Alias for tau [docker container clean](features/
|
100
|
-
tau paste [COMPONENT] [DIR] | Alias for tau [bit clipboard paste](features/
|
101
|
-
tau project | Alias for tau [info project active](features/
|
102
|
-
tau pull | Alias for tau [bit clipboard pull](features/
|
103
|
-
tau prune | Alias for tau [docker container prune](features/
|
104
|
-
tau push | Alias for tau [bit clipboard push](features/
|
105
|
-
tau update | Alias for tau [docker image update](features/
|
106
|
-
tau version | Alias for tau [self version](features/
|
50
|
+
tau [bit check workspace](features/cucumber/features/bit/bit.check.workspace.feature) | Check if a bit workspace exists
|
51
|
+
tau [bit clipboard copy](features/cucumber/features/bit/bit.clipboard.copy.feature) [DIR] [SCOPE] | Copy new [DIR] to [SCOPE]
|
52
|
+
tau [bit clipboard paste](features/cucumber/features/bit/bit.clipboard.paste.feature) [COMPONENT] [DIR] | Paste bit [COMPONENT] into [DIR]
|
53
|
+
tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature) | Pull all updates for bit components from bit remote scopes
|
54
|
+
tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature) | Push all updates of bit components to bit remote scopes
|
55
|
+
tau [bit require export](features/cucumber/features/bit/bit.require.export.feature) | Show requirements file of bit components
|
56
|
+
tau [bit require import](features/cucumber/features/bit/bit.require.import.feature) | Import bit components from requirements file
|
57
|
+
tau [bit scope add](features/cucumber/features/bit/bit.scope.add.feature) [SCOPE] | Add a bit [SCOPE]
|
58
|
+
tau [bit scope inbit](features/cucumber/features/bit/bit.scope.inbit.feature) | Log in to bit remote server
|
59
|
+
tau [bit scope list](features/cucumber/features/bit/bit.scope.list.feature) | List bit remote scopes
|
60
|
+
tau [bit scope new](features/cucumber/features/bit/bit.scope.new.feature) [SCOPE] | Init a new bit [SCOPE]
|
61
|
+
tau [completion bash](features/cucumber/features/completion/completion.bash.feature) | Print bash completion code
|
62
|
+
tau [docker check running](features/cucumber/features/docker/docker.check.running.feature) | Check if docker daemon is running
|
63
|
+
tau [docker container check existing](features/cucumber/features/docker/docker.container.check.existing.feature) [CONTAINER] | Check if docker [CONTAINER] is existing
|
64
|
+
tau [docker container check network](features/cucumber/features/docker/docker.container.check.network.feature) [NETWORK] | Check if docker [NETWORK] is existing
|
65
|
+
tau [docker container check orphaned](features/cucumber/features/docker/docker.container.check.orphaned.feature) [CONTAINER] | Check if docker [CONTAINER] is orphaned
|
66
|
+
tau [docker container command](features/cucumber/features/docker/docker.container.command.feature) [CMD] | Run [CMD] in a docker container
|
67
|
+
tau [docker container daemon](features/cucumber/features/docker/docker.container.daemon.feature) | Run docker container in daemon mode
|
68
|
+
tau [docker container login](features/cucumber/features/docker/docker.container.login.feature) | Log in to latest local docker container
|
69
|
+
tau [docker container clean](features/cucumber/features/docker/docker.container.clean.feature) | Remove all docker containers
|
70
|
+
tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature) | Remove orphaned docker containers
|
71
|
+
tau [docker image check outdated](features/cucumber/features/docker/docker.image.check.outdated.feature) | Check if a docker image is outdated
|
72
|
+
tau [docker image tag check local](features/cucumber/features/docker/docker.image.tag.check.local.feature) [TAG] | Check if local docker image [TAG] exists
|
73
|
+
tau [docker image tag check remote](features/cucumber/features/docker/docker.image.tag.check.remote.feature) [TAG] | Check if remote docker image [TAG] exists
|
74
|
+
tau [docker image tag latest local](features/cucumber/features/docker/docker.image.tag.latest.local.feature) | Print latest local docker image tag
|
75
|
+
tau [docker image tag latest remote](features/cucumber/features/docker/docker.image.tag.latest.remote.feature) | Print latest remote docker image tag
|
76
|
+
tau [docker image tag list local](features/cucumber/features/docker/docker.image.tag.list.local.feature) | Print local docker image tags
|
77
|
+
tau [docker image tag list remote](features/cucumber/features/docker/docker.image.tag.list.remote.feature) | Print remote docker image tags
|
78
|
+
tau [docker image update](features/cucumber/features/docker/docker.image.update.feature) | Get latest remote docker container
|
79
|
+
tau [docker socket host](features/cucumber/features/docker/docker.socket.host.feature) | Print docker socket host ip address
|
80
|
+
tau [docker socket scheme](features/cucumber/features/docker/docker.socket.scheme.feature) | Print docker socket scheme
|
81
|
+
tau [docker socket start](features/cucumber/features/docker/docker.socket.start.feature) | Start sockets for docker container
|
82
|
+
tau [docker socket stop](features/cucumber/features/docker/docker.socket.stop.feature) | Stop sockets for docker container
|
83
|
+
tau [git check clean](features/cucumber/features/git/git.check.clean.feature) | Check if the git workspace is clean
|
84
|
+
tau [git check master](features/cucumber/features/git/git.check.master.feature) | Check if we are on the git master branch
|
85
|
+
tau [git check workspace](features/cucumber/features/git/git.check.workspace.feature) | Check if a git workspace exists
|
86
|
+
tau [info project active](features/cucumber/features/info/info.project.active.feature) | Print active project info
|
87
|
+
tau [info project main](features/cucumber/features/info/info.project.main.feature) | Print main project info
|
88
|
+
tau [info project private](features/cucumber/features/info/info.project.private.feature) | Print private project info
|
89
|
+
tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
|
90
|
+
tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
|
91
|
+
tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
|
92
|
+
tau [self config project](features/cucumber/features/self/self.config.project.feature) | Print takelage project config file configuration
|
93
|
+
tau [self list](features/cucumber/features/self/self.list.feature) | List all commands
|
94
|
+
tau [self version](features/cucumber/features/self/self.version.feature) | Print tau semantic version number
|
95
|
+
tau config | Alias for tau [self config active](features/cucumber/features/self/self.config.active.feature)
|
96
|
+
tau copy [DIR] [SCOPE] | Alias for tau [bit clipboard copy](features/cucumber/features/bit/bit.clipboard.copy.feature)
|
97
|
+
tau list | Alias for tau [self list](features/cucumber/features/self/self.list.feature)
|
98
|
+
tau login | Alias for tau [docker container login](features/cucumber/features/docker/docker.container.login.feature)
|
99
|
+
tau clean | Alias for tau [docker container clean](features/cucumber/features/docker/docker.container.clean.feature)
|
100
|
+
tau paste [COMPONENT] [DIR] | Alias for tau [bit clipboard paste](features/cucumber/features/bit/bit.clipboard.paste.feature)
|
101
|
+
tau project | Alias for tau [info project active](features/cucumber/features/info/info.project.active.feature)
|
102
|
+
tau pull | Alias for tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature)
|
103
|
+
tau prune | Alias for tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature)
|
104
|
+
tau push | Alias for tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature)
|
105
|
+
tau update | Alias for tau [docker image update](features/cucumber/features/docker/docker.image.update.feature)
|
106
|
+
tau version | Alias for tau [self version](features/cucumber/features/self/self.version.feature)
|
107
107
|
|
108
108
|
**Warning: *tau update* will call *docker image prune* and remove all dangling images!**
|
109
109
|
|
@@ -115,7 +115,7 @@ tau version | Alias for tau [self version](features/takelage/self/self.version.f
|
|
115
115
|
which have different precedences.
|
116
116
|
They are merged to an active configuration during runtime
|
117
117
|
which can be inspected with
|
118
|
-
*tau [self config active](features/
|
118
|
+
*tau [self config active](features/cucumber/features/self/self.config.active.feature)*
|
119
119
|
or *tau config*.
|
120
120
|
|
121
121
|
| Filename | Precedence | Description |
|
@@ -168,7 +168,7 @@ Furthermore, every external command can be reconfigured.
|
|
168
168
|
which have different precedences.
|
169
169
|
They are merged to an active configuration during runtime
|
170
170
|
which can be inspected with
|
171
|
-
*tau [info project active](features/
|
171
|
+
*tau [info project active](features/cucumber/features/info/info.project.active.feature)*
|
172
172
|
or *tau project*.
|
173
173
|
|
174
174
|
| Default filename | Config key | Precedence | Description |
|
@@ -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)
|
@@ -4,6 +4,14 @@
|
|
4
4
|
module BitClipboardLib
|
5
5
|
private
|
6
6
|
|
7
|
+
# Run bit status.
|
8
|
+
def _bit_clipboard_lib_bit_status
|
9
|
+
log.debug 'Running bit status'
|
10
|
+
|
11
|
+
cmd_bit_status = config.active['cmd_bit_clipboard_lib_bit_status']
|
12
|
+
run_and_exit cmd_bit_status
|
13
|
+
end
|
14
|
+
|
7
15
|
# Prepare workspace for bit clipboard.
|
8
16
|
def _bit_clipboard_lib_prepare_workspace
|
9
17
|
unless bit_check_workspace
|
@@ -51,7 +59,7 @@ module BitClipboardLib
|
|
51
59
|
def _bit_clipboard_lib_sync_workspace
|
52
60
|
log.debug 'Syncing git workspace'
|
53
61
|
|
54
|
-
|
62
|
+
path = config.active['project_root_dir']
|
55
63
|
file = "#{path}/.bitmap"
|
56
64
|
message = 'Update .bitmap'
|
57
65
|
|
@@ -6,6 +6,8 @@ module BitClipboardPaste
|
|
6
6
|
def bit_clipboard_paste(cid, dir)
|
7
7
|
log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
|
8
8
|
|
9
|
+
return false unless configured? %w[project_root_dir]
|
10
|
+
|
9
11
|
return false unless _bit_clipboard_lib_prepare_workspace
|
10
12
|
|
11
13
|
return false unless _bit_clipboard_paste_cid_exists? cid
|
@@ -6,15 +6,15 @@ module BitClipboardPull
|
|
6
6
|
def bit_clipboard_pull
|
7
7
|
log.debug 'Running bit pull'
|
8
8
|
|
9
|
+
return false unless configured? %w[project_root_dir]
|
10
|
+
|
9
11
|
return false unless _bit_clipboard_lib_prepare_workspace
|
10
12
|
|
11
13
|
_bit_clipboard_pull_import_all
|
12
14
|
_bit_clipboard_pull_checkout_all
|
13
15
|
_bit_clipbpard_lib_remove_bit_artifacts
|
14
16
|
_bit_clipboard_lib_sync_workspace
|
15
|
-
|
16
|
-
log.info 'Pulled bit components'
|
17
|
-
true
|
17
|
+
_bit_clipboard_lib_bit_status
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -6,15 +6,15 @@ module BitClipboardPush
|
|
6
6
|
def bit_clipboard_push
|
7
7
|
log.debug 'Running bit push'
|
8
8
|
|
9
|
+
return false unless configured? %w[project_root_dir]
|
10
|
+
|
9
11
|
return false unless _bit_clipboard_lib_prepare_workspace
|
10
12
|
|
11
13
|
_bit_clipboard_push_tag_all
|
12
14
|
_bit_clipboard_push_export_all
|
13
15
|
_bit_clipbpard_lib_remove_bit_artifacts
|
14
16
|
_bit_clipboard_lib_sync_workspace
|
15
|
-
|
16
|
-
log.info 'Pushed bit components'
|
17
|
-
true
|
17
|
+
_bit_clipboard_lib_bit_status
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -6,6 +6,8 @@ module BitRequireExport
|
|
6
6
|
def bit_require_export
|
7
7
|
log.debug 'Running bit require export'
|
8
8
|
|
9
|
+
return false unless configured? %w[project_root_dir]
|
10
|
+
|
9
11
|
components = _bit_require_lib_get_components
|
10
12
|
bitrequire_yml = _bit_require_export_get_bitrequire_yml components
|
11
13
|
|
@@ -23,7 +25,7 @@ module BitRequireExport
|
|
23
25
|
scope = component['id'].clone.gsub!(%r{/.*}, '')
|
24
26
|
name = component['id'].clone.gsub!(%r{#{scope}/}, '')
|
25
27
|
bitrequire['scopes'] = { scope => [] } if bitrequire['scopes'].nil?
|
26
|
-
bitrequire['scopes'] =
|
28
|
+
bitrequire['scopes'][scope] = [] unless bitrequire['scopes'].key? scope
|
27
29
|
bitrequire['scopes'][scope] << { 'name' => name }
|
28
30
|
end
|
29
31
|
hash_to_yaml bitrequire
|
@@ -6,6 +6,8 @@ module BitRequireImport
|
|
6
6
|
def bit_require_import
|
7
7
|
log.debug 'Running bit require import'
|
8
8
|
|
9
|
+
return false unless configured? %w[project_root_dir]
|
10
|
+
|
9
11
|
return false unless _bit_clipboard_lib_prepare_workspace
|
10
12
|
|
11
13
|
return false unless _bit_require_import_check_require_file_exists
|
@@ -84,7 +86,9 @@ module BitRequireImport
|
|
84
86
|
|
85
87
|
# Paste bit components.
|
86
88
|
def _bit_require_import_paste_components(components)
|
87
|
-
|
89
|
+
path = config.active['project_root_dir']
|
90
|
+
return false if path.empty?
|
91
|
+
|
88
92
|
components.each do |component|
|
89
93
|
next if _bit_require_import_check_component_exists component, path
|
90
94
|
|
data/lib/takelage/default.yml
CHANGED
@@ -6,6 +6,7 @@ bit_root: '/bit'
|
|
6
6
|
bit_ssh: ''
|
7
7
|
cmd_bit_check_workspace_bit_list: 'bit list'
|
8
8
|
cmd_bit_check_workspace_pwd: 'pwd'
|
9
|
+
cmd_bit_clipboard_lib_bit_status: 'bit status'
|
9
10
|
cmd_bit_clipboard_copy_bit_list_scope: 'bit list --skip-update --json %{scope}'
|
10
11
|
cmd_bit_clipboard_copy_bit_list_remotes: 'bit remote --skip-update'
|
11
12
|
cmd_bit_clipboard_copy_bit_add_dir: 'bit add --skip-update --id %{id} --main %{dir}/README.bit %{dir}'
|
data/lib/takelage/lib/config.rb
CHANGED
@@ -21,12 +21,15 @@ module ConfigModule
|
|
21
21
|
# Initialze config
|
22
22
|
# rubocop:disable Metrics/AbcSize
|
23
23
|
def initialize_config
|
24
|
+
project_root_dir = _get_project_root_dir
|
25
|
+
|
24
26
|
log.debug "takelage version: #{Takelage::VERSION}"
|
25
27
|
log.debug "Current working directory: #{Dir.pwd}"
|
28
|
+
log.debug "Project root directory: #{project_root_dir}" unless project_root_dir.empty?
|
26
29
|
|
27
|
-
TakelageConfig.instance.default = _config_read_default
|
30
|
+
TakelageConfig.instance.default = _config_read_default project_root_dir
|
28
31
|
TakelageConfig.instance.home = _config_read_home
|
29
|
-
TakelageConfig.instance.project = _config_read_project
|
32
|
+
TakelageConfig.instance.project = _config_read_project project_root_dir
|
30
33
|
TakelageConfig.instance.active = _config_merge_active
|
31
34
|
end
|
32
35
|
# rubocop:enable Metrics/AbcSize
|
@@ -62,19 +65,25 @@ module ConfigModule
|
|
62
65
|
takel_config_key = TakelageConfig.instance.active[config_key]
|
63
66
|
return true unless takel_config_key.nil? || takel_config_key.empty?
|
64
67
|
|
65
|
-
|
68
|
+
if config_key == 'project_root_dir'
|
69
|
+
log.error 'Please create a "Rakefile" in the project root directory'
|
70
|
+
else
|
71
|
+
log.error "Unset config key. Please configure \"#{config_key}\""
|
72
|
+
end
|
66
73
|
@configured = false
|
67
74
|
false
|
68
75
|
end
|
69
76
|
|
70
77
|
# Read default config file in lib.
|
71
|
-
def _config_read_default
|
78
|
+
def _config_read_default(project_root_dir)
|
72
79
|
default_file = File.expand_path("#{File.dirname(__FILE__)}/../default.yml")
|
73
80
|
|
74
|
-
return {} unless File.exist? default_file
|
81
|
+
return { project_root_dir: project_root_dir } unless File.exist? default_file
|
75
82
|
|
76
83
|
default_yaml = read_yaml_file(default_file) || {}
|
77
84
|
|
85
|
+
default_yaml['project_root_dir'] = project_root_dir
|
86
|
+
|
78
87
|
default_yaml.sort.to_h
|
79
88
|
end
|
80
89
|
|
@@ -84,21 +93,16 @@ module ConfigModule
|
|
84
93
|
|
85
94
|
return {} unless File.exist? home_file
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
home_yaml.sort.to_h
|
96
|
+
(read_yaml_file(home_file) || {}).sort.to_h
|
90
97
|
end
|
91
98
|
|
92
|
-
# Read custom config file
|
93
|
-
def _config_read_project
|
94
|
-
|
95
|
-
project_file = "#{path}/takelage.yml"
|
99
|
+
# Read custom config file in project root.
|
100
|
+
def _config_read_project(project_root_dir)
|
101
|
+
project_file = "#{project_root_dir}/takelage.yml"
|
96
102
|
|
97
103
|
return {} unless File.exist? project_file
|
98
104
|
|
99
|
-
|
100
|
-
|
101
|
-
project_yaml.sort.to_h
|
105
|
+
(read_yaml_file(project_file) || {}).sort.to_h
|
102
106
|
end
|
103
107
|
|
104
108
|
# Merge active config.
|
@@ -113,4 +117,14 @@ module ConfigModule
|
|
113
117
|
project_over_home = home.merge!(project)
|
114
118
|
default.merge!(project_over_home).sort.to_h
|
115
119
|
end
|
120
|
+
|
121
|
+
# Get project root directory.
|
122
|
+
# @return [String] project root directory
|
123
|
+
def _get_project_root_dir
|
124
|
+
_rakefile, path = Rake.application.find_rakefile_location
|
125
|
+
return path unless path.nil?
|
126
|
+
|
127
|
+
log.debug 'No "Rakefile" found. Cannot determine project root directory.'
|
128
|
+
''
|
129
|
+
end
|
116
130
|
end
|
data/lib/takelage/lib/project.rb
CHANGED
@@ -34,24 +34,24 @@ module ProjectModule
|
|
34
34
|
|
35
35
|
# Read main YAML file.
|
36
36
|
def _project_read_main
|
37
|
-
|
38
|
-
main_file = "#{
|
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
|
-
|
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
|
-
|
49
|
-
private_file = "#{
|
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 =
|
54
|
+
private_yaml = read_yaml_erb_file(private_file) || {}
|
55
55
|
|
56
56
|
private_yaml.sort.to_h
|
57
57
|
end
|
data/lib/takelage/lib/system.rb
CHANGED
@@ -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 @
|
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
|
-
@
|
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
|
data/lib/takelage/self/list.rb
CHANGED
@@ -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
|
-
#
|
18
|
-
|
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
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.22.0
|