asset_sync 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ require "asset_sync/version"
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "asset_sync"
8
8
  s.version = AssetSync::VERSION
9
- s.date = "2011-12-06"
9
+ s.date = "2012-01-06"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["Simon Hamilton", "David Rice", "Phil McClure"]
12
12
  s.email = ["shamilton@rumblelabs.com", "me@davidjrice.co.uk", "pmcclure@rumblelabs.com"]
@@ -41,7 +41,7 @@ module AssetSync
41
41
  end
42
42
 
43
43
  def manifest_path
44
- default = File.join(Rails.root, 'public', 'assets', 'manifest.yml')
44
+ default = File.join(Rails.root, 'public', Rails.application.config.assets.prefix, 'manifest.yml')
45
45
  Rails.application.config.assets.manifest || default
46
46
  end
47
47
 
@@ -56,7 +56,7 @@ module AssetSync
56
56
  def aws?
57
57
  fog_provider == 'AWS'
58
58
  end
59
-
59
+
60
60
  def fail_silently?
61
61
  fail_silently == true
62
62
  end
@@ -90,7 +90,7 @@ module AssetSync
90
90
  self.gzip_compression = yml["gzip_compression"] if yml.has_key?("gzip_compression")
91
91
  self.manifest = yml["manifest"] if yml.has_key?("manifest")
92
92
  self.fail_silently = yml["fail_silently"] if yml.has_key?("fail_silently")
93
-
93
+
94
94
  # TODO deprecate the other old style config settings. FML.
95
95
  self.aws_access_key_id = yml["aws_access_key"] if yml.has_key?("aws_access_key")
96
96
  self.aws_secret_access_key = yml["aws_access_secret"] if yml.has_key?("aws_access_secret")
@@ -15,7 +15,7 @@ module AssetSync
15
15
 
16
16
  def bucket
17
17
  # fixes: https://github.com/rumblelabs/asset_sync/issues/18
18
- @bucket ||= connection.directories.get(self.config.fog_directory, :prefix => 'assets')
18
+ @bucket ||= connection.directories.get(self.config.fog_directory, :prefix => Rails.application.config.assets.prefix)
19
19
  end
20
20
 
21
21
  def keep_existing_remote_files?
@@ -27,7 +27,7 @@ module AssetSync
27
27
  end
28
28
 
29
29
  def local_files
30
- @local_files ||= get_local_files
30
+ @local_files ||= get_local_files
31
31
  end
32
32
 
33
33
  def get_local_files
@@ -35,14 +35,14 @@ module AssetSync
35
35
  if File.exists?(self.config.manifest_path)
36
36
  yml = YAML.load(IO.read(self.config.manifest_path))
37
37
  STDERR.puts "Using: Manifest #{self.config.manifest_path}"
38
- return yml.values.map { |f| File.join('assets', f) }
38
+ return yml.values.map { |f| File.join(Rails.application.config.assets.prefix, f) }
39
39
  else
40
40
  STDERR.puts "Warning: manifest.yml not found at #{self.config.manifest_path}"
41
41
  end
42
42
  end
43
- STDERR.puts "Using: Directory Search of #{path}/assets"
44
- Dir["#{path}/assets/**/**"].map { |f| f[path.length+1,f.length-path.length] }
45
- end
43
+ STDERR.puts "Using: Directory Search of #{path}/#{Rails.application.config.assets.prefix}"
44
+ Dir["#{path}/#{Rails.application.config.assets.prefix}/**/**"].map { |f| f[path.length+1,f.length-path.length] }
45
+ end
46
46
 
47
47
  def get_remote_files
48
48
  raise BucketNotFound.new("#{self.config.fog_provider} Bucket: #{self.config.fog_directory} not found.") unless bucket
@@ -65,7 +65,7 @@ module AssetSync
65
65
  remote_files = get_remote_files
66
66
  # fixes: https://github.com/rumblelabs/asset_sync/issues/19
67
67
  from_remote_files_to_delete = remote_files - local_files
68
-
68
+
69
69
  STDERR.puts "Flagging #{from_remote_files_to_delete.size} file(s) for deletion"
70
70
  # Delete unneeded remote files
