kelredd-sinatra-helpers 0.1.8 → 0.1.9
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/README.rdoc +5 -10
 - data/Rakefile +6 -2
 - data/lib/sinatra_helpers/generator/file_templates/env.rb.erb +13 -8
 - data/lib/sinatra_helpers/generator/file_templates/env_production.rb.erb +0 -5
 - data/lib/sinatra_helpers/generator/file_templates/gems.rb.erb +2 -3
 - data/lib/sinatra_helpers/generator/file_templates/gitignore.erb +1 -0
 - data/lib/sinatra_helpers/generator/file_templates/layout +2 -2
 - data/lib/sinatra_helpers/generator/template.rb +1 -3
 - data/lib/sinatra_helpers/version.rb +1 -1
 - data/lib/sinatra_helpers.rb +0 -5
 - metadata +42 -8
 - data/lib/sinatra_helpers/less/config.rb +0 -22
 - data/lib/sinatra_helpers/less/erb.rb +0 -32
 - data/lib/sinatra_helpers/less.rb +0 -91
 - data/lib/sinatra_helpers/sprockets/config.rb +0 -22
 - data/lib/sinatra_helpers/sprockets/erb.rb +0 -24
 - data/lib/sinatra_helpers/sprockets.rb +0 -88
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -10,8 +10,6 @@ I've written a generator for new Sinatra apps.  Please note: I've written this g 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
             * Most, if not all, of the helpers in this gem
         
     | 
| 
       12 
