neverprint 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.markdown +1 -0
- data/ROADMAP.markdown +0 -0
- data/Rakefile +93 -0
- data/bin/neverprint +69 -0
- data/lib/neverprint.rb +53 -0
- data/lib/neverprint/command.rb +27 -0
- data/lib/neverprint/commands/new.rb +38 -0
- data/neverprint.gemspec +44 -0
- metadata +90 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Antoine Lafontaine
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Neverprint extends Jekyll
|
data/ROADMAP.markdown
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rdoc'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
|
7
|
+
|
8
|
+
#############################################################################
|
9
|
+
#
|
10
|
+
# Helper functions
|
11
|
+
#
|
12
|
+
#############################################################################
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
16
|
+
end
|
17
|
+
|
18
|
+
def version
|
19
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
20
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
21
|
+
end
|
22
|
+
|
23
|
+
def date
|
24
|
+
Date.today.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def rubyforge_project
|
28
|
+
name
|
29
|
+
end
|
30
|
+
|
31
|
+
def gemspec_file
|
32
|
+
"#{name}.gemspec"
|
33
|
+
end
|
34
|
+
|
35
|
+
def gem_file
|
36
|
+
"#{name}-#{version}.gem"
|
37
|
+
end
|
38
|
+
|
39
|
+
def replace_header(head, header_name)
|
40
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
41
|
+
end
|
42
|
+
|
43
|
+
#############################################################################
|
44
|
+
#
|
45
|
+
# Packaging tasks
|
46
|
+
#
|
47
|
+
#############################################################################
|
48
|
+
|
49
|
+
task :release => :build do
|
50
|
+
unless `git branch` =~ /^\* master$/
|
51
|
+
puts "You must be on the master branch to release!"
|
52
|
+
exit!
|
53
|
+
end
|
54
|
+
sh "git commit --allow-empty -m 'Release #{version}'"
|
55
|
+
sh "git tag v#{version}"
|
56
|
+
sh "git push origin master"
|
57
|
+
sh "git push origin v#{version}"
|
58
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
59
|
+
end
|
60
|
+
|
61
|
+
task :build => :gemspec do
|
62
|
+
sh "mkdir -p pkg"
|
63
|
+
sh "gem build #{gemspec_file}"
|
64
|
+
sh "mv #{gem_file} pkg"
|
65
|
+
end
|
66
|
+
|
67
|
+
task :gemspec do
|
68
|
+
# read spec file and split out manifest section
|
69
|
+
spec = File.read(gemspec_file)
|
70
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
71
|
+
|
72
|
+
# replace name version and date
|
73
|
+
replace_header(head, :name)
|
74
|
+
replace_header(head, :version)
|
75
|
+
replace_header(head, :date)
|
76
|
+
#comment this out if your rubyforge_project has a different name
|
77
|
+
replace_header(head, :rubyforge_project)
|
78
|
+
|
79
|
+
# determine file list from git ls-files
|
80
|
+
files = `git ls-files`.
|
81
|
+
split("\n").
|
82
|
+
sort.
|
83
|
+
reject { |file| file =~ /^\./ }.
|
84
|
+
reject { |file| file =~ /^(rdoc|pkg|coverage)/ }.
|
85
|
+
map { |file| " #{file}" }.
|
86
|
+
join("\n")
|
87
|
+
|
88
|
+
# piece file back together and write
|
89
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
90
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
91
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
92
|
+
puts "Updated #{gemspec_file}"
|
93
|
+
end
|
data/bin/neverprint
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
STDOUT.sync = true
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
5
|
+
|
6
|
+
require 'commander/import'
|
7
|
+
require 'jekyll'
|
8
|
+
|
9
|
+
Jekyll::Deprecator.process(ARGV)
|
10
|
+
|
11
|
+
program :name, 'neverprint'
|
12
|
+
program :version, Neverprint::VERSION
|
13
|
+
program :description, 'Neverprint extends Jekyll.'
|
14
|
+
|
15
|
+
default_command :help
|
16
|
+
|
17
|
+
command :new do |c|
|
18
|
+
c.syntax = 'neverprint new PATH'
|
19
|
+
c.description = 'Adds neverprint files to an existing Jekyll site.'
|
20
|
+
|
21
|
+
c.option '--force', 'Force creation even if PATH already exists'
|
22
|
+
|
23
|
+
c.action do |args, options|
|
24
|
+
Neverprint::Commands::New.process(args, options.__hash__)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
command :build do |c|
|
29
|
+
c.syntax = 'neverprint build [options]'
|
30
|
+
c.description = 'Build your site (same as "jekyll build")'
|
31
|
+
|
32
|
+
c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
33
|
+
c.option '--future', 'Publishes posts with a future date'
|
34
|
+
c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
|
35
|
+
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
36
|
+
c.option '--lsi', 'Use LSI for improved related posts'
|
37
|
+
c.option '--drafts', 'Render posts in the _drafts folder'
|
38
|
+
|
39
|
+
c.action do |args, options|
|
40
|
+
options = normalize_options(options.__hash__)
|
41
|
+
options = Jekyll.configuration(options)
|
42
|
+
Jekyll::Commands::Build.process(options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
command :serve do |c|
|
47
|
+
c.syntax = 'neverprint serve [options]'
|
48
|
+
c.description = 'Serve your site locally (same as "jekyll serve")'
|
49
|
+
|
50
|
+
c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
51
|
+
c.option '--future', 'Publishes posts with a future date'
|
52
|
+
c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
|
53
|
+
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
54
|
+
c.option '--lsi', 'Use LSI for improved related posts'
|
55
|
+
c.option '--drafts', 'Render posts in the _drafts folder'
|
56
|
+
|
57
|
+
c.option '-p', '--port [PORT]', 'Port to listen on'
|
58
|
+
c.option '-h', '--host [HOST]', 'Host to bind to'
|
59
|
+
c.option '-b', '--baseurl [URL]', 'Base URL'
|
60
|
+
|
61
|
+
c.action do |args, options|
|
62
|
+
options.default :serving => true
|
63
|
+
|
64
|
+
options = normalize_options(options.__hash__)
|
65
|
+
options = Jekyll.configuration(options)
|
66
|
+
Jekyll::Commands::Build.process(options)
|
67
|
+
Jekyll::Commands::Serve.process(options)
|
68
|
+
end
|
69
|
+
end
|
data/lib/neverprint.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Require all of the Ruby files in the given directory.
|
2
|
+
#
|
3
|
+
# path - The String relative path from here to the directory.
|
4
|
+
#
|
5
|
+
# Returns nothing.
|
6
|
+
def require_all(path)
|
7
|
+
glob = File.join(File.dirname(__FILE__), path, '*.rb')
|
8
|
+
Dir[glob].each do |f|
|
9
|
+
require f
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# rubygems
|
14
|
+
require 'rubygems'
|
15
|
+
|
16
|
+
# stdlib
|
17
|
+
require 'fileutils'
|
18
|
+
require 'time'
|
19
|
+
# require 'safe_yaml'
|
20
|
+
# require 'English'
|
21
|
+
|
22
|
+
# leverage jekyll
|
23
|
+
|
24
|
+
require 'jekyll/stevenson'
|
25
|
+
require 'jekyll/configuration'
|
26
|
+
|
27
|
+
# extensions
|
28
|
+
require 'neverprint/command'
|
29
|
+
|
30
|
+
require_all 'neverprint/commands'
|
31
|
+
|
32
|
+
# SafeYAML::OPTIONS[:suppress_warnings] = true
|
33
|
+
|
34
|
+
module Neverprint
|
35
|
+
VERSION = '0.1.0'
|
36
|
+
|
37
|
+
def self.configuration(override)
|
38
|
+
config = Configuration[Configuration::DEFAULTS]
|
39
|
+
override = Configuration[override].stringify_keys
|
40
|
+
config = config.read_config_files(config.config_files(override))
|
41
|
+
|
42
|
+
# Merge DEFAULTS < _config.yml < override
|
43
|
+
config = config.deep_merge(override).stringify_keys
|
44
|
+
set_timezone(config['timezone']) if config['timezone']
|
45
|
+
|
46
|
+
config
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.set_timezone(timezone)
|
50
|
+
ENV['TZ'] = timezone
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Neverprint
|
2
|
+
class Command
|
3
|
+
def self.globs(source, destination)
|
4
|
+
Dir.chdir(source) do
|
5
|
+
dirs = Dir['*'].select { |x| File.directory?(x) }
|
6
|
+
dirs -= [destination, File.expand_path(destination), File.basename(destination)]
|
7
|
+
dirs = dirs.map { |x| "#{x}/**/*" }
|
8
|
+
dirs += ['*']
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Static: Run Site#process and catch errors
|
13
|
+
#
|
14
|
+
# site - the Jekyll::Site object
|
15
|
+
#
|
16
|
+
# Returns nothing
|
17
|
+
def self.process_site(site)
|
18
|
+
site.process
|
19
|
+
rescue Jekyll::FatalException => e
|
20
|
+
puts
|
21
|
+
Jekyll::Stevenson.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
22
|
+
Jekyll::Stevenson.error "", "------------------------------------"
|
23
|
+
Jekyll::Stevenson.error "", e.message
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Neverprint
|
4
|
+
module Commands
|
5
|
+
class New < Jekyll::Command
|
6
|
+
def self.process(args, options = {})
|
7
|
+
raise ArgumentError.new('You must specify a path.') if args.empty?
|
8
|
+
|
9
|
+
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
10
|
+
FileUtils.mkdir_p new_blog_path
|
11
|
+
if preserve_source_location?(new_blog_path, options)
|
12
|
+
Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty."
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
create_sample_files new_blog_path
|
17
|
+
|
18
|
+
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
|
19
|
+
f.write(self.scaffold_post_content(site_template))
|
20
|
+
end
|
21
|
+
puts "Neverprint sauce added to your jekyll site in #{new_blog_path}."
|
22
|
+
end
|
23
|
+
|
24
|
+
# Internal: Gets the filename of the sample post to be created
|
25
|
+
#
|
26
|
+
# Returns the filename of the sample post, as a String
|
27
|
+
def self.initialized_post_name
|
28
|
+
"_posts/#{Time.now.strftime('%Y-%m-%d')}-welcome-to-neverprint.markdown"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.scaffold_path
|
34
|
+
"_posts/0000-00-00-welcome-to-neverprint.markdown.erb"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/neverprint.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
4
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
5
|
+
s.rubygems_version = '1.3.5'
|
6
|
+
|
7
|
+
s.name = 'neverprint'
|
8
|
+
s.version = '0.1.0'
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.date = '2013-05-26'
|
11
|
+
s.rubyforge_project = 'neverprint'
|
12
|
+
|
13
|
+
s.summary = "Neverprint extends Jekyll."
|
14
|
+
s.description = "Neverprint extends Jekyll by adding support for Haml templates, Sass and Coffeescript."
|
15
|
+
|
16
|
+
s.authors = ["Antoine Lafontaine"]
|
17
|
+
s.email = 'antoine.lafontaine@neverprint.com'
|
18
|
+
s.homepage = 'http://github.com/neverprint/neverprint'
|
19
|
+
|
20
|
+
s.require_paths = %w[lib]
|
21
|
+
|
22
|
+
s.executables = ["neverprint"]
|
23
|
+
|
24
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
25
|
+
s.extra_rdoc_files = %w[README.markdown LICENSE]
|
26
|
+
|
27
|
+
s.add_runtime_dependency('jekyll', "~> 1.0.2")
|
28
|
+
|
29
|
+
# = MANIFEST =
|
30
|
+
s.files = %w[
|
31
|
+
Gemfile
|
32
|
+
LICENSE
|
33
|
+
README.markdown
|
34
|
+
ROADMAP.markdown
|
35
|
+
Rakefile
|
36
|
+
bin/neverprint
|
37
|
+
lib/neverprint.rb
|
38
|
+
lib/neverprint/command.rb
|
39
|
+
lib/neverprint/commands/new.rb
|
40
|
+
neverprint.gemspec
|
41
|
+
]
|
42
|
+
# = MANIFEST =
|
43
|
+
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neverprint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Antoine Lafontaine
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-05-26 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: jekyll
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
version: 1.0.2
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: Neverprint extends Jekyll by adding support for Haml templates, Sass and Coffeescript.
|
37
|
+
email: antoine.lafontaine@neverprint.com
|
38
|
+
executables:
|
39
|
+
- neverprint
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README.markdown
|
44
|
+
- LICENSE
|
45
|
+
files:
|
46
|
+
- Gemfile
|
47
|
+
- LICENSE
|
48
|
+
- README.markdown
|
49
|
+
- ROADMAP.markdown
|
50
|
+
- Rakefile
|
51
|
+
- bin/neverprint
|
52
|
+
- lib/neverprint.rb
|
53
|
+
- lib/neverprint/command.rb
|
54
|
+
- lib/neverprint/commands/new.rb
|
55
|
+
- neverprint.gemspec
|
56
|
+
homepage: http://github.com/neverprint/neverprint
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: neverprint
|
85
|
+
rubygems_version: 1.8.25
|
86
|
+
signing_key:
|
87
|
+
specification_version: 2
|
88
|
+
summary: Neverprint extends Jekyll.
|
89
|
+
test_files: []
|
90
|
+
|