mina 0.1.2 → 0.1.3.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,37 +1,43 @@
1
- v0.1.2 - Jul 06, 2012
2
- ---------------------
1
+ v0.1.3 - Jul 13, 2012 (Unreleased)
2
+ ----------------------------------
3
3
 
4
4
  ### Fixed:
5
- * __Show stdout output properly on deploy.__
6
- * 'mina rake' now works.
5
+ * [pre1] Respect the `bundle_bin` setting when doing `bundle exec` in Rails commands. (#29)
6
+ * [pre1] Doing `rails:assets_precompile` now properly skips asset compilation if not needed. (#25)
7
+
8
+ ### Added:
9
+ * [pre1] Doing `rails:db_migrate` now skips doing migrations if they're not needed. (#18)
10
+ * [pre1] Added the `mina console` command for Rails.
11
+ * [pre1] Make asset paths configurable using the `asset_paths` setting.
7
12
 
8
13
  ### Changed:
9
- * Refactor pretty printing to be simpler, cleaner, and extensible.
10
- * Show prettier abort messages when ^C'd.
11
- * Use the new error message format. (See lib/mina/output_helpers.rb)
14
+ * [pre1] Refactor pretty printing to be simpler, cleaner, and extensible.
15
+ * [pre1] Show prettier abort messages when ^C'd.
12
16
 
13
- v0.1.2.pre2 - Jul 03, 2012
14
- --------------------------
17
+ v0.1.2 - Jul 06, 2012
18
+ ---------------------
15
19
 
16
- ### Added:
17
- * Add `:bundle_bin` option.
18
- * Add `:ssh` port option.
20
+ This release had two prereleases: v0.1.2.pre1 and v0.1.2.pre2.
19
21
 
20
22
  ### Fixed:
21
- * __Fix `deploy:link_shared_paths` to use absolute paths.__
22
- * Fix console logs for task init.
23
-
24
- v0.1.2.pre1 - Jun 12, 2012
25
- --------------------------
23
+ * __Show stdout output properly on deploy.__
24
+ * 'mina rake' now works.
25
+ * [.pre2] __Fix `deploy:link_shared_paths` to use absolute paths.__
26
+ * [.pre2] Fix console logs for task init.
27
+ * [.pre1] __Fixed JRuby support.__
28
+ * [.pre1] __Respect .bashrc.__ (#5)
26
29
 
27
- ### Fixed:
28
- * __Fixed JRuby support.__
29
- * __Respect .bashrc.__ (#5)
30
+ ### Added:
31
+ * [.pre2] Add `:bundle_bin` option.
32
+ * [.pre2] Add `:ssh` port option.
30
33
 
31
- ### Changed:
32
- * Implement `ssh("..", return: true)`.
33
- * Rename `simulate_mode` to `simulate_mode?`. Same with `verbose_mode?`.
34
- * Show the SSH command in the simulation output.
34
+ ### Changed: (v0.1.2)
35
+ * Refactor pretty printing to be simpler, cleaner, and extensible.
36
+ * Show prettier abort messages when ^C'd.
37
+ * Use the new error message format. (See lib/mina/output_helpers.rb)
38
+ * [.pre1] Implement `ssh("..", return: true)`.
39
+ * [.pre1] Rename `simulate_mode` to `simulate_mode?`. Same with `verbose_mode?`.
40
+ * [.pre1] Show the SSH command in the simulation output.
35
41
 
36
42
  v0.1.1 - Jun 07, 2012
37
43
  ---------------------
data/lib/mina/helpers.rb CHANGED
@@ -155,6 +155,10 @@ module Mina
155
155
  code.strip
156
156
  end
157
157
 
158
+ def reindent(n, code)
159
+ indent n, unindent(code)
160
+ end
161
+
158
162
  # Returns an array of queued code strings.
159
163
  #
160
164
  # You may give an optional `aspect`.
@@ -68,6 +68,7 @@ module Mina
68
68
  trap "INT" do
69
69
  puts ""
70
70
  print_status "Mina: SIGINT received."
71
+ Process.kill "TERM", pid
71
72
  end
72
73
 
73
74
  # Read stderr in the background.
data/lib/mina/rails.rb CHANGED
@@ -1,8 +1,11 @@
1
+ require 'mina/bundler'
2
+
1
3
  settings.rails_env ||= 'production'
2
4
  # TODO: This should be lambda
3
- settings.bundle_prefix ||= lambda { %{RAILS_ENV="#{rails_env}" bundle exec} }
5
+ settings.bundle_prefix ||= lambda { %{RAILS_ENV="#{rails_env}" #{bundle_bin} exec} }
4
6
  settings.rake ||= lambda { %{#{bundle_prefix} rake} }
5
7
  settings.rails ||= lambda { %{#{bundle_prefix} rails} }
8
+ settings.asset_paths ||= ['vendor/assets/', 'app/assets/']
6
9
 
7
10
  # Macro used later by :rails, :rake, etc
8
11
  make_run_task = lambda { |name, sample_args|
@@ -17,15 +20,70 @@ make_run_task = lambda { |name, sample_args|
17
20
  end
18
21
  }
19
22
 
23
+ def check_for_changes_script(options={})
24
+ diffs = options[:at].map { |path|
25
+ %[diff -r "#{deploy_to}/#{current_path}/#{path}" "./#{path}" 2>/dev/null]
26
+ }.join("\n")
27
+
28
+ unindent %[
29
+ if [ -e "#{deploy_to}/#{current_path}/#{options[:check]}" ]; then
30
+ count=`(
31
+ #{reindent 4, diffs}
32
+ ) | wc -l`
33
+
34
+ if [ "$((count))" = "0" ]; then
35
+ #{reindent 4, options[:skip]} &&
36
+ exit
37
+ else
38
+ #{reindent 4, options[:changed]}
39
+ fi
40
+ else
41
+ #{reindent 2, options[:default]}
42
+ fi
43
+ ]
44
+ end
45
+
20
46
  desc "Execute a Rails command in the current deploy."
21
47
  make_run_task[:rails, 'console']
22
48
 
23
49
  desc "Execute a Rake command in the current deploy."
24
50
  make_run_task[:rake, 'db:migrate']
25
51
 
52
+ desc "Starts an interactive console."
53
+ task :console do
54
+ queue echo_cmd %[cd "#{deploy_to!}/#{current_path!}" && #{rails} console]
55
+ end
56
+
26
57
  namespace :rails do
27
- desc "Migrates the Rails database."
58
+ desc "Migrates the Rails database (skips if nothing has changed since the last release)."
28
59
  task :db_migrate do
60
+ if ENV['force_migrate']
61
+ invoke :'rails:db_migrate:force'
62
+ return
63
+ end
64
+
65
+ message = verbose_mode? ?
66
+ '$((count)) changes found, migrating database' :
67
+ 'Migrating database'
68
+
69
+ queue check_for_changes_script \
70
+ check: 'db/schema.rb',
71
+ at: ['db/schema.rb'],
72
+ skip: %[
73
+ echo "-----> DB schema unchanged; skipping DB migration"
74
+ ],
75
+ changed: %[
76
+ echo "-----> #{message}"
77
+ #{echo_cmd %[#{rake} db:migrate]}
78
+ ],
79
+ default: %[
80
+ echo "-----> Migrating database"
81
+ #{echo_cmd %[#{rake} db:migrate]}
82
+ ]
83
+ end
84
+
85
+ desc "Migrates the Rails database."
86
+ task :'db_migrate:force' do
29
87
  queue %{
30
88
  echo "-----> Migrating database"
31
89
  #{echo_cmd %[#{rake} db:migrate]}
@@ -47,24 +105,25 @@ namespace :rails do
47
105
  return
48
106
  end
49
107
 
50
- queue %{
51
- # Check if the last deploy has assets built, and if it can be re-used.
52
- if [ -d "#{current_path}/public/assets" ]; then
53
- count=`(
54
- diff -r "#{current_path}/vendor/assets/" "./vendor/assets/" 2>/dev/null;
55
- diff -r "#{current_path}/app/assets/" "./app/assets/" 2>/dev/null
56
- ) | wc -l`
57
-
58
- if [ "$((count))" = "0" ]; then
59
- echo "-----> Skipping asset precompilation"
60
- #{echo_cmd %[cp -R "#{current_path}/public/assets" "./public/assets"]} &&
61
- exit
62
- fi
63
- fi
108
+ message = verbose_mode? ?
109
+ '$((count)) changes found, precompiling asset files' :
110
+ 'Precompiling asset files'
64
111
 
65
- echo "-----> Precompiling asset files"
66
- #{echo_cmd %[#{rake} assets:precompile]}
67
- }
112
+ queue check_for_changes_script \
113
+ check: 'public/assets/',
114
+ at: [*asset_paths],
115
+ skip: %[
116
+ echo "-----> Skipping asset precompilation"
117
+ #{echo_cmd %[cp -R "#{deploy_to}/#{current_path}/public/assets" "./public/assets"]}
118
+ ],
119
+ changed: %[
120
+ echo "-----> #{message}"
121
+ #{echo_cmd %[#{rake} assets:precompile]}
122
+ ],
123
+ default: %[
124
+ echo "-----> Precompiling asset files"
125
+ #{echo_cmd %[#{rake} assets:precompile]}
126
+ ]
68
127
  end
69
128
 
70
129
  end
data/lib/mina/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  def self.version
3
- "0.1.2"
3
+ "0.1.3.pre1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3.pre1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rico Sta. Cruz
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-06 00:00:00.000000000 Z
13
+ date: 2012-07-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -125,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  none: false
127
127
  requirements:
128
- - - ! '>='
128
+ - - ! '>'
129
129
  - !ruby/object:Gem::Version
130
- version: '0'
130
+ version: 1.3.1
131
131
  requirements: []
132
132
  rubyforge_project:
133
133
  rubygems_version: 1.8.23