Aion-Fs

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

```

Используется в фильтрах функции `find`.

### See also

* [File::Wildcard](https://metacpan.org/pod/File::Wildcard).
* [String::Wildcard::Bash](https://metacpan.org/pod/String::Wildcard::Bash).
* [Text::Glob](https://metacpan.org/pod/Text::Glob) – `glob_to_regex("*.{pm,pl}")`.

## goto_editor ($path, $line)

Открывает файл в редакторе из .config на указанной строке. По умолчанию использует `vscodium %p:%l`.

Файл .config.pm:
```perl
package config;

config_module 'Aion::Fs' => {
    EDITOR => 'echo %p:%l > ed.txt',
};

1;
```

```perl
goto_editor "mypath", 10;
cat "ed.txt"  # => mypath:10\n

eval { goto_editor "`", 1 }; $@  # ~> `:1 --> 512
```

## from_pkg (;$pkg)

Переводит пакет в путь ФС. Без параметра использует `$_`.

```perl
from_pkg "Aion::Fs"  # => Aion/Fs.pm
[map from_pkg, "Aion::Fs", "A::B::C"]  # --> ["Aion/Fs.pm", "A/B/C.pm"]
```

i18n/Aion/Fs.ru-en.po  view on Meta::CPAN

msgid ""
"* [File::Wildcard](https://metacpan.org/pod/File::Wildcard).\n"
"* [String::Wildcard::Bash](https://metacpan.org/pod/String::Wildcard::Bash).\n"
"* [Text::Glob](https://metacpan.org/pod/Text::Glob) – `glob_to_regex(\"*.{pm,pl}\")`."
msgstr ""
"* [File::Wildcard](https://metacpan.org/pod/File::Wildcard).\n"
"* [String::Wildcard::Bash](https://metacpan.org/pod/String::Wildcard::Bash).\n"
"* [Text::Glob](https://metacpan.org/pod/Text::Glob) – `glob_to_regex(\"*.{pm,pl}\")`."

msgid "Открывает файл в редакторе из .config на указанной строке. По умолчанию использует `vscodium %p:%l`."
msgstr "Opens the file in the editor from .config at the specified line. Defaults to `vscodium %p:%l`."

msgid "Файл .config.pm:"
msgstr ".config.pm file:"

msgid "Переводит пакет в путь ФС. Без параметра использует `$_`."
msgstr "Transfers the packet to the FS path. Without a parameter, uses `$_`."

msgid "Переводит путь из ФС в пакет. Без параметра использует `$_`."
msgstr "Translates the path from the FS to the package. Without a parameter, uses `$_`."

lib/Aion/Fs.md  view on Meta::CPAN

```

Используется в фильтрах функции `find`.

### See also

* [File::Wildcard](https://metacpan.org/pod/File::Wildcard).
* [String::Wildcard::Bash](https://metacpan.org/pod/String::Wildcard::Bash).
* [Text::Glob](https://metacpan.org/pod/Text::Glob) – `glob_to_regex("*.{pm,pl}")`.

## goto_editor ($path, $line)

Открывает файл в редакторе из .config на указанной строке. По умолчанию использует `vscodium %p:%l`.

Файл .config.pm:
```perl
package config;

config_module 'Aion::Fs' => {
    EDITOR => 'echo %p:%l > ed.txt',
};

1;
```

```perl
goto_editor "mypath", 10;
cat "ed.txt"  # => mypath:10\n

eval { goto_editor "`", 1 }; $@  # ~> `:1 --> 512
```

## from_pkg (;$pkg)

Переводит пакет в путь ФС. Без параметра использует `$_`.

```perl
from_pkg "Aion::Fs"  # => Aion/Fs.pm
[map from_pkg, "Aion::Fs", "A::B::C"]  # --> ["Aion/Fs.pm", "A/B/C.pm"]
```

lib/Aion/Fs.pm  view on Meta::CPAN

		exists $+{w1}? "(":
		exists $+{w2}? ")":
		exists $+{comma}? "|":
		quotemeta $&
	}gxe;
	qr/^$wildcard$/ns
}

# Открывает файл на указанной строке в редакторе
use config EDITOR => "vscodium %p:%l";
sub goto_editor($$) {
	my ($path, $line) = @_;
	my $p = EDITOR;
	$p =~ s!%p!$path!;
	$p =~ s!%l!$line!;
	my $status = system $p;
	die "$path:$line --> $status" if $status;
	return;
}

# Из пакета в файловый путь

lib/Aion/Fs.pm  view on Meta::CPAN

=over

=item * L<File::Wildcard>.

=item * L<String::Wildcard::Bash>.

=item * L<Text::Glob> – C<glob_to_regex("*.{pm,pl}")>.

=back

=head2 goto_editor ($path, $line)

Opens the file in the editor from .config at the specified line. Defaults to C<vscodium %p:%l>.

.config.pm file:

	package config;
	
	config_module 'Aion::Fs' => {
	    EDITOR => 'echo %p:%l > ed.txt',
	};
	
	1;



	goto_editor "mypath", 10;
	cat "ed.txt"  # => mypath:10\n
	
	eval { goto_editor "`", 1 }; $@  # ~> `:1 --> 512

=head2 from_pkg (;$pkg)

Transfers the packet to the FS path. Without a parameter, uses C<$_>.

	from_pkg "Aion::Fs"  # => Aion/Fs.pm
	[map from_pkg, "Aion::Fs", "A::B::C"]  # --> ["Aion/Fs.pm", "A/B/C.pm"]

=head2 to_pkg (;$path)

t/aion/fs.t  view on Meta::CPAN


# 
# Используется в фильтрах функции `find`.
# 
# ### See also
# 
# * [File::Wildcard](https://metacpan.org/pod/File::Wildcard).
# * [String::Wildcard::Bash](https://metacpan.org/pod/String::Wildcard::Bash).
# * [Text::Glob](https://metacpan.org/pod/Text::Glob) – `glob_to_regex("*.{pm,pl}")`.
# 
# ## goto_editor ($path, $line)
# 
# Открывает файл в редакторе из .config на указанной строке. По умолчанию использует `vscodium %p:%l`.
# 
# Файл .config.pm:
#@> .config.pm
#>> package config;
#>> 
#>> config_module 'Aion::Fs' => {
#>>     EDITOR => 'echo %p:%l > ed.txt',
#>> };
#>> 
#>> 1;
#@< EOF
# 
::done_testing; }; subtest 'goto_editor ($path, $line)' => sub { 
goto_editor "mypath", 10;
local ($::_g0 = do {cat "ed.txt"}, $::_e0 = "mypath:10\n"); ::ok $::_g0 eq $::_e0, 'cat "ed.txt"  # => mypath:10\n' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

::like scalar do {eval { goto_editor "`", 1 }; $@}, qr{`:1 --> 512}, 'eval { goto_editor "`", 1 }; $@  # ~> `:1 --> 512'; undef $::_g0; undef $::_e0;

# 
# ## from_pkg (;$pkg)
# 
# Переводит пакет в путь ФС. Без параметра использует `$_`.
# 
::done_testing; }; subtest 'from_pkg (;$pkg)' => sub { 
local ($::_g0 = do {from_pkg "Aion::Fs"}, $::_e0 = "Aion/Fs.pm"); ::ok $::_g0 eq $::_e0, 'from_pkg "Aion::Fs"  # => Aion/Fs.pm' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map from_pkg, "Aion::Fs", "A::B::C"]}, $::_e0 = do {["Aion/Fs.pm", "A/B/C.pm"]}); ::is_deeply $::_g0, $::_e0, '[map from_pkg, "Aion::Fs", "A::B::C"]  # --> ["Aion/Fs.pm", "A/B/C.pm"]' or ::diag ::_struct_diff($::_g0, $::_e0); und...



( run in 2.008 seconds using v1.01-cache-2.11-cpan-98e64b0badf )