Skip to content
This repository
Browse code

Swap Pathname.new for File.join where possible, no digests and asset …

…syncing in dev environment
  • Loading branch information...
commit 5f679c3bbde053e9b81aff43d05ff3c78d527f98 1 parent 6065338
Jack Chu kamui authored

Showing 1 changed file with 14 additions and 11 deletions. Show diff stats Hide diff stats

  1. +14 11 app/models/deploy.rb
25 app/models/deploy.rb
@@ -22,30 +22,29 @@ def self.perform(project_name)
22 22 release.save
23 23
24 24 Dir.mktmpdir(project.name) do |project_dir|
25   - project_dir = Pathname.new(project_dir)
26   - repo_dir = project_dir.join('repo')
  25 + repo_dir = File.join(project_dir, 'repo')
27 26 FileUtils.mkdir_p(repo_dir)
28   - assets_dir = project_dir.join('assets')
  27 + assets_dir = File.join(project_dir, 'assets')
29 28 FileUtils.mkdir_p(assets_dir)
30   - public_dir = project_dir.join('public')
  29 + public_dir = File.join(project_dir, 'public')
31 30 FileUtils.mkdir_p(public_dir)
32 31
33 32 begin
34 33 # clone repo
35   - clone_repo(repo_dir.to_s, project.repo, release.branch)
  34 + clone_repo(repo_dir, project.repo, release.branch)
36 35
37 36 # TODO: Alert people
38 37 begin
39   - copy_assets(repo_dir.to_s, assets_dir.join(project.name))
  38 + copy_assets(repo_dir, File.join(assets_dir, project.name))
40 39 rescue Timeout::Error => e
41 40 release.status = e.message
42 41 release.save
43 42 raise
44 43 end
45 44
46   - compile_assets(project.name, assets_dir.to_s, public_dir.to_s)
  45 + compile_assets(project.name, assets_dir, public_dir)
47 46
48   - self.generate_views(project.name, repo_dir.to_s)
  47 + self.generate_views(project.name, repo_dir)
49 48
50 49 release.go_live
51 50 project.touch
@@ -83,7 +82,7 @@ def self.compile_assets(project_name, assets_dir, public_dir)
83 82 public_asset_path = File.join(Rails.public_path, app.config.assets.prefix)
84 83 public_dir = Rails.root.join('tmp', 'public_assets', project_name) if Rails.env.development?
85 84
86   - manifest_path = app.config.assets.manifest ? Pathname.new(app.config.assets.manifest).join(project_name) : Pathname.new(public_dir).join(project_name)
  85 + manifest_path = app.config.assets.manifest ? File.join(app.config.assets.manifest, project_name) : File.join(public_dir, project_name)
87 86 manifest = File.join(manifest_path, "manifest.yml")
88 87
89 88 assets = app.assets.dup
@@ -91,18 +90,22 @@ def self.compile_assets(project_name, assets_dir, public_dir)
91 90 assets.instance_variable_get(:@trail).instance_variable_set(:@paths, app.assets.instance_variable_get(:@trail).instance_variable_get(:@paths).dup)
92 91 assets.append_path(assets_dir)
93 92
  93 + digest = Rails.env.development? ? false : true
  94 +
94 95 compiler = Sprockets::StaticCompiler.new(assets,
95 96 public_dir,
96 97 app.config.assets.precompile,
97 98 manifest_path: manifest_path,
98   - digest: true,
  99 + digest: digest,
99 100 manifest: true)
100 101
101 102 compiler.compile
102 103
103 104 raise "Couldn't find manifest.yml" unless File.exists?(manifest)
  105 +
  106 + FileUtils.rm_r(File.join(public_asset_path, project_name), secure: true) if Dir.exists?(File.join(public_asset_path, project_name))
104 107 FileUtils.cp_r("#{public_dir}/.", public_asset_path)
105   - AssetSync.sync
  108 + AssetSync.sync unless Rails.env.development?
106 109 Rails.cache.write("digests:#{project_name}", YAML.load_file(manifest))
107 110 end
108 111

0 comments on commit 5f679c3

Please sign in to comment.
Something went wrong with that request. Please try again.