ruhoh 1.1 → 2.1

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.
Files changed (121) hide show
  1. data/Gemfile +3 -3
  2. data/README.md +3 -2
  3. data/Rakefile +1 -22
  4. data/bin/ruhoh +1 -5
  5. data/history.json +16 -0
  6. data/lib/ruhoh.rb +229 -84
  7. data/lib/ruhoh/base/collection.rb +280 -0
  8. data/lib/ruhoh/base/compiler.rb +55 -0
  9. data/lib/ruhoh/base/model.rb +220 -0
  10. data/lib/ruhoh/base/model_view.rb +152 -0
  11. data/lib/ruhoh/base/watcher.rb +25 -0
  12. data/lib/ruhoh/cache.rb +46 -0
  13. data/lib/ruhoh/client.rb +162 -0
  14. data/lib/ruhoh/collections.rb +172 -0
  15. data/lib/ruhoh/console_methods.rb +21 -0
  16. data/lib/ruhoh/{converters/converter.rb → converter.rb} +4 -1
  17. data/lib/ruhoh/programs/compile.rb +22 -0
  18. data/lib/ruhoh/programs/preview.rb +63 -0
  19. data/lib/ruhoh/programs/watch.rb +45 -0
  20. data/lib/ruhoh/resources/dash/collection.rb +10 -0
  21. data/lib/ruhoh/resources/dash/model.rb +5 -0
  22. data/lib/ruhoh/resources/dash/model_view.rb +5 -0
  23. data/lib/ruhoh/resources/dash/previewer.rb +13 -0
  24. data/lib/ruhoh/resources/data/collection.rb +9 -0
  25. data/lib/ruhoh/resources/data/collection_view.rb +23 -0
  26. data/lib/ruhoh/resources/javascripts/collection.rb +9 -0
  27. data/lib/ruhoh/resources/javascripts/collection_view.rb +46 -0
  28. data/lib/ruhoh/resources/javascripts/compiler.rb +5 -0
  29. data/lib/ruhoh/resources/layouts/client.rb +45 -0
  30. data/lib/ruhoh/resources/layouts/model.rb +16 -0
  31. data/lib/ruhoh/resources/media/collection.rb +9 -0
  32. data/lib/ruhoh/resources/media/compiler.rb +27 -0
  33. data/lib/ruhoh/resources/pages/client.rb +124 -0
  34. data/lib/ruhoh/resources/pages/collection.rb +86 -0
  35. data/lib/ruhoh/resources/pages/collection_view.rb +73 -0
  36. data/lib/ruhoh/resources/pages/compiler.rb +101 -0
  37. data/lib/ruhoh/resources/pages/model.rb +5 -0
  38. data/lib/ruhoh/resources/pages/model_view.rb +5 -0
  39. data/lib/ruhoh/resources/pages/previewer.rb +72 -0
  40. data/lib/ruhoh/resources/partials/model.rb +11 -0
  41. data/lib/ruhoh/resources/stylesheets/collection.rb +9 -0
  42. data/lib/ruhoh/resources/stylesheets/collection_view.rb +45 -0
  43. data/lib/ruhoh/resources/stylesheets/compiler.rb +5 -0
  44. data/lib/ruhoh/resources/theme/collection.rb +14 -0
  45. data/lib/ruhoh/resources/theme/compiler.rb +54 -0
  46. data/lib/ruhoh/resources/widgets/collection.rb +26 -0
  47. data/lib/ruhoh/resources/widgets/collection_view.rb +34 -0
  48. data/lib/ruhoh/resources/widgets/compiler.rb +27 -0
  49. data/lib/ruhoh/resources/widgets/model.rb +16 -0
  50. data/lib/ruhoh/routes.rb +29 -0
  51. data/lib/ruhoh/utils.rb +32 -49
  52. data/lib/ruhoh/version.rb +2 -2
  53. data/lib/ruhoh/views/helpers/categories.rb +38 -0
  54. data/lib/ruhoh/views/helpers/paginator.rb +39 -0
  55. data/lib/ruhoh/views/helpers/tags.rb +37 -0
  56. data/lib/ruhoh/views/master_view.rb +183 -0
  57. data/lib/ruhoh/views/rmustache.rb +24 -0
  58. data/ruhoh.gemspec +6 -82
  59. data/spec/spec_helper.rb +1 -1
  60. data/spec/support/shared_contexts.rb +6 -5
  61. data/system/{scaffolds/post.html → _scaffold.html} +1 -1
  62. data/system/{dash.html → dash/index.html} +37 -51
  63. data/system/{scaffolds/layout.html → layouts/_scaffold.html} +0 -0
  64. data/system/layouts/paginator.html +28 -0
  65. data/system/plugins/sprockets/javascripts/compiler.rb +25 -0
  66. data/system/plugins/sprockets/javascripts/previewer.rb +17 -0
  67. data/system/plugins/sprockets/stylesheets/compiler.rb +26 -0
  68. data/system/plugins/sprockets/stylesheets/previewer.rb +17 -0
  69. data/system/widgets/analytics/{layouts/getclicky.html → getclicky.html} +6 -2
  70. data/system/widgets/analytics/{layouts/google.html → google.html} +5 -1
  71. data/system/widgets/comments/{layouts/disqus.html → disqus.html} +6 -2
  72. data/system/widgets/comments/{layouts/facebook.html → facebook.html} +9 -2
  73. data/system/widgets/comments/{layouts/intensedebate.html → intensedebate.html} +5 -1
  74. data/system/widgets/comments/{layouts/livefyre.html → livefyre.html} +5 -1
  75. data/system/widgets/google_prettify/{layouts/google_prettify.html → default.html} +6 -2
  76. metadata +69 -66
  77. data/lib/ruhoh/client/client.rb +0 -306
  78. data/lib/ruhoh/client/console_methods.rb +0 -9
  79. data/lib/ruhoh/client/help.yml +0 -56
  80. data/lib/ruhoh/compiler.rb +0 -72
  81. data/lib/ruhoh/compilers/rss.rb +0 -39
  82. data/lib/ruhoh/compilers/theme.rb +0 -46
  83. data/lib/ruhoh/config.rb +0 -62
  84. data/lib/ruhoh/db.rb +0 -50
  85. data/lib/ruhoh/deployers/s3.rb +0 -71
  86. data/lib/ruhoh/page.rb +0 -106
  87. data/lib/ruhoh/parsers/javascripts.rb +0 -55
  88. data/lib/ruhoh/parsers/layouts.rb +0 -32
  89. data/lib/ruhoh/parsers/pages.rb +0 -79
  90. data/lib/ruhoh/parsers/partials.rb +0 -42
  91. data/lib/ruhoh/parsers/payload.rb +0 -49
  92. data/lib/ruhoh/parsers/posts.rb +0 -259
  93. data/lib/ruhoh/parsers/routes.rb +0 -20
  94. data/lib/ruhoh/parsers/scaffolds.rb +0 -35
  95. data/lib/ruhoh/parsers/site.rb +0 -19
  96. data/lib/ruhoh/parsers/stylesheets.rb +0 -63
  97. data/lib/ruhoh/parsers/theme_config.rb +0 -30
  98. data/lib/ruhoh/parsers/widgets.rb +0 -104
  99. data/lib/ruhoh/paths.rb +0 -83
  100. data/lib/ruhoh/previewer.rb +0 -48
  101. data/lib/ruhoh/program.rb +0 -68
  102. data/lib/ruhoh/templaters/asset_helpers.rb +0 -66
  103. data/lib/ruhoh/templaters/base_helpers.rb +0 -147
  104. data/lib/ruhoh/templaters/helpers.rb +0 -8
  105. data/lib/ruhoh/templaters/rmustache.rb +0 -70
  106. data/lib/ruhoh/urls.rb +0 -50
  107. data/lib/ruhoh/watch.rb +0 -78
  108. data/spec/config_spec.rb +0 -50
  109. data/spec/db_spec.rb +0 -91
  110. data/spec/page_spec.rb +0 -164
  111. data/spec/parsers/layouts_spec.rb +0 -41
  112. data/spec/parsers/pages_spec.rb +0 -120
  113. data/spec/parsers/posts_spec.rb +0 -309
  114. data/spec/parsers/routes_spec.rb +0 -39
  115. data/spec/parsers/site_spec.rb +0 -28
  116. data/spec/setup_spec.rb +0 -12
  117. data/system/scaffolds/draft.html +0 -9
  118. data/system/scaffolds/page.html +0 -4
  119. data/system/widgets/analytics/config.yml +0 -5
  120. data/system/widgets/comments/config.yml +0 -13
  121. data/system/widgets/google_prettify/config.yml +0 -1
