Skip to content

Instantly share code, notes, and snippets.

@melezhik
Created January 18, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melezhik/ec92611e854d490d5856eda405945c21 to your computer and use it in GitHub Desktop.
Save melezhik/ec92611e854d490d5856eda405945c21 to your computer and use it in GitHub Desktop.
Cannot assign to a readonly variable or a value
[melezhik@e23f8de28e56 Sparrow6]$ perl6 -MSparrow6 -e 'Sparrow6::Runner.new( root => "/home/melezhik/sparrow/plugins/public/templater/", debug =>
True ).task-run' --ll-exception
[load plugin configuration] >>> [/home/melezhik/sparrow/plugins/public/templater//suite.yaml]
[parse plugin configuration] >>> [${:foo(${:bar($["a", "b", "c", "d"])}), :mode(644)}]
[input parameters] >>> [Hash]
Cannot assign to a readonly variable or a value
in method task-run at /home/melezhik/.perl6/sources/58A2D16AF627CCE8CC3EBB21DDEBA29E2E38F9D9 (Sparrow6) line 37
in block <unit> at -e line 1
/home/melezhik/.perl6/sources/58A2D16AF627CCE8CC3EBB21DDEBA29E2E38F9D9 :
1 #!perl6
2
3 use v6;
4
5 unit module Sparrow6:ver<0.0.1>;
6 use File::Directory::Tree;
7 use Hash::Merge;
8 use YAMLish;
9
10 class Runner {
11
12 has Str $.root;
13 has Str $.sparrow-root;
14 has Bool $.debug;
15 has Hash $.parameters;
16 has Hash $.task-config is rw;
17
18 method !cache-root-dir {
19
20 my $cache-root-dir = $.sparrow-root ??
21 $.sparrow-root ~ "/tmp/" ~ $*PID !!
22 %*ENV<HOME> ~ "/.sparrow6/tmp/" ~ $*PID;
23
24 }
25
26 method task-run() {
27
28 if self!cache-root-dir.IO ~~ :e {
29 empty-directory self!cache-root-dir
30 }
31
32 if "{$.root}/suite.yaml".IO ~~ :e {
33 self!log("load plugin configuration","{$.root}/suite.yaml");
34 my $plugin-config = load-yaml(slurp "{$.root}/suite.yaml");
35 self!log("parse plugin configuration",$plugin-config.perl);
36 self!log("input parameters",$.parameters.perl);
37 $.task-config = %( foo => 100 );
38 merge-hash $plugin-config, $.parameters;
39 self!log("merged task config",$.task-config.perl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment