Permalink
Browse files

Add a few more features.

  • Loading branch information...
1 parent 4ee2eb8 commit d89527dd8ac2a02cdd1d9467a936a56e6c80d1ec @trans trans committed Sep 3, 2011
Showing with 264 additions and 0 deletions.
  1. +152 −0 .gemspec
  2. +6 −0 .gitignore
  3. 0 .reap/quarry.reap
  4. +8 −0 HISTORY.rdoc
  5. +2 −0 MANIFEST
  6. +68 −0 Reapfile
  7. +5 −0 lib/renameme.rb
  8. +23 −0 ruby.yml
View
152 .gemspec
@@ -0,0 +1,152 @@
+# encoding: utf-8
+
+require 'yaml'
+
+Gem::Specification.new do |gemspec|
+
+ manifest = Dir.glob('manifest{,.txt}', File::FNM_CASEFOLD).first
+
+ scm = case
+ when File.directory?('.git')
+ :git
+ end
+
+ files = case
+ when manifest
+ File.readlines(manifest).
+ map{ |line| line.strip }.
+ reject{ |line| line.empty? || line[0,1] == '#' }
+ when scm == :git
+ `git ls-files -z`.split("\0")
+ else
+ Dir.glob('{**/}{.*,*}') # TODO: be more specific using standard locations ?
+ end.select{ |path| File.file?(path) }
+
+ patterns = {
+ :bin_files => 'bin/*',
+ :lib_files => 'lib/{**/}*.rb',
+ :ext_files => 'ext/{**/}extconf.rb',
+ :doc_files => '*.{txt,rdoc,md,markdown,tt,textile}',
+ :test_files => '{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'
+ }
+
+ glob_files = lambda { |pattern|
+ Dir.glob(pattern).select { |path|
+ File.file?(path) && files.include?(path)
+ }
+ }
+
+ #files = glob_files[patterns[:files]]
+
+ executables = glob_files[patterns[:bin_files]].map do |path|
+ File.basename(path)
+ end
+
+ extensions = glob_files[patterns[:ext_files]].map do |path|
+ File.basename(path)
+ end
+
+ metadata = YAML.load_file('.ruby')
+
+ # build-out the gemspec
+
+ case metadata['revision']
+ when 0
+ gemspec.name = metadata['name']
+ gemspec.version = metadata['version']
+ gemspec.summary = metadata['summary']
+ gemspec.description = metadata['description']
+
+ metadata['authors'].each do |author|
+ gemspec.authors << author['name']
+
+ if author.has_key?('email')
+ if gemspec.email
+ gemspec.email << author['email']
+ else
+ gemspec.email = [author['email']]
+ end
+ end
+ end
+
+ gemspec.licenses = metadata['licenses']
+
+ metadata['requirements'].each do |req|
+ name = req['name']
+ version = req['version']
+ groups = req['groups'] || []
+
+ if md = /^(.*?)([+-~])$/.match(version)
+ version = case md[2]
+ when '+' then ">= #{$1}"
+ when '-' then "< #{$1}"
+ when '~' then "~> #{$1}"
+ else version
+ end
+ end
+
+ #development = req['development']
+ #if development
+ # # populate development dependencies
+ # if gemspec.respond_to?(:add_development_dependency)
+ # gemspec.add_development_dependency(name,*version)
+ # else
+ # gemspec.add_dependency(name,*version)
+ # end
+ #else
+ # # populate runtime dependencies
+ # if gemspec.respond_to?(:add_runtime_dependency)
+ # gemspec.add_runtime_dependency(name,*version)
+ # else
+ # gemspec.add_dependency(name,*version)
+ # end
+ #end
+
+ if groups.empty? or groups.include?('runtime')
+ # populate runtime dependencies
+ if gemspec.respond_to?(:add_runtime_dependency)
+ gemspec.add_runtime_dependency(name,*version)
+ else
+ gemspec.add_dependency(name,*version)
+ end
+ else
+ # populate development dependencies
+ if gemspec.respond_to?(:add_development_dependency)
+ gemspec.add_development_dependency(name,*version)
+ else
+ gemspec.add_dependency(name,*version)
+ end
+ end
+ end
+
+ # convert external dependencies into a requirements
+ if metadata['external_dependencies']
+ ##gemspec.requirements = [] unless metadata['external_dependencies'].empty?
+ metadata['external_dependencies'].each do |req|
+ gemspec.requirements << req.to_s
+ end
+ end
+
+ # determine homepage from resources
+ homepage = metadata['resources'].find{ |key, url| key =~ /^home/ }
+ gemspec.homepage = homepage.last if homepage
+
+ gemspec.require_paths = metadata['load_path'] || ['lib']
+ gemspec.post_install_message = metadata['install_message']
+
+ # RubyGems specific metadata
+ gemspec.files = files
+ gemspec.extensions = extensions
+ gemspec.executables = executables
+
+ if Gem::VERSION < '1.7.'
+ gemspec.default_executable = gemspec.executables.first
+ end
+
+ gemspec.test_files = glob_files[patterns[:test_files]]
+
+ unless gemspec.files.include?('.document')
+ gemspec.extra_rdoc_files = glob_files[patterns[:doc_files]]
+ end
+ end
+end
View
@@ -0,0 +1,6 @@
+.reap/digest
+.yardoc
+doc
+pkg
+tmp
+site
View
No changes.
View
@@ -0,0 +1,8 @@
+= RELEASE HISTORY
+
+0.1.0 | 2011-01-01
+
+Summary of release...
+
+* First release.
+
View
@@ -0,0 +1,2 @@
+#!mast .ruby .yardopts bin info data lib man spec test [A-Z]*.*
+
View
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+
+# @todo move to reap proper
+#require 'facets/string/file'
+require 'facets/kernel/ask' # TODO: make sure reap provides this
+
+#
+# TODO: Do things in ruby instead of shelling out!
+#
+
+ignore 'pkg', 'site'
+
+trip 'manifest' do
+ system 'mast -u'
+end
+
+trip 'release' do
+ exit -1 unless system('detroit release')
+ system 'pom news | git tag -a -F - #{version}'
+end
+
+file 'VERSION' do
+ # `dotruby -r meta -r VERSION`
+ system 'pom spec -u'
+end
+
+file 'PROFILE' do
+ # TODO: Ultimately `dotruby` should be able to do this.
+ # `dotruby -r meta -r VERSION`
+ system 'pom spec -u'
+end
+
+file 'lib/**/*' do
+ exit -1 unless system('detroit test')
+end
+
+state :create_project do
+ ! File.exist?('.ruby')
+ # gem install dotruby
+end
+
+rule :create_project do
+ system '$EDITOR ruby.yaml'
+ #break unless ask('creating new project?')
+ #meta = YAML.load_file('ruby.yaml')
+ #name = ARGV[1] || File.basename(Dir.pwd)
+ #meta['name'] = name
+ #meta.each do |k,v|
+ # case v2 = ask("#{k} (#{v}):")
+ # when nil, ''
+ # when '`' then exit
+ # when '!' then exit -1
+ # else
+ # meta[k] = YAML.load(v2)
+ # end
+ #end
+end
+
+
+#require 'facets/functor'
+#class String
+# def file
+# str = self
+# Functor.new do |op,*a,&b|
+# FileUtils.send(op,str,*a,&b)
+# end
+# end
+#end
View
@@ -0,0 +1,5 @@
+#
+module RenameMe
+
+end
+
View
@@ -0,0 +1,23 @@
+---
+version : 0.1.0
+name : <%= name %>
+title : <%= title %>
+summary : <%= summary %>
+
+description:
+ <%= description %>
+
+requirements:
+ - reap ~>0.1 (build)
+
+authors:
+ - <%= name %> <<%= email %>>
+
+resources:
+ home: <%= homepage %>
+
+copyrights:
+ - (c) 2011 <%= name %> (<%= license %>)
+
+source: ruby.yml
+

0 comments on commit d89527d

Please sign in to comment.