takelage 0.19.1 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58c7e30c19e8a11de8ad95a88ed10b273a0266205de6eef10601331b5f6f2e99
4
- data.tar.gz: 3b45502b409d12f35aabbbb0cae6cdbd33ff108f245fa9a01c1c6c5acd3e04cd
3
+ metadata.gz: eb34019e556b714fcd893cf3141e23a1fbf63aad8bb695e2b205cfffb657a2ee
4
+ data.tar.gz: a0a2b8c6b6987f52057042ef410b2a94fb5628d519aa9f3c7ede9d4831d04a0d
5
5
  SHA512:
6
- metadata.gz: 7c23d454347c4983a240601f744198709cb7368edaa5baccddcc0f483ef1cd9aef1f9e04f338420764f5337fba84b181cfb95cccc222e6190fa50ae87789e7a4
7
- data.tar.gz: 4a44ee37503a14484500b84bedf50597e966d084f9925886ba3af8eb0577c4d1313f939f54fb07feb89468e604c696fb65a0ea534f2d35e9f05aff82f867ffcd
6
+ metadata.gz: 0ef2f83567050eaf5578f793417ca4f65de20ce9d1409bef4503793a58b0ba0b8ad9fac6e889c19f33ebb3d20617519714a93e7db92b6e06283520281690ccab
7
+ data.tar.gz: ba45ccafbddeeda014a74eed0fcad687ad6d2287773cadb7d0aafde9854bc381d8003aea47965196f7faf5f7b3c8205daef0c03696eb0b0328d18838093f030f
data/README.md CHANGED
@@ -42,66 +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/takelage/self/self.list.feature)*
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/takelage/bit/bit.check.workspace.feature) | Check if a bit workspace exists
51
- tau [bit clipboard copy](features/takelage/bit/bit.clipboard.copy.feature) [DIR] [SCOPE] | Copy new [DIR] to [SCOPE]
52
- tau [bit clipboard paste](features/takelage/bit/bit.clipboard.paste.feature) [COMPONENT] [DIR] | Paste bit [COMPONENT] into [DIR]
53
- tau [bit clipboard pull](features/takelage/bit/bit.clipboard.pull.feature) | Pull all updates for bit components from bit remote scopes
54
- tau [bit clipboard push](features/takelage/bit/bit.clipboard.push.feature) | Push all updates of bit components to bit remote scopes
55
- tau [bit scope add](features/takelage/bit/bit.scope.add.feature) [SCOPE] | Add a bit [SCOPE]
56
- tau [bit scope inbit](features/takelage/bit/bit.scope.inbit.feature) | Log in to bit remote server
57
- tau [bit scope list](features/takelage/bit/bit.scope.list.feature) | List bit remote scopes
58
- tau [bit scope new](features/takelage/bit/bit.scope.new.feature) [SCOPE] | Init a new bit [SCOPE]
59
- tau [completion bash](features/takelage/completion/completion.bash.feature) | Print bash completion code
60
- tau [docker check running](features/takelage/docker/docker.check.running.feature) | Check if docker daemon is running
61
- tau [docker container check existing](features/takelage/docker/docker.container.check.existing.feature) [CONTAINER] | Check if docker [CONTAINER] is existing
62
- tau [docker container check network](features/takelage/docker/docker.container.check.network.feature) [NETWORK] | Check if docker [NETWORK] is existing
63
- tau [docker container check orphaned](features/takelage/docker/docker.container.check.orphaned.feature) [CONTAINER] | Check if docker [CONTAINER] is orphaned
64
- tau [docker container command](features/takelage/docker/docker.container.command.feature) [CMD] | Run [CMD] in a docker container
65
- tau [docker container daemon](features/takelage/docker/docker.container.daemon.feature) | Run docker container in daemon mode
66
- tau [docker container login](features/takelage/docker/docker.container.login.feature) | Log in to latest local docker container
67
- tau [docker container clean](features/takelage/docker/docker.container.clean.feature) | Remove all docker containers
68
- tau [docker container prune](features/takelage/docker/docker.container.prune.feature) | Remove orphaned docker containers
69
- tau [docker image check outdated](features/takelage/docker/docker.image.check.outdated.feature) | Check if a docker image is outdated
70
- tau [docker image tag check local](features/takelage/docker/docker.image.tag.check.local.feature) [TAG] | Check if local docker image [TAG] exists
71
- tau [docker image tag check remote](features/takelage/docker/docker.image.tag.check.remote.feature) [TAG] | Check if remote docker image [TAG] exists
72
- tau [docker image tag latest local](features/takelage/docker/docker.image.tag.latest.local.feature) | Print latest local docker image tag
73
- tau [docker image tag latest remote](features/takelage/docker/docker.image.tag.latest.remote.feature) | Print latest remote docker image tag
74
- tau [docker image tag list local](features/takelage/docker/docker.image.tag.list.local.feature) | Print local docker image tags
75
- tau [docker image tag list remote](features/takelage/docker/docker.image.tag.list.remote.feature) | Print remote docker image tags
76
- tau [docker image update](features/takelage/docker/docker.image.update.feature) | Get latest remote docker container
77
- tau [docker socket host](features/takelage/docker/docker.socket.host.feature) | Print docker socket host ip address
78
- tau [docker socket scheme](features/takelage/docker/docker.socket.scheme.feature) | Print docker socket scheme
79
- tau [docker socket start](features/takelage/docker/docker.socket.start.feature) | Start sockets for docker container
80
- tau [docker socket stop](features/takelage/docker/docker.socket.stop.feature) | Stop sockets for docker container
81
- tau [git check clean](features/takelage/git/git.check.clean.feature) | Check if the git workspace is clean
82
- tau [git check master](features/takelage/git/git.check.master.feature) | Check if we are on the git master branch
83
- tau [git check workspace](features/takelage/git/git.check.workspace.feature) | Check if a git workspace exists
84
- tau [info project active](features/takelage/info/info.project.active.feature) | Print active project info
85
- tau [info project main](features/takelage/info/info.project.main.feature) | Print main project info
86
- tau [info project private](features/takelage/info/info.project.private.feature) | Print private project info
87
- tau [self config active](features/takelage/self/self.config.active.feature) | Print active takelage configuration
88
- tau [self config default](features/takelage/self/self.config.default.feature) | Print takelage default configuration
89
- tau [self config home](features/takelage/self/self.config.home.feature) | Print takelage home config file configuration
90
- tau [self config project](features/takelage/self/self.config.project.feature) | Print takelage project config file configuration
91
- tau [self list](features/takelage/self/self.list.feature) | List all commands
92
- tau [self version](features/takelage/self/self.version.feature) | Print tau semantic version number
93
- tau config | Alias for tau [self config active](features/takelage/self/self.config.active.feature)
94
- tau copy [DIR] [SCOPE] | Alias for tau [bit clipboard copy](features/takelage/bit/bit.clipboard.copy.feature)
95
- tau list | Alias for tau [self list](features/takelage/self/self.list.feature)
96
- tau login | Alias for tau [docker container login](features/takelage/docker/docker.container.login.feature)
97
- tau clean | Alias for tau [docker container clean](features/takelage/docker/docker.container.clean.feature)
98
- tau paste [COMPONENT] [DIR] | Alias for tau [bit clipboard paste](features/takelage/bit/bit.clipboard.paste.feature)
99
- tau project | Alias for tau [info project active](features/takelage/info/info.project.active.feature)
100
- tau pull | Alias for tau [bit clipboard pull](features/takelage/bit/bit.clipboard.pull.feature)
101
- tau prune | Alias for tau [docker container prune](features/takelage/docker/docker.container.prune.feature)
102
- tau push | Alias for tau [bit clipboard push](features/takelage/bit/bit.clipboard.push.feature)
103
- tau update | Alias for tau [docker image update](features/takelage/docker/docker.image.update.feature)
104
- tau version | Alias for tau [self version](features/takelage/self/self.version.feature)
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)
105
107
 
