newgem 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,25 @@
1
+ +++ 0.9.0 12/4/2007
2
+
3
+ + 3 major enhancements:
4
+ + Includes a basic website template, with rake tasks for generation and upload to rubyforge
5
+ + Generates a History.txt file, and automatically uses it in Hoe task
6
+ + Generated applications include framework for supporting command line options
7
+ + 3 minor enhancements:
8
+ + Include History.txt in this gem
9
+ + test files ordered correctly in generated Manifest.txt
10
+ + no blank line in Manifest.txt if no bin apps
11
+
12
+ +++ 0.8.1
13
+
14
+ - Generated test file's class name now prefixed with Test, instead of suffixed
15
+
16
+ +++ 0.8.0
17
+
18
+ - Uses hoe itself - less hypocritical
19
+ - Generated test files use name 'test_<gemname>.rb' instead of '<gemname>_test.rb' to support
20
+ ZenTest's autotest expectations of naming. Manifest updated too.
21
+
22
+ +++ 0.7.1
23
+
24
+ - Installed gems now don't require 'hoe' (based on comments at http://blog.evanweaver.com/articles/2007/01/10/if-you-dont-want-to-hoe-echoe)
25
+
data/Manifest.txt CHANGED
@@ -1,4 +1,4 @@
1
- CHANGELOG
1
+ History.txt
2
2
  Manifest.txt
3
3
  README
4
4
  Rakefile
@@ -6,10 +6,31 @@ bin/newgem
6
6
  install.rb
7
7
  lib/newgem.rb
8
8
  lib/newgem/version.rb
9
+ scripts/txt2html
10
+ scripts/txt2js
9
11
  setup.rb
12
+ templates/History.txt
10
13
  templates/Manifest.txt
11
14
  templates/Rakefile
15
+ templates/app.rb
16
+ templates/scripts/txt2html
12
17
  templates/setup.rb
13
18
  templates/test.rb
19
+ templates/website/index.txt
20
+ templates/website/javascripts/rounded_corners_lite.inc.js
21
+ templates/website/stylesheets/screen.css
22
+ templates/website/template.rhtml
14
23
  test/test_helper.rb
15
24
  test/test_newgem.rb
25
+ website/index.html
26
+ website/index.txt
27
+ website/javascripts/rounded_corners_lite.inc.js
28
+ website/rubyforge.html
29
+ website/rubyforge.txt
30
+ website/stylesheets/screen.css
31
+ website/template.js
32
+ website/template.rhtml
33
+ website/version-raw.js
34
+ website/version-raw.txt
35
+ website/version.js
36
+ website/version.txt
data/Rakefile CHANGED
@@ -18,8 +18,8 @@ RUBYFORGE_PROJECT = "newgem"
18
18
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
19
19
 
20
20
  REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
21
- VERSION = ENV['VERSION'] || (Newgem::VERSION::STRING + (REV ? ".#{REV}" : ""))
22
- CLEAN.include ['**/.*.sw?', '*.gem', '.config']
21
+ VERS = ENV['VERSION'] || (Newgem::VERSION::STRING + (REV ? ".#{REV}" : ""))
22
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
23
23
  RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
24
24
  "--opname", "index.html",
25
25
  "--line-numbers",
@@ -28,7 +28,7 @@ RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
28
28
 
29
29
  # Generate all the Rake tasks
30
30
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
31
- hoe = Hoe.new(GEM_NAME, VERSION) do |p|
31
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
32
32
  p.author = AUTHOR
33
33
  p.description = DESCRIPTION
34
34
  p.email = EMAIL
@@ -39,8 +39,41 @@ hoe = Hoe.new(GEM_NAME, VERSION) do |p|
39
39
  p.clean_globs = CLEAN #An array of file patterns to delete on clean.
40
40
 
41
41
  # == Optional
42
- #p.changes - A description of the release's latest changes.
43
- p.extra_deps = ['hoe'] #An array of rubygem dependencies.
42
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
43
+ p.extra_deps = [
44
+ ['hoe', '>=1.2.0'],
45
+ ['RedCloth','>=3.0.4'],
46
+ ['syntax','>=1.0.0']
47
+ ]
44
48
  #p.spec_extras - A hash of extra values to set in the gemspec.
