Skip to content
This repository
Browse code

Remove cruft from Rakefile and gemspec

  • Loading branch information...
commit 9a64daf2a360a83761218828106ed7121f1b15c3 1 parent de2fdee
Norman Clarke norman authored
26 .yardopts
... ... @@ -1,11 +1,23 @@
1   ---readme README.md
2   ---markup markdown
3   ---markup-provider maruku
4   ---default-return ""
5   ---title "Haml Documentation"
6   ---query 'object.type != :classvariable'
7   ---query 'object.type != :constant || @api && @api.text == "public"'
  1 +--charset utf-8
  2 +--readme README.md
  3 +--markup markdown
  4 +--markup-provider maruku
  5 +--template-path yard
  6 +--default-return ""
  7 +--title "Haml Documentation"
  8 +--query 'object.type != :classvariable'
  9 +--query 'object.type != :constant || @api && @api.text == "public"'
  10 +--exclude lib/haml/template/patch.rb
  11 +--exclude lib/haml/template/plugin.rb
  12 +--exclude lib/haml/railtie.rb
  13 +--exclude lib/haml/helpers/action_view_mods.rb
  14 +--exclude lib/haml/helpers/xss_mods.rb
8 15 --hide-void-return
9 16 --protected
10 17 --no-private
11 18 --no-highlight
  19 +-
  20 +FAQ.md
  21 +CHANGELOG.md
  22 +REFERENCE.md
  23 +MIT-LICENSE
0  doc-src/CHANGELOG.md → CHANGELOG.md
File renamed without changes
0  doc-src/FAQ.md → FAQ.md
File renamed without changes
0  doc-src/REFERENCE.md → REFERENCE.md
File renamed without changes
215 Rakefile
... ... @@ -1,133 +1,27 @@
1   -# ----- Utility Functions -----
  1 +require "rake/clean"
  2 +require 'rake/testtask'
  3 +require 'rubygems/package_task'
  4 +
  5 +CLEAN << %w(pkg doc coverage .yardoc)
2 6
3 7 def scope(path)
4 8 File.join(File.dirname(__FILE__), path)
5 9 end
6 10
7   -# ----- Benchmarking -----
8   -
9   -desc <<END
10   -Benchmark haml against ERb.
11   - TIMES=n sets the number of runs. Defaults to 1000.
12   -END
  11 +desc "Benchmark Haml against ERb. TIMES=n sets the number of runs, default is 1000."
13 12 task :benchmark do
14 13 sh "ruby test/benchmark.rb #{ENV['TIMES']}"
15 14 end
16 15
17   -# ----- Default: Testing ------
18   -
19   -if ENV["RUN_CODE_RUN"] == "true"
20   - task :default => :"test:rails_compatibility"
21   -else
22   - task :default => :test
23   -end
24   -
25   -require 'rake/testtask'
26   -
27 16 Rake::TestTask.new do |t|
28 17 t.libs << 'lib'
29   - test_files = FileList[scope('test/**/*_test.rb')]
30   - test_files.exclude(scope('test/rails/*'))
31   - test_files.exclude(scope('test/plugins/*'))
32   - test_files.exclude(scope('test/haml-spec/*'))
33   - t.test_files = test_files
  18 + t.test_files = Dir["test/**/*_test.rb"].reject {|x| x =~ /haml-spec/}