106
108
  **Warning: *tau update* will call *docker image prune* and remove all dangling images!**
107
109
 
@@ -113,7 +115,7 @@ tau version | Alias for tau [self version](features/takelage/self/self.version.f
113
115
  which have different precedences.
114
116
  They are merged to an active configuration during runtime
115
117
  which can be inspected with
116
- *tau [self config active](features/takelage/self/self.config.active.feature)*
118
+ *tau [self config active](features/cucumber/features/self/self.config.active.feature)*
117
119
  or *tau config*.
118
120
 
119
121
  | Filename | Precedence | Description |
@@ -166,7 +168,7 @@ Furthermore, every external command can be reconfigured.
166
168
  which have different precedences.
167
169
  They are merged to an active configuration during runtime
168
170
  which can be inspected with
169
- *tau [info project active](features/takelage/info/info.project.active.feature)*
171
+ *tau [info project active](features/cucumber/features/info/info.project.active.feature)*
170
172
  or *tau project*.
171
173
 
172
174
  | Default filename | Config key | Precedence | Description |
@@ -184,8 +186,11 @@ source <(tau completion bash)
184
186
 
185
187
  ### Software Tests
186
188
 
189
+ *takelage-cli* uses
190
+ [minitest](https://github.com/seattlerb/minitest) unit tests.
191
+
187
192
  *takelage-cli* ships with
188
- [cucumber](https://github.com/cucumber/cucumber) ruby tests.
193
+ [cucumber](https://github.com/cucumber/cucumber) ruby system tests.
189
194
  It uses cucumber's
190
195
  [aruba](https://github.com/cucumber/aruba) extension and especially its
191
196
  [filesystem](https://relishapp.com/cucumber/aruba/v/0-11-0/docs/filesystem)
@@ -38,6 +38,10 @@ require_relative 'takelage/bit/clipboard/paste'
38
38
  require_relative 'takelage/bit/clipboard/pull'
39
39
  require_relative 'takelage/bit/clipboard/push'
40
40
  require_relative 'takelage/bit/clipboard/cli'
41
+ require_relative 'takelage/bit/require/lib'
42
+ require_relative 'takelage/bit/require/export'
43
+ require_relative 'takelage/bit/require/import'
44
+ require_relative 'takelage/bit/require/cli'
41
45
  require_relative 'takelage/bit/cli'
42
46
  require_relative 'takelage/completion/cli'
43
47
  require_relative 'takelage/docker/check/running'
@@ -112,7 +116,7 @@ module Takelage
112
116
  # Initialize global singleton project
113
117
  initialize_project
114
118
 
115
- # prepare for the worst
119
+ # Prepare for the worst
116
120
  @docker_daemon_running = false
117
121
 
118
122
  # fylla bash completion code
@@ -9,6 +9,9 @@ module Takelage
9
9
  desc 'clipboard [COMMAND]', 'Manage bit clipboard'
10
10
  subcommand 'clipboard', BitClipboard
11
11
 
12
+ desc 'require [COMMAND]', 'Manage bit requirements'
13
+ subcommand 'require', BitRequire
14
+
12
15
  desc 'scope [COMMAND]', 'Manage bit scopes'
13
16
  subcommand 'scope', BitScope
14
17
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Takelage
4
- # takelage bit
4
+ # takelage bit clipboard
5
5
  class BitClipboard < SubCommandBase
6
6
  include LoggingModule
7
7
  include ConfigModule
@@ -9,6 +9,8 @@ module BitClipboardCopy
9
9
 
10
10
  log.debug "Running bit copy \"#{dir}\" to \"#{scope}\""
11
11
 
12
+ return false unless configured? %w[project_root_dir]
13
+
12
14
  return false unless _bit_clipboard_lib_prepare_workspace
13
15
 
14
16
  unless File.directory? dir
@@ -43,7 +45,7 @@ module BitClipboardCopy
43
45
  end
44
46
  # rubocop:enable Metrics/MethodLength
45
47
 
46
- # touch README.bit if necessary
48
+ # Touch README.bit if necessary.
47
49
  def _bit_clipboard_copy_touch_readme_bit(dir)
48
50
  readme_bit = "#{dir}/README.bit"
49
51
  return if File.file? readme_bit
@@ -52,7 +54,7 @@ module BitClipboardCopy
52
54
  File.open(readme_bit, 'w') {}
53
55
  end
54
56
 
55
- # check if a README.bit file exists in a subdirectory
57
+ # Check if a README.bit file exists in a subdirectory.
56
58
  def _bit_clipboard_copy_readme_bit_exists_in_subdir?(dir)
57
59
  Dir.glob("#{dir}/**/README.bit").each do |file|
58
60
  unless file == "#{dir}/README.bit"
@@ -64,7 +66,7 @@ module BitClipboardCopy
64
66
  false
65
67
  end
66
68
 
67
- # Check if bit scope exists
69
+ # Check if bit scope exists.
68
70
  def _bit_clipboard_copy_dir_scope_exists?(scope)
69
71
  bit_dev = config.active['bit_dev_user']
70
72
 
@@ -78,7 +80,7 @@ module BitClipboardCopy
78
80
  true
79
81
  end
80
82
 
81
- # check if bit.dev remote scope exists
83
+ # Check if bit.dev remote scope exists.
82
84
  def _bit_clipboard_bit_dev_scope_exists(scope)
83
85
  cmd_bit_list_scope = format(
84
86
  config.active['cmd_bit_clipboard_copy_bit_list_scope'],
@@ -93,7 +95,7 @@ module BitClipboardCopy
93
95
  false
94
96
  end
95
97
 
96
- # check if bit remote scope is added to local workspace
98
+ # Check if bit remote scope is added to local workspace.
97
99
  def _bit_clipboard_custom_scope_exists(scope)
98
100
  cmd_bit_list_remotes =
99
101
  config.active['cmd_bit_clipboard_copy_bit_list_remotes']
@@ -107,7 +109,7 @@ module BitClipboardCopy
107
109
  false
108
110
  end
109
111
 
110
- # bit tag dir
112
+ # bit tag dir.
111
113
  def _bit_clipboard_copy_add_dir(id, dir)
112
114
  cmd_bit_add_dir = format(
113
115
  config.active['cmd_bit_clipboard_copy_bit_add_dir'],
@@ -118,7 +120,7 @@ module BitClipboardCopy
118
120
  run cmd_bit_add_dir
119
121
  end
120
122
 
121
- # bit tag dir
123
+ # bit tag dir.
122
124
  def _bit_clipboard_copy_tag_dir(id)
123
125
  cmd_bit_tag_id = format(
124
126
  config.active['cmd_bit_clipboard_copy_bit_tag_id'],
@@ -128,7 +130,7 @@ module BitClipboardCopy
128
130
  run cmd_bit_tag_id
129
131
  end
130
132
 
131
- # bit export component to bit remote scope
133
+ # bit export component to bit remote scope.
132
134
  def _bit_clipboard_copy_export_to_scope(scope)
133
135
  cmd_bit_export_to_scope = format(
134
136
  config.active['cmd_bit_clipboard_copy_bit_export_to_scope'],
@@ -51,30 +51,29 @@ module BitClipboardLib
51
51
  def _bit_clipboard_lib_sync_workspace
52
52
  log.debug 'Syncing git workspace'
53
53
 
54
- _rakefile, path = Rake.application.find_rakefile_location
55
- bitmap = "#{path}/.bitmap"
54
+ path = config.active['project_root_dir']
55
+ file = "#{path}/.bitmap"
56
+ message = 'Update .bitmap'
56
57
 
57
- _bit_clipboard_lib_git_add bitmap
58
- _bit_clipboard_lib_git_commit bitmap
58
+ _bit_clipboard_lib_git_add file
59
+ _bit_clipboard_lib_git_commit message
59
60
  _bit_clipboard_lib_git_push
60
61
  end
61
62
 
62
- # git add .bitmap
63
- def _bit_clipboard_lib_git_add(bitmap)
64
- log.debug "Adding \"#{bitmap}\" to git"
63
+ # git add .bitmap.
64
+ def _bit_clipboard_lib_git_add(file)
65
+ log.debug "Adding \"#{file}\" to git"
65
66
 
66
67
  cmd_bit_clipboard_git_add = format(
67
68
  config.active['cmd_bit_clipboard_git_add'],
68
- file: bitmap
69
+ file: file
69
70
  )
70
71
  run cmd_bit_clipboard_git_add
71
72
  end
72
73
 
73
- # git commit -m "Update .bitmap"
74
- def _bit_clipboard_lib_git_commit(bitmap)
75
- message = 'Update .bitmap'
76
-
77
- log.debug "Committing \"#{bitmap}\" to git"
74
+ # git commit -m "Update .bitmap".
75
+ def _bit_clipboard_lib_git_commit(message)
76
+ log.debug "Committing to git with message \"#{message}\""
78
77
 
79
78
  cmd_bit_clipboard_git_commit = format(
80
79
  config.active['cmd_bit_clipboard_git_commit'],
@@ -84,7 +83,7 @@ module BitClipboardLib
84
83
  run cmd_bit_clipboard_git_commit
85
84
  end
86
85
 
87
- # git push origin master
86
+ # git push origin master.
88
87
  def _bit_clipboard_lib_git_push
89
88
  log.debug 'Pushing master branch to origin'
90
89
 
@@ -94,7 +93,7 @@ module BitClipboardLib
94
93
  run cmd_bit_clipboard_git_push
95
94
  end
96
95
 
97
- # git pull
96
+ # git pull.
98
97
  def _bit_clipboard_lib_git_pull
99
98
  log.debug 'Updating git workspace'
100
99
  cmd_bit_clipboard_git_pull =
@@ -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
@@ -20,7 +22,7 @@ module BitClipboardPaste
20
22
 
21
23
  private
22
24
 
23
- # paste bit component into directory
25
+ # paste bit component into directory.
24
26
  def _bit_clipboard_paste_import_cid(cid, dir)
25
27
  cmd_bit_import_cid = format(
26
28
  config.active['cmd_bit_clipboard_paste_bit_import_cid'],
@@ -31,6 +33,7 @@ module BitClipboardPaste
31
33
  run cmd_bit_import_cid
32
34
  end
33
35
 
36
+ # Check if remote component exists.
34
37
  def _bit_clipboard_paste_cid_exists?(cid)
35
38
  scope = cid.scan(%r{([^/]*).*}).first.first
36
39
 
@@ -45,7 +48,7 @@ module BitClipboardPaste
45
48
  false
46
49
  end
47
50
 
48
- # get components in remote scope
51
+ # Get components in remote scope.
49
52
  def _bit_clipboard_paste_cid_exists_list_scope(scope)
50
53
  cmd_bit_list_scope = format(
51
54
  config.active['cmd_bit_clipboard_paste_bit_list_scope'],
@@ -6,6 +6,8 @@ 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
@@ -19,7 +21,7 @@ module BitClipboardPull
19
21
 
20
22
  private
21
23
 
22
- # bit import components into workspace
24
+ # bit import components into workspace.
23
25
  def _bit_clipboard_pull_import_all
24
26
  cmd_bit_import_all =
25
27
  config.active['cmd_bit_clipboard_pull_bit_import_all']
@@ -27,7 +29,7 @@ module BitClipboardPull
27
29
  run cmd_bit_import_all
28
30
  end
29
31
 
30
- # checkout components and merge them
32
+ # Checkout components and merge them.
31
33
  def _bit_clipboard_pull_checkout_all
32
34
  cmd_bit_checkout_all =
33
35
  config.active['cmd_bit_clipboard_pull_bit_checkout_all']
@@ -2,10 +2,12 @@
2
2
 
3
3
  # takelage bit clipboard push
4
4
  module BitClipboardPush
5
- # Backend method for bit push
5
+ # Backend method for bit push.
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
@@ -19,7 +21,7 @@ module BitClipboardPush
19
21
 
20
22
  private
21
23
 
22
- # bit tag all components
24
+ # bit tag all components.
23
25
  def _bit_clipboard_push_tag_all
24
26
  cmd_bit_tag_all =
25
27
  config.active['cmd_bit_clipboard_push_bit_tag_all']
@@ -27,7 +29,7 @@ module BitClipboardPush
27
29
  run cmd_bit_tag_all
28
30
  end
29
31
 
30
- # bit export components
32
+ # bit export components.
31
33
  def _bit_clipboard_push_export_all
32
34
  cmd_bit_export_all =
33
35
  config.active['cmd_bit_clipboard_push_bit_export_all']
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takelage
4
+ # takelage bit requiere
5
+ class BitRequire < SubCommandBase
6
+ include LoggingModule
7
+ include ConfigModule
8
+ include SystemModule
9
+ include GitCheckClean
10
+ include GitCheckMaster
11
+ include GitCheckWorkspace
12
+ include BitCheckWorkspace
13
+ include BitScopeList
14
+ include BitScopeAdd
15
+ include BitClipboardLib
16
+ include BitClipboardCopy
17
+ include BitClipboardPaste
18
+ include BitRequireLib
19
+ include BitRequireExport
20
+ include BitRequireImport
21
+
22
+ # Initialize bit require
23
+ def initialize(args = [], local_options = {}, configuration = {})
24
+ # initialize thor parent class
25
+ super args, local_options, configuration
26
+
27
+ @bit_require_file = config.active['bit_require_file']
28
+ end
29
+
30
+ #
31
+ # bit require export
32
+ #
33
+ desc 'export', 'Create requirements file with bit components.'
34
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
35
+ Create requirements file with bit components
36
+ LONGDESC
37
+ # Create requirements file with bit components.
38
+ def export
39
+ bit_require_yml = bit_require_export
40
+ exit false if bit_require_yml == false
41
+ say bit_require_yml
42
+ true
43
+ end
44
+
45
+ #
46
+ # bit require import
47
+ #
48
+ desc 'import', 'Import bit components from requirements file.'
49
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
50
+ Import bit components from requirements file
51
+ LONGDESC
52
+ # Import bit components from requirements file.
53
+ def import
54
+ exit bit_require_import
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage bit require export
4
+ module BitRequireExport
5
+ # Backend method for bit require export.
6
+ def bit_require_export
7
+ log.debug 'Running bit require export'
8
+
9
+ return false unless configured? %w[project_root_dir]
10
+
11
+ components = _bit_require_lib_get_components
12
+ bitrequire_yml = _bit_require_export_get_bitrequire_yml components
13
+
14
+ log.debug "bitrequire.yml of this project:\n#{bitrequire_yml}"
15
+ bitrequire_yml
16
+ end
17
+
18
+ private
19
+
20
+ # Create contents of bitrequire yaml file.
21
+ # rubocop:disable Metrics/AbcSize
22
+ def _bit_require_export_get_bitrequire_yml(components)
23
+ bitrequire = {}
24
+ components.each do |component|
25
+ scope = component['id'].clone.gsub!(%r{/.*}, '')
26
+ name = component['id'].clone.gsub!(%r{#{scope}/}, '')
27
+ bitrequire['scopes'] = { scope => [] } if bitrequire['scopes'].nil?
28
+ bitrequire['scopes'][scope] = [] unless bitrequire['scopes'].key? scope
29
+ bitrequire['scopes'][scope] << { 'name' => name }
30
+ end
31
+ hash_to_yaml bitrequire
32
+ end
33
+ # rubocop:enable Metrics/AbcSize
34
+ end
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage bit require import
4
+ module BitRequireImport
5
+ # Backend method for bit require import.
6
+ def bit_require_import
7
+ log.debug 'Running bit require import'
8
+
9
+ return false unless configured? %w[project_root_dir]
10
+
11
+ return false unless _bit_clipboard_lib_prepare_workspace
12
+
13
+ return false unless _bit_require_import_check_require_file_exists
14
+
15
+ scopes = _bit_require_import_get_scopes_and_components
16
+ return false unless scopes
17
+
18
+ components = _bit_require_import_get_components scopes
19
+ return false unless components
20
+
21
+ return false unless _bit_require_import_add_scopes scopes
22
+
23
+ _bit_require_import_paste_components components
24
+ end
25
+
26
+ private
27
+
28
+ # Check if a bit requirements file exists.
29
+ def _bit_require_import_check_require_file_exists
30
+ return true if File.exist? @bit_require_file
31
+
32
+ log.error "No #{@bit_require_file} file found"
33
+ false
34
+ end
35
+
36
+ # Get scopes and components from requirements file.
37
+ def _bit_require_import_get_scopes_and_components
38
+ bit_require = read_yaml_file(@bit_require_file)
39
+ return bit_require['scopes'] if bit_require.key?('scopes')
40
+
41
+ log.error "No scopes in #{@bit_require_file} file"
42
+ false
43
+ end
44
+
45
+ # Get flat components array.
46
+ def _bit_require_import_get_components(scopes)
47
+ components_all = []
48
+ scopes.each do |scope, components|
49
+ scope_components = _bit_require_import_get_scope_components scope, components
50
+ return false unless scope_components
51
+
52
+ components_all |= scope_components
53
+ end
54
+ components_all
55
+ end
56
+
57
+ # Get bit components of a scope.
58
+ def _bit_require_import_get_scope_components(scope, components)
59
+ scope_components = []
60
+ components.each do |component|
61
+ return false unless _bit_require_import_check_component_valid component, scope
62
+
63
+ name = component['name']
64
+ path = name
65
+ path = component['path'] if component.key?('path')
66
+ scope_components << { name: name, path: path, scope: scope }
67
+ log.debug "Identified bit component \"#{name}\" with path \"#{path}\" in scope \"#{scope}\""
68
+ end
69
+ scope_components
70
+ end
71
+
72
+ # Check if there are bit components
73
+ def _bit_require_import_check_component_valid(component, scope)
74
+ return true if (component.class == Hash) && component.key?('name')
75
+
76
+ log.error "No component in #{scope}"
77
+ false
78
+ end
79
+
80
+ # Add bit scopes to workspace.
81
+ def _bit_require_import_add_scopes(scopes)
82
+ scopes.each do |scope, _components|
83
+ bit_scope_add scope unless _bit_clipboard_bit_dev_scope_exists scope
84
+ end
85
+ end
86
+
87
+ # Paste bit components.
88
+ def _bit_require_import_paste_components(components)
89
+ path = config.active['project_root_dir']
90
+ return false if path.empty?
91
+
92
+ components.each do |component|
93
+ next if _bit_require_import_check_component_exists component, path
94
+
95
+ return false unless _bit_require_import_paste_component component
96
+
97
+ _bit_require_import_commit_component component, path
98
+ end
99
+ true
100
+ end
101
+
102
+ # Check if there are bit components
103
+ def _bit_require_import_check_component_exists(component, path)
104
+ scope = component[:scope]
105
+ cid = component[:name]
106
+ dir = component[:path]
107
+ dest = "#{path}/#{dir}"
108
+ cids = _bit_require_lib_get_components_ids
109
+ return false unless cids.include? "#{scope}/#{cid}"
110
+
111
+ log.warn "Skipping existing bit component \"#{scope}/#{cid}\" with path \"#{dest}\""
112
+ true
113
+ end
114
+
115
+ # Paste a bit component
116
+ def _bit_require_import_paste_component(component)
117
+ scope = component[:scope]
118
+ cid = component[:name]
119
+ dir = component[:path]
120
+ bit_clipboard_paste "#{scope}/#{cid}", dir
121
+ end
122
+
123
+ # Commit a bit component
124
+ def _bit_require_import_commit_component(component, path)
125
+ scope = component[:scope]
126
+ cid = component[:name]
127
+ dir = component[:path]
128
+ dest = "#{path}/#{dir}"
129
+ message = "Add bit component \"#{scope}/#{cid}\" to path \"#{dest}\""
130
+ _bit_clipboard_lib_git_add dest
131
+ _bit_clipboard_lib_git_commit message
132
+ end
133
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage bit require lib
4
+ module BitRequireLib
5
+ private
6
+
7
+ # Get bit components.
8
+ def _bit_require_lib_get_components
9
+ cmd_bit_list = config.active['cmd_bit_require_lib_bit_list']
10
+ bit_list = run cmd_bit_list
11
+ JSON.parse bit_list
12
+ end
13
+
14
+ # Get bit components ids.
15
+ def _bit_require_lib_get_components_ids
16
+ cmd_bit_list_ids = config.active['cmd_bit_require_lib_bit_list_ids']
17
+ run cmd_bit_list_ids
18
+ end
19
+ end
@@ -9,7 +9,7 @@ module BitScopeList
9
9
 
10
10
  return false unless configured? %w[bit_ssh bit_remote]
11
11
 
12
- # get ssh command from active config
12
+ # get ssh command from active config.
13
13
  cmd_bit_ssh =
14
14
  config.active['bit_ssh']
15
15
 
@@ -17,7 +17,7 @@ module BitScopeList
17
17
 
18
18
  cmd_bit_scope_list = _bit_scope_list_cmd root
19
19
 
20
- # run ssh command with scope list command
20
+ # run ssh command with scope list command.
21
21
  scope_list = run "#{cmd_bit_ssh} '#{cmd_bit_scope_list}'"
22
22
 
23
23
  # remove bit remote root directory from results
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  bit_dev_user: 'takelage'
3
3
  bit_remote: ''
4
+ bit_require_file: 'bitrequire.yml'
4
5
  bit_root: '/bit'
5
6
  bit_ssh: ''
6
7
  cmd_bit_check_workspace_bit_list: 'bit list'
@@ -20,6 +21,9 @@ cmd_bit_clipboard_pull_bit_import_all: 'bit import --ignore-package-json --ignor
20
21
  cmd_bit_clipboard_pull_bit_checkout_all: 'bit checkout --ignore-package-json --ignore-dist --skip-update --skip-npm-install --all latest'
21
22
  cmd_bit_clipboard_push_bit_tag_all: 'bit tag --skip-update --skip-tests --all'
22
23
  cmd_bit_clipboard_push_bit_export_all: 'bit export --skip-update --all'
24
+ cmd_bit_clipboard_export_bit_list: 'bit list --skip-update --json %{scope}'
25
+ cmd_bit_require_lib_bit_list: 'bit list --skip-update --json'
26
+ cmd_bit_require_lib_bit_list_ids: 'bit list --skip-update --json --ids'
23
27
  cmd_bit_scope_add_scope: 'bit remote add %{remote}/%{scope}'
24
28
  cmd_bit_scope_list_find_scopes: 'find -L %{root} -name scope.json'
25
29
  cmd_bit_scope_new_bit_init: 'mkdir -p %{root}/%{scope} && cd %{root}/%{scope} && bit init --bare'
@@ -22,6 +22,7 @@ module DockerContainerCheckExisting
22
22
 
23
23
  private
24
24
 
25
+ # Format command to check if docker container exists.
25
26
  def _docker_container_cmd_check_existing(container)
26
27
  format(
27
28
  config.active['cmd_docker_container_check_existing_docker_ps'],
@@ -22,6 +22,7 @@ module DockerContainerCheckNetwork
22
22
 
23
23
  private
24
24
 
25
+ # Prepare command to check if docker network exists.
25
26
  def _docker_container_cmd_check_network(network)
26
27
  format(
27
28
  config.active['cmd_docker_container_check_network_docker_network'],
@@ -22,6 +22,7 @@ module DockerContainerCheckOrphaned
22
22
 
23
23
  private
24
24
 
25
+ # Format command to check if docker container is orphaned.
25
26
  def _docker_container_cmd_check_orphaned(container)
26
27
  format(
27
28
  config.active['cmd_docker_container_check_orphaned_docker_exec'],
@@ -16,7 +16,7 @@ module DockerContainerClean
16
16
 
17
17
  private
18
18
 
19
- # Check if we are running tau clean inside a takelage container
19
+ # Check if we are running tau clean inside a takelage container.
20
20
  def _docker_container_clean_harakiri?
21
21
  hostname = ENV['HOSTNAME'] || ''
22
22
  return false unless hostname.start_with? "#{@docker_repo}_"
@@ -26,7 +26,7 @@ module DockerContainerClean
26
26
  true
27
27
  end
28
28
 
29
- # Kill all docker containers and return list of networks
29
+ # Kill all docker containers and return list of networks.
30
30
  def _docker_container_clean_kill_existing_containers
31
31
  networks = []
32
32
  _docker_container_lib_get_containers.each do |container|
@@ -8,6 +8,8 @@ module DockerContainerLib
8
8
 
9
9
  # Create docker container and network.
10
10
  def _docker_container_lib_create_net_and_ctr(name)
11
+ return false if _docker_container_lib_check_matrjoschka
12
+
11
13
  unless docker_container_check_network name
12
14
  _docker_container_lib_create_network name
13
15
  end
@@ -56,8 +58,6 @@ module DockerContainerLib
56
58
  def _docker_container_lib_create_container(container)
57
59
  log.debug "Creating container \"#{container}\""
58
60
 
59
- return false if _docker_container_lib_check_matrjoschka
60
-
61
61
  image = "#{@docker_user}/#{@docker_repo}:#{@docker_tag}"
62
62
 
63
63
  return false unless _docker_container_lib_image_available? image
@@ -105,10 +105,12 @@ module DockerContainerLib
105
105
 
106
106
  # Check if we are already inside a takelage container
107
107
  def _docker_container_lib_check_matrjoschka
108
- return false unless ENV['HOSTNAME'].start_with? @docker_repo
108
+ log.debug 'Checking if we are already inside a takelage container'
109
+
110
+ return false unless ENV.keys.include? 'TAKELAGE_PROJECT_BASE_DIR'
109
111
 
110
112
  log.error 'You cannot log in to takelage from within takelage'
111
- false
113
+ true
112
114
  end
113
115
 
114
116
  # Check if docker image is available
@@ -14,7 +14,7 @@ module DockerContainerPrune
14
14
 
15
15
  private
16
16
 
17
- # Kill orphaned docker containers and return list of networks
17
+ # Kill orphaned docker containers and return list of networks.
18
18
  def _docker_container_prune_kill_orphaned_containers
19
19
  networks = []
20
20
 
@@ -23,7 +23,7 @@ module DockerSocketLib
23
23
  cmds_start_socket
24
24
  end
25
25
 
26
- # Get socket start command
26
+ # Get socket start command.
27
27
  def _docker_socket_lib_get_start_cmd(mode, socket, host, port, path)
28
28
  if mode == 'start'
29
29
  unless _docker_socket_lib_socket_up? socket, host, port, path
@@ -45,7 +45,7 @@ module DockerSocketLib
45
45
  )
46
46
  end
47
47
 
48
- # Check if a socket is available by trying to connect to it via TCP
48
+ # Check if a socket is available by trying to connect to it via TCP.
49
49
  def _docker_socket_lib_socket_up?(socket, host, port, path)
50
50
  error_message = _docker_socket_lib_error_msg socket, host, port, path
51
51
  begin
@@ -19,15 +19,20 @@ module ConfigModule
19
19
  end
20
20
 
21
21
  # Initialze config
22
+ # rubocop:disable Metrics/AbcSize
22
23
  def initialize_config
24
+ project_root_dir = _get_project_root_dir
25
+
23
26
  log.debug "takelage version: #{Takelage::VERSION}"
24
27
  log.debug "Current working directory: #{Dir.pwd}"
28
+ log.debug "Project root directory: #{project_root_dir}" unless project_root_dir.empty?
25
29
 
26
- TakelageConfig.instance.default = _config_read_default
30
+ TakelageConfig.instance.default = _config_read_default project_root_dir
27
31
  TakelageConfig.instance.home = _config_read_home
28
- TakelageConfig.instance.project = _config_read_project
32
+ TakelageConfig.instance.project = _config_read_project project_root_dir
29
33
  TakelageConfig.instance.active = _config_merge_active
30
34
  end
35
+ # rubocop:enable Metrics/AbcSize
31
36
 
32
37
  # @return [Object] global singleton config
33
38
  def config
@@ -55,24 +60,30 @@ module ConfigModule
55
60
  false
56
61
  end
57
62
 
58
- # Check if config key is nil or empty
63
+ # Check if config key is nil or empty.
59
64
  def _check_key_set?(config_key)
60
65
  takel_config_key = TakelageConfig.instance.active[config_key]
61
66
  return true unless takel_config_key.nil? || takel_config_key.empty?
62
67
 
63
- log.error "Unset config key. Please configure \"#{config_key}\""
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
64
73
  @configured = false
65
74
  false
66
75
  end
67
76
 
68
77
  # Read default config file in lib.
69
- def _config_read_default
78
+ def _config_read_default(project_root_dir)
70
79
  default_file = File.expand_path("#{File.dirname(__FILE__)}/../default.yml")
71
80
 
72
- return {} unless File.exist? default_file
81
+ return { project_root_dir: project_root_dir } unless File.exist? default_file
73
82
 
74
83
  default_yaml = read_yaml_file(default_file) || {}
75
84
 
85
+ default_yaml['project_root_dir'] = project_root_dir
86
+
76
87
  default_yaml.sort.to_h
77
88
  end
78
89
 
@@ -82,24 +93,19 @@ module ConfigModule
82
93
 
83
94
  return {} unless File.exist? home_file
84
95
 
85
- home_yaml = read_yaml_file(home_file) || {}
86
-
87
- home_yaml.sort.to_h
96
+ (read_yaml_file(home_file) || {}).sort.to_h
88
97
  end
89
98
 
90
- # Read custom config file next to Rakefile.
91
- def _config_read_project
92
- _rakefile, path = Rake.application.find_rakefile_location
93
- 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"
94
102
 
95
103
  return {} unless File.exist? project_file
96
104
 
97
- project_yaml = read_yaml_file(project_file) || {}
98
-
99
- project_yaml.sort.to_h
105
+ (read_yaml_file(project_file) || {}).sort.to_h
100
106
  end
101
107
 
102
- # Merge active config
108
+ # Merge active config.
103
109
  def _config_merge_active
104
110
  # make a clone or else we'll change the original hash
105
111
  default = TakelageConfig.instance.default.clone
@@ -111,4 +117,14 @@ module ConfigModule
111
117
  project_over_home = home.merge!(project)
112
118
  default.merge!(project_over_home).sort.to_h
113
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
114
130
  end
@@ -28,12 +28,14 @@ module LoggingModule
28
28
 
29
29
  private
30
30
 
31
+ # Get log format.
31
32
  def _logging_get_log_format
32
33
  proc do |severity, _datetime, _progname, msg|
33
34
  "[#{severity}] #{msg}\n"
34
35
  end
35
36
  end
36
37
 
38
+ # Get log level.
37
39
  def _logging_get_log_level(loglevel)
38
40
  if %w[FATAL ERROR WARN INFO DEBUG].include? loglevel
39
41
  loglevel
@@ -34,24 +34,24 @@ module ProjectModule
34
34
 
35
35
  # Read main YAML file.
36
36
  def _project_read_main
37
- _rakefile, @path = Rake.application.find_rakefile_location
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
- _rakefile, @path = Rake.application.find_rakefile_location
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
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Thor with subcommands that work correctly with help
4
4
  class SubCommandBase < Thor
5
- # Set the subcommand banner
5
+ # Set the subcommand banner.
6
6
  def self.banner(command, _namespace = nil, _subcommand = false)
7
7
  "#{basename} #{subcommand_prefix} #{command.usage}"
8
8
  end
9
9
 
10
- # Set the subcommand prefix
10
+ # Set the subcommand prefix.
11
11
  def self.subcommand_prefix
12
12
  name.gsub(/.*::/, '')
13
13
  .gsub(/^[A-Z]/) { |match| match[0].downcase }
@@ -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,19 +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
-
27
+ # Manipulate output of thor list command.
23
28
  def _manipulate_output_(thor_list)
24
- thor_list.gsub!("takelage\n", '')
25
- thor_list.gsub!("------\n", '')
26
- thor_list.gsub!('thor ', 'tau ')
27
- thor_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
28
- 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/, '')
29
34
  end
30
35
  end
@@ -1 +1 @@
1
- 0.19.1
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.19.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin
@@ -214,6 +214,10 @@ files:
214
214
  - lib/takelage/bit/clipboard/paste.rb
215
215
  - lib/takelage/bit/clipboard/pull.rb
216
216
  - lib/takelage/bit/clipboard/push.rb
217
+ - lib/takelage/bit/require/cli.rb
218
+ - lib/takelage/bit/require/export.rb
219
+ - lib/takelage/bit/require/import.rb
220
+ - lib/takelage/bit/require/lib.rb
217
221
  - lib/takelage/bit/scope/add.rb
218
222
  - lib/takelage/bit/scope/cli.rb
219
223
  - lib/takelage/bit/scope/inbit.rb
@@ -284,7 +288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
288
  requirements:
285
289
  - - ">="
286
290
  - !ruby/object:Gem::Version
287
- version: '0'
291
+ version: '2.4'
288
292
  required_rubygems_version: !ruby/object:Gem::Requirement
289
293
  requirements:
290
294
  - - ">="