http://qs321.pair.com?node_id=11142248


in reply to I have finally done it; wrote a Tesla API library for Perl!

I've always loved to see your passion for these sorts of things, stevieb. Of course now I'm waiting for the plot twist where your local highway patrol use your own $car->speed data to hold up a speeding ticket you're contesting in court. ;-)

Just another Perl hooker - My clients appreciate that I keep my code clean but my comments dirty.

Replies are listed 'Best First'.
Re^2: I have finally done it; wrote a Tesla API library for Perl!
by stevieb (Canon) on Mar 18, 2022 at 22:46 UTC

    I wrote Mock::Sub several years ago, apparently waiting for this exact problem!

    use warnings; use strict; use feature 'say'; use Mock::Sub; use Tesla::Vehicle; my $mock = Mock::Sub->new; my $car = Tesla::Vehicle->new; my $speed_sub = $mock->mock('Tesla::Vehicle::speed'); $speed_sub->return_value(60); # No matter how fast I'm going, we'll always return 60! say $car->speed;

      In that instance was it best designated as Mock::Sub, or should it have been designated Mock::HighwayPatrol? :-)

      Just another Perl hooker - My clients appreciate that I keep my code clean but my comments dirty.