module Ore::Inferences

A mixin for {Project} which provides methods for assigning default values to project attributes.

Protected Instance Methods

infer_date!() click to toggle source

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
infer_default_executable!() click to toggle source

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
infer_documentation!() click to toggle source

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
infer_executables!() click to toggle source

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
infer_extra_doc_files!() click to toggle source

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
infer_files!() click to toggle source

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
infer_name!() click to toggle source

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
infer_namespace!() click to toggle source

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
infer_project_files!() click to toggle source

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
infer_require_paths!() click to toggle source

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
infer_required_rubygems_version!() click to toggle source

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
infer_scm!() click to toggle source

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
infer_test_files!() click to toggle source

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
infer_version!() click to toggle source

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