71
71
  bucket.files.each do |f|
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -1,162 +1,150 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
-
4
- describe AssetSync, 'with initializer' do
5
-
6
- before(:all) do
7
- Rails.root = 'without_yml'
8
- AssetSync.config = AssetSync::Config.new
9
- AssetSync.configure do |config|
10
- config.fog_provider = 'AWS'
11
- config.aws_access_key_id = 'aaaa'
12
- config.aws_secret_access_key = 'bbbb'
13
- config.fog_directory = 'mybucket'
14
- config.fog_region = 'eu-west-1'
15
- config.existing_remote_files = "keep"
3
+ describe AssetSync do
4
+ include_context "mock Rails without_yml"
5
+
6
+ describe 'with initializer' do
7
+ before(:each) do
8
+ AssetSync.config = AssetSync::Config.new
9
+ AssetSync.configure do |config|
10
+ config.fog_provider = 'AWS'
11
+ config.aws_access_key_id = 'aaaa'
12
+ config.aws_secret_access_key = 'bbbb'
13
+ config.fog_directory = 'mybucket'
14
+ config.fog_region = 'eu-west-1'
15
+ config.existing_remote_files = "keep"
16
+ end
16
17
  end
17
- end
18
18
 
19
- it "should configure provider as AWS" do
20
- AssetSync.config.fog_provider.should == 'AWS'
21
- AssetSync.config.should be_aws
22
- end
19
+ it "should configure provider as AWS" do
20
+ AssetSync.config.fog_provider.should == 'AWS'
21
+ AssetSync.config.should be_aws
22
+ end
23
23
 
24
- it "should should keep existing remote files" do
25
- AssetSync.config.existing_remote_files?.should == true
26
- end
24
+ it "should should keep existing remote files" do
25
+ AssetSync.config.existing_remote_files?.should == true
26
+ end
27
27
 
28
- it "should configure aws_access_key" do
29
- AssetSync.config.aws_access_key_id.should == "aaaa"
30
- end
28
+ it "should configure aws_access_key" do
29
+ AssetSync.config.aws_access_key_id.should == "aaaa"
30
+ end
31
31
 
32
- it "should configure aws_access_key" do
33
- AssetSync.config.aws_secret_access_key.should == "bbbb"
34
- end
32
+ it "should configure aws_access_key" do
33
+ AssetSync.config.aws_secret_access_key.should == "bbbb"
34
+ end
35
35
 
36
- it "should configure aws_access_key" do
37
- AssetSync.config.fog_directory.should == "mybucket"
38
- end
36
+ it "should configure aws_access_key" do
37
+ AssetSync.config.fog_directory.should == "mybucket"
38
+ end
39
39
 
40
- it "should configure aws_access_key" do
41
- AssetSync.config.fog_region.should == "eu-west-1"
42
- end
40
+ it "should configure aws_access_key" do
41
+ AssetSync.config.fog_region.should == "eu-west-1"
42
+ end
43
43
 
44
- it "should configure aws_access_key" do
45
- AssetSync.config.existing_remote_files.should == "keep"
46
- end
44
+ it "should configure aws_access_key" do
45
+ AssetSync.config.existing_remote_files.should == "keep"
46
+ end
47
47
 
48
- it "should default gzip_compression to false" do
49
- AssetSync.config.gzip_compression.should be_false
50
- end
48
+ it "should default gzip_compression to false" do
49
+ AssetSync.config.gzip_compression.should be_false
50
+ end
51
51
 
52
- it "should default manifest to false" do
53
- AssetSync.config.manifest.should be_false
52
+ it "should default manifest to false" do
53
+ AssetSync.config.manifest.should be_false
54
+ end
54
55
  end
55
56
 
56
- end
57
-
58
-
59
- describe AssetSync, 'from yml' do
60
-
61
- before(:all) do
62
- Rails.root = 'aws_with_yml'
63
- AssetSync.config = AssetSync::Config.new
64
- end
57
+ describe 'from yml' do
58
+ before(:each) do
59
+ set_rails_root('aws_with_yml')
60
+ AssetSync.config = AssetSync::Config.new
61
+ end
65
62
 
66
- it "should configure aws_access_key_id" do
67
- AssetSync.config.aws_access_key_id.should == "xxxx"
68
- end
63
+ it "should configure aws_access_key_id" do
64
+ AssetSync.config.aws_access_key_id.should == "xxxx"
65
+ end
69
66
 
