├── .Rbuildignore ├── .gitattributes ├── .github └── workflows │ └── pkgdown.yaml ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── import.R ├── microhaplot.R ├── runHaplot.R └── runMicroHap.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── cran-comments.md ├── docs ├── 404.html ├── LICENSE.html ├── articles │ ├── field_selection.png │ ├── index.html │ ├── locus_annotation.png │ ├── main_tab.png │ ├── microhaplot-data-prep.html │ ├── microhaplot-data-prep_files │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ ├── microhaplot-walkthrough.html │ ├── microhaplot-walkthrough_files │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ ├── read_criteria_tab.png │ ├── troubleshoot.html │ └── troubleshoot_files │ │ └── accessible-code-block-0.0.1 │ │ └── empty-anchor.js ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── index.html ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── Rplot001.png │ ├── index.html │ ├── mvShinyHaplot.html │ ├── prepHaplotFiles.html │ └── runShinyHaplot.html └── sitemap.xml ├── inst ├── extdata │ └── sebastes_sam.tar.gz ├── perl │ ├── fatlib │ │ ├── Algorithm │ │ │ └── C3.pm │ │ ├── B │ │ │ └── Hooks │ │ │ │ ├── EndOfScope.pm │ │ │ │ └── EndOfScope │ │ │ │ ├── PP.pm │ │ │ │ ├── PP │ │ │ │ ├── FieldHash.pm │ │ │ │ └── HintHash.pm │ │ │ │ └── XS.pm │ │ ├── Bio │ │ │ └── Cigar.pm │ │ ├── Class │ │ │ ├── C3.pm │ │ │ └── C3 │ │ │ │ └── next.pm │ │ ├── Devel │ │ │ ├── GlobalDestruction.pm │ │ │ └── TypeTiny │ │ │ │ ├── Perl56Compat.pm │ │ │ │ └── Perl58Compat.pm │ │ ├── Error │ │ │ ├── TypeTiny.pm │ │ │ └── TypeTiny │ │ │ │ ├── Assertion.pm │ │ │ │ ├── Compilation.pm │ │ │ │ └── WrongNumberOfParameters.pm │ │ ├── Eval │ │ │ └── TypeTiny.pm │ │ ├── Exporter │ │ │ ├── Shiny.pm │ │ │ └── Tiny.pm │ │ ├── MRO │ │ │ └── Compat.pm │ │ ├── Method │ │ │ └── Generate │ │ │ │ ├── Accessor.pm │ │ │ │ ├── BuildAll.pm │ │ │ │ ├── Constructor.pm │ │ │ │ └── DemolishAll.pm │ │ ├── Module │ │ │ ├── Implementation.pm │ │ │ └── Runtime.pm │ │ ├── Moo.pm │ │ ├── Moo │ │ │ ├── HandleMoose.pm │ │ │ ├── HandleMoose │ │ │ │ ├── FakeMetaClass.pm │ │ │ │ └── _TypeMap.pm │ │ │ ├── Object.pm │ │ │ ├── Role.pm │ │ │ ├── _Utils.pm │ │ │ ├── _mro.pm │ │ │ ├── _strictures.pm │ │ │ └── sification.pm │ │ ├── Package │ │ │ ├── Stash.pm │ │ │ └── Stash │ │ │ │ ├── Conflicts.pm │ │ │ │ └── PP.pm │ │ ├── Reply │ │ │ └── Plugin │ │ │ │ └── TypeTiny.pm │ │ ├── Sub │ │ │ ├── Defer.pm │ │ │ ├── Exporter │ │ │ │ └── Progressive.pm │ │ │ └── Quote.pm │ │ ├── Test │ │ │ └── TypeTiny.pm │ │ ├── Try │ │ │ └── Tiny.pm │ │ ├── Type │ │ │ ├── Coercion.pm │ │ │ ├── Coercion │ │ │ │ ├── FromMoose.pm │ │ │ │ └── Union.pm │ │ │ ├── Library.pm │ │ │ ├── Params.pm │ │ │ ├── Parser.pm │ │ │ ├── Registry.pm │ │ │ ├── Tiny.pm │ │ │ ├── Tiny │ │ │ │ ├── Class.pm │ │ │ │ ├── Duck.pm │ │ │ │ ├── Enum.pm │ │ │ │ ├── Intersection.pm │ │ │ │ ├── Manual.pod │ │ │ │ ├── Manual │ │ │ │ │ ├── Coercions.pod │ │ │ │ │ ├── Libraries.pod │ │ │ │ │ ├── Optimization.pod │ │ │ │ │ ├── Params.pod │ │ │ │ │ ├── Policies.pod │ │ │ │ │ ├── UsingWithMoo.pod │ │ │ │ │ ├── UsingWithMoose.pod │ │ │ │ │ ├── UsingWithMouse.pod │ │ │ │ │ └── UsingWithOther.pod │ │ │ │ ├── Role.pm │ │ │ │ ├── Union.pm │ │ │ │ └── _HalfOp.pm │ │ │ └── Utils.pm │ │ ├── Types │ │ │ ├── Common │ │ │ │ ├── Numeric.pm │ │ │ │ └── String.pm │ │ │ ├── Standard.pm │ │ │ ├── Standard │ │ │ │ ├── ArrayRef.pm │ │ │ │ ├── Dict.pm │ │ │ │ ├── HashRef.pm │ │ │ │ ├── Map.pm │ │ │ │ ├── ScalarRef.pm │ │ │ │ └── Tuple.pm │ │ │ └── TypeTiny.pm │ │ ├── darwin-thread-multi-2level │ │ │ ├── .meta │ │ │ │ ├── Bio-Cigar-1.01 │ │ │ │ │ ├── MYMETA.json │ │ │ │ │ └── install.json │ │ │ │ ├── Exporter-Tiny-0.042 │ │ │ │ │ ├── MYMETA.json │ │ │ │ │ └── install.json │ │ │ │ └── Type-Tiny-1.000005 │ │ │ │ │ ├── MYMETA.json │ │ │ │ │ └── install.json │ │ │ ├── auto │ │ │ │ ├── Bio │ │ │ │ │ └── Cigar │ │ │ │ │ │ └── .packlist │ │ │ │ ├── Exporter │ │ │ │ │ └── Tiny │ │ │ │ │ │ └── .packlist │ │ │ │ └── Type │ │ │ │ │ └── Tiny │ │ │ │ │ └── .packlist │ │ │ └── perllocal.pod │ │ ├── namespace │ │ │ ├── clean.pm │ │ │ └── clean │ │ │ │ └── _Util.pm │ │ └── oo.pm │ ├── fatpacker.trace │ ├── hapture │ └── hapture.pl └── shiny │ └── microhaplot │ ├── fish1.rds │ ├── fish1_posinfo.rds │ ├── fish2.rds │ ├── fish2_posinfo.rds │ ├── server.R │ └── ui.R ├── man ├── figures │ └── microhaplot-sticker.png ├── mvShinyHaplot.Rd ├── prepHaplotFiles.Rd └── runShinyHaplot.Rd ├── microhaplot.Rproj └── vignettes ├── .gitignore ├── field_selection.png ├── locus_annotation.png ├── main_panel_choice_tabset.png ├── main_tab.png ├── microhaplot-data-prep.Rmd ├── microhaplot-walkthrough.Rmd ├── read_criteria_tab.png └── troubleshoot.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^R/runMicroHap\.R$ 2 | ^CRAN-RELEASE$ 3 | ^Meta$ 4 | ^doc$ 5 | ^\.travis\.yml$ 6 | ^.*\.Rproj$ 7 | ^\.Rproj\.user$ 8 | ^cran-comments\.md$ 9 | ^LICENSE\.md$ 10 | ^inst/perl/fatlib/*$ 11 | ^inst/perl/fatpacker\.trace$ 12 | ^_pkgdown\.yml$ 13 | ^docs$ 14 | ^pkgdown$ 15 | ^\.github$ 16 | ^README.Rmd 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | - master 6 | 7 | name: pkgdown 8 | 9 | jobs: 10 | pkgdown: 11 | runs-on: macOS-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: r-lib/actions/setup-r@v1 18 | 19 | - uses: r-lib/actions/setup-pandoc@v1 20 | 21 | - name: Query dependencies 22 | run: | 23 | install.packages('remotes') 24 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 25 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 26 | shell: Rscript {0} 27 | 28 | - name: Cache R packages 29 | uses: actions/cache@v2 30 | with: 31 | path: ${{ env.R_LIBS_USER }} 32 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 33 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 34 | 35 | - name: Install dependencies 36 | run: | 37 | remotes::install_deps(dependencies = TRUE) 38 | install.packages("pkgdown", type = "binary") 39 | shell: Rscript {0} 40 | 41 | - name: Install package 42 | run: R CMD INSTALL . 43 | 44 | - name: Deploy package 45 | run: | 46 | git config --local user.email "actions@github.com" 47 | git config --local user.name "GitHub Actions" 48 | Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Meta 2 | doc 3 | .Rproj.user 4 | .Rhistory 5 | .RData 6 | .Ruserdata 7 | inst/doc 8 | fish2_example_posinfo.rds 9 | fish2_example.rds 10 | example_438fish_324loci.rds 11 | example_438fish_324loci_posinfo.rds 12 | .DS_Store 13 | docs 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | warnings_are_errors: true 7 | 8 | os: 9 | - linux 10 | - osx 11 | 12 | addons: 13 | apt: 14 | packages: 15 | - perl 16 | - libmoo-perl 17 | - libnamespace-clean-perl 18 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: microhaplot 2 | Type: Package 3 | Title: Microhaplotype Constructor and Visualizer 4 | Version: 1.0.2 5 | Authors@R: person("Thomas", "Ng", email = "tngthomasng@gmail.com", role = c("aut", "cre")) 6 | Description: A downstream bioinformatics tool to construct and assist 7 | curation of microhaplotypes from short read sequences. 8 | Depends: 9 | R (>= 3.5.0) 10 | Encoding: UTF-8 11 | License: GPL-3 12 | LazyData: TRUE 13 | Imports: 14 | DT (>= 0.1), 15 | dplyr (>= 0.4.3), 16 | ggplot2 (>= 2.1.0), 17 | grid (>= 3.1.2), 18 | gtools (>= 3.5.0), 19 | magrittr (>= 1.5), 20 | scales (>= 0.4.0), 21 | shiny (>= 0.13.2), 22 | shinyBS (>= 0.61), 23 | tidyr (>= 0.4.1), 24 | shinyWidgets (>= 0.4.3), 25 | ggiraph (>= 0.6.0) 26 | URL: https://github.com/ngthomas/microhaplot 27 | BugReports: https://github.com/ngthomas/microhaplot/issues 28 | RoxygenNote: 7.1.1 29 | Suggests: 30 | knitr, 31 | rmarkdown 32 | VignetteBuilder: knitr 33 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(mvShinyHaplot) 4 | export(prepHaplotFiles) 5 | export(runShinyHaplot) 6 | importFrom(magrittr,"%>%") 7 | importFrom(utils,combn) 8 | importFrom(utils,read.table) 9 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # microhaplot 1.0.0 2 | * added new parameter for `prepHaplotFiles`: `n.jobs`. For any non-window OS, you can specific the number of SAM files to be parallel processed. We recommend two times the number of processors/cores. (9/18/19) 3 | * Introduces 3 main functions: `prepHaplotFiles`, `runShinyHaplot`, `mvShinyHaplot` 4 | 5 | -------------------------------------------------------------------------------- /R/import.R: -------------------------------------------------------------------------------- 1 | 2 | #### Import the pipe operator from magrittr #### 3 | #' Pipe operator 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @importFrom magrittr %>% 9 | #' @usage lhs \%>\% rhs 10 | #' @noRd 11 | NULL 12 | 13 | 14 | #' @importFrom utils combn read.table 15 | NULL 16 | 17 | -------------------------------------------------------------------------------- /R/microhaplot.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | # quiets concerns of R CMD check re: the . and other column names 4 | # that appear in dplyr chains 5 | if (getRversion() >= "2.15.1") { 6 | utils::globalVariables( 7 | c( 8 | ".", 9 | "V1", 10 | "V2", 11 | "allele.balance", 12 | "depth", 13 | "group", 14 | "grp.indx", 15 | "haplo", 16 | "id", 17 | "indx", 18 | "locus", 19 | "max.Phred.C", 20 | "max.uniq.hapl", 21 | "n.haplo.per.indiv", 22 | "n.indiv.per.locus", 23 | "sum.Phred.C", 24 | "summary.tbl", 25 | "uniq.id" 26 | ) 27 | ) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://ngthomas.github.io/microhaplot 2 | 3 | template: 4 | params: 5 | bootswatch: cosmo 6 | 7 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local OS X install, R 3.5.3 3 | * ubuntu 14.04 (on travis-ci), R 3.6.0 4 | * macOS High Sierra 10.13.3 (on travis-ci), R 3.6.0 5 | * win-builder R 3.6.0 and R 3.7.0 6 | * local Window 10 install, R 3.5.2 7 | 8 | ## R CMD check results 9 | 10 | 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ 11 | 12 | ## Downstream dependencies 13 | There are currently no downstream dependencies for this package 14 | 15 | ## Resubmission 16 | * Fixed Win-builder Error through add perl version checkup 17 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Page not found (404) • microhaplot 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 | Content not found. Please use links in the navbar. 135 | 136 |
137 | 138 | 143 | 144 |
145 | 146 | 147 | 148 | 158 |
159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /docs/articles/field_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/docs/articles/field_selection.png -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • microhaplot 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
135 |

All vignettes

136 |

137 | 138 |
139 |
An Introduction to microhaplot data preparation
140 |
141 |
microhaplot walkthrough
142 |
143 |
Package Troubleshoot
144 |
145 |
146 |
147 |
148 |
149 | 150 | 151 | 161 |
162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /docs/articles/locus_annotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/docs/articles/locus_annotation.png -------------------------------------------------------------------------------- /docs/articles/main_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/docs/articles/main_tab.png -------------------------------------------------------------------------------- /docs/articles/microhaplot-data-prep_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/microhaplot-walkthrough_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/read_criteria_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/docs/articles/read_criteria_tab.png -------------------------------------------------------------------------------- /docs/articles/troubleshoot_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Authors • microhaplot 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
    135 |
  • 136 |

    Thomas Ng. Author, maintainer. 137 |

    138 |
  • 139 |
140 | 141 |
142 | 143 |
144 | 145 | 146 | 147 | 157 |
158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent; 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.7.3 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: 5 | microhaplot-data-prep: microhaplot-data-prep.html 6 | microhaplot-walkthrough: microhaplot-walkthrough.html 7 | troubleshoot: troubleshoot.html 8 | last_built: 2021-06-24T08:02Z 9 | urls: 10 | reference: https://ngthomas.github.io/microhaplot/reference 11 | article: https://ngthomas.github.io/microhaplot/articles 12 | 13 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | https://ngthomas.github.io/microhaplot/index.html 5 | 6 | 7 | https://ngthomas.github.io/microhaplot/reference/mvShinyHaplot.html 8 | 9 | 10 | https://ngthomas.github.io/microhaplot/reference/prepHaplotFiles.html 11 | 12 | 13 | https://ngthomas.github.io/microhaplot/reference/runShinyHaplot.html 14 | 15 | 16 | https://ngthomas.github.io/microhaplot/articles/microhaplot-data-prep.html 17 | 18 | 19 | https://ngthomas.github.io/microhaplot/articles/microhaplot-walkthrough.html 20 | 21 | 22 | https://ngthomas.github.io/microhaplot/articles/troubleshoot.html 23 | 24 | 25 | -------------------------------------------------------------------------------- /inst/extdata/sebastes_sam.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/inst/extdata/sebastes_sam.tar.gz -------------------------------------------------------------------------------- /inst/perl/fatlib/B/Hooks/EndOfScope.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope; # git description: 0.23-2-ga391106 2 | # ABSTRACT: Execute code after a scope finished compilation 3 | # KEYWORDS: code hooks execution scope 4 | 5 | use strict; 6 | use warnings; 7 | 8 | our $VERSION = '0.24'; 9 | 10 | use 5.006001; 11 | 12 | BEGIN { 13 | use Module::Implementation 0.05; 14 | Module::Implementation::build_loader_sub( 15 | implementations => [ 'XS', 'PP' ], 16 | symbols => [ 'on_scope_end' ], 17 | )->(); 18 | } 19 | 20 | use Sub::Exporter::Progressive 0.001006 -setup => { 21 | exports => [ 'on_scope_end' ], 22 | groups => { default => ['on_scope_end'] }, 23 | }; 24 | 25 | 1; 26 | 27 | __END__ 28 | 29 | =pod 30 | 31 | =encoding UTF-8 32 | 33 | =head1 NAME 34 | 35 | B::Hooks::EndOfScope - Execute code after a scope finished compilation 36 | 37 | =head1 VERSION 38 | 39 | version 0.24 40 | 41 | =head1 SYNOPSIS 42 | 43 | on_scope_end { ... }; 44 | 45 | =head1 DESCRIPTION 46 | 47 | This module allows you to execute code when perl finished compiling the 48 | surrounding scope. 49 | 50 | =head1 FUNCTIONS 51 | 52 | =head2 on_scope_end 53 | 54 | on_scope_end { ... }; 55 | 56 | on_scope_end $code; 57 | 58 | Registers C<$code> to be executed after the surrounding scope has been 59 | compiled. 60 | 61 | This is exported by default. See L on how to customize it. 62 | 63 | =head1 LIMITATIONS 64 | 65 | =head2 Pure-perl mode caveat 66 | 67 | This caveat applies to B version of perl where L 68 | is unavailable or otherwise disabled. 69 | 70 | While L has access to some very dark sorcery to make it 71 | possible to throw an exception from within a callback, the pure-perl 72 | implementation does not have access to these hacks. Therefore, what 73 | would have been a B is instead B, and your execution will continue as if the exception never 75 | happened. 76 | 77 | To explicitly request an XS (or PP) implementation one has two choices. Either 78 | to import from the desired implementation explicitly: 79 | 80 | use B::Hooks::EndOfScope::XS 81 | or 82 | use B::Hooks::EndOfScope::PP 83 | 84 | or by setting C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> to either C or 85 | C. 86 | 87 | =head2 Perl 5.8.0 ~ 5.8.3 88 | 89 | Due to a L present in 91 | older perl versions, the implementation of B::Hooks::EndOfScope deliberately 92 | leaks a single empty hash for every scope being cleaned. This is done to 93 | avoid the memory corruption associated with the bug mentioned above. 94 | 95 | In order to stabilize this workaround use of L is disabled 96 | on perls prior to version 5.8.4. On such systems loading/requesting 97 | L explicitly will result in a compile-time 98 | exception. 99 | 100 | =head2 Perl versions 5.6.x 101 | 102 | Versions of perl before 5.8.0 lack a feature allowing changing the visibility 103 | of C<%^H> via setting bit 17 within C<$^H>. As such the only way to achieve 104 | the effect necessary for this module to work, is to use the C operator 105 | explicitly on these platforms. This might lead to unexpected interference 106 | with other scope-driven libraries relying on the same mechanism. On the flip 107 | side there are no such known incompatibilities at the time this note was 108 | written. 109 | 110 | For further details on the unavailable behavior please refer to the test 111 | file F included with the distribution. 112 | 113 | =head1 SEE ALSO 114 | 115 | L 116 | 117 | L 118 | 119 | =head1 SUPPORT 120 | 121 | Bugs may be submitted through L 122 | (or L). 123 | 124 | =head1 AUTHORS 125 | 126 | =over 4 127 | 128 | =item * 129 | 130 | Florian Ragwitz 131 | 132 | =item * 133 | 134 | Peter Rabbitson 135 | 136 | =back 137 | 138 | =head1 CONTRIBUTORS 139 | 140 | =for stopwords Karen Etheridge Tatsuhiko Miyagawa Christian Walde Tomas Doran Graham Knop Simon Wilper 141 | 142 | =over 4 143 | 144 | =item * 145 | 146 | Karen Etheridge 147 | 148 | =item * 149 | 150 | Tatsuhiko Miyagawa 151 | 152 | =item * 153 | 154 | Christian Walde 155 | 156 | =item * 157 | 158 | Tomas Doran 159 | 160 | =item * 161 | 162 | Graham Knop 163 | 164 | =item * 165 | 166 | Simon Wilper 167 | 168 | =back 169 | 170 | =head1 COPYRIGHT AND LICENCE 171 | 172 | This software is copyright (c) 2008 by Florian Ragwitz. 173 | 174 | This is free software; you can redistribute it and/or modify it under 175 | the same terms as the Perl 5 programming language system itself. 176 | 177 | =cut 178 | -------------------------------------------------------------------------------- /inst/perl/fatlib/B/Hooks/EndOfScope/PP.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope::PP; 2 | # ABSTRACT: Execute code after a scope finished compilation - PP implementation 3 | 4 | use warnings; 5 | use strict; 6 | 7 | our $VERSION = '0.24'; 8 | 9 | use constant _PERL_VERSION => "$]"; 10 | 11 | BEGIN { 12 | if (_PERL_VERSION =~ /^5\.009/) { 13 | # CBA to figure out where %^H got broken and which H::U::HH is sane enough 14 | die "By design B::Hooks::EndOfScope does not operate in pure-perl mode on perl 5.9.X\n" 15 | } 16 | elsif (_PERL_VERSION < '5.010') { 17 | require B::Hooks::EndOfScope::PP::HintHash; 18 | *on_scope_end = \&B::Hooks::EndOfScope::PP::HintHash::on_scope_end; 19 | } 20 | else { 21 | require B::Hooks::EndOfScope::PP::FieldHash; 22 | *on_scope_end = \&B::Hooks::EndOfScope::PP::FieldHash::on_scope_end; 23 | } 24 | } 25 | 26 | use Sub::Exporter::Progressive 0.001006 -setup => { 27 | exports => ['on_scope_end'], 28 | groups => { default => ['on_scope_end'] }, 29 | }; 30 | 31 | sub __invoke_callback { 32 | local $@; 33 | eval { $_[0]->(); 1 } or do { 34 | my $err = $@; 35 | require Carp; 36 | Carp::cluck( (join ' ', 37 | 'A scope-end callback raised an exception, which can not be propagated when', 38 | 'B::Hooks::EndOfScope operates in pure-perl mode. Your program will CONTINUE', 39 | 'EXECUTION AS IF NOTHING HAPPENED AFTER THIS WARNING. Below is the complete', 40 | 'exception text, followed by a stack-trace of the callback execution:', 41 | ) . "\n\n$err\n\r" ); 42 | 43 | sleep 1 if -t *STDERR; # maybe a bad idea...? 44 | }; 45 | } 46 | 47 | 1; 48 | 49 | __END__ 50 | 51 | =pod 52 | 53 | =encoding UTF-8 54 | 55 | =head1 NAME 56 | 57 | B::Hooks::EndOfScope::PP - Execute code after a scope finished compilation - PP implementation 58 | 59 | =head1 VERSION 60 | 61 | version 0.24 62 | 63 | =head1 DESCRIPTION 64 | 65 | This is the pure-perl implementation of L based only on 66 | modules available as part of the perl core. Its leaner sibling 67 | L will be automatically preferred if all 68 | dependencies are available and C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> is 69 | not set to C<'PP'>. 70 | 71 | =head1 FUNCTIONS 72 | 73 | =head2 on_scope_end 74 | 75 | on_scope_end { ... }; 76 | 77 | on_scope_end $code; 78 | 79 | Registers C<$code> to be executed after the surrounding scope has been 80 | compiled. 81 | 82 | This is exported by default. See L on how to customize it. 83 | 84 | =head1 SUPPORT 85 | 86 | Bugs may be submitted through L 87 | (or L). 88 | 89 | =head1 AUTHORS 90 | 91 | =over 4 92 | 93 | =item * 94 | 95 | Florian Ragwitz 96 | 97 | =item * 98 | 99 | Peter Rabbitson 100 | 101 | =back 102 | 103 | =head1 COPYRIGHT AND LICENCE 104 | 105 | This software is copyright (c) 2008 by Florian Ragwitz. 106 | 107 | This is free software; you can redistribute it and/or modify it under 108 | the same terms as the Perl 5 programming language system itself. 109 | 110 | =cut 111 | -------------------------------------------------------------------------------- /inst/perl/fatlib/B/Hooks/EndOfScope/PP/FieldHash.pm: -------------------------------------------------------------------------------- 1 | # Implementation of a pure-perl on_scope_end for perls > 5.10 2 | # (relies on Hash::Util:FieldHash) 3 | 4 | package # hide from pause 5 | B::Hooks::EndOfScope::PP::FieldHash; 6 | 7 | use strict; 8 | use warnings; 9 | 10 | our $VERSION = '0.24'; 11 | 12 | use Tie::Hash (); 13 | use Hash::Util::FieldHash 'fieldhash'; 14 | 15 | # Here we rely on a combination of several behaviors: 16 | # 17 | # * %^H is deallocated on scope exit, so any references to it disappear 18 | # * A lost weakref in a fieldhash causes the corresponding key to be deleted 19 | # * Deletion of a key on a tied hash triggers DELETE 20 | # 21 | # Therefore the DELETE of a tied fieldhash containing a %^H reference will 22 | # be the hook to fire all our callbacks. 23 | 24 | fieldhash my %hh; 25 | { 26 | package # hide from pause too 27 | B::Hooks::EndOfScope::PP::_TieHintHashFieldHash; 28 | our @ISA = ( 'Tie::StdHash' ); # in Tie::Hash, in core 29 | sub DELETE { 30 | my $ret = shift->SUPER::DELETE(@_); 31 | B::Hooks::EndOfScope::PP::__invoke_callback($_) for @$ret; 32 | $ret; 33 | } 34 | } 35 | 36 | sub on_scope_end (&) { 37 | $^H |= 0x020000; 38 | 39 | tie(%hh, 'B::Hooks::EndOfScope::PP::_TieHintHashFieldHash') 40 | unless tied %hh; 41 | 42 | push @{ $hh{\%^H} ||= [] }, $_[0]; 43 | } 44 | 45 | 1; 46 | -------------------------------------------------------------------------------- /inst/perl/fatlib/B/Hooks/EndOfScope/PP/HintHash.pm: -------------------------------------------------------------------------------- 1 | # Implementation of a pure-perl on_scope_end for perls < 5.10 2 | # (relies on lack of compile/runtime duality of %^H before 5.10 3 | # which makes guard object operation possible) 4 | 5 | package # hide from the pauses 6 | B::Hooks::EndOfScope::PP::HintHash; 7 | 8 | use strict; 9 | use warnings; 10 | 11 | our $VERSION = '0.24'; 12 | 13 | use Scalar::Util (); 14 | use constant _NEEDS_MEMORY_CORRUPTION_FIXUP => ( 15 | "$]" >= 5.008 16 | and 17 | "$]" < 5.008004 18 | ) ? 1 : 0; 19 | 20 | 21 | use constant _PERL_VERSION => "$]"; 22 | 23 | # This is the original implementation, which sadly is broken 24 | # on perl 5.10+ within string evals 25 | sub on_scope_end (&) { 26 | 27 | # the scope-implicit %^H localization is a 5.8+ feature 28 | $^H |= 0x020000 29 | if _PERL_VERSION >= 5.008; 30 | 31 | # the explicit localization of %^H works on anything < 5.10 32 | # but we use it only on 5.6 where fiddling $^H has no effect 33 | local %^H = %^H 34 | if _PERL_VERSION < 5.008; 35 | 36 | # Workaround for memory corruption during implicit $^H-induced 37 | # localization of %^H on 5.8.0~5.8.3, see extended comment below 38 | bless \%^H, 'B::Hooks::EndOfScope::PP::HintHash::__GraveyardTransport' if ( 39 | _NEEDS_MEMORY_CORRUPTION_FIXUP 40 | and 41 | ref \%^H eq 'HASH' # only bless if it is a "pure hash" to start with 42 | ); 43 | 44 | # localised %^H behaves funny on 5.8 - a 45 | # 'local %^H;' 46 | # is in effect the same as 47 | # 'local %^H = %^H;' 48 | # therefore make sure we use different keys so that things do not 49 | # fire too early due to hashkey overwrite 50 | push @{ 51 | $^H{sprintf '__B_H_EOS__guardstack_0X%x', Scalar::Util::refaddr(\%^H) } 52 | ||= bless ([], 'B::Hooks::EndOfScope::PP::_SG_STACK') 53 | }, $_[0]; 54 | } 55 | 56 | sub B::Hooks::EndOfScope::PP::_SG_STACK::DESTROY { 57 | B::Hooks::EndOfScope::PP::__invoke_callback($_) for @{$_[0]}; 58 | } 59 | 60 | # This scope implements a clunky yet effective workaround for a core perl bug 61 | # https://rt.perl.org/Public/Bug/Display.html?id=27040#txn-82797 62 | # 63 | # While we can not prevent the hinthash being marked for destruction twice, 64 | # we *can* intercept the first DESTROY pass, and squirrel away the entire 65 | # structure, until a time it can (hopefully) no longer do any visible harm 66 | # 67 | # There still *will* be corruption by the time we get to free it for real, 68 | # since we can not prevent Perl's erroneous SAVEFREESV mark. What we hope is 69 | # that by then the corruption will no longer matter 70 | # 71 | # Yes, this code does leak by design. Yes it is better than the alternative. 72 | { 73 | my @Hint_Hash_Graveyard; 74 | 75 | # "Leak" this entire structure: ensures it and its contents will not be 76 | # garbage collected until the very very very end 77 | push @Hint_Hash_Graveyard, \@Hint_Hash_Graveyard 78 | if _NEEDS_MEMORY_CORRUPTION_FIXUP; 79 | 80 | sub B::Hooks::EndOfScope::PP::HintHash::__GraveyardTransport::DESTROY { 81 | 82 | # Resurrect the hinthash being destroyed, persist it into the graveyard 83 | push @Hint_Hash_Graveyard, $_[0]; 84 | 85 | # ensure we won't try to re-resurrect during GlobalDestroy 86 | bless $_[0], 'B::Hooks::EndOfScope::PP::HintHash::__DeactivateGraveyardTransport'; 87 | 88 | # Perform explicit free of elements (if any) triggering all callbacks 89 | # This is what would have happened without this code being active 90 | %{$_[0]} = (); 91 | } 92 | } 93 | 94 | 1; 95 | -------------------------------------------------------------------------------- /inst/perl/fatlib/B/Hooks/EndOfScope/XS.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope::XS; 2 | # ABSTRACT: Execute code after a scope finished compilation - XS implementation 3 | 4 | use strict; 5 | use warnings; 6 | 7 | our $VERSION = '0.24'; 8 | 9 | # Limit the V::M-based (XS) version to perl 5.8.4+ 10 | # 11 | # Given the unorthodox stuff we do to work around the hinthash double-free 12 | # might as well play it safe and only implement it in the PP version 13 | # and leave it at that 14 | # https://rt.perl.org/Public/Bug/Display.html?id=27040#txn-82797 15 | # 16 | use 5.008004; 17 | 18 | use Variable::Magic 0.48 (); 19 | use Sub::Exporter::Progressive 0.001006 -setup => { 20 | exports => ['on_scope_end'], 21 | groups => { default => ['on_scope_end'] }, 22 | }; 23 | 24 | my $wiz = Variable::Magic::wizard 25 | data => sub { [$_[1]] }, 26 | free => sub { $_->() for @{ $_[1] }; () }, 27 | # When someone localise %^H, our magic doesn't want to be copied 28 | # down. We want it to be around only for the scope we've initially 29 | # attached ourselves to. Merely having MGf_LOCAL and a noop svt_local 30 | # callback achieves this. If anything wants to attach more magic of our 31 | # kind to a localised %^H, things will continue to just work as we'll be 32 | # attached with a new and empty callback list. 33 | local => \undef 34 | ; 35 | 36 | sub on_scope_end (&) { 37 | $^H |= 0x020000; 38 | 39 | if (my $stack = Variable::Magic::getdata %^H, $wiz) { 40 | push @{ $stack }, $_[0]; 41 | } 42 | else { 43 | Variable::Magic::cast %^H, $wiz, $_[0]; 44 | } 45 | } 46 | 47 | 1; 48 | 49 | __END__ 50 | 51 | =pod 52 | 53 | =encoding UTF-8 54 | 55 | =head1 NAME 56 | 57 | B::Hooks::EndOfScope::XS - Execute code after a scope finished compilation - XS implementation 58 | 59 | =head1 VERSION 60 | 61 | version 0.24 62 | 63 | =head1 DESCRIPTION 64 | 65 | This is the implementation of L based on 66 | L, which is an XS module dependent on a compiler. It will 67 | always be automatically preferred if L is available. 68 | 69 | =head1 FUNCTIONS 70 | 71 | =head2 on_scope_end 72 | 73 | on_scope_end { ... }; 74 | 75 | on_scope_end $code; 76 | 77 | Registers C<$code> to be executed after the surrounding scope has been 78 | compiled. 79 | 80 | This is exported by default. See L on how to customize it. 81 | 82 | =head1 SUPPORT 83 | 84 | Bugs may be submitted through L 85 | (or L). 86 | 87 | =head1 AUTHORS 88 | 89 | =over 4 90 | 91 | =item * 92 | 93 | Florian Ragwitz 94 | 95 | =item * 96 | 97 | Peter Rabbitson 98 | 99 | =back 100 | 101 | =head1 COPYRIGHT AND LICENCE 102 | 103 | This software is copyright (c) 2008 by Florian Ragwitz. 104 | 105 | This is free software; you can redistribute it and/or modify it under 106 | the same terms as the Perl 5 programming language system itself. 107 | 108 | =cut 109 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Class/C3/next.pm: -------------------------------------------------------------------------------- 1 | package # hide me from PAUSE 2 | next; 3 | 4 | use strict; 5 | use warnings; 6 | no warnings 'redefine'; # for 00load.t w/ core support 7 | 8 | use Scalar::Util 'blessed'; 9 | 10 | our $VERSION = '0.34'; 11 | 12 | our %METHOD_CACHE; 13 | 14 | sub method { 15 | my $self = $_[0]; 16 | my $class = blessed($self) || $self; 17 | my $indirect = caller() =~ /^(?:next|maybe::next)$/; 18 | my $level = $indirect ? 2 : 1; 19 | 20 | my ($method_caller, $label, @label); 21 | while ($method_caller = (caller($level++))[3]) { 22 | @label = (split '::', $method_caller); 23 | $label = pop @label; 24 | last unless 25 | $label eq '(eval)' || 26 | $label eq '__ANON__'; 27 | } 28 | 29 | my $method; 30 | 31 | my $caller = join '::' => @label; 32 | 33 | $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do { 34 | 35 | my @MRO = Class::C3::calculateMRO($class); 36 | 37 | my $current; 38 | while ($current = shift @MRO) { 39 | last if $caller eq $current; 40 | } 41 | 42 | no strict 'refs'; 43 | my $found; 44 | foreach my $class (@MRO) { 45 | next if (defined $Class::C3::MRO{$class} && 46 | defined $Class::C3::MRO{$class}{methods}{$label}); 47 | last if (defined ($found = *{$class . '::' . $label}{CODE})); 48 | } 49 | 50 | $found; 51 | }; 52 | 53 | return $method if $indirect; 54 | 55 | die "No next::method '$label' found for $self" if !$method; 56 | 57 | goto &{$method}; 58 | } 59 | 60 | sub can { method($_[0]) } 61 | 62 | package # hide me from PAUSE 63 | maybe::next; 64 | 65 | use strict; 66 | use warnings; 67 | no warnings 'redefine'; # for 00load.t w/ core support 68 | 69 | our $VERSION = '0.34'; 70 | 71 | sub method { (next::method($_[0]) || return)->(@_) } 72 | 73 | 1; 74 | 75 | __END__ 76 | 77 | =pod 78 | 79 | =head1 NAME 80 | 81 | Class::C3::next - Pure-perl next::method and friends 82 | 83 | =head1 DESCRIPTION 84 | 85 | This module is used internally by L when 86 | necessary, and shouldn't be used (or required in 87 | distribution dependencies) directly. It 88 | defines C, C, and 89 | C in pure perl. 90 | 91 | =head1 AUTHOR 92 | 93 | Stevan Little, 94 | 95 | Brandon L. Black, 96 | 97 | =head1 COPYRIGHT AND LICENSE 98 | 99 | Copyright 2005, 2006 by Infinity Interactive, Inc. 100 | 101 | L 102 | 103 | This library is free software; you can redistribute it and/or modify 104 | it under the same terms as Perl itself. 105 | 106 | =cut 107 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Devel/GlobalDestruction.pm: -------------------------------------------------------------------------------- 1 | package Devel::GlobalDestruction; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | our $VERSION = '0.14'; 7 | 8 | use Sub::Exporter::Progressive -setup => { 9 | exports => [ qw(in_global_destruction) ], 10 | groups => { default => [ -all ] }, 11 | }; 12 | 13 | # we run 5.14+ - everything is in core 14 | # 15 | if (defined ${^GLOBAL_PHASE}) { 16 | eval 'sub in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }; 1' 17 | or die $@; 18 | } 19 | # try to load the xs version if it was compiled 20 | # 21 | elsif (eval { 22 | require Devel::GlobalDestruction::XS; 23 | no warnings 'once'; 24 | *in_global_destruction = \&Devel::GlobalDestruction::XS::in_global_destruction; 25 | 1; 26 | }) { 27 | # the eval already installed everything, nothing to do 28 | } 29 | else { 30 | # internally, PL_main_cv is set to Nullcv immediately before entering 31 | # global destruction and we can use B to detect that. B::main_cv will 32 | # only ever be a B::CV or a B::SPECIAL that is a reference to 0 33 | require B; 34 | eval 'sub in_global_destruction () { ${B::main_cv()} == 0 }; 1' 35 | or die $@; 36 | } 37 | 38 | 1; # keep require happy 39 | 40 | 41 | __END__ 42 | 43 | =head1 NAME 44 | 45 | Devel::GlobalDestruction - Provides function returning the equivalent of 46 | C<${^GLOBAL_PHASE} eq 'DESTRUCT'> for older perls. 47 | 48 | =head1 SYNOPSIS 49 | 50 | package Foo; 51 | use Devel::GlobalDestruction; 52 | 53 | use namespace::clean; # to avoid having an "in_global_destruction" method 54 | 55 | sub DESTROY { 56 | return if in_global_destruction; 57 | 58 | do_something_a_little_tricky(); 59 | } 60 | 61 | =head1 DESCRIPTION 62 | 63 | Perl's global destruction is a little tricky to deal with WRT finalizers 64 | because it's not ordered and objects can sometimes disappear. 65 | 66 | Writing defensive destructors is hard and annoying, and usually if global 67 | destruction is happening you only need the destructors that free up non 68 | process local resources to actually execute. 69 | 70 | For these constructors you can avoid the mess by simply bailing out if global 71 | destruction is in effect. 72 | 73 | =head1 EXPORTS 74 | 75 | This module uses L so the exports may be renamed, 76 | aliased, etc. if L is present. 77 | 78 | =over 4 79 | 80 | =item in_global_destruction 81 | 82 | Returns true if the interpreter is in global destruction. In perl 5.14+, this 83 | returns C<${^GLOBAL_PHASE} eq 'DESTRUCT'>, and on earlier perls, detects it using 84 | the value of C or C. 85 | 86 | =back 87 | 88 | =head1 AUTHORS 89 | 90 | Yuval Kogman Enothingmuch@woobling.orgE 91 | 92 | Florian Ragwitz Erafl@debian.orgE 93 | 94 | Jesse Luehrs Edoy@tozt.netE 95 | 96 | Peter Rabbitson Eribasushi@cpan.orgE 97 | 98 | Arthur Axel 'fREW' Schmidt Efrioux@gmail.comE 99 | 100 | Elizabeth Mattijsen Eliz@dijkmat.nlE 101 | 102 | Greham Knop Ehaarg@haarg.orgE 103 | 104 | =head1 COPYRIGHT 105 | 106 | Copyright (c) 2008 Yuval Kogman. All rights reserved 107 | This program is free software; you can redistribute 108 | it and/or modify it under the same terms as Perl itself. 109 | 110 | =cut 111 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Devel/TypeTiny/Perl56Compat.pm: -------------------------------------------------------------------------------- 1 | package Devel::TypeTiny::Perl56Compat; 2 | 3 | use 5.006; 4 | use strict; 5 | use warnings; 6 | 7 | our $AUTHORITY = 'cpan:TOBYINK'; 8 | our $VERSION = '1.000005'; 9 | 10 | #### B doesn't provide perlstring() in 5.6. Monkey patch it. 11 | 12 | use B (); 13 | 14 | unless (exists &B::perlstring) 15 | { 16 | my $d; 17 | *B::perlstring = sub { 18 | no warnings 'uninitialized'; 19 | require Data::Dumper; 20 | $d ||= 'Data::Dumper'->new([])->Indent(0)->Purity(0)->Pad('')->Useqq(1)->Terse(1)->Freezer('')->Toaster(''); 21 | my $perlstring = $d->Values([''.shift])->Dump; 22 | ($perlstring =~ /^"/) ? $perlstring : qq["$perlstring"]; 23 | }; 24 | } 25 | 26 | push @B::EXPORT_OK, 'perlstring'; 27 | 28 | #### Done! 29 | 30 | 5.6; 31 | 32 | __END__ 33 | 34 | =pod 35 | 36 | =encoding utf-8 37 | 38 | =for stopwords pragmas 39 | 40 | =head1 NAME 41 | 42 | Devel::TypeTiny::Perl56Compat - shims to allow Type::Tiny to run on Perl 5.6.x 43 | 44 | =head1 STATUS 45 | 46 | This module is considered part of Type-Tiny's internals. It is not 47 | covered by the 48 | L. 49 | 50 | =head1 DESCRIPTION 51 | 52 | This is not considered part of Type::Tiny's public API. 53 | 54 | Currently this module just has one job: it patches L to export a 55 | C function, as this was only added in Perl 5.8.0. 56 | 57 | =head1 BUGS 58 | 59 | Please report any bugs to 60 | L. 61 | 62 | =head1 AUTHOR 63 | 64 | Toby Inkster Etobyink@cpan.orgE. 65 | 66 | =head1 COPYRIGHT AND LICENCE 67 | 68 | This software is copyright (c) 2013-2014 by Toby Inkster. 69 | 70 | This is free software; you can redistribute it and/or modify it under 71 | the same terms as the Perl 5 programming language system itself. 72 | 73 | =head1 DISCLAIMER OF WARRANTIES 74 | 75 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 76 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 77 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 78 | 79 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Devel/TypeTiny/Perl58Compat.pm: -------------------------------------------------------------------------------- 1 | package Devel::TypeTiny::Perl58Compat; 2 | 3 | use 5.006; 4 | use strict; 5 | use warnings; 6 | 7 | our $AUTHORITY = 'cpan:TOBYINK'; 8 | our $VERSION = '1.000005'; 9 | 10 | #### re doesn't provide is_regexp in Perl < 5.10 11 | 12 | eval 'require re'; 13 | 14 | unless (exists &re::is_regexp) 15 | { 16 | require B; 17 | *re::is_regexp = sub { 18 | eval { B::svref_2object($_[0])->MAGIC->TYPE eq 'r' }; 19 | }; 20 | } 21 | 22 | #### Done! 23 | 24 | 5.6; 25 | 26 | __END__ 27 | 28 | =pod 29 | 30 | =encoding utf-8 31 | 32 | =for stopwords pragmas 33 | 34 | =head1 NAME 35 | 36 | Devel::TypeTiny::Perl58Compat - shims to allow Type::Tiny to run on Perl 5.8.x 37 | 38 | =head1 STATUS 39 | 40 | This module is considered part of Type-Tiny's internals. It is not 41 | covered by the 42 | L. 43 | 44 | =head1 DESCRIPTION 45 | 46 | This is not considered part of Type::Tiny's public API. 47 | 48 | Currently this module just has one job: it patches L to provide a 49 | C function, as this was only added in Perl 5.9.5. 50 | 51 | =head1 BUGS 52 | 53 | Please report any bugs to 54 | L. 55 | 56 | =head1 AUTHOR 57 | 58 | Toby Inkster Etobyink@cpan.orgE. 59 | 60 | =head1 COPYRIGHT AND LICENCE 61 | 62 | This software is copyright (c) 2013-2014 by Toby Inkster. 63 | 64 | This is free software; you can redistribute it and/or modify it under 65 | the same terms as the Perl 5 programming language system itself. 66 | 67 | =head1 DISCLAIMER OF WARRANTIES 68 | 69 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 70 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 71 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 72 | 73 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Error/TypeTiny/Assertion.pm: -------------------------------------------------------------------------------- 1 | package Error::TypeTiny::Assertion; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | if ($] < 5.008) { require Devel::TypeTiny::Perl56Compat }; 9 | } 10 | 11 | BEGIN { 12 | $Error::TypeTiny::Assertion::AUTHORITY = 'cpan:TOBYINK'; 13 | $Error::TypeTiny::Assertion::VERSION = '1.000005'; 14 | } 15 | 16 | require Error::TypeTiny; 17 | our @ISA = 'Error::TypeTiny'; 18 | 19 | sub type { $_[0]{type} }; 20 | sub value { $_[0]{value} }; 21 | sub varname { $_[0]{varname} ||= '$_' }; 22 | sub attribute_step { $_[0]{attribute_step} }; 23 | sub attribute_name { $_[0]{attribute_name} }; 24 | 25 | sub has_type { defined $_[0]{type} }; # sic 26 | sub has_attribute_step { exists $_[0]{attribute_step} }; 27 | sub has_attribute_name { exists $_[0]{attribute_name} }; 28 | 29 | sub new 30 | { 31 | my $class = shift; 32 | my $self = $class->SUPER::new(@_); 33 | 34 | if (ref $Method::Generate::Accessor::CurrentAttribute) 35 | { 36 | require B; 37 | my %d = %{$Method::Generate::Accessor::CurrentAttribute}; 38 | $self->{attribute_name} = $d{name} if defined $d{name}; 39 | $self->{attribute_step} = $d{step} if defined $d{step}; 40 | 41 | if (defined $d{init_arg}) 42 | { 43 | $self->{varname} = sprintf('$args->{%s}', B::perlstring($d{init_arg})); 44 | } 45 | elsif (defined $d{name}) 46 | { 47 | $self->{varname} = sprintf('$self->{%s}', B::perlstring($d{name})); 48 | } 49 | } 50 | 51 | return $self; 52 | } 53 | 54 | sub message 55 | { 56 | my $e = shift; 57 | $e->varname eq '$_' 58 | ? $e->SUPER::message 59 | : sprintf('%s (in %s)', $e->SUPER::message, $e->varname); 60 | } 61 | 62 | sub _build_message 63 | { 64 | my $e = shift; 65 | $e->has_type 66 | ? sprintf('%s did not pass type constraint "%s"', Type::Tiny::_dd($e->value), $e->type) 67 | : sprintf('%s did not pass type constraint', Type::Tiny::_dd($e->value)) 68 | } 69 | 70 | *to_string = sub 71 | { 72 | my $e = shift; 73 | my $msg = $e->message; 74 | 75 | my $c = $e->context; 76 | $msg .= sprintf(" at %s line %s", $c->{file}||'file?', $c->{line}||'NaN') if $c; 77 | 78 | my $explain = $e->explain; 79 | return $msg unless @{ $explain || [] }; 80 | 81 | $msg .= "\n"; 82 | for my $line (@$explain) { 83 | $msg .= " $line\n"; 84 | } 85 | 86 | return $msg; 87 | } if $] >= 5.008; 88 | 89 | sub explain 90 | { 91 | my $e = shift; 92 | return undef unless $e->has_type; 93 | $e->type->validate_explain($e->value, $e->varname); 94 | } 95 | 96 | 1; 97 | 98 | __END__ 99 | 100 | =pod 101 | 102 | =encoding utf-8 103 | 104 | =head1 NAME 105 | 106 | Error::TypeTiny::Assertion - exception when a value fails a type constraint 107 | 108 | =head1 STATUS 109 | 110 | This module is covered by the 111 | L. 112 | 113 | =head1 DESCRIPTION 114 | 115 | This exception is thrown when a value fails a type constraint assertion. 116 | 117 | This package inherits from L; see that for most 118 | documentation. Major differences are listed below: 119 | 120 | =head2 Attributes 121 | 122 | =over 123 | 124 | =item C 125 | 126 | The type constraint that was checked against. Weakened links are involved, 127 | so this may end up being C. 128 | 129 | =item C 130 | 131 | The value that was tested. 132 | 133 | =item C 134 | 135 | The name of the variable that was checked, if known. Defaults to C<< '$_' >>. 136 | 137 | =item C 138 | 139 | If this exception was thrown as the result of an isa check or a failed 140 | coercion for a Moo attribute, then this will tell you which attribute (if 141 | your Moo is new enough). 142 | 143 | (Hopefully one day this will support other OO frameworks.) 144 | 145 | =item C 146 | 147 | If this exception was thrown as the result of an isa check or a failed 148 | coercion for a Moo attribute, then this will contain either C<< "isa check" >> 149 | or C<< "coercion" >> to indicate which went wrong (if your Moo is new enough). 150 | 151 | (Hopefully one day this will support other OO frameworks.) 152 | 153 | =back 154 | 155 | =head2 Methods 156 | 157 | =over 158 | 159 | =item C, C, C 160 | 161 | Predicate methods. 162 | 163 | =item C 164 | 165 | Overridden to add C to the message if defined. 166 | 167 | =item C 168 | 169 | Attempts to explain why the value did not pass the type constraint. Returns 170 | an arrayref of strings providing step-by-step reasoning; or returns undef if 171 | no explanation is possible. 172 | 173 | =back 174 | 175 | =head1 BUGS 176 | 177 | Please report any bugs to 178 | L. 179 | 180 | =head1 SEE ALSO 181 | 182 | L. 183 | 184 | =head1 AUTHOR 185 | 186 | Toby Inkster Etobyink@cpan.orgE. 187 | 188 | =head1 COPYRIGHT AND LICENCE 189 | 190 | This software is copyright (c) 2013-2014 by Toby Inkster. 191 | 192 | This is free software; you can redistribute it and/or modify it under 193 | the same terms as the Perl 5 programming language system itself. 194 | 195 | =head1 DISCLAIMER OF WARRANTIES 196 | 197 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 198 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 199 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 200 | 201 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Error/TypeTiny/Compilation.pm: -------------------------------------------------------------------------------- 1 | package Error::TypeTiny::Compilation; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Error::TypeTiny::Compilation::AUTHORITY = 'cpan:TOBYINK'; 9 | $Error::TypeTiny::Compilation::VERSION = '1.000005'; 10 | } 11 | 12 | require Error::TypeTiny; 13 | our @ISA = 'Error::TypeTiny'; 14 | 15 | sub code { $_[0]{code} }; 16 | sub environment { $_[0]{environment} ||= {} }; 17 | sub errstr { $_[0]{errstr} }; 18 | 19 | sub _build_message 20 | { 21 | my $self = shift; 22 | sprintf("Failed to compile source because: %s", $self->errstr); 23 | } 24 | 25 | 1; 26 | 27 | __END__ 28 | 29 | =pod 30 | 31 | =encoding utf-8 32 | 33 | =head1 NAME 34 | 35 | Error::TypeTiny::Compilation - exception for Eval::TypeTiny 36 | 37 | =head1 STATUS 38 | 39 | This module is covered by the 40 | L. 41 | 42 | =head1 DESCRIPTION 43 | 44 | Thrown when compiling a closure fails. Common causes are problems with 45 | inlined type constraints, and syntax errors when coercions are given as 46 | strings of Perl code. 47 | 48 | This package inherits from L; see that for most 49 | documentation. Major differences are listed below: 50 | 51 | =head2 Attributes 52 | 53 | =over 54 | 55 | =item C 56 | 57 | The Perl source code being compiled. 58 | 59 | =item C 60 | 61 | Hashref of variables being closed over. 62 | 63 | =item C 64 | 65 | Error message from Perl compiler. 66 | 67 | =back 68 | 69 | =head1 BUGS 70 | 71 | Please report any bugs to 72 | L. 73 | 74 | =head1 SEE ALSO 75 | 76 | L. 77 | 78 | =head1 AUTHOR 79 | 80 | Toby Inkster Etobyink@cpan.orgE. 81 | 82 | =head1 COPYRIGHT AND LICENCE 83 | 84 | This software is copyright (c) 2013-2014 by Toby Inkster. 85 | 86 | This is free software; you can redistribute it and/or modify it under 87 | the same terms as the Perl 5 programming language system itself. 88 | 89 | =head1 DISCLAIMER OF WARRANTIES 90 | 91 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 92 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 93 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 94 | 95 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Error/TypeTiny/WrongNumberOfParameters.pm: -------------------------------------------------------------------------------- 1 | package Error::TypeTiny::WrongNumberOfParameters; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Error::TypeTiny::WrongNumberOfParameters::AUTHORITY = 'cpan:TOBYINK'; 9 | $Error::TypeTiny::WrongNumberOfParameters::VERSION = '1.000005'; 10 | } 11 | 12 | require Error::TypeTiny; 13 | our @ISA = 'Error::TypeTiny'; 14 | 15 | sub minimum { $_[0]{minimum} }; 16 | sub maximum { $_[0]{maximum} }; 17 | sub got { $_[0]{got} }; 18 | 19 | sub has_minimum { exists $_[0]{minimum} }; 20 | sub has_maximum { exists $_[0]{maximum} }; 21 | 22 | sub _build_message 23 | { 24 | my $e = shift; 25 | if ($e->has_minimum and $e->has_maximum and $e->minimum == $e->maximum) 26 | { 27 | return sprintf( 28 | "Wrong number of parameters; got %d; expected %d", 29 | $e->got, 30 | $e->minimum, 31 | ); 32 | } 33 | elsif ($e->has_minimum and $e->has_maximum and $e->minimum < $e->maximum) 34 | { 35 | return sprintf( 36 | "Wrong number of parameters; got %d; expected %d to %d", 37 | $e->got, 38 | $e->minimum, 39 | $e->maximum, 40 | ); 41 | } 42 | elsif ($e->has_minimum) 43 | { 44 | return sprintf( 45 | "Wrong number of parameters; got %d; expected at least %d", 46 | $e->got, 47 | $e->minimum, 48 | ); 49 | } 50 | else 51 | { 52 | return sprintf( 53 | "Wrong number of parameters; got %d", 54 | $e->got, 55 | ); 56 | } 57 | } 58 | 59 | 1; 60 | 61 | __END__ 62 | 63 | =pod 64 | 65 | =encoding utf-8 66 | 67 | =head1 NAME 68 | 69 | Error::TypeTiny::WrongNumberOfParameters - exception for Type::Params 70 | 71 | =head1 STATUS 72 | 73 | This module is covered by the 74 | L. 75 | 76 | =head1 DESCRIPTION 77 | 78 | Thrown when a Type::Params compiled check is called with the wrong number 79 | of parameters. 80 | 81 | This package inherits from L; see that for most 82 | documentation. Major differences are listed below: 83 | 84 | =head2 Attributes 85 | 86 | =over 87 | 88 | =item C 89 | 90 | The minimum expected number of parameters. 91 | 92 | =item C 93 | 94 | The maximum expected number of parameters. 95 | 96 | =item C 97 | 98 | The number of parameters actually passed to the compiled check. 99 | 100 | =back 101 | 102 | =head2 Methods 103 | 104 | =over 105 | 106 | =item C, C 107 | 108 | Predicate methods. 109 | 110 | =back 111 | 112 | =head1 BUGS 113 | 114 | Please report any bugs to 115 | L. 116 | 117 | =head1 SEE ALSO 118 | 119 | L. 120 | 121 | =head1 AUTHOR 122 | 123 | Toby Inkster Etobyink@cpan.orgE. 124 | 125 | =head1 COPYRIGHT AND LICENCE 126 | 127 | This software is copyright (c) 2013-2014 by Toby Inkster. 128 | 129 | This is free software; you can redistribute it and/or modify it under 130 | the same terms as the Perl 5 programming language system itself. 131 | 132 | =head1 DISCLAIMER OF WARRANTIES 133 | 134 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 135 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 136 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 137 | 138 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Exporter/Shiny.pm: -------------------------------------------------------------------------------- 1 | package Exporter::Shiny; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | use Exporter::Tiny (); 8 | 9 | our $AUTHORITY = 'cpan:TOBYINK'; 10 | our $VERSION = '0.042'; 11 | 12 | sub import { 13 | my $me = shift; 14 | my $caller = caller; 15 | 16 | (my $nominal_file = $caller) =~ s(::)(/)g; 17 | $INC{"$nominal_file\.pm"} ||= __FILE__; 18 | 19 | if (@_ == 2 and $_[0] eq -setup) 20 | { 21 | my (undef, $opts) = @_; 22 | @_ = @{ delete($opts->{exports}) || [] }; 23 | 24 | if (%$opts) { 25 | Exporter::Tiny::_croak( 26 | 'Unsupported Sub::Exporter-style options: %s', 27 | join(q[, ], sort keys %$opts), 28 | ); 29 | } 30 | } 31 | 32 | ref($_) && Exporter::Tiny::_croak('Expected sub name, got ref %s', $_) for @_; 33 | 34 | no strict qw(refs); 35 | push @{"$caller\::ISA"}, 'Exporter::Tiny'; 36 | push @{"$caller\::EXPORT_OK"}, @_; 37 | } 38 | 39 | 1; 40 | 41 | __END__ 42 | 43 | =pod 44 | 45 | =encoding utf-8 46 | 47 | =head1 NAME 48 | 49 | Exporter::Shiny - shortcut for Exporter::Tiny 50 | 51 | =head1 SYNOPSIS 52 | 53 | use Exporter::Shiny qw( foo bar ); 54 | 55 | Is a shortcut for: 56 | 57 | use base "Exporter::Tiny"; 58 | push our(@EXPORT_OK), qw( foo bar ); 59 | 60 | For compatibility with L, the following longer syntax is 61 | also supported: 62 | 63 | use Exporter::Shiny -setup => { 64 | exports => [qw( foo bar )], 65 | }; 66 | 67 | =head1 DESCRIPTION 68 | 69 | This is a very small wrapper to simplify using L. 70 | 71 | It does the following: 72 | 73 | =over 74 | 75 | =item * Marks your package as loaded in C<< %INC >>; 76 | 77 | =item * Pushes any function names in the import list onto your C<< @EXPORT_OK >>; and 78 | 79 | =item * Pushes C<< "Exporter::Tiny" >> onto your C<< @ISA >>. 80 | 81 | =back 82 | 83 | It doesn't set up C<< %EXPORT_TAGS >> or C<< @EXPORT >>, but there's 84 | nothing stopping you doing that yourself. 85 | 86 | =head1 BUGS 87 | 88 | Please report any bugs to 89 | L. 90 | 91 | =head1 SEE ALSO 92 | 93 | L. 94 | 95 | =head1 AUTHOR 96 | 97 | Toby Inkster Etobyink@cpan.orgE. 98 | 99 | =head1 COPYRIGHT AND LICENCE 100 | 101 | This software is copyright (c) 2014 by Toby Inkster. 102 | 103 | This is free software; you can redistribute it and/or modify it under 104 | the same terms as the Perl 5 programming language system itself. 105 | 106 | =head1 DISCLAIMER OF WARRANTIES 107 | 108 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 109 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 110 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 111 | 112 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Method/Generate/BuildAll.pm: -------------------------------------------------------------------------------- 1 | package Method::Generate::BuildAll; 2 | 3 | use Moo::_strictures; 4 | use Moo::Object (); 5 | BEGIN { our @ISA = qw(Moo::Object) } 6 | use Sub::Quote qw(quote_sub quotify); 7 | use Moo::_Utils qw(_getglob); 8 | use Moo::_mro; 9 | 10 | sub generate_method { 11 | my ($self, $into) = @_; 12 | quote_sub "${into}::BUILDALL" 13 | => join('', 14 | $self->_handle_subbuild($into), 15 | qq{ my \$self = shift;\n}, 16 | $self->buildall_body_for($into, '$self', '@_'), 17 | qq{ return \$self\n}, 18 | ) 19 | => {} 20 | => { no_defer => 1 } 21 | ; 22 | } 23 | 24 | sub _handle_subbuild { 25 | my ($self, $into) = @_; 26 | ' if (ref($_[0]) ne '.quotify($into).') {'."\n". 27 | ' return shift->Moo::Object::BUILDALL(@_)'.";\n". 28 | ' }'."\n"; 29 | } 30 | 31 | sub buildall_body_for { 32 | my ($self, $into, $me, $args) = @_; 33 | my @builds = 34 | grep *{_getglob($_)}{CODE}, 35 | map "${_}::BUILD", 36 | reverse @{mro::get_linear_isa($into)}; 37 | ' (('.$args.')[0]->{__no_BUILD__} or ('."\n" 38 | .join('', map qq{ ${me}->${_}(${args}),\n}, @builds) 39 | ." )),\n"; 40 | } 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Method/Generate/DemolishAll.pm: -------------------------------------------------------------------------------- 1 | package Method::Generate::DemolishAll; 2 | 3 | use Moo::_strictures; 4 | use Moo::Object (); 5 | BEGIN { our @ISA = qw(Moo::Object) } 6 | use Sub::Quote qw(quote_sub quotify); 7 | use Moo::_Utils qw(_getglob); 8 | use Moo::_mro; 9 | 10 | sub generate_method { 11 | my ($self, $into) = @_; 12 | quote_sub "${into}::DEMOLISHALL", join '', 13 | $self->_handle_subdemolish($into), 14 | qq{ my \$self = shift;\n}, 15 | $self->demolishall_body_for($into, '$self', '@_'), 16 | qq{ return \$self\n}; 17 | quote_sub "${into}::DESTROY", join '', 18 | q! my $self = shift; 19 | my $e = do { 20 | local $?; 21 | local $@; 22 | require Devel::GlobalDestruction; 23 | eval { 24 | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); 25 | }; 26 | $@; 27 | }; 28 | 29 | # fatal warnings+die in DESTROY = bad times (perl rt#123398) 30 | no warnings FATAL => 'all'; 31 | use warnings 'all'; 32 | die $e if $e; # rethrow 33 | !; 34 | } 35 | 36 | sub demolishall_body_for { 37 | my ($self, $into, $me, $args) = @_; 38 | my @demolishers = 39 | grep *{_getglob($_)}{CODE}, 40 | map "${_}::DEMOLISH", 41 | @{mro::get_linear_isa($into)}; 42 | join '', map qq{ ${me}->${_}(${args});\n}, @demolishers; 43 | } 44 | 45 | sub _handle_subdemolish { 46 | my ($self, $into) = @_; 47 | ' if (ref($_[0]) ne '.quotify($into).') {'."\n". 48 | ' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n". 49 | ' }'."\n"; 50 | } 51 | 52 | 1; 53 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/HandleMoose/FakeMetaClass.pm: -------------------------------------------------------------------------------- 1 | package Moo::HandleMoose::FakeMetaClass; 2 | use Moo::_strictures; 3 | use Carp (); 4 | BEGIN { our @CARP_NOT = qw(Moo::HandleMoose) } 5 | 6 | sub DESTROY { } 7 | 8 | sub AUTOLOAD { 9 | my ($meth) = (our $AUTOLOAD =~ /([^:]+)$/); 10 | my $self = shift; 11 | Carp::croak "Can't call $meth without object instance" 12 | if !ref $self; 13 | Carp::croak "Can't inflate Moose metaclass with Moo::sification disabled" 14 | if $Moo::sification::disabled; 15 | require Moo::HandleMoose; 16 | Moo::HandleMoose::inject_real_metaclass_for($self->{name})->$meth(@_) 17 | } 18 | sub can { 19 | my $self = shift; 20 | return $self->SUPER::can(@_) 21 | if !ref $self or $Moo::sification::disabled; 22 | require Moo::HandleMoose; 23 | Moo::HandleMoose::inject_real_metaclass_for($self->{name})->can(@_) 24 | } 25 | sub isa { 26 | my $self = shift; 27 | return $self->SUPER::isa(@_) 28 | if !ref $self or $Moo::sification::disabled; 29 | require Moo::HandleMoose; 30 | Moo::HandleMoose::inject_real_metaclass_for($self->{name})->isa(@_) 31 | } 32 | sub make_immutable { $_[0] } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/HandleMoose/_TypeMap.pm: -------------------------------------------------------------------------------- 1 | package Moo::HandleMoose::_TypeMap; 2 | use Moo::_strictures; 3 | 4 | package 5 | Moo::HandleMoose; 6 | our %TYPE_MAP; 7 | 8 | package Moo::HandleMoose::_TypeMap; 9 | 10 | use Scalar::Util (); 11 | use Config; 12 | 13 | our %WEAK_TYPES; 14 | 15 | sub _str_to_ref { 16 | my $in = shift; 17 | return $in 18 | if ref $in; 19 | 20 | if ($in =~ /(?:^|=)([A-Z]+)\(0x([0-9a-zA-Z]+)\)$/) { 21 | my $type = $1; 22 | my $id = do { no warnings 'portable'; hex "$2" }; 23 | require B; 24 | my $sv = bless \$id, 'B::SV'; 25 | my $ref = eval { $sv->object_2svref }; 26 | if (!defined $ref or Scalar::Util::reftype($ref) ne $type) { 27 | die <<'END_ERROR'; 28 | Moo initialization encountered types defined in a parent thread - ensure that 29 | Moo is require()d before any further thread spawns following a type definition. 30 | END_ERROR 31 | } 32 | return $ref; 33 | } 34 | return $in; 35 | } 36 | 37 | sub TIEHASH { bless {}, $_[0] } 38 | 39 | sub STORE { 40 | my ($self, $key, $value) = @_; 41 | my $type = _str_to_ref($key); 42 | $WEAK_TYPES{$type} = $type; 43 | Scalar::Util::weaken($WEAK_TYPES{$type}) 44 | if ref $type; 45 | $self->{$key} = $value; 46 | } 47 | 48 | sub FETCH { $_[0]->{$_[1]} } 49 | sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} } 50 | sub NEXTKEY { each %{$_[0]} } 51 | sub EXISTS { exists $_[0]->{$_[1]} } 52 | sub DELETE { delete $_[0]->{$_[1]} } 53 | sub CLEAR { %{$_[0]} = () } 54 | sub SCALAR { scalar %{$_[0]} } 55 | 56 | sub CLONE { 57 | my @types = map { 58 | defined $WEAK_TYPES{$_} ? ($WEAK_TYPES{$_} => $TYPE_MAP{$_}) : () 59 | } keys %TYPE_MAP; 60 | %WEAK_TYPES = (); 61 | %TYPE_MAP = @types; 62 | } 63 | 64 | sub DESTROY { 65 | my %types = %{$_[0]}; 66 | untie %TYPE_MAP; 67 | %TYPE_MAP = %types; 68 | } 69 | 70 | if ($Config{useithreads}) { 71 | my @types = %TYPE_MAP; 72 | tie %TYPE_MAP, __PACKAGE__; 73 | %TYPE_MAP = @types; 74 | } 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/Object.pm: -------------------------------------------------------------------------------- 1 | package Moo::Object; 2 | 3 | use Moo::_strictures; 4 | use Carp (); 5 | 6 | our %NO_BUILD; 7 | our %NO_DEMOLISH; 8 | our $BUILD_MAKER; 9 | our $DEMOLISH_MAKER; 10 | 11 | sub new { 12 | my $class = shift; 13 | unless (exists $NO_DEMOLISH{$class}) { 14 | unless ($NO_DEMOLISH{$class} = !$class->can('DEMOLISH')) { 15 | ($DEMOLISH_MAKER ||= do { 16 | require Method::Generate::DemolishAll; 17 | Method::Generate::DemolishAll->new 18 | })->generate_method($class); 19 | } 20 | } 21 | my $proto = $class->BUILDARGS(@_); 22 | $NO_BUILD{$class} and 23 | return bless({}, $class); 24 | $NO_BUILD{$class} = !$class->can('BUILD') unless exists $NO_BUILD{$class}; 25 | $NO_BUILD{$class} 26 | ? bless({}, $class) 27 | : bless({}, $class)->BUILDALL($proto); 28 | } 29 | 30 | # Inlined into Method::Generate::Constructor::_generate_args() - keep in sync 31 | sub BUILDARGS { 32 | my $class = shift; 33 | scalar @_ == 1 34 | ? ref $_[0] eq 'HASH' 35 | ? { %{ $_[0] } } 36 | : Carp::croak("Single parameters to new() must be a HASH ref" 37 | . " data => ". $_[0]) 38 | : @_ % 2 39 | ? Carp::croak("The new() method for $class expects a hash reference or a" 40 | . " key/value list. You passed an odd number of arguments") 41 | : {@_} 42 | ; 43 | } 44 | 45 | sub BUILDALL { 46 | my $self = shift; 47 | $self->${\(($BUILD_MAKER ||= do { 48 | require Method::Generate::BuildAll; 49 | Method::Generate::BuildAll->new 50 | })->generate_method(ref($self)))}(@_); 51 | } 52 | 53 | sub DEMOLISHALL { 54 | my $self = shift; 55 | $self->${\(($DEMOLISH_MAKER ||= do { 56 | require Method::Generate::DemolishAll; 57 | Method::Generate::DemolishAll->new 58 | })->generate_method(ref($self)))}(@_); 59 | } 60 | 61 | sub does { 62 | return !!0 63 | unless ($INC{'Moose/Role.pm'} || $INC{'Role/Tiny.pm'}); 64 | require Moo::Role; 65 | my $does = Moo::Role->can("does_role"); 66 | { no warnings 'redefine'; *does = $does } 67 | goto &$does; 68 | } 69 | 70 | # duplicated in Moo::Role 71 | sub meta { 72 | require Moo::HandleMoose::FakeMetaClass; 73 | my $class = ref($_[0])||$_[0]; 74 | bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass'); 75 | } 76 | 77 | 1; 78 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/_Utils.pm: -------------------------------------------------------------------------------- 1 | package Moo::_Utils; 2 | use Moo::_strictures; 3 | 4 | { 5 | no strict 'refs'; 6 | sub _getglob { \*{$_[0]} } 7 | sub _getstash { \%{"$_[0]::"} } 8 | } 9 | 10 | BEGIN { 11 | my ($su, $sn); 12 | $su = $INC{'Sub/Util.pm'} && defined &Sub::Util::set_subname 13 | or $sn = $INC{'Sub/Name.pm'} 14 | or $su = eval { require Sub::Util; } && defined &Sub::Util::set_subname 15 | or $sn = eval { require Sub::Name; }; 16 | 17 | *_subname = $su ? \&Sub::Util::set_subname 18 | : $sn ? \&Sub::Name::subname 19 | : sub { $_[1] }; 20 | *_CAN_SUBNAME = ($su || $sn) ? sub(){1} : sub(){0}; 21 | } 22 | 23 | use Module::Runtime qw(use_package_optimistically module_notional_filename); 24 | 25 | use Devel::GlobalDestruction (); 26 | use Exporter qw(import); 27 | use Config; 28 | use Carp qw(croak); 29 | 30 | our @EXPORT = qw( 31 | _getglob _install_modifier _load_module _maybe_load_module 32 | _getstash _install_coderef _name_coderef 33 | _unimport_coderefs _set_loaded 34 | ); 35 | 36 | sub _install_modifier { 37 | my ($into, $type, $name, $code) = @_; 38 | 39 | if ($INC{'Sub/Defer.pm'} and my $to_modify = $into->can($name)) { # CMM will throw for us if not 40 | Sub::Defer::undefer_sub($to_modify); 41 | } 42 | 43 | require Class::Method::Modifiers; 44 | Class::Method::Modifiers::install_modifier(@_); 45 | } 46 | 47 | sub _load_module { 48 | my $module = $_[0]; 49 | my $file = eval { module_notional_filename($module) } or croak $@; 50 | use_package_optimistically($module); 51 | return 1 52 | if $INC{$file}; 53 | my $error = $@ || "Can't locate $file"; 54 | 55 | # can't just ->can('can') because a sub-package Foo::Bar::Baz 56 | # creates a 'Baz::' key in Foo::Bar's symbol table 57 | my $stash = _getstash($module)||{}; 58 | return 1 if grep +(ref($_) || *$_{CODE}), values %$stash; 59 | return 1 60 | if $INC{"Moose.pm"} && Class::MOP::class_of($module) 61 | or Mouse::Util->can('find_meta') && Mouse::Util::find_meta($module); 62 | croak $error; 63 | } 64 | 65 | our %MAYBE_LOADED; 66 | sub _maybe_load_module { 67 | my $module = $_[0]; 68 | return $MAYBE_LOADED{$module} 69 | if exists $MAYBE_LOADED{$module}; 70 | if(! eval { use_package_optimistically($module) }) { 71 | warn "$module exists but failed to load with error: $@"; 72 | } 73 | elsif ( $INC{module_notional_filename($module)} ) { 74 | return $MAYBE_LOADED{$module} = 1; 75 | } 76 | return $MAYBE_LOADED{$module} = 0; 77 | } 78 | 79 | sub _set_loaded { 80 | $INC{Module::Runtime::module_notional_filename($_[0])} ||= $_[1]; 81 | } 82 | 83 | sub _install_coderef { 84 | my ($glob, $code) = (_getglob($_[0]), _name_coderef(@_)); 85 | no warnings 'redefine'; 86 | if (*{$glob}{CODE}) { 87 | *{$glob} = $code; 88 | } 89 | # perl will sometimes warn about mismatched prototypes coming from the 90 | # inheritance cache, so disable them if we aren't redefining a sub 91 | else { 92 | no warnings 'prototype'; 93 | *{$glob} = $code; 94 | } 95 | } 96 | 97 | sub _name_coderef { 98 | shift if @_ > 2; # three args is (target, name, sub) 99 | _CAN_SUBNAME ? _subname(@_) : $_[1]; 100 | } 101 | 102 | sub _unimport_coderefs { 103 | my ($target, $info) = @_; 104 | return unless $info and my $exports = $info->{exports}; 105 | my %rev = reverse %$exports; 106 | my $stash = _getstash($target); 107 | foreach my $name (keys %$exports) { 108 | if ($stash->{$name} and defined(&{$stash->{$name}})) { 109 | if ($rev{$target->can($name)}) { 110 | my $old = delete $stash->{$name}; 111 | my $full_name = join('::',$target,$name); 112 | # Copy everything except the code slot back into place (e.g. $has) 113 | foreach my $type (qw(SCALAR HASH ARRAY IO)) { 114 | next unless defined(*{$old}{$type}); 115 | no strict 'refs'; 116 | *$full_name = *{$old}{$type}; 117 | } 118 | } 119 | } 120 | } 121 | } 122 | 123 | if ($Config{useithreads}) { 124 | require Moo::HandleMoose::_TypeMap; 125 | } 126 | 127 | 1; 128 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/_mro.pm: -------------------------------------------------------------------------------- 1 | package Moo::_mro; 2 | use Moo::_strictures; 3 | 4 | if ("$]" >= 5.010_000) { 5 | require mro; 6 | } else { 7 | require MRO::Compat; 8 | } 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/_strictures.pm: -------------------------------------------------------------------------------- 1 | package Moo::_strictures; 2 | use strict; 3 | use warnings; 4 | 5 | sub import { 6 | if ($ENV{MOO_FATAL_WARNINGS}) { 7 | require strictures; 8 | strictures->VERSION(2); 9 | @_ = ('strictures'); 10 | goto &strictures::import; 11 | } 12 | else { 13 | strict->import; 14 | warnings->import; 15 | warnings->unimport('once'); 16 | } 17 | } 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Moo/sification.pm: -------------------------------------------------------------------------------- 1 | package Moo::sification; 2 | 3 | use Moo::_strictures; 4 | no warnings 'once'; 5 | use Devel::GlobalDestruction qw(in_global_destruction); 6 | use Carp qw(croak); 7 | BEGIN { our @CARP_NOT = qw(Moo::HandleMoose) } 8 | 9 | sub unimport { 10 | croak "Can't disable Moo::sification after inflation has been done" 11 | if $Moo::HandleMoose::SETUP_DONE; 12 | our $disabled = 1; 13 | } 14 | 15 | sub Moo::HandleMoose::AuthorityHack::DESTROY { 16 | unless (our $disabled or in_global_destruction) { 17 | require Moo::HandleMoose; 18 | Moo::HandleMoose->import; 19 | } 20 | } 21 | 22 | sub import { 23 | return 24 | if our $setup_done; 25 | if ($INC{"Moose.pm"}) { 26 | require Moo::HandleMoose; 27 | Moo::HandleMoose->import; 28 | } else { 29 | $Moose::AUTHORITY = bless({}, 'Moo::HandleMoose::AuthorityHack'); 30 | } 31 | $setup_done = 1; 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Package/Stash/Conflicts.pm: -------------------------------------------------------------------------------- 1 | package # hide from PAUSE 2 | Package::Stash::Conflicts; 3 | 4 | use strict; 5 | use warnings; 6 | 7 | # this module was generated with Dist::Zilla::Plugin::Conflicts 0.19 8 | 9 | use Dist::CheckConflicts 10 | -dist => 'Package::Stash', 11 | -conflicts => { 12 | 'Class::MOP' => '1.08', 13 | 'MooseX::Method::Signatures' => '0.36', 14 | 'MooseX::Role::WithOverloading' => '0.08', 15 | 'namespace::clean' => '0.18', 16 | }, 17 | -also => [ qw( 18 | B 19 | Carp 20 | Dist::CheckConflicts 21 | Getopt::Long 22 | Module::Implementation 23 | Scalar::Util 24 | Symbol 25 | constant 26 | strict 27 | warnings 28 | ) ], 29 | 30 | ; 31 | 32 | 1; 33 | 34 | # ABSTRACT: Provide information on conflicts for Package::Stash 35 | # Dist::Zilla: -PodWeaver 36 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Reply/Plugin/TypeTiny.pm: -------------------------------------------------------------------------------- 1 | package Reply::Plugin::TypeTiny; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | BEGIN { 7 | $Reply::Plugin::TypeTiny::AUTHORITY = 'cpan:TOBYINK'; 8 | $Reply::Plugin::TypeTiny::VERSION = '1.000005'; 9 | }; 10 | 11 | require Reply::Plugin; 12 | our @ISA = 'Reply::Plugin'; 13 | 14 | use Scalar::Util qw(blessed); 15 | use Term::ANSIColor; 16 | 17 | sub mangle_error { 18 | my $self = shift; 19 | my ($err) = @_; 20 | 21 | if (blessed $err and $err->isa("Error::TypeTiny::Assertion")) 22 | { 23 | my $explain = $err->explain; 24 | if ($explain) 25 | { 26 | print color("cyan"); 27 | print "Error::TypeTiny::Assertion explain:\n"; 28 | $self->_explanation($explain, ""); 29 | local $| = 1; 30 | print "\n"; 31 | print color("reset"); 32 | } 33 | } 34 | 35 | return @_; 36 | } 37 | 38 | sub _explanation 39 | { 40 | my $self = shift; 41 | my ($ex, $indent) = @_; 42 | 43 | for my $line (@$ex) 44 | { 45 | if (ref($line) eq q(ARRAY)) 46 | { 47 | print "$indent * Explain:\n"; 48 | $self->_explanation($line, "$indent "); 49 | } 50 | else 51 | { 52 | print "$indent * $line\n"; 53 | } 54 | } 55 | } 56 | 57 | 1; 58 | 59 | __END__ 60 | 61 | =pod 62 | 63 | =encoding utf-8 64 | 65 | =head1 NAME 66 | 67 | Reply::Plugin::TypeTiny - improved type constraint exceptions in Reply 68 | 69 | =head1 STATUS 70 | 71 | This module is not covered by the 72 | L. 73 | 74 | =head1 DESCRIPTION 75 | 76 | This is a small plugin to improve error messages in L. 77 | Not massively tested. 78 | 79 | =begin trustme 80 | 81 | =item mangle_error 82 | 83 | =end trustme 84 | 85 | =head1 BUGS 86 | 87 | Please report any bugs to 88 | L. 89 | 90 | =head1 SEE ALSO 91 | 92 | L, L. 93 | 94 | =head1 AUTHOR 95 | 96 | Toby Inkster Etobyink@cpan.orgE. 97 | 98 | =head1 COPYRIGHT AND LICENCE 99 | 100 | This software is copyright (c) 2013-2014 by Toby Inkster. 101 | 102 | This is free software; you can redistribute it and/or modify it under 103 | the same terms as the Perl 5 programming language system itself. 104 | 105 | =head1 DISCLAIMER OF WARRANTIES 106 | 107 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 108 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 109 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 110 | 111 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Sub/Exporter/Progressive.pm: -------------------------------------------------------------------------------- 1 | package Sub::Exporter::Progressive; 2 | $Sub::Exporter::Progressive::VERSION = '0.001013'; 3 | use strict; 4 | use warnings; 5 | 6 | # ABSTRACT: Only use Sub::Exporter if you need it 7 | 8 | sub _croak { 9 | require Carp; 10 | &Carp::croak; 11 | } 12 | 13 | sub import { 14 | my ($self, @args) = @_; 15 | 16 | my $inner_target = caller; 17 | my $export_data = sub_export_options($inner_target, @args); 18 | 19 | my $full_exporter; 20 | no strict 'refs'; 21 | no warnings 'once'; 22 | @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}}; 23 | @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}}; 24 | %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}}; 25 | *{"${inner_target}::import"} = sub { 26 | use strict; 27 | my ($self, @args) = @_; 28 | 29 | if ( grep { 30 | length ref $_ 31 | or 32 | $_ !~ / \A [:-]? \w+ \z /xm 33 | } @args ) { 34 | _croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed' 35 | unless eval { require Sub::Exporter }; 36 | $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original}); 37 | 38 | goto $full_exporter; 39 | } elsif ( defined( (my ($num) = grep { m/^\d/ } @args)[0] ) ) { 40 | _croak "cannot export symbols with a leading digit: '$num'"; 41 | } else { 42 | require Exporter; 43 | s/ \A - /:/xm for @args; 44 | @_ = ($self, @args); 45 | goto \&Exporter::import; 46 | } 47 | }; 48 | return; 49 | } 50 | 51 | my $too_complicated = <<'DEATH'; 52 | You are using Sub::Exporter::Progressive, but the features your program uses from 53 | Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well 54 | just use vanilla Sub::Exporter 55 | DEATH 56 | 57 | sub sub_export_options { 58 | my ($inner_target, $setup, $options) = @_; 59 | 60 | my @exports; 61 | my @defaults; 62 | my %tags; 63 | 64 | if ( ($setup||'') eq '-setup') { 65 | my %options = %$options; 66 | 67 | OPTIONS: 68 | for my $opt (keys %options) { 69 | if ($opt eq 'exports') { 70 | 71 | _croak $too_complicated if ref $options{exports} ne 'ARRAY'; 72 | @exports = @{$options{exports}}; 73 | _croak $too_complicated if grep { length ref $_ } @exports; 74 | 75 | } elsif ($opt eq 'groups') { 76 | %tags = %{$options{groups}}; 77 | for my $tagset (values %tags) { 78 | _croak $too_complicated if grep { 79 | length ref $_ 80 | or 81 | $_ =~ / \A - (?! all \b ) /x 82 | } @{$tagset}; 83 | } 84 | @defaults = @{$tags{default} || [] }; 85 | } else { 86 | _croak $too_complicated; 87 | } 88 | } 89 | @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags; 90 | $tags{all} ||= [ @exports ]; 91 | my %exports = map { $_ => 1 } @exports; 92 | my @errors = grep { not $exports{$_} } @defaults; 93 | _croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; 94 | } 95 | 96 | return { 97 | exports => \@exports, 98 | defaults => \@defaults, 99 | original => $options, 100 | tags => \%tags, 101 | }; 102 | } 103 | 104 | 1; 105 | 106 | __END__ 107 | 108 | =pod 109 | 110 | =encoding UTF-8 111 | 112 | =head1 NAME 113 | 114 | Sub::Exporter::Progressive - Only use Sub::Exporter if you need it 115 | 116 | =head1 VERSION 117 | 118 | version 0.001013 119 | 120 | =head1 SYNOPSIS 121 | 122 | package Syntax::Keyword::Gather; 123 | 124 | use Sub::Exporter::Progressive -setup => { 125 | exports => [qw( break gather gathered take )], 126 | groups => { 127 | default => [qw( break gather gathered take )], 128 | }, 129 | }; 130 | 131 | # elsewhere 132 | 133 | # uses Exporter for speed 134 | use Syntax::Keyword::Gather; 135 | 136 | # somewhere else 137 | 138 | # uses Sub::Exporter for features 139 | use Syntax::Keyword::Gather 'gather', take => { -as => 'grab' }; 140 | 141 | =head1 DESCRIPTION 142 | 143 | L is an incredibly powerful module, but with that power comes 144 | great responsibility, er- as well as some runtime penalties. This module 145 | is a C wrapper that will let your users just use L 146 | if all they are doing is picking exports, but use C if your 147 | users try to use C's more advanced features, like 148 | renaming exports, if they try to use them. 149 | 150 | Note that this module will export C<@EXPORT>, C<@EXPORT_OK> and 151 | C<%EXPORT_TAGS> package variables for C to work. Additionally, if 152 | your package uses advanced C features like currying, this module 153 | will only ever use C, so you might as well use it directly. 154 | 155 | =head1 CONTRIBUTORS 156 | 157 | ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) 158 | 159 | mst - Matt S. Trout (cpan:MSTROUT) 160 | 161 | leont - Leon Timmermans (cpan:LEONT) 162 | 163 | =head1 AUTHOR 164 | 165 | Arthur Axel "fREW" Schmidt 166 | 167 | =head1 COPYRIGHT AND LICENSE 168 | 169 | This software is copyright (c) 2016 by Arthur Axel "fREW" Schmidt. 170 | 171 | This is free software; you can redistribute it and/or modify it under 172 | the same terms as the Perl 5 programming language system itself. 173 | 174 | =cut 175 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Coercion/FromMoose.pm: -------------------------------------------------------------------------------- 1 | package Type::Coercion::FromMoose; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Coercion::FromMoose::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Coercion::FromMoose::VERSION = '1.000005'; 10 | } 11 | 12 | use Scalar::Util qw< blessed >; 13 | use Types::TypeTiny (); 14 | 15 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 16 | 17 | require Type::Coercion; 18 | our @ISA = 'Type::Coercion'; 19 | 20 | sub type_coercion_map 21 | { 22 | my $self = shift; 23 | 24 | my @from; 25 | if ($self->type_constraint) 26 | { 27 | my $moose = $self->type_constraint->{moose_type}; 28 | @from = @{ $moose->coercion->type_coercion_map } if $moose && $moose->has_coercion; 29 | } 30 | else 31 | { 32 | _croak "The type constraint attached to this coercion has been garbage collected... PANIC"; 33 | } 34 | 35 | my @return; 36 | while (@from) 37 | { 38 | my ($type, $code) = splice(@from, 0, 2); 39 | $type = Moose::Util::TypeConstraints::find_type_constraint($type) 40 | unless ref $type; 41 | push @return, Types::TypeTiny::to_TypeTiny($type), $code; 42 | } 43 | 44 | return \@return; 45 | } 46 | 47 | sub add_type_coercions 48 | { 49 | my $self = shift; 50 | _croak "Adding coercions to Type::Coercion::FromMoose not currently supported" if @_; 51 | } 52 | 53 | sub _build_moose_coercion 54 | { 55 | my $self = shift; 56 | 57 | if ($self->type_constraint) 58 | { 59 | my $moose = $self->type_constraint->{moose_type}; 60 | return $moose->coercion if $moose && $moose->has_coercion; 61 | } 62 | 63 | $self->SUPER::_build_moose_coercion(@_); 64 | } 65 | 66 | sub can_be_inlined 67 | { 68 | 0; 69 | } 70 | 71 | 1; 72 | 73 | __END__ 74 | 75 | =pod 76 | 77 | =encoding utf-8 78 | 79 | =head1 NAME 80 | 81 | Type::Coercion::FromMoose - a set of coercions borrowed from Moose 82 | 83 | =head1 STATUS 84 | 85 | This module is considered part of Type-Tiny's internals. It is not 86 | covered by the 87 | L. 88 | 89 | =head1 DESCRIPTION 90 | 91 | This package inherits from L; see that for most documentation. 92 | The major differences are that C always throws an 93 | exception, and the C is automatically populated from 94 | Moose. 95 | 96 | This is mostly for internal purposes. 97 | 98 | =head1 BUGS 99 | 100 | Please report any bugs to 101 | L. 102 | 103 | =head1 SEE ALSO 104 | 105 | L. 106 | 107 | L. 108 | 109 | =head1 AUTHOR 110 | 111 | Toby Inkster Etobyink@cpan.orgE. 112 | 113 | =head1 COPYRIGHT AND LICENCE 114 | 115 | This software is copyright (c) 2013-2014 by Toby Inkster. 116 | 117 | This is free software; you can redistribute it and/or modify it under 118 | the same terms as the Perl 5 programming language system itself. 119 | 120 | =head1 DISCLAIMER OF WARRANTIES 121 | 122 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 123 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 124 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 125 | 126 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Coercion/Union.pm: -------------------------------------------------------------------------------- 1 | package Type::Coercion::Union; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Coercion::Union::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Coercion::Union::VERSION = '1.000005'; 10 | } 11 | 12 | use Scalar::Util qw< blessed >; 13 | use Types::TypeTiny (); 14 | 15 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 16 | 17 | require Type::Coercion; 18 | our @ISA = 'Type::Coercion'; 19 | 20 | sub _preserve_type_constraint 21 | { 22 | my $self = shift; 23 | $self->{_union_of} = $self->{type_constraint}->type_constraints 24 | if $self->{type_constraint}; 25 | } 26 | 27 | sub _maybe_restore_type_constraint 28 | { 29 | my $self = shift; 30 | if ( my $union = $self->{_union_of} ) 31 | { 32 | return Type::Tiny::Union->new(type_constraints => $union); 33 | } 34 | return; 35 | } 36 | 37 | sub type_coercion_map 38 | { 39 | my $self = shift; 40 | 41 | Types::TypeTiny::TypeTiny->assert_valid(my $type = $self->type_constraint); 42 | $type->isa('Type::Tiny::Union') 43 | or _croak "Type::Coercion::Union must be used in conjunction with Type::Tiny::Union"; 44 | 45 | my @c; 46 | for my $tc (@$type) 47 | { 48 | next unless $tc->has_coercion; 49 | push @c, @{$tc->coercion->type_coercion_map}; 50 | } 51 | return \@c; 52 | } 53 | 54 | sub add_type_coercions 55 | { 56 | my $self = shift; 57 | _croak "Adding coercions to Type::Coercion::Union not currently supported" if @_; 58 | } 59 | 60 | sub _build_moose_coercion 61 | { 62 | my $self = shift; 63 | 64 | my %options = (); 65 | $options{type_constraint} = $self->type_constraint if $self->has_type_constraint; 66 | 67 | require Moose::Meta::TypeCoercion::Union; 68 | my $r = "Moose::Meta::TypeCoercion::Union"->new(%options); 69 | 70 | return $r; 71 | } 72 | 73 | sub can_be_inlined 74 | { 75 | my $self = shift; 76 | 77 | Types::TypeTiny::TypeTiny->assert_valid(my $type = $self->type_constraint); 78 | 79 | for my $tc (@$type) 80 | { 81 | next unless $tc->has_coercion; 82 | return !!0 unless $tc->coercion->can_be_inlined; 83 | } 84 | 85 | !!1; 86 | } 87 | 88 | 1; 89 | 90 | __END__ 91 | 92 | =pod 93 | 94 | =encoding utf-8 95 | 96 | =head1 NAME 97 | 98 | Type::Coercion::Union - a set of coercions to a union type constraint 99 | 100 | =head1 STATUS 101 | 102 | This module is covered by the 103 | L. 104 | 105 | =head1 DESCRIPTION 106 | 107 | This package inherits from L; see that for most documentation. 108 | The major differences are that C always throws an 109 | exception, and the C is automatically populated from 110 | the child constraints of the union type constraint. 111 | 112 | =head1 BUGS 113 | 114 | Please report any bugs to 115 | L. 116 | 117 | =head1 SEE ALSO 118 | 119 | L. 120 | 121 | L. 122 | 123 | =head1 AUTHOR 124 | 125 | Toby Inkster Etobyink@cpan.orgE. 126 | 127 | =head1 COPYRIGHT AND LICENCE 128 | 129 | This software is copyright (c) 2013-2014 by Toby Inkster. 130 | 131 | This is free software; you can redistribute it and/or modify it under 132 | the same terms as the Perl 5 programming language system itself. 133 | 134 | =head1 DISCLAIMER OF WARRANTIES 135 | 136 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 137 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 138 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 139 | 140 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Duck.pm: -------------------------------------------------------------------------------- 1 | package Type::Tiny::Duck; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Tiny::Duck::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Tiny::Duck::VERSION = '1.000005'; 10 | } 11 | 12 | use Scalar::Util qw< blessed >; 13 | 14 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 15 | 16 | use Type::Tiny (); 17 | our @ISA = 'Type::Tiny'; 18 | 19 | sub new { 20 | my $proto = shift; 21 | 22 | my %opts = (@_==1) ? %{$_[0]} : @_; 23 | _croak "Duck type constraints cannot have a parent constraint passed to the constructor" if exists $opts{parent}; 24 | _croak "Duck type constraints cannot have a constraint coderef passed to the constructor" if exists $opts{constraint}; 25 | _croak "Duck type constraints cannot have a inlining coderef passed to the constructor" if exists $opts{inlined}; 26 | _croak "Need to supply list of methods" unless exists $opts{methods}; 27 | 28 | $opts{methods} = [$opts{methods}] unless ref $opts{methods}; 29 | 30 | if (Type::Tiny::_USE_XS) 31 | { 32 | my $methods = join ",", sort(@{$opts{methods}}); 33 | my $xsub = Type::Tiny::XS::get_coderef_for("HasMethods[$methods]"); 34 | $opts{compiled_type_constraint} = $xsub if $xsub; 35 | } 36 | elsif (Type::Tiny::_USE_MOUSE) 37 | { 38 | require Mouse::Util::TypeConstraints; 39 | my $maker = "Mouse::Util::TypeConstraints"->can("generate_can_predicate_for"); 40 | $opts{compiled_type_constraint} = $maker->($opts{methods}) if $maker; 41 | } 42 | 43 | return $proto->SUPER::new(%opts); 44 | } 45 | 46 | sub methods { $_[0]{methods} } 47 | sub inlined { $_[0]{inlined} ||= $_[0]->_build_inlined } 48 | 49 | sub has_inlined { !!1 } 50 | 51 | sub _build_constraint 52 | { 53 | my $self = shift; 54 | my @methods = @{$self->methods}; 55 | return sub { blessed($_[0]) and not grep(!$_[0]->can($_), @methods) }; 56 | } 57 | 58 | sub _build_inlined 59 | { 60 | my $self = shift; 61 | my @methods = @{$self->methods}; 62 | 63 | if (Type::Tiny::_USE_XS) 64 | { 65 | my $methods = join ",", sort(@{$self->methods}); 66 | my $xsub = Type::Tiny::XS::get_subname_for("HasMethods[$methods]"); 67 | return sub { my $var = $_[1]; "$xsub\($var\)" } if $xsub; 68 | } 69 | 70 | sub { 71 | my $var = $_[1]; 72 | local $" = q{ }; 73 | # If $var is $_ or $_->{foo} or $foo{$_} or somesuch, then we 74 | # can't use it within the grep expression, so we need to save 75 | # it into a temporary variable ($tmp). 76 | ($var =~ /\$_/) 77 | ? qq{ Scalar::Util::blessed($var) and not do { my \$tmp = $var; grep(!\$tmp->can(\$_), qw/@methods/) } } 78 | : qq{ Scalar::Util::blessed($var) and not grep(!$var->can(\$_), qw/@methods/) }; 79 | }; 80 | } 81 | 82 | sub _instantiate_moose_type 83 | { 84 | my $self = shift; 85 | my %opts = @_; 86 | delete $opts{parent}; 87 | delete $opts{constraint}; 88 | delete $opts{inlined}; 89 | 90 | require Moose::Meta::TypeConstraint::DuckType; 91 | return "Moose::Meta::TypeConstraint::DuckType"->new(%opts, methods => $self->methods); 92 | } 93 | 94 | sub has_parent 95 | { 96 | !!1; 97 | } 98 | 99 | sub parent 100 | { 101 | require Types::Standard; 102 | Types::Standard::Object(); 103 | } 104 | 105 | sub validate_explain 106 | { 107 | my $self = shift; 108 | my ($value, $varname) = @_; 109 | $varname = '$_' unless defined $varname; 110 | 111 | return undef if $self->check($value); 112 | return ["Not a blessed reference"] unless blessed($value); 113 | 114 | require Type::Utils; 115 | return [ 116 | sprintf( 117 | '"%s" requires that the reference can %s', 118 | $self, 119 | Type::Utils::english_list(map qq["$_"], @{$self->methods}), 120 | ), 121 | map sprintf('The reference cannot "%s"', $_), 122 | grep !$value->can($_), 123 | @{$self->methods} 124 | ]; 125 | } 126 | 127 | 1; 128 | 129 | __END__ 130 | 131 | =pod 132 | 133 | =encoding utf-8 134 | 135 | =head1 NAME 136 | 137 | Type::Tiny::Duck - type constraints based on the "can" method 138 | 139 | =head1 STATUS 140 | 141 | This module is covered by the 142 | L. 143 | 144 | =head1 DESCRIPTION 145 | 146 | Type constraints of the general form C<< { $_->can("method") } >>. 147 | 148 | This package inherits from L; see that for most documentation. 149 | Major differences are listed below: 150 | 151 | =head2 Attributes 152 | 153 | =over 154 | 155 | =item C 156 | 157 | An arrayref of method names. 158 | 159 | =item C 160 | 161 | Unlike Type::Tiny, you I pass a constraint coderef to the constructor. 162 | Instead rely on the default. 163 | 164 | =item C 165 | 166 | Unlike Type::Tiny, you I pass an inlining coderef to the constructor. 167 | Instead rely on the default. 168 | 169 | =item C 170 | 171 | Parent is always Types::Standard::Object, and cannot be passed to the 172 | constructor. 173 | 174 | =back 175 | 176 | =head1 BUGS 177 | 178 | Please report any bugs to 179 | L. 180 | 181 | =head1 SEE ALSO 182 | 183 | L. 184 | 185 | L. 186 | 187 | L. 188 | 189 | =head1 AUTHOR 190 | 191 | Toby Inkster Etobyink@cpan.orgE. 192 | 193 | =head1 COPYRIGHT AND LICENCE 194 | 195 | This software is copyright (c) 2013-2014 by Toby Inkster. 196 | 197 | This is free software; you can redistribute it and/or modify it under 198 | the same terms as the Perl 5 programming language system itself. 199 | 200 | =head1 DISCLAIMER OF WARRANTIES 201 | 202 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 203 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 204 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 205 | 206 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Enum.pm: -------------------------------------------------------------------------------- 1 | package Type::Tiny::Enum; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Tiny::Enum::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Tiny::Enum::VERSION = '1.000005'; 10 | } 11 | 12 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 13 | 14 | use overload q[@{}] => 'values'; 15 | 16 | use Type::Tiny (); 17 | our @ISA = 'Type::Tiny'; 18 | 19 | sub new 20 | { 21 | my $proto = shift; 22 | 23 | my %opts = (@_==1) ? %{$_[0]} : @_; 24 | _croak "Enum type constraints cannot have a parent constraint passed to the constructor" if exists $opts{parent}; 25 | _croak "Enum type constraints cannot have a constraint coderef passed to the constructor" if exists $opts{constraint}; 26 | _croak "Enum type constraints cannot have a inlining coderef passed to the constructor" if exists $opts{inlined}; 27 | _croak "Need to supply list of values" unless exists $opts{values}; 28 | 29 | my %tmp = 30 | map { $_ => 1 } 31 | @{ ref $opts{values} eq "ARRAY" ? $opts{values} : [$opts{values}] }; 32 | $opts{values} = [sort keys %tmp]; 33 | 34 | if (Type::Tiny::_USE_XS and not grep /[^-\w]/, @{$opts{values}}) 35 | { 36 | my $enum = join ",", @{$opts{values}}; 37 | my $xsub = Type::Tiny::XS::get_coderef_for("Enum[$enum]"); 38 | $opts{compiled_type_constraint} = $xsub if $xsub; 39 | } 40 | 41 | return $proto->SUPER::new(%opts); 42 | } 43 | 44 | sub values { $_[0]{values} } 45 | sub constraint { $_[0]{constraint} ||= $_[0]->_build_constraint } 46 | 47 | sub _build_display_name 48 | { 49 | my $self = shift; 50 | sprintf("Enum[%s]", join q[,], @$self); 51 | } 52 | 53 | sub _build_constraint 54 | { 55 | my $self = shift; 56 | 57 | my $regexp = join "|", map quotemeta, @$self; 58 | return sub { defined and m{\A(?:$regexp)\z} }; 59 | } 60 | 61 | sub can_be_inlined 62 | { 63 | !!1; 64 | } 65 | 66 | sub inline_check 67 | { 68 | my $self = shift; 69 | 70 | if (Type::Tiny::_USE_XS) 71 | { 72 | my $enum = join ",", @{$self->values}; 73 | my $xsub = Type::Tiny::XS::get_subname_for("Enum[$enum]"); 74 | return "$xsub\($_[0]\)" if $xsub; 75 | } 76 | 77 | my $regexp = join "|", map quotemeta, @$self; 78 | $_[0] eq '$_' 79 | ? "(defined and !ref and m{\\A(?:$regexp)\\z})" 80 | : "(defined($_[0]) and !ref($_[0]) and $_[0] =~ m{\\A(?:$regexp)\\z})"; 81 | } 82 | 83 | sub _instantiate_moose_type 84 | { 85 | my $self = shift; 86 | my %opts = @_; 87 | delete $opts{parent}; 88 | delete $opts{constraint}; 89 | delete $opts{inlined}; 90 | require Moose::Meta::TypeConstraint::Enum; 91 | return "Moose::Meta::TypeConstraint::Enum"->new(%opts, values => $self->values); 92 | } 93 | 94 | sub has_parent 95 | { 96 | !!1; 97 | } 98 | 99 | sub parent 100 | { 101 | require Types::Standard; 102 | Types::Standard::Str(); 103 | } 104 | 105 | sub validate_explain 106 | { 107 | my $self = shift; 108 | my ($value, $varname) = @_; 109 | $varname = '$_' unless defined $varname; 110 | 111 | return undef if $self->check($value); 112 | 113 | require Type::Utils; 114 | !defined($value) ? [ 115 | sprintf( 116 | '"%s" requires that the value is defined', 117 | $self, 118 | ), 119 | ] : 120 | @$self < 13 ? [ 121 | sprintf( 122 | '"%s" requires that the value is equal to %s', 123 | $self, 124 | Type::Utils::english_list(\"or", map B::perlstring($_), @$self), 125 | ), 126 | ] : 127 | [ 128 | sprintf( 129 | '"%s" requires that the value is one of an enumerated list of strings', 130 | $self, 131 | ), 132 | ]; 133 | } 134 | 135 | 136 | 1; 137 | 138 | __END__ 139 | 140 | =pod 141 | 142 | =encoding utf-8 143 | 144 | =head1 NAME 145 | 146 | Type::Tiny::Enum - string enum type constraints 147 | 148 | =head1 STATUS 149 | 150 | This module is covered by the 151 | L. 152 | 153 | =head1 DESCRIPTION 154 | 155 | Enum type constraints. 156 | 157 | This package inherits from L; see that for most documentation. 158 | Major differences are listed below: 159 | 160 | =head2 Attributes 161 | 162 | =over 163 | 164 | =item C 165 | 166 | Arrayref of allowable value strings. Non-string values (e.g. objects with 167 | overloading) will be stringified in the constructor. 168 | 169 | =item C 170 | 171 | Unlike Type::Tiny, you I pass a constraint coderef to the constructor. 172 | Instead rely on the default. 173 | 174 | =item C 175 | 176 | Unlike Type::Tiny, you I pass an inlining coderef to the constructor. 177 | Instead rely on the default. 178 | 179 | =item C 180 | 181 | Parent is always Types::Standard::Str, and cannot be passed to the 182 | constructor. 183 | 184 | =back 185 | 186 | =head2 Overloading 187 | 188 | =over 189 | 190 | =item * 191 | 192 | Arrayrefification calls C. 193 | 194 | =back 195 | 196 | =head1 BUGS 197 | 198 | Please report any bugs to 199 | L. 200 | 201 | =head1 SEE ALSO 202 | 203 | L. 204 | 205 | L. 206 | 207 | L. 208 | 209 | =head1 AUTHOR 210 | 211 | Toby Inkster Etobyink@cpan.orgE. 212 | 213 | =head1 COPYRIGHT AND LICENCE 214 | 215 | This software is copyright (c) 2013-2014 by Toby Inkster. 216 | 217 | This is free software; you can redistribute it and/or modify it under 218 | the same terms as the Perl 5 programming language system itself. 219 | 220 | =head1 DISCLAIMER OF WARRANTIES 221 | 222 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 223 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 224 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 225 | 226 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Intersection.pm: -------------------------------------------------------------------------------- 1 | package Type::Tiny::Intersection; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Tiny::Intersection::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Tiny::Intersection::VERSION = '1.000005'; 10 | } 11 | 12 | use Scalar::Util qw< blessed >; 13 | use Types::TypeTiny (); 14 | 15 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 16 | 17 | use overload q[@{}] => sub { $_[0]{type_constraints} ||= [] }; 18 | 19 | use Type::Tiny (); 20 | our @ISA = 'Type::Tiny'; 21 | 22 | sub new { 23 | my $proto = shift; 24 | 25 | my %opts = (@_==1) ? %{$_[0]} : @_; 26 | _croak "Intersection type constraints cannot have a parent constraint" if exists $opts{parent}; 27 | _croak "Intersection type constraints cannot have a constraint coderef passed to the constructor" if exists $opts{constraint}; 28 | _croak "Intersection type constraints cannot have a inlining coderef passed to the constructor" if exists $opts{inlined}; 29 | _croak "Need to supply list of type constraints" unless exists $opts{type_constraints}; 30 | 31 | $opts{type_constraints} = [ 32 | map { $_->isa(__PACKAGE__) ? @$_ : $_ } 33 | map Types::TypeTiny::to_TypeTiny($_), 34 | @{ ref $opts{type_constraints} eq "ARRAY" ? $opts{type_constraints} : [$opts{type_constraints}] } 35 | ]; 36 | 37 | if (Type::Tiny::_USE_XS) 38 | { 39 | my @constraints = @{$opts{type_constraints}}; 40 | my @known = map { 41 | my $known = Type::Tiny::XS::is_known($_->compiled_check); 42 | defined($known) ? $known : (); 43 | } @constraints; 44 | 45 | if (@known == @constraints) 46 | { 47 | my $xsub = Type::Tiny::XS::get_coderef_for( 48 | sprintf "AllOf[%s]", join(',', @known) 49 | ); 50 | $opts{compiled_type_constraint} = $xsub if $xsub; 51 | } 52 | } 53 | 54 | return $proto->SUPER::new(%opts); 55 | } 56 | 57 | sub type_constraints { $_[0]{type_constraints} } 58 | sub constraint { $_[0]{constraint} ||= $_[0]->_build_constraint } 59 | 60 | sub _build_display_name 61 | { 62 | my $self = shift; 63 | join q[&], @$self; 64 | } 65 | 66 | sub _build_constraint 67 | { 68 | my @checks = map $_->compiled_check, @{+shift}; 69 | return sub 70 | { 71 | my $val = $_; 72 | $_->($val) || return for @checks; 73 | return !!1; 74 | } 75 | } 76 | 77 | sub can_be_inlined 78 | { 79 | my $self = shift; 80 | not grep !$_->can_be_inlined, @$self; 81 | } 82 | 83 | sub inline_check 84 | { 85 | my $self = shift; 86 | 87 | if (Type::Tiny::_USE_XS and !exists $self->{xs_sub}) 88 | { 89 | $self->{xs_sub} = undef; 90 | 91 | my @constraints = @{$self->type_constraints}; 92 | my @known = map { 93 | my $known = Type::Tiny::XS::is_known($_->compiled_check); 94 | defined($known) ? $known : (); 95 | } @constraints; 96 | 97 | if (@known == @constraints) 98 | { 99 | $self->{xs_sub} = Type::Tiny::XS::get_subname_for( 100 | sprintf "AllOf[%s]", join(',', @known) 101 | ); 102 | } 103 | } 104 | 105 | if (Type::Tiny::_USE_XS and $self->{xs_sub}) { 106 | return "$self->{xs_sub}\($_[0]\)"; 107 | } 108 | 109 | sprintf '(%s)', join " and ", map $_->inline_check($_[0]), @$self; 110 | } 111 | 112 | sub has_parent 113 | { 114 | !!@{ $_[0]{type_constraints} }; 115 | } 116 | 117 | sub parent 118 | { 119 | $_[0]{type_constraints}[0]; 120 | } 121 | 122 | sub validate_explain 123 | { 124 | my $self = shift; 125 | my ($value, $varname) = @_; 126 | $varname = '$_' unless defined $varname; 127 | 128 | return undef if $self->check($value); 129 | 130 | require Type::Utils; 131 | for my $type (@$self) 132 | { 133 | my $deep = $type->validate_explain($value, $varname); 134 | return [ 135 | sprintf( 136 | '"%s" requires that the value pass %s', 137 | $self, 138 | Type::Utils::english_list(map qq["$_"], @$self), 139 | ), 140 | @$deep, 141 | ] if $deep; 142 | } 143 | 144 | # This should never happen... 145 | return; # uncoverable statement 146 | } 147 | 148 | 149 | 1; 150 | 151 | __END__ 152 | 153 | =pod 154 | 155 | =encoding utf-8 156 | 157 | =head1 NAME 158 | 159 | Type::Tiny::Intersection - intersection type constraints 160 | 161 | =head1 STATUS 162 | 163 | This module is covered by the 164 | L. 165 | 166 | =head1 DESCRIPTION 167 | 168 | Intersection type constraints. 169 | 170 | This package inherits from L; see that for most documentation. 171 | Major differences are listed below: 172 | 173 | =head2 Attributes 174 | 175 | =over 176 | 177 | =item C 178 | 179 | Arrayref of type constraints. 180 | 181 | When passed to the constructor, if any of the type constraints in the 182 | intersection is itself an intersection type constraint, this is "exploded" 183 | into the new intersection. 184 | 185 | =item C 186 | 187 | Unlike Type::Tiny, you I pass a constraint coderef to the constructor. 188 | Instead rely on the default. 189 | 190 | =item C 191 | 192 | Unlike Type::Tiny, you I pass an inlining coderef to the constructor. 193 | Instead rely on the default. 194 | 195 | =item C 196 | 197 | Unlike Type::Tiny, you I pass an inlining coderef to the constructor. 198 | A parent will instead be automatically calculated. 199 | 200 | (Technically any of the types in the intersection could be treated as a 201 | parent type; we choose the first arbitrarily.) 202 | 203 | =back 204 | 205 | =head2 Overloading 206 | 207 | =over 208 | 209 | =item * 210 | 211 | Arrayrefification calls C. 212 | 213 | =back 214 | 215 | =head1 BUGS 216 | 217 | Please report any bugs to 218 | L. 219 | 220 | =head1 SEE ALSO 221 | 222 | L. 223 | 224 | L. 225 | 226 | L. 227 | 228 | =head1 AUTHOR 229 | 230 | Toby Inkster Etobyink@cpan.orgE. 231 | 232 | =head1 COPYRIGHT AND LICENCE 233 | 234 | This software is copyright (c) 2013-2014 by Toby Inkster. 235 | 236 | This is free software; you can redistribute it and/or modify it under 237 | the same terms as the Perl 5 programming language system itself. 238 | 239 | =head1 DISCLAIMER OF WARRANTIES 240 | 241 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 242 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 243 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 244 | 245 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/Params.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =head1 NAME 6 | 7 | Type::Tiny::Manual::Params - coerce and validate arguments to functions and methods 8 | 9 | =head1 DESCRIPTION 10 | 11 | There is a module called L available to wrap up type coercion 12 | and constraint checks into a single, simple and fast check. If you care 13 | about speed, and your sub signatures are fairly simple, then this is the way 14 | to go... 15 | 16 | use feature qw( state ); 17 | use Types::Standard qw( Str ); 18 | use Type::Utils; 19 | use Type::Params qw( compile ); 20 | 21 | my $Invocant = class_type { class => __PACKAGE__ }; 22 | 23 | sub set_name 24 | { 25 | state $check = compile($Invocant, Str); 26 | my ($self, $name) = $check->(@_); 27 | 28 | ...; 29 | } 30 | 31 | See the COOKBOOK section of L for further information. 32 | 33 | =head2 The Somewhat More Manual Way... 34 | 35 | In general, Type::Params should be sufficient to cover most needs, and 36 | will probably run faster than almost anything you could cook up yourself. 37 | However, sometimes you need to deal with unusual function signatures that 38 | it does not support. For example, imagine function C<< format_string >> 39 | takes an optional hashref of formatting instructions, followed by a 40 | required string. You might expect to be able to handle it like this: 41 | 42 | sub format_string 43 | { 44 | state $check = compile(Optional[HashRef], Str); 45 | my ($instructions, $string) = $check->(@_); 46 | 47 | ...; 48 | } 49 | 50 | However, this won't work, as Type::Params expects required parameters to 51 | always precede optional ones. So there are times you need to handle 52 | parameters more manually. 53 | 54 | In these cases, bear in mind that for any type constraint object you 55 | have several useful checking methods available: 56 | 57 | Str->check($var) # returns a boolean 58 | is_Str($var) # ditto 59 | Str->($var) # returns $var or dies 60 | assert_Str($var) # ditto 61 | 62 | Here's how you might handle the C function: 63 | 64 | sub format_string 65 | { 66 | my $instructions; 67 | $instructions = shift if HashRef->check($_[0]); 68 | 69 | my $string = Str->(shift); 70 | 71 | ...; 72 | } 73 | 74 | Alternatively, you could manipulate @_ before passing it to the compiled 75 | check: 76 | 77 | sub format_string 78 | { 79 | state $check = compile(HashRef, Str); 80 | my ($instructions, $str) = $check->(@_==1 ? ({}, @_) : @_); 81 | 82 | ...; 83 | } 84 | 85 | =head2 Signatures 86 | 87 | Don't you wish your subs could look like this? 88 | 89 | sub set_name (Object $self, Str $name) 90 | { 91 | $self->{name} = $name; 92 | } 93 | 94 | Well; here are a few solutions for sub signatures that work with 95 | L... 96 | 97 | =head3 Kavorka 98 | 99 | L is a sub signatures implementation written to natively use 100 | L' C for type constraints, and take advantage 101 | of Type::Tiny's features such as inlining, and coercions. 102 | 103 | method set_name (Str $name) 104 | { 105 | $self->{name} = $name; 106 | } 107 | 108 | Kavorka's signatures provide a lot more flexibility, and slightly more 109 | speed than Type::Params. (The speed comes from inlining almost all type 110 | checks into the body of the sub being declared.) 111 | 112 | Kavorka also includes support for type checking of the returned value. 113 | 114 | Kavorka can also be used as part of L, a larger framework for 115 | object oriented programming in Perl. 116 | 117 | =head3 Function::Parameters 118 | 119 | The following should work with L 1.0201 or above: 120 | 121 | use Type::Utils; 122 | use Function::Parameters { 123 | method => { 124 | strict => 1, 125 | reify_type => sub { Type::Utils::dwim_type($_[0]) }, 126 | }, 127 | }; 128 | 129 | method set_name (Str $name) 130 | { 131 | $self->{name} = $name; 132 | } 133 | 134 | Note that by default, Function::Parameters uses Moose's type 135 | constraints. The C option above (introduced in 136 | Function::Parameters 1.0201) allows you to "divert" type constraint 137 | lookups. Using Type::Tiny constraints will gain you about a 7% 138 | speed-up in function signature checks. 139 | 140 | An alternative way to use Function::Parameter with Type::Tiny is to 141 | provide type constraint expressions in parentheses: 142 | 143 | use Types::Standard; 144 | use Function::Parameters ':strict'; 145 | 146 | method set_name ((Str) $name) 147 | { 148 | $self->{name} = $name; 149 | } 150 | 151 | =head3 Attribute::Contract 152 | 153 | Both Kavorka and Function::Parameters require a relatively recent 154 | version of Perl. L supports older versions by 155 | using a lot less magic. 156 | 157 | You want Attribute::Contract 0.03 or above. 158 | 159 | use Attribute::Contract -types => [qw/Object Str/]; 160 | 161 | sub set_name :ContractRequires(Object, Str) 162 | { 163 | my ($self, $name) = @_; 164 | $self->{name} = $name; 165 | } 166 | 167 | Attribute::Contract also includes support for type checking of the 168 | returned value. 169 | 170 | =head1 AUTHOR 171 | 172 | Toby Inkster Etobyink@cpan.orgE. 173 | 174 | =head1 COPYRIGHT AND LICENCE 175 | 176 | This software is copyright (c) 2013-2014 by Toby Inkster. 177 | 178 | This is free software; you can redistribute it and/or modify it under 179 | the same terms as the Perl 5 programming language system itself. 180 | 181 | =head1 DISCLAIMER OF WARRANTIES 182 | 183 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 184 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 185 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 186 | 187 | =cut 188 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/Policies.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =for stopwords versioning 6 | 7 | =head1 NAME 8 | 9 | Type::Tiny::Manual::Policies - Type::Tiny policies 10 | 11 | =head1 STABILITY 12 | 13 | =head2 Type::Tiny Stability Policy 14 | 15 | Type::Tiny 1.000000 is considered stable. Any changes to the API that 16 | are big enough to I changes to the test suite will be preceded 17 | by a I<< six month >> notice period, with the following exceptions: 18 | 19 | =over 20 | 21 | =item * 22 | 23 | Any changes which are necessary to maintain compatibility with new 24 | releases of L, L, and other software that Type::Tiny needs 25 | to integrate with. 26 | 27 | =item * 28 | 29 | Changes to maintain compatibility with future versions of Perl itself. 30 | 31 | =item * 32 | 33 | Where a change fixes a contradiction between the implementation and 34 | documentation of Type::Tiny. 35 | 36 | =item * 37 | 38 | Where a feature is explicitly documented as being "experimental" or 39 | "unstable". 40 | 41 | =item * 42 | 43 | Improvements to the text of error messages. 44 | 45 | =back 46 | 47 | =head2 Experimental and Unstable Type::Tiny Features 48 | 49 | The following list is currently non-exhaustive. 50 | 51 | =over 52 | 53 | =item * 54 | 55 | L inlining subs (i.e. C) may return a list of 56 | strings (with C being allowed as the first item on the list). 57 | This is experimental. See L. 58 | 59 | =item * 60 | 61 | L's C attribute and the functionality it 62 | provides is experimental. 63 | 64 | =item * 65 | 66 | The L is subject to change. 67 | 68 | =item * 69 | 70 | The interaction of deep coercions and mutable coercions currently results 71 | in ill-defined behaviour. This could change at any time. 72 | (See L.) 73 | 74 | =item * 75 | 76 | L's ability to import L and L 77 | type libraries is experimental. 78 | 79 | =item * 80 | 81 | Integration with L. 82 | 83 | =item * 84 | 85 | These modules are considered part of Type::Tiny's internals, and not 86 | covered by the stability policy: 87 | L, 88 | L, 89 | L, 90 | L, 91 | L, 92 | L, 93 | L, 94 | L, 95 | L, 96 | L, and 97 | L. 98 | 99 | =item * 100 | 101 | L is not covered by the stability policy. 102 | 103 | =back 104 | 105 | =head2 Type::Tiny Versioning Policy 106 | 107 | As of 1.000000, this distribution follows a versioning scheme similar 108 | to L, which is based on a L-like three 109 | component version number, but with the last two components each 110 | represented by three decimal digits in the fractional part of the 111 | version number. That is, version 1.003002 of the software represents 112 | "1.3.2". 113 | 114 | Additionally, releases where the second component is an odd number will 115 | be considered unstable/trial releases. (These will also include an 116 | underscore in the version number as per the usual CPAN convention.) 117 | 118 | =head1 BUGS 119 | 120 | Please report any bugs to 121 | L. 122 | 123 | =head1 AUTHOR 124 | 125 | Toby Inkster Etobyink@cpan.orgE. 126 | 127 | =head1 COPYRIGHT AND LICENCE 128 | 129 | This software is copyright (c) 2013-2014 by Toby Inkster. 130 | 131 | This is free software; you can redistribute it and/or modify it under 132 | the same terms as the Perl 5 programming language system itself. 133 | 134 | =head1 DISCLAIMER OF WARRANTIES 135 | 136 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 137 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 138 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 139 | 140 | =cut 141 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/UsingWithMoo.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =head1 NAME 6 | 7 | Type::Tiny::Manual::UsingWithMoo - how to use Type::Tiny and Type::Library with Moo 8 | 9 | =head1 SYNOPSIS 10 | 11 | { 12 | package Person; 13 | 14 | use Moo; 15 | use Types::Standard qw( Str Int ); 16 | use Type::Utils qw( declare as where inline_as coerce from ); 17 | 18 | has name => ( 19 | is => "ro", 20 | isa => Str, 21 | ); 22 | 23 | my $PositiveInt = declare 24 | as Int, 25 | where { $_ > 0 }, 26 | inline_as { "$_ =~ /^[0-9]+\$/ and $_ > 0" }; 27 | 28 | coerce $PositiveInt, from Int, q{ abs $_ }; 29 | 30 | has age => ( 31 | is => "rwp", 32 | isa => $PositiveInt, 33 | coerce => $PositiveInt->coercion, 34 | ); 35 | 36 | sub get_older { 37 | my $self = shift; 38 | my ($years) = @_; 39 | $PositiveInt->assert_valid($years); 40 | $self->_set_age($self->age + $years); 41 | } 42 | } 43 | 44 | =head1 DESCRIPTION 45 | 46 | Type::Tiny is tested with L 1.001000 and above. 47 | 48 | Type::Tiny overloads C<< &{} >>. Moo supports using objects that overload 49 | C<< &{} >> as C constraints, so Type::Tiny objects can directly be used 50 | in C. 51 | 52 | Moo doesn't support C<< coerce => 1 >> but requires a coderef as a coercion. 53 | However, again it supports using objects that overload C<< &{} >>, which 54 | Type::Coercion does, allowing C<< coerce => $Type->coercion >> to work. 55 | 56 | Type::Tiny hooks into Moo's HandleMoose interface to ensure that type 57 | constraints get inflated to Moose type constraints if and when Moo inflates 58 | your class to a full Moose class. 59 | 60 | =head2 Optimization 61 | 62 | The usual advice for optimizing type constraints applies: use type constraints 63 | which can be inlined whenever possible, and define coercions as strings rather 64 | than coderefs. 65 | 66 | Upgrading to Moo 1.002000 or above should provide a slight increase in speed 67 | for type constraints, as it allows them to be inlined into accessors and 68 | constructors. 69 | 70 | If creating your own type constraints using C<< Type::Tiny->new >>, then 71 | consider using L to quote the coderef; this allows you to take 72 | advantage of inlining without having to write your own inlining routines. 73 | 74 | See also L. 75 | 76 | =head1 SEE ALSO 77 | 78 | For examples using Type::Tiny with L see the SYNOPSIS sections of 79 | L and L, and the 80 | L 81 | in the test suite. 82 | 83 | =head1 AUTHOR 84 | 85 | Toby Inkster Etobyink@cpan.orgE. 86 | 87 | =head1 COPYRIGHT AND LICENCE 88 | 89 | This software is copyright (c) 2013-2014 by Toby Inkster. 90 | 91 | This is free software; you can redistribute it and/or modify it under 92 | the same terms as the Perl 5 programming language system itself. 93 | 94 | =head1 DISCLAIMER OF WARRANTIES 95 | 96 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 97 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 98 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 99 | 100 | =cut 101 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/UsingWithMoose.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =head1 NAME 6 | 7 | Type::Tiny::Manual::UsingWithMoose - how to use Type::Tiny and Type::Library with Moose 8 | 9 | =head1 SYNOPSIS 10 | 11 | { 12 | package Person; 13 | 14 | use Moose; 15 | use Types::Standard qw( Str Int ); 16 | use Type::Utils qw( declare as where inline_as coerce from ); 17 | 18 | has name => ( 19 | is => "ro", 20 | isa => Str, 21 | ); 22 | 23 | my $PositiveInt = declare 24 | as Int, 25 | where { $_ > 0 }, 26 | inline_as { "$_ =~ /^[0-9]+\$/ and $_ > 0" }; 27 | 28 | coerce $PositiveInt, from Int, q{ abs $_ }; 29 | 30 | has age => ( 31 | is => "ro", 32 | isa => $PositiveInt, 33 | coerce => 1, 34 | writer => "_set_age", 35 | ); 36 | 37 | sub get_older { 38 | my $self = shift; 39 | my ($years) = @_; 40 | $PositiveInt->assert_valid($years); 41 | $self->_set_age($self->age + $years); 42 | } 43 | } 44 | 45 | =head1 DESCRIPTION 46 | 47 | L type constraints have an API almost identical to that of 48 | L. It is also able to build a 49 | Moose::Meta::TypeConstraint constraint from a Type::Tiny constraint, and 50 | will do so automatically when needed. When Moose.pm is loaded, Type::Tiny 51 | will use Perl's C feature to proxy method calls through to the 52 | Moose::Meta::TypeConstraint object. In short, you can use a Type::Tiny 53 | object pretty much anywhere you'd use a Moose::Meta::TypeConstraint and 54 | you are unlikely to notice the difference. 55 | 56 | =head2 Per-Attribute Coercions 57 | 58 | Type::Tiny offers convenience methods to alter the list of coercions 59 | associated with a type constraint. Let's imagine we wish to allow our 60 | C attribute to be coerced from an arrayref of strings. 61 | 62 | has name => ( 63 | is => "ro", 64 | isa => Str->plus_coercions( 65 | ArrayRef[Str], sub { join " ", @{$_} }, 66 | ), 67 | coerce => 1, 68 | ); 69 | 70 | This coercion will apply to the C attribute only; other attributes 71 | using the C type constraint will be unaffected. 72 | 73 | See the documentation for C, C and 74 | C in L. 75 | 76 | =head2 Optimization 77 | 78 | The usual advice for optimizing type constraints applies: use type constraints 79 | which can be inlined whenever possible. 80 | 81 | Defining coercions as strings rather than coderefs won't give you as much of 82 | a boost with Moose as it does with Moo, because Moose doesn't inline coercion 83 | code. However, it should still improve performance somewhat because it allows 84 | L to do some internal inlining. 85 | 86 | See also L. 87 | 88 | =head2 Interactions with MooseX-Types 89 | 90 | Type::Tiny and MooseX::Types type constraints should "play nice". If, for 91 | example, C is taken from L (i.e. a Type::Tiny-based 92 | type library), and C is taken from L, 93 | then the following should "just work": 94 | 95 | isa => ArrayRef[ PositiveInt ] 96 | 97 | isa => PositiveInt | ArrayRef 98 | 99 | =head1 SEE ALSO 100 | 101 | For examples using Type::Tiny with L see the SYNOPSIS sections of 102 | L and L, and the 103 | L, 104 | and 105 | L 106 | in the test suite. 107 | 108 | =head1 AUTHOR 109 | 110 | Toby Inkster Etobyink@cpan.orgE. 111 | 112 | =head1 COPYRIGHT AND LICENCE 113 | 114 | This software is copyright (c) 2013-2014 by Toby Inkster. 115 | 116 | This is free software; you can redistribute it and/or modify it under 117 | the same terms as the Perl 5 programming language system itself. 118 | 119 | =head1 DISCLAIMER OF WARRANTIES 120 | 121 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 122 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 123 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 124 | 125 | =cut 126 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/UsingWithMouse.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =head1 NAME 6 | 7 | Type::Tiny::Manual::UsingWithMouse - how to use Type::Tiny and Type::Library with Mouse 8 | 9 | =head1 SYNOPSIS 10 | 11 | { 12 | package Person; 13 | 14 | use Mouse; 15 | use Types::Standard qw( Str Int ); 16 | use Type::Utils qw( declare as where inline_as coerce from ); 17 | 18 | has name => ( 19 | is => "ro", 20 | isa => Str, 21 | ); 22 | 23 | my $PositiveInt = declare 24 | as Int, 25 | where { $_ > 0 }, 26 | inline_as { "$_ =~ /^[0-9]+\$/ and $_ > 0" }; 27 | 28 | coerce $PositiveInt, from Int, q{ abs $_ }; 29 | 30 | has age => ( 31 | is => "ro", 32 | isa => $PositiveInt, 33 | coerce => 1, 34 | writer => "_set_age", 35 | ); 36 | 37 | sub get_older { 38 | my $self = shift; 39 | my ($years) = @_; 40 | $PositiveInt->assert_valid($years); 41 | $self->_set_age($self->age + $years); 42 | } 43 | } 44 | 45 | =head1 STATUS 46 | 47 | L support in Type::Tiny was somewhat of an afterthought. It should 48 | work, but is not anywhere near as well-tested as L or L 49 | support. 50 | 51 | =head1 DESCRIPTION 52 | 53 | L type constraints have an API almost identical to that of 54 | L. As a result, you can use a Type::Tiny 55 | object pretty much anywhere you'd use a Mouse::Meta::TypeConstraint and 56 | you are unlikely to notice the difference. (And Mouse is unlikely to 57 | notice the difference too!) 58 | 59 | =head2 Per-Attribute Coercions 60 | 61 | Type::Tiny offers convenience methods to alter the list of coercions 62 | associated with a type constraint. Let's imagine we wish to allow our 63 | C attribute to be coerced from an arrayref of strings. 64 | 65 | has name => ( 66 | is => "ro", 67 | isa => Str->plus_coercions( 68 | ArrayRef[Str], sub { join " ", @{$_} }, 69 | ), 70 | coerce => 1, 71 | ); 72 | 73 | This coercion will apply to the C attribute only; other attributes 74 | using the C type constraint will be unaffected. 75 | 76 | See the documentation for C, C and 77 | C in L. 78 | 79 | =head2 Optimization 80 | 81 | Mouse's built-in type constraints are implemented using XS and are stupidly 82 | fast. For many type constraints, if Type::Tiny notices Mouse is loaded early 83 | enough, Type::Tiny will borrow Mouse's XS subs. 84 | 85 | See also L. 86 | 87 | =head2 Interactions with MouseX-Types 88 | 89 | Type::Tiny and MouseX::Types type constraints should "play nice". If, for 90 | example, C is taken from L (i.e. a Type::Tiny-based 91 | type library), and C is taken from L, 92 | then the following should "just work": 93 | 94 | isa => ArrayRef[ PositiveInt ] 95 | 96 | isa => PositiveInt | ArrayRef 97 | 98 | =head1 SEE ALSO 99 | 100 | For examples using Type::Tiny with L see the SYNOPSIS sections of 101 | L and L, and the 102 | L, 103 | and 104 | L 105 | in the test suite. 106 | 107 | =head1 AUTHOR 108 | 109 | Toby Inkster Etobyink@cpan.orgE. 110 | 111 | =head1 COPYRIGHT AND LICENCE 112 | 113 | This software is copyright (c) 2013-2014 by Toby Inkster. 114 | 115 | This is free software; you can redistribute it and/or modify it under 116 | the same terms as the Perl 5 programming language system itself. 117 | 118 | =head1 DISCLAIMER OF WARRANTIES 119 | 120 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 121 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 122 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 123 | 124 | =cut 125 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Manual/UsingWithOther.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =for stopwords inlinable 6 | 7 | =head1 NAME 8 | 9 | Type::Tiny::Manual::UsingWithOther - how to use Type::Tiny and Type::Library with other OO frameworks 10 | 11 | =head1 DESCRIPTION 12 | 13 | =head2 Class::InsideOut 14 | 15 | You want L 1.13 or above, which has support for blessed 16 | and overloaded objects (including Type::Tiny type constraints) for the 17 | C and C options. 18 | 19 | { 20 | package Person; 21 | 22 | use Class::InsideOut qw( public ); 23 | use Types::Standard qw( Str Int ); 24 | use Type::Utils qw( declare as where inline_as coerce from ); 25 | 26 | public name => my %_name, { 27 | set_hook => Str, 28 | }; 29 | 30 | my $PositiveInt = declare 31 | as Int, 32 | where { $_ > 0 }, 33 | inline_as { "$_ =~ /^[0-9]+\$/ and $_ > 0" }; 34 | 35 | coerce $PositiveInt, from Int, q{ abs $_ }; 36 | 37 | public age => my %_age, { 38 | set_hook => sub { $_ = $PositiveInt->assert_coerce($_) }, 39 | }; 40 | 41 | sub get_older { 42 | my $self = shift; 43 | my ($years) = @_; 44 | $PositiveInt->assert_valid($years); 45 | $self->_set_age($self->age + $years); 46 | } 47 | } 48 | 49 | I probably need to make coercions a little prettier. 50 | 51 | B<< See also: >> C<< t/25_accessor_hooks_typetiny.t >> and 52 | C<< t/Object/HookedTT.pm >> in the Class::InsideOut test suite; and the 53 | L 54 | in the Type::Tiny test suite. 55 | 56 | =head2 Params::Check and Object::Accessor 57 | 58 | The Params::Check C<< allow() >> function, the C option for the 59 | Params::Check C<< check() >> function, and the input validation mechanism 60 | for Object::Accessor all work in the same way, which is basically a 61 | limited pure-Perl implementation of the smart match operator. While this 62 | doesn't directly support Type::Tiny constraints, it does support coderefs. 63 | You can use Type::Tiny's C method to obtain a suitable 64 | coderef. 65 | 66 | B<< L example: >> 67 | 68 | my $tmpl = { 69 | name => { allow => Str->compiled_check }, 70 | age => { allow => Int->compiled_check }, 71 | }; 72 | check($tmpl, { name => "Bob", age => 32 }) 73 | or die Params::Check::last_error(); 74 | 75 | B<< L example: >> 76 | 77 | my $obj = Object::Accessor->new; 78 | $obj->mk_accessors( 79 | { name => Str->compiled_check }, 80 | { age => Int->compiled_check }, 81 | ); 82 | 83 | B<< Caveat: >> Object::Accessor doesn't die when a value fails to meet its 84 | type constraint; instead it outputs a warning to STDERR. This behaviour can 85 | be changed by setting C<< $Object::Accessor::FATAL = 1 >>. 86 | 87 | B<< See also: >> The 88 | L 89 | in the Type::Tiny test suite. 90 | 91 | =head2 Validation::Class::Simple 92 | 93 | You want L 7.900017 or above. 94 | 95 | The C function from L can be used to create 96 | a Type::Tiny type constraint from a Validation::Class::Simple object (and 97 | probably from Validation::Class, but this is untested). 98 | 99 | use Types::TypeTiny qw( to_TypeTiny ); 100 | use Validation::Class::Simple; 101 | 102 | my $type = to_TypeTiny Validation::Class::Simple->new( 103 | fields => { 104 | name => { 105 | required => 1, 106 | pattern => qr{^\w+(\s\w+)*$}, 107 | filters => ["trim", "strip"], 108 | }, 109 | email => { required => 1, email => 1 }, 110 | pass => { required => 1, min_length => 6 }, 111 | }, 112 | ); 113 | 114 | # true 115 | $type->check({ 116 | name => "Toby Inkster", 117 | email => "tobyink@cpan.org", 118 | pass => "foobar", 119 | }); 120 | 121 | # false 122 | $type->check({ 123 | name => "Toby Inkster ", # trailing whitespace 124 | email => "tobyink@cpan.org", 125 | pass => "foobar", 126 | }); 127 | 128 | # coercion from HashRef uses the filters defined above 129 | my $fixed = $type->coerce({ 130 | name => "Toby Inkster ", # trailing whitespace 131 | email => "tobyink@cpan.org", 132 | pass => "foobar", 133 | }); 134 | 135 | # true 136 | $type->check($fixed); 137 | 138 | Type constraints built with Validation::Class::Simple are not inlinable, so 139 | won't be as fast as C from L, but the filters are a 140 | pretty useful feature. (Note that filters are explicitly I for type 141 | constraint checking, and only come into play for coercion.) 142 | 143 | B<< See also: >> The 144 | L 145 | in the Type::Tiny test suite. 146 | 147 | =head1 AUTHOR 148 | 149 | Toby Inkster Etobyink@cpan.orgE. 150 | 151 | =head1 COPYRIGHT AND LICENCE 152 | 153 | This software is copyright (c) 2013-2014 by Toby Inkster. 154 | 155 | This is free software; you can redistribute it and/or modify it under 156 | the same terms as the Perl 5 programming language system itself. 157 | 158 | =head1 DISCLAIMER OF WARRANTIES 159 | 160 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 161 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 162 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 163 | 164 | =cut 165 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/Role.pm: -------------------------------------------------------------------------------- 1 | package Type::Tiny::Role; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Tiny::Role::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Tiny::Role::VERSION = '1.000005'; 10 | } 11 | 12 | use Scalar::Util qw< blessed weaken >; 13 | 14 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 15 | 16 | require Type::Tiny; 17 | our @ISA = 'Type::Tiny'; 18 | 19 | my %cache; 20 | 21 | sub new { 22 | my $proto = shift; 23 | 24 | my %opts = (@_==1) ? %{$_[0]} : @_; 25 | _croak "Role type constraints cannot have a parent constraint passed to the constructor" if exists $opts{parent}; 26 | _croak "Role type constraints cannot have a constraint coderef passed to the constructor" if exists $opts{constraint}; 27 | _croak "Role type constraints cannot have a inlining coderef passed to the constructor" if exists $opts{inlined}; 28 | _croak "Need to supply role name" unless exists $opts{role}; 29 | 30 | return $proto->SUPER::new(%opts); 31 | } 32 | 33 | sub role { $_[0]{role} } 34 | sub inlined { $_[0]{inlined} ||= $_[0]->_build_inlined } 35 | 36 | sub has_inlined { !!1 } 37 | 38 | sub _build_constraint 39 | { 40 | my $self = shift; 41 | my $role = $self->role; 42 | return sub { blessed($_) and do { my $method = $_->can('DOES')||$_->can('isa'); $_->$method($role) } }; 43 | } 44 | 45 | sub _build_inlined 46 | { 47 | my $self = shift; 48 | my $role = $self->role; 49 | sub { 50 | my $var = $_[1]; 51 | qq{Scalar::Util::blessed($var) and do { my \$method = $var->can('DOES')||$var->can('isa'); $var->\$method(q[$role]) }}; 52 | }; 53 | } 54 | 55 | sub _build_default_message 56 | { 57 | my $self = shift; 58 | my $c = $self->role; 59 | return sub { sprintf '%s did not pass type constraint (not DOES %s)', Type::Tiny::_dd($_[0]), $c } if $self->is_anon; 60 | my $name = "$self"; 61 | return sub { sprintf '%s did not pass type constraint "%s" (not DOES %s)', Type::Tiny::_dd($_[0]), $name, $c }; 62 | } 63 | 64 | sub has_parent 65 | { 66 | !!1; 67 | } 68 | 69 | sub parent 70 | { 71 | require Types::Standard; 72 | Types::Standard::Object(); 73 | } 74 | 75 | sub validate_explain 76 | { 77 | my $self = shift; 78 | my ($value, $varname) = @_; 79 | $varname = '$_' unless defined $varname; 80 | 81 | return undef if $self->check($value); 82 | return ["Not a blessed reference"] unless blessed($value); 83 | return ["Reference provides no DOES method to check roles"] unless $value->can('DOES'); 84 | 85 | my $display_var = $varname eq q{$_} ? '' : sprintf(' (in %s)', $varname); 86 | 87 | return [ 88 | sprintf('"%s" requires that the reference does %s', $self, $self->role), 89 | sprintf("The reference%s doesn't %s", $display_var, $self->role), 90 | ]; 91 | } 92 | 93 | 1; 94 | 95 | __END__ 96 | 97 | =pod 98 | 99 | =encoding utf-8 100 | 101 | =head1 NAME 102 | 103 | Type::Tiny::Role - type constraints based on the "DOES" method 104 | 105 | =head1 STATUS 106 | 107 | This module is covered by the 108 | L. 109 | 110 | =head1 DESCRIPTION 111 | 112 | Type constraints of the general form C<< { $_->DOES("Some::Role") } >>. 113 | 114 | This package inherits from L; see that for most documentation. 115 | Major differences are listed below: 116 | 117 | =head2 Attributes 118 | 119 | =over 120 | 121 | =item C 122 | 123 | The role for the constraint. 124 | 125 | Note that this package doesn't subscribe to any particular flavour of roles 126 | (L, L, L, L, etc). It simply 127 | trusts the object's C method (see L). 128 | 129 | =item C 130 | 131 | Unlike Type::Tiny, you I pass a constraint coderef to the constructor. 132 | Instead rely on the default. 133 | 134 | =item C 135 | 136 | Unlike Type::Tiny, you I pass an inlining coderef to the constructor. 137 | Instead rely on the default. 138 | 139 | =item C 140 | 141 | Parent is always Types::Standard::Object, and cannot be passed to the 142 | constructor. 143 | 144 | =back 145 | 146 | =head1 BUGS 147 | 148 | Please report any bugs to 149 | L. 150 | 151 | =head1 SEE ALSO 152 | 153 | L. 154 | 155 | L. 156 | 157 | L. 158 | 159 | =head1 AUTHOR 160 | 161 | Toby Inkster Etobyink@cpan.orgE. 162 | 163 | =head1 COPYRIGHT AND LICENCE 164 | 165 | This software is copyright (c) 2013-2014 by Toby Inkster. 166 | 167 | This is free software; you can redistribute it and/or modify it under 168 | the same terms as the Perl 5 programming language system itself. 169 | 170 | =head1 DISCLAIMER OF WARRANTIES 171 | 172 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 173 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 174 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 175 | 176 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Type/Tiny/_HalfOp.pm: -------------------------------------------------------------------------------- 1 | package Type::Tiny::_HalfOp; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Type::Tiny::_HalfOp::AUTHORITY = 'cpan:TOBYINK'; 9 | $Type::Tiny::_HalfOp::VERSION = '1.000005'; 10 | } 11 | 12 | use overload (); 13 | 14 | sub new { 15 | my ($class, $op, $param, $type) = @_; 16 | bless { 17 | op => $op, 18 | param => $param, 19 | type => $type, 20 | }, $class; 21 | } 22 | 23 | sub complete { 24 | my ($self, $type) = @_; 25 | my $complete_type = $type->parameterize(@{$self->{param}}); 26 | my $method = overload::Method($complete_type, $self->{op}); 27 | $complete_type->$method($self->{type}); 28 | } 29 | 30 | 1; 31 | 32 | __END__ 33 | 34 | =pod 35 | 36 | =encoding utf-8 37 | 38 | =for stopwords pragmas 39 | 40 | =head1 NAME 41 | 42 | Type::Tiny::_HalfOp - half-completed overloaded operation 43 | 44 | =head1 STATUS 45 | 46 | This module is considered part of Type-Tiny's internals. It is not 47 | covered by the 48 | L. 49 | 50 | =head1 DESCRIPTION 51 | 52 | This is not considered part of Type::Tiny's public API. 53 | 54 | It is a class representing a half-completed overloaded operation. 55 | 56 | =head2 Constructor 57 | 58 | =over 59 | 60 | =item C<< new($operation, $param, $type) >> 61 | 62 | =back 63 | 64 | =head2 Method 65 | 66 | =over 67 | 68 | =item C<< complete($type) >> 69 | 70 | =back 71 | 72 | =head1 BUGS 73 | 74 | Please report any bugs to 75 | L. 76 | 77 | =head1 AUTHOR 78 | 79 | Graham Knop Ehaarg@cpan.orgE. 80 | 81 | =head1 COPYRIGHT AND LICENCE 82 | 83 | This software is copyright (c) 2014 by Graham Knop. 84 | 85 | This is free software; you can redistribute it and/or modify it under 86 | the same terms as the Perl 5 programming language system itself. 87 | 88 | =head1 DISCLAIMER OF WARRANTIES 89 | 90 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 91 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 92 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 93 | 94 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Types/Common/Numeric.pm: -------------------------------------------------------------------------------- 1 | package Types::Common::Numeric; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | if ($] < 5.008) { require Devel::TypeTiny::Perl56Compat }; 9 | } 10 | 11 | BEGIN { 12 | $Types::Common::Numeric::AUTHORITY = 'cpan:TOBYINK'; 13 | $Types::Common::Numeric::VERSION = '1.000005'; 14 | } 15 | 16 | use Type::Library -base, -declare => qw( 17 | PositiveNum PositiveOrZeroNum 18 | PositiveInt PositiveOrZeroInt 19 | NegativeNum NegativeOrZeroNum 20 | NegativeInt NegativeOrZeroInt 21 | SingleDigit 22 | ); 23 | 24 | use Type::Tiny (); 25 | use Types::Standard qw( Num Int ); 26 | 27 | my $meta = __PACKAGE__->meta; 28 | 29 | $meta->add_type( 30 | name => 'PositiveNum', 31 | parent => Num, 32 | constraint => sub { $_ > 0 }, 33 | inlined => sub { undef, qq($_ > 0) }, 34 | message => sub { "Must be a positive number" }, 35 | ); 36 | 37 | $meta->add_type( 38 | name => 'PositiveOrZeroNum', 39 | parent => Num, 40 | constraint => sub { $_ >= 0 }, 41 | inlined => sub { undef, qq($_ >= 0) }, 42 | message => sub { "Must be a number greater than or equal to zero" }, 43 | ); 44 | 45 | my ($pos_int, $posz_int); 46 | if (Type::Tiny::_USE_XS) { 47 | $pos_int = Type::Tiny::XS::get_coderef_for('PositiveInt'); 48 | $posz_int = Type::Tiny::XS::get_coderef_for('PositiveOrZeroInt'); 49 | } 50 | 51 | $meta->add_type( 52 | name => 'PositiveInt', 53 | parent => Int, 54 | constraint => sub { $_ > 0 }, 55 | inlined => sub { 56 | if ($pos_int) { 57 | my $xsub = Type::Tiny::XS::get_subname_for($_[0]->name); 58 | return "$xsub($_[1])" if $xsub; 59 | } 60 | undef, qq($_ > 0); 61 | }, 62 | message => sub { "Must be a positive integer" }, 63 | $pos_int ? ( compiled_type_constraint => $pos_int ) : (), 64 | ); 65 | 66 | $meta->add_type( 67 | name => 'PositiveOrZeroInt', 68 | parent => Int, 69 | constraint => sub { $_ >= 0 }, 70 | inlined => sub { 71 | if ($posz_int) { 72 | my $xsub = Type::Tiny::XS::get_subname_for($_[0]->name); 73 | return "$xsub($_[1])" if $xsub; 74 | } 75 | undef, qq($_ >= 0); 76 | }, 77 | message => sub { "Must be an integer greater than or equal to zero" }, 78 | $posz_int ? ( compiled_type_constraint => $posz_int ) : (), 79 | ); 80 | 81 | $meta->add_type( 82 | name => 'NegativeNum', 83 | parent => Num, 84 | constraint => sub { $_ < 0 }, 85 | inlined => sub { undef, qq($_ < 0) }, 86 | message => sub { "Must be a negative number" }, 87 | ); 88 | 89 | $meta->add_type( 90 | name => 'NegativeOrZeroNum', 91 | parent => Num, 92 | constraint => sub { $_ <= 0 }, 93 | inlined => sub { undef, qq($_ <= 0) }, 94 | message => sub { "Must be a number less than or equal to zero" }, 95 | ); 96 | 97 | $meta->add_type( 98 | name => 'NegativeInt', 99 | parent => Int, 100 | constraint => sub { $_ < 0 }, 101 | inlined => sub { undef, qq($_ < 0) }, 102 | message => sub { "Must be a negative integer" }, 103 | ); 104 | 105 | $meta->add_type( 106 | name => 'NegativeOrZeroInt', 107 | parent => Int, 108 | constraint => sub { $_ <= 0 }, 109 | inlined => sub { undef, qq($_ <= 0) }, 110 | message => sub { "Must be an integer less than or equal to zero" }, 111 | ); 112 | 113 | $meta->add_type( 114 | name => 'SingleDigit', 115 | parent => Int, 116 | constraint => sub { $_ >= -9 and $_ <= 9 }, 117 | inlined => sub { undef, qq($_ >= -9), qq($_ <= 9) }, 118 | message => sub { "Must be a single digit" }, 119 | ); 120 | 121 | __PACKAGE__->meta->make_immutable; 122 | 123 | 1; 124 | 125 | __END__ 126 | 127 | =pod 128 | 129 | =encoding utf-8 130 | 131 | =head1 NAME 132 | 133 | Types::Common::Numeric - drop-in replacement for MooseX::Types::Common::Numeric 134 | 135 | =head1 STATUS 136 | 137 | This module is covered by the 138 | L. 139 | 140 | =head1 DESCRIPTION 141 | 142 | A drop-in replacement for L. 143 | 144 | =head2 Types 145 | 146 | The following types are similar to those described in 147 | L. 148 | 149 | =over 150 | 151 | =item C 152 | 153 | =item C 154 | 155 | =item C 156 | 157 | =item C 158 | 159 | =item C 160 | 161 | =item C 162 | 163 | =item C 164 | 165 | =item C 166 | 167 | =item C 168 | 169 | =back 170 | 171 | C interestingly accepts the numbers -9 to -1; not 172 | just 0 to 9. 173 | 174 | =head1 BUGS 175 | 176 | Please report any bugs to 177 | L. 178 | 179 | =head1 SEE ALSO 180 | 181 | L, L. 182 | 183 | L, 184 | L, 185 | L. 186 | 187 | =head1 AUTHOR 188 | 189 | Toby Inkster Etobyink@cpan.orgE. 190 | 191 | =head1 COPYRIGHT AND LICENCE 192 | 193 | This software is copyright (c) 2013-2014 by Toby Inkster. 194 | 195 | This is free software; you can redistribute it and/or modify it under 196 | the same terms as the Perl 5 programming language system itself. 197 | 198 | =head1 DISCLAIMER OF WARRANTIES 199 | 200 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 201 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 202 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 203 | 204 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Types/Standard/ArrayRef.pm: -------------------------------------------------------------------------------- 1 | package Types::Standard::ArrayRef; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Types::Standard::ArrayRef::AUTHORITY = 'cpan:TOBYINK'; 9 | $Types::Standard::ArrayRef::VERSION = '1.000005'; 10 | } 11 | 12 | use Type::Tiny (); 13 | use Types::Standard (); 14 | use Types::TypeTiny (); 15 | 16 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 17 | 18 | no warnings; 19 | 20 | sub __constraint_generator 21 | { 22 | return Types::Standard::ArrayRef unless @_; 23 | 24 | my $param = Types::TypeTiny::to_TypeTiny(shift); 25 | Types::TypeTiny::TypeTiny->check($param) 26 | or _croak("Parameter to ArrayRef[`a] expected to be a type constraint; got $param"); 27 | 28 | my $param_compiled_check = $param->compiled_check; 29 | my $xsub; 30 | if (Type::Tiny::_USE_XS) 31 | { 32 | my $paramname = Type::Tiny::XS::is_known($param_compiled_check); 33 | $xsub = Type::Tiny::XS::get_coderef_for("ArrayRef[$paramname]") 34 | if $paramname; 35 | } 36 | elsif (Type::Tiny::_USE_MOUSE and $param->_has_xsub) 37 | { 38 | require Mouse::Util::TypeConstraints; 39 | my $maker = "Mouse::Util::TypeConstraints"->can("_parameterize_ArrayRef_for"); 40 | $xsub = $maker->($param) if $maker; 41 | } 42 | 43 | return ( 44 | sub 45 | { 46 | my $array = shift; 47 | $param->check($_) || return for @$array; 48 | return !!1; 49 | }, 50 | $xsub, 51 | ); 52 | } 53 | 54 | sub __inline_generator 55 | { 56 | my $param = shift; 57 | 58 | my $param_compiled_check = $param->compiled_check; 59 | if (Type::Tiny::_USE_XS) 60 | { 61 | my $paramname = Type::Tiny::XS::is_known($param_compiled_check); 62 | my $xsubname = Type::Tiny::XS::get_subname_for("ArrayRef[$paramname]"); 63 | return sub { "$xsubname\($_[1]\)" } if $xsubname; 64 | } 65 | 66 | return unless $param->can_be_inlined; 67 | my $param_check = $param->inline_check('$i'); 68 | return sub { 69 | my $v = $_[1]; 70 | "ref($v) eq 'ARRAY' and do { " 71 | . "my \$ok = 1; " 72 | . "for my \$i (\@{$v}) { " 73 | . "(\$ok = 0, last) unless $param_check " 74 | . "}; " 75 | . "\$ok " 76 | ."}" 77 | }; 78 | } 79 | 80 | sub __deep_explanation 81 | { 82 | my ($type, $value, $varname) = @_; 83 | my $param = $type->parameters->[0]; 84 | 85 | for my $i (0 .. $#$value) 86 | { 87 | my $item = $value->[$i]; 88 | next if $param->check($item); 89 | return [ 90 | sprintf('"%s" constrains each value in the array with "%s"', $type, $param), 91 | @{ $param->validate_explain($item, sprintf('%s->[%d]', $varname, $i)) }, 92 | ] 93 | } 94 | 95 | # This should never happen... 96 | return; # uncoverable statement 97 | } 98 | 99 | sub __coercion_generator 100 | { 101 | my ($parent, $child, $param) = @_; 102 | return unless $param->has_coercion; 103 | 104 | my $coercable_item = $param->coercion->_source_type_union; 105 | my $C = "Type::Coercion"->new(type_constraint => $child); 106 | 107 | if ($param->coercion->can_be_inlined and $coercable_item->can_be_inlined) 108 | { 109 | $C->add_type_coercions($parent => Types::Standard::Stringable { 110 | my @code; 111 | push @code, 'do { my ($orig, $return_orig, @new) = ($_, 0);'; 112 | push @code, 'for (@$orig) {'; 113 | push @code, sprintf('++$return_orig && last unless (%s);', $coercable_item->inline_check('$_')); 114 | push @code, sprintf('push @new, (%s);', $param->coercion->inline_coercion('$_')); 115 | push @code, '}'; 116 | push @code, '$return_orig ? $orig : \\@new'; 117 | push @code, '}'; 118 | "@code"; 119 | }); 120 | } 121 | else 122 | { 123 | $C->add_type_coercions( 124 | $parent => sub { 125 | my $value = @_ ? $_[0] : $_; 126 | my @new; 127 | for my $item (@$value) 128 | { 129 | return $value unless $coercable_item->check($item); 130 | push @new, $param->coerce($item); 131 | } 132 | return \@new; 133 | }, 134 | ); 135 | } 136 | 137 | return $C; 138 | } 139 | 140 | 1; 141 | 142 | __END__ 143 | 144 | =pod 145 | 146 | =encoding utf-8 147 | 148 | =head1 NAME 149 | 150 | Types::Standard::ArrayRef - internals for the Types::Standard ArrayRef type constraint 151 | 152 | =head1 STATUS 153 | 154 | This module is considered part of Type-Tiny's internals. It is not 155 | covered by the 156 | L. 157 | 158 | =head1 DESCRIPTION 159 | 160 | This file contains some of the guts for L. 161 | It will be loaded on demand. You may ignore its presence. 162 | 163 | =head1 BUGS 164 | 165 | Please report any bugs to 166 | L. 167 | 168 | =head1 SEE ALSO 169 | 170 | L. 171 | 172 | =head1 AUTHOR 173 | 174 | Toby Inkster Etobyink@cpan.orgE. 175 | 176 | =head1 COPYRIGHT AND LICENCE 177 | 178 | This software is copyright (c) 2013-2014 by Toby Inkster. 179 | 180 | This is free software; you can redistribute it and/or modify it under 181 | the same terms as the Perl 5 programming language system itself. 182 | 183 | =head1 DISCLAIMER OF WARRANTIES 184 | 185 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 186 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 187 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 188 | 189 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Types/Standard/HashRef.pm: -------------------------------------------------------------------------------- 1 | package Types::Standard::HashRef; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Types::Standard::HashRef::AUTHORITY = 'cpan:TOBYINK'; 9 | $Types::Standard::HashRef::VERSION = '1.000005'; 10 | } 11 | 12 | use Type::Tiny (); 13 | use Types::Standard (); 14 | use Types::TypeTiny (); 15 | 16 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 17 | 18 | no warnings; 19 | 20 | sub __constraint_generator 21 | { 22 | return Types::Standard::HashRef unless @_; 23 | 24 | my $param = Types::TypeTiny::to_TypeTiny(shift); 25 | Types::TypeTiny::TypeTiny->check($param) 26 | or _croak("Parameter to HashRef[`a] expected to be a type constraint; got $param"); 27 | 28 | my $param_compiled_check = $param->compiled_check; 29 | my $xsub; 30 | if (Type::Tiny::_USE_XS) 31 | { 32 | my $paramname = Type::Tiny::XS::is_known($param_compiled_check); 33 | $xsub = Type::Tiny::XS::get_coderef_for("HashRef[$paramname]") 34 | if $paramname; 35 | } 36 | elsif (Type::Tiny::_USE_MOUSE and $param->_has_xsub) 37 | { 38 | require Mouse::Util::TypeConstraints; 39 | my $maker = "Mouse::Util::TypeConstraints"->can("_parameterize_HashRef_for"); 40 | $xsub = $maker->($param) if $maker; 41 | } 42 | 43 | return ( 44 | sub 45 | { 46 | my $hash = shift; 47 | $param->check($_) || return for values %$hash; 48 | return !!1; 49 | }, 50 | $xsub, 51 | ); 52 | } 53 | 54 | sub __inline_generator 55 | { 56 | my $param = shift; 57 | 58 | my $compiled = $param->compiled_check; 59 | if (Type::Tiny::_USE_XS) 60 | { 61 | my $paramname = Type::Tiny::XS::is_known($compiled); 62 | my $xsubname = Type::Tiny::XS::get_subname_for("HashRef[$paramname]"); 63 | return sub { "$xsubname\($_[1]\)" } if $xsubname; 64 | } 65 | 66 | return unless $param->can_be_inlined; 67 | my $param_check = $param->inline_check('$i'); 68 | return sub { 69 | my $v = $_[1]; 70 | "ref($v) eq 'HASH' and do { " 71 | . "my \$ok = 1; " 72 | . "for my \$i (values \%{$v}) { " 73 | . "(\$ok = 0, last) unless $param_check " 74 | . "}; " 75 | . "\$ok " 76 | ."}" 77 | }; 78 | } 79 | 80 | sub __deep_explanation 81 | { 82 | require B; 83 | my ($type, $value, $varname) = @_; 84 | my $param = $type->parameters->[0]; 85 | 86 | for my $k (sort keys %$value) 87 | { 88 | my $item = $value->{$k}; 89 | next if $param->check($item); 90 | return [ 91 | sprintf('"%s" constrains each value in the hash with "%s"', $type, $param), 92 | @{ $param->validate_explain($item, sprintf('%s->{%s}', $varname, B::perlstring($k))) }, 93 | ]; 94 | } 95 | 96 | # This should never happen... 97 | return; # uncoverable statement 98 | } 99 | 100 | sub __coercion_generator 101 | { 102 | my ($parent, $child, $param) = @_; 103 | return unless $param->has_coercion; 104 | 105 | my $coercable_item = $param->coercion->_source_type_union; 106 | my $C = "Type::Coercion"->new(type_constraint => $child); 107 | 108 | if ($param->coercion->can_be_inlined and $coercable_item->can_be_inlined) 109 | { 110 | $C->add_type_coercions($parent => Types::Standard::Stringable { 111 | my @code; 112 | push @code, 'do { my ($orig, $return_orig, %new) = ($_, 0);'; 113 | push @code, 'for (keys %$orig) {'; 114 | push @code, sprintf('$return_orig++ && last unless (%s);', $coercable_item->inline_check('$orig->{$_}')); 115 | push @code, sprintf('$new{$_} = (%s);', $param->coercion->inline_coercion('$orig->{$_}')); 116 | push @code, '}'; 117 | push @code, '$return_orig ? $orig : \\%new'; 118 | push @code, '}'; 119 | "@code"; 120 | }); 121 | } 122 | else 123 | { 124 | $C->add_type_coercions( 125 | $parent => sub { 126 | my $value = @_ ? $_[0] : $_; 127 | my %new; 128 | for my $k (keys %$value) 129 | { 130 | return $value unless $coercable_item->check($value->{$k}); 131 | $new{$k} = $param->coerce($value->{$k}); 132 | } 133 | return \%new; 134 | }, 135 | ); 136 | } 137 | 138 | return $C; 139 | } 140 | 141 | 1; 142 | 143 | __END__ 144 | 145 | =pod 146 | 147 | =encoding utf-8 148 | 149 | =head1 NAME 150 | 151 | Types::Standard::HashRef - internals for the Types::Standard HashRef type constraint 152 | 153 | =head1 STATUS 154 | 155 | This module is considered part of Type-Tiny's internals. It is not 156 | covered by the 157 | L. 158 | 159 | =head1 DESCRIPTION 160 | 161 | This file contains some of the guts for L. 162 | It will be loaded on demand. You may ignore its presence. 163 | 164 | =head1 BUGS 165 | 166 | Please report any bugs to 167 | L. 168 | 169 | =head1 SEE ALSO 170 | 171 | L. 172 | 173 | =head1 AUTHOR 174 | 175 | Toby Inkster Etobyink@cpan.orgE. 176 | 177 | =head1 COPYRIGHT AND LICENCE 178 | 179 | This software is copyright (c) 2013-2014 by Toby Inkster. 180 | 181 | This is free software; you can redistribute it and/or modify it under 182 | the same terms as the Perl 5 programming language system itself. 183 | 184 | =head1 DISCLAIMER OF WARRANTIES 185 | 186 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 187 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 188 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 189 | 190 | -------------------------------------------------------------------------------- /inst/perl/fatlib/Types/Standard/ScalarRef.pm: -------------------------------------------------------------------------------- 1 | package Types::Standard::ScalarRef; 2 | 3 | use 5.006001; 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | $Types::Standard::ScalarRef::AUTHORITY = 'cpan:TOBYINK'; 9 | $Types::Standard::ScalarRef::VERSION = '1.000005'; 10 | } 11 | 12 | use Types::Standard (); 13 | use Types::TypeTiny (); 14 | 15 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } 16 | 17 | no warnings; 18 | 19 | sub __constraint_generator 20 | { 21 | return Types::Standard::ScalarRef unless @_; 22 | 23 | my $param = Types::TypeTiny::to_TypeTiny(shift); 24 | Types::TypeTiny::TypeTiny->check($param) 25 | or _croak("Parameter to ScalarRef[`a] expected to be a type constraint; got $param"); 26 | 27 | return sub 28 | { 29 | my $ref = shift; 30 | $param->check($$ref) || return; 31 | return !!1; 32 | }; 33 | } 34 | 35 | sub __inline_generator 36 | { 37 | my $param = shift; 38 | return unless $param->can_be_inlined; 39 | return sub { 40 | my $v = $_[1]; 41 | my $param_check = $param->inline_check("\${$v}"); 42 | "(ref($v) eq 'SCALAR' or ref($v) eq 'REF') and $param_check"; 43 | }; 44 | } 45 | 46 | sub __deep_explanation 47 | { 48 | my ($type, $value, $varname) = @_; 49 | my $param = $type->parameters->[0]; 50 | 51 | for my $item ($$value) 52 | { 53 | next if $param->check($item); 54 | return [ 55 | sprintf('"%s" constrains the referenced scalar value with "%s"', $type, $param), 56 | @{ $param->validate_explain($item, sprintf('${%s}', $varname)) }, 57 | ]; 58 | } 59 | 60 | # This should never happen... 61 | return; # uncoverable statement 62 | } 63 | 64 | sub __coercion_generator 65 | { 66 | my ($parent, $child, $param) = @_; 67 | return unless $param->has_coercion; 68 | 69 | my $coercable_item = $param->coercion->_source_type_union; 70 | my $C = "Type::Coercion"->new(type_constraint => $child); 71 | 72 | if ($param->coercion->can_be_inlined and $coercable_item->can_be_inlined) 73 | { 74 | $C->add_type_coercions($parent => Types::Standard::Stringable { 75 | my @code; 76 | push @code, 'do { my ($orig, $return_orig, $new) = ($_, 0);'; 77 | push @code, 'for ($$orig) {'; 78 | push @code, sprintf('++$return_orig && last unless (%s);', $coercable_item->inline_check('$_')); 79 | push @code, sprintf('$new = (%s);', $param->coercion->inline_coercion('$_')); 80 | push @code, '}'; 81 | push @code, '$return_orig ? $orig : \\$new'; 82 | push @code, '}'; 83 | "@code"; 84 | }); 85 | } 86 | else 87 | { 88 | $C->add_type_coercions( 89 | $parent => sub { 90 | my $value = @_ ? $_[0] : $_; 91 | my $new; 92 | for my $item ($$value) 93 | { 94 | return $value unless $coercable_item->check($item); 95 | $new = $param->coerce($item); 96 | } 97 | return \$new; 98 | }, 99 | ); 100 | } 101 | 102 | return $C; 103 | } 104 | 105 | 1; 106 | 107 | __END__ 108 | 109 | =pod 110 | 111 | =encoding utf-8 112 | 113 | =head1 NAME 114 | 115 | Types::Standard::ScalarRef - internals for the Types::Standard ScalarRef type constraint 116 | 117 | =head1 STATUS 118 | 119 | This module is considered part of Type-Tiny's internals. It is not 120 | covered by the 121 | L. 122 | 123 | =head1 DESCRIPTION 124 | 125 | This file contains some of the guts for L. 126 | It will be loaded on demand. You may ignore its presence. 127 | 128 | =head1 BUGS 129 | 130 | Please report any bugs to 131 | L. 132 | 133 | =head1 SEE ALSO 134 | 135 | L. 136 | 137 | =head1 AUTHOR 138 | 139 | Toby Inkster Etobyink@cpan.orgE. 140 | 141 | =head1 COPYRIGHT AND LICENCE 142 | 143 | This software is copyright (c) 2013-2014 by Toby Inkster. 144 | 145 | This is free software; you can redistribute it and/or modify it under 146 | the same terms as the Perl 5 programming language system itself. 147 | 148 | =head1 DISCLAIMER OF WARRANTIES 149 | 150 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 151 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 152 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 153 | 154 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/.meta/Bio-Cigar-1.01/MYMETA.json: -------------------------------------------------------------------------------- 1 | { 2 | "abstract" : "Parse CIGAR strings and translate coordinates to/from reference/query", 3 | "author" : [ 4 | "Thomas Sibley " 5 | ], 6 | "dynamic_config" : 0, 7 | "generated_by" : "Dist::Milla version v1.0.8, Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.142690, CPAN::Meta::Converter version 2.133380", 8 | "license" : [ 9 | "gpl_2" 10 | ], 11 | "meta-spec" : { 12 | "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", 13 | "version" : "2" 14 | }, 15 | "name" : "Bio-Cigar", 16 | "no_index" : { 17 | "directory" : [ 18 | "t", 19 | "xt", 20 | "inc", 21 | "share", 22 | "eg", 23 | "examples" 24 | ] 25 | }, 26 | "prereqs" : { 27 | "build" : { 28 | "requires" : { 29 | "ExtUtils::MakeMaker" : "0" 30 | } 31 | }, 32 | "configure" : { 33 | "requires" : { 34 | "ExtUtils::MakeMaker" : "0" 35 | } 36 | }, 37 | "develop" : { 38 | "requires" : { 39 | "Dist::Milla" : "v1.0.8", 40 | "Test::Pod" : "1.41" 41 | } 42 | }, 43 | "runtime" : { 44 | "requires" : { 45 | "Carp" : "0", 46 | "List::Util" : "0", 47 | "Moo" : "0", 48 | "Types::Standard" : "1.000005", 49 | "namespace::clean" : "0" 50 | } 51 | }, 52 | "test" : { 53 | "requires" : { 54 | "Test::More" : "0.96" 55 | } 56 | } 57 | }, 58 | "release_status" : "stable", 59 | "resources" : { 60 | "bugtracker" : { 61 | "web" : "https://github.com/MullinsLab/Bio-Cigar/issues" 62 | }, 63 | "homepage" : "https://github.com/MullinsLab/Bio-Cigar", 64 | "repository" : { 65 | "type" : "git", 66 | "url" : "https://github.com/MullinsLab/Bio-Cigar.git", 67 | "web" : "https://github.com/MullinsLab/Bio-Cigar" 68 | } 69 | }, 70 | "version" : "1.01" 71 | } 72 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/.meta/Bio-Cigar-1.01/install.json: -------------------------------------------------------------------------------- 1 | {"target":"Bio::Cigar","name":"Bio::Cigar","dist":"Bio-Cigar-1.01","version":"1.01","provides":{"Bio::Cigar":{"file":"lib/Bio/Cigar.pm","version":"1.01"}},"pathname":"T/TS/TSIBLEY/Bio-Cigar-1.01.tar.gz"} -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/.meta/Exporter-Tiny-0.042/MYMETA.json: -------------------------------------------------------------------------------- 1 | { 2 | "abstract" : "an exporter with the features of Sub::Exporter but only core dependencies", 3 | "author" : [ 4 | "Toby Inkster (TOBYINK) " 5 | ], 6 | "dynamic_config" : 0, 7 | "generated_by" : "Dist::Inkt::Profile::TOBYINK version 0.023, CPAN::Meta::Converter version 2.140640, CPAN::Meta::Converter version 2.133380", 8 | "keywords" : [], 9 | "license" : [ 10 | "perl_5" 11 | ], 12 | "meta-spec" : { 13 | "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", 14 | "version" : "2" 15 | }, 16 | "name" : "Exporter-Tiny", 17 | "no_index" : { 18 | "directory" : [ 19 | "eg", 20 | "examples", 21 | "inc", 22 | "t", 23 | "xt" 24 | ] 25 | }, 26 | "prereqs" : { 27 | "build" : { 28 | "requires" : {} 29 | }, 30 | "configure" : { 31 | "requires" : { 32 | "ExtUtils::MakeMaker" : "6.17" 33 | } 34 | }, 35 | "runtime" : { 36 | "requires" : { 37 | "perl" : "5.006001" 38 | } 39 | }, 40 | "test" : { 41 | "recommends" : { 42 | "Test::Fatal" : "0", 43 | "Test::Warnings" : "0" 44 | }, 45 | "requires" : { 46 | "Test::More" : "0.47" 47 | } 48 | } 49 | }, 50 | "provides" : { 51 | "Exporter::Shiny" : { 52 | "file" : "lib/Exporter/Shiny.pm", 53 | "version" : "0.042" 54 | }, 55 | "Exporter::Tiny" : { 56 | "file" : "lib/Exporter/Tiny.pm", 57 | "version" : "0.042" 58 | } 59 | }, 60 | "release_status" : "stable", 61 | "resources" : { 62 | "bugtracker" : { 63 | "web" : "http://rt.cpan.org/Dist/Display.html?Queue=Exporter-Tiny" 64 | }, 65 | "homepage" : "https://metacpan.org/release/Exporter-Tiny", 66 | "license" : [ 67 | "http://dev.perl.org/licenses/" 68 | ], 69 | "repository" : { 70 | "type" : "git", 71 | "url" : "git://github.com/tobyink/p5-exporter-tiny.git", 72 | "web" : "https://github.com/tobyink/p5-exporter-tiny" 73 | }, 74 | "x_IRC" : "irc://irc.perl.org/#moops", 75 | "x_identifier" : "http://purl.org/NET/cpan-uri/dist/Exporter-Tiny/project" 76 | }, 77 | "version" : "0.042" 78 | } 79 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/.meta/Exporter-Tiny-0.042/install.json: -------------------------------------------------------------------------------- 1 | {"pathname":"T/TO/TOBYINK/Exporter-Tiny-0.042.tar.gz","provides":{"Exporter::Tiny":{"file":"lib/Exporter/Tiny.pm","version":"0.042"},"Exporter::Shiny":{"version":"0.042","file":"lib/Exporter/Shiny.pm"}},"name":"Exporter::Tiny","dist":"Exporter-Tiny-0.042","version":"0.042","target":"Exporter::Tiny"} -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/.meta/Type-Tiny-1.000005/install.json: -------------------------------------------------------------------------------- 1 | {"dist":"Type-Tiny-1.000005","version":"1.000005","name":"Type::Tiny","target":"Types::Standard","pathname":"T/TO/TOBYINK/Type-Tiny-1.000005.tar.gz","provides":{"Types::Standard::ArrayRef":{"file":"lib/Types/Standard/ArrayRef.pm","version":"1.000005"},"Error::TypeTiny::WrongNumberOfParameters":{"file":"lib/Error/TypeTiny/WrongNumberOfParameters.pm","version":"1.000005"},"Types::Standard::ScalarRef":{"file":"lib/Types/Standard/ScalarRef.pm","version":"1.000005"},"Types::Common::String":{"version":"1.000005","file":"lib/Types/Common/String.pm"},"Type::Coercion::FromMoose":{"file":"lib/Type/Coercion/FromMoose.pm","version":"1.000005"},"Error::TypeTiny::Compilation":{"file":"lib/Error/TypeTiny/Compilation.pm","version":"1.000005"},"Error::TypeTiny":{"file":"lib/Error/TypeTiny.pm","version":"1.000005"},"Types::Standard::Dict":{"file":"lib/Types/Standard/Dict.pm","version":"1.000005"},"Type::Tiny::Class":{"version":"1.000005","file":"lib/Type/Tiny/Class.pm"},"Type::Library":{"version":"1.000005","file":"lib/Type/Library.pm"},"Type::Tiny":{"file":"lib/Type/Tiny.pm","version":"1.000005"},"Type::Tiny::Role":{"version":"1.000005","file":"lib/Type/Tiny/Role.pm"},"Error::TypeTiny::Assertion":{"file":"lib/Error/TypeTiny/Assertion.pm","version":"1.000005"},"Types::Standard::Tuple":{"version":"1.000005","file":"lib/Types/Standard/Tuple.pm"},"Reply::Plugin::TypeTiny":{"version":"1.000005","file":"lib/Reply/Plugin/TypeTiny.pm"},"Type::Tiny::Enum":{"version":"1.000005","file":"lib/Type/Tiny/Enum.pm"},"Eval::TypeTiny":{"version":"1.000005","file":"lib/Eval/TypeTiny.pm"},"Type::Tiny::Intersection":{"version":"1.000005","file":"lib/Type/Tiny/Intersection.pm"},"Test::TypeTiny":{"file":"lib/Test/TypeTiny.pm","version":"1.000005"},"Type::Utils":{"file":"lib/Type/Utils.pm","version":"1.000005"},"Types::Standard":{"file":"lib/Types/Standard.pm","version":"1.000005"},"Type::Tiny::Duck":{"version":"1.000005","file":"lib/Type/Tiny/Duck.pm"},"Type::Registry":{"file":"lib/Type/Registry.pm","version":"1.000005"},"Types::Common::Numeric":{"file":"lib/Types/Common/Numeric.pm","version":"1.000005"},"Type::Tiny::Union":{"file":"lib/Type/Tiny/Union.pm","version":"1.000005"},"Devel::TypeTiny::Perl56Compat":{"file":"lib/Devel/TypeTiny/Perl56Compat.pm","version":"1.000005"},"Type::Params":{"version":"1.000005","file":"lib/Type/Params.pm"},"Devel::TypeTiny::Perl58Compat":{"file":"lib/Devel/TypeTiny/Perl58Compat.pm","version":"1.000005"},"Type::Parser":{"version":"1.000005","file":"lib/Type/Parser.pm"},"Type::Coercion":{"file":"lib/Type/Coercion.pm","version":"1.000005"},"Type::Coercion::Union":{"file":"lib/Type/Coercion/Union.pm","version":"1.000005"},"Types::TypeTiny":{"version":"1.000005","file":"lib/Types/TypeTiny.pm"},"Types::Standard::Map":{"version":"1.000005","file":"lib/Types/Standard/Map.pm"},"Types::Standard::HashRef":{"version":"1.000005","file":"lib/Types/Standard/HashRef.pm"}}} -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/auto/Bio/Cigar/.packlist: -------------------------------------------------------------------------------- 1 | /Users/tng/perl5/lib/perl5/Bio/Cigar.pm 2 | /Users/tng/perl5/man/man3/Bio::Cigar.3pm 3 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/auto/Exporter/Tiny/.packlist: -------------------------------------------------------------------------------- 1 | /Users/tng/perl5/lib/perl5/Exporter/Shiny.pm 2 | /Users/tng/perl5/lib/perl5/Exporter/Tiny.pm 3 | /Users/tng/perl5/man/man3/Exporter::Shiny.3pm 4 | /Users/tng/perl5/man/man3/Exporter::Tiny.3pm 5 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/auto/Type/Tiny/.packlist: -------------------------------------------------------------------------------- 1 | /Users/tng/perl5/lib/perl5/Devel/TypeTiny/Perl56Compat.pm 2 | /Users/tng/perl5/lib/perl5/Devel/TypeTiny/Perl58Compat.pm 3 | /Users/tng/perl5/lib/perl5/Error/TypeTiny.pm 4 | /Users/tng/perl5/lib/perl5/Error/TypeTiny/Assertion.pm 5 | /Users/tng/perl5/lib/perl5/Error/TypeTiny/Compilation.pm 6 | /Users/tng/perl5/lib/perl5/Error/TypeTiny/WrongNumberOfParameters.pm 7 | /Users/tng/perl5/lib/perl5/Eval/TypeTiny.pm 8 | /Users/tng/perl5/lib/perl5/Reply/Plugin/TypeTiny.pm 9 | /Users/tng/perl5/lib/perl5/Test/TypeTiny.pm 10 | /Users/tng/perl5/lib/perl5/Type/Coercion.pm 11 | /Users/tng/perl5/lib/perl5/Type/Coercion/FromMoose.pm 12 | /Users/tng/perl5/lib/perl5/Type/Coercion/Union.pm 13 | /Users/tng/perl5/lib/perl5/Type/Library.pm 14 | /Users/tng/perl5/lib/perl5/Type/Params.pm 15 | /Users/tng/perl5/lib/perl5/Type/Parser.pm 16 | /Users/tng/perl5/lib/perl5/Type/Registry.pm 17 | /Users/tng/perl5/lib/perl5/Type/Tiny.pm 18 | /Users/tng/perl5/lib/perl5/Type/Tiny/Class.pm 19 | /Users/tng/perl5/lib/perl5/Type/Tiny/Duck.pm 20 | /Users/tng/perl5/lib/perl5/Type/Tiny/Enum.pm 21 | /Users/tng/perl5/lib/perl5/Type/Tiny/Intersection.pm 22 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual.pod 23 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/Coercions.pod 24 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/Libraries.pod 25 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/Optimization.pod 26 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/Params.pod 27 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/Policies.pod 28 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/UsingWithMoo.pod 29 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/UsingWithMoose.pod 30 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/UsingWithMouse.pod 31 | /Users/tng/perl5/lib/perl5/Type/Tiny/Manual/UsingWithOther.pod 32 | /Users/tng/perl5/lib/perl5/Type/Tiny/Role.pm 33 | /Users/tng/perl5/lib/perl5/Type/Tiny/Union.pm 34 | /Users/tng/perl5/lib/perl5/Type/Tiny/_HalfOp.pm 35 | /Users/tng/perl5/lib/perl5/Type/Utils.pm 36 | /Users/tng/perl5/lib/perl5/Types/Common/Numeric.pm 37 | /Users/tng/perl5/lib/perl5/Types/Common/String.pm 38 | /Users/tng/perl5/lib/perl5/Types/Standard.pm 39 | /Users/tng/perl5/lib/perl5/Types/Standard/ArrayRef.pm 40 | /Users/tng/perl5/lib/perl5/Types/Standard/Dict.pm 41 | /Users/tng/perl5/lib/perl5/Types/Standard/HashRef.pm 42 | /Users/tng/perl5/lib/perl5/Types/Standard/Map.pm 43 | /Users/tng/perl5/lib/perl5/Types/Standard/ScalarRef.pm 44 | /Users/tng/perl5/lib/perl5/Types/Standard/Tuple.pm 45 | /Users/tng/perl5/lib/perl5/Types/TypeTiny.pm 46 | /Users/tng/perl5/man/man3/Devel::TypeTiny::Perl56Compat.3pm 47 | /Users/tng/perl5/man/man3/Devel::TypeTiny::Perl58Compat.3pm 48 | /Users/tng/perl5/man/man3/Error::TypeTiny.3pm 49 | /Users/tng/perl5/man/man3/Error::TypeTiny::Assertion.3pm 50 | /Users/tng/perl5/man/man3/Error::TypeTiny::Compilation.3pm 51 | /Users/tng/perl5/man/man3/Error::TypeTiny::WrongNumberOfParameters.3pm 52 | /Users/tng/perl5/man/man3/Eval::TypeTiny.3pm 53 | /Users/tng/perl5/man/man3/Reply::Plugin::TypeTiny.3pm 54 | /Users/tng/perl5/man/man3/Test::TypeTiny.3pm 55 | /Users/tng/perl5/man/man3/Type::Coercion.3pm 56 | /Users/tng/perl5/man/man3/Type::Coercion::FromMoose.3pm 57 | /Users/tng/perl5/man/man3/Type::Coercion::Union.3pm 58 | /Users/tng/perl5/man/man3/Type::Library.3pm 59 | /Users/tng/perl5/man/man3/Type::Params.3pm 60 | /Users/tng/perl5/man/man3/Type::Parser.3pm 61 | /Users/tng/perl5/man/man3/Type::Registry.3pm 62 | /Users/tng/perl5/man/man3/Type::Tiny.3pm 63 | /Users/tng/perl5/man/man3/Type::Tiny::Class.3pm 64 | /Users/tng/perl5/man/man3/Type::Tiny::Duck.3pm 65 | /Users/tng/perl5/man/man3/Type::Tiny::Enum.3pm 66 | /Users/tng/perl5/man/man3/Type::Tiny::Intersection.3pm 67 | /Users/tng/perl5/man/man3/Type::Tiny::Manual.3pm 68 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::Coercions.3pm 69 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::Libraries.3pm 70 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::Optimization.3pm 71 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::Params.3pm 72 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::Policies.3pm 73 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::UsingWithMoo.3pm 74 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::UsingWithMoose.3pm 75 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::UsingWithMouse.3pm 76 | /Users/tng/perl5/man/man3/Type::Tiny::Manual::UsingWithOther.3pm 77 | /Users/tng/perl5/man/man3/Type::Tiny::Role.3pm 78 | /Users/tng/perl5/man/man3/Type::Tiny::Union.3pm 79 | /Users/tng/perl5/man/man3/Type::Tiny::_HalfOp.3pm 80 | /Users/tng/perl5/man/man3/Type::Utils.3pm 81 | /Users/tng/perl5/man/man3/Types::Common::Numeric.3pm 82 | /Users/tng/perl5/man/man3/Types::Common::String.3pm 83 | /Users/tng/perl5/man/man3/Types::Standard.3pm 84 | /Users/tng/perl5/man/man3/Types::Standard::ArrayRef.3pm 85 | /Users/tng/perl5/man/man3/Types::Standard::Dict.3pm 86 | /Users/tng/perl5/man/man3/Types::Standard::HashRef.3pm 87 | /Users/tng/perl5/man/man3/Types::Standard::Map.3pm 88 | /Users/tng/perl5/man/man3/Types::Standard::ScalarRef.3pm 89 | /Users/tng/perl5/man/man3/Types::Standard::Tuple.3pm 90 | /Users/tng/perl5/man/man3/Types::TypeTiny.3pm 91 | -------------------------------------------------------------------------------- /inst/perl/fatlib/darwin-thread-multi-2level/perllocal.pod: -------------------------------------------------------------------------------- 1 | =head2 Wed Mar 2 14:35:24 2016: C L 2 | 3 | =over 4 4 | 5 | =item * 6 | 7 | C 8 | 9 | =item * 10 | 11 | C 12 | 13 | =item * 14 | 15 | C 16 | 17 | =item * 18 | 19 | C 20 | 21 | =back 22 | 23 | =head2 Wed Mar 2 14:35:49 2016: C L 24 | 25 | =over 4 26 | 27 | =item * 28 | 29 | C 30 | 31 | =item * 32 | 33 | C 34 | 35 | =item * 36 | 37 | C 38 | 39 | =item * 40 | 41 | C 42 | 43 | =back 44 | 45 | =head2 Wed Mar 2 14:35:51 2016: C L 46 | 47 | =over 4 48 | 49 | =item * 50 | 51 | C 52 | 53 | =item * 54 | 55 | C 56 | 57 | =item * 58 | 59 | C 60 | 61 | =item * 62 | 63 | C 64 | 65 | =back 66 | 67 | -------------------------------------------------------------------------------- /inst/perl/fatlib/namespace/clean/_Util.pm: -------------------------------------------------------------------------------- 1 | ### !!!ACHTUNG!!! 2 | # 3 | # This module is to be loaded at configure time straight from the Makefile.PL 4 | # in order to get access to some of the constants / utils 5 | # None of the dependencies will be available yet at this point, so make 6 | # sure to never use anything beyond what the minimum supported perl came with 7 | # (no, relying on configure_requires is not ok) 8 | 9 | package # hide from the pauses 10 | namespace::clean::_Util; 11 | 12 | use warnings; 13 | use strict; 14 | 15 | use base 'Exporter'; 16 | our @EXPORT_OK = qw( DEBUGGER_NEEDS_CV_RENAME DEBUGGER_NEEDS_CV_PIVOT ); 17 | 18 | use constant DEBUGGER_NEEDS_CV_RENAME => ( ( "$]" > 5.008_008 ) and ( "$]" < 5.013_006 ) ); 19 | use constant DEBUGGER_NEEDS_CV_PIVOT => ( ( ! DEBUGGER_NEEDS_CV_RENAME ) and ( "$]" < 5.015_005 ) ); 20 | 21 | # FIXME - ideally this needs to be provided by some abstraction lib 22 | # but we don't have that yet 23 | BEGIN { 24 | # 25 | # Note - both get_subname and set_subname are only called by one block 26 | # which is compiled away unless CV_RENAME is true ( the 5.8.9 ~ 5.12 range ). 27 | # Hence we compile/provide the definitions here only when needed 28 | # 29 | DEBUGGER_NEEDS_CV_RENAME and ( eval <<'EOS' or die $@ ); 30 | { 31 | my( $sub_name_loaded, $sub_util_loaded ); 32 | 33 | sub _namer_load_error { 34 | return '' if $sub_util_loaded or $sub_name_loaded; 35 | 36 | # if S::N is loaded first *and* so is B - then go with that, otherwise 37 | # prefer Sub::Util as S::U will provide a faster get_subname and will 38 | # not need further require() calls 39 | # this is rather arbitrary but remember this code exists only perls 40 | # between 5.8.9 ~ 5.13.5 41 | 42 | # when changing version also change in Makefile.PL 43 | my $sn_ver = 0.04; 44 | 45 | local $@; 46 | my $err = ''; 47 | 48 | ( 49 | ! ( 50 | $INC{"B.pm"} 51 | and 52 | $INC{"Sub/Name.pm"} 53 | and 54 | eval { Sub::Name->VERSION($sn_ver) } 55 | ) 56 | and 57 | eval { require Sub::Util } 58 | and 59 | # see https://github.com/moose/Moo/commit/dafa5118 60 | defined &Sub::Util::set_subname 61 | and 62 | $sub_util_loaded = 1 63 | ) 64 | or 65 | ( 66 | eval { require Sub::Name and Sub::Name->VERSION($sn_ver) } 67 | and 68 | $sub_name_loaded = 1 69 | ) 70 | or 71 | $err = "When running under -d on this perl $], namespace::clean requires either Sub::Name $sn_ver or Sub::Util to be installed" 72 | ; 73 | 74 | $err; 75 | } 76 | 77 | sub set_subname { 78 | if( my $err = _namer_load_error() ) { 79 | die $err; 80 | } 81 | elsif( $sub_name_loaded ) { 82 | &Sub::Name::subname; 83 | } 84 | elsif( $sub_util_loaded ) { 85 | &Sub::Util::set_subname; 86 | } 87 | else { 88 | die "How the fuck did we get here? Read source and debug please!"; 89 | } 90 | } 91 | 92 | sub get_subname { 93 | if( 94 | _namer_load_error() 95 | or 96 | ! $sub_util_loaded 97 | ) { 98 | require B; 99 | my $gv = B::svref_2object( $_[0] )->GV; 100 | join '::', $gv->STASH->NAME, $gv->NAME; 101 | } 102 | else { 103 | &Sub::Util::subname; 104 | } 105 | } 106 | } 107 | 1; 108 | EOS 109 | 110 | } 111 | 112 | 1; 113 | -------------------------------------------------------------------------------- /inst/perl/fatlib/oo.pm: -------------------------------------------------------------------------------- 1 | package oo; 2 | 3 | use Moo::_strictures; 4 | use Moo::_Utils qw(_load_module); 5 | 6 | sub moo { 7 | print <<'EOMOO'; 8 | ______ 9 | < Moo! > 10 | ------ 11 | \ ^__^ 12 | \ (oo)\_______ 13 | (__)\ )\/\ 14 | ||----w | 15 | || || 16 | EOMOO 17 | exit 0; 18 | } 19 | 20 | BEGIN { 21 | my $package; 22 | sub import { 23 | moo() if $0 eq '-'; 24 | $package = $_[1] || 'Class'; 25 | if ($package =~ /^\+/) { 26 | $package =~ s/^\+//; 27 | _load_module($package); 28 | } 29 | } 30 | use Filter::Simple sub { s/^/package $package;\nuse Moo;\n/; } 31 | } 32 | 33 | 1; 34 | __END__ 35 | 36 | =head1 NAME 37 | 38 | oo - syntactic sugar for Moo oneliners 39 | 40 | =head1 SYNOPSIS 41 | 42 | perl -Moo=Foo -e 'has bar => ( is => q[ro], default => q[baz] ); print Foo->new->bar' 43 | 44 | # loads an existing class and re-"opens" the package definition 45 | perl -Moo=+My::Class -e 'print __PACKAGE__->new->bar' 46 | 47 | =head1 DESCRIPTION 48 | 49 | oo.pm is a simple source filter that adds C to the 50 | beginning of your script, intended for use on the command line via the -M 51 | option. 52 | 53 | =head1 SUPPORT 54 | 55 | See L for support and contact information. 56 | 57 | =head1 AUTHORS 58 | 59 | See L for authors. 60 | 61 | =head1 COPYRIGHT AND LICENSE 62 | 63 | See L for the copyright and license. 64 | 65 | =cut 66 | -------------------------------------------------------------------------------- /inst/perl/fatpacker.trace: -------------------------------------------------------------------------------- 1 | Method/Generate/Constructor.pm 2 | Carp.pm 3 | Types/TypeTiny.pm 4 | Sub/Defer.pm 5 | Moo/_Utils.pm 6 | Eval/TypeTiny.pm 7 | constant.pm 8 | overload.pm 9 | Module/Runtime.pm 10 | B/Hooks/EndOfScope.pm 11 | Import/Into.pm 12 | Moo/Object.pm 13 | Moo.pm 14 | Bio/Cigar.pm 15 | Moo/sification.pm 16 | Scalar/Util.pm 17 | mro.pm 18 | Class/XSAccessor/Heavy.pm 19 | Type/Tiny.pm 20 | warnings/register.pm 21 | Moo/_mro.pm 22 | Exporter/Tiny.pm 23 | Module/Implementation.pm 24 | base.pm 25 | Sub/Exporter/Progressive.pm 26 | Types/Standard.pm 27 | Type/Tiny/Union.pm 28 | DynaLoader.pm 29 | Sub/Quote.pm 30 | re.pm 31 | Types/Standard/Tuple.pm 32 | Variable/Magic.pm 33 | Devel/GlobalDestruction.pm 34 | Package/Stash/XS.pm 35 | Package/Stash.pm 36 | Class/XSAccessor.pm 37 | Type/Coercion.pm 38 | vars.pm 39 | B/Hooks/EndOfScope/XS.pm 40 | Getopt/Std.pm 41 | List/Util.pm 42 | strictures.pm 43 | Type/Coercion/Union.pm 44 | Try/Tiny.pm 45 | Config.pm 46 | overloading.pm 47 | Moo/HandleMoose/_TypeMap.pm 48 | Type/Library.pm 49 | Method/Generate/Accessor.pm 50 | Type/Tiny/Enum.pm 51 | Sub/Name.pm 52 | namespace/clean.pm 53 | Types/Standard/ArrayRef.pm 54 | -------------------------------------------------------------------------------- /inst/perl/hapture.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use warnings; 3 | use strict; 4 | use Getopt::Std; 5 | use Bio::Cigar; # Cpan this if you want to run this script !! 6 | use List::Util qw(max); 7 | 8 | use vars qw/ %opt /; 9 | 10 | # this program is subsequently packed via App::FatPacker 11 | # see http://perltricks.com/article/58/2014/1/5/The-easy-way-to-build-stand-alone-Perl-apps/ 12 | # install fatpack via cpan App::FatPacker 13 | # 14 | # fatpack file hapture.pl > hapture 15 | # either perl hapture or -run as executable by chmod 755 16 | 17 | 18 | sub init(){ 19 | getopts( "hv:s:i:g:", \%opt ) or usage(); 20 | usage() if $opt{h}; 21 | print STDERR "Require path specification for VCF file: -v\n" and exit if not defined $opt{v}; 22 | print STDERR "Require path specification for SAM file: -s\n" and exit if not defined $opt{s}; 23 | print STDERR "Require individual ID: -i\n" and exit if not defined $opt{i}; 24 | print STDERR "Require group ID: -g \n" and exit if not defined $opt{g}; 25 | } 26 | 27 | 28 | sub usage(){ 29 | print STDERR << "EOF"; 30 | This program gathers variant haplotype sites from SAM alignment file, and reports a summary file for those variant sites 31 | 32 | usage: $0 [-h] -v vcf_file -s sam_file -i int 33 | 34 | -h : this (help) message 35 | -v file : variant caller file - VCF format (!! assumed the position is sorted) 36 | -s file : sequence alignment file - SAM format 37 | -i int : individual ID (integer value or unbroken string) 38 | -g str : group ID (unbroken string) 39 | 40 | example: $0 -v s1.vcf -s s1.sam -i 0 -g sebastes 41 | 42 | EOF 43 | exit; 44 | } 45 | 46 | #----- get user's input parameters ------ 47 | 48 | init(); 49 | 50 | #--------------------------------------- 51 | 52 | 53 | #----- read vcf file ------------- 54 | 55 | # Objective: keeps variants' info into memory so that 56 | # I can tell whether there are any variant sites for 57 | # the alignment read entry from the SAM file 58 | 59 | my $vcf; # a hash reference that keeps track of essential vcf info: reference variant, derived variants, pos 60 | my $hap; 61 | 62 | open VCF, $opt{v}; 63 | while () { 64 | next if /^#/; 65 | my @line = split "\t"; 66 | # for now, we only concern SNP site, (exclude indel and any other complex events) 67 | 68 | # reference allele 69 | next if length($line[3]) > 1; 70 | # derived allele 71 | my $max_len = 0; 72 | my @snp = split ",", $line[4]; 73 | for my $deriv (@snp) { 74 | $max_len = length($deriv) if length($deriv) > $max_len; 75 | } 76 | next if $max_len > 1; 77 | 78 | #print $line[0], "\t", $line[3], "\t", $line[4], "\n"; 79 | push @{$vcf->{$line[0]}}, $line[1]; 80 | push @{$vcf->{"ref_".$line[0]}}, $line[3]; 81 | push @{$vcf->{"der_".$line[0]}}, $snp[0]; 82 | } 83 | close VCF; 84 | 85 | #---------------------------------------- 86 | 87 | 88 | open SAM, $opt{s}; 89 | while() { 90 | next if /^\@/; 91 | my @lines = split "\t"; 92 | my $id = $lines[2]; 93 | next if $lines[1] >= 256; # skip entries that are secondary alignment or to multiple sites 94 | my $st_qpos = $lines[3]; # starting query position 95 | #my $mapq = $lines[4]; # mapping quality score 96 | #skip if the alignment id is not found in the vcf hash ref 97 | next if not defined $vcf->{$id}; 98 | 99 | next if $lines[5] eq "*"; 100 | my $cigar = Bio::Cigar->new($lines[5]); 101 | my @qseq = split "", $lines[9]; 102 | my @qseq_qual = split "", $lines[10]; 103 | 104 | next if $#qseq < 1; 105 | #print "Query length is ", $cigar->query_length, "\n"; 106 | #print "Reference length is ", $cigar->reference_length, "\n"; 107 | my $hapRead={}; 108 | $hapRead->{"seq"} = ""; 109 | my $ct=0; 110 | for my $rpos (@{$vcf->{$id}}) { 111 | my $rpos_adj = $rpos - $st_qpos +1; 112 | $ct++; 113 | 114 | if ($cigar->reference_length < $rpos_adj || $rpos_adj < 1) { 115 | $hapRead->{"seq"} .= "N"; # marked as unknown 116 | push @{$hapRead->{"qual"}}, "_"; 117 | next; 118 | } 119 | my ($qpos, $op) = $cigar->rpos_to_qpos($rpos_adj); 120 | 121 | if (not defined $qpos) { 122 | $hapRead->{"seq"} .= "X"; # marked as deletion site 123 | push @{$hapRead->{"qual"}}, "_"; 124 | } 125 | else { 126 | $hapRead->{"seq"} .= $qseq[$qpos-1]; 127 | push @{$hapRead->{"qual"}}, $qseq_qual[$qpos-1]; 128 | } 129 | 130 | #print $qpos-1, "\t", $#qseq, "\t", $lines[0], "\t", $id, "\n"; 131 | #print join "\t", $id, $rpos, $qseq[$qpos-1], $qseq_qual[$qpos-1], "\n" if $qpos != -1; 132 | } 133 | 134 | $hap->{$id}->{$hapRead->{"seq"}}->{"ct"}++; 135 | for my $i (0..$#{$vcf->{$id}}) { 136 | 137 | if(! defined ${$hap->{$id}->{$hapRead->{"seq"}}->{"maxC"}}[$i]) { 138 | ${$hap->{$id}->{$hapRead->{"seq"}}->{"maxC"}}[$i] = 0; 139 | ${$hap->{$id}->{$hapRead->{"seq"}}->{"sC"}}[$i] = 0; 140 | } 141 | 142 | my $q = 10**(-(ord(${$hapRead->{"qual"}}[$i])-33)/10); 143 | #${$hap->{$id}->{$hapRead->{"seq"}}->{"logC"}}[$i]+= log(1-$q) ; 144 | #${$hap->{$id}->{$hapRead->{"seq"}}->{"logW"}}[$i]+= log($q); 145 | ${$hap->{$id}->{$hapRead->{"seq"}}->{"sC"}}[$i]+= 1-$q; # collecting the sum of prob phred site score for future use 146 | ${$hap->{$id}->{$hapRead->{"seq"}}->{"maxC"}}[$i] = max(1-$q, ${$hap->{$id}->{$hapRead->{"seq"}}->{"maxC"}}[$i]); 147 | 148 | } 149 | #${$hap->{$id}->{$hapRead->{"seq"}}->{"mapq"}->{$mapq}}++; # collecting the MapQ alignment score 150 | 151 | } 152 | 153 | 154 | #--- output a haplotype summary file ----- 155 | 156 | for my $id (keys %{$hap}){ 157 | for my $h (keys %{$hap->{$id}}){ 158 | 159 | print join "\t", $opt{g}, # group label 160 | $opt{i}, # individual id label 161 | $id, #locus id 162 | $h, # haplotype sequence 163 | $hap->{$id}->{$h}->{"ct"}, # number of occurence observed for this haplotype or read depth 164 | #(join ",", @{$hap->{$id}->{$h}->{"logC"}}), # log scale phred stat for being a correct base 165 | #(join ",", @{$hap->{$id}->{$h}->{"logW"}}), # log scale phred stat for being a miscalled base 166 | #(join ",", @{$vcf->{$id}}); # variant position 167 | (join ",", @{$hap->{$id}->{$h}->{"sC"}}), # sum of prob for calling correct base 168 | (join ",", @{$hap->{$id}->{$h}->{"maxC"}})."\n";# max phred score 169 | 170 | #print "\t"; 171 | 172 | #print join ",", map {$_, ${$hap->{$id}->{$h}->{"mapq"}->{$_}}} (keys %{$hap->{$id}->{$h}->{"mapq"}}); 173 | #print "\n"; 174 | } 175 | } 176 | 177 | #---------------------------------------- 178 | -------------------------------------------------------------------------------- /inst/shiny/microhaplot/fish1.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/inst/shiny/microhaplot/fish1.rds -------------------------------------------------------------------------------- /inst/shiny/microhaplot/fish1_posinfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/inst/shiny/microhaplot/fish1_posinfo.rds -------------------------------------------------------------------------------- /inst/shiny/microhaplot/fish2.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/inst/shiny/microhaplot/fish2.rds -------------------------------------------------------------------------------- /inst/shiny/microhaplot/fish2_posinfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/inst/shiny/microhaplot/fish2_posinfo.rds -------------------------------------------------------------------------------- /man/figures/microhaplot-sticker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/man/figures/microhaplot-sticker.png -------------------------------------------------------------------------------- /man/mvShinyHaplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runHaplot.R 3 | \name{mvShinyHaplot} 4 | \alias{mvShinyHaplot} 5 | \title{Transfer a copy of microhaplot app.} 6 | \usage{ 7 | mvShinyHaplot(path) 8 | } 9 | \arguments{ 10 | \item{path}{string. directory path. Required} 11 | } 12 | \value{ 13 | a logical value of whether \code{file.copy} is successfully transferred Shiny app to its new directory 14 | } 15 | \description{ 16 | Moves shiny microhaplot app to a different directory 17 | } 18 | \examples{ 19 | 20 | mvShinyHaplot(tempdir()) 21 | 22 | } 23 | -------------------------------------------------------------------------------- /man/prepHaplotFiles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runHaplot.R 3 | \name{prepHaplotFiles} 4 | \alias{prepHaplotFiles} 5 | \title{Extracts haplotype from alignment reads.} 6 | \usage{ 7 | prepHaplotFiles( 8 | run.label, 9 | sam.path, 10 | label.path, 11 | vcf.path, 12 | out.path = tempdir(), 13 | add.filter = FALSE, 14 | app.path = tempdir(), 15 | n.jobs = 1 16 | ) 17 | } 18 | \arguments{ 19 | \item{run.label}{character vector. Run label to be used to display in haPLOType. Required} 20 | 21 | \item{sam.path}{string. Directory path folder containing all sequence alignment files (SAM). Required} 22 | 23 | \item{label.path}{string. Label file path. This customized label file is a tab-separate file that contains entries of SAM file name, individual ID, and group label. Required} 24 | 25 | \item{vcf.path}{string. VCF file path. Required} 26 | 27 | \item{out.path}{string. Optional. If not specified, the intermediate files are created under \code{TEMPDIR}, with the assumption that directory is granted for written permission.} 28 | 29 | \item{add.filter}{boolean. Optional. If true, this removes any haplotype with unknown and deletion alignment characters i.e. "*" and "_", removes any locus with large number of haplotypes ( # > 40) , and remove any locus with fewer than half of the total individuals.} 30 | 31 | \item{app.path}{string. Path to shiny haPLOType app. Optional. If not specified, the path is default to \code{TEMPDIR}.} 32 | 33 | \item{n.jobs}{positive integer. Number of SAM files to be parallel processed. Optional. This multithread is only available for non Window OS. Recommend two times the number of processors/core.} 34 | } 35 | \value{ 36 | This function returns a dataframe of 9 columns i.e group, id, locus, haplotype, depth, sum of Phred score, max of Phred score, allele balance and haplotype rank from highest to lowest read depth. This dataframe will also be saved in \code{out.path}. 37 | } 38 | \description{ 39 | The function \code{microhaplot} extracts haplotype from sequence alignment files through perl script \code{hapture} and returns a summary table of the read depth and read quality associate with haplotype. 40 | } 41 | \examples{ 42 | 43 | run.label <- "sebastes" 44 | 45 | sam.path <- tempdir() 46 | untar(system.file("extdata", 47 | "sebastes_sam.tar.gz", 48 | package="microhaplot"), 49 | exdir = sam.path) 50 | 51 | 52 | label.path <- file.path(sam.path, "label.txt") 53 | vcf.path <- file.path(sam.path, "sebastes.vcf") 54 | 55 | mvShinyHaplot(tempdir()) 56 | app.path <- file.path(tempdir(), "microhaplot") 57 | 58 | # retrieve system Perl version number 59 | perl.version <- as.numeric(system('perl -e "print $];"', intern=TRUE)) 60 | 61 | if (perl.version >= 5.014) { 62 | haplo.read.tbl <- prepHaplotFiles(run.label = run.label, 63 | sam.path = sam.path, 64 | out.path = tempdir(), 65 | label.path = label.path, 66 | vcf.path = vcf.path, 67 | app.path = app.path) 68 | }else { 69 | message("Perl version is outdated. Must >= 5.014.")} 70 | 71 | } 72 | -------------------------------------------------------------------------------- /man/runShinyHaplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runHaplot.R 3 | \name{runShinyHaplot} 4 | \alias{runShinyHaplot} 5 | \title{Run shiny microhaplot} 6 | \usage{ 7 | runShinyHaplot( 8 | path = system.file("shiny", "microhaplot", package = "microhaplot") 9 | ) 10 | } 11 | \arguments{ 12 | \item{path}{Path to shiny microhaplot app. Optional. If not specified, the path is default to local app path.} 13 | } 14 | \value{ 15 | Runs shiny microhaplot application via \code{shiny::runApp} which typically doesn't return; interrupt R to stop the application (usually by pressing Ctrl+C or Esc). 16 | } 17 | \description{ 18 | Run shiny microhaplot app 19 | } 20 | \examples{ 21 | if(interactive()){ 22 | runShinyHaplot() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /microhaplot.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | haPLOT-data-prep.R 2 | haPLOT-data-prep.html 3 | microhaplot-walkthrough.html 4 | troubleshoot.html 5 | -------------------------------------------------------------------------------- /vignettes/field_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/vignettes/field_selection.png -------------------------------------------------------------------------------- /vignettes/locus_annotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/vignettes/locus_annotation.png -------------------------------------------------------------------------------- /vignettes/main_panel_choice_tabset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/vignettes/main_panel_choice_tabset.png -------------------------------------------------------------------------------- /vignettes/main_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/vignettes/main_tab.png -------------------------------------------------------------------------------- /vignettes/read_criteria_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngthomas/microhaplot/42c9ed924e61b90f970286e28211cba03c609e07/vignettes/read_criteria_tab.png -------------------------------------------------------------------------------- /vignettes/troubleshoot.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Package Troubleshoot" 3 | author: "Thomas Ng and Eric C. Anderson" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Package Troubleshoot} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | # Issue with RunHaplot: 13 | ## Warning message concerning missing Moo.pm 14 | Suggestion: You might need to examine the system environment path for Perl. It is recommended that the `which Perl` should point to the `/usr/bin` path. 15 | --------------------------------------------------------------------------------