34 19 t.verbose = true
35 20 end
36   -Rake::Task[:test].send(:add_comment, <<END)
37   -To run with an alternate version of Rails, make test/rails a symlink to that version.
38   -END
39   -
40   -# ----- Packaging -----
41   -
42   -# Don't use Rake::GemPackageTast because we want prerequisites to run
43   -# before we load the gemspec.
44   -desc "Build all the packages."
45   -task :package => [:revision_file, :submodules, :permissions] do
46   - version = get_version
47   - File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
48   - load scope('haml.gemspec')
49   - Gem::Builder.new(HAML_GEMSPEC).build
50   - sh %{git checkout VERSION}
51   -
52   - pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}"
53   - mkdir_p "pkg"
54   - verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
55   -
56   - sh %{rm -f pkg/#{pkg}.tar.gz}
57   - verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
58   - sh %{gzip pkg/#{pkg}.tar}
59   -end
60   -
61   -task :permissions do
62   - sh %{chmod -R a+rx bin}
63   - sh %{chmod -R a+r .}
64   - require 'shellwords'
65   - Dir.glob('test/**/*_test.rb') do |file|
66   - next if file =~ %r{^test/haml-spec/}
67   - sh %{chmod a+rx #{file}}
68   - end
69   -end
70   -
71   -task :revision_file do
72   - require scope('lib/haml')
73   -
74   - release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
75   - if Haml.version[:rev] && !release
76   - File.open(scope('REVISION'), 'w') { |f| f.puts Haml.version[:rev] }
77   - elsif release
78   - File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" }
79   - else
80   - File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
81   - end
82   -end
83   -
84   -# We also need to get rid of this file after packaging.
85   -at_exit { File.delete(scope('REVISION')) rescue nil }
86   -
87   -desc "Install Haml as a gem. Use SUDO=1 to install with sudo."
88   -task :install => [:package] do
89   - gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
90   - sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/haml-#{get_version}}
91   -end
92   -
93   -desc "Release a new Haml package to Rubyforge."
94   -task :release => [:check_release, :package] do
95   - name = File.read(scope("VERSION_NAME")).strip
96   - version = File.read(scope("VERSION")).strip
97   - sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
98   - sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
99   - sh %{gem push pkg/haml-#{version}.gem}
100   -end
101   -
102 21
103   -# Ensures that the VERSION file has been updated for a new release.
104   -task :check_release do
105   - version = File.read(scope("VERSION")).strip
106   - raise "There have been changes since current version (#{version})" if changed_since?(version)
107   - raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
108   -end
109   -
110   -# Reads a password from the command line.
111   -#
112   -# @param name [String] The prompt to use to read the password
113   -def read_password(prompt)
114   - require 'readline'
115   - system "stty -echo"
116   - Readline.readline("#{prompt}: ").strip
117   -ensure
118   - system "stty echo"
119   - puts
120   -end
121   -
122   -# Returns whether or not the repository, or specific files,
123   -# has/have changed since a given revision.
124   -#
125   -# @param rev [String] The revision to check against
126   -# @param files [Array<String>] The files to check.
127   -# If this is empty, checks the entire repository
128   -def changed_since?(rev, *files)
129   - IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
130   - return !$?.success?
  22 +gemspec = File.expand_path("../haml.gemspec", __FILE__)
  23 +if File.exist? gemspec
  24 + Gem::PackageTask.new(eval(File.read(gemspec))) { |pkg| }
131 25 end
132 26
133 27 task :submodules do
@@ -137,95 +31,26 @@ task :submodules do
137 31 end
138 32 end
139 33
140   -task :release_edge do
141   - ensure_git_cleanup do
142   - puts "#{'=' * 50} Running rake release_edge"
143   -
144   - sh %{git checkout master}
145   - sh %{git reset --hard origin/master}
146   - sh %{rake package}
147   - version = get_version
148   - sh %{rubyforge add_release haml haml "Bleeding Edge (v#{version})" pkg/haml-#{version}.gem}
149   - sh %{gem push pkg/haml-#{version}.gem}
150   - end
151   -end
152   -
153   -# Get the version string. If this is being installed from Git,
154   -# this includes the proper prerelease version.
155   -def get_version
156   - written_version = File.read(scope('VERSION').strip)
157   - return written_version unless File.exist?(scope('.git'))
158   -
159   - # Get the current master branch version
160   - version = written_version.split('.')
161   - version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
162   - return written_version unless version.size == 5 && version[3] == "alpha" # prerelease
163   -
164   - return written_version if (commit_count = `git log --pretty=oneline --first-parent stable.. | wc -l`).empty?
165   - version[4] = commit_count.strip
166   - version.join('.')
167   -end
168   -
169   -task :watch_for_update do
170   - sh %{ruby extra/update_watch.rb}
171   -end
172   -
173   -# ----- Documentation -----
174   -
175   -task :rdoc do
176   - puts '=' * 100, <<END, '=' * 100
177   -Haml uses the YARD documentation system (http://github.com/lsegal/yard).
178   -Install the yard gem and then run "rake doc".
179   -END
180   -end
181   -
182 34 begin
183 35 require 'yard'
184 36
185 37 namespace :doc do
186 38 desc "List all undocumented methods and classes."
187 39 task :undocumented do
188   - opts = ENV["YARD_OPTS"] || ""
189   - ENV["YARD_OPTS"] = opts.dup + <<OPTS
190   - --list --query "
191   - object.docstring.blank? &&
192   - !(object.type == :method && object.is_alias?)"
193   -OPTS
194   - Rake::Task['yard'].execute
  40 + command = 'yard --list --query '
  41 + command << '"object.docstring.blank? && '
  42 + command << '!(object.type == :method && object.is_alias?)"'
  43 + sh command
195 44 end
196 45 end
197 46
198   - YARD::Rake::YardocTask.new do |t|
199   - t.files = FileList.new(scope('lib/**/*.rb')) do |list|
200   - list.exclude('lib/haml/template/patch.rb')
201   - list.exclude('lib/haml/template/plugin.rb')
202   - list.exclude('lib/haml/railtie.rb')
203   - list.exclude('lib/haml/helpers/action_view_mods.rb')
204   - list.exclude('lib/haml/helpers/xss_mods.rb')
205   - end.to_a
206   - t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
207   - t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
208   - files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
209   - t.options << '--files' << files.join(',')
210   - t.options << '--template-path' << scope('yard')
211   - t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
212   -
213   - t.before = lambda do
214   - if ENV["YARD_OPTS"]
215   - require 'shellwords'
216   - t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
217   - end
218   - end
219   - end
220   - Rake::Task['yard'].instance_variable_set('@comment', nil)
  47 + desc "Generate documentation"
  48 + task(:doc) {sh "yard"}
  49 +
  50 + desc "Generate documentation incrementally"
  51 + task(:redoc) {sh "yard -c"}
221 52
222   - desc "Generate Documentation"
223   - task :doc => :yard
224   - task :redoc => :yard
225 53 rescue LoadError
226   - desc "Generate Documentation"
227   - task :doc => :rdoc
228   - task :yard => :rdoc
229 54 end
230 55
231 56 task :pages do
@@ -287,7 +112,7 @@ END
287 112 Haml::Engine.new(file).def_method(obj, :render)
288 113 result = RubyProf.profile { times.times { obj.render } }
289 114
290   - RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
  115 + RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
291 116 end
292 117 rescue LoadError; end
293 118
42 haml.gemspec
... ... @@ -1,19 +1,17 @@
1   -require 'rubygems'
  1 +Gem::Specification.new do |spec|
  2 + spec.name = 'haml'
  3 + spec.summary = "An elegant, structured (X)HTML/XML templating engine."
  4 + spec.version = File.read(File.dirname(__FILE__) + '/VERSION').strip
  5 + spec.authors = ['Nathan Weizenbaum', 'Hampton Catlin', 'Norman Clarke']
  6 + spec.email = ['haml@googlegroups.com', 'norman@njclarke.com']
2 7
3   -HAML_GEMSPEC = Gem::Specification.new do |spec|
4   - spec.name = 'haml'
5   - spec.summary = "An elegant, structured XHTML/XML templating engine."
6   - spec.version = File.read(File.dirname(__FILE__) + '/VERSION').strip
7   - spec.authors = ['Nathan Weizenbaum', 'Hampton Catlin', 'Norman Clarke']
8   - spec.email = ['haml@googlegroups.com', 'norman@njclarke.com']
9   - spec.description = <<-END
10   - Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML
11   - that's designed to express the structure of (X)HTML or XML documents in a
12   - non-repetitive, elegant, easy way, using indentation rather than closing
13   - tags and allowing Ruby to be embedded with ease. It was originally
14   - envisioned as a plugin for Ruby on Rails, but it can function as a
15   - stand-alone templating engine.
16   - END
  8 + readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
  9 + spec.executables = ['haml', 'html2haml']
  10 + spec.files = Dir['rails/init.rb', 'lib/**/*', 'bin/*', 'test/**/*',
  11 + 'extra/**/*', 'Rakefile', 'init.rb', '.yardopts'] + readmes
  12 + spec.homepage = 'http://haml-lang.com/'
  13 + spec.has_rdoc = false
  14 + spec.test_files = Dir["test/**/*_test.rb"].reject {|x| x =~ /haml-spec/}
17 15
18 16 spec.add_development_dependency 'yard', '>= 0.5.3'
19 17 spec.add_development_dependency 'maruku', '>= 0.5.9'
@@ -22,11 +20,11 @@ HAML_GEMSPEC = Gem::Specification.new do |spec|
22 20 spec.add_development_dependency 'rails'
23 21 spec.add_development_dependency 'ruby_parser'
24 22
25   - readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
26   - spec.executables = ['haml', 'html2haml']
27   - spec.files = Dir['rails/init.rb', 'lib/**/*', 'bin/*', 'test/**/*',
28   - 'extra/**/*', 'Rakefile', 'init.rb', '.yardopts'] + readmes
29   - spec.homepage = 'http://haml-lang.com/'
30   - spec.has_rdoc = false
31   - spec.test_files = Dir['test/**/*_test.rb']
  23 + spec.description = <<-END
  24 +Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
  25 +designed to express the structure of documents in a non-repetitive, elegant, and
  26 +easy way by using indentation rather than closing tags and allowing Ruby to be
  27 +embedded with ease. It was originally envisioned as a plugin for Ruby on Rails,
  28 +but it can function as a stand-alone templating engine.
  29 +END
32 30 end

0 comments on commit 9a64daf

Please sign in to comment.
Something went wrong with that request. Please try again.