Module: Ore::Inferences
Overview
A mixin for Project which provides methods for assigning default values to project attributes.
Constant Summary collapse
- @@require_paths =
The default require-paths
[@@lib_dir, @@ext_dir]
- @@executables =
The glob to find default executables
"#{@@bin_dir}/*"
- @@test_files =
The globs to find all testing-files
[ "#{@@test_dir}/{**/}*_test.rb", "#{@@spec_dir}/{**/}*_spec.rb" ]
- @@exclude_files =
The files to always exclude
%w[ .gitignore ]
Instance Method Summary collapse
-
#infer_date! ⇒ Object
protected
Infers the release date of the project.
-
#infer_default_executable! ⇒ Object
protected
Infers the default executable of the project.
-
#infer_documentation! ⇒ Object
protected
Infers documentation of the project.
-
#infer_executables! ⇒ Object
protected
Infers the executables of the project.
-
#infer_extra_doc_files! ⇒ Object
protected
Infers the extra documentation files of the project.
-
#infer_files! ⇒ Object
protected
Infers the files of the project.
-
#infer_name! ⇒ Object
protected
Infers the project name using the directory name of the project.
-
#infer_namespace! ⇒ Object
protected
Infers the namespace of the project based on the project name.
-
#infer_project_files! ⇒ Object
protected
Infers the project files.
-
#infer_require_paths! ⇒ Object
protected
Infers the require-paths of the project.
-
#infer_required_rubygems_version! ⇒ Object
protected
Infers the required version of RubyGems to
>= 1.3.6
, if the project uses Bundler. -
#infer_scm! ⇒ Object
protected
Infers the Source Code Management used by the project.
-
#infer_test_files! ⇒ Object
protected
Infers the test-files of the project.
-
#infer_version! ⇒ Object
protected
Finds and sets the version of the project.
Methods included from Naming
#module_of, #modules_of, #names_in, #namespace_dirs_of, #namespace_of, #namespace_path_of, #underscore
Instance Method Details
#infer_date! ⇒ Object (protected)
Infers the release date of the project.
116 117 118 |
# File 'lib/ore/inferences.rb', line 116 def infer_date! @date = Date.today end |
#infer_default_executable! ⇒ Object (protected)
Infers the default executable of the project.
147 148 149 150 151 152 153 |
# 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! ⇒ Object (protected)
Infers documentation of the project.
160 161 162 163 164 165 166 |
# File 'lib/ore/inferences.rb', line 160 def infer_documentation! if file?('.yardopts') @documentation = :yard else @documentation = :rdoc end end |
#infer_executables! ⇒ Object (protected)
Infers the executables of the project.
136 137 138 139 140 |
# 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! ⇒ Object (protected)
Infers the extra documentation files of the project.
173 174 175 176 177 178 179 |
# 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! ⇒ Object (protected)
Infers the files of the project.
186 187 188 189 190 |
# 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! ⇒ Object (protected)
Infers the project name using the directory name of the project.
91 92 93 |
# File 'lib/ore/inferences.rb', line 91 def infer_name! @name = @root.basename.to_s end |
#infer_namespace! ⇒ Object (protected)
Infers the namespace of the project based on the project name.
73 74 75 76 77 78 79 80 81 82 83 84 |
# 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! ⇒ Object (protected)
Infers the project files.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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! ⇒ Object (protected)
Infers the require-paths of the project.
125 126 127 128 129 |
# 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! ⇒ Object (protected)
Infers the required version of RubyGems to >= 1.3.6
, if the
project uses Bundler.
209 210 211 212 213 |
# File 'lib/ore/inferences.rb', line 209 def infer_required_rubygems_version! if bundler? @required_rubygems_version = '>= 1.3.6' end end |
#infer_scm! ⇒ Object (protected)
Infers the Source Code Management used by the project.
38 39 40 41 42 43 44 |
# 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! ⇒ Object (protected)
Infers the test-files of the project.
197 198 199 200 201 |
# 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! ⇒ Object (protected)
Finds and sets the version of the project.
100 101 102 103 104 105 106 107 108 109 |
# 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 |