plur 0.0.1 → 0.0.2

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.
@@ -1,4 +1,2 @@
1
1
  require "plur/version"
2
-
3
- module Plur
4
- end
2
+ require "plur/railtie" if defined?(Rails)
@@ -1,60 +1,4 @@
1
- # Customization of https://github.com/ddollar/foreman/blob/master/lib/foreman/capistrano.rb
2
- Capistrano::Configuration.instance(:must_exist).load do
3
-
4
- namespace :foreman do
5
- desc <<-DESC
6
- Export the Procfile to upstart. Will use sudo if available.
7
-
8
- You can override any of these defaults by setting the variables shown below.
9
-
10
- set :foreman_format, "upstart"
11
- set :foreman_location, "/etc/init"
12
- set :foreman_procfile, "Procfile"
13
- set :foreman_root, release_path
14
- set :foreman_port, 5000
15
- set :foreman_app, application
16
- set :foreman_user, user
17
- set :foreman_log, 'shared_path/log'
18
- set :foreman_concurrency, false
19
- DESC
20
- task :export, :roles => :app do
21
- bundle_cmd = fetch(:bundle_cmd, "bundle")
22
- foreman_format = fetch(:foreman_format, "upstart")
23
- foreman_location = fetch(:foreman_location, "/etc/init")
24
- foreman_procfile = fetch(:foreman_procfile, "Procfile")
25
- foreman_port = fetch(:foreman_port, 5000)
26
- foreman_root = fetch(:foreman_root, release_path)
27
- foreman_app = fetch(:foreman_app, application)
28
- foreman_user = fetch(:foreman_user, user)
29
- foreman_log = fetch(:foreman_log, "#{shared_path}/log")
30
- foreman_concurrency = fetch(:foreman_concurrency, false)
31
-
32
- args = ["#{foreman_format} #{foreman_location}"]
33
- args << "-f #{foreman_procfile}"
34
- args << "-p #{foreman_port}"
35
- args << "-d #{foreman_root}"
36
- args << "-a #{foreman_app}"
37
- args << "-u #{foreman_user}"
38
- args << "-l #{foreman_log}"
39
- args << "-c #{foreman_concurrency}" if foreman_concurrency
40
- run "cd #{release_path} && #{sudo} #{bundle_cmd} exec foreman export #{args.join(' ')}"
41
- end
42
- end
43
-
44
- namespace :upstart do
45
- desc "Start the application services"
46
- task :start, :roles => :app do
47
- run "#{sudo} service #{application} start"
48
- end
49
-
50
- desc "Stop the application services"
51
- task :stop, :roles => :app do
52
- run "#{sudo} service #{application} stop"
53
- end
54
-
55
- desc "Restart the application services"
56
- task :restart, :roles => :app do
57
- run "#{sudo} service #{application} start || #{sudo} service #{application} restart"
58
- end
59
- end
60
- end
1
+ require "plur/capistrano/foreman"
2
+ require "plur/capistrano/upstart"
3
+ require "plur/capistrano/figaro"
4
+ require "plur/capistrano/local"
@@ -0,0 +1,28 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :figaro do
3
+ _cset :figaro_yaml, true
4
+ _cset :figaro_symlink, true
5
+ _cset(:figaro_output) { "#{shared_path}/application.yml" }
6
+ _cset(:figaro_config) { "#{latest_release}/config/application.yml" }
7
+
8
+ task :config, roles: :app do
9
+ figaro_tmpfile = "figaro-#{rails_env}"
10
+
11
+ if figaro_yaml
12
+ figaro_cmd = %Q(Figaro.env("#{rails_env}").to_yaml)
13
+ else
14
+ figaro_cmd = %Q(Figaro.vars("#{rails_env}").split)
15
+ end
16
+
17
+ run_locally "bundle exec rails runner 'puts #{figaro_cmd}' > #{figaro_tmpfile}"
18
+ transfer :up, figaro_tmpfile, figaro_output, via: :scp
19
+ run_locally "rm #{figaro_tmpfile}"
20
+ end
21
+ end
22
+
23
+ after 'deploy:setup', 'figaro:config'
24
+
25
+ after 'deploy:finalize_update' do
26
+ run "ln -sf #{figaro_output} #{figaro_config}" if figaro_symlink
27
+ end
28
+ end
@@ -0,0 +1,43 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :foreman do
3
+ desc <<-DESC
4
+ Export the Procfile to upstart. Will use sudo if available.
5
+
6
+ You can override any of these defaults by setting the variables shown below.
7
+
8
+ set :foreman_format, "upstart"
9
+ set :foreman_location, "/etc/init"
10
+ set :foreman_procfile, "Procfile"
11
+ set :foreman_root, release_path
12
+ set :foreman_port, 5000
13
+ set :foreman_app, application
14
+ set :foreman_user, user
15
+ set :foreman_log, 'shared_path/log'
16
+ set :foreman_concurrency, false
17
+ DESC
18
+ task :export, roles: :app do
19
+ bundle_cmd = fetch(:bundle_cmd, "bundle")
20
+ foreman_format = fetch(:foreman_format, "upstart")
21
+ foreman_location = fetch(:foreman_location, "/etc/init")
22
+ foreman_procfile = fetch(:foreman_procfile, "Procfile")
23
+ foreman_port = fetch(:foreman_port, 5000)
24
+ foreman_root = fetch(:foreman_root, current_path)
25
+ foreman_app = fetch(:foreman_app, application)
26
+ foreman_user = fetch(:foreman_user, user)
27
+ foreman_log = fetch(:foreman_log, "#{shared_path}/log")
28
+ foreman_concurrency = fetch(:foreman_concurrency, false)
29
+
30
+ args = ["#{foreman_format} #{foreman_location}"]
31
+ args << "-f #{foreman_procfile}"
32
+ args << "-p #{foreman_port}"
33
+ args << "-d #{foreman_root}"
34
+ args << "-a #{foreman_app}"
35
+ args << "-u #{foreman_user}"
36
+ args << "-l #{foreman_log}"
37
+ args << "-c #{foreman_concurrency}" if foreman_concurrency
38
+ run "cd #{release_path} && #{sudo} #{bundle_cmd} exec foreman export #{args.join(' ')}"
39
+ end
40
+ end
41
+
42
+ after 'deploy:update', 'foreman:export'
43
+ end
@@ -0,0 +1,21 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :local do
3
+ desc 'Run the precompile task locally and rsync with shared'
4
+ task :assets, roles: :web, except: { no_release: true } do
5
+ remote_path = "#{user}@#{domain}:#{shared_path}"
6
+
7
+ run_locally "bundle exec rake assets:precompile"
8
+ run_locally "rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{remote_path}"
9
+ run_locally "bundle exec rake assets:clean"
10
+ end
11
+ end
12
+
13
+ # TODO: allow to turn it off
14
+ namespace :deploy do
15
+ namespace :assets do
16
+ task :precompile, roles: :web, except: { no_release: true } do
17
+ local.assets
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :upstart do
3
+ desc "Start the application services"
4
+ task :start, roles: :app do
5
+ run "#{sudo} service #{application} start"
6
+ end
7
+
8
+ desc "Stop the application services"
9
+ task :stop, roles: :app do
10
+ run "#{sudo} service #{application} stop"
11
+ end
12
+
13
+ desc "Restart the application services"
14
+ task :restart, roles: :app do
15
+ run "#{sudo} service #{application} start || #{sudo} service #{application} restart"
16
+ end
17
+ end
18
+
19
+ after 'deploy:restart', 'upstart:restart'
20
+ end
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+ require 'mab'
3
+
4
+ module Plur
5
+ module Helpers
6
+ module View
7
+ def current_locale
8
+ I18n.locale.to_s
9
+ end
10
+
11
+ def rtl_locales
12
+ %w(ar ckb fa he ug)
13
+ end
14
+
15
+ def rtl?
16
+ rtl_locales.include? current_locale
17
+ end
18
+
19
+ def orientation
20
+ rtl? ? 'rtl' : 'ltr'
21
+ end
22
+
23
+ def notifications
24
+ return if flash.blank?
25
+
26
+ map_classes = {
27
+ notice: 'alert-success',
28
+ alert: 'alert-error'
29
+ }
30
+
31
+ build_html do
32
+ div class: 'notifications' do
33
+ flash.each do |name, msg|
34
+ if msg.is_a? String
35
+ classes = ['alert', map_classes[name], 'fadeout']
36
+ div msg, :class => classes.join(' '), 'data-dismiss' => 'alert'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def namespace_name
44
+ splitted = controller.class.name.split('::')
45
+ (splitted.size > 1) ? splitted.first.downcase : nil
46
+ end
47
+
48
+ def body_attributes
49
+ classes = []
50
+ classes << [controller_name, action_name].join('-')
51
+ classes << namespace_name unless namespace_name.nil?
52
+ classes << orientation
53
+
54
+ { dir: orientation, class: classes.join(' ') }
55
+ end
56
+
57
+ def build_html(assigns = {}, &block)
58
+ ::Mab::PrettyBuilder.new(assigns, self, &block).to_s.html_safe
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,9 @@
1
+ require 'plur/helpers/view'
2
+
3
+ module Plur
4
+ class Railtie < ::Rails::Railtie
5
+ initializer 'plur.view_helpers' do
6
+ ActionView::Base.send :include, Plur::Helpers::View
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Plur
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'mab', '~> 0.0.2'
19
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mab
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.2
14
30
  description: Quite useful things
15
31
  email:
16
32
  - subosito@gmail.com
@@ -25,6 +41,12 @@ files:
25
41
  - Rakefile
26
42
  - lib/plur.rb
27
43
  - lib/plur/capistrano.rb
44
+ - lib/plur/capistrano/figaro.rb
45
+ - lib/plur/capistrano/foreman.rb
46
+ - lib/plur/capistrano/local.rb
47
+ - lib/plur/capistrano/upstart.rb
48
+ - lib/plur/helpers/view.rb
49
+ - lib/plur/railtie.rb
28
50
  - lib/plur/version.rb
29
51
  - plur.gemspec
30
52
  homepage: https://github.com/subosito/plur