my-flicks 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e594642b741bc257df9444eddc292772cfb5291
4
+ data.tar.gz: dbf7c3313de06b58473322936e72849319699cc7
5
+ SHA512:
6
+ metadata.gz: 64ab80993fe429938b3f4659e9851212999022b7f2e9d18c02ded073fead637a05e14e5dfe220244e213ce30f35a86ee45a50cdfcbca2ac3891d3ecf7f80f150
7
+ data.tar.gz: aab27efb66aa80f6052c23d5850b8f2176f7d5e9bb71503cd787d5d9ea3646336a26adc79d58d9f0c88d76b9b8e02abe7ac3c5cc7c13ba4cb7352e9b7cc9771b
data/LICENCE ADDED
File without changes
data/README ADDED
File without changes
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # /usr/bin/env ruby means check the environement to find ruby interpreter
4
+
5
+ # this is the main ruby file, thats why it doesnt have .rb extension at the end
6
+
7
+ require_relative '../lib/flicks/playlist'
8
+ require_relative '../lib/flicks/movie3d'
9
+
10
+ # movie1 = Movie.new('goonies',10)
11
+ # movie2 = Movie.new('up', 5)
12
+ # movie3 = Movie.new('scarface')
13
+ # playlist1 = Playlist.new('Kermit')
14
+ # playlist1.add_movie(movie1)
15
+ # playlist1.add_movie(movie2)
16
+ # playlist1.add_movie(movie3)
17
+
18
+ #playlist = Playlist.new('Kermit')
19
+ # Playlist is now inside ot the module Flicks: we refer to it using Flicks::Playlist
20
+ playlist = Flicks::Playlist.new('Kermit')
21
+
22
+
23
+ # Read from command line using ARGV # shift method will get the value
24
+ # || operator means if shift returns nill, use the second element by argument
25
+
26
+ # Absolute directory for movies.csv
27
+ default_movie_file =
28
+ File.join(File.dirname(__FILE__), 'movies.csv') # means find movies.csv in the same directory of the current file
29
+ playlist.load( ARGV.shift || default_movie_file) # From command line : ruby fliks.rb superheros_movies.csv
30
+ # The command-line arguments are accessible in the global array ARGV. Use the shift command to return the first command-line argument (the CSV file name). If there are no command-line arguments, use the || operator to load the default player file.
31
+
32
+ movie3d = Movie3D.new('glee', 5, 20)
33
+ playlist.add_movie(movie3d)
34
+
35
+ # playlist1.play(3)
36
+ # playlist1.print_stats
37
+
38
+ # puts "How many viewings?"
39
+ # # Read from stdin using gets
40
+ # # Chomp to take away the line break
41
+ # answer = gets.chomp
42
+ # puts "Enjoy your #{answer} viewings..."
43
+
44
+ # # we need to parse answer into integer because gets will read a string and play expect an integer
45
+ # playlist1.play(answer.to_i)
46
+ # playlist1.print_stats
47
+
48
+ loop do
49
+ puts "\nHow many viewings? ('quit' to exit)"
50
+ answer = gets.chomp.downcase
51
+ case answer
52
+ when /^\d+$/ # Regular expression between // in Ruby, here for one or more numbers
53
+ playlist.play(answer.to_i)
54
+ when 'quit', 'exit'
55
+ playlist.print_stats
56
+ break
57
+ else
58
+ puts "Please enter a number or 'quit'"
59
+ end
60
+ end
61
+
62
+ playlist.save
63
+
64
+ # playlist.print_stats
65
+
66
+ # playlist2 = Playlist.new('Fozzie')
67
+ # playlist2.add_movie(movie3)
68
+ # movie4 = Movie.new('gremlins', 15)
69
+ # playlist2.add_movie(movie4)
70
+ # playlist2.play
71
+
72
+
73
+
@@ -0,0 +1,67 @@
1
+ require_relative '../lib/flicks/playlist'
2
+ require_relative '../lib/flicks/movie3d'
3
+
4
+ # movie1 = Movie.new('goonies',10)
5
+ # movie2 = Movie.new('up', 5)
6
+ # movie3 = Movie.new('scarface')
7
+ # playlist1 = Playlist.new('Kermit')
8
+ # playlist1.add_movie(movie1)
9
+ # playlist1.add_movie(movie2)
10
+ # playlist1.add_movie(movie3)
11
+
12
+ #playlist = Playlist.new('Kermit')
13
+ # Playlist is now inside ot the module Flicks: we refer to it using Flicks::Playlist
14
+ playlist = Flicks::Playlist.new('Kermit')
15
+
16
+
17
+ # Read from command line using ARGV # shift method will get the value
18
+ # || operator means if shift returns nill, use the second element by argument
19
+
20
+ # Absolute directory for movies.csv
21
+ default_movie_file =
22
+ File.join(File.dirname(__FILE__), 'movies.csv') # means find movies.csv in the same directory of the current file
23
+ playlist.load( ARGV.shift || default_movie_file) # From command line : ruby fliks.rb superheros_movies.csv
24
+ # The command-line arguments are accessible in the global array ARGV. Use the shift command to return the first command-line argument (the CSV file name). If there are no command-line arguments, use the || operator to load the default player file.
25
+
26
+ movie3d = Movie3D.new('glee', 5, 20)
27
+ playlist.add_movie(movie3d)
28
+
29
+ # playlist1.play(3)
30
+ # playlist1.print_stats
31
+
32
+ # puts "How many viewings?"
33
+ # # Read from stdin using gets
34
+ # # Chomp to take away the line break
35
+ # answer = gets.chomp
36
+ # puts "Enjoy your #{answer} viewings..."
37
+
38
+ # # we need to parse answer into integer because gets will read a string and play expect an integer
39
+ # playlist1.play(answer.to_i)
40
+ # playlist1.print_stats
41
+
42
+ loop do
43
+ puts "\nHow many viewings? ('quit' to exit)"
44
+ answer = gets.chomp.downcase
45
+ case answer
46
+ when /^\d+$/ # Regular expression between // in Ruby, here for one or more numbers
47
+ playlist.play(answer.to_i)
48
+ when 'quit', 'exit'
49
+ playlist.print_stats
50
+ break
51
+ else
52
+ puts "Please enter a number or 'quit'"
53
+ end
54
+ end
55
+
56
+ playlist.save
57
+
58
+ # playlist.print_stats
59
+
60
+ # playlist2 = Playlist.new('Fozzie')
61
+ # playlist2.add_movie(movie3)
62
+ # movie4 = Movie.new('gremlins', 15)
63
+ # playlist2.add_movie(movie4)
64
+ # playlist2.play
65
+
66
+
67
+
@@ -0,0 +1,4 @@
1
+ Glee,483
2
+ Goonies,18
3
+ Goldfinge,5
4
+ Ghostbusters,2
@@ -0,0 +1,3 @@
1
+ Goonies,10
2
+ Ghostbusters,9
3
+ Goldfinge,0
@@ -0,0 +1,3 @@
1
+ Batman,1
2
+ Spiderman,7
3
+ Superman,5
@@ -0,0 +1,115 @@
1
+ # require_relative 'movie'
2
+ # we no longer use require_relative but require, because ruby knows where to find bin and spec drectories
3
+
4
+ require 'flicks/movie'
5
+
6
+ # run 'rspec' in the root directory without '.' because ruby knows where to find the spec files
7
+
8
+ describe Movie do
9
+ # it 'has a capitalized title' do
10
+ # movie = Movie.new('goonies',10)
11
+
12
+ # movie.title.should == 'Goonies'
13
+ # end
14
+
15
+ # it 'has an intial rank' do
16
+ # movie = Movie.new('goonies', 10)
17
+ # movie.rank.should == 10
18
+ # end
19
+
20
+ # it 'has a string representation' do
21
+ # movie = Movie.new('goonies', 10)
22
+ # movie.to_s.should == 'Goonies has a rank of 10'
23
+ # end
24
+
25
+ # it 'increases rank by 1 when given a thumbs up' do
26
+ # initial_rank = 10
27
+ # movie = Movie.new('goonies', initial_rank)
28
+ # movie.thumbs_up
29
+ # movie.rank.should == initial_rank + 1
30
+ # end
31
+
32
+ # it 'decreases rank by 1 when given a thumbs down' do
33
+ # initial_rank = 10
34
+ # movie = Movie.new('goonies', initial_rank)
35
+ # movie.thumbs_down
36
+ # movie.rank.should == initial_rank - 1
37
+ # end
38
+
39
+ # Improve the previous code
40
+
41
+ # the "before" block : will run before every method, it uses instance variable
42
+
43
+ before do
44
+ @initial_rank = 10
45
+ @movie = Movie.new('goonies', @initial_rank)
46
+ end
47
+
48
+ it 'has a capitalized title' do
49
+ @movie.title.should == 'Goonies'
50
+ end
51
+
52
+ it 'has an intial rank' do
53
+ @movie.rank.should == 10
54
+ end
55
+
56
+ it 'has a string representation' do
57
+ @movie.to_s.should == 'Goonies has a rank of 10 (Hit)'
58
+ end
59
+
60
+ it 'increases rank by 1 when given a thumbs up' do
61
+ @movie.thumbs_up
62
+ @movie.rank.should == @initial_rank + 1
63
+ end
64
+
65
+ it 'decreases rank by 1 when given a thumbs down' do
66
+ @movie.thumbs_down
67
+ @movie.rank.should == @initial_rank - 1
68
+ end
69
+
70
+ context 'created with a default rank' do
71
+
72
+ before do
73
+ @movie = Movie.new('goonies')
74
+ end
75
+
76
+ it 'has a rank of 0' do
77
+ @movie.rank.should == 0
78
+ end
79
+
80
+ end
81
+
82
+ context 'with a rank of at least 10' do
83
+ before do
84
+ @movie = Movie.new('goonies',10)
85
+ end
86
+
87
+ it 'is a hit' do
88
+ # @movie.hit?.should be_true
89
+ # @movie.hit?.should == true
90
+ @movie.should be_hit
91
+ end
92
+
93
+ it 'has a hit status' do
94
+ @movie.status.should == 'Hit'
95
+ end
96
+ end
97
+
98
+ context 'with a rank less than 10' do
99
+ before do
100
+ @movie = Movie.new('goonies',9)
101
+ end
102
+
103
+ it 'is not a hit' do
104
+ # @movie.hit?.should be_false
105
+ # @movie.hit?.should == false
106
+ @movie.should_not be_hit
107
+ end
108
+
109
+ it 'has a flop status' do
110
+ @movie.status.should == 'Flop'
111
+ end
112
+
113
+ end
114
+
115
+ end
@@ -0,0 +1,47 @@
1
+ # require_relative 'playlist'
2
+ # we no longer use require_relative but require, because ruby knows where to find bin and spec drectories
3
+
4
+ require 'flicks/playlist'
5
+
6
+ # run 'rspec' in the root directory without '.' because ruby knows where to find the spec files
7
+
8
+ module Flicks
9
+ describe Playlist do
10
+
11
+ before do
12
+ @playlist = Playlist.new('Kermit')
13
+ end
14
+
15
+ context 'being played with one movie' do
16
+ before do
17
+ @initial_rank = 10
18
+ @movie = Movie.new('goonies', @initial_rank)
19
+ @playlist.add_movie(@movie)
20
+ end
21
+
22
+ it 'gives the movie a thumbs up if a high number is rolled' do
23
+ #@playlist.stub(:roll_die).and_return(5) # if the roll_die method is called always return 5
24
+ WaldorAndStatler.stub(:roll_die).and_return(5)
25
+
26
+ @playlist.play(1)
27
+ @movie.rank.should == @initial_rank + 1
28
+ end
29
+
30
+ it 'skips the movie if a medium number is rolled' do
31
+ #@playlist.stub(:roll_die).and_return(3)
32
+ WaldorAndStatler.stub(:roll_die).and_return(3)
33
+
34
+ @playlist.play(1)
35
+ @movie.rank.should == @initial_rank
36
+ end
37
+
38
+ it 'gives the movie a thumbs down if a low number is rolled' do
39
+ #@playlist.stub(:roll_die).and_return(1)
40
+ WaldorAndStatler.stub(:roll_die).and_return(1)
41
+
42
+ @playlist.play(1)
43
+ @movie.rank.should == @initial_rank - 1
44
+ end
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: my-flicks
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Aymen Chetoui
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: ''
28
+ email: aymen.chetoui@gmail.com
29
+ executables:
30
+ - flicks
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/flicks
35
+ - bin/flicks.rb
36
+ - bin/movies.csv
37
+ - bin/movie_rankings.csv
38
+ - bin/superheros_movies.csv
39
+ - LICENCE
40
+ - README
41
+ - spec/flicks/movie_spec.rb
42
+ - spec/flicks/playlist_spec.rb
43
+ homepage: ''
44
+ licenses: []
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.0.14
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Plays and reviews movies
66
+ test_files:
67
+ - spec/flicks/movie_spec.rb
68
+ - spec/flicks/playlist_spec.rb