File Coverage

lib/Finance/Robinhood/Equity/Tag.pm
Criterion Covered Total %
statement 22 34 64.7
branch n/a
condition 2 4 50.0
subroutine 9 10 90.0
pod 1 1 100.0
total 34 49 69.3


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::Tag;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Tag - Represents a Single Categorized List of Equity
10             Instruments
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new;
16             my $oil = $rh->tags('oil')->next;
17              
18             CORE::say sprintf '%d members of the tag named %s', $oil->membership_count, $oil->name;
19             CORE::say join ', ', map { $_->symbol } $oil->instruments;
20              
21             =head1 METHODS
22              
23             =cut
24              
25             our $VERSION = '0.92_003';
26 1     1   49 use Mojo::Base-base, -signatures;
  1         3  
  1         6  
27 1     1   160 use Mojo::URL;
  1         3  
  1         4  
28 1     1   36 use Time::Moment;
  1         2  
  1         19  
29 1     1   707 use Finance::Robinhood::Equity::PriceMovement;
  1         2  
  1         4  
30              
31             sub _test__init {
32 1     1   12475 my $rh = t::Utility::rh_instance(1);
33 0         0 my $tag = $rh->tags('food')->current;
34 0         0 isa_ok($tag, __PACKAGE__);
35 0         0 t::Utility::stash('TAG', $tag); # Store it for later
36             }
37 1     1   105 use overload '""' => sub ($s, @) { $s->{slug} }, fallback => 1;
  1     6   1  
  1         6  
  6         6  
  6         27  
  6         616  
  6         10  
38              
39             sub _test_stringify {
40 1   50 1   2241 t::Utility::stash('TAG') // skip_all();
41 0         0 like(+t::Utility::stash('TAG'), 'food',);
42             }
43             #
44             has _rh => undef => weak => 1;
45              
46             =head2 C
47              
48             If available, this returns a short blurb about what sort of instruments are
49             contained in this tag.
50              
51             =head2 C
52              
53             If available, this returns a full text description suited for display.
54              
55             =head2 C
56              
57             Returns the number of instruments are contained in this tag.
58              
59             =head2 C
60              
61             Returns the name of this tag in a format suited for display
62              
63             =head2 C
64              
65             Returns the internal string used to locate this tag.
66              
67             =cut
68              
69             has ['canonical_examples', 'description', 'membership_count', 'name', 'slug'];
70              
71             =head2 C
72              
73             my $instruments = $mover->instruments();
74              
75             Returns a list of Finance::Robinhood::Equity::Instrument objects.
76              
77             =cut
78              
79 0     0 1 0 sub instruments ($s) {
  0         0  
  0         0  
80             $s->_rh->equity_instruments_by_id(
81             map {
82 0         0 m/([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})\/$/i
83 0         0 } @{$s->{instruments}}
  0         0  
84             );
85             }
86              
87             sub _test_instruments {
88 1   50 1   2177 t::Utility::stash('TAG') // skip_all();
89 0           my @instruments = t::Utility::stash('TAG')->instruments();
90 0           isa_ok($instruments[0], 'Finance::Robinhood::Equity::Instrument');
91             }
92              
93             =head1 LEGAL
94              
95             This is a simple wrapper around the API used in the official apps. The author
96             provides no investment, legal, or tax advice and is not responsible for any
97             damages incurred while using this software. This software is not affiliated
98             with Robinhood Financial LLC in any way.
99              
100             For Robinhood's terms and disclosures, please see their website at
101             https://robinhood.com/legal/
102              
103             =head1 LICENSE
104              
105             Copyright (C) Sanko Robinson.
106              
107             This library is free software; you can redistribute it and/or modify it under
108             the terms found in the Artistic License 2. Other copyrights, terms, and
109             conditions may apply to data transmitted through this module. Please refer to
110             the L section.
111              
112             =head1 AUTHOR
113              
114             Sanko Robinson Esanko@cpan.orgE
115              
116             =cut
117              
118             1;