sprockets-nyny 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21fcc10ddc5e3d1da49460047294549b06742a43
4
+ data.tar.gz: b263b63cc69267c05e22198a337090f81bd89a2e
5
+ SHA512:
6
+ metadata.gz: 3ba563e35d7ef562c49040a2e83b0439135ebef2d05abf399df3d5ee851a83f2b6e46c23073b09942d26b1da2b794acbf6681a341904be4d3cf4fb624eb86bac
7
+ data.tar.gz: 2750e6e3a4ca434acc9384e8155216ba56ded6755bc510e803d05b87c564b8a8790549c3db521fabf4a3bc48773358e3d0aa7b754d5a2df83bc06efe04384c7b
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.sublime-project
19
+ *.sublime-workspace
20
+ test/public
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sprockets-nyny.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andrei Lisnic
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.
@@ -0,0 +1,76 @@
1
+ # Sprockets::NYNY
2
+
3
+ Provides integration for asset pipeline into New York, New York
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sprockets-nyny'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sprockets-nyny
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'nyny'
23
+ require 'sprockets/nyny'
24
+
25
+ class App < NYNY::App
26
+ register Sprockets::NYNY
27
+
28
+ get '/' do
29
+ #...
30
+ end
31
+ end
32
+ ```
33
+
34
+ After that, you can use `javascript_include_tag` and other assets pipeline
35
+ goodies in views, as you are used to in Rails.
36
+
37
+ ## Configuring
38
+
39
+ You can configure the asset pipeline the same way you configure it in Rails:
40
+ ```ruby
41
+ class App < NYNY::App
42
+ register Sprockets::NYNY
43
+
44
+ config.assets.debug = true
45
+ ...
46
+
47
+ #...
48
+ end
49
+ ```
50
+ You can view the configuration defaults [here][defaults]
51
+
52
+ ## Compiling for production
53
+ For that, you need a Rakefile:
54
+ ```ruby
55
+ require 'sprockets/nyny'
56
+ require_relative 'server'
57
+
58
+ Sprockets::NYNY.load_tasks(App)
59
+
60
+ task :environment do
61
+ App.new #=> needed for the the hooks to run, add your env logic below
62
+ end
63
+ ```
64
+ (where server.rb is the file with the code of your app)
65
+
66
+ `rake assets:precompile` - will compile to the `public` path
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it ( http://github.com/<my-github-username>/sprockets-nyny/fork )
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
75
+
76
+ [defaults]: https://github.com/alisnic/sprockets-nyny/blob/master/lib/sprockets/nyny/builder.rb#L6
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,52 @@
1
+ require 'rack'
2
+ require 'sprockets/nyny/version'
3
+ require 'sprockets/nyny/builder'
4
+
5
+ module Rack
6
+ class Builder
7
+ #1.6 backport
8
+ def warmup(prc=nil, &block)
9
+ @warmup = prc || block
10
+ end
11
+
12
+ alias_method :build_app, :to_app
13
+ def to_app
14
+ @warmup.call if @warmup
15
+ build_app
16
+ end
17
+ end
18
+ end
19
+
20
+ module Sprockets
21
+ module NYNY
22
+ def self.load_tasks app
23
+ require 'sprockets/rails/task'
24
+ Sprockets::Rails::Task.new(app)
25
+ end
26
+
27
+ def root
28
+ ::NYNY.root
29
+ end
30
+
31
+ def before_run &block
32
+ before_run_hooks << Proc.new(&block)
33
+ end
34
+
35
+ def self.registered app
36
+ app.send :include, ActiveSupport::Configurable
37
+ app.inheritable :before_run_hooks, []
38
+
39
+ app.helpers ActionView::Helpers::AssetUrlHelper
40
+ app.helpers ActionView::Helpers::AssetTagHelper
41
+ app.helpers Sprockets::Rails::Helper
42
+
43
+ Builder.build_environment(app)
44
+ Builder.build_config(app.config)
45
+ Builder.add_hooks(app)
46
+
47
+ app.builder.warmup do
48
+ app.before_run_hooks.each {|h| h.call(app)}
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,70 @@
1
+ require 'sprockets/rails/helper'
2
+
3
+ module Sprockets
4
+ module NYNY
5
+ class Builder
6
+ def self.build_config config
7
+ config.assets = ActiveSupport::OrderedOptions.new
8
+ config.assets._blocks = []
9
+ config.assets.paths = ['app/assets/javascripts',
10
+ 'app/assets/stylesheets', 'app/assets/images']
11
+ config.assets.prefix = "/assets"
12
+ config.assets.precompile = [/(?:\/|\\|\A)application\.(css|js)$/]
13
+ config.assets.version = ""
14
+ config.assets.debug = false
15
+ config.assets.compile = !::NYNY.env.production?
16
+ config.assets.digest = ::NYNY.env.production?
17
+ end
18
+
19
+ def self.build_environment app
20
+ sprockets = Sprockets::Environment.new do |env|
21
+ env.version = ::NYNY.env
22
+ path = ::NYNY.root.join "/tmp/cache/assets/#{::NYNY.env}"
23
+ env.cache = Sprockets::Cache::FileStore.new(path)
24
+ env.logger = Logger.new(STDOUT)
25
+ end
26
+
27
+ app.inheritable :assets, sprockets
28
+ end
29
+
30
+ def self.configure_scope config, app
31
+ config.assets.paths.each do |path|
32
+ app.assets.append_path path
33
+ end
34
+
35
+ app.scope_class.debug_assets = config.assets.debug
36
+ app.scope_class.digest_assets = config.assets.digest
37
+ app.scope_class.assets_prefix = config.assets.prefix
38
+
39
+ manifest_path = "#{::NYNY.root}/public#{config.assets.prefix}"
40
+
41
+ if config.assets.compile
42
+ app.scope_class.assets_environment = app.assets
43
+ app.scope_class.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
44
+ else
45
+ app.use Rack::Static, :urls => ['/assets'], :root => 'public'
46
+ app.scope_class.assets_manifest = Sprockets::Manifest.new(manifest_path)
47
+ end
48
+ end
49
+
50
+ def self.add_hooks app
51
+ app.before_run do |app|
52
+ config = app.config
53
+
54
+ unless config.assets.version.blank?
55
+ app.assets.version += "-#{config.assets.version}"
56
+ end
57
+
58
+ configure_scope(config, app)
59
+ app.assets.js_compressor = config.assets.js_compressor
60
+ app.assets.css_compressor = config.assets.css_compressor
61
+ app.assets = app.assets.index if ::NYNY.env.production?
62
+
63
+ if config.assets.compile
64
+ app.builder.map (config.assets.prefix) { run app.assets }
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ module Sprockets
2
+ module NYNY
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sprockets/nyny/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sprockets-nyny"
8
+ spec.version = Sprockets::NYNY::VERSION
9
+ spec.authors = ["Andrei Lisnic"]
10
+ spec.email = ["andrei.lisnic@gmail.com"]
11
+ spec.summary = %q{assets pipeline for NYNY}
12
+ spec.description = %q{Provides integration for asset pipeline into New York, New York}
13
+ spec.homepage = "https://github.com/alisnic/sprockets-nyny"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "sprockets-rails", "~> 2.0.1"
24
+ spec.add_dependency "nyny", "~> 3.2.2"
25
+ end
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sprockets'
4
+ gem 'nyny'
5
+ gem 'haml'
6
+ gem 'coffee-script'
7
+
@@ -0,0 +1,8 @@
1
+ require 'sprockets/nyny'
2
+ require_relative 'server'
3
+
4
+ Sprockets::NYNY.load_tasks(App)
5
+
6
+ task :environment do
7
+ App.new
8
+ end
@@ -0,0 +1,3 @@
1
+ #= require foo
2
+
3
+ console.log 'application loaded'
@@ -0,0 +1 @@
1
+ console.log 'fooo loaded !'
@@ -0,0 +1,2 @@
1
+ = javascript_include_tag 'application'
2
+ %h1 Dat HAML!
@@ -0,0 +1,16 @@
1
+ #!ruby -I ../lib -I lib
2
+ require 'nyny'
3
+ require 'haml'
4
+ require 'coffee_script'
5
+ require 'sprockets/nyny'
6
+
7
+ class App < NYNY::App
8
+ register Sprockets::NYNY
9
+ config.assets.precompile << 'app/assets/javascripts/application.js'
10
+
11
+ get '/' do
12
+ render 'app/views/index.haml'
13
+ end
14
+ end
15
+
16
+ App.run! if __FILE__ == $0
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-nyny
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrei Lisnic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sprockets-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: nyny
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.2
69
+ description: Provides integration for asset pipeline into New York, New York
70
+ email:
71
+ - andrei.lisnic@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/sprockets/nyny.rb
82
+ - lib/sprockets/nyny/builder.rb
83
+ - lib/sprockets/nyny/version.rb
84
+ - sprockets-nyny.gemspec
85
+ - test/Gemfile
86
+ - test/Rakefile
87
+ - test/app/assets/javascripts/application.js.coffee
88
+ - test/app/assets/javascripts/foo.js.coffee
89
+ - test/app/views/index.haml
90
+ - test/server.rb
91
+ homepage: https://github.com/alisnic/sprockets-nyny
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.0
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: assets pipeline for NYNY
115
+ test_files:
116
+ - test/Gemfile
117
+ - test/Rakefile
118
+ - test/app/assets/javascripts/application.js.coffee
119
+ - test/app/assets/javascripts/foo.js.coffee
120
+ - test/app/views/index.haml
121
+ - test/server.rb