web_assets 0.0.3 → 0.0.4
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 +4 -4
 - data/lib/web_assets/api.rb +34 -0
 - data/lib/web_assets/client_interface.rb +12 -8
 - data/lib/web_assets/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 86f6e11ff8d37590421286122c253206c08a6109
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 550279a2af50f36629a68b2617470950203eff89
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ac8aa27d7f17ea4751001c0b792207b1b97c035350afd31554b1fc553a9ec47c7e20e4344224ea17a032ffeb13122eced09c4fdb5957dffaccf0dd461945574e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6e0e07709c222f796f007cc62f9500def83cd4659c00dcfe81aa0334b0303c2846d2e1f881df532afd3e3c08c6731f6e0624919fb5e02fd22ee3cece65f79561
         
     | 
    
        data/lib/web_assets/api.rb
    CHANGED
    
    | 
         @@ -9,30 +9,55 @@ module WebAssets 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  @stylesheet_processor = stylesheet_processor
         
     | 
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
                #
         
     | 
| 
      
 13 
     | 
    
         
            +
                # set the script path and return :ok
         
     | 
| 
      
 14 
     | 
    
         
            +
                #
         
     | 
| 
       12 
15 
     | 
    
         
             
                def set_script_path path
         
     | 
| 
       13 
16 
     | 
    
         
             
                  script_processor.set_path path
         
     | 
| 
       14 
17 
     | 
    
         
             
                end
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
                #
         
     | 
| 
      
 20 
     | 
    
         
            +
                # set the stylesheet path and return :ok
         
     | 
| 
      
 21 
     | 
    
         
            +
                #
         
     | 
| 
       16 
22 
     | 
    
         
             
                def set_stylesheet_path path
         
     | 
| 
       17 
23 
     | 
    
         
             
                  stylesheet_processor.set_path path
         
     | 
| 
       18 
24 
     | 
    
         
             
                end
         
     | 
| 
       19 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # append a path to the script load path and return :ok
         
     | 
| 
      
 28 
     | 
    
         
            +
                #
         
     | 
| 
       20 
29 
     | 
    
         
             
                def add_script_load_path path
         
     | 
| 
       21 
30 
     | 
    
         
             
                  script_processor.add_load_path path
         
     | 
| 
       22 
31 
     | 
    
         
             
                end
         
     | 
| 
       23 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
                #
         
     | 
| 
      
 34 
     | 
    
         
            +
                # append a path to the stylesheet load path and return :ok
         
     | 
| 
      
 35 
     | 
    
         
            +
                #
         
     | 
| 
       24 
36 
     | 
    
         
             
                def add_stylesheet_load_path path
         
     | 
| 
       25 
37 
     | 
    
         
             
                  stylesheet_processor.add_load_path path
         
     | 
| 
       26 
38 
     | 
    
         
             
                end
         
     | 
| 
       27 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                #
         
     | 
| 
      
 41 
     | 
    
         
            +
                # return an array of the filenames the script filename depends on and itself
         
     | 
| 
      
 42 
     | 
    
         
            +
                #
         
     | 
| 
       28 
43 
     | 
    
         
             
                def script_filenames filename
         
     | 
| 
       29 
44 
     | 
    
         
             
                  script_processor.filenames filename
         
     | 
| 
       30 
45 
     | 
    
         
             
                end
         
     | 
| 
       31 
46 
     | 
    
         | 
| 
      
 47 
     | 
    
         
            +
                #
         
     | 
| 
      
 48 
     | 
    
         
            +
                # return the script filename with its content digest
         
     | 
| 
      
 49 
     | 
    
         
            +
                #
         
     | 
| 
       32 
50 
     | 
    
         
             
                def script_digest_filename filename
         
     | 
| 
       33 
51 
     | 
    
         
             
                  script_processor.digest_filename filename
         
     | 
| 
       34 
52 
     | 
    
         
             
                end
         
     | 
| 
       35 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
                #
         
     | 
| 
      
 55 
     | 
    
         
            +
                # return the script content as a string
         
     | 
| 
      
 56 
     | 
    
         
            +
                # boolean options:
         
     | 
| 
      
 57 
     | 
    
         
            +
                #   - bundle: inline all dependencies
         
     | 
| 
      
 58 
     | 
    
         
            +
                #   - minify: minify the content
         
     | 
| 
      
 59 
     | 
    
         
            +
                #   - gzip:   return the gzipped binary content
         
     | 
| 
      
 60 
     | 
    
         
            +
                #
         
     | 
| 
       36 
61 
     | 
    
         
             
                def script_content filename, options = {}
         
     | 
| 
       37 
62 
     | 
    
         
             
                  options[:bundle] = options.fetch :bundle, true
         
     | 
| 
       38 
63 
     | 
    
         
             
                  options[:minify] = options.fetch :minify, false
         
     | 
| 
         @@ -40,10 +65,19 @@ module WebAssets 
     | 
|
| 
       40 
65 
     | 
    
         
             
                  script_processor.content filename, options
         
     | 
| 
       41 
66 
     | 
    
         
             
                end
         
     | 
| 
       42 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
                #
         
     | 
| 
      
 69 
     | 
    
         
            +
                # return the stylesheet filename with its content digest
         
     | 
| 
      
 70 
     | 
    
         
            +
                #
         
     | 
| 
       43 
71 
     | 
    
         
             
                def stylesheet_digest_filename filename
         
     | 
| 
       44 
72 
     | 
    
         
             
                  stylesheet_processor.digest_filename filename
         
     | 
