Module: FunWith::Gems::FunGemAPI

Defined in:
lib/fun_with/gems/fun_gem_api.rb

Instance Method Summary collapse

Instance Method Details

#_load_tasks_from_directory(dir) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/fun_with/gems/fun_gem_api.rb', line 61

def _load_tasks_from_directory dir
  if _rake_gem_loaded?
    dir.glob do |file|
      if file.file? && ( file.ext == "rb" || file.ext == "rake" )
        Rake.load_rakefile file
      end
    end
  end
end

#_rake_gem_loaded?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/fun_with/gems/fun_gem_api.rb', line 71

def _rake_gem_loaded?
  defined?( Gem ) && Gem.respond_to?( :loaded_specs ) && defined?( Rake ) && Gem.loaded_specs.keys.include?( "rake" )
end

#gem_test_mode=(mode) ⇒ Object

I can’t think of a compelling reason to go beyond true/false here



27
28
29
# File 'lib/fun_with/gems/fun_gem_api.rb', line 27

def gem_test_mode=( mode )
  @fwg_gem_test_mode = mode
end

#gem_test_mode?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/fun_with/gems/fun_gem_api.rb', line 22

def gem_test_mode?
  @fwg_gem_test_mode || false
end

#gem_verbose=(mode) ⇒ Object



35
36
37
# File 'lib/fun_with/gems/fun_gem_api.rb', line 35

def gem_verbose=( mode )
  @fwg_gem_verbose = mode
end

#gem_verbose?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fun_with/gems/fun_gem_api.rb', line 31

def gem_verbose?
  @fwg_gem_verbose || false      # rather return false than nil
end

#is_fun_gem?Boolean

Returns:

  • (Boolean)


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

def is_fun_gem?
  true
end

#load_external_tasksObject

Tasks in gem/lib/tasks will be usable by gems which have this gem as a dependency.



57
58
59
# File 'lib/fun_with/gems/fun_gem_api.rb', line 57

def load_external_tasks
  _load_tasks_from_directory self.root( "lib", "tasks" )
end

#load_internal_tasksObject

Tasks in gem/tasks should be those which are specific to the gem itself. Tasks located here will not be made available to gems which depend on it. Made accessible during the Rakefile.setup



52
53
54
# File 'lib/fun_with/gems/fun_gem_api.rb', line 52

def load_internal_tasks
  _load_tasks_from_directory self.root( "tasks" )
end

#load_tasksObject



44
45
46
47
# File 'lib/fun_with/gems/fun_gem_api.rb', line 44

def load_tasks
  load_internal_tasks
  load_external_tasks
end

#passes_tests?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/fun_with/gems/fun_gem_api.rb', line 18

def passes_tests?
  TestSuiteRunner.new( self ).passes_tests?
end

#say_if_verbose(msg, stream = $stdout) ⇒ Object



39
40
41
# File 'lib/fun_with/gems/fun_gem_api.rb', line 39

def say_if_verbose( msg, stream = $stdout )
  stream.puts( msg ) if gem_verbose?
end

#valid_gem?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/fun_with/gems/fun_gem_api.rb', line 13

def valid_gem?
  errors = self.validate_gem
  errors.fwf_blank?
end

#validate_gemObject



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

def validate_gem
  errors = FunWith::Gems::Validator.validate self
  errors
end