kryo 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/.gitignore +1 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/README.md +29 -3
- data/bin/kryo +24 -1
- data/kryo.gemspec +0 -2
- data/lib/kryo.rb +2 -3
- data/lib/kryo/generators/base.rb +37 -0
- data/lib/kryo/generators/post/post_generator.rb +24 -0
- data/lib/kryo/generators/post/templates/post.markdown.erb +1 -0
- data/lib/kryo/generators/site/site_generator.rb +39 -0
- data/lib/kryo/generators/site/templates/Gemfile.erb +3 -0
- data/lib/kryo/generators/site/templates/config.rb.erb +16 -0
- data/lib/kryo/version.rb +1 -1
- data/spec/kryo/kryo_spec.rb +5 -0
- data/spec/spec_helper.rb +5 -0
- metadata +17 -37
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm gemset use kryo --create
|
data/README.md
CHANGED
@@ -1,17 +1,43 @@
|
|
1
1
|
# Kryo
|
2
2
|
|
3
|
-
A static
|
4
|
-
|
3
|
+
A static blog aware generator. It is a rack application, so it's not entirely
|
4
|
+
static, but it does serve the pages quickly.
|
5
5
|
|
6
|
-
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```
|
9
|
+
gem install kryo
|
10
|
+
```
|
7
11
|
|
8
12
|
## Usage
|
9
13
|
|
14
|
+
This is the basic usage I am attempting to accomplish.
|
15
|
+
|
10
16
|
```sh
|
11
17
|
kryo new blog
|
18
|
+
cd blog/
|
19
|
+
bundle install
|
20
|
+
kryo generate post some-title
|
12
21
|
kryo run
|
13
22
|
```
|
14
23
|
|
24
|
+
Similar interface with the CLI like `rails` is.
|
25
|
+
|
26
|
+
## File Structure
|
27
|
+
|
28
|
+
The file structure for this static blog generator is quite simple.
|
29
|
+
|
30
|
+
```
|
31
|
+
./source/assets # your css and images will go here
|
32
|
+
./source/posts # your posts will go here
|
33
|
+
./source/pages # any extra pages like a resume page or something will go here
|
34
|
+
./source/template # your theme will reside here
|
35
|
+
|
36
|
+
./lib # custom Ruby stuff will reside here
|
37
|
+
|
38
|
+
./public # this is where your generated content will go
|
39
|
+
```
|
40
|
+
|
15
41
|
## Contributing
|
16
42
|
|
17
43
|
Make sure you commit to a branch that is not master. Send a pull request when
|
data/bin/kryo
CHANGED
@@ -10,9 +10,32 @@ program :description, 'Kryo is a static blog generator'
|
|
10
10
|
default_command :help
|
11
11
|
|
12
12
|
command :new do |c|
|
13
|
-
c.syntax = 'kryo new
|
13
|
+
c.syntax = 'kryo new <name>'
|
14
14
|
c.description = 'Builds a new kryo application'
|
15
15
|
|
16
16
|
c.action do |args, options|
|
17
|
+
raise ArgumentError.new("'name' is required") if args.empty?
|
18
|
+
name = args[0]
|
19
|
+
Kryo::Generators::SiteGenerator.invoke(name)
|
17
20
|
end
|
18
21
|
end
|
22
|
+
|
23
|
+
command :generate do |c|
|
24
|
+
c.syntax = "kryo generate [options]"
|
25
|
+
c.description = "Generates something"
|
26
|
+
|
27
|
+
c.action do |args, options|
|
28
|
+
raise ArgumentError.new("you need to specify a generator") if args.empty?
|
29
|
+
|
30
|
+
case args[0]
|
31
|
+
when 'post'
|
32
|
+
raise ArgumentError.new("you need to specify a title for the post") if args.count < 2
|
33
|
+
title = args[1..-1].join(' ')
|
34
|
+
Kryo::Generators::PostGenerator.invoke(title)
|
35
|
+
else
|
36
|
+
raise ArgumentError.new("#{args[0]} generator doesn't exist")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
alias_command :g, :generate
|
data/kryo.gemspec
CHANGED
@@ -26,6 +26,4 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_development_dependency('rspec')
|
27
27
|
gem.add_development_dependency('rspec-core')
|
28
28
|
gem.add_development_dependency('rspec-mocks')
|
29
|
-
gem.add_development_dependency('rspec-expectations')
|
30
|
-
gem.add_development_dependency('shoulda-matchers')
|
31
29
|
end
|
data/lib/kryo.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Kryo
|
4
|
+
module Generators
|
5
|
+
|
6
|
+
# The base class for all generators to inherit from.
|
7
|
+
#
|
8
|
+
# @author Matthew A. Johnston (warmwaffles)
|
9
|
+
class Base
|
10
|
+
# Creates a file based off of the template provided.
|
11
|
+
#
|
12
|
+
# @param [String] src the source of the template file
|
13
|
+
# @param [String] destination the destination of where the generated file will go
|
14
|
+
# @param [Hash] options
|
15
|
+
# @option options [String] :name The name of the template to be written as
|
16
|
+
# @return [Boolean]
|
17
|
+
def self.create src, destination, options={}, &block
|
18
|
+
|
19
|
+
paths = File.split(src)
|
20
|
+
template_name = paths.last
|
21
|
+
template_path = paths.first
|
22
|
+
path = File.join(File.dirname(__FILE__), template_path, "#{template_name}.erb")
|
23
|
+
|
24
|
+
yield if block
|
25
|
+
|
26
|
+
erb = ERB.new(File.read(path))
|
27
|
+
output = File.join(destination, options[:name] || template_name)
|
28
|
+
|
29
|
+
file = File.open(output, 'w+')
|
30
|
+
file.write(erb.result(binding))
|
31
|
+
file.close
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'kryo/generators/base'
|
3
|
+
|
4
|
+
module Kryo
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
# Used to generate a basic post
|
8
|
+
# @author Matthew A. Johnston (warmwaffles)
|
9
|
+
class PostGenerator < Base
|
10
|
+
VALID_TYPES = %w{markdown}.freeze
|
11
|
+
|
12
|
+
def self.invoke title, type='markdown'
|
13
|
+
directory = File.join(FileUtils.pwd, 'source', 'posts')
|
14
|
+
date = DateTime.now
|
15
|
+
name = [date.strftime("%Y-%m-%d"),title.gsub(/\s+/,'-')].join('-')
|
16
|
+
name = [name, type].join('.').downcase
|
17
|
+
create "post/templates/post.#{type}", directory, name: name do
|
18
|
+
@title = title
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# <%= @title %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'kryo/generators/base'
|
3
|
+
|
4
|
+
module Kryo
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
# The standard site generator
|
8
|
+
# @author Matthew A. Johnston (warmwaffles)
|
9
|
+
class SiteGenerator < Base
|
10
|
+
|
11
|
+
# Invokes the generator
|
12
|
+
#
|
13
|
+
# @param [String] name the name of the site you want to create
|
14
|
+
# @param [String] directory the destination where the site will reside
|
15
|
+
# @return [void]
|
16
|
+
def self.invoke name, directory=FileUtils.pwd
|
17
|
+
path = File.join(directory, name)
|
18
|
+
|
19
|
+
%w{public lib}.each do |dir|
|
20
|
+
FileUtils.mkpath(File.join(path, dir))
|
21
|
+
end
|
22
|
+
|
23
|
+
FileUtils.touch(File.join(path, 'public', '.gitkeep'))
|
24
|
+
|
25
|
+
FileUtils.touch(File.join(path, 'lib', '.gitkeep'))
|
26
|
+
|
27
|
+
%w{assets pages posts template}.each do |dir|
|
28
|
+
FileUtils.mkpath(File.join(path, 'source', dir))
|
29
|
+
FileUtils.touch(File.join(path, 'source', dir, '.gitkeep'))
|
30
|
+
end
|
31
|
+
|
32
|
+
create 'site/templates/config.rb', path
|
33
|
+
create 'site/templates/Gemfile', path
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'sinatra'
|
3
|
+
|
4
|
+
def send_kryo_file path
|
5
|
+
file = File.join(File.dirname(__FILE__), 'public', path)
|
6
|
+
file = File.join(file, 'index.html') unless file =~ /\.[a-z]+$/i
|
7
|
+
send_file(file)
|
8
|
+
end
|
9
|
+
|
10
|
+
get(/.+/) do
|
11
|
+
send_kryo_file(request.path)
|
12
|
+
end
|
13
|
+
|
14
|
+
not_found do
|
15
|
+
send_file('404.html')
|
16
|
+
end
|
data/lib/kryo/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kryo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
@@ -139,38 +139,6 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rspec-expectations
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: shoulda-matchers
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
142
|
description: A quick and easy way to generate static sites
|
175
143
|
email:
|
176
144
|
- warmwaffles@gmail.com
|
@@ -180,6 +148,8 @@ extensions: []
|
|
180
148
|
extra_rdoc_files: []
|
181
149
|
files:
|
182
150
|
- .gitignore
|
151
|
+
- .rspec
|
152
|
+
- .rvmrc
|
183
153
|
- Gemfile
|
184
154
|
- LICENSE.txt
|
185
155
|
- README.md
|
@@ -187,7 +157,15 @@ files:
|
|
187
157
|
- bin/kryo
|
188
158
|
- kryo.gemspec
|
189
159
|
- lib/kryo.rb
|
160
|
+
- lib/kryo/generators/base.rb
|
161
|
+
- lib/kryo/generators/post/post_generator.rb
|
162
|
+
- lib/kryo/generators/post/templates/post.markdown.erb
|
163
|
+
- lib/kryo/generators/site/site_generator.rb
|
164
|
+
- lib/kryo/generators/site/templates/Gemfile.erb
|
165
|
+
- lib/kryo/generators/site/templates/config.rb.erb
|
190
166
|
- lib/kryo/version.rb
|
167
|
+
- spec/kryo/kryo_spec.rb
|
168
|
+
- spec/spec_helper.rb
|
191
169
|
homepage: https://github.com/warmwaffles/kryo
|
192
170
|
licenses: []
|
193
171
|
post_install_message:
|
@@ -202,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
180
|
version: '0'
|
203
181
|
segments:
|
204
182
|
- 0
|
205
|
-
hash:
|
183
|
+
hash: 2733265200132088091
|
206
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
185
|
none: false
|
208
186
|
requirements:
|
@@ -211,11 +189,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
189
|
version: '0'
|
212
190
|
segments:
|
213
191
|
- 0
|
214
|
-
hash:
|
192
|
+
hash: 2733265200132088091
|
215
193
|
requirements: []
|
216
194
|
rubyforge_project:
|
217
195
|
rubygems_version: 1.8.24
|
218
196
|
signing_key:
|
219
197
|
specification_version: 3
|
220
198
|
summary: This is similar to how Jekyll and other various static blogs function.
|
221
|
-
test_files:
|
199
|
+
test_files:
|
200
|
+
- spec/kryo/kryo_spec.rb
|
201
|
+
- spec/spec_helper.rb
|