diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..7879e88 --- /dev/null +++ b/COPYING @@ -0,0 +1,18 @@ +Copyright (c) 2010 Ryan Tomayko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b5555c0 --- /dev/null +++ b/Rakefile @@ -0,0 +1,59 @@ +require 'rake/testtask' +task :default => :test + +desc 'Run tests (default)' +Rake::TestTask.new(:test) do |t| + t.test_files = FileList['test/*_test.rb'] + t.ruby_opts = ['-rubygems'] if defined? Gem +end + +# PACKAGING ================================================================= + +if defined?(Gem) + SPEC = eval(File.read('rocco.gemspec')) + + def package(ext='') + "pkg/rocco-#{SPEC.version}" + ext + end + + desc 'Build packages' + task :package => %w[.gem .tar.gz].map {|e| package(e)} + + desc 'Build and install as local gem' + task :install => package('.gem') do + sh "gem install #{package('.gem')}" + end + + directory 'pkg/' + + file package('.gem') => %w[pkg/ rocco.gemspec] + SPEC.files do |f| + sh "gem build rocco.gemspec" + mv File.basename(f.name), f.name + end + + file package('.tar.gz') => %w[pkg/] + SPEC.files do |f| + sh "git archive --format=tar HEAD | gzip > #{f.name}" + end +end + +# GEMSPEC =================================================================== + +file 'rocco.gemspec' => FileList['{lib,test,bin}/**','Rakefile'] do |f| + # read version from tilt.rb + version = File.read('lib/rocco.rb')[/VERSION = '(.*)'/] && $1 + # read spec file and split out manifest section + spec = File. + read(f.name). + sub(/s\.version\s*=\s*'.*'/, "s.version = '#{version}'") + parts = spec.split(" # = MANIFEST =\n") + # determine file list from git ls-files + files = `git ls-files`. + split("\n").sort.reject{ |file| file =~ /^\./ }. + map{ |file| " #{file}" }.join("\n") + # piece file back together and write... + parts[1] = " s.files = %w[\n#{files}\n ]\n" + spec = parts.join(" # = MANIFEST =\n") + spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'") + File.open(f.name, 'w') { |io| io.write(spec) } + puts "updated #{f.name}" +end diff --git a/lib/rocco.rb b/lib/rocco.rb index 78bb3b9..0427b3d 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -51,6 +51,8 @@ end # whatever means necessary and return it as a string. With no `block`, the # file is read to retrieve data. class Rocco + VERSION = '0.1' + def initialize(filename, &block) @file = filename @data = diff --git a/rocco.gemspec b/rocco.gemspec new file mode 100644 index 0000000..2297704 --- /dev/null +++ b/rocco.gemspec @@ -0,0 +1,38 @@ +Gem::Specification.new do |s| + s.specification_version = 2 if s.respond_to? :specification_version= + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + + s.name = 'rocco' + s.version = '0.1' + s.date = '2010-03-08' + + s.description = "Docco in Ruby" + s.summary = s.description + + s.authors = ["Ryan Tomayko"] + s.email = "r@tomayko.com" + + # = MANIFEST = + s.files = %w[ + COPYING + README.md + Rakefile + bin/rocco + lib/rocco.rb + lib/rocco/layout.mustache + lib/rocco/layout.rb + rocco.gemspec + ] + # = MANIFEST = + + s.executables = ["rocco"] + + s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/} + s.add_dependency 'rdiscount' + s.add_dependency 'mustache' + + s.has_rdoc = false + s.homepage = "http://rtomayko.github.com/rocco/" + s.require_paths = %w[lib] + s.rubygems_version = '1.1.1' +end