letteropend 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/compareWatchlist.rb +6 -4
- data/examples/getAllTime.rb +7 -4
- data/examples/getDirectedFilms.rb +3 -0
- data/examples/getFilmDetails.rb +3 -0
- data/examples/getNumberOfFilms.rb +7 -4
- data/lib/letteropend/film.rb +15 -16
- data/lib/letteropend/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a5640da5f8ec0d3a72189d53470ba0b9fb7e2bd7
         | 
| 4 | 
            +
              data.tar.gz: 11d582a99ebc2e009982bd24561c526eb895558d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 34e4b9356825b72f9114fd6ed63db2e422fdbe41d19d55c7728cf628bf2dc62094036f69d74c566152bc6fde763182cb2e3cbac9c423a21bde4c65b91cf88318
         | 
| 7 | 
            +
              data.tar.gz: 0f4b3cc40743af4a48dd04a798f610898b3528a90ec51ea0ee088af988cada98158cc648ea4733304b43199cd27257ebf654a82688f16722392701fc63b93761
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # Usage: ruby compareWatchlist.rb <username 1> <username 2>
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative "../lib/letteropend"
         | 
| 2 4 |  | 
| 3 5 | 
             
            Letteropend::List.config do
         | 
| @@ -6,11 +8,11 @@ Letteropend::List.config do | |
| 6 8 | 
             
              end
         | 
| 7 9 | 
             
            end
         | 
| 8 10 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
            user1 =  | 
| 11 | 
            +
            # First username
         | 
| 12 | 
            +
            user1 = ARGV[0]
         | 
| 11 13 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
            user2 =  | 
| 14 | 
            +
            # Second username
         | 
| 15 | 
            +
            user2 = ARGV[1]
         | 
| 14 16 |  | 
| 15 17 | 
             
            user1_wl = Letteropend::List.new(user1, "watchlist")
         | 
| 16 18 | 
             
            user2_wl = Letteropend::List.new(user2, "watchlist")
         | 
    
        data/examples/getAllTime.rb
    CHANGED
    
    | @@ -1,9 +1,12 @@ | |
| 1 | 
            +
            # Usage: ruby getAllTime.rb <username> <list>
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative "../lib/letteropend"
         | 
| 2 4 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            un =  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 5 | 
            +
            # Username
         | 
| 6 | 
            +
            un = ARGV[0]
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # List
         | 
| 9 | 
            +
            ul = ARGV[1]
         | 
| 7 10 |  | 
| 8 11 | 
             
            # global variable and function ; yeah I know it's jank
         | 
| 9 12 | 
             
            $ct = 0
         | 
    
        data/examples/getFilmDetails.rb
    CHANGED
    
    
| @@ -1,9 +1,12 @@ | |
| 1 | 
            +
            # Usage: ruby getNumberOfFilms.rb <username> <list>
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative "../lib/letteropend"
         | 
| 2 4 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            un =  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 5 | 
            +
            # Username
         | 
| 6 | 
            +
            un = ARGV[0]
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # List
         | 
| 9 | 
            +
            ul = ARGV[1]
         | 
| 7 10 |  | 
| 8 11 | 
             
            Letteropend::List.config do
         | 
| 9 12 | 
             
              on :new_page do
         | 
    
        data/lib/letteropend/film.rb
    CHANGED
    
    | @@ -4,33 +4,32 @@ require "open-uri" | |
| 4 4 | 
             
            module Letteropend
         | 
| 5 5 | 
             
              # The Film class
         | 
| 6 6 | 
             
              class Film
         | 
| 7 | 
            -
                attr_reader :url
         | 
| 7 | 
            +
                attr_reader :slug, :url
         | 
| 8 8 | 
             
                @@valid_attributes = [:title, :tagline, :overview, :runtime]
         | 
| 9 9 | 
             
                @@valid_events = [:model_updated, :model_updating]
         | 
| 10 10 |  | 
| 11 11 | 
             
                # Creates a new film instance
         | 
| 12 12 | 
             
                #
         | 
| 13 | 
            -
                # @param  | 