70
- it "should configure aws_secret_access_key" do
71
- AssetSync.config.aws_secret_access_key.should == "zzzz"
72
- end
67
+ it "should configure aws_secret_access_key" do
68
+ AssetSync.config.aws_secret_access_key.should == "zzzz"
69
+ end
73
70
 
74
- it "should configure aws_access_key" do
75
- AssetSync.config.fog_directory.should == "rails_app_test"
76
- end
71
+ it "should configure aws_access_key" do
72
+ AssetSync.config.fog_directory.should == "rails_app_test"
73
+ end
77
74
 
78
- it "should configure aws_access_key" do
79
- AssetSync.config.fog_region.should == "eu-west-1"
80
- end
75
+ it "should configure aws_access_key" do
76
+ AssetSync.config.fog_region.should == "eu-west-1"
77
+ end
81
78
 
82
- it "should configure aws_access_key" do
83
- AssetSync.config.existing_remote_files.should == "keep"
84
- end
79
+ it "should configure aws_access_key" do
80
+ AssetSync.config.existing_remote_files.should == "keep"
81
+ end
85
82
 
86
- it "should default gzip_compression to false" do
87
- AssetSync.config.gzip_compression.should be_false
88
- end
83
+ it "should default gzip_compression to false" do
84
+ AssetSync.config.gzip_compression.should be_false
85
+ end
89
86
 
90
- it "should default manifest to false" do
91
- AssetSync.config.manifest.should be_false
87
+ it "should default manifest to false" do
88
+ AssetSync.config.manifest.should be_false
89
+ end
92
90
  end
93
-
94
- end
95
91
 
96
- describe AssetSync, 'with no configuration' do
97
-
98
- before(:all) do
99
- Rails.root = 'without_yml'
100
- AssetSync.config = AssetSync::Config.new
101
- end
92
+ describe 'with no configuration' do
93
+ before(:each) do
94
+ AssetSync.config = AssetSync::Config.new
95
+ end
102
96
 
103
- it "should be invalid" do
104
- lambda{ AssetSync.sync }.should raise_error(AssetSync::Config::Invalid)
97
+ it "should be invalid" do
98
+ lambda{ AssetSync.sync }.should raise_error(AssetSync::Config::Invalid)
99
+ end
105
100
  end
106
101
 
107
- end
108
-
109
- describe AssetSync, 'with fail_silent configuration' do
110
-
111
- before(:all) do
112
- Rails.root = 'without_yml'
113
- AssetSync.config = AssetSync::Config.new
114
- AssetSync.configure do |config|
115
- config.fail_silently = true
102
+ describe 'with fail_silent configuration' do
103
+ before(:each) do
104
+ AssetSync.config = AssetSync::Config.new
105
+ AssetSync.configure do |config|
106
+ config.fail_silently = true
107
+ end
116
108
  end
117
- end
118
109
 
119
- it "should not raise an invalid exception" do
120
- lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
110
+ it "should not raise an invalid exception" do
111
+ lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
112
+ end
121
113
  end
122
114
 
123
- end
124
-
125
- describe AssetSync, 'with gzip_compression enabled' do
126
-
127
- before(:all) do
128
- Rails.root = 'without_yml'
129
- AssetSync.config = AssetSync::Config.new
130
- AssetSync.config.gzip_compression = true
131
- end
115
+ describe 'with gzip_compression enabled' do
116
+ before(:each) do
117
+ AssetSync.config = AssetSync::Config.new
118
+ AssetSync.config.gzip_compression = true
119
+ end
132
120
 
133
- it "config.gzip? should be true" do
134
- AssetSync.config.gzip?.should be_true
121
+ it "config.gzip? should be true" do
122
+ AssetSync.config.gzip?.should be_true
123
+ end
135
124
  end
136
125
 
137
- end
138
-
139
- describe AssetSync, 'with manifest enabled' do
126
+ describe 'with manifest enabled' do
127
+ before(:each) do
128
+ AssetSync.config = AssetSync::Config.new
129
+ AssetSync.config.manifest = true
130
+ end
140
131
 
141
- before(:all) do
142
- Rails.root = 'without_yml'
143
- AssetSync.config = AssetSync::Config.new
144
- AssetSync.config.manifest = true
145
- end
132
+ it "config.manifest should be true" do
133
+ AssetSync.config.manifest.should be_true
134
+ end
146
135
 
