raptest 0.1.1

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/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'sass'
4
+ gem 'coffee-script'
5
+ gem 'uglifier'
6
+
7
+ group :development do
8
+ gem "bundler"
9
+ gem "jeweler", "~> 1.8.4"
10
+ end
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coffee-script (2.2.0)
5
+ coffee-script-source
6
+ execjs
7
+ coffee-script-source (1.4.0)
8
+ execjs (1.4.0)
9
+ multi_json (~> 1.0)
10
+ git (1.2.5)
11
+ jeweler (1.8.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rdoc
16
+ json (1.7.6)
17
+ multi_json (1.5.0)
18
+ rake (10.0.3)
19
+ rdoc (3.12)
20
+ json (~> 1.4)
21
+ sass (3.2.5)
22
+ uglifier (1.3.0)
23
+ execjs (>= 0.3.0)
24
+ multi_json (~> 1.0, >= 1.0.2)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler
31
+ coffee-script
32
+ jeweler (~> 1.8.4)
33
+ sass
34
+ uglifier
@@ -0,0 +1,53 @@
1
+ # Raptest – Rails Assets Pipeline testing tool
2
+
3
+ **Raptest** plumbs Rails assets pipeline detecting any issue that may come out during and after deploy.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ gem install raptest
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ **Raptest** consists of a single executable that should be launched from the root of a Rails application.
14
+
15
+ Running `raptest` you can test one or more assets and all their dependencies against:
16
+ - ERB processing
17
+ - Coffeescript compilation
18
+ - Javascript minification through UglifyJs
19
+ - Sass compilation
20
+ - Css minification through Sass Compressor
21
+
22
+ The `raptest` command takes a list of assets as parameters
23
+
24
+ eg.
25
+
26
+ ```
27
+ raptest application.js admin/admin.js admin/admin.css
28
+ ```
29
+
30
+ ---
31
+
32
+ Copyright (c) 2012 mcasimir
33
+
34
+ MIT License
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining
37
+ a copy of this software and associated documentation files (the
38
+ "Software"), to deal in the Software without restriction, including
39
+ without limitation the rights to use, copy, modify, merge, publish,
40
+ distribute, sublicense, and/or sell copies of the Software, and to
41
+ permit persons to whom the Software is furnished to do so, subject to
42
+ the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be
45
+ included in all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
51
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
52
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
53
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "raptest"
18
+ gem.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails Assets Pipeline test}
21
+ gem.description = %Q{Rails Assets Pipeline test}
22
+ gem.email = "maurizio.cas@gmail.com"
23
+ gem.authors = ["mcasimir"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+
29
+ task :push do
30
+ message = ENV["message"] || "commit #{Time.now}"
31
+ `git add . && git commit -a -m '#{message}' && git push`
32
+ end
33
+
34
+ task "release:patch" do
35
+ Rake::Task["gemspec"].invoke
36
+ Rake::Task["version:bump:patch"]
37
+ Rake::Task["push"].invoke
38
+ Rake::Task["release"].invoke
39
+ end
40
+
41
+ task "release:minor" do
42
+ Rake::Task["gemspec"].invoke
43
+ Rake::Task["version:bump:minor"]
44
+ Rake::Task["push"].invoke
45
+ Rake::Task["release"].invoke
46
+ end
47
+
48
+ task "release:major" do
49
+ Rake::Task["gemspec"].invoke
50
+ Rake::Task["version:bump:major"]
51
+ Rake::Task["push"].invoke
52
+ Rake::Task["release"].invoke
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require File.expand_path('./config/application', Dir.pwd)
6
+ require 'raptest/test'
7
+ require 'raptest/test_error'
8
+
9
+ module Raptest
10
+ class Main
11
+ class << self
12
+ def run!(*args)
13
+
14
+ root_assets = args.map { |p| Rails.application.assets.find_asset( p ) }.compact
15
+ assets = []
16
+ assets += root_assets
17
+
18
+ root_assets.each do |root|
19
+ assets += root.dependencies
20
+ end
21
+
22
+ test = Raptest::Test.new(assets)
23
+ begin
24
+ test.run
25
+ rescue Raptest::TestError => e
26
+ puts "\n * #{e.component} Error in:\n#{e.file}\n -- #{e.message}"
27
+ end
28
+
29
+
30
+ puts "Completed in #{test.duration} sec: #{test.processed} processed files, #{test.errors} errors found."
31
+
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Raptest::Main.run!(ARGV.dup)
@@ -0,0 +1,25 @@
1
+ # Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
2
+ # Copyright:: Copyright (c) 2012 Maurizio Casimirri
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module Raptest
24
+
25
+ end
@@ -0,0 +1,101 @@
1
+ require 'rubygems'
2
+ require 'sass'
3
+ require 'coffee-script'
4
+ require 'uglifier'
5
+
6
+ require 'asset_tester/test_error'
7
+
8
+ module Raptest
9
+ class Asset
10
+
11
+ attr_accessor :pathname
12
+ def initialize(pathname)
13
+ @pathname = pathname
14
+ end
15
+
16
+ def js?
17
+ pathname =~ /\.js\b/
18
+ end
19
+
20
+ def css?
21
+ pathname =~ /\.css\b/
22
+ end
23
+
24
+ def coffee?
25
+ pathname =~ /\.coffee\b/
26
+ end
27
+
28
+ def scss?
29
+ pathname =~ /\.scss\b/
30
+ end
31
+
32
+ def sass?
33
+ pathname =~ /\.sass\b/
34
+ end
35
+
36
+ def erb?
37
+ coffee? || pathname =~ /\.erb\b/
38
+ end
39
+
40
+ def source
41
+ @source ||= File.read(pathname)
42
+ end
43
+
44
+ def result
45
+ @result
46
+ end
47
+
48
+ def test!
49
+ reset!
50
+ begin
51
+ erb! if erb?
52
+
53
+ if js?
54
+ coffee! if coffee?
55
+ uglify!
56
+ elsif css?
57
+ minify!
58
+ end
59
+ rescue Exception => e
60
+ raise ::Raptest::TestError.new(@component, pathname, message)
61
+ end
62
+
63
+ end
64
+
65
+ protected
66
+
67
+ def erb!
68
+ @component = "Erb"
69
+ view = ActionView::Base.new(ActionController::Base.view_paths, {})
70
+ @result = view.render( :inline => @result )
71
+ end
72
+
73
+ def coffee!
74
+ @component = "Coffeescript"
75
+ @result = CoffeeScript.compile( @result )
76
+ end
77
+
78
+ def uglify!
79
+ @component = "UglifyJs"
80
+ @result = Uglifier.compile( @result )
81
+ end
82
+
83
+ def minify!
84
+ @component = "Sass Compiler/Minifier"
85
+ @result = ::Sass::Engine.new(@result, {
86
+ :syntax => :scss,
87
+ :cache => false,
88
+ :read_cache => false,
89
+ :style => :compressed
90
+ }).render
91
+ end
92
+
93
+ private
94
+
95
+ def reset!
96
+ @component = nil
97
+ @result = source
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,33 @@
1
+ require 'asset_tester/asset'
2
+
3
+ module Raptest
4
+ class Test
5
+
6
+ attr_accessor :targets, :started_at, :finished_at, :errors, :processed
7
+
8
+ def initialize(*targets)
9
+ @targets = targets.map { |a|
10
+ ::Raptest::Asset.new(a)
11
+ }
12
+ end
13
+
14
+ def duration
15
+ @start_time && @end_time ? ( @end_time - @start_time ) : 0
16
+ end
17
+
18
+ def run
19
+ @started_at = Time.now
20
+ @errors = 0
21
+ @processed = 0
22
+
23
+
24
+ targets.each do |asset|
25
+ @processed += 1
26
+ asset.test!
27
+ end
28
+
29
+ @finished_at = Time.now
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Raptest
2
+ class TestError < Exception
3
+ attr_accessor :component, :file, :message
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "raptest"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["mcasimir"]
12
+ s.date = "2013-01-24"
13
+ s.description = "Rails Assets Pipeline test"
14
+ s.email = "maurizio.cas@gmail.com"
15
+ s.executables = ["raptest"]
16
+ s.extra_rdoc_files = [
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/raptest",
26
+ "lib/raptest.rb",
27
+ "lib/raptest/asset.rb",
28
+ "lib/raptest/test.rb",
29
+ "lib/raptest/test_error.rb",
30
+ "raptest.gemspec"
31
+ ]
32
+ s.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.24"
36
+ s.summary = "Rails Assets Pipeline test"
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<sass>, [">= 0"])
43
+ s.add_runtime_dependency(%q<coffee-script>, [">= 0"])
44
+ s.add_runtime_dependency(%q<uglifier>, [">= 0"])
45
+ s.add_development_dependency(%q<bundler>, [">= 0"])
46
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
47
+ else
48
+ s.add_dependency(%q<sass>, [">= 0"])
49
+ s.add_dependency(%q<coffee-script>, [">= 0"])
50
+ s.add_dependency(%q<uglifier>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, [">= 0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<sass>, [">= 0"])
56
+ s.add_dependency(%q<coffee-script>, [">= 0"])
57
+ s.add_dependency(%q<uglifier>, [">= 0"])
58
+ s.add_dependency(%q<bundler>, [">= 0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
60
+ end
61
+ end
62
+
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: raptest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mcasimir
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sass
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: coffee-script
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: uglifier
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.8.4
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.4
94
+ description: Rails Assets Pipeline test
95
+ email: maurizio.cas@gmail.com
96
+ executables:
97
+ - raptest
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - README.md
101
+ files:
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - README.md
105
+ - Rakefile
106
+ - VERSION
107
+ - bin/raptest
108
+ - lib/raptest.rb
109
+ - lib/raptest/asset.rb
110
+ - lib/raptest/test.rb
111
+ - lib/raptest/test_error.rb
112
+ - raptest.gemspec
113
+ homepage: http://github.com/mcasimir/kaminari-bootstrap
114
+ licenses:
115
+ - MIT
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ segments:
127
+ - 0
128
+ hash: 664801373201402740
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 1.8.24
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Rails Assets Pipeline test
141
+ test_files: []