module Ore::Inferences
A mixin for {Project} which provides methods for assigning default values to project attributes.
Protected Instance Methods
Infers the release date of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 116 def infer_date! @date = Date.today end
Infers the default executable of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 147 def infer_default_executable! @default_executable = if @executables.include?(@name) @name else @executables.first end end
Infers documentation of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 160 def infer_documentation! if file?('.yardopts') @documentation = :yard else @documentation = :rdoc end end
Infers the executables of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 136 def infer_executables! glob(@@executables) do |path| check_executable(path) { |exe| @executables << File.basename(exe) } end end
Infers the extra documentation files of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 173 def infer_extra_doc_files! glob('README.*') { |path| add_extra_doc_file(path) } if @document @document.each_extra_file { |path| add_extra_doc_file(path) } end end
Infers the files of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 186 def infer_files! @project_files.each do |file| @files << file unless @@exclude_files.include?(file) end end
Infers the project name using the directory name of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 91 def infer_name! @name = @root.basename.to_s end
Infers the namespace of the project based on the project name.
@since 0.1.2.
# File lib/ore/inferences.rb, line 73 def infer_namespace! @namespace_modules = modules_of(@name) @namespace = namespace_of(@name) dir = namespace_path_of(@name) @namespace_dir = if lib_directory?(dir) dir elsif lib_directory?(@name) @name end end
Infers the project files.
@since 0.1.2.
# File lib/ore/inferences.rb, line 51 def infer_project_files! @project_files = Set[] filter_path = lambda { |path| check_readable(path) { |file| @project_files << file } } within do case @scm when :git `git ls-files -z`.split("\0").each(&filter_path) else within { Dir.glob('{**/}*',&filter_path) } end end end
Infers the require-paths of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 125 def infer_require_paths! @@require_paths.each do |name| @require_paths << name if @root.join(name).directory? end end
Infers the required version of RubyGems
to ‘>= 1.3.6`, if the project uses Bundler.
@since 0.1.2.
# File lib/ore/inferences.rb, line 209 def infer_required_rubygems_version! if bundler? @required_rubygems_version = '>= 1.3.6' end end
Infers the Source Code Management used by the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 38 def infer_scm! if @root.join('.git').directory? @scm = :git else @scm = nil end end
Infers the test-files of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 197 def infer_test_files! @@test_files.each do |pattern| glob(pattern) { |path| add_test_file(path) } end end
Finds and sets the version of the project.
@since 0.1.2.
# File lib/ore/inferences.rb, line 100 def infer_version! @version = ( Versions::VersionFile.find(self) || Versions::VersionConstant.find(self) ) unless @version raise(InvalidMetadata,"no version file or constant in #{@root}") end end