frizz 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/frizz.gemspec +27 -0
- data/lib/frizz/local.rb +42 -0
- data/lib/frizz/remote.rb +37 -0
- data/lib/frizz/site.rb +20 -0
- data/lib/frizz/sync.rb +43 -0
- data/lib/frizz/version.rb +3 -0
- data/lib/frizz.rb +21 -0
- metadata +144 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 patbenatar
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Frizz
|
2
|
+
|
3
|
+
Frizz is a utility for deploying static sites to S3.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* Sets Content-Type (including CSS files which S3 is notoriously bad at)
|
8
|
+
* Only uploads files that have changed
|
9
|
+
* Removes files that have been deleted locally
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem "frizz"
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install frizz
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Configure AWS
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Frizz.configure do |config|
|
31
|
+
config.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
32
|
+
config.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
### Setup your site and deploy!
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
site = Frizz::Site.new("my-bucket-name.com")
|
40
|
+
site.deploy!
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/frizz.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'frizz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "frizz"
|
8
|
+
spec.version = Frizz::VERSION
|
9
|
+
spec.authors = ["patbenatar"]
|
10
|
+
spec.email = ["nick@gophilosophie.com"]
|
11
|
+
spec.description = "Utility for deploying static sites to S3"
|
12
|
+
spec.summary = "Utility for deploying static sites to S3"
|
13
|
+
spec.homepage = "http://github.com/patbenatar/frizz"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "s3", "~> 0.3.13"
|
25
|
+
spec.add_dependency "colorize", "~> 0.6.0"
|
26
|
+
spec.add_dependency "mime-types", "~> 1.25"
|
27
|
+
end
|
data/lib/frizz/local.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Frizz
|
2
|
+
class Local
|
3
|
+
def initialize(root_path)
|
4
|
+
@root_path = root_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def files
|
8
|
+
@files ||= begin
|
9
|
+
Dir.chdir(root_path) do
|
10
|
+
Dir["**/*"].map do |local_path|
|
11
|
+
File.new(expand_path(local_path), local_path) unless ::File.directory?(local_path)
|
12
|
+
end.compact
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_for(local_path)
|
18
|
+
::File.open expand_path(local_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :root_path
|
24
|
+
|
25
|
+
def expand_path(local_path)
|
26
|
+
::File.join root_path, local_path
|
27
|
+
end
|
28
|
+
|
29
|
+
class File
|
30
|
+
attr_reader :path, :key
|
31
|
+
|
32
|
+
def initialize(path, key)
|
33
|
+
@path = path
|
34
|
+
@key = key
|
35
|
+
end
|
36
|
+
|
37
|
+
def checksum
|
38
|
+
Digest::MD5.file(path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/frizz/remote.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "s3"
|
2
|
+
require "mime-types"
|
3
|
+
|
4
|
+
module Frizz
|
5
|
+
class Remote
|
6
|
+
def initialize(bucket_name)
|
7
|
+
@bucket_name = bucket_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def files
|
11
|
+
@files ||= bucket.objects
|
12
|
+
end
|
13
|
+
|
14
|
+
def upload(file, key)
|
15
|
+
bucket.objects.build(key).tap do |obj|
|
16
|
+
obj.acl = :public_read
|
17
|
+
obj.content = file
|
18
|
+
obj.content_type = MIME::Types.type_for(key).first.content_type
|
19
|
+
end.save
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :bucket_name
|
25
|
+
|
26
|
+
def bucket
|
27
|
+
@bucket ||= service.buckets.find(bucket_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
def service
|
31
|
+
@service ||= S3::Service.new(
|
32
|
+
access_key_id: Frizz.configuration.access_key_id,
|
33
|
+
secret_access_key: Frizz.configuration.secret_access_key,
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/frizz/site.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Frizz
|
2
|
+
class Site
|
3
|
+
def initialize(bucket_name)
|
4
|
+
@local = Frizz::Local.new(path_to_deploy)
|
5
|
+
@remote = Frizz::Remote.new(bucket_name)
|
6
|
+
end
|
7
|
+
|
8
|
+
def deploy!
|
9
|
+
Frizz::Sync.new(local, remote).run!
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :local, :remote
|
15
|
+
|
16
|
+
def path_to_deploy
|
17
|
+
File.expand_path("build")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/frizz/sync.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Frizz
|
2
|
+
class Sync
|
3
|
+
def initialize(local, remote)
|
4
|
+
@local = local
|
5
|
+
@remote = remote
|
6
|
+
end
|
7
|
+
|
8
|
+
def run!
|
9
|
+
remote.files.each do |remote_file|
|
10
|
+
local_path = remote_file.key
|
11
|
+
local_file_md5 = local_index[local_path]
|
12
|
+
|
13
|
+
if local_file_md5.nil?
|
14
|
+
puts "#{local_path}: deleted".red
|
15
|
+
remote_file.destroy
|
16
|
+
elsif local_file_md5 == remote_file.etag
|
17
|
+
puts "#{local_path}: unchanged"
|
18
|
+
local_index.delete(local_path)
|
19
|
+
else
|
20
|
+
puts "#{local_path}: updated".green
|
21
|
+
remote.upload file_for(local_path), local_path
|
22
|
+
local_index.delete(local_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Upload new files
|
27
|
+
local_index.each do |local_path, md5|
|
28
|
+
puts "#{local_path}: new".green
|
29
|
+
remote.upload local.file_for(local_path), local_path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :local, :remote
|
36
|
+
|
37
|
+
def local_index
|
38
|
+
@local_index ||= local.files.each_with_object({}) do |file, obj|
|
39
|
+
obj[file.key] = file.checksum
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/frizz.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "frizz/version"
|
2
|
+
require "colorize"
|
3
|
+
|
4
|
+
module Frizz
|
5
|
+
autoload :Site, "frizz/site"
|
6
|
+
autoload :Local, "frizz/local"
|
7
|
+
autoload :Remote, "frizz/remote"
|
8
|
+
autoload :Sync, "frizz/sync"
|
9
|
+
|
10
|
+
Configuration = Struct.new(:access_key_id, :secret_access_key)
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def configure
|
14
|
+
yield(configuration)
|
15
|
+
end
|
16
|
+
|
17
|
+
def configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: frizz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- patbenatar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
name: bundler
|
17
|
+
type: :development
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.3'
|
23
|
+
none: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.3'
|
29
|
+
none: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
32
|
+
name: rake
|
33
|
+
type: :development
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
none: false
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
none: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
prerelease: false
|
48
|
+
name: s3
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.13
|
55
|
+
none: false
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.3.13
|
61
|
+
none: false
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
prerelease: false
|
64
|
+
name: colorize
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.6.0
|
71
|
+
none: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.6.0
|
77
|
+
none: false
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
prerelease: false
|
80
|
+
name: mime-types
|
81
|
+
type: :runtime
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '1.25'
|
87
|
+
none: false
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.25'
|
93
|
+
none: false
|
94
|
+
description: Utility for deploying static sites to S3
|
95
|
+
email:
|
96
|
+
- nick@gophilosophie.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- frizz.gemspec
|
107
|
+
- lib/frizz.rb
|
108
|
+
- lib/frizz/local.rb
|
109
|
+
- lib/frizz/remote.rb
|
110
|
+
- lib/frizz/site.rb
|
111
|
+
- lib/frizz/sync.rb
|
112
|
+
- lib/frizz/version.rb
|
113
|
+
homepage: http://github.com/patbenatar/frizz
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
hash: -3366162893133711877
|
127
|
+
version: '0'
|
128
|
+
none: false
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
hash: -3366162893133711877
|
136
|
+
version: '0'
|
137
|
+
none: false
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.8.23
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: Utility for deploying static sites to S3
|
144
|
+
test_files: []
|