staticpress 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Rakefile +46 -1
- data/features/happy_path.feature +10 -0
- data/features/step_definitions/staticpress_steps.rb +4 -0
- data/lib/staticpress.rb +2 -2
- data/lib/staticpress/cli.rb +13 -5
- data/lib/staticpress/content/base.rb +13 -4
- data/lib/staticpress/content/category.rb +21 -4
- data/lib/staticpress/content/index.rb +18 -5
- data/lib/staticpress/content/page.rb +6 -2
- data/lib/staticpress/content/resource_content.rb +3 -1
- data/lib/staticpress/content/tag.rb +21 -4
- data/lib/staticpress/helpers.rb +8 -1
- data/lib/staticpress/js_object.rb +4 -0
- data/lib/staticpress/settings.rb +18 -0
- data/lib/staticpress/site.rb +18 -6
- data/lib/staticpress/version.rb +9 -5
- data/staticpress.gemspec +1 -1
- data/tests/staticpress/content/base_test.rb +2 -1
- data/tests/staticpress/content/category_test.rb +26 -3
- data/tests/staticpress/content/index_test.rb +36 -0
- data/tests/staticpress/content/tag_test.rb +12 -3
- data/tests/staticpress/helpers_test.rb +13 -12
- data/tests/staticpress/js_object_test.rb +6 -0
- data/tests/staticpress/settings_test.rb +13 -0
- data/tests/staticpress_test.rb +3 -3
- data/tests/test_blog/Gemfile +1 -1
- data/tests/test_case.rb +11 -0
- metadata +27 -25
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ task :tests, :path do |t, args|
|
|
8
8
|
args.with_defaults(:path => 'tests')
|
9
9
|
|
10
10
|
run_recursively = lambda do |dir|
|
11
|
-
Pathname
|
11
|
+
Pathname(dir).expand_path.children.each do |dir_or_test|
|
12
12
|
if dir_or_test.directory?
|
13
13
|
run_recursively.call dir_or_test
|
14
14
|
elsif dir_or_test.to_s.end_with? '_test.rb'
|
@@ -19,3 +19,48 @@ task :tests, :path do |t, args|
|
|
19
19
|
|
20
20
|
run_recursively.call args[:path]
|
21
21
|
end
|
22
|
+
|
23
|
+
desc 'Enumerate annotations. Optionally takes a pipe-separated list of tags to process'
|
24
|
+
task :notes, :types do |t, args|
|
25
|
+
args.with_defaults :types => 'FIXME|TODO'
|
26
|
+
|
27
|
+
types = args[:types].split '|'
|
28
|
+
finder = /.*# ?(?<type>[A-Z]+):? (?<note>.+)$/
|
29
|
+
result = Hash.new { |hash, key| hash[key] = {} }
|
30
|
+
|
31
|
+
`git ls-files`.split("\n").each do |p|
|
32
|
+
path = Pathname(p)
|
33
|
+
line_number = 0
|
34
|
+
|
35
|
+
path.each_line do |line|
|
36
|
+
line_number += 1
|
37
|
+
|
38
|
+
if match = finder.match(line)
|
39
|
+
result[path][line_number] = { :type => match[:type], :note => match[:note] } if types.include? match[:type]
|
40
|
+
end
|
41
|
+
end rescue nil
|
42
|
+
end
|
43
|
+
|
44
|
+
numbers = []
|
45
|
+
|
46
|
+
result.each do |path, lines|
|
47
|
+
lines.each do |number, note|
|
48
|
+
numbers << number
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
number_width = numbers.max.to_s.length
|
53
|
+
type_width = types.max_by { |type| type.to_s.length }.to_s.length
|
54
|
+
|
55
|
+
result.each do |path, lines|
|
56
|
+
puts "\e[1m#{path}\e[0m:"
|
57
|
+
|
58
|
+
lines.each do |number, note|
|
59
|
+
line_number = "[\e[1m#{number.to_s.rjust(number_width)}\e[0m]"
|
60
|
+
type = "[\e[0;37m#{note[:type]}\e[0m]"
|
61
|
+
puts " * #{line_number} #{type.ljust(type_width + type.length - note[:type].length)} #{note[:note]}"
|
62
|
+
end
|
63
|
+
|
64
|
+
puts
|
65
|
+
end
|
66
|
+
end
|
data/features/happy_path.feature
CHANGED
@@ -93,6 +93,11 @@ Feature: The happy path
|
|
93
93
|
| public/index.html |
|
94
94
|
| public/about/index.html |
|
95
95
|
|
96
|
+
Scenario: Building a site (verbose)
|
97
|
+
Given a blog with content exists
|
98
|
+
When I run `staticpress build --verbose`
|
99
|
+
Then the output should contain " page public/about/index.html"
|
100
|
+
|
96
101
|
Scenario: Building a site a custom homepage
|
97
102
|
Given a blog with content exists
|
98
103
|
And I write to "content/index.markdown" with:
|
@@ -102,6 +107,11 @@ Feature: The happy path
|
|
102
107
|
---
|
103
108
|
in custom page
|
104
109
|
"""
|
110
|
+
# FIXME hacky-hack to keep Tilt happy
|
111
|
+
# NOTE this does not seem to be an issue when running this command for real
|
112
|
+
And I require "haml"
|
113
|
+
And I require "redcarpet"
|
114
|
+
And I require "sass"
|
105
115
|
When I run `staticpress build`
|
106
116
|
Then the file "public/index.html" should contain exactly:
|
107
117
|
"""
|
data/lib/staticpress.rb
CHANGED
@@ -2,7 +2,7 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Staticpress
|
4
4
|
def self.blog_path
|
5
|
-
Pathname
|
5
|
+
Pathname(@path || '.').expand_path
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.blog_path=(path)
|
@@ -10,6 +10,6 @@ module Staticpress
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.root
|
13
|
-
Pathname
|
13
|
+
Pathname File.expand_path('..', __FILE__)
|
14
14
|
end
|
15
15
|
end
|
data/lib/staticpress/cli.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# http://practicingruby.com/articles/shared/ozkzbsdmagcm
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
-
require 'pathname'
|
5
4
|
require 'rack'
|
6
5
|
require 'thor'
|
7
6
|
|
@@ -10,6 +9,7 @@ require 'staticpress/error'
|
|
10
9
|
require 'staticpress/helpers'
|
11
10
|
require 'staticpress/plugin'
|
12
11
|
require 'staticpress/pusher'
|
12
|
+
require 'staticpress/settings'
|
13
13
|
require 'staticpress/site'
|
14
14
|
require 'staticpress/version'
|
15
15
|
|
@@ -23,11 +23,18 @@ module Staticpress
|
|
23
23
|
map ['-h', '--help'] => :help
|
24
24
|
map ['-v', '--version'] => :version
|
25
25
|
|
26
|
+
class_option '--verbose', :type => :boolean, :default => false, :required => false, :desc => 'Output information as the task is running'
|
27
|
+
|
28
|
+
def initialize(*args)
|
29
|
+
super
|
30
|
+
Staticpress::Settings.set! options
|
31
|
+
end
|
32
|
+
|
26
33
|
desc 'help [task]', 'Describe available tasks or one specific task'
|
27
34
|
def help(*args)
|
28
35
|
general_usage = <<-USAGE
|
29
36
|
Usage:
|
30
|
-
staticpress <task> <required-argument> [option-argument]
|
37
|
+
staticpress <task> <required-argument> [option-argument] [--options...]
|
31
38
|
|
32
39
|
USAGE
|
33
40
|
puts general_usage if args.empty?
|
@@ -97,9 +104,10 @@ customizations. If [theme-name] is blank, copies the currently configured theme
|
|
97
104
|
end
|
98
105
|
|
99
106
|
desc 'list [method]', 'Send [method] to every content and output the result, or list all content if [method] is not present'
|
100
|
-
def list(method =
|
101
|
-
|
102
|
-
|
107
|
+
def list(method = :to_s)
|
108
|
+
Staticpress::Site.new.each do |content|
|
109
|
+
puts(content.respond_to?(method) ? content.send(method) : content)
|
110
|
+
end
|
103
111
|
end
|
104
112
|
|
105
113
|
desc 'build', 'Prepare blog for deployment'
|
@@ -16,7 +16,7 @@ module Staticpress::Content
|
|
16
16
|
|
17
17
|
attr_reader :params
|
18
18
|
|
19
|
-
def initialize(params)
|
19
|
+
def initialize(params = {})
|
20
20
|
clean_params = params.select { |key, value| value }.map do |key, value|
|
21
21
|
cast_value = case Staticpress::Route::REGEX_STUBS[key].klass
|
22
22
|
when :integer then Integer value rescue value
|
@@ -101,10 +101,19 @@ module Staticpress::Content
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def save
|
104
|
-
unless output_path.file?
|
105
|
-
|
106
|
-
|
104
|
+
save! unless output_path.file?
|
105
|
+
end
|
106
|
+
|
107
|
+
def save!
|
108
|
+
if settings.verbose
|
109
|
+
width = config.routes.to_hash.keys.max_by { |sym| sym.to_s.length }.to_s.length
|
110
|
+
type = self.class.type.rjust width
|
111
|
+
path = output_path.to_s.sub Staticpress.blog_path.to_s + '/', ''
|
112
|
+
puts "#{type} #{path}"
|
107
113
|
end
|
114
|
+
|
115
|
+
FileUtils.mkdir_p output_path.dirname
|
116
|
+
output_path.open('w') { |f| f.write render }
|
108
117
|
end
|
109
118
|
|
110
119
|
def template_context
|
@@ -8,8 +8,19 @@ module Staticpress::Content
|
|
8
8
|
extend CollectionContent
|
9
9
|
extend ResourceContent
|
10
10
|
|
11
|
+
attr_reader :name
|
12
|
+
|
13
|
+
def initialize(params)
|
14
|
+
@name = params[:name]
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
11
18
|
def optional_param_defaults
|
12
|
-
{ :number =>
|
19
|
+
{ :number => pages_count }
|
20
|
+
end
|
21
|
+
|
22
|
+
def pages_count
|
23
|
+
(self.class.content_by_category[name].count / config.posts_per_page.to_f).ceil
|
13
24
|
end
|
14
25
|
|
15
26
|
def sub_content
|
@@ -21,9 +32,15 @@ module Staticpress::Content
|
|
21
32
|
end
|
22
33
|
|
23
34
|
def self.all
|
24
|
-
|
25
|
-
|
35
|
+
reply = []
|
36
|
+
|
37
|
+
content_by_category.each do |category, posts|
|
38
|
+
1.upto paginate(posts).count do |number|
|
39
|
+
reply << new(:name => category, :number => number)
|
40
|
+
end
|
26
41
|
end
|
42
|
+
|
43
|
+
reply
|
27
44
|
end
|
28
45
|
|
29
46
|
def self.categories
|
@@ -31,7 +48,7 @@ module Staticpress::Content
|
|
31
48
|
end
|
32
49
|
|
33
50
|
def self.content_by_category
|
34
|
-
reply = {}
|
51
|
+
reply = Hash.new { |hash, key| hash[key] = [] }
|
35
52
|
Staticpress::Content::Post.all.each do |post|
|
36
53
|
(post.meta.categories || []).each do |category|
|
37
54
|
(reply[category] ||= []) << post
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'staticpress'
|
2
2
|
require 'staticpress/content/base'
|
3
|
+
require 'staticpress/content/post'
|
3
4
|
require 'staticpress/content/collection_content'
|
4
5
|
|
5
6
|
module Staticpress::Content
|
@@ -7,11 +8,15 @@ module Staticpress::Content
|
|
7
8
|
extend CollectionContent
|
8
9
|
|
9
10
|
def optional_param_defaults
|
10
|
-
{ :number =>
|
11
|
+
{ :number => pages_count }
|
12
|
+
end
|
13
|
+
|
14
|
+
def pages_count
|
15
|
+
(self.class.all_posts.count / config.posts_per_page.to_f).ceil
|
11
16
|
end
|
12
17
|
|
13
18
|
def sub_content
|
14
|
-
paginate(
|
19
|
+
paginate(self.class.all_posts.sort)[params[:number] - 1]
|
15
20
|
end
|
16
21
|
|
17
22
|
def template_path
|
@@ -19,9 +24,17 @@ module Staticpress::Content
|
|
19
24
|
end
|
20
25
|
|
21
26
|
def self.all
|
22
|
-
[
|
23
|
-
|
24
|
-
|
27
|
+
reply = []
|
28
|
+
|
29
|
+
1.upto paginate(all_posts).count do |number|
|
30
|
+
reply << new(:number => number)
|
31
|
+
end
|
32
|
+
|
33
|
+
reply
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.all_posts
|
37
|
+
Staticpress::Content::Post.all
|
25
38
|
end
|
26
39
|
end
|
27
40
|
end
|
@@ -18,7 +18,7 @@ module Staticpress::Content
|
|
18
18
|
def initialize(params)
|
19
19
|
super
|
20
20
|
|
21
|
-
index = extensionless_basename Pathname
|
21
|
+
index = extensionless_basename Pathname(config.index_file)
|
22
22
|
|
23
23
|
@full_slug = params[:slug]
|
24
24
|
@extension = find_supported_extension(Staticpress.blog_path + config.source_path + full_slug)
|
@@ -32,6 +32,10 @@ module Staticpress::Content
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def save
|
36
|
+
save!
|
37
|
+
end
|
38
|
+
|
35
39
|
def static?
|
36
40
|
(Staticpress.blog_path + config.source_path + params[:slug]).file?
|
37
41
|
end
|
@@ -64,7 +68,7 @@ module Staticpress::Content
|
|
64
68
|
def self.find_by_path(path)
|
65
69
|
if path.file?
|
66
70
|
raw_slug = parse_slug(path, (Staticpress.blog_path + config.source_path)).first
|
67
|
-
basename = extensionless_basename Pathname
|
71
|
+
basename = extensionless_basename Pathname(config.index_file)
|
68
72
|
slug = raw_slug.sub(/.*(\/?#{basename})$/, '')
|
69
73
|
new :slug => slug
|
70
74
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
require 'staticpress'
|
2
4
|
require 'staticpress/content/static_content'
|
3
5
|
|
@@ -6,7 +8,7 @@ module Staticpress::Content
|
|
6
8
|
# FIXME add tests
|
7
9
|
def find_supported_extension(extensionless_path)
|
8
10
|
Staticpress::Content::StaticContent.supported_extensions.detect do |extension|
|
9
|
-
extension.to_sym if Pathname
|
11
|
+
extension.to_sym if Pathname("#{extensionless_path}.#{extension}").file?
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
@@ -8,8 +8,19 @@ module Staticpress::Content
|
|
8
8
|
extend CollectionContent
|
9
9
|
extend ResourceContent
|
10
10
|
|
11
|
+
attr_reader :name
|
12
|
+
|
13
|
+
def initialize(params)
|
14
|
+
@name = params[:name]
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
11
18
|
def optional_param_defaults
|
12
|
-
{ :number =>
|
19
|
+
{ :number => pages_count }
|
20
|
+
end
|
21
|
+
|
22
|
+
def pages_count
|
23
|
+
(self.class.content_by_tag[name].count / config.posts_per_page.to_f).ceil
|
13
24
|
end
|
14
25
|
|
15
26
|
def sub_content
|
@@ -21,9 +32,15 @@ module Staticpress::Content
|
|
21
32
|
end
|
22
33
|
|
23
34
|
def self.all
|
24
|
-
|
25
|
-
|
35
|
+
reply = []
|
36
|
+
|
37
|
+
content_by_tag.each do |tag, posts|
|
38
|
+
1.upto paginate(posts).count do |number|
|
39
|
+
reply << new(:name => tag, :number => number)
|
40
|
+
end
|
26
41
|
end
|
42
|
+
|
43
|
+
reply
|
27
44
|
end
|
28
45
|
|
29
46
|
def self.tags
|
@@ -31,7 +48,7 @@ module Staticpress::Content
|
|
31
48
|
end
|
32
49
|
|
33
50
|
def self.content_by_tag
|
34
|
-
reply = {}
|
51
|
+
reply = Hash.new { |hash, key| hash[key] = [] }
|
35
52
|
Staticpress::Content::Post.all.each do |post|
|
36
53
|
(post.meta.tags || []).each do |tag|
|
37
54
|
(reply[tag] ||= []) << post
|
data/lib/staticpress/helpers.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
require 'staticpress'
|
2
4
|
require 'staticpress/configuration'
|
5
|
+
require 'staticpress/settings'
|
3
6
|
|
4
7
|
module Staticpress
|
5
8
|
module Helpers
|
@@ -14,7 +17,7 @@ module Staticpress
|
|
14
17
|
|
15
18
|
def extensionless_path(pathname)
|
16
19
|
path = pathname.to_path
|
17
|
-
Pathname
|
20
|
+
Pathname path[0...(path.length - pathname.extname.length)]
|
18
21
|
end
|
19
22
|
|
20
23
|
def hash_from_array(array, &block)
|
@@ -48,6 +51,10 @@ module Staticpress
|
|
48
51
|
reply
|
49
52
|
end
|
50
53
|
|
54
|
+
def settings
|
55
|
+
Staticpress::Settings.instance
|
56
|
+
end
|
57
|
+
|
51
58
|
def spider_directory(dir, &block)
|
52
59
|
dir.children.map do |child|
|
53
60
|
if child.directory?
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'staticpress'
|
2
|
+
require 'staticpress/js_object'
|
3
|
+
|
4
|
+
module Staticpress
|
5
|
+
class Settings < JSObject
|
6
|
+
def self.default
|
7
|
+
new 'verbose' => false
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.instance
|
11
|
+
new(default.to_hash.merge(@runtime_settings || {}))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.set!(settings)
|
15
|
+
(@runtime_settings ||= {}).merge!(settings)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/staticpress/site.rb
CHANGED
@@ -22,6 +22,7 @@ module Staticpress
|
|
22
22
|
Staticpress::Content::Theme
|
23
23
|
]
|
24
24
|
|
25
|
+
include Enumerable
|
25
26
|
include Staticpress::Helpers
|
26
27
|
|
27
28
|
attr_reader :directory
|
@@ -30,8 +31,21 @@ module Staticpress
|
|
30
31
|
@directory = Staticpress.blog_path + config.source_path
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
-
|
34
|
+
def each(&block)
|
35
|
+
threads = []
|
36
|
+
semaphore = Mutex.new
|
37
|
+
|
38
|
+
CONTENT_TYPES.each do |content_type|
|
39
|
+
threads << Thread.new do
|
40
|
+
content_type.all.each do |content|
|
41
|
+
semaphore.synchronize do
|
42
|
+
block.call content
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
threads.each &:join
|
35
49
|
end
|
36
50
|
|
37
51
|
def find_content_by_env(env)
|
@@ -47,15 +61,13 @@ module Staticpress
|
|
47
61
|
|
48
62
|
def meta
|
49
63
|
# or something...
|
50
|
-
|
51
|
-
m << page.meta
|
52
|
-
end
|
64
|
+
inject(Staticpress::Metadata.new) { |meta, content| meta << content.meta }
|
53
65
|
end
|
54
66
|
|
55
67
|
def save
|
56
68
|
destination = Staticpress.blog_path + config.destination_path
|
57
69
|
FileUtils.rm_r destination if destination.directory?
|
58
|
-
|
70
|
+
each &:save
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
data/lib/staticpress/version.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Staticpress
|
2
|
-
# TODO figure out how to implement Gem::Version properly
|
3
2
|
class Version
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
extend Comparable
|
4
|
+
|
5
|
+
SIGNATURE = [0, 5, 0]
|
6
|
+
|
7
|
+
def self.<=>(other)
|
8
|
+
other = other.split('.').map(&:to_i) if other.respond_to? :split
|
9
|
+
SIGNATURE <=> Array(other)
|
10
|
+
end
|
7
11
|
|
8
12
|
def self.to_s
|
9
|
-
|
13
|
+
SIGNATURE.join('.')
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
data/staticpress.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/staticpress/version', __FILE__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'staticpress'
|
7
|
-
s.version = Staticpress::Version
|
7
|
+
s.version = Staticpress::Version
|
8
8
|
s.authors = ['Raving Genius']
|
9
9
|
s.email = ['rg+code@ravinggenius.com']
|
10
10
|
s.summary = 'Blog-centric static site builder'
|
@@ -13,7 +13,7 @@ class ContentBaseTest < TestCase
|
|
13
13
|
let(:category_1) { Staticpress::Content::Category.new(:name => 'programming', :number => '1') }
|
14
14
|
let(:category_2) { Staticpress::Content::Category.new(:name => 'programming', :number => '2') }
|
15
15
|
|
16
|
-
let(:index) { Staticpress::Content::Index.new
|
16
|
+
let(:index) { Staticpress::Content::Index.new }
|
17
17
|
let(:index_2) { Staticpress::Content::Index.new :number => 2 }
|
18
18
|
|
19
19
|
let(:page) { Staticpress::Content::Page.new(:slug => 'about') }
|
@@ -57,6 +57,7 @@ class ContentBaseTest < TestCase
|
|
57
57
|
refute_operator asset_style, :==, nil
|
58
58
|
|
59
59
|
refute_operator Staticpress::Content::Category.new(:name => 'programming'), :==, Staticpress::Content::Tag.new(:name => 'programming')
|
60
|
+
refute_operator Staticpress::Content::Tag.new(:name => 'charlotte'), :==, Staticpress::Content::Category.new(:name => 'charlotte')
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_content_type
|
@@ -2,21 +2,44 @@ require_relative '../../test_case'
|
|
2
2
|
|
3
3
|
require 'staticpress/content/category'
|
4
4
|
require 'staticpress/content/post'
|
5
|
+
require 'staticpress/helpers'
|
5
6
|
|
6
7
|
class ContentCategoryTest < TestCase
|
8
|
+
include Staticpress::Helpers
|
9
|
+
|
7
10
|
let(:category) { Staticpress::Content::Category.new :name => 'programming' }
|
8
11
|
|
9
12
|
def test_categories
|
10
13
|
assert_equal [ 'programming', 'travel' ], Staticpress::Content::Category.categories
|
11
14
|
end
|
12
15
|
|
16
|
+
def test_pages_count
|
17
|
+
assert_equal 1, category.pages_count
|
18
|
+
|
19
|
+
with_config :posts_per_page => 2 do
|
20
|
+
assert_equal 2, category.pages_count
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
13
24
|
def test_sub_content
|
14
|
-
|
25
|
+
expected = [
|
26
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '01', :title => 'announcing-staticpress'),
|
27
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '02', :title => 'staticpress'),
|
28
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress')
|
29
|
+
]
|
30
|
+
assert_equal expected, category.sub_content
|
15
31
|
end
|
16
32
|
|
17
33
|
def test_all
|
18
|
-
|
19
|
-
|
34
|
+
with_config :posts_per_page => 1 do
|
35
|
+
expected = [
|
36
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 1),
|
37
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 2),
|
38
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 3),
|
39
|
+
Staticpress::Content::Category.new(:name => 'travel', :number => 1)
|
40
|
+
]
|
41
|
+
assert_equal expected, Staticpress::Content::Category.all
|
42
|
+
end
|
20
43
|
end
|
21
44
|
|
22
45
|
def test_content_by_category
|
@@ -1,6 +1,42 @@
|
|
1
1
|
require_relative '../../test_case'
|
2
2
|
|
3
3
|
require 'staticpress/content/index'
|
4
|
+
require 'staticpress/content/post'
|
5
|
+
require 'staticpress/helpers'
|
4
6
|
|
5
7
|
class ContentIndexTest < TestCase
|
8
|
+
include Staticpress::Helpers
|
9
|
+
|
10
|
+
let(:index) { Staticpress::Content::Index.new }
|
11
|
+
|
12
|
+
def test_pages_count
|
13
|
+
assert_equal 1, index.pages_count
|
14
|
+
|
15
|
+
with_config :posts_per_page => 2 do
|
16
|
+
assert_equal 4, index.pages_count
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_sub_content
|
21
|
+
with_config :posts_per_page => 4 do
|
22
|
+
# expect three most recent posts with oldest on top (index is lazy-evaluated)
|
23
|
+
expected = [
|
24
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'conferences'),
|
25
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress'),
|
26
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '20', :title => 'forever')
|
27
|
+
]
|
28
|
+
assert_equal expected, index.sub_content
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_all
|
33
|
+
with_config :posts_per_page => 3 do
|
34
|
+
expected = [
|
35
|
+
Staticpress::Content::Index.new(:number => 1),
|
36
|
+
Staticpress::Content::Index.new(:number => 2),
|
37
|
+
Staticpress::Content::Index.new(:number => 3)
|
38
|
+
]
|
39
|
+
assert_equal expected, Staticpress::Content::Index.all
|
40
|
+
end
|
41
|
+
end
|
6
42
|
end
|
@@ -10,6 +10,10 @@ class ContentTagTest < TestCase
|
|
10
10
|
assert_equal [ 'charlotte' ], Staticpress::Content::Tag.tags
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_pages_count
|
14
|
+
assert_equal 1, tag.pages_count
|
15
|
+
end
|
16
|
+
|
13
17
|
def test_optional_param_defaults
|
14
18
|
expected = { :number => 1 }
|
15
19
|
assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte').optional_param_defaults
|
@@ -17,12 +21,17 @@ class ContentTagTest < TestCase
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def test_sub_content
|
20
|
-
|
24
|
+
expected = [
|
25
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'in-charlotte')
|
26
|
+
]
|
27
|
+
assert_equal expected, tag.sub_content
|
21
28
|
end
|
22
29
|
|
23
30
|
def test_all
|
24
|
-
|
25
|
-
|
31
|
+
expected = [
|
32
|
+
Staticpress::Content::Tag.new(:name => 'charlotte', :number => 1)
|
33
|
+
]
|
34
|
+
assert_equal expected, Staticpress::Content::Tag.all
|
26
35
|
end
|
27
36
|
|
28
37
|
def test_content_by_tag
|
@@ -8,19 +8,19 @@ class HelpersTest < TestCase
|
|
8
8
|
include Staticpress::Helpers
|
9
9
|
|
10
10
|
def test_extensionless_basename
|
11
|
-
assert_equal 'extensionless', extensionless_basename(Pathname
|
12
|
-
assert_equal '.htaccess', extensionless_basename(Pathname
|
13
|
-
assert_equal 'tyrannasaurus_rex', extensionless_basename(Pathname
|
14
|
-
assert_equal 'stegosaurus', extensionless_basename(Pathname
|
15
|
-
assert_equal 'stegosaurus', extensionless_basename(Pathname
|
11
|
+
assert_equal 'extensionless', extensionless_basename(Pathname('extensionless'))
|
12
|
+
assert_equal '.htaccess', extensionless_basename(Pathname('.htaccess'))
|
13
|
+
assert_equal 'tyrannasaurus_rex', extensionless_basename(Pathname('tyrannasaurus_rex.rb'))
|
14
|
+
assert_equal 'stegosaurus', extensionless_basename(Pathname('dinosaurs/stegosaurus.rb'))
|
15
|
+
assert_equal 'stegosaurus', extensionless_basename(Pathname('/dinosaurs/stegosaurus.rb'))
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_extensionless_path
|
19
|
-
assert_equal Pathname
|
20
|
-
assert_equal Pathname
|
21
|
-
assert_equal Pathname
|
22
|
-
assert_equal Pathname
|
23
|
-
assert_equal Pathname
|
19
|
+
assert_equal Pathname('extensionless'), extensionless_path(Pathname('extensionless'))
|
20
|
+
assert_equal Pathname('.htaccess'), extensionless_path(Pathname('.htaccess'))
|
21
|
+
assert_equal Pathname('tyrannasaurus_rex'), extensionless_path(Pathname('tyrannasaurus_rex.rb'))
|
22
|
+
assert_equal Pathname('dinosaurs/stegosaurus'), extensionless_path(Pathname('dinosaurs/stegosaurus.rb'))
|
23
|
+
assert_equal Pathname('/dinosaurs/stegosaurus'), extensionless_path(Pathname('/dinosaurs/stegosaurus.rb'))
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_hash_from_empty_array
|
@@ -45,10 +45,11 @@ class HelpersTest < TestCase
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_paginate
|
48
|
+
# a == oldest, z == newest
|
48
49
|
assert_equal 3, paginate(:a..:z).count
|
49
|
-
assert_equal (:a..:j).to_a, paginate(:a..:z)[0]
|
50
|
+
assert_equal (:a..:j).to_a, paginate(:a..:z)[0] # page 1 lists oldest, with oldest at top
|
50
51
|
assert_equal (:k..:t).to_a, paginate(:a..:z)[1]
|
51
|
-
assert_equal (:u..:z).to_a, paginate(:a..:z)[2]
|
52
|
+
assert_equal (:u..:z).to_a, paginate(:a..:z)[2] # page 3 lists newest, with newest at bottom (default page)
|
52
53
|
assert_equal [], paginate(:a..:z)[5], 'Accessing an invalid index on anything that has been paginated should return an empty array'
|
53
54
|
end
|
54
55
|
|
@@ -37,6 +37,12 @@ class JSObjectTest < TestCase
|
|
37
37
|
assert_equal :hullabaloo, js_object.hoopla
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_merge
|
41
|
+
assert_nil js_object.some_key
|
42
|
+
enhanced = js_object.merge :some_key => 42
|
43
|
+
assert_equal 42, enhanced.some_key
|
44
|
+
end
|
45
|
+
|
40
46
|
def test_to_hash
|
41
47
|
assert_equal({ :key => :value, :nested => { :a => :b } }, js_object.to_hash)
|
42
48
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../test_case'
|
2
|
+
|
3
|
+
class SettingsTest < TestCase
|
4
|
+
def test_default
|
5
|
+
refute Staticpress::Settings.instance.verbose
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_set!
|
9
|
+
assert_equal nil, Staticpress::Settings.instance.favorite_number
|
10
|
+
Staticpress::Settings.set! :favorite_number => 42
|
11
|
+
assert_equal 42, Staticpress::Settings.instance.favorite_number
|
12
|
+
end
|
13
|
+
end
|
data/tests/staticpress_test.rb
CHANGED
@@ -4,15 +4,15 @@ require 'pathname'
|
|
4
4
|
|
5
5
|
class StaticpressTest < TestCase
|
6
6
|
def test_blog_path
|
7
|
-
assert_equal Pathname
|
7
|
+
assert_equal Pathname('tests/test_blog').expand_path, Staticpress.blog_path
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_blog_path=
|
11
11
|
Staticpress.blog_path = 'some/other/directory'
|
12
|
-
assert_equal Pathname
|
12
|
+
assert_equal Pathname('some/other/directory').expand_path, Staticpress.blog_path
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_root
|
16
|
-
assert_equal Pathname
|
16
|
+
assert_equal Pathname('lib/').expand_path, Staticpress.root
|
17
17
|
end
|
18
18
|
end
|
data/tests/test_blog/Gemfile
CHANGED
data/tests/test_case.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staticpress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,11 +50,11 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date: 2011-12-
|
53
|
+
date: 2011-12-28 00:00:00.000000000 Z
|
54
54
|
dependencies:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: aruba
|
57
|
-
requirement: &
|
57
|
+
requirement: &18072460 !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
60
60
|
- - ! '>='
|
@@ -62,10 +62,10 @@ dependencies:
|
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
|
-
version_requirements: *
|
65
|
+
version_requirements: *18072460
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
67
|
name: compass
|
68
|
-
requirement: &
|
68
|
+
requirement: &18072040 !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
71
71
|
- - ! '>='
|
@@ -73,10 +73,10 @@ dependencies:
|
|
73
73
|
version: '0'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
|
-
version_requirements: *
|
76
|
+
version_requirements: *18072040
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: cucumber
|
79
|
-
requirement: &
|
79
|
+
requirement: &18071440 !ruby/object:Gem::Requirement
|
80
80
|
none: false
|
81
81
|
requirements:
|
82
82
|
- - ! '>='
|
@@ -84,10 +84,10 @@ dependencies:
|
|
84
84
|
version: '0'
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
|
-
version_requirements: *
|
87
|
+
version_requirements: *18071440
|
88
88
|
- !ruby/object:Gem::Dependency
|
89
89
|
name: haml
|
90
|
-
requirement: &
|
90
|
+
requirement: &18070840 !ruby/object:Gem::Requirement
|
91
91
|
none: false
|
92
92
|
requirements:
|
93
93
|
- - ! '>='
|
@@ -95,10 +95,10 @@ dependencies:
|
|
95
95
|
version: '0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
|
-
version_requirements: *
|
98
|
+
version_requirements: *18070840
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: minitest
|
101
|
-
requirement: &
|
101
|
+
requirement: &18070260 !ruby/object:Gem::Requirement
|
102
102
|
none: false
|
103
103
|
requirements:
|
104
104
|
- - ! '>='
|
@@ -106,10 +106,10 @@ dependencies:
|
|
106
106
|
version: '0'
|
107
107
|
type: :development
|
108
108
|
prerelease: false
|
109
|
-
version_requirements: *
|
109
|
+
version_requirements: *18070260
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: ruby-debug19
|
112
|
-
requirement: &
|
112
|
+
requirement: &18069840 !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
115
|
- - ! '>='
|
@@ -117,10 +117,10 @@ dependencies:
|
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
|
-
version_requirements: *
|
120
|
+
version_requirements: *18069840
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
122
|
name: sass
|
123
|
-
requirement: &
|
123
|
+
requirement: &18069400 !ruby/object:Gem::Requirement
|
124
124
|
none: false
|
125
125
|
requirements:
|
126
126
|
- - ! '>='
|
@@ -128,10 +128,10 @@ dependencies:
|
|
128
128
|
version: '0'
|
129
129
|
type: :development
|
130
130
|
prerelease: false
|
131
|
-
version_requirements: *
|
131
|
+
version_requirements: *18069400
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: bundler
|
134
|
-
requirement: &
|
134
|
+
requirement: &18068940 !ruby/object:Gem::Requirement
|
135
135
|
none: false
|
136
136
|
requirements:
|
137
137
|
- - ! '>='
|
@@ -139,10 +139,10 @@ dependencies:
|
|
139
139
|
version: '0'
|
140
140
|
type: :runtime
|
141
141
|
prerelease: false
|
142
|
-
version_requirements: *
|
142
|
+
version_requirements: *18068940
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: rack
|
145
|
-
requirement: &
|
145
|
+
requirement: &18068240 !ruby/object:Gem::Requirement
|
146
146
|
none: false
|
147
147
|
requirements:
|
148
148
|
- - ! '>='
|
@@ -150,10 +150,10 @@ dependencies:
|
|
150
150
|
version: '0'
|
151
151
|
type: :runtime
|
152
152
|
prerelease: false
|
153
|
-
version_requirements: *
|
153
|
+
version_requirements: *18068240
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: thor
|
156
|
-
requirement: &
|
156
|
+
requirement: &18067540 !ruby/object:Gem::Requirement
|
157
157
|
none: false
|
158
158
|
requirements:
|
159
159
|
- - ! '>='
|
@@ -161,10 +161,10 @@ dependencies:
|
|
161
161
|
version: '0'
|
162
162
|
type: :runtime
|
163
163
|
prerelease: false
|
164
|
-
version_requirements: *
|
164
|
+
version_requirements: *18067540
|
165
165
|
- !ruby/object:Gem::Dependency
|
166
166
|
name: tilt
|
167
|
-
requirement: &
|
167
|
+
requirement: &18066880 !ruby/object:Gem::Requirement
|
168
168
|
none: false
|
169
169
|
requirements:
|
170
170
|
- - ! '>='
|
@@ -172,7 +172,7 @@ dependencies:
|
|
172
172
|
version: '0'
|
173
173
|
type: :runtime
|
174
174
|
prerelease: false
|
175
|
-
version_requirements: *
|
175
|
+
version_requirements: *18066880
|
176
176
|
description: ! 'Staticpress is a blog-focused static site generator. It uses Tilt
|
177
177
|
for rendering nearly any template you can think of and come with a built-in Rack
|
178
178
|
server for easy development previews.
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/staticpress/pusher.rb
|
232
232
|
- lib/staticpress/route.rb
|
233
233
|
- lib/staticpress/server.rb
|
234
|
+
- lib/staticpress/settings.rb
|
234
235
|
- lib/staticpress/site.rb
|
235
236
|
- lib/staticpress/theme.rb
|
236
237
|
- lib/staticpress/version.rb
|
@@ -259,6 +260,7 @@ files:
|
|
259
260
|
- tests/staticpress/pusher_test.rb
|
260
261
|
- tests/staticpress/route_test.rb
|
261
262
|
- tests/staticpress/server_test.rb
|
263
|
+
- tests/staticpress/settings_test.rb
|
262
264
|
- tests/staticpress/site_test.rb
|
263
265
|
- tests/staticpress/theme_test.rb
|
264
266
|
- tests/staticpress/view_helpers_test.rb
|
@@ -314,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
314
316
|
version: '0'
|
315
317
|
requirements: []
|
316
318
|
rubyforge_project: staticpress
|
317
|
-
rubygems_version: 1.8.
|
319
|
+
rubygems_version: 1.8.13
|
318
320
|
signing_key:
|
319
321
|
specification_version: 3
|
320
322
|
summary: Blog-centric static site builder
|
metadata.gz.sig
CHANGED
Binary file
|