| 13 | 
            +
                # @param id - the title letterboxd assigns the film for the url
         | 
| 14 14 | 
             
                # @param details - the attributes the user assigns the film (instead of pulling from letterboxd)
         | 
| 15 15 | 
             
                # @param events - block of user defined events
         | 
| 16 | 
            -
                def initialize( | 
| 17 | 
            -
                  @ | 
| 16 | 
            +
                def initialize(slug, details={}, &events)
         | 
| 17 | 
            +
                  @slug = slug.split("/").last
         | 
| 18 | 
            +
                  @url = "http://letterboxd.com/film/#{@slug}/"
         | 
| 18 19 | 
             
                  @pulled = false
         | 
| 19 20 | 
             
                  @pulling = false
         | 
| 20 21 | 
             
                  @events = {}
         | 
| 21 22 |  | 
| 22 23 | 
             
                  # assign each detail to a method
         | 
| 23 | 
            -
                  details.each do | | 
| 24 | 
            -
                    detail.each do |key, value|
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                      # only assign valid attributes to a film
         | 
| 27 | 
            -
                      if @@valid_attributes.include? key
         | 
| 28 | 
            -
                        define_singleton_method(key, lambda{value})
         | 
| 29 | 
            -
                      else
         | 
| 30 | 
            -
                        puts "Error: trying to assign invalid film data | film: #{@url}, attribute: #{key}"
         | 
| 31 | 
            -
                      end
         | 
| 24 | 
            +
                  details.each do |key, value|
         | 
| 32 25 |  | 
| 26 | 
            +
                    # only assign valid attributes to a film
         | 
| 27 | 
            +
                    if @@valid_attributes.include? key
         | 
| 28 | 
            +
                      define_singleton_method(key, lambda{value})
         | 
| 29 | 
            +
                    else
         | 
| 30 | 
            +
                      puts "Error: trying to assign invalid film data | film: #{@slug}, attribute: #{key}"
         | 
| 33 31 | 
             
                    end
         | 
| 32 | 
            +
             | 
| 34 33 | 
             
                  end
         | 
| 35 34 |  | 
| 36 35 | 
             
                  # assign events to film object
         | 
| @@ -83,7 +82,7 @@ module Letteropend | |
| 83 82 | 
             
                  model_updating
         | 
| 84 83 |  | 
| 85 84 | 
             
                  # pull the page from the url
         | 
| 86 | 
            -
                  page = Nokogiri::HTML(open( | 
| 85 | 
            +
                  page = Nokogiri::HTML(open(@url))
         | 
| 87 86 |  | 
| 88 87 | 
             
                  # get the title for the film
         | 
| 89 88 | 
             
                  title = page.css("h1.film-title").text
         | 
| @@ -114,7 +113,7 @@ module Letteropend | |
| 114 113 |  | 
| 115 114 | 
             
                # Equivalence operator
         | 
| 116 115 | 
             
                def ==(film)
         | 
| 117 | 
            -
                  @ | 
| 116 | 
            +
                  @slug == film.slug
         | 
| 118 117 | 
             
                end
         | 
| 119 118 |  | 
| 120 119 | 
             
                # Method Missing implementation
         | 
| @@ -127,7 +126,7 @@ module Letteropend | |
| 127 126 | 
             
                      pull_data
         | 
| 128 127 | 
             
                      self.send(sym)
         | 
| 129 128 | 
             
                    elsif !@pulled and @pulling
         | 
| 130 | 
            -
                      puts "Error: trying to get film data prematurely | film: #{@ | 
| 129 | 
            +
                      puts "Error: trying to get film data prematurely | film: #{@slug}, method: #{sym}"
         | 
| 131 130 | 
             
                    end
         | 
| 132 131 | 
             
                  elsif (@@valid_events.include? sym)
         | 
| 133 132 | 
             
                    # no method was defined for this event
         | 
    
        data/lib/letteropend/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: letteropend
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0. | 
| 4 | 
            +
              version: 2.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jesse Jurman
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-08- | 
| 11 | 
            +
            date: 2014-08-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: nokogiri
         |