147
- it "config.manifest should be true" do
148
- AssetSync.config.manifest.should be_true
149
- end
136
+ it "config.manifest_path should default to public/assets.." do
137
+ AssetSync.config.manifest_path.should =~ /public\/assets\/manifest.yml/
138
+ end
150
139
 
151
- it "config.manifest_path should default to public/assets.." do
152
- pending
153
- AssetSync.config.manifest_path.should =~ "public/assets/manifest.yml"
154
- end
140
+ it "config.manifest_path should default to public/assets.." do
141
+ Rails.application.config.assets.manifest = "/var/assets/manifest.yml"
142
+ AssetSync.config.manifest_path.should == "/var/assets/manifest.yml"
143
+ end
155
144
 
156
- it "config.manifest_path should default to public/assets.." do
157
- pending
158
- Rails.app.config.assets.manifest = "/var/assets/manifest.yml"
159
- AssetSync.config.manifest_path.should == "/var/assets/manifest.yml"
145
+ it "config.manifest_path should default to public/custom_assets.." do
146
+ Rails.application.config.assets.prefix = 'custom_assets'
147
+ AssetSync.config.manifest_path.should =~ /public\/custom_assets\/manifest.yml/
148
+ end
160
149
  end
161
-
162
150
  end
@@ -1,91 +1,90 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
+ describe AssetSync do
4
+ include_context "mock Rails"
5
+
6
+ describe 'using Rackspace with initializer' do
7
+ before(:each) do
8
+ set_rails_root('without_yml')
9
+ AssetSync.config = AssetSync::Config.new
10
+ AssetSync.configure do |config|
11
+ config.fog_provider = 'Rackspace'
12
+ config.fog_directory = 'mybucket'
13
+ config.fog_region = 'dunno'
14
+ config.rackspace_username = 'aaaa'
15
+ config.rackspace_api_key = 'bbbb'
16
+ config.existing_remote_files = 'keep'
17
+ end
18
+ end
3
19
 
4
- describe AssetSync, 'using Rackspace with initializer' do
5
-
6
- before(:all) do
7
- Rails.root = 'without_yml'
8
- AssetSync.config = AssetSync::Config.new
9
- AssetSync.configure do |config|
10
- config.fog_provider = 'Rackspace'
11
- config.fog_directory = 'mybucket'
12
- config.fog_region = 'dunno'
13
- config.rackspace_username = 'aaaa'
14
- config.rackspace_api_key = 'bbbb'
15
- config.existing_remote_files = 'keep'
20
+ it "should configure provider as Rackspace" do
21
+ AssetSync.config.fog_provider.should == 'Rackspace'
22
+ AssetSync.config.should be_rackspace
16
23
  end
17
- end
18
24
 
19
- it "should configure provider as Rackspace" do
20
- AssetSync.config.fog_provider.should == 'Rackspace'
21
- AssetSync.config.should be_rackspace
22
- end
25
+ it "should keep existing remote files" do
26
+ AssetSync.config.existing_remote_files?.should == true
27
+ end
23
28
 
24
- it "should keep existing remote files" do
25
- AssetSync.config.existing_remote_files?.should == true
26
- end
29
+ it "should configure rackspace_username" do
30
+ AssetSync.config.rackspace_username.should == "aaaa"
31
+ end
27
32
 
28
- it "should configure rackspace_username" do
29
- AssetSync.config.rackspace_username.should == "aaaa"
30
- end
33
+ it "should configure rackspace_api_key" do
34
+ AssetSync.config.rackspace_api_key.should == "bbbb"
35
+ end
31
36
 
32
- it "should configure rackspace_api_key" do
33
- AssetSync.config.rackspace_api_key.should == "bbbb"
34
- end
37
+ it "should configure fog_directory" do
38
+ AssetSync.config.fog_directory.should == "mybucket"
39
+ end
35
40
 
36
- it "should configure fog_directory" do
37
- AssetSync.config.fog_directory.should == "mybucket"
38
- end
41
+ it "should configure fog_region" do
42
+ AssetSync.config.fog_region.should == "dunno"
43
+ end
39
44
 
40
- it "should configure fog_region" do
41
- AssetSync.config.fog_region.should == "dunno"
42
- end
45
+ it "should configure existing_remote_files" do
46
+ AssetSync.config.existing_remote_files.should == "keep"
47
+ end
43
48
 
