method
validate
![Some documentation Importance_1](https://d2vfyqvduarcvs.cloudfront.net/images/importance_1.png?1349367920)
v1_9_3_125 -
Show latest stable
-
0 notes -
Class: Specification
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
Related methods
- Class methods (48)
-
add_spec
-
add_specs
-
all
-
_all
-
all=
-
all_names
-
array_attributes
-
attribute_names
-
_clear_load_cache (>= v2_1_10)
-
default_stubs
(>= v2_4_6)
-
dirs
-
dirs=
-
each
-
each_gemspec (>= v2_1_10)
-
each_spec (>= v2_1_10)
-
each_stub (>= v2_1_10)
-
find_active_stub_by_path (>= v2_4_6)
-
find_all_by_full_name (>= v2_5_5)
-
find_all_by_name
-
find_by_name
-
find_by_path
-
find_inactive_by_path (>= v2_1_10)
-
find_in_unresolved
-
find_in_unresolved_tree
-
from_yaml
-
gemspec_stubs_in
(>= v2_4_6)
-
installed_stubs
(>= v2_4_6)
-
_latest_specs (>= v2_4_6)
-
latest_specs
-
load
-
_load
-
load_defaults (>= v2_1_10)
-
map_stubs
(>= v2_4_6)
-
new
-
non_nil_attributes
-
normalize_yaml_input
-
outdated
-
outdated_and_latest_version (>= v2_1_10)
-
remove_spec
-
required_attribute?
-
required_attributes
-
reset
-
_resort!
-
sort_by!
(>= v2_4_6)
-
stubs (>= v2_1_10)
-
stubs_for (>= v2_4_6)
-
uniq_by
(>= v2_4_6)
-
unresolved_deps (>= v2_1_10)
- Instance methods (150)
-
<=>
-
==
-
abbreviate (>= v2_4_6)
-
activate
-
activate_dependencies
-
add_bindir
-
add_dependency
-
add_dependency_with_type
-
add_development_dependency
-
add_runtime_dependency
-
add_self_to_load_path
-
author
-
author=
-
authors
-
authors=
-
base_dir
-
bin_dir
-
bin_file
-
build_args (>= v2_1_10)
-
build_extensions (>= v2_1_10)
-
build_info_dir (>= v2_1_10)
-
build_info_file (>= v2_1_10)
-
bundled_gem_in_old_ruby? (>= v2_2_9)
-
cache_dir
-
cache_file
-
cache_gem
-
check_version_conflict
(>= v2_2_9)
-
conficts_when_loaded_with? (>= v2_4_6)
-
conflicts
-
contains_requirable_file?
-
date
-
date=
-
default_executable
-
default_value
-
dependencies
-
dependencies_to_gemfile
(>= v2_6_3)
-
dependent_gems
-
dependent_specs
-
description=
-
development_dependencies
-
doc_dir
-
_dump
-
encode_with
-
eql?
-
executable
-
executable=
-
executables
-
executables=
-
extension_dir (>= v2_6_3)
-
extensions
-
extensions=
-
extra_rdoc_files
-
extra_rdoc_files=
-
file_name
-
files
-
files=
-
find_all_satisfiers
-
find_full_gem_path
(>= v2_1_10)
-
for_cache
-
full_gem_path
-
full_name
-
gem_build_complete_path (>= v2_1_10)
-
gem_dir
-
gems_dir
-
git_version (>= v2_6_3)
-
groups (>= v2_6_3)
-
has_conflicts? (>= v2_4_6)
-
hash
-
has_rdoc
-
has_rdoc=
-
has_rdoc?
-
has_unit_tests?
-
initialize_copy
-
init_with
-
inspect (>= v2_1_10)
-
installation_path
-
installed_by_version (>= v2_1_10)
-
installed_by_version= (>= v2_1_10)
-
internal_init (>= v2_4_6)
-
invalidate_memoized_attributes
(>= v2_1_10)
-
keep_only_files_and_directo... (>= v2_6_3)
-
lib_dirs_glob
-
lib_files
-
license
-
license=
-
licenses
-
licenses=
-
loaded_from (>= v2_6_3)
-
loaded_from=
-
load_paths (>= v2_6_3)
-
mark_version
-
matches_for_glob
-
method_missing
-
missing_extensions? (>= v2_2_9)
-
name_tuple (>= v2_1_10)
-
nondevelopment_dependencies (>= v2_6_3)
-
normalize
-
original_name
-
original_platform
-
platform
-
platform=
-
pretty_print
-
raise_if_conflicts
-
raw_require_paths (>= v2_4_6)
-
rdoc_options
-
rdoc_options=
-
required_rubygems_version=
-
required_ruby_version=
-
requirements
-
requirements=
-
require_path
-
require_path=
-
require_paths= (>= v2_2_9)
-
reset_nil_attributes_to_def... (>= v2_1_10)
-
respond_to_missing? (>= v2_1_10)
-
rg_loaded_from (>= v2_6_3)
-
ri_dir
-
ruby_code
-
runtime_dependencies
-
same_attributes?
-
sanitize (>= v2_4_6)
-
sanitize_string (>= v2_4_6)
-
satisfies_requirement?
-
sort_obj
-
source (>= v2_1_10)
-
spec_dir
-
spec_file
-
spec_name
-
stubbed? (>= v2_1_10)
-
summary=
-
test_file
-
test_file=
-
test_files
-
test_files=
-
test_suite_file
-
test_suite_file=
-
to_gemfile (>= v2_6_3)
-
to_ruby
-
to_ruby_for_cache
-
to_s
-
to_spec (>= v2_1_10)
-
to_yaml
-
traverse
-
validate
-
validate_dependencies (>= v2_1_10)
-
validate_metadata (>= v2_5_5)
-
validate_permissions (>= v2_1_10)
-
version=
-
warning (>= v2_1_10)
-
yaml_initialize
= private
= protected
validate(packaging = true)
public
Checks that the specification contains all required fields, and does a very basic sanity check.
Raises InvalidSpecificationException if the spec does not pass the checks..
Show source
# File lib/rubygems/specification.rb, line 1947 def validate packaging = true require 'rubygems/user_interaction' extend Gem::UserInteraction normalize nil_attributes = self.class.non_nil_attributes.find_all do |name| instance_variable_get("@#{name}").nil? end unless nil_attributes.empty? then raise Gem::InvalidSpecificationException, "#{nil_attributes.join ', '} must not be nil" end if packaging and rubygems_version != Gem::VERSION then raise Gem::InvalidSpecificationException, "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}" end @@required_attributes.each do |symbol| unless self.send symbol then raise Gem::InvalidSpecificationException, "missing value for attribute #{symbol}" end end unless String === name then raise Gem::InvalidSpecificationException, "invalid value for attribute name: \"#{name.inspect}\"" end if require_paths.empty? then raise Gem::InvalidSpecificationException, 'specification must have at least one require_path' end @files.delete_if { |x| File.directory?(x) } @test_files.delete_if { |x| File.directory?(x) } @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) } @extra_rdoc_files.delete_if { |x| File.directory?(x) } @extensions.delete_if { |x| File.directory?(x) } non_files = files.reject { |x| File.file?(x) } unless not packaging or non_files.empty? then raise Gem::InvalidSpecificationException, "[\"#{non_files.join "\", \""}\"] are not files" end unless specification_version.is_a?(Fixnum) raise Gem::InvalidSpecificationException, 'specification_version must be a Fixnum (did you mean version?)' end case platform when Gem::Platform, Gem::Platform::RUBY then # ok else raise Gem::InvalidSpecificationException, "invalid platform #{platform.inspect}, see Gem::Platform" end self.class.array_attributes.each do |field| val = self.send field klass = case field when :dependencies Gem::Dependency else String end unless Array === val and val.all? { |x| x.kind_of?(klass) } then raise(Gem::InvalidSpecificationException, "#{field} must be an Array of #{klass}") end end [:authors].each do |field| val = self.send field raise Gem::InvalidSpecificationException, "#{field} may not be empty" if val.empty? end licenses.each { |license| if license.length > 64 raise Gem::InvalidSpecificationException, "each license must be 64 characters or less" end } # reject lazy developers: lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '') unless authors.grep(/FI XME|TO DO/).empty? then raise Gem::InvalidSpecificationException, "#{lazy} is not an author" end unless Array(email).grep(/FI XME|TO DO/).empty? then raise Gem::InvalidSpecificationException, "#{lazy} is not an email" end if description =~ /FI XME|TO DO/ then raise Gem::InvalidSpecificationException, "#{lazy} is not a description" end if summary =~ /FI XME|TO DO/ then raise Gem::InvalidSpecificationException, "#{lazy} is not a summary" end if homepage and not homepage.empty? and homepage !~ /\A[a-z][a-z\d+.-]*:/ then raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a URI" end # Warnings ]author description email homepage summary].each do |attribute| value = self.send attribute alert_warning "no #{attribute} specified" if value.nil? or value.empty? end if description == summary then alert_warning 'description and summary are identical' end # TODO: raise at some given date alert_warning "deprecated autorequire specified" if autorequire executables.each do |executable| executable_path = File.join(bindir, executable) shebang = File.read(executable_path, 2) == '#!' alert_warning "#{executable_path} is missing #! line" unless shebang end true end