| 
       45 
73 
     | 
    
         
             
                end
         
     | 
| 
       46 
74 
     | 
    
         | 
| 
      
 75 
     | 
    
         
            +
                #
         
     | 
| 
      
 76 
     | 
    
         
            +
                # return the stylesheet content processed, as a string
         
     | 
| 
      
 77 
     | 
    
         
            +
                # boolean options:
         
     | 
| 
      
 78 
     | 
    
         
            +
                #   - minify: minify the content
         
     | 
| 
      
 79 
     | 
    
         
            +
                #   - gzip:   return the gzipped binary content
         
     | 
| 
      
 80 
     | 
    
         
            +
                #
         
     | 
| 
       47 
81 
     | 
    
         
             
                def stylesheet_content filename, options = {}
         
     | 
| 
       48 
82 
     | 
    
         
             
                  options[:minify] = options.fetch :minify, false
         
     | 
| 
       49 
83 
     | 
    
         
             
                  options[:gzip]   = options.fetch :gzip, false
         
     | 
| 
         @@ -44,27 +44,32 @@ module WebAssets 
     | 
|
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                  request.when [:script_filenames, String] do |filename|
         
     | 
| 
       46 
46 
     | 
    
         
             
                    WebAssets.logger.debug "ClientInterface#process: script_filenames = #{filename.inspect}"
         
     | 
| 
       47 
     | 
    
         
            -
                     
     | 
| 
      
 47 
     | 
    
         
            +
                    names = api.script_filenames(filename)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    reply request, [:filenames, names]
         
     | 
| 
       48 
49 
     | 
    
         
             
                  end
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
51 
     | 
    
         
             
                  request.when [:script_digest_filename, String] do |filename|
         
     | 
| 
       51 
52 
     | 
    
         
             
                    WebAssets.logger.debug "ClientInterface#process: script_digest_filename = #{filename.inspect}"
         
     | 
| 
       52 
     | 
    
         
            -
                     
     | 
| 
      
 53 
     | 
    
         
            +
                    name = api.script_digest_filename(filename)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    reply request, [:filename, name]
         
     | 
| 
       53 
55 
     | 
    
         
             
                  end
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
       55 
57 
     | 
    
         
             
                  request.when [:script_content, Array] do |filename, options|
         
     | 
| 
       56 
     | 
    
         
            -
                    WebAssets.logger.debug "ClientInterface#process: script_content = #{filename.inspect}"
         
     | 
| 
       57 
     | 
    
         
            -
                     
     | 
| 
      
 58 
     | 
    
         
            +
                    WebAssets.logger.debug "ClientInterface#process: script_content = #{filename.inspect}, #{options.inspect}"
         
     | 
| 
      
 59 
     | 
    
         
            +
                    content = api.script_content(filename, Hash[options])
         
     | 
| 
      
 60 
     | 
    
         
            +
                    reply request, [:content, content]
         
     | 
| 
       58 
61 
     | 
    
         
             
                  end
         
     | 
| 
       59 
62 
     | 
    
         | 
| 
       60 
63 
     | 
    
         
             
                  request.when [:stylesheet_digest_filename, String] do |filename|
         
     | 
| 
       61 
64 
     | 
    
         
             
                    WebAssets.logger.debug "ClientInterface#process: stylesheet_digest_filename = #{filename.inspect}"
         
     | 
| 
       62 
     | 
    
         
            -
                     
     | 
| 
      
 65 
     | 
    
         
            +
                    name = api.stylesheet_digest_filename(filename)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    reply request, [:filename, name]
         
     | 
| 
       63 
67 
     | 
    
         
             
                  end
         
     | 
| 
       64 
68 
     | 
    
         | 
| 
       65 
69 
     | 
    
         
             
                  request.when [:stylesheet_content, Array] do |filename, options|
         
     | 
| 
       66 
     | 
    
         
            -
                    WebAssets.logger.debug "ClientInterface#process: stylesheet_content = #{filename.inspect}"
         
     | 
| 
       67 
     | 
    
         
            -
                     
     | 
| 
      
 70 
     | 
    
         
            +
                    WebAssets.logger.debug "ClientInterface#process: stylesheet_content = #{filename.inspect}, #{options.inspect}"
         
     | 
| 
      
 71 
     | 
    
         
            +
                    content = api.stylesheet_content(filename, Hash[options])
         
     | 
| 
      
 72 
     | 
    
         
            +
                    reply request, [:content, content]
         
     | 
| 
       68 
73 
     | 
    
         
             
                  end
         
     | 
| 
       69 
74 
     | 
    
         | 
| 
       70 
75 
     | 
    
         
             
                  WebAssets.logger.debug "ClientInterface#process: END"
         
     | 
| 
         @@ -73,7 +78,6 @@ module WebAssets 
     | 
|
| 
       73 
78 
     | 
    
         
             
                def reply request, response
         
     | 
| 
       74 
79 
     | 
    
         
             
                  WebAssets.logger.debug "ClientInterface#reply: #send! #{response.inspect}"
         
     | 
| 
       75 
80 
     | 
    
         
             
                  request.send! response
         
     | 
| 
       76 
     | 
    
         
            -
                  WebAssets.logger.debug "ClientInterface#reply: #receive_loop"
         
     | 
| 
       77 
81 
     | 
    
         
             
                  request.receive_loop
         
     | 
| 
       78 
82 
     | 
    
         
             
                end
         
     | 
| 
       79 
83 
     | 
    
         | 
    
        data/lib/web_assets/version.rb
    CHANGED