godfat-source-tools 0.5.0

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/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ = source-tools changes history
2
+
3
+ == source-tools 0.5 / 2008-12-12
4
+
5
+ * 1 major enhancement
6
+ * Birthday!
data/README ADDED
@@ -0,0 +1,2 @@
1
+ source code layout formatter collection
2
+ http://github.com/godfat/source-tools
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'bones'
5
+ Bones.setup
6
+ rescue LoadError
7
+ load 'tasks/setup.rb' # this line should already be there
8
+ end
9
+
10
+ PROJ.name = 'source-tools'
11
+ PROJ.authors = 'Lin Jen-Shin (a.k.a. godfat 真常)'
12
+ PROJ.email = 'godfat (XD) godfat.org'
13
+ PROJ.url = 'http://github.com/godfat/source-tools'
14
+ PROJ.rubyforge.name = 'ludy'
15
+
16
+ # PROJ.gem.dependencies << ['source-tools', '>=0.5.0']
17
+ # PROJ.gem.development_dependencies << ['minitest', '>=1.3.0']
18
+ PROJ.gem.executables = ["bin/#{PROJ.name}"]
19
+
20
+ # PROJ.ruby_opts.delete '-w'
21
+
22
+ PROJ.description = PROJ.summary = paragraphs_of('README', 'description').join("\n\n")
23
+ PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
24
+ PROJ.version = File.read("lib/#{PROJ.name}/version.rb").gsub(/.*VERSION = '(.*)'.*/m, '\1')
25
+
26
+ PROJ.manifest_file = 'Manifest'
27
+ PROJ.exclude += ['^Manifest$', '^tmp', 'tmp$', '^pkg',
28
+ '^\.gitignore$', '^ann-', '\.sqlite3$', '\.db$']
29
+
30
+ PROJ.rdoc.remote_dir = PROJ.name
31
+
32
+ PROJ.readme_file = 'README'
33
+ PROJ.rdoc.main = 'README'
34
+ PROJ.rdoc.exclude += ['Rakefile', '^tasks', '^test']
35
+ PROJ.rdoc.include << '\w+'
36
+ PROJ.rdoc.opts << '--diagram' if !WIN32 and `which dot` =~ %r/\/dot/
37
+ PROJ.rdoc.opts += ['--charset=utf-8', '--inline-source',
38
+ '--line-numbers', '--promiscuous']
39
+
40
+ PROJ.spec.opts << '--color'
41
+
42
+ PROJ.ann.file = "ann-#{PROJ.name}-#{PROJ.version}"
43
+ PROJ.ann.paragraphs.concat %w[LINKS SYNOPSIS REQUIREMENTS INSTALL LICENSE]
44
+
45
+ CLEAN.include Dir['**/*.rbc']
46
+
47
+ task :default do
48
+ Rake.application.options.show_task_pattern = /./
49
+ Rake.application.display_tasks_and_comments
50
+ end
51
+
52
+ namespace :gem do
53
+ desc "create #{PROJ.name}.gemspec"
54
+ task 'gemspec' do
55
+ puts "rake gem:debug > #{PROJ.name}.gemspec"
56
+ File.open("#{PROJ.name}.gemspec", 'w'){|spec| spec << `rake gem:debug`.sub(/.*/, '')}
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load 'source-tools/bin.rake'
@@ -0,0 +1,48 @@
1
+
2
+ module SourceTools
3
+ module_function
4
+
5
+ def strip file, spaces = ' '
6
+ strip_utf8_bom(
7
+ file.map{ |line| line.gsub("\t", spaces).rstrip }.join("\n") + "\n"
8
+ )
9
+ end
10
+
11
+ def strip_utf8_bom str
12
+ str[0..2] == "\xEF\xBB\xBF" ? str[3..-1] : str
13
+ end
14
+
15
+ def each_source_path
16
+ require 'pathname'
17
+
18
+ Pathname.getwd.find do |path|
19
+ # skip unreadable, unwritable, .git and .svn directories
20
+ skip_dir = path.directory? && (!path.readable? || !path.writable?)
21
+ Find.prune if skip_dir || %w[.git .svn].include?(path.basename.to_s)
22
+
23
+ # skip non-files, zero-sized files, files not matching specific names, or files without the matching extensions
24
+ match = files.include?(path.basename.to_s) || extensions.include?(path.extname[1..-1])
25
+ next unless path.file? && path.size? && match && path.readable? && path.writable?
26
+
27
+ yield(path)
28
+ end
29
+
30
+ end
31
+
32
+ def files
33
+ # files and extensions to process
34
+ %w[ CHANGELOG HISTORY MIT-LICENSE LICENSE README README_FOR_APP
35
+ RUNNING_UNIT_TESTS TODO USAGE INSTALL NOTICE .autotest .gitignore
36
+ Makefile Rakefile capfile ]
37
+ end
38
+
39
+ def extensions
40
+ source_codes = %w[ rb rake sake php pl py js sh c cpp cxx h hpp hs ml java cs d y ]
41
+ templates = %w[ haml builder erb eruby rxml rhtml rjs ratom rcsv ]
42
+ markup = %w[ css htm html xml rdf yml yaml ]
43
+ others = %w[ cgi fcgi conf deploy example htc key opts rpdf sql txt vcf log ]
44
+
45
+ (source_codes + templates + markup + others)
46
+ end
47
+
48
+ end
@@ -0,0 +1,9 @@
1
+
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ require 'source-tools/tasks'
6
+ load 'source-tools/default.rake'
7
+
8
+ Rake.application.init('source-tools')
9
+ Rake.application.top_level
@@ -0,0 +1,5 @@
1
+
2
+ task :default do
3
+ Rake.application.options.show_task_pattern = /./
4
+ Rake.application.display_tasks_and_comments
5
+ end
@@ -0,0 +1,4 @@
1
+
2
+ %w[strip rakefile chmod].each{ |task|
3
+ load "source-tools/tasks/#{task}.rake"
4
+ }
@@ -0,0 +1,15 @@
1
+
2
+ namespace :st do
3
+ desc 'fix files(644) and directories(755) permission recursively.'
4
+ task :chmod do
5
+ require 'pathname'
6
+ Pathname.getwd.find do |path|
7
+ if path.directory?
8
+ path.chmod(0755)
9
+ else
10
+ path.chmod(0644)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+
2
+ namespace :st do
3
+ desc 'create a Rakefile template for bones.'
4
+ task :rakefile, :project do |t, args|
5
+ if args[:project].nil?
6
+ puts 'please specify your project name like:'
7
+ puts ' > source-tools st:rakefile project=my_project'
8
+ exit(1)
9
+ end
10
+
11
+ if File.exist?('Rakefile')
12
+ puts 'Rakefile exists.'
13
+ exit(1)
14
+ end
15
+
16
+ File.open('Rakefile', 'w'){ |file|
17
+ require 'erb'
18
+ project = args[:project]
19
+ author = `whoami`.chop
20
+
21
+ file <<
22
+ ERB.new(File.read("#{File.dirname(__FILE__)}/../templates/Rakefile.erb")).
23
+ result(binding)
24
+ }
25
+
26
+ puts 'Rakefile generated.'
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+
2
+ # forked from http://github.com/dkubb/dm-dev
3
+
4
+ namespace :st do
5
+ desc 'Strip trailing whitespace from source files, also normalize tabs to spaces, and an newline at end of file'
6
+ task :strip, :spaces do |t, args|
7
+ require 'source-tools'
8
+ require 'zlib'
9
+
10
+ spaces = ' ' * (args[:spaces] || 2).to_i
11
+
12
+ SourceTools.each_source_path{ |path|
13
+ # strat striping unnecessary whitespaces
14
+ result = path.open('r'){ |f| SourceTools.strip(f, spaces) }
15
+
16
+ # skip the file if it was not modified
17
+ next if Zlib.crc32(result) == Zlib.crc32(path.read)
18
+
19
+ puts "stripping #{path.relative_path_from(Pathname.new(Dir.pwd))}"
20
+ path.open('w'){ |f| f.write result }
21
+ }
22
+
23
+ end
24
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'bones'
5
+ Bones.setup
6
+ rescue LoadError
7
+ load 'tasks/setup.rb' # this line should already be there
8
+ end
9
+
10
+ PROJ.name = '<%= project %>'
11
+ PROJ.authors = '<%= author %>'
12
+ PROJ.email = '<%= author %>@<%= author %>.org'
13
+ PROJ.url = 'http://github.com/<%= author %>/<%= project %>'
14
+ PROJ.rubyforge.name = '<%= project %>'
15
+
16
+ # PROJ.gem.dependencies << ['source-tools', '>=0.5.0']
17
+ # PROJ.gem.development_dependencies << ['minitest', '>=1.3.0']
18
+ # PROJ.gem.executables = ["bin/#{PROJ.name}"]
19
+
20
+ # PROJ.ruby_opts.delete '-w'
21
+
22
+ PROJ.description = PROJ.summary = paragraphs_of('README', 'description').join("\n\n")
23
+ PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
24
+ PROJ.version = File.read("lib/#{PROJ.name}/version.rb").gsub(/.*VERSION = '(.*)'.*/m, '\1')
25
+
26
+ PROJ.manifest_file = 'Manifest'
27
+ PROJ.exclude += ['^Manifest$', '^tmp', 'tmp$', '^pkg',
28
+ '^\.gitignore$', '^ann-', '\.sqlite3$', '\.db$']
29
+
30
+ PROJ.rdoc.remote_dir = PROJ.name
31
+
32
+ PROJ.readme_file = 'README'
33
+ PROJ.rdoc.main = 'README'
34
+ PROJ.rdoc.exclude += ['Rakefile', '^tasks', '^test']
35
+ PROJ.rdoc.include << '\w+'
36
+ PROJ.rdoc.opts << '--diagram' if !WIN32 and `which dot` =~ %r/\/dot/
37
+ PROJ.rdoc.opts += ['--charset=utf-8', '--inline-source',
38
+ '--line-numbers', '--promiscuous']
39
+
40
+ PROJ.spec.opts << '--color'
41
+
42
+ PROJ.ann.file = "ann-#{PROJ.name}-#{PROJ.version}"
43
+ PROJ.ann.paragraphs.concat %w[LINKS SYNOPSIS REQUIREMENTS INSTALL LICENSE]
44
+
45
+ CLEAN.include Dir['**/*.rbc']
46
+
47
+ task :default do
48
+ Rake.application.options.show_task_pattern = /./
49
+ Rake.application.display_tasks_and_comments
50
+ end
51
+
52
+ namespace :gem do
53
+ desc "create #{PROJ.name}.gemspec"
54
+ task 'gemspec' do
55
+ puts "rake gem:debug > #{PROJ.name}.gemspec"
56
+ File.open("#{PROJ.name}.gemspec", 'w'){|spec| spec << `rake gem:debug`.sub(/.*/, '')}
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module SourceTools
2
+ VERSION = '0.5.0'
3
+ end
@@ -0,0 +1,37 @@
1
+
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{source-tools}
6
+ s.version = "0.5.0"
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.authors = ["Lin Jen-Shin (a.k.a. godfat \347\234\237\345\270\270)"]
10
+ s.date = %q{2009-01-06}
11
+ s.default_executable = %q{source-tools}
12
+ s.description = %q{}
13
+ s.email = %q{godfat (XD) godfat.org}
14
+ s.executables = ["source-tools"]
15
+ s.extra_rdoc_files = ["CHANGES", "README", "bin/source-tools", "lib/source-tools/bin.rake", "lib/source-tools/default.rake", "lib/source-tools/tasks/chmod.rake", "lib/source-tools/tasks/rakefile.rake", "lib/source-tools/tasks/strip.rake", "source-tools.gemspec"]
16
+ s.files = ["CHANGES", "README", "Rakefile", "bin/source-tools", "lib/source-tools.rb", "lib/source-tools/bin.rake", "lib/source-tools/default.rake", "lib/source-tools/tasks.rb", "lib/source-tools/tasks/chmod.rake", "lib/source-tools/tasks/rakefile.rake", "lib/source-tools/tasks/strip.rake", "lib/source-tools/templates/Rakefile.erb", "lib/source-tools/version.rb", "source-tools.gemspec"]
17
+ s.has_rdoc = true
18
+ s.homepage = %q{http://github.com/godfat/source-tools}
19
+ s.rdoc_options = ["--diagram", "--charset=utf-8", "--inline-source", "--line-numbers", "--promiscuous", "--main", "README"]
20
+ s.require_paths = ["lib"]
21
+ s.rubyforge_project = %q{ludy}
22
+ s.rubygems_version = %q{1.3.1}
23
+ s.summary = %q{}
24
+
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 2
28
+
29
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
+ s.add_development_dependency(%q<bones>, [">= 2.2.0"])
31
+ else
32
+ s.add_dependency(%q<bones>, [">= 2.2.0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<bones>, [">= 2.2.0"])
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: godfat-source-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - "Lin Jen-Shin (a.k.a. godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-06 00:00:00 -08:00
13
+ default_executable: source-tools
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bones
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.2.0
23
+ version:
24
+ description: ""
25
+ email: godfat (XD) godfat.org
26
+ executables:
27
+ - source-tools
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - CHANGES
32
+ - README
33
+ - bin/source-tools
34
+ - lib/source-tools/bin.rake
35
+ - lib/source-tools/default.rake
36
+ - lib/source-tools/tasks/chmod.rake
37
+ - lib/source-tools/tasks/rakefile.rake
38
+ - lib/source-tools/tasks/strip.rake
39
+ - source-tools.gemspec
40
+ files:
41
+ - CHANGES
42
+ - README
43
+ - Rakefile
44
+ - bin/source-tools
45
+ - lib/source-tools.rb
46
+ - lib/source-tools/bin.rake
47
+ - lib/source-tools/default.rake
48
+ - lib/source-tools/tasks.rb
49
+ - lib/source-tools/tasks/chmod.rake
50
+ - lib/source-tools/tasks/rakefile.rake
51
+ - lib/source-tools/tasks/strip.rake
52
+ - lib/source-tools/templates/Rakefile.erb
53
+ - lib/source-tools/version.rb
54
+ - source-tools.gemspec
55
+ has_rdoc: true
56
+ homepage: http://github.com/godfat/source-tools
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --diagram
60
+ - --charset=utf-8
61
+ - --inline-source
62
+ - --line-numbers
63
+ - --promiscuous
64
+ - --main
65
+ - README
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: ludy
83
+ rubygems_version: 1.2.0
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: ""
87
+ test_files: []
88
+