Wednesday, July 26, 2017

Glimmer Ruby Desktop Library Version 0.1.9.470

Glimmer Ruby Desktop Library Version 0.1.9.470 is released!

It now supports one-way Tree data-binding similar to that of SWT Table.

Example:



You may learn more from the screenshot and rspec test included below.


Happy Glimmering!

Tuesday, July 25, 2017

Puts Debuggerer v0.7.1 with run_at condition option

Puts Debuggerer v0.7.1 is out.

(defaults to awesome_print as its print_engine now)

Ever wished you'd see debug statements only the first time a puts statement executes, and avoid printing 10 or 100 times in a test run? Now you can with PutsDebuggerer.run_at option.

PutsDebuggerer.run_at

(default = nil)
Set condition for when to run as specified by an index, array, or range.
  • Default value is nil meaning always
  • Value as an Integer index (1-based) specifies at which run to print once
  • Value as an Array of indices specifies at which runs to print multiple times
  • Value as a range specifies at which runs to print multiple times, indefinitely if it ends with ..-1 or ...-1
Can be set globally via PutsDebuggerer.run_at or piecemeal via pd object, run_at: run_at_value
Global usage should be good enough for most cases. When there is a need to track a single expression among several, you may add the option piecemeal, but it expects the same exact object passed to pd for counting.
Examples (global):
  PutsDebuggerer.run_at = 1
  pd (x=1) # prints standard PD output
  pd (x=1) # prints nothing

  PutsDebuggerer.run_at = 2
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output

  PutsDebuggerer.run_at = [1, 3]
  pd (x=1) # prints standard PD output
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output
  pd (x=1) # prints nothing

  PutsDebuggerer.run_at = 3..5
  pd (x=1) # prints nothing
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output
  pd (x=1) # prints standard PD output
  pd (x=1) # prints standard PD output
  pd (x=1) # prints nothing
  pd (x=1) # prints nothing

  PutsDebuggerer.run_at = 3...6
  pd (x=1) # prints nothing
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output
  pd (x=1) # prints standard PD output
  pd (x=1) # prints standard PD output
  pd (x=1) # prints nothing

  PutsDebuggerer.run_at = 3..-1
  pd (x=1) # prints nothing
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output
  pd (x=1) # ... continue printing indefinitely on all subsequent runs

  PutsDebuggerer.run_at = 3...-1
  pd (x=1) # prints nothing
  pd (x=1) # prints nothing
  pd (x=1) # prints standard PD output
  pd (x=1) # ... continue printing indefinitely on all subsequent runs

Sunday, July 23, 2017

Glimmer Ruby Desktop Library Version 0.1.8.470


Come and grab Glimmer Ruby Desktop Library Version 0.1.8.470 over here: https://github.com/AndyObtiva/glimmer/tree/v0.1.8.470

Ships with girb (Glimmer IRB), providing a Ruby playground for trying out Glimmer app ideas.

Happy Glimmering!

Saturday, July 22, 2017

Glimmer Ruby Desktop Library Version 0.1.5.470

The Glimmer Ruby Desktop Library Version 0.1.5.470 was just released.

Key Features:
- Glimmer now uses a Ruby Logger in debug mode to provide helpful debugging information
- Glimmer has a smart new Ruby shell script for executing applications
- ***DRUMROLL*** As part of the smart new Ruby shell script, Glimmer now downloads swt.jar automatically for the user platform whether Mac, Windows, or Linux, and whether it's an x86 or x86-64 CPU architecture.

Below are new sections added to Glimmer's README:



More details can be found at the project page README over here:
https://github.com/AndyObtiva/glimmer/tree/v0.1.5.470

Happy Glimmering!

Friday, July 21, 2017

Glimmer Ruby Desktop Library Version 0.1.4.470

Glimmer - The Original One and Only - is alive and well. A new version has just been released supporting Ruby 2.3.0 (jruby-9.1.12.0) and SWT 4.7.0, with improved glimmer executable and instructions.

Get it here.

Example code:













Monday, March 06, 2017

puts_debuggerer v0.5.0 adds caller, formatter, and more goodies

puts_debuggerer v0.5.0

Yes, many of us avoid debuggers like the plague and clamp on to our puts statements like an umbrella in a stormy day. Why not make it official and have puts debugging become its own perfectly legitimate thing?!!
And thus, puts_debuggerer was born. A guilt-free puts debugger Ruby gem FTW!
In other words, puts_debuggerer is a Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.
Partially inspired (only partially ;) by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)
Below are some of its options.

Options

Options enable more data to be displayed with puts_debuggerer, such as the caller backtrace, header, and footer. They also allow customization of output format.

PutsDebuggerer.print_engine

(default = :p)
Print engine to use in object printout (e.g. p, ap, pp). It is represented by the print engine's global method name as a symbol (e.g. :ap for awesome_print). Defaults to Ruby's built-in p method identified by the symbol :p. If it finds awesome_print loaded, it defaults to ap as :ap instead.
Example:
# File Name: /Users/User/example.rb
require 'awesome_print'
PutsDebuggerer.print_engine = :ap
array = [1, [2, 3]]
pd array
Prints out:
[PD] /Users/User/example.rb:5
   > pd array
  => [
    [0] 1,
    [1] [
        [0] 2,
        [1] 3
    ]
]

