descendants_tracker-0.0.4/0000755000004100000410000000000012324243255015553 5ustar www-datawww-datadescendants_tracker-0.0.4/Rakefile0000640000004100000410000000010012324243255017203 0ustar www-datawww-data# encoding: utf-8 require 'devtools' Devtools.init_rake_tasks descendants_tracker-0.0.4/Gemfile0000644000004100000410000000027512324243255017052 0ustar www-datawww-data# encoding: utf-8 source 'https://rubygems.org' gemspec group :development, :test do gem 'devtools', git: 'https://github.com/rom-rb/devtools.git' end eval_gemfile 'Gemfile.devtools' descendants_tracker-0.0.4/Gemfile.devtools0000644000004100000410000000315212324243255020705 0ustar www-datawww-data# encoding: utf-8 group :development do gem 'rake', '~> 10.2.1' gem 'rspec', '~> 2.14.1' gem 'rspec-core', '~> 2.14.8' gem 'yard', '~> 0.8.7.4' platform :rbx do gem 'rubysl-singleton', '~> 2.0.0' end end group :yard do gem 'kramdown', '~> 1.3.3' end group :guard do gem 'guard', '~> 2.6.0' gem 'guard-bundler', '~> 2.0.0' gem 'guard-rspec', '~> 4.2.8' gem 'guard-rubocop', '~> 1.0.2' # file system change event handling gem 'listen', '~> 2.7.1' gem 'rb-fchange', '~> 0.0.6', require: false gem 'rb-fsevent', '~> 0.9.4', require: false gem 'rb-inotify', '~> 0.9.3', require: false # notification handling gem 'libnotify', '~> 0.8.2', require: false gem 'rb-notifu', '~> 0.0.4', require: false gem 'terminal-notifier-guard', '~> 1.5.3', require: false end group :metrics do gem 'coveralls', '~> 0.7.0' gem 'flay', '~> 2.4.0' gem 'flog', '~> 4.2.0' gem 'reek', '~> 1.3.7' gem 'rubocop', '~> 0.19.1' gem 'simplecov', '~> 0.8.2' gem 'yardstick', '~> 0.9.9' platforms :mri do gem 'mutant', '~> 0.5.8' gem 'mutant-rspec', '~> 0.5.3' end platforms :ruby_19, :ruby_20 do gem 'yard-spellcheck', '~> 0.1.5' end platform :rbx do gem 'json', '~> 1.8.1' gem 'racc', '~> 1.4.11' gem 'rubysl-logger', '~> 2.0.0' gem 'rubysl-open-uri', '~> 2.0.0' gem 'rubysl-prettyprint', '~> 2.0.3' end end group :benchmarks do gem 'rbench', '~> 0.2.3' end platform :jruby do group :jruby do gem 'jruby-openssl', '~> 0.8.5' end end descendants_tracker-0.0.4/.rspec0000644000004100000410000000007612324243255016673 0ustar www-datawww-data--color --format progress --order random --profile --warnings descendants_tracker-0.0.4/spec/0000755000004100000410000000000012324243255016505 5ustar www-datawww-datadescendants_tracker-0.0.4/spec/rcov.opts0000640000004100000410000000015712324243255020364 0ustar www-datawww-data--exclude-only "spec/,^/" --sort coverage --callsites --xrefs --profile --text-summary --failure-threshold 100 descendants_tracker-0.0.4/spec/spec.opts0000640000004100000410000000005112324243255020336 0ustar www-datawww-data--color --loadby random --format profile descendants_tracker-0.0.4/spec/spec_helper.rb0000644000004100000410000000107512324243255021326 0ustar www-datawww-data# encoding: utf-8 if ENV['COVERAGE'] == 'true' require 'simplecov' require 'coveralls' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start do command_name 'spec:unit' add_filter 'config' add_filter 'spec' add_filter 'vendor' minimum_coverage 100 end end require 'devtools/spec_helper' require 'descendants_tracker' RSpec.configure do |config| config.expect_with :rspec do |expect_with| expect_with.syntax = :expect end end descendants_tracker-0.0.4/spec/unit/0000755000004100000410000000000012324243255017464 5ustar www-datawww-datadescendants_tracker-0.0.4/spec/unit/descendants_tracker/0000755000004100000410000000000012324243255023472 5ustar www-datawww-datadescendants_tracker-0.0.4/spec/unit/descendants_tracker/inherited_spec.rb0000644000004100000410000000131412324243255027003 0ustar www-datawww-data# encoding: utf-8 require 'spec_helper' describe DescendantsTracker, '#inherited' do subject { Class.new(object) } let!(:object) { Class.new(superklass).extend(self.class.described_class) } let(:superklass) { Class.new } it 'delegates to the superclass #inherited method' do superklass.should_receive(:inherited) do |descendant| expect(descendant).to be_instance_of(Class) expect(descendant.ancestors).to include(object) end subject end it 'adds the descendant' do expect(object.descendants).to include(subject) end it 'sets up descendants in the child class' do expect(subject.descendants).to eql([]) end end descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb0000644000004100000410000000144412324243255027754 0ustar www-datawww-data# encoding: utf-8 require 'spec_helper' describe DescendantsTracker, '#add_descendant' do subject { object.add_descendant(descendant) } let(:described_class) { Class.new { extend DescendantsTracker } } let(:object) { Class.new(described_class) } let(:descendant) { Class.new } it_should_behave_like 'a command method' it 'prepends the class to the descendants' do object.descendants << original = Class.new expect { subject }.to change { object.descendants.dup } .from([original]) .to([descendant, original]) end it 'prepends the class to the superclass descendants' do expect { subject }.to change { object.superclass.descendants.dup } .from([object]) .to([descendant, object]) end end descendants_tracker-0.0.4/spec/unit/descendants_tracker/descendants_spec.rb0000644000004100000410000000113412324243255027323 0ustar www-datawww-data# encoding: utf-8 require 'spec_helper' describe DescendantsTracker, '#descendants' do subject { object.descendants } let(:described_class) { Class.new { extend DescendantsTracker } } let(:object) { described_class } context 'when there are no descendants' do it_should_behave_like 'an idempotent method' it { should be_empty } end context 'when there are descendants' do let!(:descendant) { Class.new(object) } # trigger the class inhertance it_should_behave_like 'an idempotent method' it { should eql([descendant]) } end end descendants_tracker-0.0.4/spec/support/0000755000004100000410000000000012324243255020221 5ustar www-datawww-datadescendants_tracker-0.0.4/spec/support/config_alias.rb0000644000004100000410000000012512324243255023162 0ustar www-datawww-data# encoding: utf-8 require 'rbconfig' ::Config = RbConfig unless defined?(::Config) descendants_tracker-0.0.4/.travis.yml0000644000004100000410000000135212324243255017665 0ustar www-datawww-datalanguage: ruby before_install: gem install bundler bundler_args: --without yard guard benchmarks script: "bundle exec rake ci:metrics" rvm: - 1.9.3 - 2.0.0 - 2.1.0 - 2.1.1 - ruby-head - rbx-2 matrix: include: - rvm: jruby-19mode env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov - rvm: jruby-20mode env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov - rvm: jruby-21mode env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov - rvm: jruby-head env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov allow_failures: - rvm: 2.1.0 # buggy runtime fast_finish: true notifications: irc: channels: - irc.freenode.org#rom-rb on_success: never on_failure: change descendants_tracker-0.0.4/lib/0000755000004100000410000000000012324243255016321 5ustar www-datawww-datadescendants_tracker-0.0.4/lib/descendants_tracker/0000755000004100000410000000000012324243255022327 5ustar www-datawww-datadescendants_tracker-0.0.4/lib/descendants_tracker/version.rb0000644000004100000410000000020512324243255024336 0ustar www-datawww-data# encoding: utf-8 module DescendantsTracker # Unreleased gem version VERSION = '0.0.4'.freeze end # module DescendantsTracker descendants_tracker-0.0.4/lib/descendants_tracker.rb0000644000004100000410000000237212324243255022660 0ustar www-datawww-data# encoding: utf-8 require 'thread_safe' # Module that adds descendant tracking to a class module DescendantsTracker # Return the descendants of this class # # @example # descendants = ParentClass.descendants # # @return [Array>] # # @api public attr_reader :descendants # Setup the class for descendant tracking # # @param [Class] descendant # # @return [undefined] # # @api private def self.setup(descendant) descendant.instance_variable_set(:@descendants, ThreadSafe::Array.new) end class << self alias_method :extended, :setup private :extended end # Add the descendant to this class and the superclass # # @param [Class] descendant # # @return [self] # # @api private def add_descendant(descendant) ancestor = superclass if ancestor.respond_to?(:add_descendant) ancestor.add_descendant(descendant) end descendants.unshift(descendant) self end private # Hook called when class is inherited # # @param [Class] descendant # # @return [self] # # @api private def inherited(descendant) super DescendantsTracker.setup(descendant) add_descendant(descendant) end end # module DescendantsTracker descendants_tracker-0.0.4/metadata.yml0000644000004100000410000000551112324243255020060 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: descendants_tracker version: !ruby/object:Gem::Version version: 0.0.4 platform: ruby authors: - Dan Kubb - Piotr Solnica - Markus Schirp autorequire: bindir: bin cert_chain: [] date: 2014-03-27 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: thread_safe requirement: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '0.3' - - '>=' - !ruby/object:Gem::Version version: 0.3.1 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '0.3' - - '>=' - !ruby/object:Gem::Version version: 0.3.1 - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.5' - - '>=' - !ruby/object:Gem::Version version: 1.5.3 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.5' - - '>=' - !ruby/object:Gem::Version version: 1.5.3 description: Module that adds descendant tracking to a class email: - dan.kubb@gmail.com - piotr.solnica@gmail.com - mbj@schirp-dso.com executables: [] extensions: [] extra_rdoc_files: - LICENSE - README.md - CONTRIBUTING.md - TODO files: - .gitignore - .rspec - .ruby-gemset - .travis.yml - CONTRIBUTING.md - Gemfile - Gemfile.devtools - Guardfile - LICENSE - README.md - Rakefile - TODO - config/devtools.yml - config/flay.yml - config/flog.yml - config/mutant.yml - config/reek.yml - config/rubocop.yml - config/yardstick.yml - descendants_tracker.gemspec - lib/descendants_tracker.rb - lib/descendants_tracker/version.rb - spec/rcov.opts - spec/spec.opts - spec/spec_helper.rb - spec/support/config_alias.rb - spec/unit/descendants_tracker/add_descendant_spec.rb - spec/unit/descendants_tracker/descendants_spec.rb - spec/unit/descendants_tracker/inherited_spec.rb homepage: https://github.com/dkubb/descendants_tracker licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: Module that adds descendant tracking to a class test_files: - spec/unit/descendants_tracker/add_descendant_spec.rb - spec/unit/descendants_tracker/descendants_spec.rb - spec/unit/descendants_tracker/inherited_spec.rb has_rdoc: descendants_tracker-0.0.4/.gitignore0000640000004100000410000000040712324243255017540 0ustar www-datawww-data## MAC OS .DS_Store ## TEXTMATE *.tmproj tmtags ## EMACS *~ \#* .\#* ## VIM *.swp ## Rubinius *.rbc .rbx ## PROJECT::GENERAL *.gem coverage profiling turbulence rdoc pkg tmp doc log .yardoc measurements ## BUNDLER .bundle Gemfile.lock ## PROJECT::SPECIFIC descendants_tracker-0.0.4/config/0000755000004100000410000000000012324243255017020 5ustar www-datawww-datadescendants_tracker-0.0.4/config/flay.yml0000644000004100000410000000004012324243255020470 0ustar www-datawww-data--- threshold: 2 total_score: 4 descendants_tracker-0.0.4/config/reek.yml0000644000004100000410000000346612324243255020502 0ustar www-datawww-data--- Attribute: enabled: true exclude: - DescendantsTracker BooleanParameter: enabled: true exclude: [] ClassVariable: enabled: true exclude: [] ControlParameter: enabled: true exclude: [] DataClump: enabled: true exclude: [] max_copies: 2 min_clump_size: 2 DuplicateMethodCall: enabled: true exclude: [] max_calls: 1 allow_calls: [] FeatureEnvy: enabled: true exclude: [] IrresponsibleModule: enabled: true exclude: [] LongParameterList: enabled: true exclude: [] max_params: 2 overrides: initialize: max_params: 3 LongYieldList: enabled: true exclude: [] max_params: 2 NestedIterators: enabled: true exclude: [] max_allowed_nesting: 1 ignore_iterators: [] NilCheck: enabled: true exclude: [] RepeatedConditional: enabled: true exclude: [] max_ifs: 1 TooManyInstanceVariables: enabled: true exclude: [] max_instance_variables: 3 TooManyMethods: enabled: true exclude: [] max_methods: 10 TooManyStatements: enabled: true exclude: - DescendantsTracker#add_descendant - DescendantsTracker#inherited - each max_statements: 2 UncommunicativeMethodName: enabled: true exclude: [] reject: - !ruby/regexp /^[a-z]$/ - !ruby/regexp /[0-9]$/ - !ruby/regexp /[A-Z]/ accept: [] UncommunicativeModuleName: enabled: true exclude: [] reject: - !ruby/regexp /^.$/ - !ruby/regexp /[0-9]$/ accept: [] UncommunicativeParameterName: enabled: true exclude: [] reject: - !ruby/regexp /^.$/ - !ruby/regexp /[0-9]$/ - !ruby/regexp /[A-Z]/ accept: [] UncommunicativeVariableName: enabled: true exclude: [] reject: - !ruby/regexp /^.$/ - !ruby/regexp /[0-9]$/ - !ruby/regexp /[A-Z]/ accept: [] UnusedParameters: enabled: true exclude: [] UtilityFunction: enabled: true exclude: [] max_helper_calls: 0 descendants_tracker-0.0.4/config/devtools.yml0000644000004100000410000000006612324243255021404 0ustar www-datawww-data--- unit_test_timeout: 0.1 fail_on_branch: - "master" descendants_tracker-0.0.4/config/yardstick.yml0000640000004100000410000000002312324243255021527 0ustar www-datawww-data--- threshold: 100 descendants_tracker-0.0.4/config/rubocop.yml0000644000004100000410000000304612324243255021217 0ustar www-datawww-dataAllCops: Includes: - '**/*.rake' - 'Gemfile' - 'Gemfile.devtools' Excludes: - '**/vendor/**' - '**/benchmarks/**' # Avoid parameter lists longer than five parameters. ParameterLists: Max: 3 CountKeywordArgs: true # Avoid more than `Max` levels of nesting. BlockNesting: Max: 3 # Align with the style guide. CollectionMethods: PreferredMethods: collect: 'map' inject: 'reduce' find: 'detect' find_all: 'select' # Do not force public/protected/private keyword to be indented at the same # level as the def keyword. My personal preference is to outdent these keywords # because I think when scanning code it makes it easier to identify the # sections of code and visually separate them. When the keyword is at the same # level I think it sort of blends in with the def keywords and makes it harder # to scan the code and see where the sections are. AccessModifierIndentation: Enabled: false # Limit line length LineLength: Max: 79 # Disable documentation checking until a class needs to be documented once Documentation: Enabled: false # Do not favor modifier if/unless usage when you have a single-line body IfUnlessModifier: Enabled: false # Allow case equality operator (in limited use within the specs) CaseEquality: Enabled: false # Constants do not always have to use SCREAMING_SNAKE_CASE ConstantName: Enabled: false # Not all trivial readers/writers can be defined with attr_* methods TrivialAccessors: Enabled: false # Allow empty lines around body EmptyLinesAroundBody: Enabled: false descendants_tracker-0.0.4/config/flog.yml0000640000004100000410000000002312324243255020461 0ustar www-datawww-data--- threshold: 5.5 descendants_tracker-0.0.4/config/mutant.yml0000640000004100000410000000007412324243255021050 0ustar www-datawww-data--- name: descendants_tracker namespace: DescendantsTracker descendants_tracker-0.0.4/descendants_tracker.gemspec0000644000004100000410000000164012324243255023127 0ustar www-datawww-data# encoding: utf-8 require File.expand_path('../lib/descendants_tracker/version', __FILE__) Gem::Specification.new do |gem| gem.name = 'descendants_tracker' gem.version = DescendantsTracker::VERSION.dup gem.authors = [ 'Dan Kubb', 'Piotr Solnica', 'Markus Schirp' ] gem.email = %w[ dan.kubb@gmail.com piotr.solnica@gmail.com mbj@schirp-dso.com ] gem.description = 'Module that adds descendant tracking to a class' gem.summary = gem.description gem.homepage = 'https://github.com/dkubb/descendants_tracker' gem.license = 'MIT' gem.require_paths = %w[lib] gem.files = `git ls-files`.split($/) gem.test_files = `git ls-files -- spec/unit`.split($/) gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO] gem.add_runtime_dependency('thread_safe', '~> 0.3', '>= 0.3.1') gem.add_development_dependency('bundler', '~> 1.5', '>= 1.5.3') end descendants_tracker-0.0.4/CONTRIBUTING.md0000644000004100000410000000201112324243255017776 0ustar www-datawww-data# Contributing * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin. * Fork the project. * Make your feature addition or bug fix. * Follow this [style guide](https://github.com/dkubb/styleguide). * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered. * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged. * Send me a pull request. Bonus points for topic branches. descendants_tracker-0.0.4/LICENSE0000640000004100000410000000222112324243255016551 0ustar www-datawww-dataCopyright (c) 2012-2013 Dan Kubb (author) Copyright (c) 2011-2012 Piotr Solnica (source maintainer) Copyright (c) 2012 Markus Schirp (packaging) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. descendants_tracker-0.0.4/.ruby-gemset0000644000004100000410000000002412324243255020013 0ustar www-datawww-datadescendants_tracker descendants_tracker-0.0.4/TODO0000640000004100000410000000000012324243255016225 0ustar www-datawww-datadescendants_tracker-0.0.4/checksums.yaml.gz0000444000004100000410000000041512324243255021041 0ustar www-datawww-data3Se;r@ D=^`F3g@_"gz=~|?ÿL%*\7W9nE5LWo$F46Ա%Ie0 ٹ%'#eDq\{eSAG;iX#**+Gn [Bar] ``` ## Credits * Dan Kubb ([dkubb](https://github.com/dkubb)) * Piotr Solnica ([solnic](https://github.com/solnic)) * Markus Schirp ([mbj](https://github.com/mbj)) ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) for details. ## Copyright Copyright © 2012-2013 Dan Kubb (author) Copyright © 2011-2012 Piotr Solnica (source maintainer) Copyright © 2012 Markus Schirp (packaging) See LICENSE for details. descendants_tracker-0.0.4/Guardfile0000640000004100000410000000117112324243255017374 0ustar www-datawww-data# encoding: utf-8 guard :bundler do watch('Gemfile') end guard :rspec do # run all specs if the spec_helper or supporting files files are modified watch('spec/spec_helper.rb') { 'spec' } watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' } # run unit specs if associated lib code is modified watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] } watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' } # run a spec if it is modified watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z}) end