44
- it "should configure existing_remote_files" do
45
- AssetSync.config.existing_remote_files.should == "keep"
46
- end
49
+ it "should configure existing_remote_files" do
50
+ AssetSync.config.existing_remote_files.should == "keep"
51
+ end
47
52
 
48
- it "should configure existing_remote_files" do
49
- AssetSync.config.existing_remote_files.should == "keep"
50
- end
53
+ it "should default rackspace_auth_url to false" do
54
+ AssetSync.config.rackspace_auth_url.should be_false
55
+ end
51
56
 
52
- it "should default rackspace_auth_url to false" do
53
- AssetSync.config.rackspace_auth_url.should be_false
54
57
  end
55
58
 
56
- end
57
-
58
-
59
- describe AssetSync, 'using Rackspace from yml' do
59
+ describe 'using Rackspace from yml' do
60
60
 
61
- before(:all) do
62
- Rails.root = 'rackspace_with_yml'
63
- AssetSync.config = AssetSync::Config.new
64
- end
61
+ before(:each) do
62
+ set_rails_root('rackspace_with_yml')
63
+ AssetSync.config = AssetSync::Config.new
64
+ end
65
65
 
66
- it "should keep existing remote files" do
67
- AssetSync.config.existing_remote_files?.should == true
68
- end
66
+ it "should keep existing remote files" do
67
+ AssetSync.config.existing_remote_files?.should == true
68
+ end
69
69
 
70
- it "should configure rackspace_username" do
71
- AssetSync.config.rackspace_username.should == "xxxx"
72
- end
70
+ it "should configure rackspace_username" do
71
+ AssetSync.config.rackspace_username.should == "xxxx"
72
+ end
73
73
 
74
- it "should configure rackspace_api_key" do
75
- AssetSync.config.rackspace_api_key.should == "zzzz"
76
- end
74
+ it "should configure rackspace_api_key" do
75
+ AssetSync.config.rackspace_api_key.should == "zzzz"
76
+ end
77
77
 
78
- it "should configure fog_directory" do
79
- AssetSync.config.fog_directory.should == "rails_app_test"
80
- end
78
+ it "should configure fog_directory" do
79
+ AssetSync.config.fog_directory.should == "rails_app_test"
80
+ end
81
81
 
82
- it "should configure fog_region" do
83
- AssetSync.config.fog_region.should == "eu-west-1"
84
- end
82
+ it "should configure fog_region" do
83
+ AssetSync.config.fog_region.should == "eu-west-1"
84
+ end
85
85
 
86
- it "should configure existing_remote_files" do
87
- AssetSync.config.existing_remote_files.should == "keep"
86
+ it "should configure existing_remote_files" do
87
+ AssetSync.config.existing_remote_files.should == "keep"
88
+ end
88
89
  end
89
-
90
-
91
- end
90
+ end
@@ -12,20 +12,31 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
12
  $LOAD_PATH.unshift(File.dirname(__FILE__))
13
13
  require 'asset_sync'
14
14
 
15
- class Rails
16
-
17
- @@path = 'without_yml'
15
+ RSpec.configure do |config|
16
+ config.mock_framework = :rspec
17
+ end
18
18
 
19
- def self.env
20
- "test"
19
+ shared_context "mock Rails" do
20
+ before(:each) do
21
+ unless defined? Rails
22
+ Rails = mock 'Rails'
23
+ end
24
+ Rails.stub(:env).and_return('test')
25
+ Rails.stub :application => mock('application')
26
+ Rails.application.stub :config => mock('config')
27
+ Rails.application.config.stub :assets => ActiveSupport::OrderedOptions.new
28
+ Rails.application.config.assets.prefix = '/assets'
21
29
  end
30
+ end
22
31
 
23
- def self.root=(path)
24
- @@path = path
25
- end
32
+ shared_context "mock Rails without_yml" do
33
+ include_context "mock Rails"
26
34
 
27
- def self.root
28
- File.expand_path(File.join('spec', @@path))
35
+ before(:each) do
36
+ set_rails_root('without_yml')
29
37
  end
38
+ end
30
39
 
31
- end
40
+ def set_rails_root(path)
41
+ Rails.stub(:root).and_return(File.join(File.dirname(__FILE__), path))
42
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: asset_sync
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Simon Hamilton
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-12-06 00:00:00 Z
15
+ date: 2012-01-06 00:00:00 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: fog