Module: Jekyll::Deprecator

Extended by:
Deprecator
Included in:
Deprecator
Defined in:
lib/jekyll/deprecator.rb

Instance Method Summary collapse

Instance Method Details

#arg_is_present?(args, deprecated_argument, message) ⇒ Boolean



28
29
30
31
32
# File 'lib/jekyll/deprecator.rb', line 28

def arg_is_present?(args, deprecated_argument, message)
  if args.include?(deprecated_argument)
    deprecation_message(message)
  end
end

#defaults_deprecate_type(old, current) ⇒ Object



38
39
40
41
# File 'lib/jekyll/deprecator.rb', line 38

def defaults_deprecate_type(old, current)
  Jekyll.logger.warn "Defaults:", "The '#{old}' type has become '#{current}'."
  Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use 'type: #{current}'."
end

#deprecation_message(message) ⇒ Object



34
35
36
# File 'lib/jekyll/deprecator.rb', line 34

def deprecation_message(message)
  Jekyll.logger.error "Deprecation:", message
end

#gracefully_require(gem_name) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/jekyll/deprecator.rb', line 43

def gracefully_require(gem_name)
  Array(gem_name).each do |name|
    begin
      require name
    rescue LoadError => e
      Jekyll.logger.error "Dependency Error:", <<-MSG
  Yikes! It looks like you don't have #{name} or one of its dependencies installed.
  In order to use Jekyll as currently configured, you'll need to install this gem.

  The full error message from Ruby is: '#{e.message}'

  If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!
MSG
      raise Errors::MissingDependencyException.new(name)
    end
  end
end

#no_subcommand(args) ⇒ Object



21
22
23
24
25
26
# File 'lib/jekyll/deprecator.rb', line 21

def no_subcommand(args)
  if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first)
    deprecation_message "Jekyll now uses subcommands instead of just \
                        switches. Run `jekyll --help' to find out more."
  end
end

#process(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jekyll/deprecator.rb', line 5

def process(args)
  no_subcommand(args)
  arg_is_present? args, "--server", "The --server command has been replaced by the \
                      'serve' subcommand."
  arg_is_present? args, "--no-server", "To build Jekyll without launching a server, \
                      use the 'build' subcommand."
  arg_is_present? args, "--auto", "The switch '--auto' has been replaced with '--watch'."
  arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \
                      the '--watch' switch."
  arg_is_present? args, "--pygments", "The 'pygments'settings has been removed in \
                      favour of 'highlighter'."
  arg_is_present? args, "--paginate", "The 'paginate' setting can only be set in your \
                      config files."
  arg_is_present? args, "--url", "The 'url' setting can only be set in your config files."
end