Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated the pure gemspec using Ore 0.9.x.

  • Loading branch information...
commit 6691d11249b9aa8f73a0b468080fbf4375012e12 1 parent 3458b9a
@postmodern authored
Showing with 38 additions and 105 deletions.
  1. +38 −105 dm-visualizer.gemspec
View
143 dm-visualizer.gemspec
@@ -2,126 +2,59 @@
require 'yaml'
-Gem::Specification.new do |gemspec|
- files = if File.directory?('.git')
- `git ls-files`.split($/)
- elsif File.directory?('.hg')
- `hg manifest`.split($/)
- elsif File.directory?('.svn')
- `svn ls -R`.split($/).select { |path| File.file?(path) }
- else
- Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
- end
+Gem::Specification.new do |gem|
+ gemspec = YAML.load_file('gemspec.yml')
- filter_files = lambda { |paths|
- case paths
- when Array
- (files & paths)
- when String
- (files & Dir[paths])
- end
- }
-
- version = {
- :file => 'lib/dm-visualizer/version.rb',
- :constant => 'DataMapper::Visualizer::VERSION'
- }
-
- defaults = {
- 'name' => File.basename(File.dirname(__FILE__)),
- 'files' => files,
- 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
- 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
- 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
- }
-
- metadata = defaults.merge(YAML.load_file('gemspec.yml'))
-
- gemspec.name = metadata.fetch('name',defaults[:name])
- gemspec.version = if metadata['version']
- metadata['version']
- elsif File.file?(version[:file])
- require File.join('.',version[:file])
- eval(version[:constant])
- end
-
- gemspec.summary = metadata.fetch('summary',metadata['description'])
- gemspec.description = metadata.fetch('description',metadata['summary'])
-
- case metadata['license']
- when Array
- gemspec.licenses = metadata['license']
- when String
- gemspec.license = metadata['license']
- end
-
- case metadata['authors']
- when Array
- gemspec.authors = metadata['authors']
- when String
- gemspec.author = metadata['authors']
- end
+ gem.name = gemspec.fetch('name')
+ gem.version = gemspec.fetch('version') do
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
- gemspec.email = metadata['email']
- gemspec.homepage = metadata['homepage']
+ require 'dm/visualizer/version'
+ DataMapper::Visualizer::VERSION
+ end
- case metadata['require_paths']
- when Array
- gemspec.require_paths = metadata['require_paths']
- when String
- gemspec.require_path = metadata['require_paths']
- end
+ gem.summary = gemspec['summary']
+ gem.description = gemspec['description']
+ gem.licenses = Array(gemspec['license'])
+ gem.authors = Array(gemspec['authors'])
+ gem.email = gemspec['email']
+ gem.homepage = gemspec['homepage']
- gemspec.files = filter_files[metadata['files']]
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
- gemspec.executables = metadata['executables']
- gemspec.extensions = metadata['extensions']
+ gem.files = `git ls-files`.split($/)
+ gem.files = glob[gemspec['files']] if gemspec['files']
- if Gem::VERSION < '1.7.'
- gemspec.default_executable = gemspec.executables.first
+ gem.executables = gemspec.fetch('executables') do
+ glob['bin/*'].map { |path| File.basename(path) }
end
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
- gemspec.test_files = filter_files[metadata['test_files']]
-
- unless gemspec.files.include?('.document')
- gemspec.extra_rdoc_files = metadata['extra_doc_files']
- end
-
- 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
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
- if gemspec.respond_to?(:required_rubygems_version=)
- gemspec.required_rubygems_version = metadata['required_ruby_version']
- end
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
+ %w[ext lib].select { |dir| File.directory?(dir) }
+ })
- parse_versions = lambda { |versions|
- case versions
- when Array
- versions.map { |v| v.to_s }
- when String
- versions.split(/,\s*/)
- end
- }
+ gem.requirements = gemspec['requirements']
+ gem.required_ruby_version = gemspec['required_ruby_version']
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
+ gem.post_install_message = gemspec['post_install_message']
- if metadata['dependencies']
- metadata['dependencies'].each do |name,versions|
- gemspec.add_dependency(name,parse_versions[versions])
- end
- end
+ split = lambda { |string| string.split(/,\s*/) }
- if metadata['runtime_dependencies']
- metadata['runtime_dependencies'].each do |name,versions|
- gemspec.add_runtime_dependency(name,parse_versions[versions])
+ if gemspec['dependencies']
+ gemspec['dependencies'].each do |name,versions|
+ gem.add_dependency(name,split[versions])
end
end
- if metadata['development_dependencies']
- metadata['development_dependencies'].each do |name,versions|
- gemspec.add_development_dependency(name,parse_versions[versions])
+ if gemspec['development_dependencies']
+ gemspec['development_dependencies'].each do |name,versions|
+ gem.add_development_dependency(name,split[versions])
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.