Class: Jekyll::Commands::Extract
- Inherits:
-
Command
- Object
- Command
- Jekyll::Commands::Extract
- Defined in:
- lib/jekyll-extract.rb
Class Method Summary collapse
Class Method Details
.init_with_program(prog) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll-extract.rb', line 9 def init_with_program(prog) prog.command(:extract) do |c| c.syntax "extract [DIR (or) FILE-PATH] [options]" c.description "Extract theme-gem contents to source directory" c.option "show", "--show", "List the contents of the specified [DIR]" c.option "force", "--force", "Force extraction even if file already exists" c.option "list-all", "--list-all", "List all files in the theme-gem" c.action do |args, | process(args, ) end end end |
.process(args, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jekyll-extract.rb', line 24 def process(args, = {}) unless ["list-all"] raise ArgumentError, "You must specify a path." if args.empty? end config = Jekyll.configuration() @site ||= Site.new(config) Jekyll.logger.info "Source Directory:", config["source"] Jekyll.logger.info "Theme Directory:", @site.theme.root puts "" return list_all_files if ["list-all"] # Substitute leading special-characters in an argument with an # 'underscore' to disable extraction of files outside the theme-gem # but allow extraction of theme directories with a leading underscore. # # Process each valid argument individually to enable extraction of # multiple files or directories. args.map { |i| i.sub(%r!\A\W!, "_") }.each do |arg| ThemeGemExtractor.new(@site, ).extract arg end end |