Class: HtmlMockup::Cli
- Inherits:
-
Thor
- Object
- Thor
- HtmlMockup::Cli
- Defined in:
- lib/html_mockup/cli.rb
Instance Method Summary collapse
- #extract(source_path = ".", target_path = "../out") ⇒ Object
- #release(path = ".") ⇒ Object
- #serve(path = ".") ⇒ Object
- #validate(path = ".") ⇒ Object
Instance Method Details
#extract(source_path = ".", target_path = "../out") ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/html_mockup/cli.rb', line 94 def extract(source_path=".", target_path="../out") project = initialize_project(source_path) extractor = HtmlMockup::Extractor.new(project, target_path) puts "Extracting mockup" puts (project) extractor.run! end |
#release(path = ".") ⇒ Object
51 52 53 54 |
# File 'lib/html_mockup/cli.rb', line 51 def release(path=".") project = initialize_project(path, ) project.release.run! end |
#serve(path = ".") ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/html_mockup/cli.rb', line 29 def serve(path=".") = {} .each{|k,v| [k.to_sym] = v } [:server] = {} [:port, :handler, :validate].each do |k| [:server][k] = .delete(k) if .has_key?(k) end # Load the project, it should take care of all the paths @project = initialize_project(path, ) server = @project.server server.([:server]) puts "Running HtmlMockup with #{server.handler.inspect} on port #{server.port}" puts (@project) server.run! end |
#validate(path = ".") ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/html_mockup/cli.rb', line 59 def validate(path=".") filter = ["filter"] || "[^_]*.html" puts "Filtering on #{["filter"]}" if ["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 |