Skip to content

Commit

Permalink
[November::Tags] remove use of class variables
Browse files Browse the repository at this point in the history
It doesn't seem necessary, and it's not yet implemented in Rakudo.
  • Loading branch information
Carl Masak committed Nov 23, 2010
1 parent 39ea975 commit 0d56401
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/November/Tags.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use November::Config;


class November::Tags { class November::Tags {
my $server_root = November::Config.new.server_root; my $server_root = November::Config.new.server_root;
my $.page_tags_path is rw = $server_root ~ 'data/page_tags/'; my $page_tags_path = $server_root ~ 'data/page_tags/';
my $.tags_count_path is rw = $server_root ~ 'data/tags_count'; my $tags_count_path = $server_root ~ 'data/tags_count';
my $.tags_index_path is rw = $server_root ~ 'data/tags_index'; my $tags_index_path = $server_root ~ 'data/tags_index';


method update_tags($_: Str $page, Str $new_tags) { method update_tags($_: Str $page, Str $new_tags) {
my $old_tags = .read_page_tags($page).chomp; my $old_tags = .read_page_tags($page).chomp;
Expand Down Expand Up @@ -71,39 +71,39 @@ class November::Tags {
} }


method read_page_tags(Str $page) { method read_page_tags(Str $page) {
my $file = $.page_tags_path ~ $page; my $file = $page_tags_path ~ $page;
return '' unless $file ~~ :e; return '' unless $file.IO ~~ :e;
return slurp($file); return slurp($file);
} }


method write_page_tags(Str $page, Str $tags) { method write_page_tags(Str $page, Str $tags) {
my $file = $.page_tags_path ~ $page; my $file = $page_tags_path ~ $page;
my $fh = open( $file, :w ); my $fh = open( $file, :w );
$fh.say($tags); $fh.say($tags);
$fh.close; $fh.close;
} }


method read_tags_count() { method read_tags_count() {
my $file = $.tags_count_path; my $file = $tags_count_path;
return {} unless $file ~~ :e; return {} unless $file.IO ~~ :e;
return eval slurp $file; return eval slurp $file;
} }


method write_tags_count(Hash $counts) { method write_tags_count(Hash $counts) {
my $file = $.tags_count_path; my $file = $tags_count_path;
my $fh = open( $file, :w ); my $fh = open( $file, :w );
$fh.say( $counts.perl ); $fh.say( $counts.perl );
$fh.close; $fh.close;
} }


method read_tags_index() { method read_tags_index() {
my $file = $.tags_index_path; my $file = $tags_index_path;
return {} unless $file ~~ :e; return {} unless $file.IO ~~ :e;
return eval slurp $file; return eval slurp $file;
} }


method write_tags_index(Hash $index) { method write_tags_index(Hash $index) {
my $file = $.tags_index_path; my $file = $tags_index_path;
my $fh = open( $file, :w ); my $fh = open( $file, :w );
$fh.say( $index.perl ); $fh.say( $index.perl );
$fh.close; $fh.close;
Expand Down

0 comments on commit 0d56401

Please sign in to comment.