45
49
  end
46
50
 
51
+ desc 'Generate website files'
52
+ task :website_generate => :load_consts do
53
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
54
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
55
+ end
56
+ sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
57
+ sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
58
+ end
59
+
60
+ desc 'Upload website files to rubyforge'
61
+ task :website_upload do
62
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
63
+ host = "#{config["username"]}@rubyforge.org"
64
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
65
+ local_dir = 'website'
66
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
67
+ end
68
+
69
+ desc 'Generate and upload website files'
70
+ task :website => [:website_generate, :website_upload]
71
+
72
+ task :load_consts do
73
+ ENV['AUTHOR'] = AUTHOR
74
+ ENV['EMAIL'] = EMAIL
75
+ ENV['DESCRIPTION'] = DESCRIPTION
76
+ ENV['GEM_NAME'] = GEM_NAME
77
+ ENV['RUBYFORGE_PROJECT'] = RUBYFORGE_PROJECT
78
+ ENV['HOMEPATH'] = HOMEPATH
79
+ end
data/bin/newgem CHANGED
@@ -35,6 +35,7 @@ BANNER
35
35
  opts.parse!(ARGV)
36
36
  end
37
37
  OPTIONS[:version] = OPTIONS[:version].to_s.split(/\./)
38
+ version_str = OPTIONS[:version].join('.')
38
39
 
39
40
  gem_name = project_name = ARGV[0]
40
41
  parser.parse!(["-h"]) unless gem_name
@@ -43,9 +44,11 @@ module_name = project_name.classify
43
44
  lib = project_name + '/lib'
44
45
  lib_project_name = project_name + '/lib/' + project_name
45
46
  version = project_name + "/lib/" + project_name + "/version.rb"
46
- rakefile, changelog, readme, setup, manifest, history =
47
- %w(Rakefile CHANGELOG.txt README.txt setup.rb Manifest.txt History.txt).
47
+ readme, setup = %w(README.txt setup.rb).
48
48
  collect {|f| project_name + '/' + f}
49
+ template_files = %w(Rakefile Manifest.txt History.txt scripts/txt2html website/index.txt website/template.rhtml)
50
+ copy_files = %w(website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css)
51
+
49
52
 
50
53
  test = project_name + "/test"
51
54
  main = project_name + "/lib/" + project_name + ".rb"
@@ -53,7 +56,8 @@ test_helper = test + "/test_helper.rb"
53
56
  unit_test = test + "/test_" + project_name + ".rb"
54
57
 
55
58
  examples = project_name + '/examples'
56
- bin = project_name + '/bin'
59
+ bin = project_name + '/bin'
60
+ folders = %w( scripts website website/javascripts website/stylesheets)
57
61
 
58
62
  # Rakefile variables
59
63
  author = ENV['USERNAME'] || ENV['USER'] || 'you'
@@ -63,12 +67,6 @@ FileUtils.rm_rf project_name
63
67
  puts "creating: " + project_name
64
68
  Dir.mkdir project_name
65
69
 
66
- puts "creating: " + changelog
67
- FileUtils.touch changelog
68
-
69
- puts "creating: " + history
70
- FileUtils.touch history
71
-
72
70
  puts "creating: " + readme
73
71
  File.open(readme, 'w') do |file|
74
72
  file << <<-eos
@@ -82,6 +80,12 @@ end
82
80
  puts "creating: " + lib
83
81
  Dir.mkdir lib
84
82
 
83
+ folders.each do |folder|
84
+ new_folder = project_name + '/' + folder
85
+ puts "creating: " + new_folder
86
+ Dir.mkdir new_folder
87
+ end
88
+
85
89
  if OPTIONS[:import_path]
86
90
  require 'fileutils'
87
91
  OPTIONS[:import_path].chomp! if OPTIONS[:import_path][-1] == 47 # /
@@ -116,13 +120,12 @@ Dir.mkdir bin
116
120
 
