qricker 0.0.7 → 0.0.8
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/SUMMARY.md +1 -0
- data/lib/qricker/dependency.rb +137 -4
- data/lib/qricker/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 119efee59977a04778db633dd450371a048dcb10
         | 
| 4 | 
            +
              data.tar.gz: 5b92a34bb285f8dd3a0b03ceac858a664be53390
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fa89b0c7095e18934465684ea6bd32be8c479a5716da92f0eb4fa42919f04589dc1d00c4495df988f43375eebb8ef7cb44f020ca02b0bd55fa9184546620bdaf
         | 
| 7 | 
            +
              data.tar.gz: 3a5fa92b479d3f196b27fbae493eb95004eced911b4799e145bd8f84835a11f264878d97393a174c8144db9bdb08a17fe9e72c21101d40aff3dfc94ef1061d19
         | 
    
        data/SUMMARY.md
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            * [README.md](/README.md)
         | 
    
        data/lib/qricker/dependency.rb
    CHANGED
    
    | @@ -5,6 +5,136 @@ require_relative "module.rb" | |
| 5 5 | 
             
            require_relative "podspecs.rb"
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Qricker
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              class DependencyNode
         | 
| 10 | 
            +
                attr_accessor :name
         | 
| 11 | 
            +
                attr_accessor :childs
         | 
| 12 | 
            +
                def initialize(name)
         | 
| 13 | 
            +
                  @name = name
         | 
| 14 | 
            +
                  @childs = []
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def hasChild(childName)
         | 
| 18 | 
            +
                  subs = @childs.map { |c|
         | 
| 19 | 
            +
                    c if  c.name == childName
         | 
| 20 | 
            +
                  }.compact
         | 
| 21 | 
            +
                  subs.count > 0
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def removeChild(child)
         | 
| 25 | 
            +
                  @childs.delete child
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def containsChild?(child)
         | 
| 29 | 
            +
                  not searchChild(child).nil?
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def addChild(child)
         | 
| 33 | 
            +
                  if containsChild? child.name
         | 
| 34 | 
            +
                  else
         | 
| 35 | 
            +
                    @childs << child
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def searchChild(childName)
         | 
| 40 | 
            +
                  aimChild = nil
         | 
| 41 | 
            +
                  for child in @childs
         | 
| 42 | 
            +
                    if (child.name == childName)
         | 
| 43 | 
            +
                      aimChild = child
         | 
| 44 | 
            +
                      break
         | 
| 45 | 
            +
                    else
         | 
| 46 | 
            +
                      aimChild = child.searchChild(childName)
         | 
| 47 | 
            +
                      if not aimChild.nil?
         | 
| 48 | 
            +
                        break
         | 
| 49 | 
            +
                      end
         | 
| 50 | 
            +
                    end
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  return aimChild
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def printSelf(level)
         | 
| 57 | 
            +
                  line = "--"
         | 
| 58 | 
            +
                  level.times {
         | 
| 59 | 
            +
                    line+="--"
         | 
| 60 | 
            +
                  }
         | 
| 61 | 
            +
                  puts "#{line}#{@name}"
         | 
| 62 | 
            +
                  @childs.each { |child|
         | 
| 63 | 
            +
                    child.printSelf(level+1)
         | 
| 64 | 
            +
                  }
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
              class Resolver
         | 
| 69 | 
            +
                def initialize(deps)
         | 
| 70 | 
            +
                  @roots = DependencyNode.new("root")
         | 
| 71 | 
            +
                  @deps = deps
         | 
| 72 | 
            +
                  deps.each { |spec|
         | 
| 73 | 
            +
                    dependencies =  spec.podSpecilication.attributes_hash["dependencies"]
         | 
| 74 | 
            +
                    next if  dependencies.nil?
         | 
| 75 | 
            +
                    dependencies.each { |name , versions|
         | 
| 76 | 
            +
                      addDependency(name, spec.name)
         | 
| 77 | 
            +
                    }
         | 
| 78 | 
            +
                  }
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                def addDependency(parent, child)
         | 
| 82 | 
            +
                  parentNode = @roots.searchChild(parent)
         | 
| 83 | 
            +
                  if parentNode.nil?
         | 
| 84 | 
            +
                    parentNode = DependencyNode.new(parent)
         | 