@@ -1,66 +0,0 @@
1
- class Ruhoh
2
- module Templaters
3
- module AssetHelpers
4
-
5
- def assets
6
- method = "assets_#{Ruhoh.config.env}"
7
- return '' unless self.respond_to?(method)
8
- self.__send__(method)
9
- end
10
-
11
- def assets_development
12
- buffer = ''
13
- master_layout = self.context['page']['master_layout']
14
- sub_layout = self.context['page']['sub_layout']
15
- stylesheets = Ruhoh::DB.stylesheets[master_layout] || []
16
- stylesheets += Ruhoh::DB.stylesheets[sub_layout] || []
17
- stylesheets += Ruhoh::DB.stylesheets[Ruhoh.names.widgets] || []
18
- stylesheets.each do |style|
19
- buffer += "<link href=\"#{style['url']}?#{rand()}\" type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n"
20
- end
21
- buffer += "\n"
22
- scripts = Ruhoh::DB.javascripts[master_layout] || []
23
- scripts += Ruhoh::DB.javascripts[sub_layout] || []
24
- scripts += Ruhoh::DB.javascripts[Ruhoh.names.widgets] || []
25
- scripts.each do |script|
26
- buffer += "<script src=\"#{script['url']}?#{rand()}\"></script>\n"
27
- end
28
-
29
- buffer
30
- end
31
-
32
- # TODO: Implement this for real.
33
- def assets_production
34
- self.assets_development
35
- end
36
-
37
- # NOTICE: This is unfinished and not-implemented!
38
- def assets_production_not_implemented
39
- buffer = ''
40
- master_layout = self.context['page']['master_layout']
41
- sub_layout = self.context['page']['sub_layout']
42
- stylesheets = []
43
- stylesheets << master_layout if Ruhoh::DB.stylesheets[master_layout]
44
- stylesheets << sub_layout if Ruhoh::DB.stylesheets[sub_layout]
45
-
46
- stylesheets.each do |name|
47
- url = [Ruhoh.urls.theme_stylesheets, "#{name}.css"].join('/')
48
- buffer += "<link href=\"#{url}\" type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n"
49
- end
50
- buffer += "\n"
51
-
52
- scripts = []
53
- scripts << master_layout if Ruhoh::DB.javascripts[master_layout]
54
- scripts << sub_layout if Ruhoh::DB.javascripts[sub_layout]
55
- # Missing widgets
56
- scripts.each do |name|
57
- url = [Ruhoh.urls.theme_javascripts, "#{name}.js"].join('/')
58
- buffer += "<script src=\"#{url}\"></script>\n"
59
- end
60
-
61
- buffer
62
- end
63
-
64
- end #AssetHelpers
65
- end #Templaters
66
- end #Ruhoh
@@ -1,147 +0,0 @@
1
- class Ruhoh
2
- module Templaters
3
- module BaseHelpers
4
-
5
- def partial(name)
6
- p = Ruhoh::DB.partials[name.to_s]
7
- Ruhoh::Friend.say { yellow "partial not found: '#{name}'" } if p.nil?
8
- p
9
- end
10
-
11
- # Truncate the page content relative to a line_count limit.
12
- # This is optimized for markdown files in which content is largely
13
- # blocked into chunks and separating by blank lines.
14
- # The line_limit truncates content based on # of content-based lines,
15
- # so blank lines don't count toward the limit.
16
- # Always break the content on a blank line only so result stays formatted nicely.
17
- def summary
18
- content, id = self.get_page_content
19
- line_limit = self.context['site']['config']['posts']['summary_lines'].to_i rescue nil
20
- line_limit ||= 20
21
- line_count = 0
22
- line_breakpoint = content.lines.count
23
-
24
- content.lines.each_with_index do |line, i|
25
- if line =~ /^\s*$/ # line with only whitespace
26
- if line_count >= line_limit
27
- line_breakpoint = i
28
- break
29
- end
30
- else
31
- line_count += 1
32
- end
33
- end
34
-
35
- content = content.lines.to_a[0, line_breakpoint].join
36
- content = self.render(content)
37
- Ruhoh::Converter.convert(content, id)
38
- end
39
-
40
- def pages
41
- pages = []
42
- self.context['db']['pages'].each_value {|page| pages << page }
43
- self.mark_active_page(pages)
44
- end
45
-
46
- def posts
47
- self.to_posts(self.context['db']['posts']['chronological'])
48
- end
49
-
50
- def posts_latest
51
- latest = self.context['site']['config']['posts']['latest'].to_i rescue nil
52
- latest ||= 10
53
- (latest.to_i > 0) ? self.posts[0, latest.to_i] : self.posts
54
- end
55
-
56
- def categories
57
- cats = []
58
- self.context['db']['posts']['categories'].each_value { |cat| cats << cat }
59
- cats
60
- end
61
-
62
- def tags
63
- tags = []
64
- self.context['db']['posts']['tags'].each_value { |tag| tags << tag }
65
- tags
66
- end
67
-
68
- def raw_code(sub_context)
69
- code = sub_context.gsub('{', '&#123;').gsub('}', '&#125;').gsub('<', '&lt;').gsub('>', '&gt;')
70
- "<pre><code>#{code}</code></pre>"
71
- end
72
-
73
- def debug(sub_context)
74
- Ruhoh::Friend.say {
75
- yellow "?debug:"
76
- magenta sub_context.class
77
- cyan sub_context.inspect
78
- }
79
-
80
- "<pre>#{sub_context.class}\n#{sub_context.pretty_inspect}</pre>"
81
- end
82
-
83
- def to_posts(sub_context)
84
- Array(sub_context).map { |id|
85
- self.context['db']['posts']['dictionary'][id]
86
- }.compact
87
- end
88
-
89
- def to_pages(sub_context)
90
- pages = Array(sub_context).map { |id|
91
- self.context['db']['pages'][id]
92
- }.compact
93
- self.mark_active_page(pages)
94
- end
95
-
96
- def to_categories(sub_context)
97
- Array(sub_context).map { |id|
98
- self.context['db']['posts']['categories'][id]
99
- }.compact
100
- end
101
-
102
- def to_tags(sub_context)
103
- Array(sub_context).map { |id|
104
- self.context['db']['posts']['tags'][id]
105
- }.compact
106
- end
107
-
108
- def next(sub_context)
109
- return unless sub_context.is_a?(String) || sub_context.is_a?(Hash)
110
- id = sub_context.is_a?(Hash) ? sub_context['id'] : sub_context
111
- return unless id
112
- index = self.context['db']['posts']['chronological'].index(id)
113
- return unless index && (index-1 >= 0)
114
- next_id = self.context['db']['posts']['chronological'][index-1]
115
- return unless next_id
116
- self.to_posts(next_id)
117
- end
118
-
119
- def previous(sub_context)
120
- return unless sub_context.is_a?(String) || sub_context.is_a?(Hash)
121
- id = sub_context.is_a?(Hash) ? sub_context['id'] : sub_context
122
- return unless id
123
- index = self.context['db']['posts']['chronological'].index(id)
124
- return unless index && (index+1 >= 0)
125
- prev_id = self.context['db']['posts']['chronological'][index+1]
126
- return unless prev_id
127
- self.to_posts(prev_id)
128
- end
129
-
130
- def to_json(sub_context)
131
- sub_context.to_json
132
- end
133
-
134
- # Marks the active page if exists in the given pages Array
135
- def mark_active_page(pages)
136
- pages.each_with_index do |page, i|
137
- next unless page['id'] == self.context[:page]['id']
138
- active_page = page.dup
139
- active_page['is_active_page'] = true
140
- pages[i] = active_page
141
- end
142
- pages
143
- end
144
-
145
- end #BaseHelpers
146
- end #Templaters
147
- end #Ruhoh
@@ -1,8 +0,0 @@
1
- class Ruhoh
2
- module Templaters
3
- # Interface for user-defined helper methods
4
- module Helpers
5
-
6
- end #Helpers
7
- end #Templaters
8
- end #Ruhoh
@@ -1,70 +0,0 @@
1
- require 'ruhoh/templaters/base_helpers'
2
- require 'ruhoh/templaters/asset_helpers'
3
- require 'ruhoh/templaters/helpers'
4
-
5
- class Ruhoh
6
- module Templaters
7
- class RMustache < Mustache
8
- include Ruhoh::Templaters::BaseHelpers
9
- include Ruhoh::Templaters::AssetHelpers
10
- include Ruhoh::Templaters::Helpers
11
-
12
- class RContext < Context
13
-
14
- # Overload find method to catch helper expressions
15
- def find(obj, key, default = nil)
16
- return super unless key.to_s.index('?')
17
- context, helper = key.to_s.split('?')
18
- context = context.empty? ? obj : super(obj, context)
19
-
20
- self.mustache_in_stack.__send__ helper, context
21
- end
22
-
23
- end #RContext
24
-
25
- def context
26
- @context ||= RContext.new(self)
27
- end
28
-
29
- # Lazy-load the page body.
30
- # When in a global scope (layouts, pages), the content is for the current page.
31
- # May also be called in sub-contexts such as looping through posts.
32
- #
33
- # {{# posts }}
34
- # {{{ content }}}
35
- # {{/ posts }}
36
- def content
37
- content, id = self.get_page_content
38
- content = self.render(content)
39
- Ruhoh::Converter.convert(content, id)
40
- end
41
-
42
- def get_page_content
43
- id = self.context['id']
44
- id ||= self.context['page']['id']
45
- return '' unless id
46
- unless id =~ Regexp.new("^#{Ruhoh.names.posts}")
47
- id = "#{Ruhoh.names.pages}/#{id}"
48
- end
49
-
50
- [Ruhoh::Utils.parse_page_file(Ruhoh.paths.base, id)['content'], id]
51
- end
52
-
53
- def widget(name)
54
- return '' if self.context['page'][name.to_s].to_s == 'false'
55
- Ruhoh::DB.widgets[name.to_s]['layout']
56
- end
57
-
58
- def method_missing(name, *args, &block)
59
- return self.widget(name.to_s) if Ruhoh::DB.widgets.has_key?(name.to_s)
60
- super
61
- end
62
-
63
- def respond_to?(method)
64
- return true if Ruhoh::DB.widgets.has_key?(method.to_s)
65
- super
66
- end
67
-
68
- end #RMustache
69
- end #Templaters
70
- end #Ruhoh
data/lib/ruhoh/urls.rb DELETED
@@ -1,50 +0,0 @@
1
- class Ruhoh
2
- # Structured container for all pre-defined URLs in the system.
3
- # These URLs are used primarily for static assets in development mode.
4
- # When compiling, all urls are of course mapped literally to the asset filepaths.
5
- module Urls
6
- Urls = Struct.new(
7
- :media,
8
- :widgets,
9
- :dashboard,
10
- :theme,
11
- :theme_media,
12
- :theme_javascripts,
13
- :theme_stylesheets,
14
- :theme_widgets
15
- )
16
-
17
- def self.generate
18
- urls = Urls.new
19
- urls.media = self.to_url(Ruhoh.names.assets, Ruhoh.names.media)
20
- urls.widgets = self.to_url(Ruhoh.names.assets, Ruhoh.names.widgets)
21
- urls.dashboard = self.to_url(Ruhoh.names.dashboard_file.split('.')[0])
22
-
23
- urls.theme = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme)
24
- urls.theme_media = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.media)
25
- urls.theme_javascripts = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.javascripts)
26
- urls.theme_stylesheets = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.stylesheets)
27
- urls.theme_widgets = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.widgets)
28
- urls
29
- end
30
-
31
- # Ruhoh.config.base_path is assumed to be well-formed.
32
- # Always remove trailing slash.
33
- # Returns String - normalized url with prepended base_path
34
- def self.to_url(*args)
35
- url = args.join('/').chomp('/').reverse.chomp('/').reverse
36
- url = Ruhoh.config.base_path + url
37
- end
38
-
39
- def self.to_url_slug(title)
40
- CGI::escape self.to_slug(title)
41
- end
42
-
43
- # My Post Title ===> my-post-title
44
- def self.to_slug(title)
45
- title = title.to_s.downcase.strip.gsub(/[^\p{Word}+]/u, '-')
46
- title.gsub(/^\-+/, '').gsub(/\-+$/, '').gsub(/\-+/, '-')
47
- end
48
-
49
- end #Urls
50
- end #Ruhoh
data/lib/ruhoh/watch.rb DELETED
@@ -1,78 +0,0 @@
1
- require 'directory_watcher'
2
-
3
- class Ruhoh
4
- module Watch
5
-
6
- # Internal: Watch website source directory for file changes.
7
- # The observer triggers data regeneration as files change
8
- # in order to keep the data up to date in real time.
9
- #
10
- # Returns: Nothing
11
- def self.start
12
- Ruhoh.ensure_setup
13
- Ruhoh::Friend.say {
14
- plain "=> Start watching: #{Ruhoh.paths.base}"
15
- }
16
- glob = ''
17
-
18
- # Watch all files + all sub directories except for special folders e.g '_database'
19
- Dir.chdir(Ruhoh.paths.base) {
20
- dirs = Dir['*'].select { |x| File.directory?(x) }
21
- dirs = dirs.map { |x| "#{x}/**/*" }
22
- dirs += ['*']
23
- glob = dirs
24
- }
25
-
26
- dw = DirectoryWatcher.new(Ruhoh.paths.base, {
27
- :glob => glob,
28
- :pre_load => true
29
- })
30
- dw.interval = 1
31
- dw.add_observer {|*args|
32
- args.each {|event|
33
- path = event['path'].gsub(Ruhoh.paths.base + '/', '')
34
-
35
- if path == Ruhoh.names.site_data
36
- type = "Site"
37
- Ruhoh::DB.update(:site)
38
- elsif path == Ruhoh.names.config_data
39
- type = "Config"
40
- Ruhoh::DB.update(:site)
41
- elsif path =~ Regexp.new("^#{Ruhoh.names.pages}")
42
- type = "Pages"
43
- Ruhoh::DB.update(:pages)
44
- Ruhoh::DB.update(:routes)
45
- elsif path =~ Regexp.new("^(#{Ruhoh.names.partials}|#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}\/#{Ruhoh.names.partials})")
46
- type = "Partials"
47
- Ruhoh::DB.update(:partials)
48
- elsif path =~ Regexp.new("^#{Ruhoh.names.posts}")
49
- type = "Posts"
50
- Ruhoh::DB.update(:posts)
51
- Ruhoh::DB.update(:routes)
52
- elsif path =~ Regexp.new("^#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}\/#{Ruhoh.names.layouts}")
53
- type = "Layouts"
54
- Ruhoh::DB.update(:layouts)
55
- elsif path =~ Regexp.new("^#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}")
56
- type = "Theme"
57
- Ruhoh::DB.update(:stylesheets)
58
- Ruhoh::DB.update(:javascripts)
59
- Ruhoh::DB.update(:widgets)
60
- Ruhoh::DB.update(:layouts)
61
- elsif path =~ Regexp.new("^#{Ruhoh.names.widgets}")
62
- type = "Widgets"
63
- Ruhoh::DB.update(:widgets)
64
- else
65
- type = 'Unrecognized'
66
- end
67
-
68
- Ruhoh::Friend.say {
69
- yellow "Watch [#{Time.now.strftime("%H:%M:%S")}] [Update #{type}] : #{args.size} files changed"
70
- }
71
- }
72
- }
73
-
74
- dw.start
75
- end
76
-
77
- end #Watch
78
- end #Ruhoh
data/spec/config_spec.rb DELETED
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Config
4
- describe "Config" do
5
- describe "#setup_config" do
6
- context "Invalid _config.yml file" do
7
- it 'should log error and return false if theme is not specified.' do
8
- Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({})
9
-
10
- Ruhoh.log.should_receive(:error)
11
- Ruhoh::Config.generate.should be_false
12
- end
13
- end
14
- context "Valid _config.yml file" do
15
- it 'should setup the config struct based on configuration input.' do
16
- custom_permalink = '/my/custom/link'
17
- custom_theme = 'table'
18
- custom_exclude = ['.secret']
19
- Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
20
- "theme" => custom_theme,
21
- "posts" => {
22
- "permalink" => custom_permalink,
23
- 'exclude' => custom_exclude
24
- }
25
- })
26
-
27
- config = Ruhoh::Config.generate
28
- config.theme.should == custom_theme
29
- config.posts_exclude.should == [/.secret/]
30
- end
31
- end
32
- end
33
-
34
- describe "#setup_filters" do
35
- it 'should add custom exclude filters to the filters variable' do
36
- custom_exclude = ['.secret', '^test']
37
- Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
38
- 'theme' => "twitter",
39
- "posts" => {
40
- 'exclude' => custom_exclude
41
- },
42
- })
43
-
44
- config = Ruhoh::Config.generate
45
- config.posts_exclude.should include(/.secret/)
46
- config.posts_exclude.should include(/^test/)
47
- end
48
- end
49
- end
50
- end