railscheck 0.1.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/History.txt +7 -0
- data/License.txt +27 -0
- data/Manifest.txt +32 -0
- data/README.txt +112 -0
- data/Rakefile +4 -0
- data/TODO.txt +27 -0
- data/bin/jrailscheck +3 -0
- data/bin/jrailscheck.bat +3 -0
- data/bin/railscheck +3 -0
- data/bin/railscheck.bat +3 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +15 -0
- data/lib/railscheck/testcase.rb +16 -0
- data/lib/railscheck/version.rb +9 -0
- data/lib/railscheck.rb +93 -0
- data/lib/test/tc_config.rb +16 -0
- data/lib/test/tc_database_models.rb +43 -0
- data/lib/test/tc_html_and_css.rb +55 -0
- data/lib/test/tc_project.rb +106 -0
- data/lib/test/tc_views.rb +27 -0
- data/log/debug.log +0 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +10 -0
- data/test/test_helper.rb +2 -0
- data/test/test_railscheck.rb +11 -0
- data/website/index.html +18 -0
- metadata +94 -0
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'railscheck/testcase'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Railscheck
         | 
| 4 | 
            +
              module Test
         | 
| 5 | 
            +
                class Views < Railscheck::TestCase
         | 
| 6 | 
            +
                  module TempTemplates; end # Container for template evaluation.
         | 
| 7 | 
            +
                          
         | 
| 8 | 
            +
                  # Test that every erb/rhtml file in the project can parse (except vendor plugins/rails).
         | 
| 9 | 
            +
                  def test_views_can_parse
         | 
| 10 | 
            +
                    # Nb. This task is inspired by a snippet by dseverin (http://snippets.dzone.com/posts/show/3397)        
         | 
| 11 | 
            +
                    Dir["#{RAILS_ROOT}/app/views/**/*.erb", "#{RAILS_ROOT}/app/views/**/*.rhtml"].each do |fname|
         | 
| 12 | 
            +
                      local_source = ERB.new(IO.read(fname), nil, '-').src
         | 
| 13 | 
            +
                      template_source = "def _tmpl\n#{local_source}\nend"
         | 
| 14 | 
            +
                      
         | 
| 15 | 
            +
                      assert_nothing_raised("Syntax error in \"#{fname}\".") do
         | 
| 16 | 
            +
                        begin 
         | 
| 17 | 
            +
                          TempTemplates.module_eval(template_source, fname, 0 )
         | 
| 18 | 
            +
                        rescue SyntaxError => e
         | 
| 19 | 
            +
                          t = ActionView::TemplateError.new("#{RAILS_ROOT}/app/views/", fname, {}, template_source, e)
         | 
| 20 | 
            +
                          raise SyntaxError.new("Error (#{t.message}) on line ##{t.line_number} of #{t.file_name}")
         | 
| 21 | 
            +
                        end  
         | 
| 22 | 
            +
                      end
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                  end 
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/log/debug.log
    ADDED
    
    | 
            File without changes
         | 
    
        data/script/console
    ADDED
    
    | @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # File: script/console
         | 
| 3 | 
            +
            irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            libs =  " -r irb/completion"
         | 
| 6 | 
            +
            # Perhaps use a console_lib to store any extra methods I may want available in the cosole
         | 
| 7 | 
            +
            # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
         | 
| 8 | 
            +
            libs <<  " -r #{File.dirname(__FILE__) + '/../lib/railscheck.rb'}"
         | 
| 9 | 
            +
            puts "Loading railscheck gem"
         | 
| 10 | 
            +
            exec "#{irb} #{libs} --simple-prompt"
         | 
    
        data/script/destroy
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            begin
         | 
| 5 | 
            +
              require 'rubigen'
         | 
| 6 | 
            +
            rescue LoadError
         | 
| 7 | 
            +
              require 'rubygems'
         | 
| 8 | 
            +
              require 'rubigen'
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
            require 'rubigen/scripts/destroy'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ARGV.shift if ['--help', '-h'].include?(ARGV[0])
         | 
| 13 | 
            +
            RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
         | 
| 14 | 
            +
            RubiGen::Scripts::Destroy.new.run(ARGV)
         | 
    
        data/script/generate
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            begin
         | 
| 5 | 
            +
              require 'rubigen'
         | 
| 6 | 
            +
            rescue LoadError
         | 
| 7 | 
            +
              require 'rubygems'
         | 
| 8 | 
            +
              require 'rubigen'
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
            require 'rubigen/scripts/generate'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ARGV.shift if ['--help', '-h'].include?(ARGV[0])
         | 
| 13 | 
            +
            RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
         | 
| 14 | 
            +
            RubiGen::Scripts::Generate.new.run(ARGV)
         | 
    
        data/script/txt2html
    ADDED
    
    | @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            begin
         | 
| 5 | 
            +
              require 'newgem'
         | 
| 6 | 
            +
            rescue LoadError
         | 
| 7 | 
            +
              puts "\n\nGenerating the website requires the newgem RubyGem"
         | 
| 8 | 
            +
              puts "Install: gem install newgem\n\n"
         | 
| 9 | 
            +
              exit(1)
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
            require 'redcloth'
         | 
| 12 | 
            +
            require 'syntax/convertors/html'
         | 
| 13 | 
            +
            require 'erb'
         | 
| 14 | 
            +
            require File.dirname(__FILE__) + '/../lib/railscheck/version.rb'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            version  = Railscheck::VERSION::STRING
         | 
| 17 | 
            +
            download = 'http://rubyforge.org/projects/railscheck'
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            class Fixnum
         | 
| 20 | 
            +
              def ordinal
         | 
| 21 | 
            +
                # teens
         | 
| 22 | 
            +
                return 'th' if (10..19).include?(self % 100)
         | 
| 23 | 
            +
                # others
         | 
| 24 | 
            +
                case self % 10
         | 
| 25 | 
            +
                when 1: return 'st'
         | 
| 26 | 
            +
                when 2: return 'nd'
         | 
| 27 | 
            +
                when 3: return 'rd'
         | 
| 28 | 
            +
                else    return 'th'
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            class Time
         | 
| 34 | 
            +
              def pretty
         | 
| 35 | 
            +
                return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            def convert_syntax(syntax, source)
         | 
| 40 | 
            +
              return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
         | 
| 41 | 
            +
            end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            if ARGV.length >= 1
         | 
| 44 | 
            +
              src, template = ARGV
         | 
| 45 | 
            +
              template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
         | 
| 46 | 
            +
              
         | 
| 47 | 
            +
            else
         | 
| 48 | 
            +
              puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
         | 
| 49 | 
            +
              exit!
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            template = ERB.new(File.open(template).read)
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            title = nil
         | 
| 55 | 
            +
            body = nil
         | 
| 56 | 
            +
            File.open(src) do |fsrc|
         | 
| 57 | 
            +
              title_text = fsrc.readline
         | 
| 58 | 
            +
              body_text = fsrc.read
         | 
| 59 | 
            +
              syntax_items = []
         | 
| 60 | 
            +
              body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
         | 
| 61 | 
            +
                ident = syntax_items.length
         | 
| 62 | 
            +
                element, syntax, source = $1, $2, $3
         | 
| 63 | 
            +
                syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
         | 
| 64 | 
            +
                "syntax-temp-#{ident}"
         | 
| 65 | 
            +
              }
         | 
| 66 | 
            +
              title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
         | 
| 67 | 
            +
              body = RedCloth.new(body_text).to_html
         | 
| 68 | 
            +
              body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
         | 
| 69 | 
            +
            end
         | 
| 70 | 
            +
            stat = File.stat(src)
         | 
| 71 | 
            +
            created = stat.ctime
         | 
| 72 | 
            +
            modified = stat.mtime
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            $stdout << template.result(binding)
         |