cachivache 0.1.0 → 0.1.1
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 +3 -4
- data/bin/template/Rakefile +6 -12
- data/bin/template/lib/rake-helper.rb +21 -4
- data/bin/template/lib/shell-contexts/shell-context.rb +15 -6
- data/bin/template/lib/shell-contexts/shell-exec.rb +12 -0
- data/bin/template/lib/shell-contexts/shell_buffer.rb +10 -3
- data/bin/template/lib/shell-contexts/shell_debugger.rb +11 -0
- data/bin/template/lib/stuff-api-behaviour.rb +1 -1
- data/bin/template/lib/stuff-configuration.rb +2 -2
- data/bin/template/lib/stuff-reminders-behaviour.rb +2 -8
- data/lib/cachivache/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e68c84fc309762c64ddf571c3f53d6e274b9140
|
4
|
+
data.tar.gz: a88c0c0a348c71891bbd17d3628d44a728394c8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab8a7e369843262583de50fda7e30a469cc3c4cdfa7bc4d7e75e41916ddcbdb27395a6c6410a52428a745c13632d979cc4e53364c3a01ebcb44bd628c321e8e
|
7
|
+
data.tar.gz: a772bce3e35172d195786f28e60b7420ceeee4b04637905601fbd4b1823152567e8297f46b0b385185d2286d3bf70a5b8e8daa9abff6929e56ed5d13eb8b2baf
|
data/README.md
CHANGED
@@ -164,7 +164,7 @@ end
|
|
164
164
|
|
165
165
|
You see in the last example that if we define strings using "" we need to scape internals \", so the simpliest is to use `%Q{}`.
|
166
166
|
|
167
|
-
### You can call as many `
|
167
|
+
### You can call as many `shell` blocks within a task as you like. You can also :invoke and :execute other tasks:
|
168
168
|
|
169
169
|
```ruby
|
170
170
|
stuff :'do-stuff' do
|
@@ -298,8 +298,7 @@ To remove a stuff library do:
|
|
298
298
|
|
299
299
|
## Debugging
|
300
300
|
|
301
|
-
During the building of the stuff, it's useful to be able to see what the provision
|
302
|
-
what would do instead of running it.
|
301
|
+
During the building of the stuff, it's useful to be able to see what the provision would do instead of running it.
|
303
302
|
|
304
303
|
To debug the provision do
|
305
304
|
|
@@ -321,4 +320,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/cabeza
|
|
321
320
|
|
322
321
|
## License
|
323
322
|
|
324
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
323
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/bin/template/Rakefile
CHANGED
@@ -4,27 +4,21 @@ raise_validation_error "Please define the parameter Cachivache.git_user_email in
|
|
4
4
|
raise_validation_error "Please define the parameter Cachivache.git_user_name in './cachivache.rb' run 'vagrant provision' again" unless Cachivache.is_defined?(:git_user_name)
|
5
5
|
raise_validation_error "Please define some Cachivache.stuff_to_install in './cachivache.rb' run 'vagrant provision' again" if Cachivache.stuff_to_install.empty?
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
def provision_stuff_to_install()
|
8
|
+
stuff_to_install do |stuff_name|
|
9
9
|
show_info "Provisioning #{stuff_name}"
|
10
|
-
|
11
|
-
block.call stuff_name
|
10
|
+
invoke stuff_name
|
12
11
|
end
|
13
|
-
|
14
12
|
show_info "All done!!!"
|
15
13
|
end
|
16
14
|
|
17
15
|
stuff :provision do
|
18
|
-
|
19
|
-
invoke stuff_name
|
20
|
-
end
|
16
|
+
provision_stuff_to_install
|
21
17
|
end
|
22
18
|
|
23
19
|
stuff :explain do
|
24
|
-
|
25
|
-
|
26
|
-
puts explained.green
|
27
|
-
end
|
20
|
+
ShellContext.set_current ShellDebugger.new
|
21
|
+
provision_stuff_to_install
|
28
22
|
end
|
29
23
|
|
30
24
|
stuff default: :provision
|
@@ -11,6 +11,12 @@ def all_rb_files_in(folder, &block)
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def stuff_to_install(&block)
|
15
|
+
Cachivache.stuff_to_install.each do |stuff_name|
|
16
|
+
block.call stuff_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
public
|
15
21
|
|
16
22
|
######################################
|
@@ -25,9 +31,20 @@ end
|
|
25
31
|
# Stuff Api behaviour
|
26
32
|
######################################
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
def stuff(task_definition, *args, &block)
|
35
|
+
task_name = fully_qualified_name_of(task_definition)
|
36
|
+
|
37
|
+
Rake::Task[task_name].clear if Rake::Task.task_defined?(task_name)
|
38
|
+
|
39
|
+
task(task_definition, *args, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def fully_qualified_name_of(task_definition)
|
43
|
+
task_name = (task_definition.is_a? Hash) ? task_definition.keys.first : task_definition
|
44
|
+
namespace = Rake.application.current_scope.path
|
45
|
+
|
46
|
+
return task_name if namespace.empty?
|
47
|
+
(namespace.to_s + ':' + task_name.to_s).to_sym
|
31
48
|
end
|
32
49
|
|
33
50
|
def execute_shell_command(command)
|
@@ -47,4 +64,4 @@ all_rb_files_in Cachivache.cachivache_folder do |file|
|
|
47
64
|
Stuff::Configuration.creating_undefined_subclasses do
|
48
65
|
require file
|
49
66
|
end
|
50
|
-
end
|
67
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class ShellContext
|
2
2
|
@current = nil
|
3
|
+
@reminders = []
|
3
4
|
|
4
5
|
def self.current()
|
5
6
|
@current
|
@@ -19,20 +20,24 @@ class ShellContext
|
|
19
20
|
@current = current_shell_context
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
@
|
23
|
+
def self.reminders()
|
24
|
+
@reminders
|
24
25
|
end
|
25
26
|
|
26
|
-
def
|
27
|
-
|
27
|
+
def self.show_info(text)
|
28
|
+
puts '-----------------------------------------------'.red
|
29
|
+
puts text.green
|
30
|
+
puts '-----------------------------------------------'.red
|
28
31
|
end
|
29
32
|
|
33
|
+
# Instance methods
|
34
|
+
|
30
35
|
def shell(command)
|
31
36
|
raise 'Subclass responsibility'
|
32
37
|
end
|
33
38
|
|
34
39
|
def shell!(command)
|
35
|
-
|
40
|
+
raise 'Subclass responsibility'
|
36
41
|
end
|
37
42
|
|
38
43
|
def invoke(task_name, *args)
|
@@ -44,11 +49,15 @@ class ShellContext
|
|
44
49
|
end
|
45
50
|
|
46
51
|
def remind_to(text)
|
47
|
-
reminders << text
|
52
|
+
ShellContext.reminders << text
|
48
53
|
end
|
49
54
|
|
50
55
|
def raise_validation_error(message)
|
51
56
|
show_info(message)
|
52
57
|
exit
|
53
58
|
end
|
59
|
+
|
60
|
+
def show_info(text)
|
61
|
+
ShellContext.show_info(text)
|
62
|
+
end
|
54
63
|
end
|
@@ -1,7 +1,19 @@
|
|
1
1
|
require_relative 'shell-context'
|
2
2
|
|
3
3
|
class ShellExec < ShellContext
|
4
|
+
def initialize(scope)
|
5
|
+
@scope = scope
|
6
|
+
end
|
7
|
+
|
8
|
+
def scope()
|
9
|
+
@scope
|
10
|
+
end
|
11
|
+
|
4
12
|
def shell(command)
|
5
13
|
shell! command
|
6
14
|
end
|
15
|
+
|
16
|
+
def shell!(command)
|
17
|
+
scope.execute_shell_command(command)
|
18
|
+
end
|
7
19
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require_relative 'shell-context'
|
2
2
|
|
3
3
|
class ShellBuffer < ShellContext
|
4
|
-
def initialize(
|
5
|
-
|
6
|
-
|
4
|
+
def initialize(underlaying_shell_context)
|
5
|
+
@underlaying_shell_context = underlaying_shell_context
|
7
6
|
@contents = ''
|
8
7
|
end
|
9
8
|
|
9
|
+
def underlaying_shell_context()
|
10
|
+
@underlaying_shell_context
|
11
|
+
end
|
12
|
+
|
10
13
|
def contents
|
11
14
|
@contents
|
12
15
|
end
|
@@ -15,4 +18,8 @@ class ShellBuffer < ShellContext
|
|
15
18
|
contents << "\n" unless contents.empty?
|
16
19
|
contents << command
|
17
20
|
end
|
21
|
+
|
22
|
+
def shell!(command)
|
23
|
+
underlaying_shell_context.shell! command
|
24
|
+
end
|
18
25
|
end
|
@@ -100,7 +100,7 @@ module Stuff
|
|
100
100
|
protected
|
101
101
|
|
102
102
|
def during_shell_buffer(&block)
|
103
|
-
temporary_shell_buffer = ShellBuffer.new(shell_context
|
103
|
+
temporary_shell_buffer = ShellBuffer.new(shell_context)
|
104
104
|
|
105
105
|
ShellContext.during_shell_context(temporary_shell_buffer, &block)
|
106
106
|
|
@@ -1,17 +1,11 @@
|
|
1
1
|
module Stuff
|
2
2
|
module RemindersBehaviour
|
3
|
-
def reminders()
|
4
|
-
@reminders ||= []
|
5
|
-
end
|
6
|
-
|
7
3
|
def show_reminders()
|
8
|
-
reminders.each { |alert| show_info(alert) }
|
4
|
+
ShellContext.reminders.each { |alert| show_info(alert) }
|
9
5
|
end
|
10
6
|
|
11
7
|
def show_info(text)
|
12
|
-
|
13
|
-
puts text.green
|
14
|
-
puts '-----------------------------------------------'.red
|
8
|
+
ShellContext.show_info(text)
|
15
9
|
end
|
16
10
|
end
|
17
11
|
end
|
data/lib/cachivache/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachivache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Rubi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- bin/template/lib/shell-contexts/shell-context.rb
|
92
92
|
- bin/template/lib/shell-contexts/shell-exec.rb
|
93
93
|
- bin/template/lib/shell-contexts/shell_buffer.rb
|
94
|
+
- bin/template/lib/shell-contexts/shell_debugger.rb
|
94
95
|
- bin/template/lib/shell-file-context.rb
|
95
96
|
- bin/template/lib/shell-if-context.rb
|
96
97
|
- bin/template/lib/stuff-api-behaviour.rb
|