Rspec Screenshot

Rspec Screenshot
Copyright © 2014, 2015 LHA. All rights reserved.

Tuesday, January 27, 2015

PURE Ruby Code Injectors

In this release we have continued the trend towards integration with the Ruby base, and have eliminated all external dependencies from the main library.  It is now all PURE Ruby.  The only dependencies remaining are now the ones needed for the command line utility.

We have also added some more examples, and cleaned up others, and once again tried to improve the ReadMe file.  We are letting everyone know that from now on we will be doing our updates hopefully on a monthly basis or until a release candidate is available.

We would also like to take this opportunity to announce we will be conducting what we have termed a Jackbox Challenge in the coming month.  We hope it will be to everyone's liking and interest.  We will be offering a prize for the winner.  We are still working out the contest rules, but hope to have them ready soon.

Thank you again to all the people who have shown their interest and support, and we hope to see you soon on a website near you.

For more info: http://louhenryalvarez.github.io/jackbox/

Lou

Friday, January 23, 2015

Injector Naming/Tagging

In this release, we primarily increased the integration with the Ruby base and have eliminated the NEED to use #inject/#enrich although these are still recommended for injectors from a cognitive standpoint. However, injectors now accept and it is now completely possible to just use #include/#extend, for which the former are now just aliases, even with Injector Versioning.
Also, we continued the trend to set some design limits on the code, tried to manifest those in the form of Jackbox::UserError, improved injector directive algorithms, cleaned up some of the specs and comments, and once again have improved the Readme file.  Finally, the concept of version naming/tagging was introduced.

    injector :Bar

    Tag = Bar do
      def foo_bar
        'a bar and foo'
      end
    end

    AnotherTag = Bar do
      def foo_bar
        'a foo and bar'
      end
    end


    class One
      inject Tag                                        # first version tag
    end
    One.new.foo_bar.should == 'a bar and foo'


    class Two
      inject AnotherTag                                 # second version tag
    end
    Two.new.foo_bar.should == 'a foo and bar'
   
Please visit us at: https://github.com/LouHenryAlvarez/jackbox
Once again we would like to thank the people who have shown interest, and have sent us their comments. We hope we can keep up with your expectations.  We will certainly try our best to do so.

Thank you,

lha

Injector Versioning

In this release, we have introduced the definition of Injector Versioning.   We have included a separate Rspec file with examples on it, and have expanded the documentation to include a new section describing what it is and how it works. We hope you find it useful.


    # injector declaration
    injector :My_injector

    # first version
    #__________________
    My_injector() do                
      def bar
        :a_bar                                  # version bar.1
      end
      def foo
        # ...
      end
    end

    object1 = Object.new
    object1.enrich My_injector()                # apply --first snapshot
    object1.bar.should == :a_bar                # pass the test

    # second version
    #__________________
    My_injector() do                    
      def bar
        :some_larger_bar                        # version bar.2 --re-defines bar
      end
      def some_other_function
        # ...
      end
    end

    object2 = Object.new
    object2.enrich My_injector()                # apply --second snapshot
    object2.bar.should == :some_larger_bar      # pass the test

                                                ############################
    object1.bar.should == :a_bar                # object1 still using bar.1
                                                ############################
      

We have also started to set design limits to some of the other features for things which fall outside the domain of influence, and eliminated the binaries. Finally, we have improved the ReadMe file to be hopefully, more didactically oriented and easier to follow.

Once again we would like to thank the people who have contacted us for their input on how to better explain what Injectors are, and how to improve the documentation, and please continue to send your comments and  inquiries to the email address on the github page: https://github.com/LouHenryAlvarez/jackbox.

To use the product: gem install jackbox


Thanks again,

lha

Wednesday, January 21, 2015

Injector Orthogonality

In this release we have primarily relegated code in the examples name space to a second plane. It is assumed that if you want to run those examples you will know to enable them in the spec_helper, and that you will have the debugger appropriate for version of Ruby present on your machine as we have eliminated the dependencies.

We have also started a new set of examples on injectors that illustrate some additional properties of injectors we have cataloged under the description of orthogonality. They are intended to do just that, show some of the orthogonality available to injectors with respect to the rest of the library.

In this example we illustrate the various alternate and equivalent ways of working with Injector and member method declarations. Take a look:


class SomeClass
end

injector :Function do
   def meth
   end
end
SomeClass.inject Function()
# ...
SomeClass.eject Function() 



injector :Function
SomeClass.inject Function() do
   def meth
   end
end

# ...
SomeClass.eject Function() 




SomeClass.inject facet :Function do
   def meth
   end
end

# ...
SomeClass.eject Function() 

In this example we show how injectors like other mix-ins can be self extended/enriched, and they can under the right premises also be made to work in conjunction with #decorate and #with.


injector :tester 
                      
tester do                      
   enrich self          
                      
   def meth arg         
      arg * arg
   end
end
tester.meth(4).should == 16  


tester do
   decorate :meth do |arg|    
      super(arg) + 1
   end
end
tester.meth(3).should == 10  

with tester do         
   meth(5).should == 26
   def math arg1, arg2      
      meth(arg1 + arg2)
   end
end
tester.math(3, 2).should == 26 
  

A few last examples before we go.


class SomeClass
end

injector :Ortho

with Ortho() do
   def foo
   end
end

SomeClass.inject Ortho()

# ...


      

   
   

with SomeClass do
   include Ortho()
   extend Ortho(), Ortho()
end
     
# ....

with SomeClass do
   eject *injectors
end
      

  



with Ortho() do
   lets(:brand){'Special Brand'}

   def print
      puts brand
   end
end

enrich Ortho()
make.should == 'Special Brand'
#...
  

We hope you find the code illustrative, and please continue to send your comments and inquiries to the address on Github. We will do our best to answer them as quickly and knowledgeably as we can. Remember that some of this is uncharted territory and we are kind of making it up as we go.

Thanks so much for the people that have show interest, and kind regards to all.


lha

Wednesday, January 14, 2015

Can Closures be Modules?

Well, Ladies and Gents we would like to introduce you to our new library called Jackbox.  It toys with the ideas of closures as modules.  In it you'll find a series of new takes on ruby that are sure to spike you interest.  With it we have come up with a solution to the decorators handicap in ruby and introduced some new constructs for code injection.

 
class ClosureExpose

   some_value = 'some class level value'

   injector :capture do
      define_method :local_value do
         some_value
      end
   end

end

class SecondClass
   include ClosureExpose.capture
end

# the result
obj = SecondClass.new
obj.local_value.should == 'some class level value'

      

Or at the simple object level:
 
Thing = Object.new
Thang = Object.new

injector :agent

Thing.extend agent
Thang.extend agent

agent do                                          # on the fly definitions
   def capability
      'do the deed'
   end
   def location
      'main building'
   end
end

Thing.capability.should == 'do the deed'
Thang.location.should == 'main building'
      

Jackbox Google+

The main library function at this time centers around the concept of code Injectors. To make it easier to grasp the idea behind them, these can perhaps be thought of as a form of closures which can also serve as modules. Most of all Injectors propose some additional interesting properties to the idea of a mix-in. For instance, ...read on

Please feel free to use it free of charge and to send us your comments or inquiries.  Available from RubyGems.org for Linux, Mac, and Windows.  Just run: gem install jackbox.

More info here: https://github.com/LouHenryAlvarez/jackbox

Thank you.