overlay 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80ccbfd578014c00094c8eb7b434a5ca509c75eb
4
- data.tar.gz: cdd707ea7987ecbe0ac9cc01a872323408240099
3
+ metadata.gz: 13630f419fcc1df76230779d926555c3fe01fd45
4
+ data.tar.gz: 0da3f0f3557e2d3f72cca034d1851cc9b90f16d5
5
5
  SHA512:
6
- metadata.gz: 02ff926a5c3600648642ce92f802b044ed97c0643a7faaf450012b807d8090757e8777b8de9bfbf0f5afb621224edbfd1589020c22867aee499032e8229e9b88
7
- data.tar.gz: ad846c7c49712f864bf213857a4690486c07373d496786b97da699199dc762bca5be07334fdfbaf69b99de2e175279d8f3eda88941245091558ed375c510ef4a
6
+ metadata.gz: 64989fa6ca9e932e511db3c9e89c4b4af9a166a722ef8d120cf79ce9c3a392ccb39f73ebe08e0cd72b58b21f71dc449c77caeef0036033101ab5c71089559d7c
7
+ data.tar.gz: bd629bffc910ffc07ad4b787f2db45826e43b7ad60a155c063db8f01bf8c93e9a2f4f28da0f6c24d1166b29c272676d704222cf19ee0614435ed20d7f164c9da
@@ -30,5 +30,5 @@ module Overlay
30
30
  end
31
31
  end
32
32
 
33
- GithubRepo = Struct.new(:user, :repo, :branch, :root_path)
33
+ GithubRepo = Struct.new(:user, :repo, :branch, :root_source_path, :root_dest_path)
34
34
  end
@@ -1,5 +1,15 @@
1
1
  module Overlay
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Overlay
4
+
5
+ config.after_initialize do
6
+ ActionController::Base.class_eval do
7
+ before_filter do
8
+ Overlay.configuration.repositories.each do |repo_config|
9
+ prepend_view_path repo_config[:root_dest_path]
10
+ end
11
+ end
12
+ end
13
+ end
4
14
  end
5
15
  end
@@ -54,7 +54,10 @@ module Overlay
54
54
  def self.overlay_repo repo_config
55
55
  # Get our root entries
56
56
  #
57
- root_entries = github_repo.contents.get(repo_config[:user], repo_config[:repo], '/', ref: repo_config[:branch]).response.body
57
+ root = repo_config[:root_source_path] || '/'
58
+ overlay_directory root, repo_config and return if root != '/'
59
+
60
+ root_entries = github_repo.contents.get(repo_config[:user], repo_config[:repo], root, ref: repo_config[:branch]).response.body
58
61
 
59
62
  # We aren't pulling anything out of root. Cycle through directories and overlay
60
63
  #
@@ -66,9 +69,10 @@ module Overlay
66
69
  end
67
70
 
68
71
  def self.overlay_directory path, repo_config
69
- root_path = repo_config[:root_path].empty? ? "#{Rails.application.root}/#{repo_config[:root_path]}" : "#{Rails.application.root}"
72
+ root_path = repo_config[:root_dest_path].empty? ? "#{Rails.application.root}" : "#{Rails.application.root}/#{repo_config[:root_dest_path]}"
73
+ dynamic_path = path.partition(repo_config[:root_source_path]).last
70
74
 
71
- FileUtils.mkdir_p "#{root_path}/#{path}"
75
+ FileUtils.mkdir_p "#{root_path}/#{dynamic_path}"
72
76
  directory_entries = github_repo.contents.get(repo_config[:user], repo_config[:repo], path, ref: repo_config[:branch]).response.body
73
77
 
74
78
  directory_entries.each do |entry|
@@ -81,10 +85,11 @@ module Overlay
81
85
  end
82
86
 
83
87
  def self.clone_file path, repo_config
84
- root_path = repo_config[:root_path].empty? ? "#{Rails.application.root}/#{repo_config[:root_path]}" : "#{Rails.application.root}"
88
+ root_path = repo_config[:root_dest_path].empty? ? "#{Rails.application.root}" : "#{Rails.application.root}/#{repo_config[:root_dest_path]}"
89
+ dynamic_path = path.partition(repo_config[:root_source_path]).last
85
90
 
86
91
  file = github_repo.contents.get(repo_config[:user], repo_config[:repo], path, ref: repo_config[:branch]).response.body.content
87
- File.open("#{root_path}/#{path}", "wb") { |f| f.write(Base64.decode64(file)) }
92
+ File.open("#{root_path}/#{dynamic_path}", "wb") { |f| f.write(Base64.decode64(file)) }
88
93
  end
89
94
 
90
95
  private
@@ -1,3 +1,3 @@
1
1
  module Overlay
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overlay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Saarinen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-31 00:00:00.000000000 Z
11
+ date: 2013-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails