ruhoh 0.1.3 → 0.2.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.
@@ -9,19 +9,38 @@ module Pages
9
9
  before(:each) do
10
10
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({'theme' => "twitter"})
11
11
  Ruhoh.setup(:source => SampleSitePath)
12
+
13
+ the_pages_dir = File.join SampleSitePath, "_pages"
14
+
15
+ FileUtils.remove_dir(the_pages_dir, 1) if Dir.exists? the_pages_dir
16
+ Dir.mkdir the_pages_dir
17
+
18
+ expected_pages.each do |page_name|
19
+ full_file_name = File.join(the_pages_dir, page_name)
20
+ File.open full_file_name, "w+" do |file|
21
+ file.puts <<-TEXT
22
+ ---
23
+ title: #{page_name} (test)
24
+ ---
25
+ TEXT
26
+ end
27
+ end
12
28
  end
13
29
 
30
+ let(:expected_pages) {
31
+ %w{about.md archive.html categories.html index.html pages.html sitemap.txt tags.html}
32
+ }
33
+
14
34
  let(:pages){
15
35
  Ruhoh::Parsers::Pages.generate
16
36
  }
17
37
 
18
38
  it 'should extract valid pages from source directory.' do
19
- pages.keys.sort.should == ['about.md', 'archive.html', 'categories.html', 'index.html', 'pages.html', 'tags.html']
39
+ pages.keys.sort.should == ['about.md', 'archive.html', 'categories.html', 'index.html', 'pages.html', 'sitemap.txt', 'tags.html']
20
40
  end
21
41
 
22
42
  it 'should return a properly formatted hash for each page' do
23
43
  pages.each_value { |value|
24
- value.should have_key("layout")
25
44
  value.should have_key("id")
26
45
  value.should have_key("url")
27
46
  value.should have_key("title")
@@ -44,11 +63,6 @@ module Pages
44
63
  Ruhoh::Parsers::Pages.is_valid_page?(filepath).should == true
45
64
  end
46
65
 
47
- it "should return false for a filepath beginning with _" do
48
- filepath = '_blah/about.md'
49
- Ruhoh::Parsers::Pages.is_valid_page?(filepath).should == false
50
- end
51
-
52
66
  it "should return false for a filepath beginning with ." do
53
67
  filepath = '.vim'
54
68
  Ruhoh::Parsers::Pages.is_valid_page?(filepath).should == false
@@ -89,9 +103,9 @@ module Pages
89
103
  end
90
104
 
91
105
 
92
- pending "#titleize"
93
- pending "#permalink"
106
+ describe "#to_title"
107
+ describe "#permalink"
94
108
 
95
109
  end
96
110
 
97
- end
111
+ end
@@ -9,7 +9,7 @@ module Posts
9
9
  Ruhoh.setup(:source => SampleSitePath)
10
10
  end
11
11
 
12
- describe "#generate" do
12
+ pending "#generate" do
13
13
 
14
14
  it 'should return a valid data structures for core API' do
15
15
  posts = Ruhoh::Parsers::Posts.generate
@@ -31,11 +31,10 @@ module Posts
31
31
  dictionary.keys.sort.should == ['_posts/2012-01-01-hello-world.md']
32
32
  end
33
33
 
34
- it 'should return a properly formatted hash for each post' do
34
+ pending 'should return a properly formatted hash for each post' do
35
35
  dictionary = Ruhoh::Parsers::Posts.process
36
36
 
37
37
  dictionary.each_value { |value|
38
- value.should have_key("layout")
39
38
  value.should have_key("id")
40
39
  value.should have_key("url")
41
40
  value.should have_key("title")
@@ -94,7 +93,7 @@ module Posts
94
93
  end
95
94
 
96
95
  describe "#parse_filename" do
97
- it "should parse a post filename into corresponding metadata" do
96
+ it "should parse a post filename with DATE into corresponding metadata" do
98
97
  filename = '_posts/2011-10-10-my-post-title.md'
99
98
  data = Ruhoh::Parsers::Posts.parse_filename(filename)
100
99
 
@@ -104,9 +103,18 @@ module Posts
104
103
  data['extension'].should == ".md"
105
104
  end
106
105
 
107
- it "should return a blank hash if the filename format is invalid" do
106
+ it "should parse a post filename without DATE into corresponding metadata" do
108
107
  filename = '_posts/my-post-title.md'
109
108
  data = Ruhoh::Parsers::Posts.parse_filename(filename)
109
+ data['path'].should == "_posts/"
110
+ data['date'].should == nil
111
+ data['slug'].should == "my-post-title"
112
+ data['extension'].should == ".md"
113
+ end
114
+
115
+ it "should return a blank hash if the filename has no extension and therefore invalid" do
116
+ filename = '_posts/my-post-title'
117
+ data = Ruhoh::Parsers::Posts.parse_filename(filename)
110
118
  data.should == {}
111
119
  end
112
120
  end
@@ -151,10 +159,10 @@ module Posts
151
159
  end
152
160
  end
153
161
 
154
- describe "#titleize" do
162
+ describe "#to_title" do
155
163
  it "should prettify a filename slug for use as a title/header" do
156
164
  file_slug = 'my-post-title'
157
- title = Ruhoh::Parsers::Posts.titleize(file_slug)
165
+ title = Ruhoh::Parsers::Posts.to_title(file_slug)
158
166
  title.should == "My Post Title"
159
167
  end
160
168
  end
data/spec/setup_spec.rb CHANGED
@@ -1,33 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Setup
4
-
5
4
  describe "Setup" do
6
-
7
5
  describe "#setup" do
8
-
9
6
  it 'should setup config, paths, and filters' do
10
- Ruhoh.should_receive(:setup_config)
11
- Ruhoh.should_receive(:setup_paths)
12
- Ruhoh.should_receive(:setup_filters)
7
+ Ruhoh.should_receive(:setup_config).and_return(true)
8
+ Ruhoh.should_receive(:setup_paths).and_return(true)
9
+ Ruhoh.should_receive(:setup_filters).and_return(true)
13
10
  Ruhoh.setup
14
11
  end
15
-
16
12
  end
17
13
 
18
14
  describe "#setup_config" do
19
-
20
15
  context "Invalid _config.yml file" do
21
-
22
- it 'should raise an exception if theme is not specified.' do
16
+ it 'should log error and return false if theme is not specified.' do
23
17
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({})
24
- lambda { Ruhoh.setup_config }.should raise_error
18
+ Ruhoh.log.should_receive(:error)
19
+ Ruhoh.setup_config.should be_false
25
20
  end
26
-
27
21
  end
28
-
29
22
  context "Valid _config.yml file" do
30
-
31
23
  it 'should setup the config struct based on configuration input.' do
32
24
  custom_permalink = '/my/custom/link'
33
25
  custom_theme = 'table'
@@ -45,13 +37,10 @@ module Setup
45
37
  Ruhoh.config.theme_path.should == "/_templates/themes/#{custom_theme}"
46
38
  Ruhoh.config.exclude.should == custom_exclude
47
39
  end
48
-
49
40
  end
50
-
51
41
  end
52
42
 
53
43
  describe "#setup_filters" do
54
-
55
44
  it 'should add custom exclude filters to the filters variable' do
56
45
  custom_exclude = ['.secret', /^test/]
57
46
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
@@ -64,9 +53,6 @@ module Setup
64
53
  Ruhoh.filters.pages['names'].should include('.secret')
65
54
  Ruhoh.filters.pages['regexes'].should include(/^test/)
66
55
  end
67
-
68
56
  end
69
-
70
57
  end
71
-
72
58
  end
data/spec/spec_helper.rb CHANGED
@@ -19,5 +19,7 @@ RSpec.configure do |config|
19
19
  end
20
20
  end
21
21
 
22
- SampleSitePath = File.expand_path(File.join(File.dirname(__FILE__), '../scaffolds/blog'))
22
+ SampleSitePath = '__tmp'
23
23
 
24
+ FileUtils.remove_dir(SampleSitePath,1) if Dir.exists? SampleSitePath
25
+ Dir.mkdir SampleSitePath
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruhoh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000Z
12
+ date: 2012-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70227452372580 !ruby/object:Gem::Requirement
16
+ requirement: &70148787084820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70227452372580
24
+ version_requirements: *70148787084820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mustache
27
- requirement: &70227452372080 !ruby/object:Gem::Requirement
27
+ requirement: &70148787084320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.99'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70227452372080
35
+ version_requirements: *70148787084320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: directory_watcher
38
- requirement: &70227452371620 !ruby/object:Gem::Requirement
38
+ requirement: &70148787083860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70227452371620
46
+ version_requirements: *70148787083860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: maruku
49
- requirement: &70227452371160 !ruby/object:Gem::Requirement
49
+ requirement: &70148787083400 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,18 @@ dependencies:
54
54
  version: '0.6'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70227452371160
57
+ version_requirements: *70148787083400
58
+ - !ruby/object:Gem::Dependency
59
+ name: psych
60
+ requirement: &70148787113120 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '1.3'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70148787113120
58
69
  description: Ruhoh is a Universal API for your static blog.
59
70
  email: plusjade@gmail.com
60
71
  executables:
@@ -66,6 +77,7 @@ files:
66
77
  - README.md
67
78
  - Rakefile
68
79
  - bin/ruhoh
80
+ - dash.html
69
81
  - history.txt
70
82
  - lib/ruhoh.rb
71
83
  - lib/ruhoh/client/client.rb
@@ -77,7 +89,6 @@ files:
77
89
  - lib/ruhoh/friend.rb
78
90
  - lib/ruhoh/logger.rb
79
91
  - lib/ruhoh/page.rb
80
- - lib/ruhoh/parsers/drafts.rb
81
92
  - lib/ruhoh/parsers/layouts.rb
82
93
  - lib/ruhoh/parsers/pages.rb
83
94
  - lib/ruhoh/parsers/partials.rb
@@ -85,6 +96,7 @@ files:
85
96
  - lib/ruhoh/parsers/routes.rb
86
97
  - lib/ruhoh/parsers/site.rb
87
98
  - lib/ruhoh/previewer.rb
99
+ - lib/ruhoh/program.rb
88
100
  - lib/ruhoh/templaters/base.rb
89
101
  - lib/ruhoh/templaters/helpers.rb
90
102
  - lib/ruhoh/templaters/rmustache.rb
@@ -1,54 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- module Drafts
4
-
5
- def self.generate
6
- raise "Ruhoh.config cannot be nil.\n To set config call: Ruhoh.setup" unless Ruhoh.config
7
-
8
- dictionary = {}
9
- invalid = []
10
-
11
- self.files.each do |filename|
12
- parsed_page = Ruhoh::Utils.parse_file(filename)
13
- if parsed_page.empty?
14
- error = "Invalid YAML Front Matter. Ensure this page has valid YAML, even if it's empty."
15
- invalid << [filename, error] ; next
16
- end
17
-
18
- data = parsed_page['data']
19
- data['id'] = filename
20
- data['url'] = "/#{filename}"
21
- dictionary[filename] = data
22
- end
23
-
24
- self.report(dictionary, invalid)
25
- dictionary
26
- end
27
-
28
- def self.files
29
- FileUtils.cd(Ruhoh.paths.site_source) {
30
- return Dir["#{Ruhoh.folders.drafts}/**/*.*"].select { |filename|
31
- next if FileTest.directory?(filename)
32
- next if ['.'].include? filename[0]
33
- true
34
- }
35
- }
36
- end
37
-
38
- def self.report(dictionary, invalid)
39
- output = "#{dictionary.count}/#{dictionary.count + invalid.count} drafts processed."
40
- if dictionary.empty? && invalid.empty?
41
- Ruhoh::Friend.say { plain "0 drafts to process." }
42
- elsif invalid.empty?
43
- Ruhoh::Friend.say { green output }
44
- else
45
- Ruhoh::Friend.say {
46
- yellow output
47
- list "Drafts not processed:", invalid
48
- }
49
- end
50
- end
51
-
52
- end #Drafts
53
- end #Parsers
54
- end #Ruhoh