nanoc_deploy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +19 -0
- data/README.md +74 -0
- data/Rakefile +15 -0
- data/lib/nanoc_deploy.rb +8 -0
- data/lib/nanoc_deploy/base.rb +2 -0
- data/lib/nanoc_deploy/extra.rb +5 -0
- data/lib/nanoc_deploy/extra/deployers.rb +7 -0
- data/lib/nanoc_deploy/extra/deployers/cloud.rb +148 -0
- data/lib/nanoc_deploy/tasks.rb +10 -0
- data/lib/nanoc_deploy/tasks/deploy/cloud.rake +11 -0
- data/lib/nanoc_deploy/version.rb +3 -0
- data/nanoc_deploy.gemspec +24 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nanoc_deploy (0.0.1)
|
5
|
+
fog (>= 0.7.2)
|
6
|
+
nanoc (>= 3.1.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
builder (3.0.0)
|
12
|
+
cri (1.0.1)
|
13
|
+
excon (0.6.2)
|
14
|
+
fog (0.7.2)
|
15
|
+
builder
|
16
|
+
excon (>= 0.6.1)
|
17
|
+
formatador (>= 0.1.3)
|
18
|
+
json
|
19
|
+
mime-types
|
20
|
+
net-ssh (>= 2.1.3)
|
21
|
+
nokogiri (>= 1.4.4)
|
22
|
+
ruby-hmac
|
23
|
+
formatador (0.1.3)
|
24
|
+
json (1.5.1)
|
25
|
+
mime-types (1.16)
|
26
|
+
nanoc (3.1.6)
|
27
|
+
nanoc3 (>= 3.1.6)
|
28
|
+
nanoc3 (3.1.6)
|
29
|
+
cri (>= 1.0.0)
|
30
|
+
net-ssh (2.1.4)
|
31
|
+
nokogiri (1.4.4)
|
32
|
+
ruby-hmac (0.4.0)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
nanoc_deploy!
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010-2011 Jack Chu and contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
Nanoc Deploy
|
2
|
+
=============================
|
3
|
+
|
4
|
+
Nanoc Deploy is a nanoc 3.1 gem that adds a deployer that will upload your site into the cloud.
|
5
|
+
|
6
|
+
It uses the [fog](https://github.com/geemus/fog) gem and currently supports Amazon S3, Rackspace Cloud Files, and Google Storage.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
- You need Nanoc 3.1.6 or above
|
12
|
+
- This gem requires fog 0.7.2 or above
|
13
|
+
|
14
|
+
If you're using bundler, just add this to your Gemfile:
|
15
|
+
|
16
|
+
gem 'nanoc_deploy'
|
17
|
+
|
18
|
+
Otherwise, you can just install the gem manually:
|
19
|
+
|
20
|
+
gem install nanoc_deploy
|
21
|
+
|
22
|
+
and then in your nanoc project, put this in lib/default.rb:
|
23
|
+
|
24
|
+
require 'nanoc_deploy/tasks'
|
25
|
+
|
26
|
+
Usage
|
27
|
+
------------
|
28
|
+
|
29
|
+
In config.yaml:
|
30
|
+
|
31
|
+
deploy:
|
32
|
+
default:
|
33
|
+
provider: aws
|
34
|
+
bucket: some-bucket-name
|
35
|
+
aws_access_key_id: your_id
|
36
|
+
aws_secret_access_key: your_key
|
37
|
+
|
38
|
+
In this example, the provider is aws (s3). Valid values are "aws", "rackspace", or "google".
|
39
|
+
The bucket is the s3 bucket name, or root directory for your data storage provider.
|
40
|
+
The key/secret pair differ depending on your provider. In this case, we use
|
41
|
+
aws_access_key_id/aws_secret_access_key because we're using s3.
|
42
|
+
|
43
|
+
If your provider is "rackspace":
|
44
|
+
|
45
|
+
provider: rackspace
|
46
|
+
rackspace_username: your_username
|
47
|
+
rackspace_api_key: your_key
|
48
|
+
|
49
|
+
If your provider is "google":
|
50
|
+
|
51
|
+
provider: google
|
52
|
+
google_storage_secret_access_key: your_key
|
53
|
+
google_storage_access_key_id: your_id
|
54
|
+
|
55
|
+
You can set an optional path if you want a path prefix to your site. For example, the code
|
56
|
+
below:
|
57
|
+
|
58
|
+
path: myproject
|
59
|
+
|
60
|
+
will produce a url similar to:
|
61
|
+
|
62
|
+
https://s3.amazonaws.com/some-bucket-name/myproject
|
63
|
+
|
64
|
+
If you check your rake tasks you should now see a deploy:cloud task:
|
65
|
+
|
66
|
+
rake -T
|
67
|
+
|
68
|
+
To deploy:
|
69
|
+
|
70
|
+
rake deploy:cloud
|
71
|
+
|
72
|
+
Contact
|
73
|
+
------------
|
74
|
+
You can reach me at <jack@jackchu.com>.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift 'lib'
|
7
|
+
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc "Run tests"
|
11
|
+
task :test do
|
12
|
+
Dir['test/*_test.rb'].each do |f|
|
13
|
+
require File.expand_path(f)
|
14
|
+
end
|
15
|
+
end
|
data/lib/nanoc_deploy.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'fog'
|
4
|
+
|
5
|
+
module NanocDeploy::Extra::Deployers
|
6
|
+
|
7
|
+
# A deployer that deploys a site to the cloud.
|
8
|
+
class Cloud
|
9
|
+
|
10
|
+
# Creates a new deployer that uses fog. The deployment configurations
|
11
|
+
# will be read from the configuration file of the site (which is assumed
|
12
|
+
# to be the current working directory).
|
13
|
+
#
|
14
|
+
# The deployment configurations are stored like this in the site's
|
15
|
+
# configuration file:
|
16
|
+
#
|
17
|
+
# deploy:
|
18
|
+
# NAME:
|
19
|
+
# provider: [ aws, rackspace, google ]
|
20
|
+
# path: ""
|
21
|
+
# bucket: "some-bucket-name"
|
22
|
+
#
|
23
|
+
# if your provider is "aws"
|
24
|
+
# aws_access_key_id: your_id
|
25
|
+
# aws_secret_access_key: your_key
|
26
|
+
# if your provider is "rackspace"
|
27
|
+
# rackspace_username: your_username
|
28
|
+
# rackspace_api_key: your_key
|
29
|
+
# if your provider is "google"
|
30
|
+
# google_storage_secret_access_key: your_key
|
31
|
+
# google_storage_access_key_id: your_id
|
32
|
+
#
|
33
|
+
# `NAME` is a unique name for the deployment configuration. By default,
|
34
|
+
# the deployer will use the deployment configuration named `"default"`.
|
35
|
+
#
|
36
|
+
# `BUCKET` is the name of the bucket or root directory
|
37
|
+
#
|
38
|
+
# `PATH` is a string containing the path prefix that will be used
|
39
|
+
# in the cloud. For example, a path of "stuff" will serve your files from
|
40
|
+
# `"s3.amazon.com/stuff"`. If you want to serve your static files from the root
|
41
|
+
# then leave this blank. It should not end with a trailing slash.
|
42
|
+
#
|
43
|
+
# Example: This deployment configuration defines a "default" and a
|
44
|
+
# "staging" deployment configuration. The default options are used.
|
45
|
+
#
|
46
|
+
# deploy:
|
47
|
+
# default:
|
48
|
+
# provider: aws
|
49
|
+
# bucket: mywebsite
|
50
|
+
# aws_access_key_id: 123456789
|
51
|
+
# aws_secret_access_key: ABCDEFGHIJK
|
52
|
+
# rackspace:
|
53
|
+
# provider: rackspace
|
54
|
+
# bucket: backupsite
|
55
|
+
# rackspace_username: hello
|
56
|
+
# rackspace_api_key: 123456789
|
57
|
+
def initialize
|
58
|
+
# Get site
|
59
|
+
error 'No site configuration found' unless File.file?('config.yaml')
|
60
|
+
@site = Nanoc3::Site.new('.')
|
61
|
+
end
|
62
|
+
|
63
|
+
# Runs the task. Possible params:
|
64
|
+
#
|
65
|
+
# @option params [String] :config_name (:default) The name of the
|
66
|
+
# deployment configuration to use.
|
67
|
+
#
|
68
|
+
# @return [void]
|
69
|
+
def run(params={})
|
70
|
+
# Extract params
|
71
|
+
config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default
|
72
|
+
|
73
|
+
# Validate config
|
74
|
+
error 'No deploy configuration found' if @site.config[:deploy].nil?
|
75
|
+
error "No deploy configuration found for #{config_name}" if @site.config[:deploy][config_name].nil?
|
76
|
+
|
77
|
+
# Set arguments
|
78
|
+
provider = @site.config[:deploy][config_name][:provider]
|
79
|
+
src = File.expand_path(@site.config[:output_dir]) + '/'
|
80
|
+
bucket = @site.config[:deploy][config_name][:bucket]
|
81
|
+
|
82
|
+
path = @site.config[:deploy][config_name][:path]
|
83
|
+
|
84
|
+
# Validate arguments
|
85
|
+
error 'No provider found in deployment configuration' if provider.nil?
|
86
|
+
error 'No bucket found in deployment configuration' if bucket.nil?
|
87
|
+
error 'The path requires no trailing slash' if path && path[-1,1] == '/'
|
88
|
+
|
89
|
+
case provider
|
90
|
+
when 'aws'
|
91
|
+
connection = Fog::Storage.new(
|
92
|
+
:provider => 'AWS',
|
93
|
+
:aws_access_key_id => @site.config[:deploy][config_name][:aws_access_key_id],
|
94
|
+
:aws_secret_access_key => @site.config[:deploy][config_name][:aws_secret_access_key]
|
95
|
+
)
|
96
|
+
when 'rackspace'
|
97
|
+
connection = Fog::Storage.new(
|
98
|
+
:provider => 'Rackspace',
|
99
|
+
:rackspace_username => @site.config[:deploy][config_name][:rackspace_username],
|
100
|
+
:rackspace_api_key => @site.config[:deploy][config_name][:rackspace_api_key]
|
101
|
+
)
|
102
|
+
when 'google'
|
103
|
+
connection = Fog::Storage.new(
|
104
|
+
:provider => 'Google',
|
105
|
+
:google_storage_secret_access_key => @site.config[:deploy][config_name][:google_storage_secret_access_key],
|
106
|
+
:google_storage_access_key_id => @site.config[:deploy][config_name][:google_storage_access_key_id]
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# if bucket doesn't exist, create it
|
111
|
+
begin
|
112
|
+
directory = connection.directories.get(bucket)
|
113
|
+
rescue Excon::Errors::NotFound
|
114
|
+
directory = connection.directories.create(:key => bucket)
|
115
|
+
end
|
116
|
+
|
117
|
+
# deal with buckets with more than the 1,000 key limit
|
118
|
+
files = directory.files
|
119
|
+
truncated = files.is_truncated
|
120
|
+
|
121
|
+
while truncated
|
122
|
+
set = directory.files.all(:marker => files.last.key)
|
123
|
+
truncated = set.is_truncated
|
124
|
+
files = files + set
|
125
|
+
end
|
126
|
+
|
127
|
+
# delete all the files in the bucket
|
128
|
+
files.all.each do |file|
|
129
|
+
file.destroy
|
130
|
+
end
|
131
|
+
|
132
|
+
# upload all the files in the output folder to the clouds
|
133
|
+
Dir.chdir(src)
|
134
|
+
Dir.glob('**/*').each do |file_path|
|
135
|
+
if (!File.directory?(file_path))
|
136
|
+
directory.files.create(:key => "#{path}#{file_path}", :body => File.open(file_path), :public => true)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# Prints the given message on stderr and exits.
|
144
|
+
def error(msg)
|
145
|
+
raise RuntimeError.new(msg)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'nanoc_deploy'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
module NanocDeploy::Tasks
|
7
|
+
end
|
8
|
+
|
9
|
+
Dir[File.dirname(__FILE__) + '/tasks/**/*.rb'].each { |f| load f }
|
10
|
+
Dir[File.dirname(__FILE__) + '/tasks/**/*.rake'].each { |f| Rake.application.add_import(f) }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :deploy do
|
4
|
+
desc 'Upload the compiled site to the cloud'
|
5
|
+
task :cloud do
|
6
|
+
config_name = ENV['config'] || :default
|
7
|
+
|
8
|
+
deployer = NanocDeploy::Extra::Deployers::Cloud.new
|
9
|
+
deployer.run(:config_name => config_name)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nanoc_deploy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nanoc_deploy"
|
7
|
+
s.version = NanocDeploy::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jack Chu"]
|
10
|
+
s.email = ["jack@jackchu.com"]
|
11
|
+
s.homepage = "https://github.com/kamui/nanoc_deploy"
|
12
|
+
s.summary = %q{nanoc 3.1 extension adds rake cloud deployment options using fog.}
|
13
|
+
s.description = %q{}
|
14
|
+
|
15
|
+
s.rubyforge_project = "nanoc_deploy"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency('nanoc', '>= 3.1.6')
|
23
|
+
s.add_runtime_dependency('fog', '>= 0.7.2')
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanoc_deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jack Chu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-29 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nanoc
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.1.6
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: fog
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.2
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
description: ""
|
38
|
+
email:
|
39
|
+
- jack@jackchu.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/nanoc_deploy.rb
|
54
|
+
- lib/nanoc_deploy/base.rb
|
55
|
+
- lib/nanoc_deploy/extra.rb
|
56
|
+
- lib/nanoc_deploy/extra/deployers.rb
|
57
|
+
- lib/nanoc_deploy/extra/deployers/cloud.rb
|
58
|
+
- lib/nanoc_deploy/tasks.rb
|
59
|
+
- lib/nanoc_deploy/tasks/deploy/cloud.rake
|
60
|
+
- lib/nanoc_deploy/version.rb
|
61
|
+
- nanoc_deploy.gemspec
|
62
|
+
homepage: https://github.com/kamui/nanoc_deploy
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: nanoc_deploy
|
85
|
+
rubygems_version: 1.7.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: nanoc 3.1 extension adds rake cloud deployment options using fog.
|
89
|
+
test_files: []
|
90
|
+
|