зеркало из https://github.com/github/pages-gem.git
first pass at versioning config
This commit is contained in:
Родитель
a6bfbcce76
Коммит
d046cc1be2
|
@ -15,10 +15,10 @@ Mercenary.program(:"github-pages") do |p|
|
|||
c.option "gemfile", "--gemfile", "use Gemfile formatting"
|
||||
c.action do |args, options|
|
||||
if options["gemfile"]
|
||||
GitHubPages.gems.each { |g,v| puts "gem '#{g}', '#{v}'" }
|
||||
GitHubPages::Dependencies.gems.each { |g,v| puts "gem '#{g}', '#{v}'" }
|
||||
else
|
||||
require 'terminal-table'
|
||||
versions = options['all'] ? GitHubPages.versions : GitHubPages.gems
|
||||
versions = options['all'] ? GitHubPages::Dependencies.versions : GitHubPages::Dependencies.gems
|
||||
puts Terminal::Table.new :rows => versions, :headings => ["Gem", "Version"]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require File.expand_path('../lib/github-pages', __FILE__)
|
||||
require File.expand_path('../lib/github-pages/dependencies', __FILE__)
|
||||
require File.expand_path('../lib/github-pages/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 2.0.0"
|
||||
|
@ -13,17 +14,17 @@ Gem::Specification.new do |s|
|
|||
s.license = "MIT"
|
||||
s.executables = ["github-pages"]
|
||||
s.files = ["lib/github-pages.rb"]
|
||||
|
||||
|
||||
s.post_install_message = <<-msg
|
||||
---------------------------------------------------
|
||||
Thank you for installing github-pages!
|
||||
GitHub Pages recently upgraded to Jekyll 3.0, which
|
||||
GitHub Pages recently upgraded to Jekyll 3.0, which
|
||||
includes some breaking changes. More information:
|
||||
https://github.com/blog/2100-github-pages-jekyll-3
|
||||
---------------------------------------------------
|
||||
msg
|
||||
|
||||
GitHubPages.gems.each do |gem, version|
|
||||
GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
s.add_dependency(gem, "= #{version}")
|
||||
end
|
||||
|
||||
|
|
|
@ -1,61 +1,13 @@
|
|||
class GitHubPages
|
||||
VERSION = 48
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
|
||||
# Jekyll and related dependency versions as used by GitHub Pages.
|
||||
# For more information see:
|
||||
# https://help.github.com/articles/using-jekyll-with-pages
|
||||
def self.gems
|
||||
{
|
||||
# Jekyll
|
||||
"jekyll" => "3.0.3",
|
||||
"jekyll-sass-converter" => "1.3.0",
|
||||
"jekyll-textile-converter" => "0.1.0",
|
||||
require 'jekyll'
|
||||
|
||||
# Converters
|
||||
"kramdown" => "1.9.0",
|
||||
"rdiscount" => "2.1.8",
|
||||
"redcarpet" => "3.3.3",
|
||||
"RedCloth" => "4.2.9",
|
||||
|
||||
# Liquid
|
||||
"liquid" => "3.0.6",
|
||||
|
||||
# Highlighters
|
||||
"rouge" => "1.10.1",
|
||||
|
||||
# Plugins
|
||||
"jemoji" => "0.5.1",
|
||||
"jekyll-mentions" => "1.0.0",
|
||||
"jekyll-redirect-from" => "0.9.1",
|
||||
"jekyll-sitemap" => "0.10.0",
|
||||
"jekyll-feed" => "0.3.1",
|
||||
"jekyll-gist" => "1.4.0",
|
||||
"jekyll-paginate" => "1.1.0",
|
||||
"github-pages-health-check" => "0.6.1",
|
||||
"jekyll-coffeescript" => "1.0.1",
|
||||
"jekyll-seo-tag" => "1.0.0",
|
||||
}
|
||||
end
|
||||
|
||||
# Versions used by GitHub Pages, including github-pages gem and ruby version
|
||||
# Useful for programmatically querying for the current-running version
|
||||
def self.versions
|
||||
gems.merge deps_version_report
|
||||
end
|
||||
|
||||
def self.deps_version_report
|
||||
require 'html/pipeline/version'
|
||||
require 'sass/version'
|
||||
require 'safe_yaml/version'
|
||||
|
||||
{
|
||||
"ruby" => RUBY_VERSION,
|
||||
|
||||
# Gem versions we're curious about
|
||||
"github-pages" => VERSION.to_s,
|
||||
"html-pipeline" => HTML::Pipeline::VERSION,
|
||||
"sass" => Sass.version[:number],
|
||||
"safe_yaml" => SafeYAML::VERSION
|
||||
}
|
||||
end
|
||||
module GitHubPages
|
||||
autoload :Configuration, "github-pages/configuration"
|
||||
autoload :Dependencies, "github-pages/dependencies"
|
||||
end
|
||||
|
||||
Jekyll::Hooks.register :site, :after_reset do |site|
|
||||
puts "REGISTERING HOOK"
|
||||
GitHubPages::Configuration.set(site)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
module GitHubPages
|
||||
class Configuration
|
||||
|
||||
DEFAULT_PLUGINS = %w[
|
||||
jekyll-coffeescript
|
||||
jekyll-gist
|
||||
jekyll-paginate
|
||||
].freeze
|
||||
|
||||
PLUGIN_WHITELIST = %w[
|
||||
jekyll-redirect-from
|
||||
jekyll-mentions
|
||||
jekyll-sitemap
|
||||
jekyll-feed
|
||||
jekyll-coffeescript
|
||||
jekyll-paginate
|
||||
jekyll-seo-tag
|
||||
jekyll-gist
|
||||
jemoji
|
||||
].freeze
|
||||
|
||||
DEFAULTS = {
|
||||
"gems" => DEFAULT_PLUGINS,
|
||||
"kramdown" => {
|
||||
"input" => "GFM",
|
||||
"hard_wrap" => false
|
||||
}
|
||||
}.freeze
|
||||
|
||||
OVERRIDES = {
|
||||
"source" => Dir.pwd,
|
||||
"destination" => File.expand_path("_site", Dir.pwd),
|
||||
"lsi" => false,
|
||||
"safe" => true,
|
||||
"plugins" => SecureRandom.hex,
|
||||
"whitelist" => PLUGIN_WHITELIST,
|
||||
"incremental" => false,
|
||||
"highlighter" => "rouge",
|
||||
"kramdown" => {
|
||||
"template" => '',
|
||||
'math_engine' => 'mathajx',
|
||||
'syntax_highligher' => 'rouge'
|
||||
},
|
||||
"gist" => {
|
||||
"noscript" => false
|
||||
}
|
||||
}.freeze
|
||||
|
||||
def self.set(site)
|
||||
user_config_overridden = Jekyll.configuration(OVERRIDES)
|
||||
config = Jekyll::Utils.deep_merge_hashes(DEFAULTS, user_config_overridden)
|
||||
|
||||
site.instance_variable_set '@config', config
|
||||
config.keys.each do |key|
|
||||
site.send("#{key}=", config[key]) if site.respond_to?("#{key}=")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,61 @@
|
|||
module GitHubPages
|
||||
class Dependencies
|
||||
# Jekyll and related dependency versions as used by GitHub Pages.
|
||||
# For more information see:
|
||||
# https://help.github.com/articles/using-jekyll-with-pages
|
||||
def self.gems
|
||||
{
|
||||
# Jekyll
|
||||
"jekyll" => "3.0.3",
|
||||
"jekyll-sass-converter" => "1.3.0",
|
||||
"jekyll-textile-converter" => "0.1.0",
|
||||
|
||||
# Converters
|
||||
"kramdown" => "1.9.0",
|
||||
"rdiscount" => "2.1.8",
|
||||
"redcarpet" => "3.3.3",
|
||||
"RedCloth" => "4.2.9",
|
||||
|
||||
# Liquid
|
||||
"liquid" => "3.0.6",
|
||||
|
||||
# Highlighters
|
||||
"rouge" => "1.10.1",
|
||||
|
||||
# Plugins
|
||||
"jemoji" => "0.5.1",
|
||||
"jekyll-mentions" => "1.0.0",
|
||||
"jekyll-redirect-from" => "0.9.1",
|
||||
"jekyll-sitemap" => "0.10.0",
|
||||
"jekyll-feed" => "0.3.1",
|
||||
"jekyll-gist" => "1.4.0",
|
||||
"jekyll-paginate" => "1.1.0",
|
||||
"github-pages-health-check" => "0.6.1",
|
||||
"jekyll-coffeescript" => "1.0.1",
|
||||
"jekyll-seo-tag" => "1.0.0",
|
||||
}
|
||||
end
|
||||
|
||||
# Versions used by GitHub Pages, including github-pages gem and ruby version
|
||||
# Useful for programmatically querying for the current-running version
|
||||
def self.versions
|
||||
gems.merge version_report
|
||||
end
|
||||
|
||||
def self.version_report
|
||||
require 'html/pipeline/version'
|
||||
require 'sass/version'
|
||||
require 'safe_yaml/version'
|
||||
|
||||
{
|
||||
"ruby" => RUBY_VERSION,
|
||||
|
||||
# Gem versions we're curious about
|
||||
"github-pages" => VERSION.to_s,
|
||||
"html-pipeline" => HTML::Pipeline::VERSION,
|
||||
"sass" => Sass.version[:number],
|
||||
"safe_yaml" => SafeYAML::VERSION
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module GitHubPages
|
||||
VERSION = 48
|
||||
end
|
|
@ -5,7 +5,7 @@ describe(GitHubPages) do
|
|||
output = `github-pages versions`
|
||||
expect(output).to include("Gem")
|
||||
expect(output).to include("Version")
|
||||
GitHubPages.gems.each do |name, version|
|
||||
GitHubPages::Dependencies.gems.each do |name, version|
|
||||
expect(output).to include("| #{name}")
|
||||
expect(output).to include("| #{version}")
|
||||
end
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe(GitHubPages::Dependencies) do
|
||||
it "exposes its gem versions" do
|
||||
expect(described_class.gems).to be_a(Hash)
|
||||
end
|
||||
|
||||
it "exposes relevant versions of dependencies, self and Ruby" do
|
||||
expect(described_class.versions).to be_a(Hash)
|
||||
expect(described_class.versions).to include("ruby")
|
||||
expect(described_class.versions).to include("github-pages")
|
||||
end
|
||||
|
||||
%w[jekyll kramdown liquid rouge rdiscount redcarpet RedCloth].each do |gem|
|
||||
it "exposes #{gem} dependency version" do
|
||||
expect(described_class.gems[gem]).to be_a(String)
|
||||
expect(described_class.gems[gem]).not_to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it "exposes versions as Strings only" do
|
||||
described_class.versions.values.each do |version|
|
||||
expect(version).to be_a(String)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,27 +4,4 @@ describe(GitHubPages) do
|
|||
it "exposes its version" do
|
||||
expect(described_class::VERSION).to be_a(Fixnum)
|
||||
end
|
||||
|
||||
it "exposes its gem versions" do
|
||||
expect(described_class.gems).to be_a(Hash)
|
||||
end
|
||||
|
||||
it "exposes relevant versions of dependencies, self and Ruby" do
|
||||
expect(described_class.versions).to be_a(Hash)
|
||||
expect(described_class.versions).to include("ruby")
|
||||
expect(described_class.versions).to include("github-pages")
|
||||
end
|
||||
|
||||
%w[jekyll kramdown liquid rouge rdiscount redcarpet RedCloth].each do |gem|
|
||||
it "exposes #{gem} dependency version" do
|
||||
expect(described_class.gems[gem]).to be_a(String)
|
||||
expect(described_class.gems[gem]).not_to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it "exposes versions as Strings only" do
|
||||
described_class.versions.values.each do |version|
|
||||
expect(version).to be_a(String)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче