Class: HtmlMockup::Cli::Base

Inherits:
Thor
  • Object
show all
Defined in:
lib/html_mockup/cli.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



36
37
38
39
# File 'lib/html_mockup/cli.rb', line 36

def initialize(*args)
  super
  self.class.project = initialize_project
end

Class Attribute Details

.projectObject

Returns the value of attribute project.



42
43
44
# File 'lib/html_mockup/cli.rb', line 42

def project
  @project
end

Instance Method Details

#validate(path = ".") ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/html_mockup/cli.rb', line 71

def validate(path=".")
  filter = options["filter"] || "[^_]*.html"
  
  puts "Filtering on #{options["filter"]}" if options["filter"]
  
  if File.directory?(path)
    any_invalid = false
    
    if (files = Dir.glob("#{path}/**/#{filter}")).any?
    	files.each do |file|
    		if !self.w3cvalidate(file)
    		  any_invalid = true
    	  end
    	end
    	if !any_invalid
    	  puts "All files were considered valid"
      end
    else
      puts "No files matched \"#{filter}\""
    end
  elsif File.readable?(path)
    self.w3cvalidate(path)
  else
    puts "No such file/directory #{path}"
  end      
end