bub_bot 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/bub_bot.gemspec +1 -0
- data/lib/bub_bot.rb +1 -0
- data/lib/bub_bot/configuration.rb +40 -1
- data/lib/bub_bot/deploy_manager.rb +7 -11
- data/lib/bub_bot/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f624985c964068cf82f1766cb94e27e0ee895ab4
|
4
|
+
data.tar.gz: 112176a7a01c8bdd9f40434ee8f37eee12e355bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45a161978eaae8e736497d6fa2f5d2eeea829424236d50b47d2c20533fb4644ac980f6d8f1dbb0161317389e10ed9e2bdf0661ded67b8cc4cc997de814776147
|
7
|
+
data.tar.gz: 88adca1eb0da42fc256a4989a3b347872370c962473e3f104f6d0cf541df49edea24d46c0d6f814c774762e7a03135f6a2701f18558dc559c95b96d73306bd53
|
data/.gitignore
CHANGED
data/bub_bot.gemspec
CHANGED
data/lib/bub_bot.rb
CHANGED
@@ -17,7 +17,7 @@ class BubBot::Configuration
|
|
17
17
|
|
18
18
|
OPTIONS = RACK_OPTIONS + BUB_BOT_OPTIONS
|
19
19
|
|
20
|
-
|
20
|
+
attr_writer *OPTIONS
|
21
21
|
|
22
22
|
def rack_options_hash
|
23
23
|
RACK_OPTIONS.each_with_object({}) do |option_name, options_hash|
|
@@ -31,4 +31,43 @@ class BubBot::Configuration
|
|
31
31
|
true
|
32
32
|
end
|
33
33
|
|
34
|
+
# Each config option will, when requested (eg BubBot.configuration.bot_name), be
|
35
|
+
# run through ERB. You can provide optional additional context for the erb call.
|
36
|
+
# This is is a good way to provide variable that you want to access in the yaml.
|
37
|
+
# Eg if the bot_name is "friendly_bot_<%= phase_of_moon %>" in the yaml, you could
|
38
|
+
# call `BubBot.configuration.bot_name(phase_of_moon: 'waxing')`.
|
39
|
+
OPTIONS.each do |option|
|
40
|
+
define_method(option) do |extra_context = {}|
|
41
|
+
option_data = instance_variable_get("@#{option}".to_sym)
|
42
|
+
interpolate(option_data, extra_context)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def interpolate(data, extra_context)
|
49
|
+
if data.is_a?(String)
|
50
|
+
ERB.new(data).result(get_binding(extra_context))
|
51
|
+
elsif data.is_a?(Array)
|
52
|
+
data.map { |element| interpolate(element, extra_context) }
|
53
|
+
elsif data.is_a?(Hash)
|
54
|
+
data.each_with_object({}) do |(key, value), new_hash|
|
55
|
+
new_hash[key] = interpolate(value, extra_context)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
data
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Gets a binding object with the given variables defined in it. You'd *think*
|
63
|
+
# there'd be a simpler way. Well, ok, there is, but there's no simpler way that
|
64
|
+
# doesn't *also* polute the binding with variables from the outer scope.
|
65
|
+
def get_binding(variables)
|
66
|
+
obj = Class.new {
|
67
|
+
attr_accessor *variables.keys
|
68
|
+
def get_binding(); binding end
|
69
|
+
}.new
|
70
|
+
variables.each { |name, value| obj.public_send(:"#{name}=", value) }
|
71
|
+
obj.get_binding
|
72
|
+
end
|
34
73
|
end
|
@@ -10,7 +10,7 @@ class BubBot::DeployManager
|
|
10
10
|
|
11
11
|
begin
|
12
12
|
DeployState[server, target_name].set(true)
|
13
|
-
target_config = target(target_name)
|
13
|
+
target_config = target(target_name, server)
|
14
14
|
|
15
15
|
unless deploy_config = target_config['deploy']
|
16
16
|
raise "Missing deploy config for #{target_name}"
|
@@ -24,7 +24,6 @@ class BubBot::DeployManager
|
|
24
24
|
# TODO: maybe handle multiple deploys for each target? Right now the
|
25
25
|
# workaround to do that is to just have a script-type deploy that does that.
|
26
26
|
if deploy_git_remote = deploy_config['git']
|
27
|
-
deploy_git_remote = ERB.new(deploy_git_remote).result(get_binding(locals))
|
28
27
|
repo(target_name, server).push(branch, deploy_git_remote)
|
29
28
|
elsif deploy_script = deploy_config['script']
|
30
29
|
puts "xdeploying web script #{deploy_script}"
|
@@ -42,11 +41,8 @@ class BubBot::DeployManager
|
|
42
41
|
elsif deploy_url = deploy_config['http']
|
43
42
|
raise RespondableError.new('Sorry, deploys by http request are not supported yet')
|
44
43
|
end
|
45
|
-
|
46
|
-
DeployState[server, target_name].set(false)
|
47
|
-
rescue
|
44
|
+
ensure
|
48
45
|
DeployState[server, target_name].set(false)
|
49
|
-
raise
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
@@ -62,17 +58,17 @@ class BubBot::DeployManager
|
|
62
58
|
|
63
59
|
def repo(target_name, server)
|
64
60
|
@repos ||= {}
|
65
|
-
target = target(target_name)
|
61
|
+
target = target(target_name, server)
|
66
62
|
@repos[target_name + '__' + server] ||= Repo.new(target_name, target['git'], server)
|
67
63
|
end
|
68
64
|
|
69
65
|
# Returns a hash of config data for the target with this name
|
70
|
-
def target(target_name)
|
71
|
-
targets.find { |name, _| name == target_name }.last
|
66
|
+
def target(target_name, server = nil)
|
67
|
+
targets(server).find { |name, _| name == target_name }.last
|
72
68
|
end
|
73
69
|
|
74
|
-
def targets
|
75
|
-
BubBot.configuration.deploy_targets
|
70
|
+
def targets(server = nil)
|
71
|
+
BubBot.configuration.deploy_targets(server: server)
|
76
72
|
end
|
77
73
|
|
78
74
|
# Gets a binding object with the given variables defined in it. You'd *think*
|
data/lib/bub_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bub_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Kuchta
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: dotenv
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
description:
|
196
210
|
email:
|
197
211
|
- kevin@kevinkuchta.com
|