Permalink
Browse files

Cleaned up newgem output

  • Loading branch information...
0 parents commit 955825b9972699d12e394c20f53d382073720be2 @kennethkalmer committed Jan 7, 2009
Showing with 335 additions and 0 deletions.
  1. +3 −0 History.txt
  2. +26 −0 Manifest.txt
  3. +7 −0 PostInstall.txt
  4. +55 −0 README.textile
  5. +29 −0 Rakefile
  6. +6 −0 lib/daemon-kit.rb
  7. +42 −0 lib/daemon-kit/cli.rb
  8. +10 −0 script/console
  9. +14 −0 script/destroy
  10. +14 −0 script/generate
  11. +71 −0 script/txt2html
  12. +15 −0 spec/daemon-kit_cli_spec.rb
  13. +11 −0 spec/daemon-kit_spec.rb
  14. +1 −0 spec/spec.opts
  15. +10 −0 spec/spec_helper.rb
  16. +21 −0 tasks/rspec.rake
@@ -0,0 +1,3 @@
+== 0.0.1 (not released yet)
+
+* 1 small step for man, 1 giant leap for mankind
@@ -0,0 +1,26 @@
+History.txt
+Manifest.txt
+PostInstall.txt
+README.rdoc
+Rakefile
+bin/daemon-kit
+config/website.yml.sample
+features/development.feature
+features/steps/common.rb
+features/steps/env.rb
+lib/daemon-kit.rb
+lib/daemon-kit/cli.rb
+script/console
+script/destroy
+script/generate
+script/txt2html
+spec/daemon-kit_cli_spec.rb
+spec/daemon-kit_spec.rb
+spec/spec.opts
+spec/spec_helper.rb
+tasks/rspec.rake
+website/index.html
+website/index.txt
+website/javascripts/rounded_corners_lite.inc.js
+website/stylesheets/screen.css
+website/template.html.erb
@@ -0,0 +1,7 @@
+
+For more information on daemon-kit, see http://daemon-kit.rubyforge.org
+
+NOTE: Change this information in PostInstall.txt
+You can also delete it if you don't want it.
+
+
@@ -0,0 +1,55 @@
+h1. Daemon Kit
+
+* http://daemon-kit.rubyforge.org/ (coming soon)
+
+h2. DESCRIPTION:
+
+Daemon Kit aims to simplify creating Ruby daemons by providing a sound application skeleton (through a generator), task specific generators (jabber bot, etc) and robust environment management code.
+
+h2. FEATURES/PROBLEMS:
+
+* Build it
+
+h2. SYNOPSIS:
+
+ $ daemon-kit [/path/to/your/daemon] [options]
+
+h2. REQUIREMENTS:
+
+* Ruby 1.8.6
+* daemons
+
+h2. INSTALL:
+
+Unstable development releases
+
+* sudo gem install kennethkalmer-daemon-kit -s http://gems.github.com
+
+Stable releases (coming soon)
+
+* sudo gem install daemon-kit
+
+h2. LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 Kenneth Kalmer
+
+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 OR COPYRIGHT HOLDERS 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.
@@ -0,0 +1,29 @@
+
+%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
+require File.dirname(__FILE__) + '/lib/daemon-kit'
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.new('daemon-kit', DaemonKit::VERSION) do |p|
+ p.developer('Kenneth Kalmer', 'kenneth.kalmer@gmail.com')
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ p.rubyforge_name = p.name # TODO this is default value
+ p.extra_deps = [
+ ['daemons','>= 1.0.10'],
+ ]
+ p.extra_dev_deps = [
+ ['newgem', ">= #{::Newgem::VERSION}"]
+ ]
+
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
+ p.rsync_args = '-av --delete --ignore-errors'
+end
+
+require 'newgem/tasks' # load /tasks/*.rake
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+task :default => [:spec, :features]
@@ -0,0 +1,6 @@
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+module DaemonKit
+ VERSION = '0.0.1'
+end
@@ -0,0 +1,42 @@
+require 'optparse'
+
+module DaemonKit
+ class CLI
+ def self.execute(stdout, arguments=[])
+
+ # NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
+
+ options = {
+ :path => '~'
+ }
+ mandatory_options = %w( )
+
+ parser = OptionParser.new do |opts|
+ opts.banner = <<-BANNER.gsub(/^ /,'')
+ This application is wonderful because...
+
+ Usage: #{File.basename($0)} [options]
+
+ Options are:
+ BANNER
+ opts.separator ""
+ opts.on("-p", "--path=PATH", String,
+ "This is a sample message.",
+ "For multiple lines, add more strings.",
+ "Default: ~") { |arg| options[:path] = arg }
+ opts.on("-h", "--help",
+ "Show this help message.") { stdout.puts opts; exit }
+ opts.parse!(arguments)
+
+ if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
+ stdout.puts opts; exit
+ end
+ end
+
+ path = options[:path]
+
+ # do stuff
+ puts "To update this executable, look in lib/daemon-kit/cli.rb"
+ end
+ end
+end
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# File: script/console
+irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
+
+libs = " -r irb/completion"
+# Perhaps use a console_lib to store any extra methods I may want available in the cosole
+# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
+libs << " -r #{File.dirname(__FILE__) + '/../lib/daemon-kit.rb'}"
+puts "Loading daemon-kit gem"
+exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,71 @@
+#!/usr/bin/env ruby
+
+load File.dirname(__FILE__) + "/../Rakefile"
+require 'rubyforge'
+require 'redcloth'
+require 'syntax/convertors/html'
+require 'erb'
+
+download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
+version = $hoe.version
+
+def rubyforge_project_id
+ RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
+end
+
+class Fixnum
+ def ordinal
+ # teens
+ return 'th' if (10..19).include?(self % 100)
+ # others
+ case self % 10
+ when 1: return 'st'
+ when 2: return 'nd'
+ when 3: return 'rd'
+ else return 'th'
+ end
+ end
+end
+
+class Time
+ def pretty
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
+ end
+end
+
+def convert_syntax(syntax, source)
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
+end
+
+if ARGV.length >= 1
+ src, template = ARGV
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
+else
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
+ exit!
+end
+
+template = ERB.new(File.open(template).read)
+
+title = nil
+body = nil
+File.open(src) do |fsrc|
+ title_text = fsrc.readline
+ body_text_template = fsrc.read
+ body_text = ERB.new(body_text_template).result(binding)
+ syntax_items = []
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
+ ident = syntax_items.length
+ element, syntax, source = $1, $2, $3
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
+ "syntax-temp-#{ident}"
+ }
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
+ body = RedCloth.new(body_text).to_html
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
+end
+stat = File.stat(src)
+created = stat.ctime
+modified = stat.mtime
+
+$stdout << template.result(binding)
@@ -0,0 +1,15 @@
+require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+require 'daemon-kit/cli'
+
+describe DaemonKit::CLI, "execute" do
+ before(:each) do
+ @stdout_io = StringIO.new
+ DaemonKit::CLI.execute(@stdout_io, [])
+ @stdout_io.rewind
+ @stdout = @stdout_io.read
+ end
+
+ it "should do something" do
+ @stdout.should_not =~ /To update this executable/
+ end
+end
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/spec_helper.rb'
+
+# Time to add your specs!
+# http://rspec.info/
+describe "Place your specs here" do
+
+ it "find this spec in spec directory" do
+ violated "Be sure to write your specs"
+ end
+
+end
@@ -0,0 +1 @@
+--colour
@@ -0,0 +1,10 @@
+begin
+ require 'spec'
+rescue LoadError
+ require 'rubygems'
+ gem 'rspec'
+ require 'spec'
+end
+
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+require 'daemon-kit'
@@ -0,0 +1,21 @@
+begin
+ require 'spec'
+rescue LoadError
+ require 'rubygems'
+ require 'spec'
+end
+begin
+ require 'spec/rake/spectask'
+rescue LoadError
+ puts <<-EOS
+To use rspec for testing you must install rspec gem:
+ gem install rspec
+EOS
+ exit(0)
+end
+
+desc "Run the specs under spec/models"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_opts = ['--options', "spec/spec.opts"]
+ t.spec_files = FileList['spec/**/*_spec.rb']
+end

0 comments on commit 955825b

Please sign in to comment.