newext 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ +++ 0.0.1 2007-04-30
2
+
3
+ + 1 major enhancement:
4
+ + Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/newext
6
+ lib/newext.rb
7
+ lib/newext/version.rb
8
+ scripts/txt2html
9
+ setup.rb
10
+ test/test_helper.rb
11
+ test/test_newext.rb
12
+
data/README.txt ADDED
@@ -0,0 +1,3 @@
1
+ README for newext
2
+ =================
3
+
data/Rakefile ADDED
@@ -0,0 +1,89 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'newext', 'version')
13
+
14
+ AUTHOR = 'Administrator' # can also be an array of Authors
15
+ EMAIL = "your contact email for bug fixes and info"
16
+ DESCRIPTION = "description of gem"
17
+ GEM_NAME = 'newext' # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = 'newext' # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
21
+
22
+ NAME = "newext"
23
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
24
+ VERS = Newext::VERSION::STRING + (REV ? ".#{REV}" : "")
25
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
26
+ RDOC_OPTS = ['--quiet', '--title', 'newext documentation',
27
+ "--opname", "index.html",
28
+ "--line-numbers",
29
+ "--main", "README",
30
+ "--inline-source"]
31
+
32
+ class Hoe
33
+ def extra_deps
34
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
35
+ end
36
+ end
37
+
38
+ # Generate all the Rake tasks
39
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
40
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
41
+ p.author = AUTHOR
42
+ p.description = DESCRIPTION
43
+ p.email = EMAIL
44
+ p.summary = DESCRIPTION
45
+ p.url = HOMEPATH
46
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
+ p.test_globs = ["test/**/test_*.rb"]
48
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
+
50
+ # == Optional
51
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
52
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
53
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
54
+ end
55
+
56
+
57
+ desc 'Generate website files'
58
+ task :website_generate do
59
+ Dir['website/**/*.txt'].each do |txt|
60
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
61
+ end
62
+ end
63
+
64
+ desc 'Upload website files to rubyforge'
65
+ task :website_upload do
66
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
67
+ host = "#{config["username"]}@rubyforge.org"
68
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
69
+ # remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
+ local_dir = 'website'
71
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
72
+ end
73
+
74
+ desc 'Generate and upload website files'
75
+ task :website => [:website_generate, :website_upload]
76
+
77
+ desc 'Release the website and new gem version'
78
+ task :deploy => [:check_version, :website, :release]
79
+
80
+ task :check_version do
81
+ unless ENV['VERSION']
82
+ puts 'Must pass a VERSION=x.y.z release version'
83
+ exit
84
+ end
85
+ unless ENV['VERSION'] == VERS
86
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
87
+ exit
88
+ end
89
+ end
data/bin/newext ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by MYNAME on 2007-4-30.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ begin
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ # no rubygems to load, so we fail silently
10
+ end
11
+
12
+ require 'optparse'
13
+
14
+ # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
15
+
16
+ OPTIONS = {
17
+ :path => '~'
18
+ }
19
+ MANDATORY_OPTIONS = %w( path )
20
+
21
+ parser = OptionParser.new do |opts|
22
+ opts.banner = <<BANNER
23
+ This application is wonderful because...
24
+
25
+ Usage: #{File.basename($0)} [options]
26
+
27
+ Options are:
28
+ BANNER
29
+ opts.separator ""
30
+ opts.on("-p", "--path=PATH", String,
31
+ "The root path for selecting files",
32
+ "Default: ~") { |OPTIONS[:path]| }
33
+ opts.on("-h", "--help",
34
+ "Show this help message.") { puts opts; exit }
35
+ opts.parse!(ARGV)
36
+
37
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
38
+ puts opts; exit
39
+ end
40
+ end
41
+
42
+ path = OPTIONS[:path]
43
+
44
+ # do stuff
45
+ unless ARGV[0]
46
+ puts "������չ����(input you extension name)"
47
+ puts "����(sample):newext mytest"
48
+ exit
49
+ end
50
+ @extname = "mytest"
51
+ @extname=ARGV[0] if ARGV[0]
52
+
53
+ data={}
54
+ data["toso.cmd"]=<<-eot
55
+ mt -manifest #{@extname}.so.manifest -outputresource:#{@extname}.so;2
56
+ ruby client.rb
57
+ eot
58
+
59
+ data["client.rb"]=<<-eot
60
+ require "#{@extname}"
61
+ eot
62
+
63
+ data["extconf.rb"]=<<-eot
64
+ require "mkmf"
65
+
66
+ dir_config("#{@extname}","c:/sdk")
67
+ dir_config("#{@extname}","C:/sdk/Include/crt","c:/vclib")
68
+ dir_config("#{@extname}","C:/ruby/src/ruby-1.8.5",nil)
69
+
70
+ create_makefile("#{@extname}")
71
+ eot
72
+
73
+ data[@extname.to_s + ".c"]=<<-eot
74
+ #include "ruby.h"
75
+ void Init_#{@extname}(){
76
+
77
+ }
78
+
79
+ eot
80
+
81
+ data.each do |fn,content|
82
+ open(fn,"wb"){|f|
83
+ f.write(content)
84
+ puts "created.." + fn.to_s
85
+ }
86
+ end
87
+
88
+ system("ruby extconf.rb")
@@ -0,0 +1,9 @@
1
+ module Newext #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/newext.rb ADDED
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'newext/**/*.rb')].sort.each { |lib| require lib }
data/scripts/txt2html ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'redcloth'
5
+ require 'syntax/convertors/html'
6
+ require 'erb'
7
+ require File.dirname(__FILE__) + '/../lib/newext/version.rb'
8
+
9
+ version = Newext::VERSION::STRING
10
+ download = 'http://rubyforge.org/projects/newext'
11
+
12
+ class Fixnum
13
+ def ordinal
14
+ # teens
15
+ return 'th' if (10..19).include?(self % 100)
16
+ # others
17
+ case self % 10
18
+ when 1: return 'st'
19
+ when 2: return 'nd'
20
+ when 3: return 'rd'
21
+ else return 'th'
22
+ end
23
+ end
24
+ end
25
+
26
+ class Time
27
+ def pretty
28
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
29
+ end
30
+ end
31
+
32
+ def convert_syntax(syntax, source)
33
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
34
+ end
35
+
36
+ if ARGV.length >= 1
37
+ src, template = ARGV
38
+ template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
39
+
40
+ else
41
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
42
+ exit!
43
+ end
44
+
45
+ template = ERB.new(File.open(template).read)
46
+
47
+ title = nil
48
+ body = nil
49
+ File.open(src) do |fsrc|
50
+ title_text = fsrc.readline
51
+ body_text = fsrc.read
52
+ syntax_items = []
53
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</>!m){
54
+ ident = syntax_items.length
55
+ element, syntax, source = $1, $2, $3
56
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
57
+ "syntax-temp-#{ident}"
58
+ }
59
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
60
+ body = RedCloth.new(body_text).to_html
61
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
62
+ end
63
+ stat = File.stat(src)
64
+ created = stat.ctime
65
+ modified = stat.mtime
66
+
67
+ $stdout << template.result(binding)