Skip to content

Commit

Permalink
Merge 4730bec into 74f79d3
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov committed Dec 26, 2018
2 parents 74f79d3 + 4730bec commit fc984cd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
3 changes: 1 addition & 2 deletions lib/xcake.rb
@@ -1,5 +1,4 @@
require 'xcake/core_ext/array'
require 'xcake/core_ext/object'
require 'xcake/core_ext/class'
require 'xcake/core_ext/string'

require 'xcake/xcode/project'
Expand Down
5 changes: 0 additions & 5 deletions lib/xcake/core_ext/array.rb

This file was deleted.

14 changes: 14 additions & 0 deletions lib/xcake/core_ext/class.rb
@@ -0,0 +1,14 @@
module Xcake
module CoreExtensions
# @example Including in a class
# Class.send(:include, Xcake::CoreExtensions::ClassDescendants) # done with send because of old ruby versions
#
module ClassDescendants
# Returns all descendants of a class
#
def descendants
ObjectSpace.each_object(singleton_class).select { |klass| klass < self }
end
end
end
end
7 changes: 0 additions & 7 deletions lib/xcake/core_ext/object.rb

This file was deleted.

6 changes: 3 additions & 3 deletions lib/xcake/dependency_provider.rb
Expand Up @@ -7,9 +7,9 @@ class DependencyProvider
def initialize(dependency_class)
plugins = dependency_class.load_plugins

@dependency_graph = plugins.map do |p|
[p, p.dependencies]
end.to_h
@dependency_graph = plugins.each_with_object({}) do |p, hash|
hash[p] = p.dependencies
end
end

def tsort_each_node(&block)
Expand Down
1 change: 1 addition & 0 deletions lib/xcake/generator.rb
Expand Up @@ -3,6 +3,7 @@ class Generator
include Dependency
include Plugin
include Visitor
Class.send(:include, CoreExtensions::ClassDescendants) # done with send because of old ruby versions

attr_accessor :context

Expand Down
7 changes: 0 additions & 7 deletions spec/core_ext/array_spec.rb

This file was deleted.

4 changes: 3 additions & 1 deletion spec/core_ext/object_spec.rb → spec/core_ext/class_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'

class Parent
Class.send(:include, Xcake::CoreExtensions::ClassDescendants) # done with send because of old ruby versions
end

class Child < Parent
Expand All @@ -9,10 +10,11 @@ class Child < Parent
class Grandchild < Child
end

describe Object do
describe Xcake::CoreExtensions do
it 'should return all descendants' do
descendants = Parent.descendants

expect(descendants.count).to eq(2)
expect(descendants).to include(Child)
expect(descendants).to include(Grandchild)
end
Expand Down

0 comments on commit fc984cd

Please sign in to comment.