Class: FunWith::Gems::Validator
- Inherits:
-
Object
- Object
- FunWith::Gems::Validator
- Defined in:
- lib/fun_with/gems/validator.rb
Constant Summary collapse
- TEST_SUITE_DATA_REGEX =
/(<?tests>\d+) tests, (<?assertions>\d+) assertions, (<?failures>\d+) failures, (<?errors>\d+) errors, (<?skips>\d+) skips/
Class Method Summary collapse
Instance Method Summary collapse
- #fun_gem_errors ⇒ Object
- #git_up_to_date?(filepath) ⇒ Boolean
-
#initialize(gem_const) ⇒ Validator
constructor
A new instance of Validator.
- #passes_tests?(filepath) ⇒ Boolean
- #scan_results(str) ⇒ Object
-
#validate ⇒ Object
should be available via the gem itgem_const?.
Constructor Details
#initialize(gem_const) ⇒ Validator
Returns a new instance of Validator.
10 11 12 |
# File 'lib/fun_with/gems/validator.rb', line 10 def initialize( gem_const ) @gem_const = gem_const end |
Class Method Details
.validate(gem_const) ⇒ Object
6 7 8 |
# File 'lib/fun_with/gems/validator.rb', line 6 def self.validate( gem_const ) self.new( gem_const ).validate end |
Instance Method Details
#fun_gem_errors ⇒ Object
40 41 42 |
# File 'lib/fun_with/gems/validator.rb', line 40 def fun_gem_errors @fun_gem_errors end |
#git_up_to_date?(filepath) ⇒ Boolean
59 60 61 62 63 64 65 66 |
# File 'lib/fun_with/gems/validator.rb', line 59 def git_up_to_date?( filepath ) # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # (use "git push" to publish your local commits) # # nothing to commit, working directory clean # end |
#passes_tests?(filepath) ⇒ Boolean
45 46 47 48 |
# File 'lib/fun_with/gems/validator.rb', line 45 def passes_tests?( filepath ) @test_output = `cd #{filepath} && rake` results = scan_results( @test_output ) end |
#scan_results(str) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/fun_with/gems/validator.rb', line 50 def scan_results( str ) if m = str.match( TEST_SUITE_DATA_REGEX ) m[0] else "TEST STATS NOT FOUND" end end |
#validate ⇒ Object
should be available via the gem itgem_const?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fun_with/gems/validator.rb', line 15 def validate @fun_gem_errors = [] if @gem_const.respond_to?(:root) if @gem_const.root.is_a?( FunWith::Files::FilePath ) @fun_gem_errors << ".root() doesn't exist" unless @gem_const.root.directory? @fun_gem_errors << "VERSION file doesn't exist" unless @gem_const.root("VERSION").file? @fun_gem_errors << "CHANGELOG.markdown doesn't exist" unless @gem_const.root("CHANGELOG.markdown") @fun_gem_errors << "lib/fun_with directory doesn't exist" unless @gem_const.root("lib", "fun_with").directory? else @fun_gem_errors << ".root() doesn't give a filepath" end else @fun_gem_errors << "doesn't respond to .root()" end if @gem_const.respond_to?(:version) else @fun_gem_errors << "doesn't respond to .version()" end @fun_gem_errors end |