Permalink
Browse files

Switched to using gemspec.yml and rubygems-tasks ~> 0.1.

  • Loading branch information...
1 parent d1259c5 commit 29abcaca07afab300c87ec2075072aa8d788e93a @postmodern postmodern committed Apr 25, 2012
Showing with 159 additions and 116 deletions.
  1. +0 −25 Gemfile
  2. +27 −90 Rakefile
  3. +0 −1 VERSION
  4. +109 −0 ffi-pcap.gemspec
  5. +23 −0 gemspec.yml
View
25 Gemfile
@@ -1,25 +0,0 @@
-source 'http://rubygems.org'
-
-group :runtime do
- gem 'ffi', '~> 0.5.0'
- gem 'ffi_dry', '~> 0.1.9'
-end
-
-group :development do
- gem 'bundler', '~> 0.9.25'
- gem 'rake', '~> 0.8.7'
- gem 'jeweler', '~> 1.4.0', :git => 'git://github.com/technicalpickles/jeweler.git'
-end
-
-group :doc do
- case RUBY_PLATFORM
- when 'java'
- gem 'maruku', '~> 0.6.0'
- else
- gem 'rdiscount', '~> 1.6.3'
- end
-
- gem 'yard', '~> 0.5.3'
-end
-
-gem 'rspec', '~> 1.3.0', :group => [:development, :test]
View
117 Rakefile
@@ -1,99 +1,36 @@
+require 'rubygems'
+require 'rake'
-rubyforge_project = 'ffi-pcap'
-name = "ffi-pcap"
-summary = "FFI bindings for libpcap"
-email = "postmodern.mod3@gmail.com"
-homepage = "http://github.com/sophsec/ffi-pcap"
-description = "Bindings to libpcap via FFI interface in Ruby."
-authors = ["Postmodern", "Dakrone", "Eric Monti"]
+begin
+ gem 'rubygems-tasks', '~> 0.1'
+ require 'rubygems/tasks'
-### touch '.justrake' in the toplevel directory
-### to use a pared down project rakefile
-### with fewer development dependencies
-unless File.exists?('.justrake')
-
- require 'rubygems'
- require 'bundler'
-
- begin
- Bundler.setup(:development, :doc)
- rescue Bundler::BundlerError => e
- STDERR.puts e.message
- STDERR.puts "Run `bundle install` to install missing gems"
- exit e.status_code
- end
-
- require 'rake'
- require 'rake/clean'
- require 'jeweler'
-
- Jeweler::Tasks.new do |gem|
- gem.rubyforge_project = rubyforge_project
- gem.name = name
- gem.summary = summary
- gem.email = email
- gem.homepage = homepage
- gem.description = description
- gem.authors = authors
- gem.requirements = ['libpcap or winpcap (if on Windows)']
- gem.has_rdoc = 'yard'
- end
-
- require 'spec/rake/spectask'
-
- desc "Run all specifications"
- Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs += ['lib', 'spec']
- spec.spec_opts = ['--options', '.specopts']
- end
+ Gem::Tasks.new
+rescue LoadError => e
+ warn e.message
+ warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
+end
- task :default => :spec
+begin
+ gem 'rspec', '~> 2.0'
+ require 'rspec/core/rake_task'
- require 'spec/rake/spectask'
- Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
+ RSpec::Core::RakeTask.new
+rescue LoadError => e
+ task :spec do
+ abort "Please run `gem install rspec` to install RSpec."
end
+end
+task :test => :spec
+task :default => :spec
+begin
+ gem 'yard', '~> 0.7'
require 'yard'
- YARD::Rake::YardocTask.new
-
- task :docs => :yard
-
-else
- STDERR.puts "!! Using pared down Rake setup.",
- "!! For bundler/jeweler, rm the .justrake file at root"
-
- load 'tasks/setup.rb'
-
- ensure_in_path 'lib'
-
- task :default => 'spec:run'
-
- PROJ.name = rubyforge_project
- PROJ.authors = authors
- PROJ.email = email
- PROJ.summary = summary
- PROJ.description = description
- PROJ.url = homepage
-
- PROJ.version = File.open("VERSION","r"){|f| f.readline.chomp}
- PROJ.readme_file = 'README.md'
- PROJ.history_file = 'ChangeLog.md'
-
- PROJ.spec.opts += File.read(".specopts").split("\n")
-
- # exclude rcov.rb and external libs from rcov report
- PROJ.rcov.opts += [
- "--exclude", "rcov",
- "--exclude", "ffi",
- "--exclude", "ffi_dry",
- ]
-
- depend_on 'ffi', '>= 0.5.0'
- depend_on 'ffi_dry', '>= 0.1.9'
+ YARD::Rake::YardocTask.new
+rescue LoadError => e
+ task :yard do
+ abort "Please run `gem install yard` to install YARD."
+ end
end
-
-
View
1 VERSION
@@ -1 +0,0 @@
-0.2.1
View
109 ffi-pcap.gemspec
@@ -0,0 +1,109 @@
+# 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/pcap/version.rb',
+ :constant => 'FFI::PCap::VERSION'
+ }
+
+ defaults = {
+ 'name' => File.basename(File.dirname(__FILE__)),
+ '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}'],
+ '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.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
View
23 gemspec.yml
@@ -0,0 +1,23 @@
+name: ffi-pcap
+version: 0.2.1
+summary: FFI bindings for libpcap
+description: Bindings to libpcap via FFI interface in Ruby.
+license: MIT
+authors:
+ - Postmodern
+ - Dakrone
+ - Eric Monti
+email: postmodern.mod3@gmail.com
+homepage: http://github.com/sophsec/ffi-pcap
+has_yard: true
+
+requirements: libpcap
+
+dependencies:
+ ffi: ~> 1.0
+ ffi_dry: ~> 0.1.12
+
+development_dependencies:
+ rubygems-tasks: ~> 0.1
+ rspec: ~> 2.0
+ yard: ~> 0.7

0 comments on commit 29abcac

Please sign in to comment.