Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 106 lines (84 sloc) 3.272 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
# encoding: utf-8

require 'yaml'

Gem::Specification.new do |gemspec|
  root = File.dirname(__FILE__)
  lib_dir = File.join(root,'lib')
  files = `git ls-files`.split($/)

  filter_files = lambda { |paths|
    files & case paths
            when Array
              paths
            when String
              Dir[paths]
            end
  }

  version = {
    :file => 'data_paths/version',
    :constant => 'DataPaths::VERSION'
  }

  defaults = {
    'name' => File.basename(root),
    'files' => files,
    'require_paths' => ['ext', 'lib'].select { |dir| File.directory?(dir) },
    'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
    'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
    'doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
    'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}']
  }

  metadata = defaults.merge(YAML.load_file('gemspec.yml'))

  gemspec.name = metadata['name']
  gemspec.version = if metadata['version']
                      metadata['version']
                    else
                      $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)

                      require version[:file]
                      eval(version[:constant])
                    end

  gemspec.summary = metadata.fetch('summary',metadata['description'])
  gemspec.description = metadata.fetch('description',metadata['summary'])

  gemspec.licenses = Array(metadata['license'])
  gemspec.authors = Array(metadata['authors'])

  gemspec.email = metadata['email']
  gemspec.homepage = metadata['homepage']

  gemspec.require_paths = Array(metadata['require_paths'])
  gemspec.files = filter_files[metadata['files']]
  gemspec.files += Array(metadata['generated_files'])
  gemspec.executables = metadata['executables']
  gemspec.extensions = metadata['extensions']

  if Gem::VERSION < '1.7.'
    gemspec.default_executable = gemspec.executables.first
  end

  gemspec.test_files = filter_files[metadata['test_files']]
  gemspec.extra_rdoc_files = Array(metadata['extra_doc_files'])

  gemspec.post_install_message = metadata['post_install_message']
  gemspec.requirements = metadata['requirements']

  if gemspec.respond_to?(:required_ruby_version=)
    gemspec.required_ruby_version = metadata['required_ruby_version']
  end

  if gemspec.respond_to?(:required_rubygems_version=)
    gemspec.required_rubygems_version = metadata['required_ruby_version']
  end

  parse_versions = lambda { |versions|
    case versions
    when Array
      versions.map { |v| v.to_s }
    when String
      versions.split(/,\s*/)
    end
  }

  if metadata['dependencies']
    metadata['dependencies'].each do |name,versions|
      gemspec.add_dependency(name,parse_versions[versions])
    end
  end

  if metadata['runtime_dependencies']
    metadata['runtime_dependencies'].each do |name,versions|
      gemspec.add_runtime_dependency(name,parse_versions[versions])
    end
  end

  if metadata['development_dependencies']
    metadata['development_dependencies'].each do |name,versions|
      gemspec.add_development_dependency(name,parse_versions[versions])
    end
  end
end
Something went wrong with that request. Please try again.