rumination 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -9
- data/bin/rspec +17 -0
- data/lib/rumination/deploy/base.rb +56 -0
- data/lib/rumination/deploy/class_methods.rb +15 -0
- data/lib/rumination/deploy.rb +12 -0
- data/lib/rumination/docker_compose/container.rb +34 -0
- data/lib/rumination/docker_compose/sh.rb +10 -0
- data/lib/rumination/docker_compose.rb +23 -0
- data/lib/rumination/railtie.rb +12 -0
- data/lib/rumination/tasks/deploy/bootstrap.rake +11 -0
- data/lib/rumination/tasks/deploy/finish.rake +30 -0
- data/lib/rumination/tasks/deploy.rake +4 -0
- data/lib/rumination/version.rb +1 -1
- data/lib/rumination.rb +1 -0
- data/rumination.gemspec +2 -0
- metadata +41 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe4dfb1cb7b66f72ab2775c4949a86a487bbbd0
|
4
|
+
data.tar.gz: 8c9b28a63244d8911eec1066b262ada854293743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b905220d6888d4a15f319c74616214bdbe417081510ed117f093f9035e1fd609798f1092df86485809778f2f85a02067f5bc2a8fd4d91aefd19fdf2c7e2c4b
|
7
|
+
data.tar.gz: 52f8ad78f39d8604a44b8c161c03a318152da4bf4ed9963b2753332cb70c92f1fa592ffed8e0d8c896a4b5d003efa4a1922fbe6f11ddf6c785ce6b287350ab1b
|
data/README.md
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# Rumination
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/rumination)
|
4
|
+
|
3
5
|
/ruːmɪˈneɪʃ(ə)n/
|
4
6
|
|
5
7
|
noun
|
6
8
|
|
7
|
-
1.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
*"this film stuck out, demanding attention and rumination"*
|
9
|
+
1. a deep or considered thought about something:
|
10
|
+
*"philosophical ruminations about life and humanity"*;
|
11
|
+
the action or process of thinking deeply about something:
|
12
|
+
*"this film stuck out, demanding attention and rumination"*
|
12
13
|
|
13
|
-
2.
|
14
|
-
the action of chewing the cud:
|
15
|
-
*"cows slow down their rumination"*
|
14
|
+
2. the action of chewing the cud: *"cows slow down their rumination"*
|
16
15
|
|
17
16
|
## Installation
|
18
17
|
|
@@ -49,7 +48,7 @@ git commits and tags, and push the `.gem` file to
|
|
49
48
|
## Contributing
|
50
49
|
|
51
50
|
Bug reports and pull requests are welcome on GitHub at
|
52
|
-
https://github.com/
|
51
|
+
https://github.com/artm/rumination.
|
53
52
|
|
54
53
|
|
55
54
|
## License
|
data/bin/rspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rspec' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rspec-core", "rspec")
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "../docker_compose"
|
2
|
+
require "dotenv/parser"
|
3
|
+
|
4
|
+
module Rumination
|
5
|
+
module Deploy
|
6
|
+
Base ||= Struct.new(:target) do
|
7
|
+
def bootstrap
|
8
|
+
call do
|
9
|
+
on_fresh_containers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
load_target_config
|
15
|
+
DockerCompose.build.down.up
|
16
|
+
yield if block_given?
|
17
|
+
container(:backend)
|
18
|
+
.exec("rake deploy:unload[#{target}]")
|
19
|
+
.run("rake deploy:finish[#{target}]")
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_fresh_containers
|
23
|
+
puts "Bootstrapping '#{target}'"
|
24
|
+
raise BootstrappedAlready if bootstrapped?
|
25
|
+
initialize_database
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_target_config
|
29
|
+
load "./config/deploy/targets/#{target}.rb"
|
30
|
+
ENV["VIRTUAL_HOST"] = Deploy.config.virtual_host
|
31
|
+
ENV["COMPOSE_FILE"] = Deploy.config.compose_file if Deploy.config.compose_file
|
32
|
+
setup_docker_machine_env if Deploy.config.docker_machine
|
33
|
+
rescue LoadError => e
|
34
|
+
raise UnknownTarget, e.message
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_docker_machine_env
|
38
|
+
dm_env_str = `docker-machine env #{Deploy.config.docker_machine}`
|
39
|
+
ENV.update Dotenv::Parser.call(dm_env_str)
|
40
|
+
end
|
41
|
+
|
42
|
+
def bootstrapped?
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize_database
|
47
|
+
container(:backend).run("rake db:setup:maybe_load_dump")
|
48
|
+
raise DatabaseInitError unless $? == 0
|
49
|
+
end
|
50
|
+
|
51
|
+
def container(name)
|
52
|
+
DockerCompose::Container.new(name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "active_support/configurable"
|
2
|
+
require_relative "deploy/class_methods"
|
3
|
+
|
4
|
+
module Rumination
|
5
|
+
module Deploy
|
6
|
+
include ActiveSupport::Configurable
|
7
|
+
extend Deploy::ClassMethods
|
8
|
+
UnknownTarget = Class.new(RuntimeError)
|
9
|
+
BootstrappedAlready = Class.new(RuntimeError)
|
10
|
+
DatabaseInitError = Class.new(RuntimeError)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "sh"
|
2
|
+
|
3
|
+
module Rumination
|
4
|
+
module DockerCompose
|
5
|
+
Container = Struct.new(:name) do
|
6
|
+
include Sh
|
7
|
+
|
8
|
+
def has_file?(path)
|
9
|
+
run "test -f #{path}"
|
10
|
+
$? == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def up?
|
14
|
+
exec "true"
|
15
|
+
$? == 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def exec command
|
19
|
+
sh "docker-compose exec #{name} #{command}"
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def run command
|
24
|
+
sh "docker-compose run --rm #{name} #{command}"
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def restart
|
29
|
+
sh "docker-compose restart #{name}"
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "docker_compose/container"
|
2
|
+
require_relative "docker_compose/sh"
|
3
|
+
|
4
|
+
module Rumination
|
5
|
+
module DockerCompose
|
6
|
+
extend Sh
|
7
|
+
|
8
|
+
def self.build
|
9
|
+
sh "docker-compose build"
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
sh "docker-compose down"
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.up
|
19
|
+
sh "docker-compose up -d"
|
20
|
+
self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
task :bootstrap, [:target] do |t, args|
|
3
|
+
args.with_defaults target: :development
|
4
|
+
begin
|
5
|
+
Rumination::Deploy.bootstrap(target: args.target)
|
6
|
+
rescue Rumination::Deploy::BootstrappedAlready
|
7
|
+
abort "'#{args.target}' has already been bootstrapped"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
task :unload, [:target] do |t, args|
|
3
|
+
vhost = ENV["VIRTUAL_HOST"]
|
4
|
+
if vhost.present?
|
5
|
+
sh "rm -f /etc/nginx/vhost.d/#{vhost}*"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
task :finish, [:target] => %w[static_files vhost_conf]
|
10
|
+
|
11
|
+
task :static_files, [:target] do |t, args|
|
12
|
+
vhost = ENV["VIRTUAL_HOST"]
|
13
|
+
if vhost
|
14
|
+
sh "rsync -av public/ /var/www/#{vhost}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :vhost_conf, [:target] do |t, args|
|
19
|
+
def erb_config basename, vhost
|
20
|
+
template = "config/nginx/vhost.d/#{basename}.erb"
|
21
|
+
if vhost && File.exists?(template)
|
22
|
+
new_name = basename.sub("app", vhost)
|
23
|
+
sh "erb #{template} > /etc/nginx/vhost.d/#{new_name}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
vhost = ENV["VIRTUAL_HOST"]
|
27
|
+
erb_config "app", vhost
|
28
|
+
erb_config "app_location", vhost
|
29
|
+
end
|
30
|
+
end
|
data/lib/rumination/version.rb
CHANGED
data/lib/rumination.rb
CHANGED
data/rumination.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Baguinski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: railties
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: dotenv
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: development utilities
|
84
112
|
email:
|
85
113
|
- abaguinski@depraktijkindex.nl
|
@@ -95,12 +123,23 @@ files:
|
|
95
123
|
- README.md
|
96
124
|
- Rakefile
|
97
125
|
- bin/console
|
126
|
+
- bin/rspec
|
98
127
|
- bin/setup
|
99
128
|
- lib/rumination.rb
|
129
|
+
- lib/rumination/deploy.rb
|
130
|
+
- lib/rumination/deploy/base.rb
|
131
|
+
- lib/rumination/deploy/class_methods.rb
|
100
132
|
- lib/rumination/dev_user.rb
|
133
|
+
- lib/rumination/docker_compose.rb
|
134
|
+
- lib/rumination/docker_compose/container.rb
|
135
|
+
- lib/rumination/docker_compose/sh.rb
|
101
136
|
- lib/rumination/pg.rb
|
102
137
|
- lib/rumination/pg/commands.rb
|
103
138
|
- lib/rumination/pg/restore.rb
|
139
|
+
- lib/rumination/railtie.rb
|
140
|
+
- lib/rumination/tasks/deploy.rake
|
141
|
+
- lib/rumination/tasks/deploy/bootstrap.rake
|
142
|
+
- lib/rumination/tasks/deploy/finish.rake
|
104
143
|
- lib/rumination/version.rb
|
105
144
|
- rumination.gemspec
|
106
145
|
homepage: https://github.com/artm/rumination
|