| 85 | 
            +
                    @roots.addChild(parentNode)
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                  childNode = nil
         | 
| 88 | 
            +
                  if @roots.hasChild(child)
         | 
| 89 | 
            +
                    childNode = @roots.searchChild(child)
         | 
| 90 | 
            +
                    @roots.removeChild childNode
         | 
| 91 | 
            +
                  else
         | 
| 92 | 
            +
                    childNode = DependencyNode.new(child)
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
                  if parentNode.searchChild(child).nil?
         | 
| 95 | 
            +
                    parentNode.addChild(childNode)
         | 
| 96 | 
            +
                  end
         | 
| 97 | 
            +
                  @roots.printSelf(0)
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                def sorted
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  array = Array.new
         | 
| 103 | 
            +
                  addSortedArray(array, @roots)
         | 
| 104 | 
            +
                  deps = @deps.sort{|x, y|
         | 
| 105 | 
            +
                    xIndex = array.index(x.name)
         | 
| 106 | 
            +
                    yIndex =  array.index(y.name)
         | 
| 107 | 
            +
                    xIndex <=> yIndex
         | 
| 108 | 
            +
                  }
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  return deps
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                private
         | 
| 114 | 
            +
                def addSortedArray(array, node)
         | 
| 115 | 
            +
                  spec = nil
         | 
| 116 | 
            +
                  baseIndex = array.count
         | 
| 117 | 
            +
                  for n in node.childs
         | 
| 118 | 
            +
                    if array.include?(n.name)
         | 
| 119 | 
            +
                      index = array.index(n.name)
         | 
| 120 | 
            +
                      baseIndex = index+1
         | 
| 121 | 
            +
                    else
         | 
| 122 | 
            +
                      array.insert(baseIndex, n.name)
         | 
| 123 | 
            +
                    end
         | 
| 124 | 
            +
                  end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                  for n in node.childs
         | 
| 127 | 
            +
                     addSortedArray(array, n)
         | 
| 128 | 
            +
                  end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                def printSelf
         | 
| 133 | 
            +
                  @roots.printSelf(0)
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
              end
         | 
| 137 | 
            +
             | 
| 8 138 | 
             
              def Qricker.collectDependencies(config,dependecies, originSpec)
         | 
| 9 139 | 
             
                if config.get_groups.include?(originSpec)
         | 
| 10 140 | 
             
                  podspec = Pod::Specification.from_file(config[originSpec]["PATH"]+"/#{originSpec}.podspec")
         | 
| @@ -37,8 +167,12 @@ module Qricker | |
| 37 167 | 
             
                    outputDependencies << spec
         | 
| 38 168 | 
             
                  end
         | 
| 39 169 | 
             
                }
         | 
| 40 | 
            -
                 | 
| 41 | 
            -
             | 
| 170 | 
            +
                return sortDenpencies outputDependencies
         | 
| 171 | 
            +
              end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
              def Qricker.sortDenpencies(deps)
         | 
| 174 | 
            +
                resolver = Resolver.new(deps)
         | 
| 175 | 
            +
                resolver.sorted
         | 
| 42 176 | 
             
              end
         | 
| 43 177 |  | 
| 44 178 | 
             
              def Qricker.dependencyIncludeSelf(localfile, specnames)
         | 
| @@ -60,7 +194,6 @@ module Qricker | |
| 60 194 | 
             
                    outputDependencies << spec
         | 
| 61 195 | 
             
                  end
         | 
| 62 196 | 
             
                }
         | 
| 63 | 
            -
                return outputDependencies
         | 
| 64 | 
            -
             | 
| 197 | 
            +
                return sortDenpencies(outputDependencies)
         | 
| 65 198 | 
             
              end
         | 
| 66 199 | 
             
            end
         | 
    
        data/lib/qricker/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: qricker
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Your Name Here
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-12-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         | 
| @@ -111,6 +111,7 @@ files: | |
| 111 111 | 
             
            - README.md
         | 
| 112 112 | 
             
            - README.rdoc
         | 
| 113 113 | 
             
            - Rakefile
         | 
| 114 | 
            +
            - SUMMARY.md
         | 
| 114 115 | 
             
            - bin/qricker
         | 
| 115 116 | 
             
            - features/qricker.feature
         | 
| 116 117 | 
             
            - features/step_definitions/qricker_steps.rb
         |