Module: Ore::Settings

Included in:
Project
Defined in:
lib/ore/settings.rb

Overview

A mixin for Project which provides methods for normalizing and setting project attributes.

Instance Method Summary collapse

Instance Method Details

#set_authors!(authors) ⇒ Object (protected)

Sets the authors of the project.

Parameters:

  • authors (Array<String>, String)

    The authors listed in the metadata file.



58
59
60
61
62
63
64
# File 'lib/ore/settings.rb', line 58

def set_authors!(authors)
  if authors.kind_of?(Array)
    @authors += authors
  else
    @authors << authors
  end
end

#set_date!(date) ⇒ Object (protected)

Sets the release date of the project.

Parameters:

  • date (String)

    The release date from the metadata file.



72
73
74
# File 'lib/ore/settings.rb', line 72

def set_date!(date)
  @date = Date.parse(date)
end

#set_default_executable!(name) ⇒ Object (protected)

Sets the default executable of the project.

Parameters:

  • name (String)

    The default executable name listed in the metadata file.



111
112
113
114
115
116
117
# File 'lib/ore/settings.rb', line 111

def set_default_executable!(name)
  if @executables.include?(name)
    @default_executable = name
  else
    warn "#{name} is not in the executables list"
  end
end

#set_dependencies!(dependencies) ⇒ Object (protected)

Sets the dependencies of the project.

Parameters:

  • dependencies (Hash{String => String})

    The dependency names and versions listed in the metadata file.

Raises:



218
219
220
221
222
223
224
225
226
# File 'lib/ore/settings.rb', line 218

def set_dependencies!(dependencies)
  unless dependencies.kind_of?(Hash)
    raise(,"dependencies must be a Hash")
  end

  dependencies.each do |name,versions|
    @dependencies << Dependency.parse_versions(name,versions)
  end
end

#set_development_dependencies!(dependencies) ⇒ Object (protected)

Sets the development-dependencies of the project.

Parameters:

  • dependencies (Hash{String => String})

    The development-dependency names and versions listed in the metadata file.

Raises:



258
259
260
261
262
263
264
265
266
# File 'lib/ore/settings.rb', line 258

def set_development_dependencies!(dependencies)
  unless dependencies.kind_of?(Hash)
    raise(,"development_dependencies must be a Hash")
  end

  dependencies.each do |name,versions|
    @development_dependencies << Dependency.parse_versions(name,versions)
  end
end

#set_executables!(paths) ⇒ Object (protected)

Sets the executables of the project.

Parameters:

  • The (Array<String>, String)

    executable names or the glob-pattern listed in the metadata file.



97
98
99
100
101
102
103
# File 'lib/ore/settings.rb', line 97

def set_executables!(paths)
  if paths.kind_of?(Array)
    paths.each { |path| add_executable(path) }
  else
    glob(paths) { |path| add_executable(path) }
  end
end

#set_extra_doc_files!(paths) ⇒ Object (protected)

Sets the extra documentation files of the project.

Parameters:

  • paths (Array<String>, String)

    The file paths or the glob-pattern listed in the metadata file.



125
126
127
128
129
130
131
# File 'lib/ore/settings.rb', line 125

def set_extra_doc_files!(paths)
  if paths.kind_of?(Array)
    paths.each { |path| add_extra_doc_file(path) }
  else
    glob(paths) { |path| add_extra_doc_file(path) }
  end
end

#set_files!(paths) ⇒ Object (protected)

Sets the files of the project.

Parameters:

  • paths (Array<String>, String)

    The files or the glob-pattern listed in the metadata file.



139
140
141
142
143
144
145
# File 'lib/ore/settings.rb', line 139

def set_files!(paths)
  if paths.kind_of?(Array)
    paths.each { |path| add_file(path) }
  else
    glob(paths) { |path| add_file(path) }
  end
end

#set_license!(license) ⇒ Object (protected)

Sets the license(s) of the project.

Parameters:

  • license (Array, String)

    The license(s) of the project.



44
45
46
47
48
49
50
# File 'lib/ore/settings.rb', line 44

def set_license!(license)
  if license.kind_of?(Array)
    @licenses += license
  else
    @licenses << license
  end
end

#set_post_install_message!(message) ⇒ Object (protected)

Sets the post-installation message.

Parameters:

  • message (String)

    The post-install message.

Since:

  • 0.1.0



169
170
171
# File 'lib/ore/settings.rb', line 169

def set_post_install_message!(message)
  @post_install_message = message
end

#set_require_paths!(paths) ⇒ Object (protected)

Sets the require-paths of the project.

Parameters:

  • paths (Array<String>, String)

    The require-paths or the glob-pattern listed in the metadata file.



82
83
84
85
86
87
88
# File 'lib/ore/settings.rb', line 82

def set_require_paths!(paths)
  if paths.kind_of?(Array)
    paths.each { |path| add_require_path(path) }
  else
    glob(paths) { |path| add_require_path(path) }
  end
end

#set_required_ruby_version!(version) ⇒ Object (protected)

Sets the Ruby version required by the project.

Parameters:

  • version (String)

    The version requirement.



195
196
197
# File 'lib/ore/settings.rb', line 195

def set_required_ruby_version!(version)
  @required_ruby_version = version.to_s
end

#set_required_rubygems_version!(version) ⇒ Object (protected)

Sets the RubyGems version required by the project.

Parameters:

  • version (String)

    The version requirement.



205
206
207
# File 'lib/ore/settings.rb', line 205

def set_required_rubygems_version!(version)
  @required_rubygems_version = version.to_s
end

#set_requirements!(requirements) ⇒ Object (protected)

Sets the external requirements of the project.

Parameters:

  • requirements (Array, String)

    The external requirements.

Since:

  • 0.2.0



181
182
183
184
185
186
187
# File 'lib/ore/settings.rb', line 181

def set_requirements!(requirements)
  if requirements.kind_of?(Array)
    @requirements += requirements
  else
    @requirements << requirements
  end
end

#set_runtime_dependencies!(dependencies) ⇒ Object (protected)

Sets the runtime-dependencies of the project.

Parameters:

  • dependencies (Hash{String => String})

    The runtime-dependency names and versions listed in the metadata file.

Raises:



238
239
240
241
242
243
244
245
246
# File 'lib/ore/settings.rb', line 238

def set_runtime_dependencies!(dependencies)
  unless dependencies.kind_of?(Hash)
    raise(,"runtime_dependencies must be a Hash")
  end

  dependencies.each do |name,versions|
    @runtime_dependencies << Dependency.parse_versions(name,versions)
  end
end

#set_test_files!(paths) ⇒ Object (protected)

Sets the test-files of the project.

Parameters:

  • paths (Array<String>, String)

    The test-files of the glob-pattern listed in the metadata file.



153
154
155
156
157
158
159
# File 'lib/ore/settings.rb', line 153

def set_test_files!(paths)
  if paths.kind_of?(Array)
    paths.each { |path| add_test_file(path) }
  else
    glob(paths) { |path| add_test_file(path) }
  end
end

#set_version!(version) ⇒ Object (protected)

Sets the version of the project.

Parameters:

  • version (Hash<Integer>, String)

    The version from the metadata file.

Raises:

  • (InvalidVersion)

    The version must either be a String or a Hash.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ore/settings.rb', line 22

def set_version!(version)
  case version
  when Hash
    major = version['major']
    minor = version['minor']
    patch = version['patch']
    build = version['build']

    @version = Versions::Version.new(major,minor,patch,build)
  when String
    @version = Versions::Version.parse(version.to_s)
  else
    raise(,"version must be a Hash or a String")
  end
end