PutsDebuggerer.announcer

(default = "[PD]")
Announcer (e.g. [PD]) to announce every print out with (default: "[PD]")
Example:
PutsDebuggerer.announcer = "*** PD ***\n  "
pd (x=1)
Prints out:
*** PD ***
   /Users/User/example.rb:2
   > pd x=1
  => "1"

PutsDebuggerer.formatter

(default = PutsDebuggerer::FORMATTER_DEFAULT)
Formatter used in every print out Passed a data argument with the following keys:
  • :announcer (string)
  • :caller (array)
  • :file (string)
  • :footer (string)
  • :header (string)
  • :line_number (string)
  • :pd_expression (string)
  • :object (object)
  • :object_printer (proc)
NOTE: data for :object_printer is not a string, yet a proc that must be called to output value. It is a proc as it automatically handles usage of print_engine and encapsulates its details. In any case, data for :object is available should one want to avoid altogether.
Example:
PutsDebuggerer.formatter = -> (data) {
  puts "-<#{data[:announcer]}>-"
  puts "HEADER: #{data[:header]}"
  puts "FILE: #{data[:file]}"
  puts "LINE: #{data[:line_number]}"
  puts "EXPRESSION: #{data[:pd_expression]}"
  print "PRINT OUT: "
  data[:object_printer].call
  puts "CALLER: #{data[:caller].to_a.first}"
  puts "FOOTER: #{data[:footer]}"
}
pd (x=1)
Prints out:
-<[PD]>-
FILE: /Users/User/example.rb
HEADER: ********************************************************************************
LINE: 9
EXPRESSION: x=1
PRINT OUT: 1
CALLER: #/Users/User/master_examples.rb:83:in `block (3 levels) in '
FOOTER: ********************************************************************************

PutsDebuggerer.caller

(default = nil)
Caller backtrace included at the end of every print out Passed an argument of true/false, nil, or depth as an integer.
  • true and -1 means include full caller backtrace
  • false and nil means do not include caller backtrace
  • depth (0-based) means include limited caller backtrace depth
Example:
# File Name: /Users/User/sample_app/lib/sample.rb
PutsDebuggerer.caller = 3
pd (x=1)
Prints out:
[PD] /Users/User/sample_app/lib/sample.rb:3
    > pd x=1
   => "1"
     /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
     /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
     /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
     /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/context.rb:381:in \`evaluate\'

Options can be set as a global configuration or piecemeal per puts statement.

Global configuration is done via PutsDebuggerer module attribute writers. On the other hand, piecemeal options can be passed to the pd global method as the second argument.


Example:
# File Name: /Users/User/project/piecemeal.rb
data = [1, [2, 3]]
pd data, header: '>'*80, footer: '<'*80, announcer: "   -<[PD]>-\n  "
Prints out:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   -<[PD]>-
   /Users/User/project/piecemeal.rb:3
   > pd data
  => [1, [2, 3]]
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Become a puts_debuggerer!

Sunday, March 05, 2017

puts_debuggerer v0.3.0 (header/footer + multi-line)

What's New in puts_debuggerer v0.3.0 ?

Usage
Simply invoke global pd method anywhere you'd like to see line number and source code with output. If the argument is a pure string, the print out is simplified by not showing duplicate source.
Quickly locate printed lines using Find feature (e.g. CTRL+F) by looking for:
  • [PD]
  • file:line_number
  • ruby expression.
This gives you the added benefit of easily removing your pd statements later on from the code.
Happy puts_debuggerering!
Example Code:
# /Users/User/finance_calculator_app/pd_test.rb # line 1
bug = 'beattle'                                 # line 2
pd "Show me the source of the bug: #{bug}"      # line 3
pd 'What line number am I?'                     # line 4
Example Printout:
[PD] /Users/User/finance_calculator_app/pd_test.rb:3
   > ("Show me the source of the bug: #{bug}").inspect
  => "Show me the source of the bug: beattle"
[PD] /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"

PutsDebuggerer.header

Header to include at the top of every print out.
  • Default value is nil
  • Value true enables header as '*'*80
  • Value false, nil, or empty string disables header
  • Any other string value gets set as a custom header
Example:
PutsDebuggerer.header = true
pd (x=1)
Prints out:
********************************************************************************
[PD] /Users/User/example.rb:2
   > (x=1).inspect
  => "1"

PutsDebuggerer.footer

Footer to include at the bottom of every print out.
  • Default value is nil
  • Value true enables footer as '*'*80
  • Value false, nil, or empty string disables footer
  • Any other string value gets set as a custom footer
Example:
PutsDebuggerer.footer = true
pd (x=1)
Prints out
[PD] /Users/User/example.rb:2
   > (x=1).inspect
  => "1"
********************************************************************************

Become a puts_debuggerer!