Class: FunWith::Gems::Validator

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_const) ⇒ Validator

Returns a new instance of Validator.



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

def initialize( gem_const )
  @gem_const = gem_const
end

Class Method Details

.validate(gem_const) ⇒ Object



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

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

Instance Method Details

#fun_gem_errorsObject



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

def fun_gem_errors
  @fun_gem_errors
end

#git_up_to_date?(filepath) ⇒ Boolean

Returns:

  • (Boolean)


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

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?



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

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