cloud_crooner 0.0.1 → 0.0.2

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: 0264cd064043ffa30c3b8e1f243c568614c33071
4
- data.tar.gz: 5c5c511702a426b686d529d7e3d28b8eb219591c
3
+ metadata.gz: 96c6f6bcbfc3bc6923aa74ee75f875a9c8be8f37
4
+ data.tar.gz: df7ffd57e4962c7ad2343b2960c6a553d603301c
5
5
  SHA512:
6
- metadata.gz: b56c82ae03ac812ba2b39c778ad0f619b62a4115e346d297b7c3b1c63cbfbe01f36d2fb444a14504fed8adc3c980e15e1f717e3a7ec251e087dbb02f2acb8e9c
7
- data.tar.gz: 990555fd530e9372fe0efaacdb5a5c3609e990c1148eef286f734c93b59072b6cb13f1df9ac6e00b200af5d13f005705f161e4a7eda3191b4bf7b94f2661fd83
6
+ metadata.gz: b522ae4cb68eeb23cb34421928954824fdecc6fd7ce894332916403f1492a696110401795d0adae3a4c63a09930e840748f66c98b4568dd91f1d6745db649383
7
+ data.tar.gz: f7878e04dea4a3349fc84daddb4069dfd3a6c090e7d77de60728d446d49de18add7b9b5ea770d646da28d854532940f42e8933cd2fd0b0d53250317462c6d48b
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # v0.0.2
2
+ * fixed bug where sync did not check for remote_enabled
3
+
4
+ # v0.0.1
5
+ * initial release
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Manage your Sinatra app's assets with [Sprockets](https://github.com/sstephenson/sprockets) and sync them with [Amazon S3](http://aws.amazon.com/s3/).
4
4
 
5
- Cloud Crooner will run a Sprockets instance and configure helpers for your views. Create a rake task to call the sync method to compile your assets and upload them to the cloud. The helpers will make sure you're pointing to the S3 assets in prod. Your assets will have appended to their names an MD5 hash of their contents which updates when your assets change, ensuring that your users will always be served the freshest assets without needing to worry about expiring caches.
5
+ Cloud Crooner will run a Sprockets instance and configure helpers for your views. Create a rake task to compile your assets and upload them to the cloud, and use helper methods to make sure you're always pointing to the right asset paths for your environment. In prod, your assets will have appended to their names an MD5 hash of their contents which updates when your assets change, ensuring that your users will always be served the freshest assets without needing to worry about expiring caches.
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Configuration
22
22
 
