stevenson 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +103 -19
- data/assets/template_aliases.yml +4 -4
- data/lib/stevenson/application.rb +53 -0
- data/lib/stevenson/configurators/yaml_configurator.rb +3 -23
- data/lib/stevenson/input/email.rb +19 -0
- data/lib/stevenson/input/password.rb +19 -0
- data/lib/stevenson/input/select.rb +69 -0
- data/lib/stevenson/input/text.rb +28 -0
- data/lib/stevenson/input/url.rb +19 -0
- data/lib/stevenson/input.rb +51 -0
- data/lib/stevenson/version.rb +1 -1
- data/lib/stevenson.rb +4 -49
- data/spec/input/email_spec.rb +12 -0
- data/spec/input/password_spec.rb +12 -0
- data/spec/input/select_spec.rb +12 -0
- data/spec/input/text_spec.rb +12 -0
- data/spec/input/url_spec.rb +12 -0
- data/spec/input_spec.rb +38 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01532f19f37e0bbd43a680127d4471c9988edae
|
4
|
+
data.tar.gz: 0c6ccedfe334238758c7c9e1146fb93e85212350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774610b2e82f5e08bb134b231b664084f91e52b48ef4e2ecadd05f5fc71caf02da37610edfc3745cc9b719dd8ff3ff2fb3bfedd9281d741213fd03563f5cf5d8
|
7
|
+
data.tar.gz: 4d0bdf722f9ff79cb00d9592cd9610976a0415efdc993e4b47f143260cd76439d8da7c337349f330916579cec6ff79d66e2087b1cb7ef875ddc90e3e8662d8b4
|
data/README.md
CHANGED
@@ -13,17 +13,15 @@ generator.
|
|
13
13
|
|
14
14
|
Add this line to your application's Gemfile:
|
15
15
|
|
16
|
-
gem 'stevenson'
|
16
|
+
gem 'stevenson'
|
17
17
|
|
18
18
|
And then execute:
|
19
19
|
|
20
20
|
$ bundle
|
21
21
|
|
22
|
-
Or install it
|
22
|
+
Or install it globally:
|
23
23
|
|
24
|
-
$
|
25
|
-
$ cd stevenson
|
26
|
-
$ rake install
|
24
|
+
$ gem install stevenson
|
27
25
|
|
28
26
|
## Usage
|
29
27
|
|
@@ -84,19 +82,22 @@ validated as emails, validated as URLs, or limited to a certain length.
|
|
84
82
|
|
85
83
|
Here's an example of the YAML file:
|
86
84
|
|
87
|
-
#_stevenson.yml
|
85
|
+
# _stevenson.yml
|
86
|
+
|
88
87
|
'_config.yml':
|
89
88
|
title:
|
90
|
-
|
91
|
-
|
89
|
+
type: 'text'
|
90
|
+
prompt: 'Title: '
|
91
|
+
limit: 40
|
92
92
|
email:
|
93
|
-
|
94
|
-
|
93
|
+
type: 'email'
|
94
|
+
prompt: 'Email: '
|
95
95
|
description:
|
96
|
-
|
96
|
+
type: 'text'
|
97
|
+
prompt: 'Description: '
|
97
98
|
url:
|
98
|
-
|
99
|
-
|
99
|
+
type: 'url'
|
100
|
+
prompt: 'URL: '
|
100
101
|
|
101
102
|
This file will produce the following questions when
|
102
103
|
`stevenson new hello_world https://github.com/YourUsername/YourTemplate.git` is
|
@@ -111,17 +112,100 @@ used:
|
|
111
112
|
When these questions are answered, the following will be added to
|
112
113
|
`hello_world/_config.yml`:
|
113
114
|
|
114
|
-
#_config.yml
|
115
|
+
# _config.yml
|
116
|
+
|
115
117
|
title: RootsRated.com
|
116
118
|
email: info@rootsrated.com
|
117
119
|
description: This is a microsite created by RootsRated.com
|
118
120
|
url: http://www.rootsrated.com
|
119
121
|
|
120
|
-
|
121
|
-
input
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
The `prompt` attribute defines how the user should be prompted for input, the
|
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'
|
165
|
+
|
166
|
+
The first value given is the value that will be offer to the user to choose. The
|
167
|
+
second value is the value that will be written to `_config.yml`.
|
168
|
+
|
169
|
+
Optionally, you can also fetch more options from a JSON API source using the
|
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:
|
176
|
+
|
177
|
+
# http://someapi.com/source.json
|
178
|
+
|
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
|
+
}
|
195
|
+
|
196
|
+
# _stevenson.yml
|
197
|
+
|
198
|
+
favorite_color:
|
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'
|
205
|
+
|
206
|
+
Additionally, remote sources and the `options` attribute can be used together.
|
207
|
+
If two keys collide between the two, the remote source will always override the
|
208
|
+
`options` attribute.
|
125
209
|
|
126
210
|
## Similar Projects
|
127
211
|
|
data/assets/template_aliases.yml
CHANGED
@@ -25,12 +25,12 @@ rr-base:
|
|
25
25
|
rr-ironman:
|
26
26
|
git: https://github.com/RootsRated/rootsrated_hyde.git
|
27
27
|
subdirectory: ironman
|
28
|
-
rr-
|
28
|
+
rr-graphite:
|
29
29
|
git: https://github.com/RootsRated/rootsrated_hyde.git
|
30
|
-
subdirectory:
|
30
|
+
subdirectory: graphite
|
31
31
|
rr-new-balance:
|
32
32
|
git: https://github.com/RootsRated/rootsrated_hyde.git
|
33
33
|
subdirectory: new-balance
|
34
|
-
rr-ski
|
34
|
+
rr-ski:
|
35
35
|
git: https://github.com/RootsRated/rootsrated_hyde.git
|
36
|
-
subdirectory: ski
|
36
|
+
subdirectory: ski
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Stevenson
|
4
|
+
class Application < Thor
|
5
|
+
desc 'stevenson new PROJECT_NAME', 'generates a Jekyll at PROJECT_NAME'
|
6
|
+
|
7
|
+
method_option :branch,
|
8
|
+
aliases: '-b',
|
9
|
+
desc: 'The git branch you would like to use from your template'
|
10
|
+
method_option :jekyll,
|
11
|
+
type: :boolean,
|
12
|
+
aliases: '-j',
|
13
|
+
desc: 'Jekyll compiles the output directory'
|
14
|
+
method_option :subdirectory,
|
15
|
+
aliases: '-s',
|
16
|
+
desc: 'The subdirectory to use from the template, if any'
|
17
|
+
method_option :template,
|
18
|
+
aliases: '-t',
|
19
|
+
default: 'hyde-base',
|
20
|
+
desc: 'The template repository to use'
|
21
|
+
method_option :zip,
|
22
|
+
type: :boolean,
|
23
|
+
aliases: "-z",
|
24
|
+
desc: 'Zip compresses the output directory'
|
25
|
+
|
26
|
+
def new(output_directory)
|
27
|
+
# Load the template using the template loader
|
28
|
+
template = Stevenson::TemplateLoader.load options[:template]
|
29
|
+
|
30
|
+
# If a branch is provided, switch to that branch
|
31
|
+
template.switch_branch options[:branch] if options[:branch]
|
32
|
+
|
33
|
+
# If a subdirectory is provided, switch to that directory
|
34
|
+
template.select_subdirectory options[:subdirectory] if options[:subdirectory]
|
35
|
+
|
36
|
+
# Configure the template
|
37
|
+
configurator = Stevenson::Configurator::YAMLConfigurator.new template.path
|
38
|
+
configurator.configure
|
39
|
+
|
40
|
+
# If the jekyll flag is set, compile the template output
|
41
|
+
template.extend(Stevenson::OutputFilters::JekyllFilter) if options[:jekyll]
|
42
|
+
|
43
|
+
# If the zip flag is set, zip up the template output
|
44
|
+
template.extend(Stevenson::OutputFilters::ZipFilter) if options[:zip]
|
45
|
+
|
46
|
+
# Save the repo to the output directory
|
47
|
+
template.output output_directory
|
48
|
+
|
49
|
+
rescue Templates::InvalidTemplateException => e
|
50
|
+
say e.message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'highline/import'
|
2
1
|
require 'yaml'
|
3
2
|
|
4
3
|
module Stevenson
|
@@ -40,7 +39,7 @@ module Stevenson
|
|
40
39
|
private
|
41
40
|
|
42
41
|
def collect_answers(options, config)
|
43
|
-
if !options['
|
42
|
+
if !options['type'] || options['type'].is_a?(Hash)
|
44
43
|
# If the current option is not a leaf, iterate over its values
|
45
44
|
options.each do |key, value|
|
46
45
|
# If no key is present in the config, assign one
|
@@ -54,9 +53,8 @@ module Stevenson
|
|
54
53
|
# Return the new config
|
55
54
|
config
|
56
55
|
else
|
57
|
-
#
|
58
|
-
|
59
|
-
ask_question options, config
|
56
|
+
# Collect the appropriate answer for the given question
|
57
|
+
Input.input_for(options).collect!
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
@@ -76,24 +74,6 @@ module Stevenson
|
|
76
74
|
f.write config.to_yaml
|
77
75
|
end
|
78
76
|
end
|
79
|
-
|
80
|
-
def ask_question(options, default_value)
|
81
|
-
# Load the question text and highline options hash
|
82
|
-
question = options['question']
|
83
|
-
options.delete 'question'
|
84
|
-
|
85
|
-
# Ask the user the question and apply all options
|
86
|
-
answer = ask(question) do |q|
|
87
|
-
q.default = default_value if default_value != {}
|
88
|
-
q.echo = false if options['secret']
|
89
|
-
q.validate = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i if options['email']
|
90
|
-
q.validate = /https?:\/\/[\S]+/ if options['url']
|
91
|
-
q.limit = options['limit'] if options['limit']
|
92
|
-
end
|
93
|
-
|
94
|
-
# Return the user's answer
|
95
|
-
answer.to_s
|
96
|
-
end
|
97
77
|
end
|
98
78
|
end
|
99
79
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Stevenson
|
2
|
+
module Input
|
3
|
+
class Email < Text
|
4
|
+
include Base
|
5
|
+
|
6
|
+
def collect!
|
7
|
+
# Ask the user the question and apply the appropriate options
|
8
|
+
answer = ask(@prompt) do |q|
|
9
|
+
q.default = default
|
10
|
+
q.validate = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
|
11
|
+
q.limit = @limit if @limit
|
12
|
+
end
|
13
|
+
|
14
|
+
# Return the user's answer
|
15
|
+
answer.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Stevenson
|
2
|
+
module Input
|
3
|
+
class Password < Text
|
4
|
+
include Base
|
5
|
+
|
6
|
+
def collect!
|
7
|
+
# Ask the user the question and apply the appropriate options
|
8
|
+
answer = ask(@prompt) do |q|
|
9
|
+
q.default = default
|
10
|
+
q.echo = @is_secret
|
11
|
+
q.limit = @limit if @limit
|
12
|
+
end
|
13
|
+
|
14
|
+
# Return the user's answer
|
15
|
+
answer.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Stevenson
|
6
|
+
module Input
|
7
|
+
class Select
|
8
|
+
include Base
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
super
|
12
|
+
|
13
|
+
# Save the basic settings for the prompt
|
14
|
+
@prompt = options['prompt'] || ''
|
15
|
+
|
16
|
+
# Load settings from remote sources, if any
|
17
|
+
load_remote_options options['url'], options if options['url']
|
18
|
+
end
|
19
|
+
|
20
|
+
def collect!
|
21
|
+
# Prompt the user with a menu using the provided settings
|
22
|
+
choose do |menu|
|
23
|
+
menu.prompt = @prompt
|
24
|
+
|
25
|
+
options.each do |key, value|
|
26
|
+
menu.choice(key) { value }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def load_remote_options(url, options)
|
34
|
+
# Download and parse the JSON to use for options
|
35
|
+
uri = URI(url)
|
36
|
+
raw_json = Net::HTTP.get uri
|
37
|
+
json = JSON.parse raw_json
|
38
|
+
|
39
|
+
# Get the appropriate keys for processing the JSON
|
40
|
+
list_key = options['list_key'] || ''
|
41
|
+
name_key = options['name_key'] || ''
|
42
|
+
value_key = options['value_key'] || options['name_key'] || ''
|
43
|
+
|
44
|
+
# Get the array of items to generate options for
|
45
|
+
list_items = get_value_from_selector json, list_key
|
46
|
+
|
47
|
+
# For each item, fetch the name and value for each option and assign them
|
48
|
+
list_items.each do |list_item|
|
49
|
+
name = get_value_from_selector list_item, name_key
|
50
|
+
value = get_value_from_selector list_item, value_key
|
51
|
+
options[name] = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_value_from_selector(hash, selector_string)
|
56
|
+
# Split the provided selector into an array of selectors
|
57
|
+
selectors = selector_string.split '.'
|
58
|
+
|
59
|
+
# For each one, get the associated subhash from the hash
|
60
|
+
selectors.each do |selector|
|
61
|
+
hash = hash[selector] if hash
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return the resulting hash
|
65
|
+
hash
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
module Stevenson
|
4
|
+
module Input
|
5
|
+
class Text
|
6
|
+
include Input::Base
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super
|
10
|
+
|
11
|
+
# Save the basic settings for the prompt
|
12
|
+
@prompt = options['prompt'] || ''
|
13
|
+
@limit = options['limit'] || false
|
14
|
+
end
|
15
|
+
|
16
|
+
def collect!
|
17
|
+
# Ask the user the question and apply the appropriate options
|
18
|
+
answer = ask(@prompt) do |q|
|
19
|
+
q.default = default
|
20
|
+
q.limit = @limit if @limit
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return the user's answer
|
24
|
+
answer.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Stevenson
|
2
|
+
module Input
|
3
|
+
class Url < Text
|
4
|
+
include Base
|
5
|
+
|
6
|
+
def collect!
|
7
|
+
# Ask the user the question and apply the appropriate options
|
8
|
+
answer = ask(@prompt) do |q|
|
9
|
+
q.default = default
|
10
|
+
q.validate = /https?:\/\/[\S]+/
|
11
|
+
q.limit = @limit if @limit
|
12
|
+
end
|
13
|
+
|
14
|
+
# Return the user's answer
|
15
|
+
answer.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Stevenson
|
2
|
+
module Input
|
3
|
+
autoload :Email, 'stevenson/input/email'
|
4
|
+
autoload :Password, 'stevenson/input/password'
|
5
|
+
autoload :Select, 'stevenson/input/select'
|
6
|
+
autoload :Text, 'stevenson/input/text'
|
7
|
+
autoload :Url, 'stevenson/input/url'
|
8
|
+
|
9
|
+
module Base
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
def self.included(input)
|
13
|
+
input.extend ClassMethods
|
14
|
+
|
15
|
+
Stevenson.inputs[input.input_name] = input
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
def input_name
|
20
|
+
name.gsub(/^.*::/, '').downcase.to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(options, default=nil)
|
25
|
+
@options, @default = options, default
|
26
|
+
end
|
27
|
+
|
28
|
+
def collect!
|
29
|
+
raise NotImplementedError
|
30
|
+
end
|
31
|
+
|
32
|
+
def default
|
33
|
+
@default ||= options['default'] if options['default']
|
34
|
+
@default ||= ''
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.input_for(options)
|
39
|
+
input_klass = input_klass_for(options['type'])
|
40
|
+
input_klass.new(options)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.input_klass_for(type)
|
46
|
+
Stevenson.inputs[type] || const_get(type.to_s.capitalize)
|
47
|
+
rescue NameError => e
|
48
|
+
raise NameError.new "Type '#{type}' is not a valid input type.", e
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/stevenson/version.rb
CHANGED
data/lib/stevenson.rb
CHANGED
@@ -3,57 +3,12 @@ require 'stevenson/output_filters/jekyll'
|
|
3
3
|
require 'stevenson/output_filters/zip'
|
4
4
|
require 'stevenson/template_loader'
|
5
5
|
require 'stevenson/version'
|
6
|
-
require 'thor'
|
7
6
|
|
8
7
|
module Stevenson
|
8
|
+
autoload :Application, 'stevenson/application'
|
9
|
+
autoload :Input, 'stevenson/input'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
method_option :branch,
|
14
|
-
aliases: '-b',
|
15
|
-
desc: 'The git branch you would like to use from your template'
|
16
|
-
method_option :jekyll,
|
17
|
-
type: :boolean,
|
18
|
-
aliases: '-j',
|
19
|
-
desc: 'Jekyll compiles the output directory'
|
20
|
-
method_option :subdirectory,
|
21
|
-
aliases: '-s',
|
22
|
-
desc: 'The subdirectory to use from the template, if any'
|
23
|
-
method_option :template,
|
24
|
-
aliases: '-t',
|
25
|
-
default: 'hyde-base',
|
26
|
-
desc: 'The template repository to use'
|
27
|
-
method_option :zip,
|
28
|
-
type: :boolean,
|
29
|
-
aliases: "-z",
|
30
|
-
desc: 'Zip compresses the output directory'
|
31
|
-
|
32
|
-
def new(output_directory)
|
33
|
-
# Load the template using the template loader
|
34
|
-
template = Stevenson::TemplateLoader.load options[:template]
|
35
|
-
|
36
|
-
# If a branch is provided, switch to that branch
|
37
|
-
template.switch_branch options[:branch] if options[:branch]
|
38
|
-
|
39
|
-
# If a subdirectory is provided, switch to that directory
|
40
|
-
template.select_subdirectory options[:subdirectory] if options[:subdirectory]
|
41
|
-
|
42
|
-
# Configure the template
|
43
|
-
configurator = Stevenson::Configurator::YAMLConfigurator.new template.path
|
44
|
-
configurator.configure
|
45
|
-
|
46
|
-
# If the jekyll flag is set, compile the template output
|
47
|
-
template.extend(Stevenson::OutputFilters::JekyllFilter) if options[:jekyll]
|
48
|
-
|
49
|
-
# If the zip flag is set, zip up the template output
|
50
|
-
template.extend(Stevenson::OutputFilters::ZipFilter) if options[:zip]
|
51
|
-
|
52
|
-
# Save the repo to the output directory
|
53
|
-
template.output output_directory
|
54
|
-
|
55
|
-
rescue Templates::InvalidTemplateException => e
|
56
|
-
say e.message
|
57
|
-
end
|
11
|
+
def self.inputs
|
12
|
+
@_inputs ||= {}
|
58
13
|
end
|
59
14
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Stevenson::Input::Email do
|
2
|
+
describe '#initialize' do
|
3
|
+
let(:text_input) { Stevenson::Input::Email.new({}) }
|
4
|
+
|
5
|
+
it 'creates a new email input' do
|
6
|
+
expect(text_input).to be_an_instance_of Stevenson::Input::Email
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#collect!' do
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Stevenson::Input::Password do
|
2
|
+
describe '#initialize' do
|
3
|
+
let(:text_input) { Stevenson::Input::Password.new({}) }
|
4
|
+
|
5
|
+
it 'creates a new password input' do
|
6
|
+
expect(text_input).to be_an_instance_of Stevenson::Input::Password
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#collect!' do
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Stevenson::Input::Select do
|
2
|
+
describe '#initialize' do
|
3
|
+
let(:text_input) { Stevenson::Input::Select.new({}) }
|
4
|
+
|
5
|
+
it 'creates a new selection input' do
|
6
|
+
expect(text_input).to be_an_instance_of Stevenson::Input::Select
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#collect!' do
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Stevenson::Input::Text do
|
2
|
+
describe '#initialize' do
|
3
|
+
let(:text_input) { Stevenson::Input::Text.new({}) }
|
4
|
+
|
5
|
+
it 'creates a new text input' do
|
6
|
+
expect(text_input).to be_an_instance_of Stevenson::Input::Text
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#collect!' do
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Stevenson::Input::Url do
|
2
|
+
describe '#initialize' do
|
3
|
+
let(:text_input) { Stevenson::Input::Url.new({}) }
|
4
|
+
|
5
|
+
it 'creates a new url input' do
|
6
|
+
expect(text_input).to be_an_instance_of Stevenson::Input::Url
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#collect!' do
|
11
|
+
end
|
12
|
+
end
|
data/spec/input_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Stevenson::Input
|
4
|
+
class Test
|
5
|
+
include Base
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Stevenson::Input do
|
10
|
+
let(:input) { double(:test_input) }
|
11
|
+
let(:options) { Hash['type' => :test] }
|
12
|
+
before { allow(Stevenson::Input::Test).to receive(:new).and_return(input) }
|
13
|
+
|
14
|
+
describe ".input_for()" do
|
15
|
+
context "when the input has been registered previously" do
|
16
|
+
it "should return the input class from Stevenson.inputs" do
|
17
|
+
expect(Stevenson::Input.input_for(options)).to eq(input)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the input has not been registered previously" do
|
22
|
+
it "should return the fetched class from Stevenson" do
|
23
|
+
allow(Stevenson).to receive(:inputs).and_return({})
|
24
|
+
expect(Stevenson::Input.input_for(options)).to eq(input)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the input doesn't exist" do
|
29
|
+
it "should raise a NameError with a descriptive error message" do
|
30
|
+
expect { Stevenson::Input.input_for('type' => :bad_input) }.to raise_error do |error|
|
31
|
+
expect(error).to be_a(NameError)
|
32
|
+
expect(error.message).to eq("Type 'bad_input' is not a valid input type.")
|
33
|
+
expect(error.cause).to be_a(NameError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Karr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -140,7 +140,14 @@ files:
|
|
140
140
|
- assets/template_aliases.yml
|
141
141
|
- bin/stevenson
|
142
142
|
- lib/stevenson.rb
|
143
|
+
- lib/stevenson/application.rb
|
143
144
|
- lib/stevenson/configurators/yaml_configurator.rb
|
145
|
+
- lib/stevenson/input.rb
|
146
|
+
- lib/stevenson/input/email.rb
|
147
|
+
- lib/stevenson/input/password.rb
|
148
|
+
- lib/stevenson/input/select.rb
|
149
|
+
- lib/stevenson/input/text.rb
|
150
|
+
- lib/stevenson/input/url.rb
|
144
151
|
- lib/stevenson/output_filters/jekyll.rb
|
145
152
|
- lib/stevenson/output_filters/zip.rb
|
146
153
|
- lib/stevenson/template_loader.rb
|
@@ -150,6 +157,12 @@ files:
|
|
150
157
|
- lib/stevenson/version.rb
|
151
158
|
- spec/configurators/yaml_configurator_spec.rb
|
152
159
|
- spec/helpers.rb
|
160
|
+
- spec/input/email_spec.rb
|
161
|
+
- spec/input/password_spec.rb
|
162
|
+
- spec/input/select_spec.rb
|
163
|
+
- spec/input/text_spec.rb
|
164
|
+
- spec/input/url_spec.rb
|
165
|
+
- spec/input_spec.rb
|
153
166
|
- spec/output_filters/jekyll_spec.rb
|
154
167
|
- spec/output_filters/zip_spec.rb
|
155
168
|
- spec/spec_helper.rb
|
@@ -177,13 +190,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
190
|
version: '0'
|
178
191
|
requirements: []
|
179
192
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.4.6
|
181
194
|
signing_key:
|
182
195
|
specification_version: 4
|
183
196
|
summary: Stevenson is a generator for Jekyll microsites created by RootsRated.com
|
184
197
|
test_files:
|
185
198
|
- spec/configurators/yaml_configurator_spec.rb
|
186
199
|
- spec/helpers.rb
|
200
|
+
- spec/input/email_spec.rb
|
201
|
+
- spec/input/password_spec.rb
|
202
|
+
- spec/input/select_spec.rb
|
203
|
+
- spec/input/text_spec.rb
|
204
|
+
- spec/input/url_spec.rb
|
205
|
+
- spec/input_spec.rb
|
187
206
|
- spec/output_filters/jekyll_spec.rb
|
188
207
|
- spec/output_filters/zip_spec.rb
|
189
208
|
- spec/spec_helper.rb
|