Importing theme works with ruby 1.9.2 + clean code

This commit is contained in:
dinedine 2010-12-27 12:59:54 +01:00
parent d0a089fb77
commit 8d610dee49
8 changed files with 32 additions and 24 deletions

View File

@ -1,6 +1,6 @@
GIT GIT
remote: git://github.com/floehopper/mocha.git remote: git://github.com/floehopper/mocha.git
revision: 1ed96f77a967b497746176e0b8a46746f5b4d722 revision: 9de0e619d46ba50c938fb1d24d30e931c38ebef1
specs: specs:
mocha (0.9.10.20101125155727) mocha (0.9.10.20101125155727)
rake rake
@ -42,7 +42,7 @@ GEM
arel (2.0.6) arel (2.0.6)
autotest (4.4.6) autotest (4.4.6)
ZenTest (>= 4.4.1) ZenTest (>= 4.4.1)
bcrypt-ruby (2.1.2) bcrypt-ruby (2.1.3)
bson (1.1.5) bson (1.1.5)
bson_ext (1.1.5) bson_ext (1.1.5)
builder (2.1.2) builder (2.1.2)
@ -56,7 +56,7 @@ GEM
selenium-webdriver (>= 0.0.27) selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.2) xpath (~> 0.1.2)
celerity (0.8.6) celerity (0.8.6)
childprocess (0.1.4) childprocess (0.1.6)
ffi (~> 0.6.3) ffi (~> 0.6.3)
closure-compiler (0.3.3) closure-compiler (0.3.3)
columnize (0.3.2) columnize (0.3.2)
@ -89,7 +89,7 @@ GEM
diff-lcs (1.1.2) diff-lcs (1.1.2)
erubis (2.6.6) erubis (2.6.6)
abstract (>= 1.0.0) abstract (>= 1.0.0)
excon (0.3.4) excon (0.3.6)
factory_girl (1.3.2) factory_girl (1.3.2)
factory_girl_rails (1.0) factory_girl_rails (1.0)
factory_girl (~> 1.3) factory_girl (~> 1.3)
@ -115,7 +115,7 @@ GEM
growl-glue (1.0.7) growl-glue (1.0.7)
haml (3.0.18) haml (3.0.18)
has_scope (0.5.0) has_scope (0.5.0)
heroku (1.14.10) heroku (1.15.1)
json_pure (>= 1.2.0, < 1.5.0) json_pure (>= 1.2.0, < 1.5.0)
launchy (~> 0.3.2) launchy (~> 0.3.2)
rest-client (>= 1.4.0, < 1.7.0) rest-client (>= 1.4.0, < 1.7.0)
@ -134,7 +134,7 @@ GEM
s3 (>= 0.3.7) s3 (>= 0.3.7)
json (1.4.6) json (1.4.6)
json_pure (1.4.6) json_pure (1.4.6)
kgio (2.0.0) kgio (2.1.1)
launchy (0.3.7) launchy (0.3.7)
configuration (>= 0.0.5) configuration (>= 0.0.5)
rake (>= 0.8.1) rake (>= 0.8.1)
@ -147,7 +147,7 @@ GEM
locomotive_mongoid_acts_as_tree (0.1.5.1) locomotive_mongoid_acts_as_tree (0.1.5.1)
bson (>= 0.20.1) bson (>= 0.20.1)
mongoid (<= 2.0.0.beta.19) mongoid (<= 2.0.0.beta.19)
mail (2.2.12) mail (2.2.13)
activesupport (>= 2.3.6) activesupport (>= 2.3.6)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
@ -226,8 +226,8 @@ GEM
rubyzip (0.9.4) rubyzip (0.9.4)
s3 (0.3.7) s3 (0.3.7)
proxies proxies
selenium-webdriver (0.1.1) selenium-webdriver (0.1.2)
childprocess (= 0.1.4) childprocess (~> 0.1.5)
ffi (~> 0.6.3) ffi (~> 0.6.3)
json_pure json_pure
rubyzip rubyzip
@ -238,15 +238,15 @@ GEM
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
trollop (1.16.2) trollop (1.16.2)
tzinfo (0.3.23) tzinfo (0.3.23)
unicorn (3.1.0) unicorn (3.2.1)
kgio (~> 2.0.0) kgio (~> 2.1)
rack rack
warden (0.10.7) warden (0.10.7)
rack (>= 1.0.0) rack (>= 1.0.0)
will_paginate (3.0.pre2) will_paginate (3.0.pre2)
xpath (0.1.2) xpath (0.1.2)
nokogiri (~> 1.3) nokogiri (~> 1.3)
yard (0.6.3) yard (0.6.4)
yui-compressor (0.9.1) yui-compressor (0.9.1)
PLATFORMS PLATFORMS

