seedling 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/AUTHORS +3 -0
  2. data/CHANGELOG +76 -0
  3. data/MANIFEST +42 -0
  4. data/README +28 -0
  5. data/Rakefile +68 -0
  6. data/bin/seedling +15 -0
  7. data/lib/seedling.rb +5 -0
  8. data/lib/seedling/bin.rb +196 -0
  9. data/lib/seedling/extensions/inflector.rb +283 -0
  10. data/lib/seedling/project_creator.rb +147 -0
  11. data/lib/seedling/version.rb +3 -0
  12. data/lib/templates/core/Rakefile.seed +68 -0
  13. data/lib/templates/core/lib/library.rb.seed +5 -0
  14. data/lib/templates/core/lib/library/version.rb.seed +3 -0
  15. data/lib/templates/core/spec/helper.rb.seed +28 -0
  16. data/lib/templates/core/tasks/authors.rake +30 -0
  17. data/lib/templates/core/tasks/bacon.rake +70 -0
  18. data/lib/templates/core/tasks/changelog.rake +18 -0
  19. data/lib/templates/core/tasks/copyright.rake +21 -0
  20. data/lib/templates/core/tasks/gem.rake +23 -0
  21. data/lib/templates/core/tasks/gem_installer.rake +76 -0
  22. data/lib/templates/core/tasks/install_dependencies.rake +6 -0
  23. data/lib/templates/core/tasks/manifest.rake +4 -0
  24. data/lib/templates/core/tasks/rcov.rake +23 -0
  25. data/lib/templates/core/tasks/release.rake +52 -0
  26. data/lib/templates/core/tasks/reversion.rake +8 -0
  27. data/lib/templates/core/tasks/setup.rake.seed +15 -0
  28. data/seedling.gemspec +38 -0
  29. data/spec/helper.rb +28 -0
  30. data/tasks/authors.rake +30 -0
  31. data/tasks/bacon.rake +70 -0
  32. data/tasks/changelog.rake +18 -0
  33. data/tasks/copyright.rake +21 -0
  34. data/tasks/gem.rake +23 -0
  35. data/tasks/gem_installer.rake +76 -0
  36. data/tasks/install_dependencies.rake +6 -0
  37. data/tasks/manifest.rake +4 -0
  38. data/tasks/rcov.rake +23 -0
  39. data/tasks/release.rake +52 -0
  40. data/tasks/reversion.rake +8 -0
  41. data/tasks/setup.rake +15 -0
  42. data/tasks/yard.rake +4 -0
  43. metadata +101 -0