117
121
  if OPTIONS[:bin_name]
118
122
  bin_names_list = OPTIONS[:bin_name].split(',')
123
+ template = File.open(templates + 'app.rb','r') {|f| f.readlines.join}
124
+ p template
119
125
  bin_names_list.each do |bin_name|
120
126
  puts "creating: " + bin + '/' + bin_name
121
127
  File.open(bin + '/' + bin_name, 'w') do |file|
122
- file << <<-eos
123
- #!/usr/bin/env ruby
124
-
125
- eos
128
+ file << eval('"' + template.gsub(/"/, '\"') + '"')
126
129
  end
127
130
  end
128
131
  bin_names = bin_names_list.join(' ')
@@ -131,19 +134,6 @@ else
131
134
  bin_names_list = []
132
135
  end
133
136
 
134
- puts "creating: " + rakefile
135
- template = File.open(templates + 'Rakefile','r') {|f| f.readlines.join}
136
- File.open(rakefile, 'w') do |file|
137
- file << eval('"' + template.gsub(/"/, '\"') + '"')
138
- end
139
-
140
- puts "creating: " + manifest
141
- template = File.open(templates + 'Manifest.txt','r') {|f| f.readlines.join}
142
- File.open(manifest, 'w') do |file|
143
- file << eval('"' + template.gsub(/"/, '\"') + '"')
144
- end
145
-
146
-
147
137
 
148
138
  puts "creating: " + test
149
139
  Dir.mkdir test
@@ -171,4 +161,26 @@ File.open(setup, 'w') do |file|
171
161
  file << template
172
162
  end
173
163
 
164
+ bin_names_list = bin_names_list.collect {|name| 'bin/' + name }.join("\n")
165
+ bin_names_list += "\n" if bin_names_list.size > 0
166
+ test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| 'test/test_' + name }.join("\n")
167
+
168
+ template_files.each do |template_file|
169
+ puts "creating: " + project_name + '/' + template_file
170
+ template = File.open(templates + template_file,'r') {|f| f.readlines.join}
171
+ File.open(project_name + '/' + template_file, 'w') do |file|
172
+ file << eval('"' + template.gsub(/"/, '\"') + '"')
173
+ end
174
+ end
175
+
176
+ copy_files.each do |file|
177
+ puts "copying: " + project_name + '/' + file
178
+ template = File.open(templates + file,'r') {|f| f.readlines.join}
179
+ File.open(project_name + '/' + file, 'w') do |file|
180
+ file << template
181
+ end
182
+ end
183
+
184
+
185
+
174
186
  puts "NOW - update #{gem_name}/Rakefile with gem description, etc"
@@ -1,8 +1,8 @@
1
1
  module Newgem #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 8
5
- TINY = 1
4
+ MINOR = 9
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/scripts/txt2html ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'redcloth'
5
+ require 'syntax/convertors/html'
6
+ require 'erb'
7
+
8
+ class Fixnum
9
+ def ordinal
10
+ # teens
11
+ return 'th' if (10..19).include?(self % 100)
12
+ # others
13
+ case self % 10
14
+ when 1: return 'st'
15
+ when 2: return 'nd'
16
+ when 3: return 'rd'
17
+ else return 'th'
18
+ end
19
+ end
20
+ end
21
+
22
+ class Time
23
+ def pretty
24
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
25
+ end
26
+ end
27
+
28
+ def convert_syntax(syntax, source)
29
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
30
+ end
31
+
32
+ require File.dirname(__FILE__) + '/../lib/newgem/version.rb'
33
+
34
+ version = Newgem::VERSION::STRING
35
+ download = ENV['HOMEPAGE']
36
+
37
+ if ARGV.length >= 1
38
+ src, template = ARGV
39
+ template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
40
+
41
+ else
42
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
43
+ exit!
44
+ end
45
+
46
+ template = ERB.new(File.open(template).read)
47
+
48
+ title = nil
49
+ body = nil
50
+ File.open(src) do |fsrc|
51
+ title_text = fsrc.readline
52
+ body_text = fsrc.read
53
+ syntax_items = []
54
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
55
+ ident = syntax_items.length
56
+ element, syntax, source = $1, $2, $3
57
+ syntax_items << "<#{element} class=\"syntax\">#{convert_syntax(syntax, source)}</#{element}>"
58
+ "syntax-temp-#{ident}"
59
+ }
60
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
61
+ body = RedCloth.new(body_text).to_html
62
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
63
+ end
64
+ stat = File.stat(src)
65
+ created = stat.ctime
66
+ modified = stat.mtime
67
+
68
+ $stdout << template.result(binding)
data/scripts/txt2js ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'redcloth'
5
+ require 'syntax/convertors/html'
6
+ require 'erb'
7
+ require 'active_support'
8
+ require File.dirname(__FILE__) + '/../lib/newgem/version.rb'
9
+
10
+ version = Newgem::VERSION::STRING
11
+ download = 'http://rubyforge.org/projects/newgem'
12
+
13
+ class Fixnum
14
+ def ordinal
15
+ # teens
16
+ return 'th' if (10..19).include?(self % 100)
17
+ # others
18
+ case self % 10
19
+ when 1: return 'st'
20
+ when 2: return 'nd'
21
+ when 3: return 'rd'
22
+ else return 'th'
23
+ end
24
+ end
25
+ end
26
+
27
+ class Time
28
+ def pretty
29
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
30
+ end
31
+ end
32
+
33
+ def convert_syntax(syntax, source)
34
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
35
+ end
36
+
37
+ if ARGV.length >= 1
38
+ src, template = ARGV
39
+ template ||= File.dirname(__FILE__) + '/../website/template.js'
40
+ else
41
+ puts("Usage: #{File.split($0).last} source.txt [template.js] > 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
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
53
+ body = RedCloth.new(body_text)
54
+ end
55
+ stat = File.stat(src)
56
+ created = stat.ctime
57
+ modified = stat.mtime
58
+
59
+ $stdout << template.result(binding)
@@ -0,0 +1,4 @@
1
+ +++ #{version_str} #{Date.today}
2
+
3
+ + 1 major enhancement:
4
+ + Initial release
@@ -1,11 +1,14 @@
1
- CHANGELOG.txt
2
1
  History.txt
3
2
  Manifest.txt
4
3
  README.txt
5
4
  Rakefile
6
- #{bin_names_list.collect {|name| 'bin/' + name }.join('\n')}
7
- lib/#{project_name}.rb
5
+ #{bin_names_list}lib/#{project_name}.rb
8
6
  lib/#{project_name}/version.rb
7
+ scripts/txt2html
9
8
  setup.rb
10
- test/test_helper.rb
11
- test/test_#{project_name}.rb
9
+ #{test_names_list}
10
+ website/index.html
11
+ website/index.txt
12
+ website/javascripts/rounded_corners_lite.inc.js
13
+ website/stylesheets/screen.css
14
+ website/template.rhtml
data/templates/Rakefile CHANGED
@@ -22,7 +22,7 @@ HOMEPATH = "http://\#{RUBYFORGE_PROJECT}.rubyforge.org"
22
22
  NAME = "#{gem_name}"
23
23
  REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
24
24
  VERS = ENV['VERSION'] || (#{module_name}::VERSION::STRING + (REV ? ".\#{REV}" : ""))
25
- CLEAN.include ['**/.*.sw?', '*.gem', '.config']
25
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
26
26
  RDOC_OPTS = ['--quiet', '--title', "#{gem_name} documentation",
27
27
  "--opname", "index.html",
28
28
  "--line-numbers",
@@ -44,11 +44,32 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
44
44
  p.summary = DESCRIPTION
45
45
  p.url = HOMEPATH
46
46
  p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
- p.test_globs = ["test/**/*_test.rb"]
47
+ p.test_globs = ["test/**/test_*.rb"]
48
48
  p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
49
 
50
50
  # == Optional
51
- #p.changes - A description of the release's latest changes.
52
- #p.extra_deps - An array of rubygem dependencies.
53
- #p.spec_extras - A hash of extra values to set in the gemspec.
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
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]