letteropend 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5e35304268f8c5572b2229b6e9f1b652fc85558
4
- data.tar.gz: 5ca98b6f08d5095cabe6c4f13a42baabdc01d024
3
+ metadata.gz: a5640da5f8ec0d3a72189d53470ba0b9fb7e2bd7
4
+ data.tar.gz: 11d582a99ebc2e009982bd24561c526eb895558d
5
5
  SHA512:
6
- metadata.gz: f80309d6f2665d12fa045e36fb9fb212685468d8574f45b63dd9d47d2bd8e52f602f4b3079645de13c9d53b595f29ec2f235c1eea2e24514f174a3039043f09d
7
- data.tar.gz: b9737ce23e168e491c00d6f579939378a4b51a7debb096b7d9abd224990ecfe7653c456533e7dc02b434fcfea828db2215083c295adb3b3b685069657eb5e9e0
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
- print "First username: "
10
- user1 = gets.chomp
11
+ # First username
12
+ user1 = ARGV[0]
11
13
 
12
- print "Second username: "
13
- user2 = gets.chomp
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")
@@ -1,9 +1,12 @@
1
+ # Usage: ruby getAllTime.rb <username> <list>
2
+
1
3
  require_relative "../lib/letteropend"
2
4
 
3
- print "Enter username: "
4
- un = gets().chomp
5
- print "Enter list: "
6
- ul = gets().chomp
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
@@ -1,3 +1,6 @@
1
+ # Usage: ruby getDirectedFilms.rb
2
+ # TODO: Allow the user to pass command line arguments
3
+
1
4
  require_relative "../lib/letteropend"
2
5
 
3
6
  puts "Looking at films directed by Alfred Hitchcock"
@@ -1,3 +1,6 @@
1
+ # Usage: ruby getFilmDetails.rb
2
+ # TODO: Allow the user to pass command line arguments
3
+
1
4
  require_relative "../lib/letteropend"
2
5
 
3
6
  Letteropend::Film.config do
@@ -1,9 +1,12 @@
1
+ # Usage: ruby getNumberOfFilms.rb <username> <list>
2
+
1
3
  require_relative "../lib/letteropend"
2
4
 
3
- print "Enter username: "
4
- un = gets().chomp
5
- print "Enter list: "
6
- ul = gets().chomp
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
@@ -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 url - the url letterboxd assigns the film
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(url, *details, &events)
17
- @url = url
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 |detail|
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("http://www.letterboxd.com/film/#{@url}/"))
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
- @url == film.url
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: #{@url}, method: #{sym}"
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
@@ -1,3 +1,3 @@
1
1
  module Letteropend
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
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.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-19 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri