rails-erb-check 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "actionpack", "~> 3.0"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.5.2"
14
+ end
@@ -0,0 +1,53 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionpack (3.0.7)
6
+ activemodel (= 3.0.7)
7
+ activesupport (= 3.0.7)
8
+ builder (~> 2.1.2)
9
+ erubis (~> 2.6.6)
10
+ i18n (~> 0.5.0)
11
+ rack (~> 1.2.1)
12
+ rack-mount (~> 0.6.14)
13
+ rack-test (~> 0.5.7)
14
+ tzinfo (~> 0.3.23)
15
+ activemodel (3.0.7)
16
+ activesupport (= 3.0.7)
17
+ builder (~> 2.1.2)
18
+ i18n (~> 0.5.0)
19
+ activesupport (3.0.7)
20
+ builder (2.1.2)
21
+ diff-lcs (1.1.2)
22
+ erubis (2.6.6)
23
+ abstract (>= 1.0.0)
24
+ git (1.2.5)
25
+ i18n (0.5.0)
26
+ jeweler (1.5.2)
27
+ bundler (~> 1.0.0)
28
+ git (>= 1.2.5)
29
+ rake
30
+ rack (1.2.2)
31
+ rack-mount (0.6.14)
32
+ rack (>= 1.0.0)
33
+ rack-test (0.5.7)
34
+ rack (>= 1.0)
35
+ rake (0.8.7)
36
+ rspec (2.3.0)
37
+ rspec-core (~> 2.3.0)
38
+ rspec-expectations (~> 2.3.0)
39
+ rspec-mocks (~> 2.3.0)
40
+ rspec-core (2.3.1)
41
+ rspec-expectations (2.3.0)
42
+ diff-lcs (~> 1.1.2)
43
+ rspec-mocks (2.3.0)
44
+ tzinfo (0.3.27)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ actionpack (~> 3.0)
51
+ bundler (~> 1.0.0)
52
+ jeweler (~> 1.5.2)
53
+ rspec (~> 2.3.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 jugyo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ rails-erb-check
2
+ ====
3
+
4
+ A command to check syntax as rails's erb.
5
+ It provides the rails-erb-check command.
6
+
7
+ Usage
8
+ ----
9
+
10
+ $ gem install rails-erb-check
11
+ $ rails-erb-check app/views/**/*.html.erb
12
+
13
+ Copyright
14
+ ----
15
+
16
+ Copyright (c) 2011 jugyo. See LICENSE.txt for further details.
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "rails-erb-check"
15
+ gem.homepage = "http://github.com/jugyo/rails-erb-check"
16
+ gem.license = "MIT"
17
+ gem.summary = %Q{A command to check syntax as rails's erb.}
18
+ gem.description = %Q{A command to check syntax as rails's erb. It provides the rails-erb-check command.}
19
+ gem.email = "jugyo.org@gmail.com"
20
+ gem.authors = ["jugyo"]
21
+ end
22
+ Jeweler::RubygemsDotOrgTasks.new
23
+
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
26
+ RSpec::Core::RakeTask.new(:spec) do |spec|
27
+ spec.pattern = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path('../../lib', __FILE__)) if $0 == __FILE__
3
+ require 'rails-erb-check'
4
+
5
+ ARGV.each do |filepath|
6
+ if RailsErbCheck.valid_syntax?(File.read(filepath))
7
+ puts "#{filepath}\e[34m => \e[32mvalid\e[0m"
8
+ else
9
+ puts "#{filepath}\e[34m => \e[31minvalid\e[0m"
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'action_view'
2
+
3
+ module RailsErbCheck
4
+ def self.valid_syntax?(erb)
5
+ begin
6
+ ActionView::Template::Handlers::Erubis.new(erb).result
7
+ rescue SyntaxError
8
+ return false
9
+ rescue Exception
10
+ return true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ <!-- missing 'do' -->
2
+ <%= form_for @user |f| %>
3
+ <%= f.text_field :name %>
4
+ <%= f.submit %>
5
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <!-- missing '%>' -->
2
+ <%= form_for @user do |f|
3
+ <%= f.text_field :name %>
4
+ <%= f.submit %>
5
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <% foo = 'bar' %>
2
+ <%= foo %>
@@ -0,0 +1,5 @@
1
+ <!-- with block -->
2
+ <%= form_for @user do |f| %>
3
+ <%= f.text_field :name %>
4
+ <%= f.submit %>
5
+ <% end %>
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RailsErbCheck" do
4
+ def erb(name)
5
+ File.open(File.join(File.dirname(__FILE__), 'fixtures', name)).read
6
+ end
7
+
8
+ %w(valid1.erb valid2.erb).each do |erb_file|
9
+ it { RailsErbCheck.valid_syntax?(erb(erb_file)).should be_true }
10
+ end
11
+
12
+ %w(invalid1.erb invalid2.erb).each do |erb_file|
13
+ it { RailsErbCheck.valid_syntax?(erb(erb_file)).should be_false }
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'rails-erb-check'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-erb-check
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - jugyo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-27 00:00:00 +09:00
14
+ default_executable: rails-erb-check
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: actionpack
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "3.0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 2.3.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: jeweler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.5.2
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ description: A command to check syntax as rails's erb. It provides the rails-erb-check command.
61
+ email: jugyo.org@gmail.com
62
+ executables:
63
+ - rails-erb-check
64
+ extensions: []
65
+
66
+ extra_rdoc_files:
67
+ - LICENSE.txt
68
+ - README.md
69
+ files:
70
+ - .document
71
+ - .rspec
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - VERSION
78
+ - bin/rails-erb-check
79
+ - lib/rails-erb-check.rb
80
+ - spec/fixtures/invalid1.erb
81
+ - spec/fixtures/invalid2.erb
82
+ - spec/fixtures/valid1.erb
83
+ - spec/fixtures/valid2.erb
84
+ - spec/rails-erb-check_spec.rb
85
+ - spec/spec_helper.rb
86
+ has_rdoc: true
87
+ homepage: http://github.com/jugyo/rails-erb-check
88
+ licenses:
89
+ - MIT
90
+ post_install_message:
91
+ rdoc_options: []
92
+
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 533179752458817036
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.6.0
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: A command to check syntax as rails's erb.
117
+ test_files:
118
+ - spec/rails-erb-check_spec.rb
119
+ - spec/spec_helper.rb