porter 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.4
@@ -39,34 +39,36 @@ namespace :porter do
39
39
 
40
40
  task :assets => :environment do
41
41
  require 'yaml'
42
- root = RAILS_ROOT
43
- config = YAML.load_file(File.join(RAILS_ROOT, 'config', 'porter_config.yml'))
44
- user = config['server']['user']
45
- domain = config['server']['domain']
46
- dir = config['server']['dir']
47
- model = config['assets']['model'].constantize
48
- column = config['assets']['column']
49
- exclusions = config['assets']['exclusions'].blank? ? '' : config['assets']['exclusions'].split(',').map { |i| i.strip }
50
- rsync_options = config['assets']['rsync_options']
51
-
52
- excluding = exclusions.blank? ? '' : "(excluding: #{config['assets']['exclusions']} files) "
53
- puts "Building a list of assets #{excluding}to rsync down..."
42
+ root = RAILS_ROOT
43
+ config = YAML.load_file(File.join(RAILS_ROOT, 'config', 'porter_config.yml'))
44
+ user = config['server']['user']
45
+ domain = config['server']['domain']
46
+ dir = config['server']['dir']
47
+ entire_dirs = config['assets']['entire_dirs'].blank? ? '' : config['assets']['entire_dirs'].split(',').map { |i| i.strip }
48
+ excludable_dir = config['assets']['excludable_dir']
49
+ model = config['assets']['excludable_model'].constantize unless config['assets']['excludable_model'].blank?
50
+ column = config['assets']['excludable_column']
51
+ exclusions = config['assets']['excludable_matches'].blank? ? '' : config['assets']['excludable_matches'].split(',').map { |i| i.strip }
52
+ rsync_options = config['assets']['rsync_options']
54
53
 
55
- unless exclusions.blank?
54
+ if exclusions.blank?
55
+ entire_dirs << excludable_dir unless excludable_dir.blank?
56
+ else
57
+ puts "Building a list of excludable assets (excluding: #{exclusions.join(', ')}) to rsync down..."
56
58
  rsync_file_list = File.new('rsync_file_list.txt', "w")
57
59
  attachments = model.find(:all, :conditions => ["#{column} NOT IN (?)", exclusions])
58
60
  attachments.each do |a|
59
- rsync_file_list.send((a == attachments.last ? :print : :puts), ('attachments/' + a.partitioned_path.join('/')))
61
+ rsync_file_list.send((a == attachments.last ? :print : :puts), a.partitioned_path.join('/'))
60
62
  end
61
63
  rsync_file_list.close
64
+ system "rsync --files-from=#{root}/rsync_file_list.txt #{rsync_options} #{user}@#{domain}:#{dir}/shared/#{excludable_dir}/ #{excludable_dir}"
65
+ system "rm #{root}/rsync_file_list.txt" if File.exists?("#{root}/rsync_file_list.txt")
62
66
  end
63
67
 
64
- rsync_list_command = exclusions.blank? ? '' : "--files-from=#{root}/rsync_file_list.txt "
65
-
66
- puts "Synchronizing with production assets..."
67
- system "rsync #{rsync_list_command}#{rsync_options} --exclude 'plugin_assets' #{user}@#{domain}:#{dir}/shared/public/ public"
68
-
69
- system "rm #{root}/rsync_file_list.txt" if File.exists?("#{root}/rsync_file_list.txt")
68
+ entire_dirs.each do |d|
69
+ puts "Synchronizing assets in #{d}..."
70
+ system "rsync #{rsync_options} #{user}@#{domain}:#{dir}/shared/#{d}/ #{d}"
71
+ end
70
72
 
71
73
  puts "Production asset synchronization complete"
72
74
  end
@@ -6,15 +6,19 @@ server:
6
6
  dir: /opt/apps/<%= app %>
7
7
 
8
8
  assets:
9
- model: Attachment
10
- column: attachable_type
11
- exclusions:
9
+ entire_dirs: public/attachments
10
+ excludable_dir:
11
+ excludable_model:
12
+ excludable_column:
13
+ excludable_matches:
12
14
  rsync_options: --verbose --progress --stats --recursive --times --compress
13
15
 
14
16
  # Example:
15
- #
17
+ #
16
18
  # assets:
17
- # model: Attachment
18
- # column: attachable_type
19
- # exclusions: NULL, Design, Item, Placement
20
- # rsync_options: --verbose --progress --stats --recursive --times --compress
19
+ # entire_dirs:
20
+ # excludable_dir: public/attachments
21
+ # excludable_model: Attachment
22
+ # excludable_column: attachable_type
23
+ # excludable_matches: NULL, Design, Item, Placement
24
+ # rsync_options: --verbose --progress --stats --recursive --times --compress
data/porter.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{porter}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kenny Johnston"]
12
- s.date = %q{2010-06-22}
12
+ s.date = %q{2010-07-02}
13
13
  s.description = %q{Capistrano and Rake tasks for cloning production database and assets to development.}
14
14
  s.email = %q{info@appcreations.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: porter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kenny Johnston
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-22 00:00:00 -07:00
18
+ date: 2010-07-02 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency