vlad-unity 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 992649944855d7127aef166c41941dae72665ec2
4
+ data.tar.gz: 1df92c0fede7baaadce9eeec2b9565fb310bbca7
5
+ SHA512:
6
+ metadata.gz: bea0335129662fd5cfd9d4fa24897c6bf0780329a77c7604d0f85a9f25be47efbfbac3d288f2520964af4ae29941063c400b27d088eb278d8be1105a20dcb07d
7
+ data.tar.gz: 0a565b6d7fa0835cfacb221cbfeada6bebe34c935f4b2be0ea8e575c4353cc3a379045bf70987f6458c5a1a601d53c6c508f54273799de5bbaff442f273e0703
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Matt Smith
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # vlad-unity
2
+
3
+ ### A (hopefully) more agnostic set of vlad extensions.
4
+
5
+ This library fixes some things that might bother you over default vlad tasks
6
+ and adds a few more enahncements.
7
+
8
+ It tries to make vlad less opinionated when having an opinion about being
9
+ opinionated.
10
+
11
+ ## Dependencies
12
+
13
+ - vlad
14
+
15
+ ## Useage
16
+
17
+ This gem requires you to
18
+
19
+ ```ruby
20
+ # require the files that you want... be a standup citizen
21
+
22
+ require 'vlad-unity/rails/assets'
23
+ set :rails_env, nil
24
+
25
+ # similar to shared_paths, i.e. { shared file => linked location }
26
+ # key of hash is looked for in the shared_path location
27
+ #
28
+ #
29
+ require 'vlad-unity/extension'
30
+ set :shared_files, {
31
+ 'neo4j.yml' => 'config/neo4j.yml'
32
+ }
33
+
34
+ require 'vlad-unity/app'
35
+ set :start_app, 'vlad:systemd:start'
36
+ set :restart_app, 'vlad:systemd:restart'
37
+
38
+ # Every deploy is its own special flower -- we have a default implementation
39
+ # for:
40
+ # vlad:app:update
41
+ # vlad:deploy
42
+ #
43
+ # But you can make your own!
44
+ #
45
+ Rake::Task['vlad:app:update'].clear
46
+ namespace :vlad do
47
+ namespace :app do
48
+ Rake::Task['vlad:app:update'].clear
49
+ remote_task :update, :roles => :app do
50
+ Rake::Task['vlad:update_app'].invoke
51
+ Rake::Task['vlad:update_symlinks'].invoke
52
+
53
+ # your tasks here
54
+
55
+ Rake::Task['vlad:set_current_release'].invoke
56
+ Rake::Task['vlad:log_revision'].invoke
57
+ end
58
+ end
59
+
60
+ Rake::Task['vlad:deploy'].clear
61
+ remote_task :deploy, :roles => :app do
62
+
63
+ # your tasks here
64
+
65
+ Rake::Task['vlad:cleanup'].invoke
66
+ end
67
+ end
68
+ ```
69
+
70
+ ```shell
71
+ rake vlad:deploy
72
+ ```
73
+
74
+ ## Contributors
75
+
76
+ - Matt Smith, Near Apogee Consulting (www.nearapogee.com)
77
+
78
+ ## License
79
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
80
+
data/lib/vlad-unity.rb ADDED
@@ -0,0 +1,9 @@
1
+ # extension
2
+ set :shared_files, Hash.new
3
+
4
+ # rails/assets
5
+ set :rails_env, nil
6
+
7
+ # app
8
+ set :start_app, nil
9
+ set :restart_app, nil
@@ -0,0 +1,55 @@
1
+ namespace :vlad do
2
+ # Override the default update.
3
+ #
4
+ Rake::Task['vlad:update'].clear
5
+ remote_task :update, :roles => :app do
6
+ Rake::Task['vlad:update_app'].invoke
7
+ Rake::Task['vlad:update_symlinks'].invoke
8
+ Rake::Task['vlad:set_current_release'].invoke
9
+ Rake::Task['vlad:log_revision'].invoke
10
+ end
11
+
12
+ # Set start_app to call :start.
13
+ #
14
+ remote_task :start_app, :roles => :app do
15
+ unless (Rake::Task[start_app] rescue false)
16
+ raise <<-ERR
17
+ start_app must defiened. i.e. `set :start_app, 'vlad:systemd:start'`"
18
+ ERR
19
+ end
20
+ Rake::Task[start_app].invoke
21
+ end
22
+
23
+ namespace :app do
24
+ remote_task :update, :roles => :app do
25
+ Rake::Task['vlad:update_app'].invoke
26
+ Rake::Task['vlad:update_symlinks'].invoke
27
+
28
+ if (Rake::Task['vlad:bundle:install'] rescue false)
29
+ Rake::Task['vlad:bundle:install'].invoke
30
+ end
31
+ if (Rake::Task['vlad:migrate'] rescue false)
32
+ Rake::Task['vlad:migrate'].invoke
33
+ end
34
+ if (Rake::Task['vlad:assets:precompile'] rescue false)
35
+ Rake::Task['vlad:assets:precompile'].invoke unless ENV['SKIP_ASSETS']
36
+ end
37
+
38
+ Rake::Task['vlad:set_current_release'].invoke
39
+ Rake::Task['vlad:log_revision'].invoke
40
+ end
41
+ end
42
+
43
+ desc "Deploy application and start servers."
44
+ remote_task :deploy, :roles => :app do
45
+ unless (Rake::Task[restart_app] rescue false)
46
+ raise <<-ERR
47
+ restart_app must defiened. i.e. `set :restart_app' 'vlad:systemd:restart'`"
48
+ ERR
49
+ end
50
+ Rake::Task['vlad:app:update'].invoke
51
+ Rake::Task[restart_app].invoke
52
+ Rake::Task['vlad:cleanup'].invoke
53
+ end
54
+
55
+ end
@@ -0,0 +1,72 @@
1
+
2
+ [
3
+ ["Thread.current[:task]", :move, :relocate],
4
+ ["Rake::RemoteTask", :roles, :hosts_for, :ask]
5
+ ].each do |methods|
6
+ receiver = methods.shift
7
+ methods.each do |method|
8
+ eval "def #{method} *args, &block; #{receiver}.#{method}(*args, &block);end"
9
+ end
10
+ end
11
+
12
+ class Rake::RemoteTask
13
+ def self.ask name
14
+ set(name) do
15
+ state = `stty -g`
16
+
17
+ raise Rake::Error, "stty(1) not found" unless $?.success?
18
+
19
+ begin
20
+ system "stty -echo"
21
+ $stdout.print "#{name}: "
22
+ $stdout.flush
23
+ value = $stdin.gets.chomp!
24
+ $stdout.puts
25
+ ensure
26
+ system "stty #{state}"
27
+ end
28
+ value
29
+ end
30
+ end
31
+
32
+ def move from, to, options={}
33
+ cmds = ["mv #{from} #{to}"]
34
+ cmds = cmds.map {|c| ["#{sudo_cmd}", c].join(' ')} if options[:sudo]
35
+ run cmds.join(' && ')
36
+ end
37
+
38
+ def relocate to, options={}
39
+ tmp_path = ['/tmp', File.basename(to)].join('/')
40
+ put(tmp_path) { yield }
41
+ move tmp_path, to, sudo: true
42
+ end
43
+ end
44
+
45
+ namespace :vlad do
46
+ # Enhance update_symlinks to also symlink a shared_files variable.
47
+ #
48
+ Rake::Task['vlad:update_symlinks'].enhance do
49
+ begin
50
+ ops = []
51
+ unless shared_files.empty?
52
+ shared_files.each do |sp, rp|
53
+ ops << "mkdir -p #{latest_release}/#{File.dirname(rp)}"
54
+ ops << "ln -s #{shared_path}/#{sp} #{latest_release}/#{rp}"
55
+ end
56
+ end
57
+ run ops.join(' && ') unless ops.empty?
58
+ rescue => e
59
+ run "rm -rf #{release_path}"
60
+ raise e
61
+ end
62
+ end
63
+
64
+ task :wait do
65
+ continue = false
66
+ begin
67
+ print "Press enter to continue. Ctl-C to quit."
68
+ input = STDIN.gets
69
+ continue = true if input == "\n"
70
+ end while !continue
71
+ end
72
+ end
@@ -0,0 +1,10 @@
1
+ namespace :vlad do
2
+
3
+ namespace :assets do
4
+ desc "Precomile"
5
+ remote_task :precompile , :roles => :app do
6
+ run "cd #{latest_release} && RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
7
+ end
8
+ end
9
+
10
+ end
@@ -0,0 +1,3 @@
1
+ module VladUnity
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vlad-unity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vlad
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ description: General vlad utilities.
28
+ email:
29
+ - matt@nearapogee.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - lib/vlad-unity.rb
37
+ - lib/vlad-unity/app.rb
38
+ - lib/vlad-unity/extension.rb
39
+ - lib/vlad-unity/rails/assets.rb
40
+ - lib/vlad-unity/version.rb
41
+ homepage: https://github.com/nearapogee/vlad-unity
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.6.11
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: A (hopefully) more agnostic set of vlad extensions.
65
+ test_files: []