Class: FunWith::Gems::Testing::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_with/gems/testing/validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_const) ⇒ Validator

Returns a new instance of Validator.



9
10
11
# File 'lib/fun_with/gems/testing/validator.rb', line 9

def initialize( gem_const )
  @gem_const = gem_const
end

Class Method Details

.validate(gem_const) ⇒ Object



5
6
7
# File 'lib/fun_with/gems/testing/validator.rb', line 5

def self.validate( gem_const )
  self.new( gem_const ).validate
end

Instance Method Details

#fun_gem_errorsObject



37
38
39
# File 'lib/fun_with/gems/testing/validator.rb', line 37

def fun_gem_errors
  @fun_gem_errors
end

#git_up_to_date?(filepath) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
# File 'lib/fun_with/gems/testing/validator.rb', line 41

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

#validateObject

should be available via the gem itgem_const?



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fun_with/gems/testing/validator.rb', line 14

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 directory doesn't exist"          unless @gem_const.root("lib").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)
    @fun_gem_errors << "doesn't respond to .version()"
  end

  @fun_gem_errors
end