Module: Syntaxer
- Defined in:
- lib/syntaxer/reader.rb,
lib/syntaxer.rb,
lib/syntaxer/checker.rb,
lib/syntaxer/printer.rb,
lib/syntaxer/railtie.rb,
lib/syntaxer/repository.rb,
lib/syntaxer/file_status.rb,
lib/syntaxer/progress_bar.rb,
lib/syntaxer/language_definition.rb
Overview
Defined Under Namespace
Modules: Reader Classes: Checker, FileStatus, Git, GitRepositoryError, LanguageDefinition, LanguageDefinitionException, LanguageRules, PlainChecker, Printer, ProgressBar, Railtie, RepoChecker, Repository, RepositoryError, Svn, SvnRepositoryError
Constant Summary collapse
- DEFAULT_FILES_MASK =
"**/*"
- SYNTAXER_RULES_FILE =
File.join(File.dirname(__FILE__), "..", "syntaxer_rules.dist.rb")
Class Attribute Summary collapse
-
.hook ⇒ Object
readonly
Returns the value of attribute hook.
-
.reader ⇒ Object
readonly
Returns the value of attribute reader.
-
.repository ⇒ Object
readonly
Returns the value of attribute repository.
-
.results ⇒ Object
readonly
Returns the value of attribute results.
-
.root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
.warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
-
.check_syntax(options = {}) ⇒ Boolean
Main method to be used for syntax checking.
- .configure {|_self| ... } ⇒ Object
-
.make_hook(options) ⇒ Nil
This method generate and put hook to .git/hooks.
Class Attribute Details
.hook ⇒ Object (readonly)
Returns the value of attribute hook.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def hook @hook end |
.reader ⇒ Object (readonly)
Returns the value of attribute reader.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def reader @reader end |
.repository ⇒ Object (readonly)
Returns the value of attribute repository.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def repository @repository end |
.results ⇒ Object (readonly)
Returns the value of attribute results.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def results @results end |
.root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def root_path @root_path end |
.warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
23 24 25 |
# File 'lib/syntaxer.rb', line 23 def warnings @warnings end |
Class Method Details
.check_syntax(options = {}) ⇒ Boolean
Main method to be used for syntax checking.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/syntaxer.rb', line 39 def check_syntax( = {}) @root_path = [:root_path] Printer.quite = [:quite] || false Printer.loud = [:loud] || false @warnings = [:warnings] @hook = [:hook] @reader = Reader::DSLReader.load([:config_file]) @repository = Repository.factory(@root_path, [:repository]) if [:repository] checker = Checker.process(self) Printer.print_result checker exit(1) unless checker.error_files.empty? end |
.configure {|_self| ... } ⇒ Object
25 26 27 |
# File 'lib/syntaxer.rb', line 25 def configure yield(self) if block_given? end |
.make_hook(options) ⇒ Nil
This method generate and put hook to .git/hooks
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/syntaxer.rb', line 62 def make_hook() @root_path = [:root_path] raise ArgumentError, 'Indicate repository type' unless .include?(:repository) raise ArgumentError, "SVN is temporarily not supported" if [:repository].to_sym == :svn repo = Repository.factory(@root_path, [:repository]) hook_file = "#{@root_path}/.git/hooks/pre-commit" hook_string = "syntaxer -r git --hook" hook_string += " -c config/syntaxer.rb" if [:rails] File.open(hook_file, 'w') do |f| f.puts hook_string end File.chmod(0755, hook_file) rescue Exception => e puts e..color(:red) raise e end |