Method: LibGems::Specification#validate
- Defined in:
- lib/libgems/specification.rb
#validate ⇒ Object
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..
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
# File 'lib/libgems/specification.rb', line 819 def validate extend LibGems::UserInteraction normalize # TODO: Fix the versioning here if rubygems_version != LibGems::VERSION then raise LibGems::InvalidSpecificationException, "expected RubyGems version #{LibGems::VERSION}, was #{rubygems_version}" end @@required_attributes.each do |symbol| unless self.send symbol then raise LibGems::InvalidSpecificationException, "missing value for attribute #{symbol}" end end unless String === name then raise LibGems::InvalidSpecificationException, "invalid value for attribute name: \"#{name.inspect}\"" end if require_paths.empty? then raise LibGems::InvalidSpecificationException, 'specification must have at least one require_path' end @files.delete_if do |file| File.directory? file end @test_files.delete_if do |file| File.directory? file end @executables.delete_if do |file| File.directory? File.join(bindir, file) end @extra_rdoc_files.delete_if do |file| File.directory? file end @extensions.delete_if do |file| File.directory? file end non_files = files.select do |file| !File.file? file end unless non_files.empty? then non_files = non_files.map { |file| file.inspect } raise LibGems::InvalidSpecificationException, "[#{non_files.join ", "}] are not files" end unless specification_version.is_a?(Fixnum) raise LibGems::InvalidSpecificationException, 'specification_version must be a Fixnum (did you mean version?)' end case platform when LibGems::Platform, LibGems::Platform::RUBY then # ok else raise LibGems::InvalidSpecificationException, "invalid platform #{platform.inspect}, see LibGems::Platform" end unless Array === and .all? { || String === } then raise LibGems::InvalidSpecificationException, 'authors must be Array of Strings' end licenses.each { |license| if license.length > 64 raise LibGems::InvalidSpecificationException, "each license must be 64 characters or less" end } # reject FIXME and TODO unless .grep(/FIXME|TODO/).empty? then raise LibGems::InvalidSpecificationException, '"FIXME" or "TODO" is not an author' end unless Array(email).grep(/FIXME|TODO/).empty? then raise LibGems::InvalidSpecificationException, '"FIXME" or "TODO" is not an email address' end if description =~ /FIXME|TODO/ then raise LibGems::InvalidSpecificationException, '"FIXME" or "TODO" is not a description' end if summary =~ /FIXME|TODO/ then raise LibGems::InvalidSpecificationException, '"FIXME" or "TODO" is not a summary' end if homepage and not homepage.empty? and homepage !~ /\A[a-z][a-z\d+.-]*:/i then raise LibGems::InvalidSpecificationException, "\"#{homepage}\" is not a URI" end # Warnings %w[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 summary and not summary.empty? and description == summary then alert_warning 'description and summary are identical' end 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 |