Skip to content

Commit 8d610de

Browse files
committed
Importing theme works with ruby 1.9.2 + clean code
1 parent d0a089f commit 8d610de

File tree

8 files changed

+32
-24
lines changed

8 files changed

+32
-24
lines changed

Gemfile.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: git://github.com/floehopper/mocha.git
3-
revision: 1ed96f77a967b497746176e0b8a46746f5b4d722
3+
revision: 9de0e619d46ba50c938fb1d24d30e931c38ebef1
44
specs:
55
mocha (0.9.10.20101125155727)
66
rake
@@ -42,7 +42,7 @@ GEM
4242
arel (2.0.6)
4343
autotest (4.4.6)
4444
ZenTest (>= 4.4.1)
45-
bcrypt-ruby (2.1.2)
45+
bcrypt-ruby (2.1.3)
4646
bson (1.1.5)
4747
bson_ext (1.1.5)
4848
builder (2.1.2)
@@ -56,7 +56,7 @@ GEM
5656
selenium-webdriver (>= 0.0.27)
5757
xpath (~> 0.1.2)
5858
celerity (0.8.6)
59-
childprocess (0.1.4)
59+
childprocess (0.1.6)
6060
ffi (~> 0.6.3)
6161
closure-compiler (0.3.3)
6262
columnize (0.3.2)
@@ -89,7 +89,7 @@ GEM
8989
diff-lcs (1.1.2)
9090
erubis (2.6.6)
9191
abstract (>= 1.0.0)
92-
excon (0.3.4)
92+
excon (0.3.6)
9393
factory_girl (1.3.2)
9494
factory_girl_rails (1.0)
9595
factory_girl (~> 1.3)
@@ -115,7 +115,7 @@ GEM
115115
growl-glue (1.0.7)
116116
haml (3.0.18)
117117
has_scope (0.5.0)
118-
heroku (1.14.10)
118+
heroku (1.15.1)
119119
json_pure (>= 1.2.0, < 1.5.0)
120120
launchy (~> 0.3.2)
121121
rest-client (>= 1.4.0, < 1.7.0)
@@ -134,7 +134,7 @@ GEM
134134
s3 (>= 0.3.7)
135135
json (1.4.6)
136136
json_pure (1.4.6)
137-
kgio (2.0.0)
137+
kgio (2.1.1)
138138
launchy (0.3.7)
139139
configuration (>= 0.0.5)
140140
rake (>= 0.8.1)
@@ -147,7 +147,7 @@ GEM
147147
locomotive_mongoid_acts_as_tree (0.1.5.1)
148148
bson (>= 0.20.1)
149149
mongoid (<= 2.0.0.beta.19)
150-
mail (2.2.12)
150+
mail (2.2.13)
151151
activesupport (>= 2.3.6)
152152
i18n (>= 0.4.0)
153153
mime-types (~> 1.16)
@@ -226,8 +226,8 @@ GEM
226226
rubyzip (0.9.4)
227227
s3 (0.3.7)
228228
proxies
229-
selenium-webdriver (0.1.1)
230-
childprocess (= 0.1.4)
229+
selenium-webdriver (0.1.2)
230+
childprocess (~> 0.1.5)
231231
ffi (~> 0.6.3)
232232
json_pure
233233
rubyzip
@@ -238,15 +238,15 @@ GEM
238238
polyglot (>= 0.3.1)
239239
trollop (1.16.2)
240240
tzinfo (0.3.23)
241-
unicorn (3.1.0)
242-
kgio (~> 2.0.0)
241+
unicorn (3.2.1)
242+
kgio (~> 2.1)
243243
rack
244244
warden (0.10.7)
245245
rack (>= 1.0.0)
246246
will_paginate (3.0.pre2)
247247
xpath (0.1.2)
248248
nokogiri (~> 1.3)
249-
yard (0.6.3)
249+
yard (0.6.4)
250250
yui-compressor (0.9.1)
251251

252252
PLATFORMS

app/controllers/admin/imports_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def create
2828
:reset => Boolean.set(params[:reset])
2929
})
3030

31-
flash[:notice] = t('flash.admin.imports.create.notice')
31+
flash[:notice] = t("flash.admin.imports.create.#{Locomotive.config.delayed_job ? 'notice' : 'done'}")
3232

3333
redirect_to Locomotive.config.delayed_job ? admin_import_url : new_admin_import_url
3434
rescue

app/controllers/admin/installation_controller.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def handle_post
4444
@site.save
4545

4646
if @site.valid?
47-
# begin
48-
unless params[:zipfile].blank?
49-
Locomotive::Import::Job.run!(params[:zipfile], @site, { :samples => true })
47+
begin
48+
unless params[:zipfile].blank?
49+
Locomotive::Import::Job.run!(params[:zipfile], @site, { :samples => true })
50+
end
51+
rescue Exception => e
52+
logger.error "Import failed because of #{e.message}"
5053
end
51-
# rescue Exception => e
52-
# logger.error "Import failed because of #{e.message}"
53-
# end
5454

5555
redirect_to admin_session_url(:host => Site.first.domains.first, :port => request.port)
5656
else

config/locales/flash.en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,6 @@ en:
111111

112112
imports:
113113
create:
114+
done: "Your site was successfully updated."
114115
notice: "Your site is being updated."
115116
alert: "The import was not done."

config/locales/flash.fr.yml

+1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,6 @@ fr:
111111

112112
imports:
113113
create:
114+
done: "Votre site a été mis à jour"
114115
notice: "Votre site est en train d'être mis à jour"
115116
alert: "L'import n'a pas pu se faire"

doc/TODO

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

1010
BACKLOG:
1111

lib/locomotive/import/job.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def initialize(zipfile, site, options = {})
1717
@identifier = self.store_zipfile(zipfile)
1818

1919
raise "Theme identifier not found" if @identifier.blank?
20+
21+
@uploader = nil # fix issue with Ruby 1.9.2 and serialization
2022
end
2123

2224
def before(worker)
@@ -95,11 +97,10 @@ def store_zipfile(zipfile)
9597

9698
begin
9799
uploader.store!(file)
100+
uploader.identifier
98101
rescue CarrierWave::IntegrityError
99-
return nil
102+
nil
100103
end
101-
102-
uploader.identifier
103104
end
104105

105106
def retrieve_zipfile

script/delayed_job

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

0 commit comments

Comments
 (0)