mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-16 06:05:00 -05:00
Merge pull request #1022 from gkarekinian/patch-2
Fixed configuration overriding
This commit is contained in:
commit
7265683c33
5
Rakefile
5
Rakefile
@ -9,6 +9,7 @@ require 'rake/minify'
|
||||
require 'time'
|
||||
require 'yaml'
|
||||
require 'octopress'
|
||||
require 'rake/testtask'
|
||||
|
||||
### Configuring Octopress:
|
||||
### Under _config/ you will find:
|
||||
@ -525,3 +526,7 @@ task :list do
|
||||
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
|
||||
puts "(type rake -T for more detail)\n\n"
|
||||
end
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = "spec/**/*_spec.rb"
|
||||
end
|
||||
|
@ -2,8 +2,10 @@ require 'yaml'
|
||||
|
||||
module Octopress
|
||||
module Configuration
|
||||
CONFIG_DIR = File.join(File.dirname(__FILE__), '../', '../' '_config')
|
||||
|
||||
def self.config_dir(*subdirs)
|
||||
File.absolute_path(File.join(File.dirname(__FILE__), '../', '../' '_config', *subdirs))
|
||||
File.absolute_path(File.join(CONFIG_DIR, *subdirs))
|
||||
end
|
||||
|
||||
# Static: Reads the configuration of the specified file
|
||||
@ -55,10 +57,10 @@ module Octopress
|
||||
Dir.glob(self.config_dir('*.yml')) do |filename|
|
||||
file_yaml = YAML.load(File.read(filename))
|
||||
unless file_yaml.nil?
|
||||
configs = file_yaml.deep_merge(configs)
|
||||
configs = configs.deep_merge(file_yaml)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
configs.to_symbol_keys
|
||||
end
|
||||
|
||||
|
11
spec/fixtures/no_override/defaults/classic.yml
vendored
Normal file
11
spec/fixtures/no_override/defaults/classic.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# ------------------------------- #
|
||||
# Classic Theme Configuration #
|
||||
# ------------------------------- #
|
||||
|
||||
url: http://yoursite.com
|
||||
title: My Octopress Blog
|
||||
subtitle: A blogging framework for hackers.
|
||||
author: Your Name
|
||||
simple_search: http://google.com/search
|
||||
description:
|
11
spec/fixtures/override/defaults/classic.yml
vendored
Normal file
11
spec/fixtures/override/defaults/classic.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# ------------------------------- #
|
||||
# Classic Theme Configuration #
|
||||
# ------------------------------- #
|
||||
|
||||
url: http://yoursite.com
|
||||
title: My Octopress Blog
|
||||
subtitle: A blogging framework for hackers.
|
||||
author: Your Name
|
||||
simple_search: http://google.com/search
|
||||
description:
|
11
spec/fixtures/override/site.yml
vendored
Normal file
11
spec/fixtures/override/site.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# ------------------------------- #
|
||||
# Classic Theme Configuration #
|
||||
# ------------------------------- #
|
||||
|
||||
url: http://myownsite.com
|
||||
title: My Octopress custom Blog
|
||||
subtitle: "How did this get here? I'm not good with computers"
|
||||
author: John Doe
|
||||
simple_search: http://google.com/search
|
||||
description:
|
42
spec/octopress/configuration_spec.rb
Normal file
42
spec/octopress/configuration_spec.rb
Normal file
@ -0,0 +1,42 @@
|
||||
require 'minitest/autorun'
|
||||
require_relative '../../lib/octopress'
|
||||
|
||||
describe Octopress::Configuration do
|
||||
describe '.read_configuration' do
|
||||
subject do
|
||||
Octopress::Configuration.read_configuration
|
||||
end
|
||||
|
||||
describe "when no override" do
|
||||
before do
|
||||
Octopress::Configuration::CONFIG_DIR = File.join(File.dirname(__FILE__), '../', 'fixtures', 'no_override')
|
||||
end
|
||||
|
||||
it "returns the default config with keys as symbols" do
|
||||
expected_config = { :url => "http://yoursite.com",
|
||||
:title => "My Octopress Blog",
|
||||
:subtitle => "A blogging framework for hackers.",
|
||||
:author => "Your Name",
|
||||
:simple_search => "http://google.com/search",
|
||||
:description => nil }
|
||||
subject.must_equal expected_config
|
||||
end
|
||||
end
|
||||
|
||||
describe "when override" do
|
||||
before do
|
||||
Octopress::Configuration::CONFIG_DIR = File.join(File.dirname(__FILE__), '../', 'fixtures', 'override')
|
||||
end
|
||||
|
||||
it "returns the default config with keys as symbols" do
|
||||
expected_config = { :url => "http://myownsite.com",
|
||||
:title => "My Octopress custom Blog",
|
||||
:subtitle => "How did this get here? I'm not good with computers",
|
||||
:author => "John Doe",
|
||||
:simple_search => "http://google.com/search",
|
||||
:description => nil }
|
||||
subject.must_equal expected_config
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user