<commit_before>require 'feedjira'
require 'lj_media/journal_parser'
require 'lj_media/post'

module LJMedia

  # Public: This class represents an LJ journal specified by username.
  #
  # See the LJMedia::JournalParser docs for attributes description.
  #
  # Examples
  #
  #   journal = LJMedia::Journal.new('ru-chp')
  #   journal.type #=> "community"
  class Journal
    extend Forwardable

    # Internal: Underlying Feedjira parser defined in LJMedia::JournalParser
    attr_reader :feed

    private
    # Internal: Dummy methods to allow rdoc to correctly parse attr_reader
    # for delegate
    def self.pass_methods(*methods)
      delegate methods => :feed
    end
    public

    ##
    # :attr_reader:
    #
    # Public: \Journal attribute processed by LJMedia::JournalParser
    pass_methods :id, :type, :name,
                     :title, :description,
                     :link, :published,
                     :posts

    # Public: Initialize journal parser by passing a LiveJournal username.
    #
    # username - [ String ] LiveJournal username. Can be personal journal or a community
    #
    # *TODO*: check username validity
    #
    # *TODO*: support custom feed links, including local files for testing #
    # purposes
    def initialize(username)
      feed_url = "http://#{username}.livejournal.com/data/rss?unfold_embed=1"
      feed_xml = Feedjira::Feed.fetch_raw feed_url

      @feed  = Feedjira::Feed.parse_with JournalParser, feed_xml
    end

    # :stopdoc:
    def inspect
      "#<#{self.class} #{feed.link}, @posts=#{posts.inspect}>"
    end
  end
end
<commit_msg>Add more detail description for LJMedia::Journal feed attribute<commit_after>require 'feedjira'
require 'lj_media/journal_parser'
require 'lj_media/post'

module LJMedia

  # Public: This class represents an LJ journal specified by username.
  #
  # See the LJMedia::JournalParser docs for attributes description.
  #
  # Examples
  #
  #   journal = LJMedia::Journal.new('ru-chp')
  #   journal.type #=> "community"
  class Journal
    extend Forwardable

    # Internal: Underlying Feedjira parser defined in LJMedia::JournalParser
    #
    # You should only call this if you have a reason for accessing some #
    # of Feedjira provided functionality, and I can not guarantee that it #
    # will not break with Feedjira updates. Only attributes listed in this #
    # document will continue to work until the next major version of lj_media.
    attr_reader :feed

    private
    # Internal: Dummy methods to allow rdoc to correctly parse attr_reader
    # for delegate
    def self.pass_methods(*methods)
      delegate methods => :feed
    end
    public

    ##
    # :attr_reader:
    #
    # Public: \Journal attribute processed by LJMedia::JournalParser
    pass_methods :id, :type, :name,
                     :title, :description,
                     :link, :published,
                     :posts

    # Public: Initialize journal parser by passing a LiveJournal username.
    #
    # username - [ String ] LiveJournal username. Can be personal journal or a community
    #
    # *TODO*: check username validity
    #
    # *TODO*: support custom feed links, including local files for testing #
    # purposes
    def initialize(username)
      feed_url = "http://#{username}.livejournal.com/data/rss?unfold_embed=1"
      feed_xml = Feedjira::Feed.fetch_raw feed_url

      @feed  = Feedjira::Feed.parse_with JournalParser, feed_xml
    end

    # :stopdoc:
    def inspect
      "#<#{self.class} #{feed.link}, @posts=#{posts.inspect}>"
    end
  end
end

{'fraction_non_alphanumeric': 0.08854748603351956, 'fraction_numerical': 0.0005586592178770949, 'mean_word_length': 2.821771611526147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4367278', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1014, 'n_words': 324}