sinatra-simple-assets 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Sinatra Simple Assets
2
2
 
3
- # Gemfile
4
- gem 'sinatra-simple-assets', :require => 'sinatra/simple_assets'
3
+ * Concatinates and minifies JavaScript and CSS
4
+ * Provides view helpers
5
5
 
6
- # Sinatra app
7
- register Sinatra::SimpleAssets
6
+ [See examples directory for sample apps](https://github.com/peteog/sinatra-simple-assets/tree/master/examples)
7
+
8
+ ## Usage
9
+
10
+ ### In the app
8
11
 
9
12
  assets do
10
13
  css :application, [
@@ -24,14 +27,52 @@
24
27
  ]
25
28
  end
26
29
 
27
- # Views
28
- <%= javascript :application %>
30
+ ### In the views
31
+
32
+ #### CSS
33
+
29
34
  <%= stylesheet :application %>
30
35
 
36
+ development:
37
+
38
+ <link rel="stylesheet" href="http://localhost:9292/stylesheets/bootstrap.css">
39
+ <link rel="stylesheet" href="http://localhost:9292/stylesheets/application.css">
40
+
41
+ production:
42
+
43
+ <link rel="stylesheet" href="http://localhost:9292/stylesheets/application-1d512aa30517f9c05c6fc81258c586caeafc1136.css">
44
+
45
+ #### JavaScript
46
+
47
+ <%= javascript :application %>
48
+
49
+ development:
50
+
51
+ <script src="http://localhost:9292/javascripts/bootstrap-modal.js"></script>
52
+ <script src="http://localhost:9292/javascripts/bootstrap-dropdown.js"></script>
53
+ <script src="http://localhost:9292/javascripts/bootstrap-scrollspy.js"></script>
54
+ <script src="http://localhost:9292/javascripts/bootstrap-buttons.js"></script>
55
+ <script src="http://localhost:9292/javascripts/bootstrap-tabs.js"></script>
56
+ <script src="http://localhost:9292/javascripts/bootstrap-twipsy.js"></script>
57
+ <script src="http://localhost:9292/javascripts/bootstrap-popover.js"></script>
58
+ <script src="http://localhost:9292/javascripts/bootstrap-alerts.js"></script>
59
+ <script src="http://localhost:9292/javascripts/application.js"></script>
60
+
61
+ production:
62
+
63
+ <script src="http://localhost:9292/javascripts/application-2e4cd283a08121a850c0117a1ca64648e34cce98.js"></script>
64
+
65
+ ## Precompiling
66
+
31
67
  # Rakefile
68
+ require "#{File.dirname(__FILE__)}/app"
69
+
32
70
  namespace :assets do
33
71
  desc 'Precompile assets'
34
72
  task :precompile do
35
- App.assets.precompile
73
+ App.assets.precompile
74
+ # Sinatra::Application.assets.precompile # classic apps
36
75
  end
37
76
  end
77
+
78
+ [See examples directory for sample apps](https://github.com/peteog/sinatra-simple-assets/tree/master/examples)
@@ -1,6 +1,4 @@
1
1
  require 'sinatra/base'
2
- require 'cssmin'
3
- require 'uglifier'
4
2
 
5
3
  module Sinatra
6
4
  module SimpleAssets
@@ -41,14 +39,22 @@ module Sinatra
41
39
  end
42
40
 
43
41
  def hash
44
- @hash ||= Digest::SHA1.hexdigest content
42
+ @hash ||= begin
43
+ Digest::SHA1.hexdigest content
44
+ rescue
45
+ # Find the most recent compressed version if the JS runtime is unavailable
46
+ fname = Dir.glob("#{@root}/#{path}/#{@name}-*.#{@type}").sort_by {|f| File.mtime(f)}.last
47
+ fname.split('-').last.sub(".#{@type}", "")
48
+ end
45
49
  end
46
50
 
47
51
  def content
48
52
  case @type
49
53
  when :js
54
+ require 'uglifier'
50
55
  @content ||= Uglifier.new.compress combined
51
56
  when :css
57
+ require 'cssmin'
52
58
  @content ||= CSSMin.minify combined
53
59
  end
54
60
  end
@@ -1,16 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'sinatra-simple-assets'
4
- s.version = '0.0.4'
4
+ s.version = '0.0.5'
5
5
  s.authors = ["Pete O'Grady"]
6
6
  s.email = ['pete@peteogrady.com']
7
7
  s.homepage = 'https://github.com/peteog/sinatra-simple-assets'
8
8
  s.summary = %q{Asset minification and bundling for Sinatra}
9
9
  s.description = %q{Asset minification and bundling for Sinatra}
10
10
 
11
- s.files = `git ls-files`.split("\n")
12
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ s.files = [
12
+ ".gitignore",
13
+ "Gemfile",
14
+ "README.md",
15
+ "Rakefile",
16
+ "lib/sinatra/simple_assets.rb",
17
+ "sinatra-simple-assets.gemspec"
18
+ ]
14
19
  s.require_paths = ['lib']
15
20
 
16
21
  s.add_dependency 'cssmin', '~> 1.0.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-simple-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-16 00:00:00.000000000 Z
12
+ date: 2012-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cssmin
16
- requirement: &70097767374720 !ruby/object:Gem::Requirement
16
+ requirement: &70118374541480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70097767374720
24
+ version_requirements: *70118374541480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sinatra
27
- requirement: &70097767373280 !ruby/object:Gem::Requirement
27
+ requirement: &70118374540960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70097767373280
35
+ version_requirements: *70118374540960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: uglifier
38
- requirement: &70097767372560 !ruby/object:Gem::Requirement
38
+ requirement: &70118374540480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70097767372560
46
+ version_requirements: *70118374540480
47
47
  description: Asset minification and bundling for Sinatra
48
48
  email:
49
49
  - pete@peteogrady.com
@@ -69,12 +69,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
69
  - - ! '>='
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
+ segments:
73
+ - 0
74
+ hash: -4536364782455552744
72
75
  required_rubygems_version: !ruby/object:Gem::Requirement
73
76
  none: false
74
77
  requirements:
75
78
  - - ! '>='
76
79
  - !ruby/object:Gem::Version
77
80
  version: '0'
81
+ segments:
82
+ - 0
83
+ hash: -4536364782455552744
78
84
  requirements: []
79
85
  rubyforge_project:
80
86
  rubygems_version: 1.8.11