stevenson 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -0
- data/README.md +23 -153
- data/lib/stevenson/application.rb +12 -2
- data/lib/stevenson/deployer.rb +53 -0
- data/lib/stevenson/deployers/s3.rb +40 -0
- data/lib/stevenson/template.rb +1 -1
- data/lib/stevenson/version.rb +1 -1
- data/lib/stevenson.rb +5 -0
- data/spec/lib/deployer_spec.rb +38 -0
- data/spec/lib/deployers/s3_spec.rb +3 -0
- data/spec/spec_helper.rb +3 -0
- data/stevenson.gemspec +1 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65c934219c82cb57f9ed0cb87eda58348cc6219d
|
4
|
+
data.tar.gz: ffc0f55365499f06312e1ae956f5f6847eb25072
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6adb7a7c86cc0f9616e9d44568180a3017eb3c31899e10ddeccaccf8699bcb372793c24197bb2b37425279ce34f88557776cdd03ff2204b168d5fab0b8559555
|
7
|
+
data.tar.gz: bf375e0bc19e27e9b26151d3573dbb4ad786aea0ae4bded4c906d624eedd207b76ede31bd9a315583d18d828ab0224f31385b5f2ce7725980358cf3c6e23241f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
2.1.0 (October 3rd, 2015)
|
2
|
+
- Add deployer logic
|
3
|
+
- Add S3 deployer class for sending compiled projects to S3 buckets
|
4
|
+
|
5
|
+
2.0.0 (September 30th, 2015)
|
6
|
+
- Add template aliases as dotfile
|
7
|
+
- Remove individual template config logic and inputs
|
8
|
+
- Refactor processing logic from templates, with data files, and through output filters
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Stevenson
|
2
2
|
[](https://travis-ci.org/RootsRated/stevenson)
|
3
|
+
[](http://badge.fury.io/rb/stevenson)
|
4
|
+
[](https://codeclimate.com/github/RootsRated/stevenson)
|
5
|
+
[](https://codeclimate.com/github/RootsRated/stevenson/coverage)
|
3
6
|
|
4
7
|
Stevenson is a [Jekyll](http://jekyllrb.com) microsite generator created by
|
5
8
|
RootsRated.com. Stevenson is named for Robert Louis Stevenson, author of *The
|
@@ -35,35 +38,6 @@ This will create a new directory in your current working directory named
|
|
35
38
|
`hello_world`. This directory should be a ready-to-use Jekyll
|
36
39
|
installation.
|
37
40
|
|
38
|
-
### Jekyll Compiling
|
39
|
-
|
40
|
-
Stevenson can automatically jekyll build a project and output a built directory
|
41
|
-
using the `-j` or `--jekyll`. Following the example from above, you can use the
|
42
|
-
following command:
|
43
|
-
|
44
|
-
$ stevenson new hello_world -j
|
45
|
-
|
46
|
-
This will output a directory called `hello_world` with the built assets from the
|
47
|
-
jekyll project created by the earlier command without the jekyll flag.
|
48
|
-
|
49
|
-
### Zip Output
|
50
|
-
|
51
|
-
Stevenson can also output directories as a zip archive using the `-z` or `--zip`
|
52
|
-
flags. The following command will produce the same result as the first example
|
53
|
-
as a zip archive:
|
54
|
-
|
55
|
-
$ stevenson new hello_world.zip -z
|
56
|
-
|
57
|
-
Also, the zip flag and jekyll flag can be used together to produce a built and
|
58
|
-
compress out like so:
|
59
|
-
|
60
|
-
$ stevenson new hello_world.zip -z -j
|
61
|
-
|
62
|
-
This will output a file called `hello_world.zip` with a ready-built website.
|
63
|
-
|
64
|
-
Remember that the first argument to `stevenson new` should have a `.zip` on the
|
65
|
-
end, as stevenson will not automatically add this extension.
|
66
|
-
|
67
41
|
### Templates
|
68
42
|
|
69
43
|
By default, stevenson will use RootsRated's
|
@@ -74,138 +48,27 @@ option, like so:
|
|
74
48
|
$ stevenson new hello_world -t https://github.com/YourUsername/YourTemplate.git
|
75
49
|
|
76
50
|
This will clone the repo at `https://github.com/YourUsername/YourTemplate.git`
|
77
|
-
to `hello_world
|
78
|
-
YAML file in your template's root directory named `_stevenson.yml`. This file
|
79
|
-
should contain config options to be set in various files of your Jekyll
|
80
|
-
installation along with information on whether these options should be secret,
|
81
|
-
validated as emails, validated as URLs, or limited to a certain length.
|
82
|
-
|
83
|
-
Here's an example of the YAML file:
|
84
|
-
|
85
|
-
# _stevenson.yml
|
86
|
-
|
87
|
-
'_config.yml':
|
88
|
-
title:
|
89
|
-
type: 'text'
|
90
|
-
prompt: 'Title: '
|
91
|
-
limit: 40
|
92
|
-
email:
|
93
|
-
type: 'email'
|
94
|
-
prompt: 'Email: '
|
95
|
-
description:
|
96
|
-
type: 'text'
|
97
|
-
prompt: 'Description: '
|
98
|
-
url:
|
99
|
-
type: 'url'
|
100
|
-
prompt: 'URL: '
|
101
|
-
|
102
|
-
This file will produce the following questions when
|
103
|
-
`stevenson new hello_world https://github.com/YourUsername/YourTemplate.git` is
|
104
|
-
used:
|
105
|
-
|
106
|
-
$ stevenson new hello_world -t https://github.com/YourUsername/YourTemplate.git
|
107
|
-
Title: My Site
|
108
|
-
Email: info@example.org
|
109
|
-
Description: Lorem Ipsum...
|
110
|
-
URL: http://www.example.org
|
111
|
-
|
112
|
-
When these questions are answered, the following will be added to
|
113
|
-
`hello_world/_config.yml`:
|
114
|
-
|
115
|
-
# _config.yml
|
116
|
-
|
117
|
-
title: RootsRated.com
|
118
|
-
email: info@rootsrated.com
|
119
|
-
description: This is a microsite created by RootsRated.com
|
120
|
-
url: http://www.rootsrated.com
|
51
|
+
to `hello_world`.
|
121
52
|
|
122
|
-
|
123
|
-
`type` attribute specifies which kind of input the prompt should accept, and any
|
124
|
-
values already set in the `_config.yml` will be used as defaults for these
|
125
|
-
questions. Alternatively, defaults can be overriden with a `default` attribute.
|
126
|
-
|
127
|
-
### Input Types
|
128
|
-
|
129
|
-
There are several input types available now, and hopefully, there will be more
|
130
|
-
in the future.
|
131
|
-
|
132
|
-
#### Text
|
133
|
-
|
134
|
-
The most basic input is the text input. This simply accepts a text string.
|
135
|
-
Optionally, a limit can be added with the `limit` attribute.
|
136
|
-
|
137
|
-
#### Email
|
138
|
-
|
139
|
-
This input is a subclass of the text input that only accepts emails as validated
|
140
|
-
with the following regex: `/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i`.
|
141
|
-
Additionally, Email has the same options as Text.
|
142
|
-
|
143
|
-
#### Password
|
144
|
-
|
145
|
-
This input is also a subclass of text, but unlike text, it will not output the
|
146
|
-
input string to the console for added security.
|
147
|
-
|
148
|
-
#### Url
|
149
|
-
|
150
|
-
This input, another subclass of text, accepts only text that satisfies this
|
151
|
-
regex: `/https?:\/\/[\S]+/`.
|
152
|
-
|
153
|
-
#### Select
|
154
|
-
|
155
|
-
This input prompts the user to choose from a list of given options. The options
|
156
|
-
can be provided as subkeys to the `options` attribute like so:
|
157
|
-
|
158
|
-
favorite_color:
|
159
|
-
type: 'select'
|
160
|
-
prompt: 'Favorite Color: '
|
161
|
-
options:
|
162
|
-
'Red': '#FF0000'
|
163
|
-
'Blue': '#00FF00'
|
164
|
-
'Green': '#0000FF'
|
53
|
+
### Zip Output
|
165
54
|
|
166
|
-
|
167
|
-
|
55
|
+
Stevenson can output directories as a zip archive using the `-z` or `--zip`
|
56
|
+
flags. The following command will produce a zipped version of the first
|
57
|
+
example's result:
|
168
58
|
|
169
|
-
|
170
|
-
`url`, `list_key`, `name_key`, and `value_key` attributes. `url` specifies the
|
171
|
-
url to fetch json options from. `list_key` specifies the root element of the
|
172
|
-
JSON document to iterate over for options. `name_key` specifies the name from
|
173
|
-
each iterated item to use as a name. `value_key` specifies the value from each
|
174
|
-
iterated item to use as a value. The following example is identical to the
|
175
|
-
previous example using the `options` attribute:
|
59
|
+
$ stevenson new hello_world.zip -z
|
176
60
|
|
177
|
-
|
61
|
+
This will output a file called `hello_world.zip` with a ready-built website.
|
178
62
|
|
179
|
-
|
180
|
-
"response": [
|
181
|
-
{
|
182
|
-
"name": "Red",
|
183
|
-
"value": "#FF0000"
|
184
|
-
},
|
185
|
-
{
|
186
|
-
"name": "Blue",
|
187
|
-
"value": "#00FF00"
|
188
|
-
},
|
189
|
-
{
|
190
|
-
"name": "Green",
|
191
|
-
"value": "#0000FF"
|
192
|
-
}
|
193
|
-
]
|
194
|
-
}
|
63
|
+
### S3 Deploy
|
195
64
|
|
196
|
-
|
65
|
+
Stevenson can deploy projects to S3 using the `--s3` flag. The following
|
66
|
+
command will deploy the resulting output to S3:
|
197
67
|
|
198
|
-
|
199
|
-
type: 'select'
|
200
|
-
prompt: 'Favorite Color: '
|
201
|
-
url: 'http://someapi.com/source.json'
|
202
|
-
list_key: 'response'
|
203
|
-
name_key: 'name'
|
204
|
-
value_key: 'value'
|
68
|
+
$ stevenson new hello_world.zip --s3=bucket file_key AWS_KEY AWS_SECRET
|
205
69
|
|
206
|
-
Additionally,
|
207
|
-
|
208
|
-
`options` attribute.
|
70
|
+
Additionally, Stevenson can use the `AWS_ACCESS_KEY_ID` and
|
71
|
+
`AWS_SECRET_ACCESS_KEY` environment variables.
|
209
72
|
|
210
73
|
## Similar Projects
|
211
74
|
|
@@ -228,3 +91,10 @@ idea a while back, but unfortunately it hasn't been updated in over 2 years.
|
|
228
91
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
229
92
|
4. Push to the branch (`git push origin my-new-feature`)
|
230
93
|
5. Create a new Pull Request
|
94
|
+
|
95
|
+
### Contributors
|
96
|
+
|
97
|
+
- [Dylan Karr](https://github.com/dylankarr)
|
98
|
+
- [Scott BonAmi](http://github.com/sbonami)
|
99
|
+
|
100
|
+
Don't forget to check out other open-source projects from [RootsRated](http://github.com/RootsRated)!
|
@@ -22,9 +22,10 @@ module Stevenson
|
|
22
22
|
aliases: "-d",
|
23
23
|
desc: 'The path to related data yml files'
|
24
24
|
|
25
|
-
# Output Options
|
25
|
+
# Output Filter Options
|
26
26
|
method_option :output,
|
27
27
|
type: :array,
|
28
|
+
enum: [:zip],
|
28
29
|
aliases: "-o",
|
29
30
|
desc: 'Array of output filters to be applied in order'
|
30
31
|
method_option :zip,
|
@@ -32,6 +33,12 @@ module Stevenson
|
|
32
33
|
aliases: "-z",
|
33
34
|
desc: 'Zip compresses the output directory'
|
34
35
|
|
36
|
+
# Deploy Options
|
37
|
+
method_option :s3,
|
38
|
+
type: :array,
|
39
|
+
banner: 'bucket key access_key access_secret',
|
40
|
+
desc: 'The s3 information necessary for deploying to S3'
|
41
|
+
|
35
42
|
def new(output_directory, config_path)
|
36
43
|
# Load the template using the template loader
|
37
44
|
template = Stevenson::Template.load(options[:template], options)
|
@@ -41,7 +48,10 @@ module Stevenson
|
|
41
48
|
template.place_files(options[:data], '_data') if options[:data]
|
42
49
|
|
43
50
|
# Run output filters, in order, against the template
|
44
|
-
|
51
|
+
directory = Stevenson::OutputFilter.generate!(template, options)
|
52
|
+
|
53
|
+
# Run deployers against filtered template directory
|
54
|
+
Stevenson::Deployer.deploy(directory, options)
|
45
55
|
|
46
56
|
rescue StandardError => e
|
47
57
|
say e.message
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Stevenson
|
2
|
+
module Deployer
|
3
|
+
autoload :S3, 'stevenson/deployers/s3'
|
4
|
+
|
5
|
+
module Base
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def self.included(deployer)
|
9
|
+
deployer.extend ClassMethods
|
10
|
+
|
11
|
+
Stevenson.deployers[deployer.deployer_name] = deployer
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def deployer_name
|
16
|
+
name.gsub(/^.*::/, '').downcase.to_sym
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(options)
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
def deploy!(directory)
|
25
|
+
raise NotImplementedError
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
def deploy(directory, options)
|
31
|
+
deployers_for(options).each do |deployer|
|
32
|
+
deployer.new(options).deploy!(directory)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def deployers_for(options)
|
39
|
+
[].tap do |deployers|
|
40
|
+
deployers << deployer_for(:s3) if options.keys.include?("s3")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def deployer_for(type)
|
45
|
+
Stevenson.deployers.fetch(type, nil) || const_get(type.to_s.capitalize)
|
46
|
+
rescue NameError
|
47
|
+
raise InvalidDeployerException.new "Type '#{type}' is not a valid deployer."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class InvalidDeployerException < StandardError; end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'fog'
|
2
|
+
|
3
|
+
module Stevenson
|
4
|
+
module Deployer
|
5
|
+
class S3
|
6
|
+
include Deployer::Base
|
7
|
+
|
8
|
+
attr_reader :deployment_bucket_name, :deployment_key
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@deployment_bucket_name, @deployment_key, @deployment_access_key, @deployment_access_secret = options["s3"]
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def deploy!(directory)
|
16
|
+
Dir.glob("#{directory}/**/*").each do |file|
|
17
|
+
s3_bucket.files.create(
|
18
|
+
key: File.join(deployment_key, file.partition(directory).last),
|
19
|
+
body: File.read(file),
|
20
|
+
public: true,
|
21
|
+
) if File.file?(file)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def fog
|
28
|
+
@_fog ||= Fog::Storage.new(
|
29
|
+
provider: 'AWS',
|
30
|
+
aws_access_key_id: @deployment_access_key || ENV["AWS_ACCESS_KEY_ID"],
|
31
|
+
aws_secret_access_key: @deployment_access_secret || ENV["AWS_SECRET_ACCESS_KEY"],
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def s3_bucket
|
36
|
+
@_s3_bucket = fog.directories.new(key: deployment_bucket_name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/stevenson/template.rb
CHANGED
data/lib/stevenson/version.rb
CHANGED
data/lib/stevenson.rb
CHANGED
@@ -2,10 +2,15 @@ require 'stevenson/version'
|
|
2
2
|
|
3
3
|
module Stevenson
|
4
4
|
autoload :Application, 'stevenson/application'
|
5
|
+
autoload :Deployer, 'stevenson/deployer'
|
5
6
|
autoload :Dotfile, 'stevenson/dotfile'
|
6
7
|
autoload :Template, 'stevenson/template'
|
7
8
|
autoload :OutputFilter, 'stevenson/output_filter'
|
8
9
|
|
10
|
+
def self.deployers
|
11
|
+
@_deployers ||= {}
|
12
|
+
end
|
13
|
+
|
9
14
|
def self.dotfile
|
10
15
|
@_dotfile ||= Dotfile.new
|
11
16
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Stevenson::Deployer::Test
|
2
|
+
include Stevenson::Deployer::Base
|
3
|
+
end
|
4
|
+
|
5
|
+
describe Stevenson::Deployer do
|
6
|
+
let(:deployer) { Stevenson::Deployer::Test }
|
7
|
+
|
8
|
+
describe ".deploy(directory, options)" do
|
9
|
+
let(:directory) { "/tmp/path/to/template" }
|
10
|
+
let(:options) { Hash.new }
|
11
|
+
let(:deployer) { double(:deployer, deploy!: true) }
|
12
|
+
subject { described_class.generate!(template, options) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".deployer_for()" do
|
16
|
+
context "when the deployer has been registered previously" do
|
17
|
+
it "should return the deployer class from Stevenson.deployers" do
|
18
|
+
expect(Stevenson::Deployer.send(:deployer_for, :test)).to eq(deployer)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when the deployer has not been registered previously" do
|
23
|
+
it "should return the deployer class from Stevenson.deployers" do
|
24
|
+
allow(Stevenson).to receive(:deployers).and_return({})
|
25
|
+
expect(Stevenson::Deployer.send(:deployer_for, :test)).to eq(deployer)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the deployer doesn't exist" do
|
30
|
+
it "should raise a NameError with a descriptive error message" do
|
31
|
+
expect { Stevenson::Deployer.send(:deployer_for, :bad_deployer) }.to raise_error do |error|
|
32
|
+
expect(error).to be_a(Stevenson::Deployer::InvalidDeployerException)
|
33
|
+
expect(error.message).to eq("Type 'bad_deployer' is not a valid deployer.")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/stevenson.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stevenson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RootsRated
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fog
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: hashie
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +161,7 @@ files:
|
|
147
161
|
- ".gitignore"
|
148
162
|
- ".rspec"
|
149
163
|
- ".travis.yml"
|
164
|
+
- CHANGELOG.md
|
150
165
|
- Gemfile
|
151
166
|
- LICENSE.txt
|
152
167
|
- README.md
|
@@ -155,6 +170,8 @@ files:
|
|
155
170
|
- bin/stevenson
|
156
171
|
- lib/stevenson.rb
|
157
172
|
- lib/stevenson/application.rb
|
173
|
+
- lib/stevenson/deployer.rb
|
174
|
+
- lib/stevenson/deployers/s3.rb
|
158
175
|
- lib/stevenson/dotfile.rb
|
159
176
|
- lib/stevenson/output_filter.rb
|
160
177
|
- lib/stevenson/output_filter/generator.rb
|
@@ -167,6 +184,8 @@ files:
|
|
167
184
|
- lib/stevenson/version.rb
|
168
185
|
- spec/bin/.gitkeep
|
169
186
|
- spec/helpers.rb
|
187
|
+
- spec/lib/deployer_spec.rb
|
188
|
+
- spec/lib/deployers/s3_spec.rb
|
170
189
|
- spec/lib/output_filter/generator_spec.rb
|
171
190
|
- spec/lib/output_filter_spec.rb
|
172
191
|
- spec/lib/output_filters/jekyll_spec.rb
|
@@ -204,6 +223,8 @@ summary: Stevenson is a generator for Jekyll microsites created by RootsRated.co
|
|
204
223
|
test_files:
|
205
224
|
- spec/bin/.gitkeep
|
206
225
|
- spec/helpers.rb
|
226
|
+
- spec/lib/deployer_spec.rb
|
227
|
+
- spec/lib/deployers/s3_spec.rb
|
207
228
|
- spec/lib/output_filter/generator_spec.rb
|
208
229
|
- spec/lib/output_filter_spec.rb
|
209
230
|
- spec/lib/output_filters/jekyll_spec.rb
|