View File

@ -28,7 +28,7 @@ module Admin
:reset => Boolean.set(params[:reset]) :reset => Boolean.set(params[:reset])
}) })
flash[:notice] = t('flash.admin.imports.create.notice') flash[:notice] = t("flash.admin.imports.create.#{Locomotive.config.delayed_job ? 'notice' : 'done'}")
redirect_to Locomotive.config.delayed_job ? admin_import_url : new_admin_import_url redirect_to Locomotive.config.delayed_job ? admin_import_url : new_admin_import_url
rescue rescue

View File

@ -44,13 +44,13 @@ module Admin
@site.save @site.save
if @site.valid? if @site.valid?
# begin begin
unless params[:zipfile].blank? unless params[:zipfile].blank?
Locomotive::Import::Job.run!(params[:zipfile], @site, { :samples => true }) Locomotive::Import::Job.run!(params[:zipfile], @site, { :samples => true })
end end
# rescue Exception => e rescue Exception => e
# logger.error "Import failed because of #{e.message}" logger.error "Import failed because of #{e.message}"
# end end
redirect_to admin_session_url(:host => Site.first.domains.first, :port => request.port) redirect_to admin_session_url(:host => Site.first.domains.first, :port => request.port)
else else

View File

@ -111,5 +111,6 @@ en:
imports: imports:
create: create:
done: "Your site was successfully updated."
notice: "Your site is being updated." notice: "Your site is being updated."
alert: "The import was not done." alert: "The import was not done."

View File

@ -111,5 +111,6 @@ fr:
imports: imports:
create: create:
done: "Votre site a été mis à jour"
notice: "Votre site est en train d'être mis à jour" notice: "Votre site est en train d'être mis à jour"
alert: "L'import n'a pas pu se faire" alert: "L'import n'a pas pu se faire"

View File

@ -4,8 +4,8 @@ x jammit-s3: assets
x copy assets.yml config file when using it as gem (http://asciicasts.com/episodes/218-making-generators-in-rails-3) x copy assets.yml config file when using it as gem (http://asciicasts.com/episodes/218-making-generators-in-rails-3)
x import theme without delayed_job x import theme without delayed_job
x rspec 2.3 x rspec 2.3
- ruby 1.9.2: x ruby 1.9.2:
- DelayedJob not working x DelayedJob not working
BACKLOG: BACKLOG:

View File

@ -17,6 +17,8 @@ module Locomotive
@identifier = self.store_zipfile(zipfile) @identifier = self.store_zipfile(zipfile)
raise "Theme identifier not found" if @identifier.blank? raise "Theme identifier not found" if @identifier.blank?
@uploader = nil # fix issue with Ruby 1.9.2 and serialization
end end
def before(worker) def before(worker)
@ -95,11 +97,10 @@ module Locomotive
begin begin
uploader.store!(file) uploader.store!(file)
rescue CarrierWave::IntegrityError
return nil
end
uploader.identifier uploader.identifier
rescue CarrierWave::IntegrityError
nil
end
end end
def retrieve_zipfile def retrieve_zipfile

5
script/delayed_job Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize