frizz 0.0.1 → 0.0.2
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.
- data/README.md +104 -5
- data/lib/frizz/configuration.rb +40 -0
- data/lib/frizz/environment.rb +24 -0
- data/lib/frizz/middleman/tasks.rb +53 -0
- data/lib/frizz/middleman/view_helpers.rb +9 -0
- data/lib/frizz/version.rb +1 -1
- data/lib/frizz.rb +2 -2
- metadata +8 -4
data/README.md
CHANGED
@@ -12,19 +12,30 @@ Frizz is a utility for deploying static sites to S3.
|
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem "frizz"
|
17
|
+
```
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
19
|
-
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
20
24
|
|
21
25
|
Or install it yourself as:
|
22
26
|
|
23
|
-
|
27
|
+
```bash
|
28
|
+
$ gem install frizz
|
29
|
+
```
|
24
30
|
|
25
31
|
## Usage
|
26
32
|
|
27
|
-
###
|
33
|
+
### Configuration
|
34
|
+
|
35
|
+
#### AWS
|
36
|
+
|
37
|
+
Frizz will automatically look for this in ENV vars: `AWS_ACCESS_KEY_ID`
|
38
|
+
and `AWS_SECRET_ACCESS_KEY`. Or you can optionally configure manually:
|
28
39
|
|
29
40
|
```ruby
|
30
41
|
Frizz.configure do |config|
|
@@ -33,13 +44,101 @@ Frizz.configure do |config|
|
|
33
44
|
end
|
34
45
|
```
|
35
46
|
|
36
|
-
###
|
47
|
+
### Basic deploys
|
37
48
|
|
38
49
|
```ruby
|
39
50
|
site = Frizz::Site.new("my-bucket-name.com")
|
40
51
|
site.deploy!
|
41
52
|
```
|
42
53
|
|
54
|
+
## Usage With Middleman
|
55
|
+
|
56
|
+
Managing more than the basic two environments (dev and build) in a Middleman app
|
57
|
+
can be a pain, which is why Frizz comes with optional Middleman-specific
|
58
|
+
functionality to make things fun again!
|
59
|
+
|
60
|
+
### `frizz.yml`
|
61
|
+
|
62
|
+
Create a `frizz.yml` in the root of your project. This is how Frizz will know
|
63
|
+
what you want in each of your environments and where you want to deploy them
|
64
|
+
to.
|
65
|
+
|
66
|
+
### Rake tasks
|
67
|
+
|
68
|
+
Based on your `frizz.yml`, Frizz will create useful Rake tasks for you.
|
69
|
+
|
70
|
+
#### Configuration
|
71
|
+
|
72
|
+
Add it to your `Rakefile`:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
require "frizz/middleman/tasks"
|
76
|
+
```
|
77
|
+
|
78
|
+
#### Usage
|
79
|
+
|
80
|
+
With the following `frizz.yml`:
|
81
|
+
|
82
|
+
```yaml
|
83
|
+
environments:
|
84
|
+
staging:
|
85
|
+
bucket: "staging.example.com"
|
86
|
+
production:
|
87
|
+
bucket: "example.com"
|
88
|
+
```
|
89
|
+
|
90
|
+
Frizz would give us the following Rake tasks:
|
91
|
+
|
92
|
+
```bash
|
93
|
+
$ rake -T
|
94
|
+
rake frizz:build:production # Build production
|
95
|
+
rake frizz:build:staging # Build staging
|
96
|
+
rake frizz:deploy:production # Build and deploy production
|
97
|
+
rake frizz:deploy:staging # Build and deploy staging
|
98
|
+
```
|
99
|
+
|
100
|
+
### Settings and Variables for each of your environments
|
101
|
+
|
102
|
+
Ever built a frontend app and wanted to hit a different API for dev, staging,
|
103
|
+
and production environments? Frizz lets you specify arbitrary environment-specific
|
104
|
+
configurations in `frizz.yml` and access them later in your Middleman app's views.
|
105
|
+
|
106
|
+
#### Configuration
|
107
|
+
|
108
|
+
Add it to your `config.rb`:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
require "frizz/middleman/view_helpers"
|
112
|
+
helpers Frizz::Middleman::ViewHelpers
|
113
|
+
```
|
114
|
+
|
115
|
+
#### Usage
|
116
|
+
|
117
|
+
With the following `frizz.yml`:
|
118
|
+
|
119
|
+
```yaml
|
120
|
+
environments:
|
121
|
+
staging:
|
122
|
+
bucket: "staging.example.com"
|
123
|
+
api_root: http://api.staging.example.com/v0
|
124
|
+
welcome_message: I'm A Staging Server
|
125
|
+
production:
|
126
|
+
bucket: "example.com"
|
127
|
+
api_root: http://api.example.com/v0
|
128
|
+
welcome_message: I'm A Production Server
|
129
|
+
development:
|
130
|
+
api_root: http://localhost:3000/v0
|
131
|
+
welcome_message: Developers! Developers! Developers!
|
132
|
+
```
|
133
|
+
|
134
|
+
You would be able to access your variables from views like so:
|
135
|
+
|
136
|
+
```html
|
137
|
+
<script type="text/javascript">MyApp.config.apiRoot = "<%= frizz.api_root %>";</script>
|
138
|
+
<h1><%= frizz.welcome_message %></h1>
|
139
|
+
<h2><%= "And hi QA team!" if frizz.staging? %></h2>
|
140
|
+
```
|
141
|
+
|
43
142
|
## Contributing
|
44
143
|
|
45
144
|
1. Fork it
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Frizz
|
2
|
+
class Configuration
|
3
|
+
YAML_FILENAME = "frizz.yml"
|
4
|
+
|
5
|
+
attr_accessor :access_key_id, :secret_access_key, :environments,
|
6
|
+
:current_environment
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
self.environments = {}
|
10
|
+
|
11
|
+
# Attempt to load defaults from ENV
|
12
|
+
self.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
13
|
+
self.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
14
|
+
self.current_environment = ENV["FRIZZ_ENV"] || "development"
|
15
|
+
|
16
|
+
# Allow to be overridden in yaml
|
17
|
+
load_yaml!
|
18
|
+
end
|
19
|
+
|
20
|
+
def environment
|
21
|
+
environments[current_environment]
|
22
|
+
end
|
23
|
+
|
24
|
+
def environments=(environments_data)
|
25
|
+
@environments = environments_data.each_with_object({}) do |(name, data), obj|
|
26
|
+
obj[name] = Environment.new(name, data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def load_yaml!
|
33
|
+
return unless File.exists?(YAML_FILENAME)
|
34
|
+
|
35
|
+
YAML.load_file(YAML_FILENAME).each do |key, value|
|
36
|
+
send "#{key}=", value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Frizz
|
2
|
+
class Environment
|
3
|
+
attr_reader :name
|
4
|
+
|
5
|
+
def initialize(name, data)
|
6
|
+
@name = name
|
7
|
+
|
8
|
+
data.each do |attribute, value|
|
9
|
+
ivar_name = "@#{attribute}"
|
10
|
+
instance_variable_set(ivar_name, value)
|
11
|
+
|
12
|
+
self.class.send :define_method, attribute do
|
13
|
+
instance_variable_get(ivar_name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# This is a creative way to allow for calling frizz.production? or
|
19
|
+
# frizz.staging? from the Middleman view helpers
|
20
|
+
def method_missing(meth, args, &block)
|
21
|
+
name == meth.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "frizz"
|
2
|
+
|
3
|
+
module Frizz
|
4
|
+
module Middleman
|
5
|
+
module CmdHelper
|
6
|
+
def self.run_with_live_output(cmd)
|
7
|
+
IO.popen(cmd) do |io|
|
8
|
+
io.each do |line|
|
9
|
+
puts line
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Tasks
|
16
|
+
include Rake::DSL
|
17
|
+
|
18
|
+
def self.install!
|
19
|
+
new.install
|
20
|
+
end
|
21
|
+
|
22
|
+
def install
|
23
|
+
namespace :frizz do
|
24
|
+
namespace :build do
|
25
|
+
relevant_environments.each do |name, env|
|
26
|
+
desc "Build #{env.name}"
|
27
|
+
task env.name do
|
28
|
+
CmdHelper.run_with_live_output "FRIZZ_ENV=#{env.name} middleman build"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
namespace :deploy do
|
34
|
+
relevant_environments.each do |name, env|
|
35
|
+
desc "Build and deploy #{env.name}"
|
36
|
+
task env.name => ["frizz:build:#{env.name}"] do
|
37
|
+
Frizz::Site.new(env.bucket).deploy!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def relevant_environments
|
47
|
+
Frizz.configuration.environments.reject { |name, env| name == "development" }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Frizz::Middleman::Tasks.install!
|
data/lib/frizz/version.rb
CHANGED
data/lib/frizz.rb
CHANGED
@@ -6,8 +6,8 @@ module Frizz
|
|
6
6
|
autoload :Local, "frizz/local"
|
7
7
|
autoload :Remote, "frizz/remote"
|
8
8
|
autoload :Sync, "frizz/sync"
|
9
|
-
|
10
|
-
|
9
|
+
autoload :Configuration, "frizz/configuration"
|
10
|
+
autoload :Environment, "frizz/environment"
|
11
11
|
|
12
12
|
class << self
|
13
13
|
def configure
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: frizz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- patbenatar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -105,7 +105,11 @@ files:
|
|
105
105
|
- Rakefile
|
106
106
|
- frizz.gemspec
|
107
107
|
- lib/frizz.rb
|
108
|
+
- lib/frizz/configuration.rb
|
109
|
+
- lib/frizz/environment.rb
|
108
110
|
- lib/frizz/local.rb
|
111
|
+
- lib/frizz/middleman/tasks.rb
|
112
|
+
- lib/frizz/middleman/view_helpers.rb
|
109
113
|
- lib/frizz/remote.rb
|
110
114
|
- lib/frizz/site.rb
|
111
115
|
- lib/frizz/sync.rb
|
@@ -123,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
127
|
- !ruby/object:Gem::Version
|
124
128
|
segments:
|
125
129
|
- 0
|
126
|
-
hash:
|
130
|
+
hash: 2336966259519313102
|
127
131
|
version: '0'
|
128
132
|
none: false
|
129
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -132,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
136
|
- !ruby/object:Gem::Version
|
133
137
|
segments:
|
134
138
|
- 0
|
135
|
-
hash:
|
139
|
+
hash: 2336966259519313102
|
136
140
|
version: '0'
|
137
141
|
none: false
|
138
142
|
requirements: []
|