facade-1.1.0/0000755000004100000410000000000013425022570012744 5ustar www-datawww-datafacade-1.1.0/test/0000755000004100000410000000000013425022570013723 5ustar www-datawww-datafacade-1.1.0/test/test_facade.rb0000644000004100000410000000262313425022570016515 0ustar www-datawww-data######################################################################### # test_facade.rb # # Test suite for the Facade module. This test suite should be run via # the 'rake test' task. ######################################################################### require 'test/unit' require 'facade' module Baz def testme(str) str end end class FooString < String extend Facade facade File, :basename, 'dirname' facade Dir facade Baz def blockdev? 'test' end end class TC_Facade < Test::Unit::TestCase def setup @str = FooString.new('/home/djberge') end def test_facade_version assert_equal('1.1.0', Facade::FACADE_VERSION) assert_true(Facade::FACADE_VERSION.frozen?) end def test_file_methods assert_respond_to(@str, :basename) assert_respond_to(@str, :dirname) assert_raises(NoMethodError){ @str.executable? } assert_raises(NoMethodError){ @str.chardev? } end def test_file_method_return_values assert_equal('djberge', @str.basename) assert_equal('/home', @str.dirname) end def test_dir_methods assert_respond_to(@str, :pwd) assert_respond_to(@str, :entries) end def test_no_clobber assert_respond_to(@str, :blockdev?) assert_equal('test', @str.blockdev?) end def test_module_methods assert_respond_to(@str, :testme) assert_equal('/home/djberge', @str.testme) end def teardown @str = nil end end facade-1.1.0/MANIFEST0000644000004100000410000000017113425022570014074 0ustar www-datawww-data* CHANGES * MANIFEST * README * Rakefile * facade.gemspec * certs/djberg96_pub.pem * lib/facade.rb * test/test_facade.rb facade-1.1.0/data.tar.gz.sig0000444000004100000410000000060013425022570015557 0ustar www-datawww-dataDL,*UNBnkʟk}{ߩӷ-qR SM<ҳGM>>&|ofb9э12 Ao9;m*#H-B2V[5T`k g:=-ЎIvzTQY:'):]ɘ.Sh @GW̕:mI-޴s4kN|1ڌyrf 즟{%e8G[HR$z1>=]Ն.ljcB(d'e7$ M !p#TnBҏԚfacade-1.1.0/facade.gemspec0000644000004100000410000000233113425022570015513 0ustar www-datawww-datarequire 'rubygems' Gem::Specification.new do |spec| spec.name = 'facade' spec.version = '1.1.0' spec.author = 'Daniel J. Berger' spec.license = 'Apache-2.0' spec.email = 'djberg96@gmail.com' spec.homepage = 'https://github.com/djberg96/facade' spec.summary = 'An easy way to implement the facade pattern in your class' spec.test_file = 'test/test_facade.rb' spec.files = Dir['**/*'].reject{ |f| f.include?('git') } spec.cert_chain = ['certs/djberg96_pub.pem'] spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST'] spec.add_development_dependency('rake') spec.metadata = { 'homepage_uri' => 'https://github.com/djberg96/facade', 'bug_tracker_uri' => 'https://github.com/djberg96/facade/issues', 'changelog_uri' => 'https://github.com/djberg96/facade/blob/master/CHANGES', 'documentation_uri' => 'https://github.com/djberg96/facade/wiki', 'source_code_uri' => 'https://github.com/djberg96/facade', 'wiki_uri' => 'https://github.com/djberg96/facade/wiki' } spec.description = <<-EOF The facade library allows you to mixin singleton methods from classes or modules as instance methods of the extending class. EOF end facade-1.1.0/certs/0000755000004100000410000000000013425022570014064 5ustar www-datawww-datafacade-1.1.0/certs/djberg96_pub.pem0000644000004100000410000000307613425022570017057 0ustar www-datawww-data-----BEGIN CERTIFICATE----- MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3 ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh -----END CERTIFICATE----- facade-1.1.0/CHANGES0000644000004100000410000000207113425022570013737 0ustar www-datawww-data== 1.1.0 - 28-Jan-2019 * License switched to Apache-2.0. * The FACADE_VERSION constant is now frozen. * Added some metadata to the gemspec. * Updated the cert, should be good for about 10 years. == 1.0.7 - 9-Sep-2015 * This gem is now signed. * The Rakefile tasks now assume Rubygems 2.x. == 1.0.6 - 12-Oct-2014 * Updates to the gemspec and Rakefile. == 1.0.5 - 10-Nov-2010 * Refactored the Rakefile. == 1.0.4 - 3-Aug-2009 * Fixed a symbol vs string issue for Ruby 1.9.x. == 1.0.3 - 21-Jul-2009 * License changed to Artistic 2.0. * Documentation updates. * Test file renamed to test_facade.rb. * Some Rakefile and gemspec updates * One test modified so that it passes with 1.9.x as well. == 1.0.2 - 11-Jun-2007 * Added a Rakefile with tasks for installation and testing. * Removed the install.rb file. Installation is now handled as a Rake task. * Some test suite refactoring. * Fixed the FACADE_VERSION number (now 1.0.2, was 1.1.0). == 1.0.1 - 8-Jun-2005 * Moved project to RubyForge. * Added a .gemspec file. * Added a MANIFEST. == 1.0.0 - 18-May-2005 * Initial release facade-1.1.0/metadata.gz.sig0000444000004100000410000000060013425022570015641 0ustar www-datawww-data^,V`pcbI[cMawS!Um28Y72-m,!ݫ\FO,JWîB?" J`.;1rIt$wE`cV:$v ˆqg1 VmǂrCk_z_|a{֑Ʃ [:clean] do require 'rubygems/package' spec = eval(IO.read('facade.gemspec')) spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem') Gem::Package.build(spec) end desc 'Install the facade gem' task :install => [:create] do file = Dir["*.gem"].first sh "gem install -l #{file}" end end Rake::TestTask.new do |t| t.libs << 'test' t.verbose = true t.warning = true end task :default => :test facade-1.1.0/lib/0000755000004100000410000000000013425022570013512 5ustar www-datawww-datafacade-1.1.0/lib/facade.rb0000644000004100000410000000265413425022570015251 0ustar www-datawww-datamodule Facade # The version of the facade library FACADE_VERSION = '1.1.0'.freeze # The facade method will forward a singleton method as an instance # method of the extending class. If no arguments are provided, then all # singleton methods of the class or module become instance methods. # # Existing instance methods are NOT overridden, but are instead ignored. # # Example: # # require 'facade' # # class MyString < String # extend Facade # facade File, :dirname, :basename # end # # s = MyString.new('/home/djberge') # s.basename # => 'djberge' # s.dirname # => '/home' # def facade(klass, *methods) methods = methods.flatten if methods.empty? # Default to all methods if klass.kind_of?(Class) methods = klass.methods(false) else methods = klass.public_instance_methods(false) end end # Convert all strings to symbols to stay sane between 1.8.x and 1.9.x methods = methods.map{ |m| m.to_sym } methods -= self.instance_methods.map{ |m| m.to_sym } # No clobber methods.each do |methname| define_method(methname){ if klass.kind_of?(Class) meth = klass.method(methname) else meth = Object.new.extend(klass).method(methname) end if meth.arity.zero? # Zero or one argument meth.call else meth.call(self) end } end end end facade-1.1.0/README0000644000004100000410000000157113425022570013630 0ustar www-datawww-data== Synopsis An easy way to implement the facade pattern in your classes. In short, this library wraps singleton methods from another class as instance methods of the current class. == Installation gem install facade == Usage require 'facade' class MyString < String extend Facade facade File, :dirname, :basename end f = MyString.new('/home/djberge') puts f.basename # 'djberge' puts f.dirname # '/home' == Acknowledgements Eero Saynatkari, Eric Hodel and Michael Granger for ideas and code which I shamelessly plagiarized. == Copyright Copyright (c) 2005-2019 Daniel J. Berger == License Apache-2.0 == Warranty This package is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose == Author Daniel J. Berger