cyborg 0.5.21 → 0.5.22
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/cyborg.rb +2 -0
- data/lib/cyborg/helpers/asset_helpers.rb +4 -0
- data/lib/cyborg/plugin/assets/asset.rb +2 -2
- data/lib/cyborg/plugin/assets/stylesheets.rb +16 -0
- data/lib/cyborg/sass/engine.rb +19 -0
- data/lib/cyborg/sass/importer.rb +60 -0
- data/lib/cyborg/version.rb +1 -1
- metadata +3 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 81146b5c5d42c18d82d89720c63b63ae8c03513f
         | 
| 4 | 
            +
              data.tar.gz: 355163c3ad9d19551ba974e51f3a42345c892652
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a1d41793cbb1d1ad9a181c8849842b475cf2a4ddf2e0826646d18b92add2ea19ea12ef488041f8b49ee6eca382520c01b50c37ec64f15a6a456056e720a8dc5c
         | 
| 7 | 
            +
              data.tar.gz: d1a046acbe247d15b8838d097fd618809ac903b1bdff5b2fa9924627ba277980682131b2f90552fd5fec919acfc6e8177125ad73eb3b222ced263e8c5787b490
         | 
    
        data/lib/cyborg.rb
    CHANGED
    
    
| @@ -120,8 +120,8 @@ module Cyborg | |
| 120 120 | 
             
                  end
         | 
| 121 121 |  | 
| 122 122 | 
             
                  def change(modified, added, removed)
         | 
| 123 | 
            -
                    puts "Added: #{file_event(added)}".colorize(:light_green) | 
| 124 | 
            -
                    puts "Removed: #{file_event(removed)}".colorize(:light_red) | 
| 123 | 
            +
                    puts "Added: #{file_event(added)}".colorize(:light_green)        unless added.empty?
         | 
| 124 | 
            +
                    puts "Removed: #{file_event(removed)}".colorize(:light_red)      unless removed.empty?
         | 
| 125 125 | 
             
                    puts "Modified: #{file_event(modified)}".colorize(:light_yellow) unless modified.empty?
         | 
| 126 126 |  | 
| 127 127 | 
             
                    build
         | 
| @@ -59,6 +59,22 @@ module Cyborg | |
| 59 59 | 
             
                    compress(dest)
         | 
| 60 60 | 
             
                  end
         | 
| 61 61 |  | 
| 62 | 
            +
                  def data
         | 
| 63 | 
            +
                    if @data
         | 
| 64 | 
            +
                      @data
         | 
| 65 | 
            +
                    else
         | 
| 66 | 
            +
                      data = {}
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                      Dir[File.join(base, "**/*.yml")].each do |file|
         | 
| 69 | 
            +
                        key = file.sub(base+"/", '').sub(/^_/,'').sub('.yml','')
         | 
| 70 | 
            +
                        data[key] = YAML.load(IO.read(file))
         | 
| 71 | 
            +
                      end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                      @data = data if Cyborg.production?
         | 
| 74 | 
            +
                      data
         | 
| 75 | 
            +
                    end
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 62 78 | 
             
                  # Convert extension
         | 
| 63 79 | 
             
                  def versioned(file)
         | 
| 64 80 | 
             
                    super(file.sub(/(\.css)?\.s[ca]ss$/i,'.css'))
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'cyborg/sass/importer'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Taken from https://github.com/chriseppstein/sass-css-importer/blob/master/lib/sass/css_importer/monkey_patches.rb
         | 
| 4 | 
            +
            # TODO: This feels wrong, surely there must be a better way to handle this
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Sass::Engine
         | 
| 7 | 
            +
              alias initialize_without_yaml_importer initialize
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def initialize(template, options={})
         | 
| 10 | 
            +
                initialize_without_yaml_importer(template, options)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                yaml_importer = self.options[:load_paths].find {|lp| lp.is_a?(Cyborg::Importer) }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                unless yaml_importer
         | 
| 15 | 
            +
                  root = File.dirname(options[:filename] || ".")
         | 
| 16 | 
            +
                  self.options[:load_paths] << Cyborg::Importer.new(root)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            require 'sass'
         | 
| 2 | 
            +
            require 'yaml'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Cyborg
         | 
| 5 | 
            +
              class Importer < Sass::Importers::Filesystem
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def watched_file?(uri)
         | 
| 8 | 
            +
                  !!(uri =~ /\.yml$/ &&
         | 
| 9 | 
            +
                    uri.start_with?(root + File::SEPARATOR))
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                protected
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def extensions
         | 
| 15 | 
            +
                  {'yml' => :scss}
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def yaml?(name)
         | 
| 19 | 
            +
                  File.extname(name) == '.yml'
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                private
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def _find(dir, name, options)
         | 
| 25 | 
            +
                  return unless yaml? name
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
         | 
| 28 | 
            +
                  return unless full_filename && File.readable?(full_filename)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  yaml       = YAML.load(IO.read(full_filename))
         | 
| 31 | 
            +
                  variables  = yaml.map { |key, value| "$#{key}: #{_convert_to_sass(value)};" }.join("\n")
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  Sass::Engine.new(variables, options.merge(
         | 
| 34 | 
            +
                      :filename => full_filename,
         | 
| 35 | 
            +
                      :importer => self,
         | 
| 36 | 
            +
                      :syntax   => :scss
         | 
| 37 | 
            +
                  ))
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def _convert_to_sass(item)
         | 
| 41 | 
            +
                  if item.is_a? Array
         | 
| 42 | 
            +
                    _make_list(item)
         | 
| 43 | 
            +
                  elsif item.is_a? Hash
         | 
| 44 | 
            +
                    _make_map(item)
         | 
| 45 | 
            +
                  else
         | 
| 46 | 
            +
                    item.to_s
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def _make_list(item)
         | 
| 51 | 
            +
                  '(' + item.map { |i| _convert_to_sass(i) }.join(',') + ')'
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def _make_map(item)
         | 
| 55 | 
            +
                  '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            end
         | 
| 60 | 
            +
             | 
    
        data/lib/cyborg/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cyborg
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.22
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Brandon Mathis
         | 
| @@ -201,6 +201,8 @@ files: | |
| 201 201 | 
             
            - lib/cyborg/plugin/assets/javascripts.rb
         | 
| 202 202 | 
             
            - lib/cyborg/plugin/assets/stylesheets.rb
         | 
| 203 203 | 
             
            - lib/cyborg/plugin/assets/svgs.rb
         | 
| 204 | 
            +
            - lib/cyborg/sass/engine.rb
         | 
| 205 | 
            +
            - lib/cyborg/sass/importer.rb
         | 
| 204 206 | 
             
            - lib/cyborg/version.rb
         | 
| 205 207 | 
             
            homepage: https://github.com/compose-ui/cyborg
         | 
| 206 208 | 
             
            licenses:
         |