mascot 0.1.14 → 0.1.15
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/mascot/extensions/layouts.rb +1 -1
 - data/lib/mascot/extensions/proc_manipulator.rb +1 -1
 - data/lib/mascot/resources_node.rb +9 -23
 - data/lib/mascot/site.rb +19 -13
 - data/lib/mascot/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3cbf26b5dbbcb679dee59b1f38f93d73dfd8bab7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 53bb98405c06bf85705c397c69bba07992895038
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4ac9c815391409fd3e57fd942a23b49e7d106cf58f117e9e19f5155860c4f6958fbaeb3a3774658e4b46216788e48abb08efda31d7e74bbc57c4df1e084409d4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 49099b0682866088cb2aba0cbd16397682a280084de69cade3e378392b3306020be20bd9d0a805c8fa55ec20f5c5f1f65adb67c29aba5310360d94426bbc497c
         
     | 
| 
         @@ -48,26 +48,12 @@ module Mascot 
     | 
|
| 
       48 
48 
     | 
    
         
             
                  child_nodes.empty?
         
     | 
| 
       49 
49 
     | 
    
         
             
                end
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                 
     | 
| 
       52 
     | 
    
         
            -
                   
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                    @node = node
         
     | 
| 
       56 
     | 
    
         
            -
                  end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                  def each(&block)
         
     | 
| 
       59 
     | 
    
         
            -
                    @node.formats.each(&block)
         
     | 
| 
       60 
     | 
    
         
            -
                    @node.children.each { |child| child.resources.each(&block) }
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                  def glob(pattern)
         
     | 
| 
       64 
     | 
    
         
            -
                    paths = Dir.glob(pattern)
         
     | 
| 
       65 
     | 
    
         
            -
                    select { |r| paths.include? r.asset.path.to_s }
         
     | 
| 
      
 51 
     | 
    
         
            +
                def flatten(resources: [])
         
     | 
| 
      
 52 
     | 
    
         
            +
                  formats.each{ |resource| resources << resource }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  children.each do |child|
         
     | 
| 
      
 54 
     | 
    
         
            +
                    child.flatten.each{ |resource| resources << resource }
         
     | 
| 
       66 
55 
     | 
    
         
             
                  end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                def resources
         
     | 
| 
       70 
     | 
    
         
            -
                  Resources.new(node: self)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  resources
         
     | 
| 
       71 
57 
     | 
    
         
             
                end
         
     | 
| 
       72 
58 
     | 
    
         | 
| 
       73 
59 
     | 
    
         
             
                def remove
         
     | 
| 
         @@ -91,18 +77,18 @@ module Mascot 
     | 
|
| 
       91 
77 
     | 
    
         
             
                end
         
     | 
| 
       92 
78 
     | 
    
         
             
                alias :[]= :add
         
     | 
| 
       93 
79 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                def  
     | 
| 
      
 80 
     | 
    
         
            +
                def get(path)
         
     | 
| 
       95 
81 
     | 
    
         
             
                  *path, ext = tokenize(path)
         
     | 
| 
       96 
82 
     | 
    
         
             
                  if node = dig(*path)
         
     | 
| 
       97 
83 
     | 
    
         
             
                    node.formats.ext(ext)
         
     | 
| 
       98 
84 
     | 
    
         
             
                  end
         
     | 
| 
       99 
85 
     | 
    
         
             
                end
         
     | 
| 
       100 
86 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
                def  
     | 
| 
       102 
     | 
    
         
            -
                  *path,  
     | 
| 
      
 87 
     | 
    
         
            +
                def get_node(path)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  *path, _ = tokenize(path)
         
     | 
| 
       103 
89 
     | 
    
         
             
                  dig(*path)
         
     | 
| 
       104 
90 
     | 
    
         
             
                end
         
     | 
| 
       105 
     | 
    
         
            -
                alias :[] : 
     | 
| 
      
 91 
     | 
    
         
            +
                alias :[] :get_node
         
     | 
| 
       106 
92 
     | 
    
         | 
| 
       107 
93 
     | 
    
         
             
                def inspect
         
     | 
| 
       108 
94 
     | 
    
         
             
                  "<#{self.class}: formats=#{formats.map(&:request_path)} children=#{children.map(&:name).inspect}>"
         
     | 
    
        data/lib/mascot/site.rb
    CHANGED
    
    | 
         @@ -16,27 +16,33 @@ module Mascot 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  self.root_path = root_path
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                 
     | 
| 
       20 
     | 
    
         
            -
                  root.resources.glob(root_path.join(glob))
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                # Returns a list of resources.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # A tree representation of the resourecs wthin the site.
         
     | 
| 
       24 
20 
     | 
    
         
             
                def root
         
     | 
| 
       25 
     | 
    
         
            -
                  ResourcesNode.new.tap do | 
     | 
| 
       26 
     | 
    
         
            -
                    DirectoryCollection.new(assets: assets, path: root_path).mount( 
     | 
| 
       27 
     | 
    
         
            -
                    resources_pipeline.process  
     | 
| 
      
 21 
     | 
    
         
            +
                  ResourcesNode.new.tap do |node|
         
     | 
| 
      
 22 
     | 
    
         
            +
                    DirectoryCollection.new(assets: assets, path: root_path).mount(node)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    resources_pipeline.process node
         
     | 
| 
       28 
24 
     | 
    
         
             
                  end
         
     | 
| 
       29 
25 
     | 
    
         
             
                end
         
     | 
| 
       30 
26 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                #  
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                # Returns a list of all the resources within #root.
         
     | 
| 
      
 28 
     | 
    
         
            +
                def resources
         
     | 
| 
      
 29 
     | 
    
         
            +
                  root.flatten
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                def glob(pattern)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  paths = Dir.glob root_path.join(pattern)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  resources.select { |r| paths.include? r.asset.path.to_s }
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                # Find the page with a path.
         
     | 
| 
       38 
38 
     | 
    
         
             
                def get(request_path)
         
     | 
| 
       39 
     | 
    
         
            -
                  root. 
     | 
| 
      
 39 
     | 
    
         
            +
                  root.get(request_path)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                # Quick and dirty way to manipulate resources in the site without
         
     | 
| 
      
 43 
     | 
    
         
            +
                # creating classes that implement the #process_resources method
         
     | 
| 
      
 44 
     | 
    
         
            +
                def manipulate(&block)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  resources_pipeline << Extensions::ProcManipulator.new(block)
         
     | 
| 
       40 
46 
     | 
    
         
             
                end
         
     | 
| 
       41 
47 
     | 
    
         | 
| 
       42 
48 
     | 
    
         
             
                def root_path=(path)
         
     | 
    
        data/lib/mascot/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mascot
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.15
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Brad Gessler
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |