-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffi-tre.gemspec
127 lines (103 loc) · 3.48 KB
/
ffi-tre.gemspec
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# encoding: utf-8
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
filter_files = lambda { |paths|
case paths
when Array
(files & paths)
when String
(files & Dir[paths])
end
}
version = {
:file => 'lib/ffi/tre/version.rb',
:constant => 'FFI::TRE::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
gemspec.email = metadata['email']
gemspec.homepage = metadata['homepage']
case metadata['require_paths']
when Array
gemspec.require_paths = metadata['require_paths']
when String
gemspec.require_path = metadata['require_paths']
end
gemspec.files = filter_files[metadata['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']]
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
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