23
- Cloud Crooner has many configuration options which can be set in a configure block:
23
+ Cloud Crooner has many configuration options which can be set in a configure block. [Explicit configuration is optional.](#no-configuration)
24
24
 
25
25
  CloudCrooner.configure do |config|
26
26
  config.prefix = '/assets'
@@ -32,7 +32,7 @@ Cloud Crooner has many configuration options which can be set in a configure blo
32
32
 
33
33
  `prefix` - the path from root where you keep your assets. By default it is `/assets`. Your compiled assets will be placed in `public_folder/prefix.` It will also be the pseudo-folder on S3 where your assets will be stored, so the paths will look something like `http://bucket-name.s3.amazonaws.com/prefix/filename`.
34
34
 
35
- `sprockets` - by default, this will be your Sprockets environment and it will load paths the config option `asset_paths`.
35
+ `sprockets` - by default, this will be your Sprockets environment and it will add to its load path the paths set in the config option `asset_paths`.
36
36
 
37
37
  `asset_paths` - the [load paths](https://github.com/sstephenson/sprockets#the-load-path) for your Sprockets instance. By default it will add the `prefix` directory.
38
38
 
@@ -42,13 +42,16 @@ Cloud Crooner has many configuration options which can be set in a configure blo
42
42
 
43
43
  `backups_to_keep` - the number of compiled asset backups to keep. Default is 2. When running the sync task, if an asset's content has changed, it will be recompiled. If there are already more than the set number of backups present, the oldest asset will be deleted locally, removed from the manifest, and deleted remotely.
44
44
 
45
- `bucket_name` - the name of your AWS S3 bucket. [See below for details.](#hooking_up )
45
+ ### Amazon S3 settings and credentials
46
+ [See "Hooking Up With Your Amazon S3 Account" for details.](#hooking-up-with-your-amazon-s3-account)
46
47
 
47
- `region` - the region of your AWS S3 bucket. [See below for details.](#hooking_up )
48
-
49
- `aws_access_id_key` - aws credentials. [See below for details.](#hooking_up )
48
+ `bucket_name` - the name of your AWS S3 bucket.
50
49
 
51
- `aws_secret_access_key` - aws credentials. [See below for details.](#hooking_up )
50
+ `region` - the region of your AWS S3 bucket.
51
+
52
+ `aws_access_id_key` - aws credentials.
53
+
54
+ `aws_secret_access_key` - aws credentials.
52
55
 
53
56
  ### No Configuration
54
57
 
@@ -56,9 +59,9 @@ If you're keen to run everything on defaults, you will still need to run one com
56
59
 
57
60
  CloudCrooner.configure_sprockets_helpers
58
61
 
59
- Normally this is called at the end of the configure method.
62
+ Normally this is called at the end of the `CloudCrooner.configure` method. This method also assumes you have put the S3 settings into ENV outside of the app.
60
63
 
61
- ### <a id="hooking_up"></a>Hooking up with your Amazon S3 Account
64
+ ### Hooking Up With Your Amazon S3 Account
62
65
 
63
66
  After you have created an S3 account, [you will will be provided with an "access key id" and a "secret access key"](https://console.aws.amazon.com/iam/home?#security_credential). You will also need your bucket name and the bucket's region. One of the ways to find the region is by going to the [S3 console](https://console.aws.amazon.com/s3/) and checking the end of the URL: it will look something like us-west-1. Cloud Crooner will look for your AWS credentials in your ENV by default. _Do not put your credentials anywhere they can be checked into source control._ I would suggest loading them into the env with your bash login scripts. The env keys that will be checked by default are:
64
67
 
@@ -78,7 +81,7 @@ You may also set these in the Cloud Crooner config block, but please do not dire
78
81
 
79
82
  ## Setting Up Your App:
80
83
 
81
- I have thrown together a very simple application as an example.
84
+ [I have thrown together a very simple application as an example.](https://github.com/bambery/cloud_crooner_example)
82
85
 
83
86
  In a file of your choosing (in this case `/config/cloud_crooner_config.rb`) run the configuration block with your desired settings.
84
87
 
@@ -103,6 +106,16 @@ In config.ru, require this file, and set up the following:
103
106
  run App # your application class name
104
107
  end
105
108
 
109
+ You have to register the helpers in your application so they can find your assets:
110
+
111
+ class App < Sinatra::Base
112
+ helpers do
113
+ include Sprockets::Helpers
114
+ end
115
+ end
116
+
117
+ The helpers which you can use are [detailed below](#helpers).
118
+
106
119
  To compile and upload the assets, in your rakefile:
107
120
 
108
121
  require './config/cloud_crooner_config.rb'
@@ -125,6 +138,27 @@ Running your app in development mode will serve uncompiled assets locally (from
125
138
 
126
139
  If you want to precompile and upload your assets every time you spin up your app, you can put the configure block directly into config.ru and after config run CloudCrooner.sync.
127
140
 
141
+
142
+ ## Helpers
143
+
144
+ Helper methods are provided for use in your views using the [sprockets-helpers](https://github.com/petebrowne/sprockets-helpers) gem.
145
+
146
+ `stylesheet_tag` - put this in your views to insert an html tag referencing a stylesheet in the Sprockets load path. For example, if you have `/assets/stylesheets/application.scss` and have placed `assets/stylesheets` in the load path, you would write:
147
+ <%= stylesheet_tag 'application' %>
148
+ and in dev it will compile to
149
+ <link rel="stylesheet" href="/assets/application.css">
150
+ in prod it will compile to
151
+ <link rel="stylesheet" href="http://my-bucket.s3.amazonaws.com/assets/application.css">
152
+
153
+ `javascript_tag` - similar to `stylesheet_tag`
154
+
155
+ `asset_tag` - similar to stylesheet, but you pass a block to generate a tag of your choosing.
156
+ asset_tag('main.js') { |path| "<script src=#{path}></script>" }
157
+ will generate
158
+ <script src=/main.js></script>
159
+
160
+ `asset_path` - returns the path to an asset, no tag.
161
+
128
162
  ## Notes About Sass and Sprockets
129
163
 
130
164
  If you are using sass files, you should use the [ sprockets-sass ](https://github.com/petebrowne/sprockets-sass) and [ sass ](https://github.com/nex3/sass) gems to help Sprockets cope (sprockets-sass still necessary as of 06/30/13 for functional Sinatra @imports, email me if this changes).
@@ -184,8 +184,10 @@ module CloudCrooner
184
184
  compile_sprockets_assets
185
185
  clean_sprockets_assets
186
186
 
187
- storage.upload_files
188
- storage.clean_remote
187
+ if remote_enabled?
188
+ storage.upload_files
189
+ storage.clean_remote
190
+ end
189
191
 
190
192
  end
191
193
 
@@ -1,3 +1,3 @@
1
1
  module CloudCrooner
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -292,27 +292,46 @@ describe CloudCrooner do
292
292
 
293
293
  end # describe
294
294
 
295
- it 'compiles assets' do
296
- within_construct do |c|
297
- mock_environment(c)
298
- CloudCrooner.assets_to_compile = ['a.css', 'b.css']
299
- (CloudCrooner.storage.local_compiled_assets).should == []
300
- CloudCrooner.compile_sprockets_assets
301
-
302
- expect(CloudCrooner.storage.local_compiled_assets).to eq(['assets/' + CloudCrooner.sprockets['a.css'].digest_path, 'assets/' + CloudCrooner.sprockets['b.css'].digest_path])
303
- end # construct
304
- end # it
305
-
306
- it 'syncs assets to the cloud', :moo => true do
307
- within_construct do |c|
308
- mock_environment(c)
309
- CloudCrooner.assets_to_compile = ['a.css', 'b.css']
310
- mock_fog(CloudCrooner.storage)
311
- CloudCrooner.sync
312
-
313
- expect(local_equals_remote?(CloudCrooner.storage)).to be_true
314
- end # construct
315
- end # it
295
+ describe 'compiling and syncing assets' do
296
+
297
+ it 'compiles assets' do
298
+ within_construct do |c|
299
+ mock_environment(c)
300
+ CloudCrooner.assets_to_compile = ['a.css', 'b.css']
301
+ (CloudCrooner.storage.local_compiled_assets).should == []
302
+ CloudCrooner.compile_sprockets_assets
303
+
304
+ expect(CloudCrooner.storage.local_compiled_assets).to eq(['assets/' + CloudCrooner.sprockets['a.css'].digest_path, 'assets/' + CloudCrooner.sprockets['b.css'].digest_path])
305
+ end # construct
306
+ end # it
307
+
308
+ it 'compiles and syncs assets to the cloud', :moo => true do
309
+ within_construct do |c|
310
+ mock_environment(c)
311
+ CloudCrooner.assets_to_compile = ['a.css', 'b.css']
312
+ mock_fog(CloudCrooner.storage)
313
+ CloudCrooner.sync
314
+
315
+ expect(local_equals_remote?(CloudCrooner.storage)).to be_true
316
+ end # construct
317
+ end # it
318
+
319
+ it 'compiles and does not sync assets if remote_enabled is false' do
320
+ within_construct do |c|
321
+ mock_environment(c)
322
+ CloudCrooner.configure do |config|
323
+ config.assets_to_compile = ['a.css', 'b.css']
324
+ config.remote_enabled = false
325
+ end
326
+ mock_fog(CloudCrooner.storage)
327
+ CloudCrooner.sync
328
+
329
+ expect(local_equals_remote?(CloudCrooner.storage)).to be_false
330
+ expect(CloudCrooner.storage.bucket.versions.first).to be_nil
331
+ end # construct
332
+ end # it
333
+
334
+ end # describe
316
335
 
317
336
  after(:each) do
318
337
  reload_crooner
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_crooner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bambery
@@ -132,6 +132,7 @@ files:
132
132
  - .gitignore
133
133
  - .rspec
134
134
  - .rvmrc
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - LICENSE.txt
137
138
  - README.md
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  version: '0'
165
166
  requirements: []
166
167
  rubyforge_project:
167
- rubygems_version: 2.0.5
168
+ rubygems_version: 2.0.3
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: Manage assets with Sprockets, precompile them into static assets, then upload