File: validate_project.rb

package info (click to toggle)
ruby-compass 1.0.3~dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,184 kB
  • ctags: 1,789
  • sloc: ruby: 12,904; makefile: 100; perl: 43; xml: 14; sh: 4
file content (77 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'compass/commands/project_base'
require 'compass/commands/update_project'

module Compass
  module Commands
    module ValidationOptionsParser
      def set_options(opts)
        opts.banner = %Q{
          Usage: compass validate [path/to/project] [options]

          Description:
            Compile project at the path specified or the current
            directory if not specified and then validate the 
            generated CSS.

          Options:
        }.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n")

        super
      end
    end
    class ValidateProject < ProjectBase

      register :validate

      def initialize(working_path, options)
        super
        assert_project_directory_exists!
      end

      def perform
        require 'compass/validator'
        UpdateProject.new(working_path, options).perform
        Dir.chdir Compass.configuration.project_path do
          Validator.new(project_css_subdirectory).validate()
        end
      end

      class << self

        def option_parser(arguments)
          parser = Compass::Exec::CommandOptionParser.new(arguments)
          parser.extend(Compass::Exec::GlobalOptionsParser)
          parser.extend(Compass::Exec::ProjectOptionsParser)
          parser.extend(ValidationOptionsParser)
        end

        def usage
          option_parser([]).to_s
        end

        def description(command)
          "Validate your generated css."
        end

        def parse!(arguments)
          parser = option_parser(arguments)
          parser.parse!
          parse_arguments!(parser, arguments)
          parser.options
        end

        def parse_arguments!(parser, arguments)
          if arguments.size == 1
            parser.options[:project_name] = arguments.shift
          elsif arguments.size == 0
            # default to the current directory.
          else
            raise Compass::Error, "Too many arguments were specified."
          end
        end

      end

    end
  end
end