Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use the new pure-Ruby gemspec from Ore 0.8.0.

  • Loading branch information...
commit aef3685033906f2da2f2469b30221cccd1c1ddd4 1 parent 9812edc
Postmodern authored June 18, 2011

Showing 1 changed file with 125 additions and 13 deletions. Show diff stats Hide diff stats

  1. 138  ffi-libc.gemspec
138  ffi-libc.gemspec
... ...
@@ -1,15 +1,127 @@
1  
-# -*- encoding: utf-8 -*-
2  
-
3  
-begin
4  
-  Ore::Specification.new do |gemspec|
5  
-    # custom logic here
6  
-  end
7  
-rescue NameError
8  
-  begin
9  
-    require 'ore/specification'
10  
-    retry
11  
-  rescue LoadError
12  
-    STDERR.puts "The 'ffi-libc.gemspec' file requires Ore."
13  
-    STDERR.puts "Run `gem install ore-core` to install Ore."
  1
+# encoding: utf-8
  2
+
  3
+require 'yaml'
  4
+
  5
+Gem::Specification.new do |gemspec|
  6
+  files = if File.directory?('.git')
  7
+            `git ls-files`.split($/)
  8
+          elsif File.directory?('.hg')
  9
+            `hg manifest`.split($/)
  10
+          elsif File.directory?('.svn')
  11
+            `svn ls -R`.split($/).select { |path| File.file?(path) }
  12
+          else
  13
+            Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
  14
+          end
  15
+
  16
+  filter_files = lambda { |paths|
  17
+    case paths
  18
+    when Array
  19
+      (files & paths)
  20
+    when String
  21
+      (files & Dir[paths])
  22
+    end
  23
+  }
  24
+
  25
+  version = {
  26
+    :file => 'lib/ffi/libc/version.rb',
  27
+    :constant => 'FFI::LibC::VERSION'
  28
+  }
  29
+
  30
+  defaults = {
  31
+    'name' => File.basename(File.dirname(__FILE__)),
  32
+    'files' => files,
  33
+    'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
  34
+    'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
  35
+    'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
  36
+  }
  37
+
  38
+  metadata = defaults.merge(YAML.load_file('gemspec.yml'))
  39
+
  40
+  gemspec.name = metadata.fetch('name',defaults[:name])
  41
+  gemspec.version = if metadata['version']
  42
+                      metadata['version']
  43
+                    elsif File.file?(version[:file])
  44
+                      require File.join('.',version[:file])
  45
+                      eval(version[:constant])
  46
+                    end
  47
+
  48
+  gemspec.summary = metadata.fetch('summary',metadata['description'])
  49
+  gemspec.description = metadata.fetch('description',metadata['summary'])
  50
+
  51
+  case metadata['license']
  52
+  when Array
  53
+    gemspec.licenses = metadata['license']
  54
+  when String
  55
+    gemspec.license = metadata['license']
  56
+  end
  57
+
  58
+  case metadata['authors']
  59
+  when Array
  60
+    gemspec.authors = metadata['authors']
  61
+  when String
  62
+    gemspec.author = metadata['authors']
  63
+  end
  64
+
  65
+  gemspec.email = metadata['email']
  66
+  gemspec.homepage = metadata['homepage']
  67
+
  68
+  case metadata['require_paths']
  69
+  when Array
  70
+    gemspec.require_paths = metadata['require_paths']
  71
+  when String
  72
+    gemspec.require_path = metadata['require_paths']
  73
+  end
  74
+
  75
+  gemspec.files = filter_files[metadata['files']]
  76
+
  77
+  gemspec.executables = metadata['executables']
  78
+  gemspec.extensions = metadata['extensions']
  79
+
  80
+  if Gem::VERSION < '1.7.'
  81
+    gemspec.default_executable = gemspec.executables.first
  82
+  end
  83
+
  84
+  gemspec.test_files = filter_files[metadata['test_files']]
  85
+
  86
+  unless gemspec.files.include?('.document')
  87
+    gemspec.extra_rdoc_files = metadata['extra_doc_files']
  88
+  end
  89
+
  90
+  gemspec.post_install_message = metadata['post_install_message']
  91
+  gemspec.requirements = metadata['requirements']
  92
+
  93
+  if gemspec.respond_to?(:required_ruby_version=)
  94
+    gemspec.required_ruby_version = metadata['required_ruby_version']
  95
+  end
  96
+
  97
+  if gemspec.respond_to?(:required_rubygems_version=)
  98
+    gemspec.required_rubygems_version = metadata['required_ruby_version']
  99
+  end
  100
+
  101
+  parse_versions = lambda { |versions|
  102
+    case versions
  103
+    when Array
  104
+      versions.map { |v| v.to_s }
  105
+    when String
  106
+      versions.split(/,\s*/)
  107
+    end
  108
+  }
  109
+
  110
+  if metadata['dependencies']
  111
+    metadata['dependencies'].each do |name,versions|
  112
+      gemspec.add_dependency(name,parse_versions[versions])  
  113
+    end
  114
+  end
  115
+
  116
+  if metadata['runtime_dependencies']
  117
+    metadata['runtime_dependencies'].each do |name,versions|
  118
+      gemspec.add_runtime_dependency(name,parse_versions[versions])  
  119
+    end
  120
+  end
  121
+
  122
+  if metadata['development_dependencies']
  123
+    metadata['development_dependencies'].each do |name,versions|
  124
+      gemspec.add_development_dependency(name,parse_versions[versions])  
  125
+    end
14 126
   end
15 127
 end

0 notes on commit aef3685

Please sign in to comment.
Something went wrong with that request. Please try again.