12 
     | 
    
         
             
             * Gem configuration (via gemsconfig: http://github.com/kelredd/gemsconfig)
         
     | 
| 
       13 
     | 
    
         
            -
             * Sprockets (via sprockets-sinatra: http://github.com/kelredd/sprockets-sinatra)
         
     | 
| 
       14 
     | 
    
         
            -
             * Less (coming)
         
     | 
| 
       15 
13 
     | 
    
         
             
             * Capistrano deployment scheme
         
     | 
| 
       16 
14 
     | 
    
         
             
             * Source control with Git
         
     | 
| 
       17 
15 
     | 
    
         
             
             * Erb (with generators from useful: http://github.com/kelredd/useful/tree/master/lib/useful/erb_helpers/)
         
     | 
| 
         @@ -19,8 +17,9 @@ I've written a generator for new Sinatra apps.  Please note: I've written this g 
     | 
|
| 
       19 
17 
     | 
    
         
             
             * Default layout that I like
         
     | 
| 
       20 
18 
     | 
    
         
             
             * Rack::Cache using my configuration (see admin/production.ru)
         
     | 
| 
       21 
19 
     | 
    
         
             
             * Rack::Flash
         
     | 
| 
       22 
     | 
    
         
            -
             *  
     | 
| 
       23 
     | 
    
         
            -
             *  
     | 
| 
      
 20 
     | 
    
         
            +
             * Rack::Less (http://github.com/kelredd/rack-less)
         
     | 
| 
      
 21 
     | 
    
         
            +
             * Rack::Sprockets (http://github.com/kelredd/rack-sprockets)
         
     | 
| 
      
 22 
     | 
    
         
            +
             * Unit testing with Test::Unit
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
24 
     | 
    
         
             
            If you don't like/want to use something that this generates, don't use the generator, or back out some generated code manually.  Ok, enough about that.  On to usage:
         
     | 
| 
       26 
25 
     | 
    
         | 
| 
         @@ -36,17 +35,13 @@ Have environment tests like development? and production? available in your app c 
     | 
|
| 
       36 
35 
     | 
    
         
             
            Helpful view template helpers for partial rendering and html generation.  See
         
     | 
| 
       37 
36 
     | 
    
         
             
            http://github.com/kelredd/useful/tree/master/lib/useful/erb_helpers/ for more info.
         
     | 
| 
       38 
37 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
            === Sprockets
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            Coming.
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
38 
     | 
    
         
             
            === ActiveRecord
         
     | 
| 
       44 
39 
     | 
    
         | 
| 
       45 
40 
     | 
    
         
             
            Coming.
         
     | 
| 
       46 
41 
     | 
    
         | 
| 
       47 
42 
     | 
    
         
             
            == Installation
         
     | 
| 
       48 
43 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
      
 44 
     | 
    
         
            +
                gem install kelredd-sinatra-helpers
         
     | 
| 
       50 
45 
     | 
    
         | 
| 
       51 
46 
     | 
    
         
             
            == Usage
         
     | 
| 
       52 
47 
     | 
    
         | 
| 
         @@ -54,7 +49,7 @@ Coming. 
     | 
|
| 
       54 
49 
     | 
    
         | 
| 
       55 
50 
     | 
    
         
             
            == License
         
     | 
| 
       56 
51 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
            Copyright (c)  
     | 
| 
      
 52 
     | 
    
         
            +
            Copyright (c) 2010 Kelly Redding (mailto:kelly@kelredd.com)
         
     | 
| 
       58 
53 
     | 
    
         | 
| 
       59 
54 
     | 
    
         
             
            Permission is hereby granted, free of charge, to any person
         
     | 
| 
       60 
55 
     | 
    
         
             
            obtaining a copy of this software and associated documentation
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -17,7 +17,12 @@ spec = Gem::Specification.new do |s| 
     | 
|
| 
       17 
17 
     | 
    
         
             
              s.files            = %w(README.rdoc Rakefile) + Dir.glob("{bin,lib}/**/*")
         
     | 
| 
       18 
18 
     | 
    
         
             
              s.executables    = ['sinatra']
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
              s.add_dependency('kelredd-useful', '>= 0.2.6')
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_dependency('kelredd-useful', ['>= 0.2.6'])
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_development_dependency("shoulda", [">= 2.10.2"])
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_development_dependency("sinatra", [">= 0.9.4"])
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.add_development_dependency("rack-test", [">= 0.5.3"])
         
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency("webrat", [">= 0.6.0"])
         
     | 
| 
       21 
26 
     | 
    
         
             
            end
         
     | 
| 
       22 
27 
     | 
    
         | 
| 
       23 
28 
     | 
    
         
             
            Rake::GemPackageTask.new(spec) do |pkg|
         
     | 
| 
         @@ -47,7 +52,6 @@ rescue LoadError 
     | 
|
| 
       47 
52 
     | 
    
         
             
              task :default => :test
         
     | 
| 
       48 
53 
     | 
    
         
             
            end
         
     | 
| 
       49 
54 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
55 
     | 
    
         
             
            desc 'Generate the gemspec to serve this gem'
         
     | 
| 
       52 
56 
     | 
    
         
             
            task :gemspec do
         
     | 
| 
       53 
57 
     | 
    
         
             
              file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
         
     | 
| 
         @@ -15,12 +15,17 @@ load_app 'models' 
     | 
|
| 
       15 
15 
     | 
    
         
             
            use Rack::Session::Cookie, :key => '_sess'
         
     | 
| 
       16 
16 
     | 
    
         
             
            use Rack::Flash
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
            use Rack::Less
         
     | 
| 
      
 19 
     | 
    
         
            +
            Rack::Less.configure do |config|
         
     | 
| 
      
 20 
     | 
    
         
            +
              config.combinations = {
         
     | 
| 
      
 21 
     | 
    
         
            +
                'web' => ['reset', 'app']
         
     | 
| 
      
 22 
     | 
    
         
            +
              }
         
     | 
| 
      
 23 
     | 
    
         
            +
              config.compress = config.cache = production? 
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
       22 
25 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
            use Rack::Sprockets
         
     | 
| 
      
 27 
     | 
    
         
            +
            Rack::Sprockets.configure do |config|
         
     | 
| 
      
 28 
     | 
    
         
            +
              if config.cache = production? 
         
     | 
| 
      
 29 
     | 
    
         
            +
                config.compress = :whitespace
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -4,12 +4,7 @@ use Rack::Cache, 
     | 
|
| 
       4 
4 
     | 
    
         
             
              :metastore   => "file:#{root_path('cache-rack', 'meta')}",
         
     | 
| 
       5 
5 
     | 
    
         
             
              :entitystore => "file:#{root_path('cache-rack', 'body')}"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
7 
     | 
    
         
             
            FileUtils.mkdir_p 'log' unless File.exists?('log')
         
     | 
| 
       9 
8 
     | 
    
         
             
            log = File.new("log/#{RACK_ENV.downcase}.log", "a+")
         
     | 
| 
       10 
9 
     | 
    
         
             
            $stdout.reopen(log)
         
     | 
| 
       11 
10 
     | 
    
         
             
            $stderr.reopen(log)
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            SinatraHelpers::Less.configure do |config|
         
     | 
| 
       14 
     | 
    
         
            -
              config.compress = true
         
     | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -8,11 +8,10 @@ Gemsconfig::init do |config| 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              config.gem 'rack-flash', :lib => 'rack-flash'
         
     | 
| 
       10 
10 
     | 
    
         
             
              config.gem 'rack-cache', :lib => false
         
     | 
| 
      
 11 
     | 
    
         
            +
              config.gem 'rack-less', :lib => 'rack/less'
         
     | 
| 
      
 12 
     | 
    
         
            +
              config.gem 'rack-sprockets', :lib => 'rack/sprockets'
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
              config.gem 'kelredd-useful', :lib => 'useful/ruby_extensions'
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
15 
     | 
    
         
             
              config.gem 'kelredd-sinatra-helpers', :lib => 'sinatra_helpers'
         
     | 
| 
       15 
     | 
    
         
            -
              config.gem 'kelredd-sinatra-helpers', :lib => 'sinatra_helpers/less'
         
     | 
| 
       16 
     | 
    
         
            -
              config.gem 'kelredd-sinatra-helpers', :lib => 'sinatra_helpers/sprockets'
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
            end if defined?(Gemsconfig)
         
     | 
| 
         @@ -11,9 +11,9 @@ 
     | 
|
| 
       11 
11 
     | 
    
         
             
                <meta name="robots" content="noindex,nofollow" />
         
     | 
| 
       12 
12 
     | 
    
         
             
              <% end %>
         
     | 
| 
       13 
13 
     | 
    
         
             
              <link rel="icon" type="image/png" href="/favicon.png"></link>
         
     | 
| 
       14 
     | 
    
         
            -
              <%=  
     | 
| 
      
 14 
     | 
    
         
            +
              <%= spreadsheet_link_tag Rack::Less.combinations('web'), :media => "all" %>
         
     | 
| 
       15 
15 
     | 
    
         
             
            	<% unless @noscript %>
         
     | 
| 
       16 
     | 
    
         
            -
            	  <%=  
     | 
| 
      
 16 
     | 
    
         
            +
            	  <%= javascript_include_tag 'app.js' %>
         
     | 
| 
       17 
17 
     | 
    
         
             
              <% end %>
         
     | 
| 
       18 
18 
     | 
    
         
             
            </head>
         
     | 
| 
       19 
19 
     | 
    
         
             
            <body class="body">
         
     | 
    
        data/lib/sinatra_helpers.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: kelredd-sinatra-helpers
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Kelly Redding
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2010-02- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2010-02-14 00:00:00 -06:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -22,6 +22,46 @@ dependencies: 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       23 
23 
     | 
    
         
             
                    version: 0.2.6
         
     | 
| 
       24 
24 
     | 
    
         
             
                version: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: shoulda
         
     | 
| 
      
 27 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 28 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 29 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 2.10.2
         
     | 
| 
      
 34 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 35 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 36 
     | 
    
         
            +
              name: sinatra
         
     | 
| 
      
 37 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 39 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: 0.9.4
         
     | 
| 
      
 44 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 46 
     | 
    
         
            +
              name: rack-test
         
     | 
| 
      
 47 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 48 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 49 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: 0.5.3
         
     | 
| 
      
 54 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: webrat
         
     | 
| 
      
 57 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 58 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 59 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 60 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 61 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 62 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 63 
     | 
    
         
            +
                    version: 0.6.0
         
     | 
| 
      
 64 
     | 
    
         
            +
                version: 
         
     | 
| 
       25 
65 
     | 
    
         
             
            description: 
         
     | 
| 
       26 
66 
     | 
    
         
             
            email: kelly@kelredd.com
         
     | 
| 
       27 
67 
     | 
    
         
             
            executables: 
         
     | 
| 
         @@ -64,12 +104,6 @@ files: 
     | 
|
| 
       64 
104 
     | 
    
         
             
            - lib/sinatra_helpers/generator/file_templates/test_helper.rb.erb
         
     | 
| 
       65 
105 
     | 
    
         
             
            - lib/sinatra_helpers/generator/template.rb
         
     | 
| 
       66 
106 
     | 
    
         
             
            - lib/sinatra_helpers/generator.rb
         
     | 
| 
       67 
     | 
    
         
            -
            - lib/sinatra_helpers/less/config.rb
         
     | 
| 
       68 
     | 
    
         
            -
            - lib/sinatra_helpers/less/erb.rb
         
     | 
| 
       69 
     | 
    
         
            -
            - lib/sinatra_helpers/less.rb
         
     | 
| 
       70 
     | 
    
         
            -
            - lib/sinatra_helpers/sprockets/config.rb
         
     | 
| 
       71 
     | 
    
         
            -
            - lib/sinatra_helpers/sprockets/erb.rb
         
     | 
| 
       72 
     | 
    
         
            -
            - lib/sinatra_helpers/sprockets.rb
         
     | 
| 
       73 
107 
     | 
    
         
             
            - lib/sinatra_helpers/version.rb
         
     | 
| 
       74 
108 
     | 
    
         
             
            - lib/sinatra_helpers.rb
         
     | 
| 
       75 
109 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
         @@ -1,22 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       2 
     | 
    
         
            -
            module SinatraHelpers::Less
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              class Config
         
     | 
| 
       5 
     | 
    
         
            -
                ATTRIBUTES = [:hosted_root, :src_root, :concat, :compress]
         
     | 
| 
       6 
     | 
    
         
            -
                DEFAULTS = {
         
     | 
| 
       7 
     | 
    
         
            -
                  :hosted_root => '/stylesheets',
         
     | 
| 
       8 
     | 
    
         
            -
                  :src_root => 'app/stylesheets',
         
     | 
| 
       9 
     | 
    
         
            -
                  :concat => {},
         
     | 
| 
       10 
     | 
    
         
            -
                  :compress => false
         
     | 
| 
       11 
     | 
    
         
            -
                }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                attr_accessor *ATTRIBUTES
         
     | 
| 
       14 
     | 
    
         
            -
                
         
     | 
| 
       15 
     | 
    
         
            -
                def initialize(args={})
         
     | 
| 
       16 
     | 
    
         
            -
                  ATTRIBUTES.each do |a|
         
     | 
| 
       17 
     | 
    
         
            -
                    instance_variable_set("@#{a}", args[a] || DEFAULTS[a])
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
              
         
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,32 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "sinatra_helpers/erb"
         
     | 
| 
       2 
     | 
    
         
            -
            require 'useful/ruby_extensions/object' unless ::Object.new.respond_to?('blank?')
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       5 
     | 
    
         
            -
            module SinatraHelpers::Less
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              module Erb
         
     | 
| 
       8 
     | 
    
         
            -
                
         
     | 
| 
       9 
     | 
    
         
            -
                def less_link_tag(*args)
         
     | 
| 
       10 
     | 
    
         
            -
                  the_args = args.flatten
         
     | 
| 
       11 
     | 
    
         
            -
                  srcs, options = if the_args.last && the_args.last.kind_of?(::Hash)
         
     | 
| 
       12 
     | 
    
         
            -
                    [the_args[0..-2], the_args.last]
         
     | 
| 
       13 
     | 
    
         
            -
                  else
         
     | 
| 
       14 
     | 
    
         
            -
                    [the_args, {}]
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
                  
         
     | 
| 
       17 
     | 
    
         
            -
                  options[:environment] ||= SinatraHelpers::Less.app.environment.to_s
         
     | 
| 
       18 
     | 
    
         
            -
                  
         
     | 
| 
       19 
     | 
    
         
            -
                  concat = options.delete(:concat)
         
     | 
| 
       20 
     | 
    
         
            -
                  if concat && !(concat.to_s).blank?
         
     | 
| 
       21 
     | 
    
         
            -
                    SinatraHelpers::Less.config do |config|
         
     | 
| 
       22 
     | 
    
         
            -
                      config.concat[concat.to_s] = srcs
         
     | 
| 
       23 
     | 
    
         
            -
                    end
         
     | 
| 
       24 
     | 
    
         
            -
                    srcs = concat.to_s if SinatraHelpers.page_cache?(SinatraHelpers::Less.app) 
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                    
         
     | 
| 
       27 
     | 
    
         
            -
                  stylesheet_link_tag srcs, options
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            end
         
     | 
    
        data/lib/sinatra_helpers/less.rb
    DELETED
    
    | 
         @@ -1,91 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            begin
         
     | 
| 
       2 
     | 
    
         
            -
              require 'less'
         
     | 
| 
       3 
     | 
    
         
            -
            rescue LoadError => err
         
     | 
| 
       4 
     | 
    
         
            -
              err.message << "\n**** Install less (gem install less) to use the sinatra less helpers ****\n"
         
     | 
| 
       5 
     | 
    
         
            -
              raise err
         
     | 
| 
       6 
     | 
    
         
            -
            end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            require 'sinatra_helpers/less/config'
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       11 
     | 
    
         
            -
            module SinatraHelpers::Less
         
     | 
| 
       12 
     | 
    
         
            -
              
         
     | 
| 
       13 
     | 
    
         
            -
              CONTENT_TYPE = "text/css"
         
     | 
| 
       14 
     | 
    
         
            -
              
         
     | 
| 
       15 
     | 
    
         
            -
              class << self
         
     | 
| 
       16 
     | 
    
         
            -
                attr_reader :app
         
     | 
| 
       17 
     | 
    
         
            -
                
         
     | 
| 
       18 
     | 
    
         
            -
                def config
         
     | 
| 
       19 
     | 
    
         
            -
                  if instance_variable_get("@config").nil?
         
     | 
| 
       20 
     | 
    
         
            -
                    instance_variable_set("@config", SinatraHelpers::Less::Config.new)
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
                  yield instance_variable_get("@config") if block_given?
         
     | 
| 
       23 
     | 
    
         
            -
                  instance_variable_get("@config")
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
                
         
     | 
| 
       26 
     | 
    
         
            -
                def [](config_attribute)
         
     | 
| 
       27 
     | 
    
         
            -
                  config.send(config_attribute)
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              
         
     | 
| 
       30 
     | 
    
         
            -
                def registered(app)
         
     | 
| 
       31 
     | 
    
         
            -
                  instance_variable_set("@app", app)
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                  app.get "/less-sinatra-helper-test" do
         
     | 
| 
       34 
     | 
    
         
            -
                    if SinatraHelpers::Less.config
         
     | 
| 
       35 
     | 
    
         
            -
                      "The LESS sinatra helper is configured and ready :)"
         
     | 
| 
       36 
     | 
    
         
            -
                    else
         
     | 
| 
       37 
     | 
    
         
            -
                      "The LESS sinatra helper is NOT configured and ready :("
         
     | 
| 
       38 
     | 
    
         
            -
                    end
         
     | 
| 
       39 
     | 
    
         
            -
                  end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                  app.get "#{SinatraHelpers::Less[:hosted_root]}/*.css" do
         
     | 
| 
       42 
     | 
    
         
            -
                    file_name = params['splat'].first.to_s
         
     | 
| 
       43 
     | 
    
         
            -
                    less_path = File.join([
         
     | 
| 
       44 
     | 
    
         
            -
                      app.root, SinatraHelpers::Less[:src_root], "#{file_name}.less"
         
     | 
| 
       45 
     | 
    
         
            -
                    ])
         
     | 
| 
       46 
     | 
    
         
            -
                    css_path = File.join([
         
     | 
| 
       47 
     | 
    
         
            -
                      app.root, SinatraHelpers::Less[:src_root], "#{file_name}.css"
         
     | 
| 
       48 
     | 
    
         
            -
                    ])
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                    content_type CONTENT_TYPE
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                    if File.exists?(less_path)
         
     | 
| 
       53 
     | 
    
         
            -
                      SinatraHelpers::Less.compile(file_name, [less_path])
         
     | 
| 
       54 
     | 
    
         
            -
                    elsif File.exists?(css_path)
         
     | 
| 
       55 
     | 
    
         
            -
                      SinatraHelpers::Less.compile(file_name, [css_path])
         
     | 
| 
       56 
     | 
    
         
            -
                    elsif SinatraHelpers::Less[:concat].include?(file_name)
         
     | 
| 
       57 
     | 
    
         
            -
                      less_paths = SinatraHelpers::Less[:concat][file_name].collect do |concat_name|
         
     | 
| 
       58 
     | 
    
         
            -
                        File.join(app.root, SinatraHelpers::Less[:src_root], "#{concat_name}.less")
         
     | 
| 
       59 
     | 
    
         
            -
                      end.select do |less_path|
         
     | 
| 
       60 
     | 
    
         
            -
                        File.exists?(less_path)
         
     | 
| 
       61 
     | 
    
         
            -
                      end
         
     | 
| 
       62 
     | 
    
         
            -
                      SinatraHelpers::Less.compile(file_name, less_paths)
         
     | 
| 
       63 
     | 
    
         
            -
                    else
         
     | 
| 
       64 
     | 
    
         
            -
                      halt SinatraHelpers::HTTP_STATUS[:not_found]
         
     | 
| 
       65 
     | 
    
         
            -
                    end
         
     | 
| 
       66 
     | 
    
         
            -
                  end    
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
                
         
     | 
| 
       69 
     | 
    
         
            -
                def compile(css_name, file_paths)
         
     | 
| 
       70 
     | 
    
         
            -
                  compiled_less = file_paths.collect do |file_path|
         
     | 
| 
       71 
     | 
    
         
            -
                    Less::Engine.new(File.new(file_path)).to_css
         
     | 
| 
       72 
     | 
    
         
            -
                  end.join("\n")
         
     | 
| 
       73 
     | 
    
         
            -
                  compiled_less.delete!("\n") if use_compression?
         
     | 
| 
       74 
     | 
    
         
            -
                  if SinatraHelpers.page_cache?(SinatraHelpers::Less.app)
         
     | 
| 
       75 
     | 
    
         
            -
                    pub_path = File.join(SinatraHelpers::Less.app.public, SinatraHelpers::Less[:hosted_root])
         
     | 
| 
       76 
     | 
    
         
            -
                    FileUtils.mkdir_p(pub_path)
         
     | 
| 
       77 
     | 
    
         
            -
                    hosted = File.join(pub_path, "#{css_name}.css")
         
     | 
| 
       78 
     | 
    
         
            -
                    File.open(hosted, "w") do |file|
         
     | 
| 
       79 
     | 
    
         
            -
                      file.write(compiled_less)
         
     | 
| 
       80 
     | 
    
         
            -
                    end
         
     | 
| 
       81 
     | 
    
         
            -
                  end
         
     | 
| 
       82 
     | 
    
         
            -
                  compiled_less
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
                
         
     | 
| 
       85 
     | 
    
         
            -
                def use_compression?
         
     | 
| 
       86 
     | 
    
         
            -
                  SinatraHelpers::Less[:compress]
         
     | 
| 
       87 
     | 
    
         
            -
                end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
              end
         
     | 
| 
       90 
     | 
    
         
            -
              
         
     | 
| 
       91 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,22 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       2 
     | 
    
         
            -
            module SinatraHelpers::Sprockets
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              class Config
         
     | 
| 
       5 
     | 
    
         
            -
                ATTRIBUTES = [:hosted_root, :src_root, :load_path, :expand_paths]
         
     | 
| 
       6 
     | 
    
         
            -
                DEFAULTS = {
         
     | 
| 
       7 
     | 
    
         
            -
                  :hosted_root => '/javascripts',
         
     | 
| 
       8 
     | 
    
         
            -
                  :src_root => 'app/javascripts',
         
     | 
| 
       9 
     | 
    
         
            -
                  :load_path => ['app/javascripts/**', 'vendor/javascripts', 'vendor/sprockets'],
         
     | 
| 
       10 
     | 
    
         
            -
                  :expand_paths => true
         
     | 
| 
       11 
     | 
    
         
            -
                }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                attr_accessor *ATTRIBUTES
         
     | 
| 
       14 
     | 
    
         
            -
                
         
     | 
| 
       15 
     | 
    
         
            -
                def initialize(args={})
         
     | 
| 
       16 
     | 
    
         
            -
                  ATTRIBUTES.each do |a|
         
     | 
| 
       17 
     | 
    
         
            -
                    instance_variable_set("@#{a}", args[a] || DEFAULTS[a])
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,24 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "sinatra_helpers/erb"
         
     | 
| 
       2 
     | 
    
         
            -
            require 'useful/ruby_extensions/object' unless ::Object.new.respond_to?('blank?')
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       5 
     | 
    
         
            -
            module SinatraHelpers::Sprockets
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              module Erb
         
     | 
| 
       8 
     | 
    
         
            -
                
         
     | 
| 
       9 
     | 
    
         
            -
                def sprockets_include_tag(*args)
         
     | 
| 
       10 
     | 
    
         
            -
                  the_args = args.flatten
         
     | 
| 
       11 
     | 
    
         
            -
                  srcs, options = if the_args.last && the_args.last.kind_of?(::Hash)
         
     | 
| 
       12 
     | 
    
         
            -
                    [the_args[0..-2], the_args.last]
         
     | 
| 
       13 
     | 
    
         
            -
                  else
         
     | 
| 
       14 
     | 
    
         
            -
                    [the_args, {}]
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
                  
         
     | 
| 
       17 
     | 
    
         
            -
                  options[:environment] ||= SinatraHelpers::Sprockets.app.environment.to_s
         
     | 
| 
       18 
     | 
    
         
            -
                  
         
     | 
| 
       19 
     | 
    
         
            -
                  javascript_include_tag srcs, options
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,88 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            begin
         
     | 
| 
       2 
     | 
    
         
            -
              require 'sprockets'
         
     | 
| 
       3 
     | 
    
         
            -
            rescue LoadError => err
         
     | 
| 
       4 
     | 
    
         
            -
              err.message << "\n**** Install sprockets (gem install sprockets) to use the sinatra sprockets helpers ****\n"
         
     | 
| 
       5 
     | 
    
         
            -
              raise err
         
     | 
| 
       6 
     | 
    
         
            -
            end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            require 'sinatra_helpers/sprockets/config'
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            module SinatraHelpers; end
         
     | 
| 
       11 
     | 
    
         
            -
            module SinatraHelpers::Sprockets
         
     | 
| 
       12 
     | 
    
         
            -
              
         
     | 
| 
       13 
     | 
    
         
            -
              CONTENT_TYPE = "text/javascript; charset=utf-8"
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              class << self
         
     | 
| 
       16 
     | 
    
         
            -
                attr_reader :app
         
     | 
| 
       17 
     | 
    
         
            -
                
         
     | 
| 
       18 
     | 
    
         
            -
                def config
         
     | 
| 
       19 
     | 
    
         
            -
                  if instance_variable_get("@config").nil?
         
     | 
| 
       20 
     | 
    
         
            -
                    instance_variable_set("@config", SinatraHelpers::Sprockets::Config.new)
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
                  yield instance_variable_get("@config") if block_given?
         
     | 
| 
       23 
     | 
    
         
            -
                  instance_variable_get("@config")
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
                
         
     | 
| 
       26 
     | 
    
         
            -
                def secretary
         
     | 
| 
       27 
     | 
    
         
            -
                  if instance_variable_get("@secretary").nil?
         
     | 
| 
       28 
     | 
    
         
            -
                    instance_variable_set("@secretary", {
         
     | 
| 
       29 
     | 
    
         
            -
                      :root => app.root,
         
     | 
| 
       30 
     | 
    
         
            -
                      :load_path => config.load_path,
         
     | 
| 
       31 
     | 
    
         
            -
                      :expand_paths => config.expand_paths
         
     | 
| 
       32 
     | 
    
         
            -
                    })
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                  yield instance_variable_get("@secretary") if block_given?
         
     | 
| 
       35 
     | 
    
         
            -
                  instance_variable_get("@secretary")      
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
                
         
     | 
| 
       38 
     | 
    
         
            -
                def [](config_attribute)
         
     | 
| 
       39 
     | 
    
         
            -
                  config.send(config_attribute)
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
              
         
     | 
| 
       42 
     | 
    
         
            -
                def registered(app)
         
     | 
| 
       43 
     | 
    
         
            -
                  instance_variable_set("@app", app)
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  app.get "/sprockets-sinatra-helper-test" do
         
     | 
| 
       46 
     | 
    
         
            -
                    if SinatraHelpers::Sprockets.config
         
     | 
| 
       47 
     | 
    
         
            -
                      "The sprockets sinatra helper is configured and ready :)"
         
     | 
| 
       48 
     | 
    
         
            -
                    else
         
     | 
| 
       49 
     | 
    
         
            -
                      "The sprockets sinatra helper is NOT configured and ready :("
         
     | 
| 
       50 
     | 
    
         
            -
                    end
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
                  
         
     | 
| 
       53 
     | 
    
         
            -
                  app.get "#{SinatraHelpers::Sprockets[:hosted_root]}/*.js" do
         
     | 
| 
       54 
     | 
    
         
            -
                    src_name = params['splat'].first.to_s
         
     | 
| 
       55 
     | 
    
         
            -
                    src_file_path = File.join([
         
     | 
| 
       56 
     | 
    
         
            -
                      SinatraHelpers::Sprockets[:src_root], "#{src_name}.js"
         
     | 
| 
       57 
     | 
    
         
            -
                    ])
         
     | 
| 
       58 
     | 
    
         
            -
                    src_path = File.join(app.root, src_file_path)
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                    content_type CONTENT_TYPE
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                    if File.exists?(src_path)
         
     | 
| 
       63 
     | 
    
         
            -
                      SinatraHelpers::Sprockets.compile(src_file_path)
         
     | 
| 
       64 
     | 
    
         
            -
                    else
         
     | 
| 
       65 
     | 
    
         
            -
                      halt SinatraHelpers::HTTP_STATUS[:not_found]
         
     | 
| 
       66 
     | 
    
         
            -
                    end
         
     | 
| 
       67 
     | 
    
         
            -
                  end    
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
                
         
     | 
| 
       70 
     | 
    
         
            -
                def compile(src_file_name)
         
     | 
| 
       71 
     | 
    
         
            -
                  secretary_params = SinatraHelpers::Sprockets.secretary do |params|
         
     | 
| 
       72 
     | 
    
         
            -
                    params[:source_files] = [src_file_name]
         
     | 
| 
       73 
     | 
    
         
            -
                  end
         
     | 
| 
       74 
     | 
    
         
            -
                  compiled_src = Sprockets::Secretary.new(secretary_params).concatenation.to_s
         
     | 
| 
       75 
     | 
    
         
            -
                  if SinatraHelpers.page_cache?(SinatraHelpers::Sprockets.app)
         
     | 
| 
       76 
     | 
    
         
            -
                    pub_path = File.join(SinatraHelpers::Sprockets.app.public, SinatraHelpers::Sprockets[:hosted_root])
         
     | 
| 
       77 
     | 
    
         
            -
                    FileUtils.mkdir_p(pub_path)
         
     | 
| 
       78 
     | 
    
         
            -
                    hosted = File.join(pub_path, File.basename(src_file_name))
         
     | 
| 
       79 
     | 
    
         
            -
                    File.open(hosted, "w") do |file|
         
     | 
| 
       80 
     | 
    
         
            -
                      file.write(compiled_src)
         
     | 
| 
       81 
     | 
    
         
            -
                    end
         
     | 
| 
       82 
     | 
    
         
            -
                  end
         
     | 
| 
       83 
     | 
    
         
            -
                  compiled_src
         
     | 
| 
       84 
     | 
    
         
            -
                end
         
     | 
| 
       85 
     | 
    
         
            -
                
         
     | 
| 
       86 
     | 
    
         
            -
              end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
            end
         
     |