baron 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/baron.gemspec +2 -1
- data/lib/baron.rb +6 -14
- data/spec/baron_theme_spec.rb +9 -0
- data/spec/sample_data/supplemental-files/theme_config.yml +5 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.9
|
data/baron.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "baron"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Buggia"]
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
"spec/sample_data/resources/feed.rss",
|
45
45
|
"spec/sample_data/resources/redirects.txt",
|
46
46
|
"spec/sample_data/resources/robots.txt",
|
47
|
+
"spec/sample_data/supplemental-files/theme_config.yml",
|
47
48
|
"spec/sample_data/themes/typography/css/app.css",
|
48
49
|
"spec/sample_data/themes/typography/css/bootstrap-responsive.css",
|
49
50
|
"spec/sample_data/themes/typography/css/bootstrap-responsive.min.css",
|
data/lib/baron.rb
CHANGED
@@ -102,6 +102,7 @@ module Baron
|
|
102
102
|
params = {:page_name => route.first, :rss_feed => get_feed_path}
|
103
103
|
params[:page_title] = (route.first == @config[:root] ? '' : "#{route.first.capitalize} #{@config[:title_delimiter]} ") + "#{@config[:title]}"
|
104
104
|
theme = Theme.new(@config)
|
105
|
+
theme.load_config
|
105
106
|
|
106
107
|
begin
|
107
108
|
|
@@ -232,20 +233,10 @@ module Baron
|
|
232
233
|
get_all_categories.each { |h| return true if h[:node_name] == path_node }
|
233
234
|
return false
|
234
235
|
end
|
235
|
-
|
236
|
-
def load_theme_config filename_and_path
|
237
|
-
bar = {}
|
238
|
-
metadata = File.read(filename_and_path)
|
239
|
-
YAML.load(metadata).each_pair { |key, value| bar[key.downcase.to_sym] = value }
|
240
|
-
bar
|
241
|
-
rescue Errno::ENOENT => e
|
242
|
-
return {}
|
243
|
-
end
|
244
236
|
|
245
237
|
def get_pages_path() "#{@config[:sample_data_path]}pages/" end
|
246
238
|
def get_articles_path() "#{@config[:sample_data_path]}articles" end
|
247
239
|
def get_page_template(name) "#{@config[:sample_data_path]}pages/#{name}.rhtml" end
|
248
|
-
def get_theme_template(name) "#{@config[:sample_data_path]}themes/#{@config[:theme]}/templates/#{name}.rhtml" end
|
249
240
|
def get_system_resource(name) "#{@config[:sample_data_path]}resources/#{name}" end
|
250
241
|
def get_feed_path() "#{@config[:url]}/feed.rss" end
|
251
242
|
end
|
@@ -256,12 +247,13 @@ module Baron
|
|
256
247
|
self[:root] = "/themes/#{config[:theme]}"
|
257
248
|
self[:name] = config[:theme]
|
258
249
|
self[:file_root] = "#{@config[:sample_data_path]}themes/#{@config[:theme]}".squeeze('/')
|
259
|
-
|
250
|
+
self[:theme_config] = "#{self[:file_root]}/theme_config.yml".squeeze('/')
|
260
251
|
end
|
261
252
|
|
262
|
-
def load_config filename_and_path
|
263
|
-
|
264
|
-
YAML.load(
|
253
|
+
def load_config filename_and_path = ''
|
254
|
+
filename_and_path = filename_and_path.empty? ? self[:theme_config] : filename_and_path
|
255
|
+
params = YAML.load(File.read(filename_and_path))
|
256
|
+
params.each_pair { |key, value| self[key.downcase.to_sym] = value } unless !params
|
265
257
|
rescue Errno::ENOENT => e
|
266
258
|
puts "Warning: unable to load config file : " + filename_and_path
|
267
259
|
end
|
data/spec/baron_theme_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe "Baron::Theme" do
|
|
9
9
|
before :all do
|
10
10
|
@config = load_config()
|
11
11
|
@theme = Baron::Theme.new(@config)
|
12
|
+
@theme.load_config()
|
12
13
|
end
|
13
14
|
|
14
15
|
it "finds all parameters in theme_config.yml" do
|
@@ -26,4 +27,12 @@ describe "Baron::Theme" do
|
|
26
27
|
@theme.get_template('home').should == SAMPLE_DATA_PATH + 'themes/typography/templates/home.rhtml'
|
27
28
|
@theme.get_template('layout').should == SAMPLE_DATA_PATH + 'themes/typography/templates/layout.rhtml'
|
28
29
|
end
|
30
|
+
|
31
|
+
it "doesn't crash with a bad or empty config file" do
|
32
|
+
theme = Baron::Theme.new({})
|
33
|
+
theme.load_config("#{SAMPLE_DATA_PATH}supplemental-files/theme_config.yml")
|
34
|
+
theme.length.should == 4
|
35
|
+
theme.load_config("FOOBAR-FAKE-URL-FAKE-FAKE")
|
36
|
+
theme.length.should == 4
|
37
|
+
end
|
29
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- spec/sample_data/resources/feed.rss
|
82
82
|
- spec/sample_data/resources/redirects.txt
|
83
83
|
- spec/sample_data/resources/robots.txt
|
84
|
+
- spec/sample_data/supplemental-files/theme_config.yml
|
84
85
|
- spec/sample_data/themes/typography/css/app.css
|
85
86
|
- spec/sample_data/themes/typography/css/bootstrap-responsive.css
|
86
87
|
- spec/sample_data/themes/typography/css/bootstrap-responsive.min.css
|