mozart-rails 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTEyMWNiODY0MzM2ODM2NjRmMTk1OWY5ZmM1MjczZTlmMjk5YWUwNA==
5
+ data.tar.gz: !binary |-
6
+ NDdmODBjODYzZGU5ZGJiMDgyYjYyOGJhOTNmMjE4ZWIxNzhiOTRmNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MzUyYWNjZTgyNjZkODM4NDRmMTA3N2M3MDg3MzM4NWY4NTQxZGNiZjdjYTkz
10
+ M2NmYjIxNDQzNTNhZTE1OGVmZDJhN2UzOWVmOTkxNTNhMDRiM2EyZTlhYjdh
11
+ MmE4ZWE0MDYyNzViOTEwYzQzYTI2YzhhNmUxZWFmMjIyYTE3NTI=
12
+ data.tar.gz: !binary |-
13
+ ODk5MjU2NDAzN2U1MGIwNjEzMjg2ZDhjNDhiNThkODBjYWVmNjFlM2Y0ZDli
14
+ NmFhZTNhNzI5YmQwM2RmYmNjYzA4YzY3YTIzNDc4ZjdkNzIwMzBiMWMxYzdj
15
+ MGU3YjgyYWM4NjdkMGM5NjNhYTg1MGEwNjAxZWMyYjJmYmNjODk=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mozart-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sasha Gerrand
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Mozart::Rails
2
+
3
+ Mozart! For Rails!
4
+
5
+ This gem provides:
6
+
7
+ * Mozart 0.1.8
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ For Rails 3.0 apps, add the mozart-rails gem to your Gemfile.
14
+
15
+ gem 'mozart-rails'
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself via:
22
+
23
+ $ bundle exec rake build
24
+ $ gem install --local pkg/mozart-rails-1.0.0.gem
25
+
26
+ ### Rails 3.1 or greater
27
+
28
+ The mozart files will be added to the asset pipeline and available for you to
29
+ use. If they're not already in app/assets/javascripts/application.js by default,
30
+ add these lines:
31
+
32
+ //= require mozart
33
+
34
+ ## Usage
35
+
36
+ TODO: Write usage instructions here
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :release => [:clean, :copy_source_files, :guard_version]
4
+
5
+ task :guard_version do
6
+ def check_version(file, pattern, constant)
7
+ body = File.read("vendor/assets/javascripts/#{file}")
8
+ match = body.match(pattern) or abort "Version check failed: no pattern matched in #{file}"
9
+ file_version = match[1]
10
+ constant_version = Mozart::Rails.const_get(constant)
11
+
12
+ unless constant_version == file_version
13
+ abort "Mozart::Rails::#{constant} was #{constant_version} but it should be #{file_version}"
14
+ end
15
+ end
16
+
17
+ check_version("mozart.min.js", /\/\*\! Mozart v([\S]+)/, 'MOZART_VERSION')
18
+ end
19
+
20
+ desc "Remove JavaScript asset files"
21
+ task :clean do
22
+ puts "Removing JavaScript assets"
23
+
24
+ Dir.glob("vendor/assets/javascripts/*.js").each do |file|
25
+ puts "Removing #{file}"
26
+ File.unlink file
27
+ end
28
+ end
29
+
30
+ desc "Copy source files into the assets directory"
31
+ task :copy_source_files do
32
+ require 'fileutils'
33
+
34
+ VENDOR_PATH = "vendor/mozart-empty/app/assets/js"
35
+ ASSETS_PATH = "vendor/assets/javascripts"
36
+
37
+ [
38
+ "handlebars-#{Mozart::Rails::HANDLEBARS_VERSION}",
39
+ "jquery-#{Mozart::Rails::JQUERY_VERSION}",
40
+ "mozart.min",
41
+ "underscore-#{Mozart::Rails::UNDERSCORE_VERSION}",
42
+ ].each do |file|
43
+ if File.file? File.join(ASSETS_PATH, "#{file}.js")
44
+ puts "File exists: #{File.join(ASSETS_PATH, "#{file.gsub(/-.+/, '')}.js")}, skipping"
45
+ else
46
+ FileUtils.cp File.join(VENDOR_PATH, "#{file}.js"), File.join(ASSETS_PATH, "#{file.gsub(/-.+/, '')}.js")
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,43 @@
1
+ require 'rails'
2
+
3
+ # Supply generator for Rails 3.0.x or if asset pipeline is not enabled
4
+ if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled
5
+ module Mozart
6
+ module Generators
7
+ class InstallGenerator < ::Rails::Generators::Base
8
+
9
+ desc "This generator installs Mozart #{Mozart::Rails::MOZART_VERSION}"
10
+ source_root File.expand_path('../../../../../vendor/assets/javascripts/mozart/vendor/scripts', __FILE__)
11
+
12
+ def copy_mozart
13
+ say_status("copying", "Mozart (#{Mozart::Rails::MOZART_VERSION})", :green)
14
+ copy_file "mozart.js", "public/javascripts/mozart.js"
15
+ copy_file "handlebars.js", "public/javascripts/handlebars.js"
16
+ copy_file "jquery.js", "public/javascripts/jquery.js"
17
+ copy_file "underscore.js", "public/javascripts/underscore.js"
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ else
24
+ module Mozart
25
+ module Generators
26
+ class InstallGenerator < ::Rails::Generators::Base
27
+ desc "Just show instructions so people will know what to do when mistakenly using generator for Rails 3.1 apps"
28
+
29
+ def do_nothing
30
+ say_status("deprecated", "You are using Rails 3.1 with the asset pipeline enabled, so this generator is not needed.")
31
+ say_status("", "The necessary files are already in your asset pipeline.")
32
+ say_status("", "Just add the following to your app/assets/javascripts/application.js")
33
+ say_status("", "//= require mozart")
34
+ say_status("", "//= require handlebars")
35
+ say_status("", "//= require jquery")
36
+ say_status("", "//= require underscore")
37
+ say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.")
38
+ # ok, nothing
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ module ActionDispatch
2
+ module Assertions
3
+ module SelectorAssertions
4
+
5
+ PATTERN_HTML = %Q{"((\\\\\"|[^\"])*)"}
6
+ PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
7
+
8
+ private
9
+
10
+ # Unescapes a JS string.
11
+ def unescape_js(js_string)
12
+ # js encodes double quotes and line breaks.
13
+ unescaped= js_string.gsub('\"', '"')
14
+ unescaped.gsub!('\\\'', "'")
15
+ unescaped.gsub!(/\\\//, '/')
16
+ unescaped.gsub!('\n', "\n")
17
+ unescaped.gsub!('\076', '>')
18
+ unescaped.gsub!('\074', '<')
19
+ # js encodes non-ascii characters.
20
+ unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
21
+ unescaped
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ module Mozart
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,16 @@
1
+ module Mozart
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ config.before_configuration do
5
+ if config.action_view.javascript_expansions
6
+ if ::Rails.root.join("public/javascripts/mozart.js").exist?
7
+ mzrt_defaults = %w(mozart handlebars jquery underscore)
8
+ # mzrt_defaults.map!{|a| a + ".min" } if ::Rails.env.production? || ::Rails.env.test?
9
+ else
10
+ # mzrt_defaults = ::Rails.env.production? || ::Rails.env.test? ? %w(mozart.min) : %w(mozart)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module Mozart
2
+ module Rails
3
+ VERSION = "1.0.0"
4
+
5
+ # Static JavaScript asset versions
6
+ HANDLEBARS_VERSION = "1.0.rc.1"
7
+ JQUERY_VERSION = "1.9.1"
8
+ MOZART_VERSION = "0.1.8"
9
+ UNDERSCORE_VERSION = "min"
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'mozart/assert_select' if ::Rails.env.test?
2
+ require 'mozart/rails/engine' if ::Rails.version >= '3.1'
3
+ require 'mozart/rails/railtie'
4
+ require 'mozart/rails/version'
5
+
6
+ module Mozart
7
+ module Rails
8
+
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ require 'mozart/rails'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mozart/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mozart-rails"
8
+ spec.version = Mozart::Rails::VERSION
9
+ spec.authors = ["Sasha Gerrand"]
10
+ spec.email = ["sasha.gerrand@bigcommerce.com"]
11
+ spec.description = %q{Use Mozart with Rails 3}
12
+ spec.summary = %q{This gem provides Mozart for your Rails 3 application.}
13
+ spec.homepage = "https://mozart.io"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = %w{Gemfile LICENSE.txt mozart-rails.gemspec Rakefile README.md}
17
+ spec.files += Dir.glob('lib/*.rb')
18
+ spec.files += Dir.glob('lib/**/*.rb')
19
+ spec.files += Dir.glob('vendor/assets/javascripts/*.js')
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_runtime_dependency "sass"
27
+ end