@@ -0,0 +1,6 @@
1
+ desc 'install dependencies'
2
+ task :install_dependencies => [:gem_installer] do
3
+ GemInstaller.new do
4
+ setup_gemspec(GEMSPEC)
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ desc 'update manifest'
2
+ task :manifest do
3
+ File.open('MANIFEST', 'w+'){|io| io.puts(*GEMSPEC.files) }
4
+ end
@@ -0,0 +1,23 @@
1
+ desc 'code coverage'
2
+ task :rcov => :clean do
3
+ specs = PROJECT_SPECS
4
+
5
+ ignore = %w[ gem rack bacon innate hpricot nagoro/lib/nagoro ]
6
+
7
+ if RUBY_VERSION >= '1.8.7'
8
+ ignore << 'begin_with' << 'end_with'
9
+ end
10
+ if RUBY_VERSION < '1.9'
11
+ ignore << 'fiber'
12
+ end
13
+
14
+ ignored = ignore.join(',')
15
+
16
+ cmd = "rcov --aggregate coverage.data --sort coverage -t --%s -x '#{ignored}' %s"
17
+
18
+ while spec = specs.shift
19
+ puts '', "Gather coverage for #{spec} ..."
20
+ html = specs.empty? ? 'html' : 'no-html'
21
+ sh(cmd % [html, spec])
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ namespace :release do
2
+ task :all => [:release_github, :release_rubyforge]
3
+
4
+ desc 'Display instructions to release on github'
5
+ task :github => [:reversion, :gemspec] do
6
+ name, version = GEMSPEC.name, GEMSPEC.version
7
+
8
+ puts <<INSTRUCTIONS
9
+ First add the relevant files:
10
+
11
+ git add AUTHORS MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb
12
+
13
+ Then commit them, tag the commit, and push:
14
+
15
+ git commit -m 'Version #{version}'
16
+ git tag -a -m '#{version}' '#{version}'
17
+ git push
18
+
19
+ INSTRUCTIONS
20
+
21
+ end
22
+
23
+ # TODO: Not tested
24
+ desc 'Display instructions to release on rubyforge'
25
+ task :rubyforge => [:reversion, :gemspec, :package] do
26
+ name, version = GEMSPEC.name, GEMSPEC.version
27
+
28
+ puts <<INSTRUCTIONS
29
+ To publish to rubyforge do following:
30
+
31
+ rubyforge login
32
+ rubyforge add_release #{name} #{name} '#{version}' pkg/#{name}-#{version}.gem
33
+
34
+ After you have done these steps, see:
35
+
36
+ rake release:rubyforge_archives
37
+
38
+ INSTRUCTIONS
39
+ end
40
+
41
+ desc 'Display instructions to add archives after release:rubyforge'
42
+ task :rubyforge_archives do
43
+ name, version = GEMSPEC.name, GEMSPEC.version
44
+ puts "Adding archives for distro packagers is:", ""
45
+
46
+ Dir["pkg/#{name}-#{version}.{tgz,zip}"].each do |file|
47
+ puts "rubyforge add_file #{name} #{name} '#{version}' '#{file}'"
48
+ end
49
+
50
+ puts
51
+ end
52
+ end
@@ -0,0 +1,8 @@
1
+ desc "update version.rb"
2
+ task :reversion do
3
+ File.open("lib/#{GEMSPEC.name}/version.rb", 'w+') do |file|
4
+ file.puts("module #{PROJECT_MODULE}")
5
+ file.puts(' VERSION = %p' % GEMSPEC.version.to_s)
6
+ file.puts('end')
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ desc 'install all possible dependencies'
2
+ task :setup => :gem_installer do
3
+ GemInstaller.new do
4
+ # core
5
+
6
+ # spec
7
+ gem '<%= @options[:test_suite] %>'
8
+ gem 'rcov'
9
+
10
+ # doc
11
+ gem '<%= @options[:doc_generator] %>'
12
+
13
+ setup
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{seedling}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Kevin Berry"]
9
+ s.date = %q{2009-05-18}
10
+ s.default_executable = %q{seedling}
11
+ s.description = %q{A lightweight tool to create new ruby library trees, with helpers to make gemming and maintaining a breeze.}
12
+ s.email = %q{deathsyn@gmail.com}
13
+ s.executables = ["seedling"]
14
+ s.files = ["AUTHORS", "CHANGELOG", "MANIFEST", "README", "Rakefile", "bin/seedling", "lib/seedling.rb", "lib/seedling/bin.rb", "lib/seedling/extensions/inflector.rb", "lib/seedling/project_creator.rb", "lib/seedling/version.rb", "lib/templates/core/Rakefile.seed", "lib/templates/core/lib/library.rb.seed", "lib/templates/core/lib/library/version.rb.seed", "lib/templates/core/spec/helper.rb.seed", "lib/templates/core/tasks/authors.rake", "lib/templates/core/tasks/bacon.rake", "lib/templates/core/tasks/changelog.rake", "lib/templates/core/tasks/copyright.rake", "lib/templates/core/tasks/gem.rake", "lib/templates/core/tasks/gem_installer.rake", "lib/templates/core/tasks/install_dependencies.rake", "lib/templates/core/tasks/manifest.rake", "lib/templates/core/tasks/rcov.rake", "lib/templates/core/tasks/release.rake", "lib/templates/core/tasks/reversion.rake", "lib/templates/core/tasks/setup.rake.seed", "seedling.gemspec", "spec/helper.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/copyright.rake", "tasks/gem.rake", "tasks/gem_installer.rake", "tasks/install_dependencies.rake", "tasks/manifest.rake", "tasks/rcov.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/yard.rake"]
15
+ s.has_rdoc = true
16
+ s.homepage = %q{http://github.com/deathsyn/seedling}
17
+ s.post_install_message = %q{============================================================
18
+
19
+ Thank you for installing Seedling!
20
+ Begin by planting your ruby project with
21
+ # seedling plant /path/to/new/project
22
+
23
+ ============================================================}
24
+ s.require_paths = ["lib"]
25
+ s.rubyforge_project = %q{seedling}
26
+ s.rubygems_version = %q{1.3.1}
27
+ s.summary = %q{A lightweight tool to create new ruby library trees, with helpers to make gemming and maintaining a breeze.}
28
+
29
+ if s.respond_to? :specification_version then
30
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
31
+ s.specification_version = 2
32
+
33
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
34
+ else
35
+ end
36
+ else
37
+ end
38
+ end
@@ -0,0 +1,28 @@
1
+ require "pathname"
2
+ begin
3
+ require "bacon"
4
+ rescue LoadError
5
+ require "rubygems"
6
+ require "bacon"
7
+ end
8
+
9
+ begin
10
+ if (local_path = Pathname.new(__FILE__).dirname.join("..", "lib", "seedling.rb")).file?
11
+ require local_path
12
+ else
13
+ require "seedling"
14
+ end
15
+ rescue LoadError
16
+ require "rubygems"
17
+ require "seedling"
18
+ end
19
+
20
+ Bacon.summary_on_exit
21
+
22
+ describe "Spec Helper" do
23
+ it "Should bring our library namespace in" do
24
+ Seedling.should == Seedling
25
+ end
26
+ end
27
+
28
+
@@ -0,0 +1,30 @@
1
+ # Once git has a fix for the glibc in handling .mailmap and another fix for
2
+ # allowing empty mail address to be mapped in .mailmap we won't have to handle
3
+ # them manually.
4
+
5
+ desc 'Update AUTHORS'
6
+ task :authors do
7
+ authors = Hash.new(0)
8
+
9
+ `git shortlog -nse`.scan(/(\d+)\s(.+)\s<(.*)>$/) do |count, name, email|
10
+ case name
11
+ when "bougyman"
12
+ name, email = "TJ Vanderpoel", "bougy.man@gmail.com"
13
+ when /riscfuture/i
14
+ name, email = "Tim Morgan", "riscfuture@gmail.com"
15
+ when "Michael Fellinger m.fellinger@gmail.com"
16
+ name, email = "Michael Fellinger", "m.fellinger@gmail.com"
17
+ end
18
+
19
+ authors[[name, email]] += count.to_i
20
+ end
21
+
22
+ File.open('AUTHORS', 'w+') do |io|
23
+ io.puts "Following persons have contributed to #{GEMSPEC.name}."
24
+ io.puts '(Sorted by number of submitted patches, then alphabetically)'
25
+ io.puts ''
26
+ authors.sort_by{|(n,e),c| [-c, n.downcase] }.each do |(name, email), count|
27
+ io.puts("%6d %s <%s>" % [count, name, email])
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,70 @@
1
+ desc 'Run all bacon specs with pretty output'
2
+ task :bacon => :install_dependencies do
3
+ require 'open3'
4
+ require 'scanf'
5
+ require 'matrix'
6
+
7
+ specs = PROJECT_SPECS
8
+
9
+ some_failed = false
10
+ specs_size = specs.size
11
+ if specs.size == 0
12
+ $stderr.puts "You have no specs! Put a spec in spec/ before running this task"
13
+ exit 1
14
+ end
15
+ len = specs.map{|s| s.size }.sort.last
16
+ total_tests = total_assertions = total_failures = total_errors = 0
17
+ totals = Vector[0, 0, 0, 0]
18
+
19
+ red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
20
+ left_format = "%4d/%d: %-#{len + 11}s"
21
+ spec_format = "%d specifications (%d requirements), %d failures, %d errors"
22
+
23
+ specs.each_with_index do |spec, idx|
24
+ print(left_format % [idx + 1, specs_size, spec])
25
+
26
+ Open3.popen3(RUBY, spec) do |sin, sout, serr|
27
+ out = sout.read.strip
28
+ err = serr.read.strip
29
+
30
+ # this is conventional, see spec/innate/state/fiber.rb for usage
31
+ if out =~ /^Bacon::Error: (needed .*)/
32
+ puts(yellow % ("%6s %s" % ['', $1]))
33
+ else
34
+ total = nil
35
+
36
+ out.each_line do |line|
37
+ scanned = line.scanf(spec_format)
38
+
39
+ next unless scanned.size == 4
40
+
41
+ total = Vector[*scanned]
42
+ break
43
+ end
44
+
45
+ if total
46
+ totals += total
47
+ tests, assertions, failures, errors = total_array = total.to_a
48
+
49
+ if tests > 0 && failures + errors == 0
50
+ puts((green % "%6d passed") % tests)
51
+ else
52
+ some_failed = true
53
+ puts(red % " failed")
54
+ puts out unless out.empty?
55
+ puts err unless err.empty?
56
+ end
57
+ else
58
+ some_failed = true
59
+ puts(red % " failed")
60
+ puts out unless out.empty?
61
+ puts err unless err.empty?
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ total_color = some_failed ? red : green
68
+ puts(total_color % (spec_format % totals.to_a))
69
+ exit 1 if some_failed
70
+ end
@@ -0,0 +1,18 @@
1
+ desc 'update changelog'
2
+ task :changelog do
3
+ File.open('CHANGELOG', 'w+') do |changelog|
4
+ `git log -z --abbrev-commit`.split("\0").each do |commit|
5
+ next if commit =~ /^Merge: \d*/
6
+ ref, author, time, _, title, _, message = commit.split("\n", 7)
7
+ ref = ref[/commit ([0-9a-f]+)/, 1]
8
+ author = author[/Author: (.*)/, 1].strip
9
+ time = Time.parse(time[/Date: (.*)/, 1]).utc
10
+ title.strip!
11
+
12
+ changelog.puts "[#{ref} | #{time}] #{author}"
13
+ changelog.puts '', " * #{title}"
14
+ changelog.puts '', message.rstrip if message
15
+ changelog.puts
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ desc "add copyright to all .rb files in the distribution"
2
+ task :copyright do
3
+ ignore = File.readlines('doc/LEGAL').
4
+ select{|line| line.strip!; File.exist?(line)}.
5
+ map{|file| File.expand_path(file)}
6
+
7
+ puts "adding copyright to files that don't have it currently"
8
+ puts PROJECT_COPYRIGHT
9
+ puts
10
+
11
+ Dir['{lib,test}/**/*{.rb}'].each do |file|
12
+ file = File.expand_path(file)
13
+ next if ignore.include? file
14
+ lines = File.readlines(file).map{|l| l.chomp}
15
+ unless lines.first(PROJECT_COPYRIGHT.size) == PROJECT_COPYRIGHT
16
+ puts "#{file} seems to need attention, first 4 lines:"
17
+ puts lines[0..3]
18
+ puts
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'rake/gempackagetask'
2
+
3
+ desc "make a gemspec"
4
+ task :gemspec => [:manifest, :changelog, :authors] do
5
+ gemspec_file = "#{GEMSPEC.name}.gemspec"
6
+ File.open(gemspec_file, 'w+'){|gs| gs.puts(GEMSPEC.to_ruby) }
7
+ end
8
+
9
+ desc "package and install from gemspec"
10
+ task :install => [:gemspec] do
11
+ sh "gem build #{GEMSPEC.name}.gemspec"
12
+ sh "gem install #{GEMSPEC.name}-#{GEMSPEC.version}.gem"
13
+ end
14
+
15
+ desc "uninstall the gem"
16
+ task :uninstall => [:clean] do
17
+ sh %{gem uninstall -x #{GEMSPEC.name}}
18
+ end
19
+
20
+ Rake::GemPackageTask.new(GEMSPEC) do |p|
21
+ p.need_tar = true
22
+ p.need_zip = true
23
+ end
@@ -0,0 +1,76 @@
1
+ task :gem_installer do
2
+ class GemInstaller
3
+ def initialize(options = {}, &block)
4
+ @gems = []
5
+ @options = options
6
+
7
+ run(&block)
8
+ end
9
+
10
+ def run(&block)
11
+ instance_eval(&block) if block_given?
12
+ end
13
+
14
+ def gem(name, version = nil, options = {})
15
+ if version.respond_to?(:merge!)
16
+ options = version
17
+ else
18
+ options[:version] = version
19
+ end
20
+
21
+ @gems << [name, options]
22
+ end
23
+
24
+ def setup_gemspec(gemspec)
25
+ gemspec.dependencies.each do |dependency|
26
+ dependency.version_requirements.as_list.each do |version|
27
+ gem(dependency.name, version)
28
+ end
29
+ end
30
+
31
+ setup
32
+ end
33
+
34
+ def setup
35
+ require 'rubygems'
36
+ require 'rubygems/dependency_installer'
37
+
38
+ @gems.each do |name, options|
39
+ setup_gem(name, options)
40
+ end
41
+ end
42
+
43
+ def setup_gem(name, options, try_install = true)
44
+ print "activating #{name} ... "
45
+ Gem.activate(name, *[options[:version]].compact)
46
+ require(options[:lib] || name)
47
+ puts "success."
48
+ rescue LoadError => error
49
+ puts error
50
+ install_gem(name, options) if try_install
51
+ setup_gem(name, options, try_install = false)
52
+ end
53
+
54
+ def install_gem(name, options)
55
+ installer = Gem::DependencyInstaller.new(options)
56
+
57
+ temp_argv(options[:extconf]) do
58
+ print "Installing #{name} ... "
59
+ installer.install(name, options[:version])
60
+ puts "done."
61
+ end
62
+ end
63
+
64
+ def temp_argv(extconf)
65
+ if extconf ||= @options[:extconf]
66
+ old_argv = ARGV.clone
67
+ ARGV.replace(extconf.split(' '))
68
+ end
69
+
70
+ yield
71
+
72
+ ensure
73
+ ARGV.replace(old_argv) if extconf
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,6 @@
1
+ desc 'install dependencies'
2
+ task :install_dependencies => [:gem_installer] do
3
+ GemInstaller.new do
4
+ setup_gemspec(GEMSPEC)
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ desc 'update manifest'
2
+ task :manifest do
3
+ File.open('MANIFEST', 'w+'){|io| io.puts(*GEMSPEC.files) }
4
+ end