From 299dff95d75f85b0dc49dced6825c036f0c42ab0 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Wed, 15 Jan 2014 13:35:10 -0800 Subject: [PATCH 01/41] Update roster.txt --- week1/exercises/roster.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week1/exercises/roster.txt b/week1/exercises/roster.txt index 21b0964..3a58940 100644 --- a/week1/exercises/roster.txt +++ b/week1/exercises/roster.txt @@ -18,5 +18,5 @@ 16, Robert McCreary Mannino, rmccreary8@gmail.com, psytau, maalaoshi, rmccreary8@gmail.com 17, Rukia, rukk86@gmail.com, rukk86, no twitter, Rukia 18, -19, +19, Kevin Young, kevin@young.net, keviny22, null, KevinYoung 20, Zack Walkingstick, zackwalkingstick@gmail.com, zackwalkingstick, no twitter, @zack From 1a04086463db0e8ea41f3a897196f672f2a8270c Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Wed, 15 Jan 2014 16:21:24 -0800 Subject: [PATCH 02/41] first commit --- .ruby-version | 2 +- week1/homework/questions.txt | 51 +++++++++++++++++++++++- week1/homework/strings_and_rspec_spec.rb | 14 ++++--- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/.ruby-version b/.ruby-version index c506e4e..9304515 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.0.0-p353 +ruby-2.1.0 diff --git a/week1/homework/questions.txt b/week1/homework/questions.txt index 2257bb9..c110442 100644 --- a/week1/homework/questions.txt +++ b/week1/homework/questions.txt @@ -3,13 +3,60 @@ Chapter 3 Classes, Objects, and Variables p.86-90 Strings (Strings section in Chapter 6 Standard Types) 1. What is an object? +In Ruby, objects are instances of the class which can be created using the +special method constructor called new. 2. What is a variable? +In Ruby, a variable is a name that is associated with a particular object; a +reference to an object +There are four types of variables, global, instance, local and constant 3. What is the difference between an object and a class? +Some may say they are the same thing, on object is just an instance of a +class. 4. What is a String? +Verbatim, “Ruby strings are simply sequences of characters. They normally hold +printable characters, but that is not a requirement; a string can also hold +binary data. Strings are objects of class String.“ -5. What are three messages that I can send to a string object? Hint: think methods +5. What are three messages that I can send to a string object? Hint: think +methods +You could use chop, delete, empty + +2.1.0 :010 > car="Ford F-150" + => "Ford F-150" +2.1.0 :011 > puts car.chop +Ford F-15 + => nil +2.1.0 :012 > +2.1.0 :013 > puts car.delete "150" +Ford F- + => nil +2.1.0 :014 > +2.1.0 :014 > puts car.empty? +false + => nil + + +6. What are two ways of defining a String literal? Bonus: What is the +difference between them? + +%q (single-quoted string) and %Q (double-quoted string) + +single-quoted string literals undergo the least substitution of the two, for +example. + + +2.1.0 :017 > car="ford" + => "ford" +2.1.0 :018 > model="f-150" + => "f-150" +2.1.0 :021 > puts %q{I drive an #{car}, #{model}} +I drive an #{car}, #{model} + => nil +2.1.0 :022 > puts %Q{I drive an #{car}, #{model}} +I drive an ford, f-150 + => nil +2.1.0 :023 > -6. What are two ways of defining a String literal? Bonus: What is the difference between them? diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index ea79e4c..0fd4cc8 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -12,14 +12,18 @@ before(:all) do @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" end - it "should be able to count the charaters" - it "should be able to split on the . charater" do - pending - result = #do something with @my_string here + + it "should be able to count the charaters" do + @my_string.should have(66).characters + end + + it "should be able to split on the . charater" do + result = @my_string.split('.') result.should have(2).items end + it "should be able to give the encoding of the string" do - pending 'helpful hint: should eq (Encoding.find("UTF-8"))' + @my_string.should eq (Encoding.find("UTF-8")) end end end From c40b45989db00ec7d8716da7729891b397379177 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 16 Jan 2014 10:15:28 -0800 Subject: [PATCH 03/41] finished spec --- week1/homework/strings_and_rspec_spec.rb | 31 ++++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index 0fd4cc8..6e2965f 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -8,23 +8,22 @@ # (Hint: You should do the reading on Strings first) describe String do - context "When a string is defined" do - before(:all) do - @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" - end - - it "should be able to count the charaters" do - @my_string.should have(66).characters - end + context "When a string is defined" do + before(:all) do + @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" + end + + it "should be able to count the charaters" do + @my_string.should have(66).characters + end - it "should be able to split on the . charater" do - result = @my_string.split('.') - result.should have(2).items - end + it "should be able to split on the . charater" do + @my_string.split('.').should have(2).items + end - it "should be able to give the encoding of the string" do - @my_string.should eq (Encoding.find("UTF-8")) - end - end + it "should be able to give the encoding of the string" do + @my_string.encoding.should eq (Encoding.find("UTF-8")) + end + end end From 8b442af0564a8e5f0bf458fe55ff12e38fa29d3e Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 23 Jan 2014 11:46:15 -0800 Subject: [PATCH 04/41] week2 --- week2/homework/questions.txt | 22 ++++++++++++++++++++++ week2/homework/simon_says.rb | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 week2/homework/simon_says.rb diff --git a/week2/homework/questions.txt b/week2/homework/questions.txt index 939e42d..343b96d 100644 --- a/week2/homework/questions.txt +++ b/week2/homework/questions.txt @@ -3,11 +3,33 @@ Containers, Blocks, and Iterators Sharing Functionality: Inheritance, Modules, and Mixins 1. What is the difference between a Hash and an Array? +A hash uses a key value pair, which is benifitial if you need to do lookups on +either. usually used when you have a one to one relationship, ex. +FirstName=Joe +LastName=Smith + +With an array, its is just a listing where each element in the array is +associated by an numerical index. This is useful if you have a listing of the +same times of items, ex. +Kids=sally,bobby,fred 2. When would you use an Array over a Hash and vice versa? +I use a hash when i would need to lookup a value based on its key, or vice +versa. 3. What is a module? Enumerable is a built in Ruby module, what is it? +a way of grouping together methods, classes, and constants +an enumerable is a standard mixin, which combines a bunch of methods, i like +the map enumerable which makes running blocks of code much cleaner 4. Can you inherit more than one thing in Ruby? How could you get around this problem? +use mixins 5. What is the difference between a Module and a Class? +ruby-doc.org says it best +Every class is also a module, but unlike modules a class may not be mixed-in +to another module (or class). Like a module, a class can be used as a +namespace. A class also inherits methods and constants from its superclass. +However, you can put a mix-in a module but not a class + + diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb new file mode 100644 index 0000000..5c57ab8 --- /dev/null +++ b/week2/homework/simon_says.rb @@ -0,0 +1,23 @@ +module SimonSays + def echo( statement ) + statement + end + + def shout( statement ) + statement.upcase + end + + def repeat( statement, amount = 2 ) + ([statement] * amount).join(" ") + end + + def start_of_word(statement, number) + statement[0, number] + end + + def first_word(statement) + a = statement.split + a[0] + end +end + From 3e66047871fc53af3fb2d63fc4c25ad6e97297f0 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 23 Jan 2014 11:59:12 -0800 Subject: [PATCH 05/41] week2_fixed spaces --- week2/homework/simon_says.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb index 5c57ab8..6677d03 100644 --- a/week2/homework/simon_says.rb +++ b/week2/homework/simon_says.rb @@ -1,13 +1,13 @@ module SimonSays - def echo( statement ) + def echo(statement) statement end - def shout( statement ) + def shout(statement) statement.upcase end - def repeat( statement, amount = 2 ) + def repeat(statement, amount = 2) ([statement] * amount).join(" ") end From 3a7c71ea82367d793f8ebe25336adf9f5d92e01b Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 6 Feb 2014 11:46:02 -0800 Subject: [PATCH 06/41] homework --- week3/homework/calculator.rb | 22 ++++++++++++++++++++++ week3/homework/questions.txt | 11 +++++++++++ week4/homework/questions.txt | 8 +++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 week3/homework/calculator.rb diff --git a/week3/homework/calculator.rb b/week3/homework/calculator.rb new file mode 100644 index 0000000..4d9e891 --- /dev/null +++ b/week3/homework/calculator.rb @@ -0,0 +1,22 @@ +class Calculator + def sum(numbers) + return 0 unless numbers.any? + numbers.inject{|sum,x| sum + x} + end + + def multiply(*numbers) + return 0 unless numbers.any? + numbers.flatten.inject{|multiply,x| multiply * x} + end + + def pow(*numbers) + return 0 unless numbers.any? + numbers.inject{|pow,x| pow ** x} + end + + def fac(number) + return 1 if number == 1 + return 1 if number == 0 + number * fac(number-1) + end +end diff --git a/week3/homework/questions.txt b/week3/homework/questions.txt index dfb158d..f8f651d 100644 --- a/week3/homework/questions.txt +++ b/week3/homework/questions.txt @@ -5,11 +5,22 @@ Please Read: - Chapter 22 The Ruby Language: basic types (symbols), variables and constants 1. What is a symbol? +A Ruby symbol is an identifier corresponding to a string of characters, often a +name. 2. What is the difference between a symbol and a string? +Mostly that a symbol is immutable, 3. What is a block and how do I call a block? +a block is a chunk of code with a begining or an end. you can call a block +using do ... end or with curly braces 4. How do I pass a block to a method? What is the method signature? +use yield to pass a block to a method. +A method signature tells you how to use/call that method 5. Where would you use regular expressions? +As little as possible :) +Generally when you are trying to match patterns then specific text. Like if +you are trying to detect if something fits the pattern off a social security +number or ip address, etc... diff --git a/week4/homework/questions.txt b/week4/homework/questions.txt index 187b3d3..36e4824 100644 --- a/week4/homework/questions.txt +++ b/week4/homework/questions.txt @@ -3,12 +3,18 @@ Chapter 10 Basic Input and Output The Rake Gem: http://rake.rubyforge.org/ 1. How does Ruby read files? +Many lines are read at one time into a buffer 2. How would you output "Hello World!" to a file called my_output.txt? +File.open("my_output.txt", 'w') { |file| file.write("Hello World!") } 3. What is the Directory class and what is it used for? +The Dir class is used for listing directories and its contents, traversing +through directories and creating/deleting directories 4. What is an IO object? +An IO object is something returned from calling the IO class. 5. What is rake and what is it used for? What is a rake task? - +rake is best used for automating tasks, a rake task a specific action defined +in the rake file From faff9cb4e603608e7fa532c6638aeb6301ed17d6 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 6 Feb 2014 11:48:15 -0800 Subject: [PATCH 07/41] homework --- .idea/.name | 1 + .idea/RubyWinter2014.iml | 141 +++++ .idea/encodings.xml | 5 + .idea/misc.xml | 5 + .idea/modules.xml | 9 + .idea/scopes/scope_settings.xml | 5 + .idea/vcs.xml | 7 + .idea/workspace.xml | 685 ++++++++++++++++++++++ week4/class_materials/odd_number_kevin.rb | 14 + week4/homework/worker.rb | 6 + 10 files changed, 878 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/RubyWinter2014.iml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scopes/scope_settings.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 week4/class_materials/odd_number_kevin.rb create mode 100644 week4/homework/worker.rb diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..fdb70fb --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +RubyWinter2014 \ No newline at end of file diff --git a/.idea/RubyWinter2014.iml b/.idea/RubyWinter2014.iml new file mode 100644 index 0000000..f925dd8 --- /dev/null +++ b/.idea/RubyWinter2014.iml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ea782b3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..241ede5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..7143d06 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,685 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1389931367465 + 1389931367465 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/week2/exercises/book.rb + 4 + + + file://$PROJECT_DIR$/week3/homework/calculator.rb + 19 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week4/class_materials/odd_number_kevin.rb b/week4/class_materials/odd_number_kevin.rb new file mode 100644 index 0000000..b3e6998 --- /dev/null +++ b/week4/class_materials/odd_number_kevin.rb @@ -0,0 +1,14 @@ +class OddNumberKevin + def initialize value + @value = value + end + + def succ + return OddNumberKevin.new(@value + 2) if @value.odd? + OddNumberKevin.new(@value + 1) + end + + def <=> other + @value + end +end \ No newline at end of file diff --git a/week4/homework/worker.rb b/week4/homework/worker.rb new file mode 100644 index 0000000..8f67700 --- /dev/null +++ b/week4/homework/worker.rb @@ -0,0 +1,6 @@ +class Worker + def self.work n = 1 + n.times.inject(nil){yield} + end +end + From 7ad4856f430be0965efe097bc3bac4d8814f246c Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 12:31:28 -0800 Subject: [PATCH 08/41] updates --- midterm/.idea/.name | 1 + midterm/.idea/encodings.xml | 5 + midterm/.idea/midterm.iml | 105 ++++++ midterm/.idea/misc.xml | 5 + midterm/.idea/modules.xml | 9 + midterm/.idea/scopes/scope_settings.xml | 5 + midterm/.idea/vcs.xml | 7 + midterm/.idea/workspace.xml | 447 ++++++++++++++++++++++++ midterm/answers.txt | 71 ++++ midterm/even_number.rb | 16 + midterm/even_number_spec.rb | 20 ++ midterm/thanksgiving_dinner.rb | 34 ++ midterm/turkey.rb | 18 + 13 files changed, 743 insertions(+) create mode 100644 midterm/.idea/.name create mode 100644 midterm/.idea/encodings.xml create mode 100644 midterm/.idea/midterm.iml create mode 100644 midterm/.idea/misc.xml create mode 100644 midterm/.idea/modules.xml create mode 100644 midterm/.idea/scopes/scope_settings.xml create mode 100644 midterm/.idea/vcs.xml create mode 100644 midterm/.idea/workspace.xml create mode 100644 midterm/answers.txt create mode 100644 midterm/even_number.rb create mode 100644 midterm/even_number_spec.rb create mode 100644 midterm/thanksgiving_dinner.rb create mode 100644 midterm/turkey.rb diff --git a/midterm/.idea/.name b/midterm/.idea/.name new file mode 100644 index 0000000..dda36a8 --- /dev/null +++ b/midterm/.idea/.name @@ -0,0 +1 @@ +midterm \ No newline at end of file diff --git a/midterm/.idea/encodings.xml b/midterm/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/midterm/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/midterm/.idea/midterm.iml b/midterm/.idea/midterm.iml new file mode 100644 index 0000000..470f70a --- /dev/null +++ b/midterm/.idea/midterm.iml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/.idea/misc.xml b/midterm/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/midterm/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/midterm/.idea/modules.xml b/midterm/.idea/modules.xml new file mode 100644 index 0000000..cbe1fd7 --- /dev/null +++ b/midterm/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/midterm/.idea/scopes/scope_settings.xml b/midterm/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/midterm/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/midterm/.idea/vcs.xml b/midterm/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/midterm/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml new file mode 100644 index 0000000..5fbc307 --- /dev/null +++ b/midterm/.idea/workspace.xml @@ -0,0 +1,447 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1392852566659 + 1392852566659 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/answers.txt b/midterm/answers.txt new file mode 100644 index 0000000..46f9e32 --- /dev/null +++ b/midterm/answers.txt @@ -0,0 +1,71 @@ + - What are the three uses of the curly brackets {} in Ruby? +1. For string interpolation, ex + irb(main):001:0> name="fred" + => "fred" + irb(main):002:0> puts "Hello #{name}" + Hello fred + => nil + irb(main):003:0> + +2. They are the literal constructor for constructing a hash, ex. + irb(main):003:0> hash={"ford" => "mustang","dodge" => "charger"} + => {"ford"=>"mustang", "dodge"=>"charger"} + irb(main):004:0> puts hash + {"ford"=>"mustang", "dodge"=>"charger"} + => nil + irb(main):005:0> + +3. You can put a code block in curly braces to deliminate instead of using do/end + irb(main):006:0> array = [1,10,100] + => [1, 10, 100] + irb(main):008:0> puts array.map{|n|n+1} + 2 + 11 + 101 + => nil + irb(main):009:0> + + - What is a regular expression and what is a common use for them? + Regular Expressions can be used in Ruby to do pattern matching, substitution, pretty much any type of string manipulation. + + - What is the difference between how a String, a symbol, a FixNum, and a Float are stored in Ruby? + A symbol is a string that is stored as unique identifiers in memeory,meaning it is only stored once. + A string on the other hand can be changed so it is stored many times, making look ups take longer + A FixNum is stored as the value itself, in ruby 2.0 a float behaves like a FixNum + + - Are these two statements equivalent? Why or Why Not? + 1. x, y = "hello", "hello" + 2. x = y = "hello" + + Yes, in the sense that x = "hello" and y = "hello" in both cases. + +- What is the difference between a Range and an Array? + A range is sequential: a,b,c,d 1,2,3,4 etc + An array is a collection a,1,b,4,car,baby + +- Why would I use a Hash instead of an Array? + if you care about the relationship between a key and value a hash should be used. + if you just want to store a collection of things, an array should be used. + +- What is your favorite thing about Ruby so far? + It isn't strict on syntax, you dont have to declare everything + +- What is your least favorite thing about Ruby so far? + So many ways to do something, it turns into an artform especially when working in groups. it makes it more important to agree style. + + Programming Problems (10pts each): + - Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber. + - The EvenNumber class should: + - Only allow even numbers + - Get the next even number + - Compare even numbers + - Generate a range of even numbers +- Make the rspec tests in wish_list_spec.rb pass by writing a WishList class + - The WishList class should: + - Mixin Enumerable + - Define each so it returns wishes as strings with their index as part of the string + +Mid-Term Spec (50pts): +- Make the tests pass. + + diff --git a/midterm/even_number.rb b/midterm/even_number.rb new file mode 100644 index 0000000..507c4f6 --- /dev/null +++ b/midterm/even_number.rb @@ -0,0 +1,16 @@ +class EvenNumber + + def next(num) + return false if not num.even? + num + 2 + end + + def compare(num1,num2) + return false if not num.even? + return false if not num.even? + end + +end + +@evennumber = EvenNumber.new +puts @evennumber.next(3) diff --git a/midterm/even_number_spec.rb b/midterm/even_number_spec.rb new file mode 100644 index 0000000..bd9717a --- /dev/null +++ b/midterm/even_number_spec.rb @@ -0,0 +1,20 @@ +# - Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber. +# - The EvenNumber class should: +# - Only allow even numbers +# - Get the next even number +# - Compare even numbers +# - Generate a range of even numbers + +require "#{File.dirname(__FILE__)}/even_number" + +describe EvenNumber do + + before do + @evennumber = EvenNumber.new + end + + it "should only allow even numbers" do + @evennumber.should be_even + end + +end diff --git a/midterm/thanksgiving_dinner.rb b/midterm/thanksgiving_dinner.rb new file mode 100644 index 0000000..294f695 --- /dev/null +++ b/midterm/thanksgiving_dinner.rb @@ -0,0 +1,34 @@ +module Dinner;end +class ThanksgivingDinner + include Dinner + attr_accessor :menu, :guests + + def initialize(vegan) + @vegan = vegan + end + + def guests + end + + def seating_chart_size + 45 + end + + def menu + { :diet => :vegan, + :proteins => ["Tofurkey", "Hummus"], + :veggies => [:ginger_carrots , :potatoes, :yams], + :desserts => {:pies=>[:pumkin_pie], :other=>["Chocolate Moose"], :molds=>[:cranberry, :mango, :cherry]} + } + + end + + def whats_for_dinner + "Tonight we have proteins Tofurkey and Hummus, and veggies Ginger Carrots, Potatoes, and Yams." + end + + def whats_for_dessert + "Tonight we have 5 delicious desserts: Pumkin Pie, Chocolate Moose, and 3 molds: Cranberry and Mango and Cherry." + end + +end diff --git a/midterm/turkey.rb b/midterm/turkey.rb new file mode 100644 index 0000000..8fff844 --- /dev/null +++ b/midterm/turkey.rb @@ -0,0 +1,18 @@ +module Animal;end + class Turkey + include Animal + + def initialize(weight) + @weight = weight + end + + def weight + @weight + end + + def gobble_speak(message) + if message == "Hello I Am a Turkey. Please Don't Eat Me." + "Gobble Gobble Gobble gobble Gobble. Gobble Gobb'le Gobble Gobble." + end + end + end From 44272bb277d01a9715de353c8861a4e9ef93ea29 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 15:23:45 -0800 Subject: [PATCH 09/41] updates --- midterm/.idea/midterm.iml | 37 ++++++++++ midterm/.idea/workspace.xml | 132 ++++++++++++++++++++++++------------ midterm/even_number.rb | 19 ++++-- midterm/even_number_spec.rb | 19 +++++- 4 files changed, 155 insertions(+), 52 deletions(-) diff --git a/midterm/.idea/midterm.iml b/midterm/.idea/midterm.iml index 470f70a..4801022 100644 --- a/midterm/.idea/midterm.iml +++ b/midterm/.idea/midterm.iml @@ -91,6 +91,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index 5fbc307..f89ab6b 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -12,9 +12,10 @@ + - - + + - + + @@ -393,51 +437,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/midterm/even_number.rb b/midterm/even_number.rb index 507c4f6..441bcc7 100644 --- a/midterm/even_number.rb +++ b/midterm/even_number.rb @@ -1,16 +1,23 @@ class EvenNumber def next(num) - return false if not num.even? + return false unless num.even? num + 2 end def compare(num1,num2) - return false if not num.even? - return false if not num.even? + return false unless num1.even? + return false unless num2.even? + true if num1 == num2 end + + def range(num1,num2) + return false unless num1.even? + return false unless num2.even? + (num1..num2).step(2) do |n| + n + end -end + end -@evennumber = EvenNumber.new -puts @evennumber.next(3) +end diff --git a/midterm/even_number_spec.rb b/midterm/even_number_spec.rb index bd9717a..ca9fe17 100644 --- a/midterm/even_number_spec.rb +++ b/midterm/even_number_spec.rb @@ -8,13 +8,28 @@ require "#{File.dirname(__FILE__)}/even_number" describe EvenNumber do - before do @evennumber = EvenNumber.new end it "should only allow even numbers" do - @evennumber.should be_even + @evennumber.next(3).should be_false + end + + it "should return the next even number" do + @evennumber.next(2).should equal 4 + end + + it "should compare even numbers" do + @evennumber.compare(2,2).should be_true + end + + it "should not return true of numbers are not the same" do + @evennumber.compare(2,4).should_not be_true + end + + it "should generate a range of even numbers" do + @evennumber.range(2,8).should be_a Range end end From de507333e9de5779d41495d3a9197cb7c302d570 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 16:01:33 -0800 Subject: [PATCH 10/41] updates --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 12560fe..2c0d3e4 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,4 @@ Week 10 [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/UWE-Ruby/rubywinter2014/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From 2f64efbcc126a42cd19665dfe65189b2fa653c35 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 19:05:26 -0800 Subject: [PATCH 11/41] updates --- midterm/.idea/workspace.xml | 74 +++++++++++++++--- week6/homework/hola_keviny22/hola-0.0.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/hola-0.1.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/hola.gemspec | 13 +++ .../hola_keviny22/hola_keviny22-0.1.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/lib/hola.rb | 5 ++ 6 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 week6/homework/hola_keviny22/hola-0.0.0.gem create mode 100644 week6/homework/hola_keviny22/hola-0.1.0.gem create mode 100644 week6/homework/hola_keviny22/hola.gemspec create mode 100644 week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem create mode 100644 week6/homework/hola_keviny22/lib/hola.rb diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index f89ab6b..d9aab8a 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -14,8 +14,8 @@ - + - @@ -169,6 +169,7 @@ + @@ -365,9 +366,9 @@ - - - + + + @@ -381,8 +382,8 @@ - - + + @@ -393,7 +394,7 @@ - + @@ -423,6 +424,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -481,7 +531,7 @@ - + diff --git a/week6/homework/hola_keviny22/hola-0.0.0.gem b/week6/homework/hola_keviny22/hola-0.0.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..5803344ed1f5514366ae7b776453496447e3b516 GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk4xgQ1bJfuX69v8kyUgMp#3iHRwL zf&r}@glukUaY8f@({lvJcp)zuyWbn$Np&~KQ)u<%4-nsBpy)7vTQ1pd$6c=;~t)>m80mh{XuH_pH3 zvuf3$%^UcBALGC8srqr&8UcB+psM9leQsG7T$*&?rZnev5vBM}_Zqw0`3xU9va;`O zkeFF!7twf={mHB}`9%#}_b;w3`*Cx9-l^+$7tV*WpJQz?|ArScFmS{75y@aYh!lLExon^wPc%rpAPm| zOk~{@B;9Clv@!g*&ziC+4evbGdh$K9lenu|wDZ_w!xMHrabK-#59El2XMVYm^6{0y zfj7FkMW>3EZRuEca#F#gh~EaLH#IKo6Sz?>E3ww%ve=7fZ{0UcQPEal{r8W#yMN_% zJ+(}qe9dD*l3arEUUygAd3{UY=q$Te`{|A6MSiJE{jOt+pcU+0s+jM5{LGIl}5+wO0uKUKjkM>`Vu<=3Swz%aaUi->ENhWL#x`<5E_#Tf8d>^=l<7}U)2r?6mcz#^9MTj|9@r% zjh-Yg1`d2~AC;p#1d=mSle3FUbBpyV6LWKDQwo5pMtt?ZiJ=Kv{cmDsFk1gp9=SxA zfXM%;6Rg9S4R~07&ruTR@V^%S^2H0w#+1_`CVN8W$h8Yqy*-zazy0>pzi&(L=wE-G zZeR3NIo@vH`|Aha6!WcrbMtmVX?nh6gmT70{s_aeV<-Qn$^HB~J9>si)T%;#vrQQe z?B^o)T)2Hi&KF?&a9WGIhnoLE%zW<{g%5yrx( z<9s#mo>Wb_T(bH@OV0hk7QpX`N{2 gU2s)qy1bCQ#-BxuLb%7 literal 0 HcmV?d00001 diff --git a/week6/homework/hola_keviny22/hola-0.1.0.gem b/week6/homework/hola_keviny22/hola-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..0aadb8e996a38a2c7ce71b75149dd11eeb417cd0 GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk56gQ1bJfuX69v8g#wouRRbi5Y`} z0j(T_Y;I|BNn#PuN#z--sX53JXlz3A5WgWjho*h7a^<@@7;2WY1v4=p4ff5yVj!^h z{Q4Q+E(P03eNEvE@oQKW$K}M-qI7(wFV8=Z+~p;$Ki>DueW%B9McZ@9jdQcj^Y8hr zT6Jji2EO0N_~SiQKh9bs@LnvaYWY;3Th;}aCLOpb&B-sKB;Q$oq~?Yl<0HW<*QS?p zcTdcG-YhyJ*(*9S6=&NN$ed;9x?L6hDzi2Qi0u4A_> zZug8OhI^Mva2ty#?whj9v+~o{_>@`vlla<`=c|4>Z}KgVIjX30wzQx1GN&~^?CO6$ znlruf^PQL{uV*}8wD(7_lit7mr*7=%ikCSfY`ro0pg32{e$}$lKG`yRM{>2> z(fjptguie-%390AQ+fEUZL`arotM}AVNy(ft<}a%r33}e`@kG9kon)p#0WkA8=IPp z=6@+pcU*Z@#kxN5x<~7VzOawK%HEvsf1Ay`kl!g| zazBgG=Zde6Il}HgM1x$muVb#VPE%U!xOG;@{a5#%*e%^^*1%G~VcF4RHm9D=eCm9E z`>(>ClXrCca<Pd`|EUwKH;FiKxPFd2nvT*+(e4o6^jbCx(`<0#3ufP8K zk}JFtG{04oHBJO&kJ_R?M|~UC+)eT{<$xHevI-d zw)as-+E4mrG;P&hrx#+{@=f^PbuEwom2)K{Iu_~WoW2sKyFqa6D~r3ma;~%PoZNY{ zsx)bW4x4$9ird+hUf)FZZhC2Q3P(NME_&vnNz@V}=auCyUY(jP52n?B_mL0c mHfQ$fnL>8rO^=St&taDmU&Kg6V2vsn4S~@R7!8486aoP7)$yqS literal 0 HcmV?d00001 diff --git a/week6/homework/hola_keviny22/hola.gemspec b/week6/homework/hola_keviny22/hola.gemspec new file mode 100644 index 0000000..605a448 --- /dev/null +++ b/week6/homework/hola_keviny22/hola.gemspec @@ -0,0 +1,13 @@ +Gem::Specification.new do |s| + s.name = 'hola_keviny22' + s.version = '0.1.0' + s.date = '2014-02-20' + s.summary = "Hola!" + s.description = "A simple hello world gem" + s.authors = ["Kevin Young"] + s.email = 'kevin@young.net' + s.files = ["lib/hola.rb"] + s.homepage = + 'http://rubygems.org/gems/hola_keviny22' + s.license = 'MIT' +end diff --git a/week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem b/week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..43e23bf60c1363b5e2360775ccc080cb4242ca6e GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk4pgQ1bJfuX69iHV^xgMp#3iHQM& zf&r}@glukUaY8f@({lvJcp)zuyWWKnlmFiLQjcwG7^oo0x(goR1f% zIkmS;(>uA!TXXG+4MHEYS4vNHkNvIixn@C$h0JfKh4sren$KRWI(_HPk6V&8j&#lc zJYE0XO`X}#pDkLGJg@uPBhA*JKlMvDCa$e2H1L0Oq|0@`lfob0jjOHay<4Kb{O%Fi z+nd9Gedf2?8Rr`9rM-F>enKF2Eo;^7^hMImnKREU-FmIyU3wam%8zE%vw5c$uW@v- z|5Cg9{dDV&-Mgl2I4vHaSS4xD$>%Hanfv3;Gn}veLX_7P2Gy_nyx*qgE0;#sB8|Rm zV8Z_YpP7MAda4iu2Y$zo%2FHx$r-81*~O)~#d?*AxjD2c1wd6JzWU$9&g4Lw=+p-hHa4dT7Ee>JHZuSBeP}CMYx=g_TgBNcelz$ zZu|G`;Waz&zW@JAQuO?f&)+{kmCNp)XKTGiS=Vz0x1f|$_D-=V#?+WQ=AV1|^ZClT zwL&zuPMXrFdwCo8xiz_VCtp4KzgGIX{(7C(y}N{Gg;_3s{cV?9O@f*F`=jh`eB9IG z_wxz!JYL6qA$6S{mt%MP>|J7+$L(hQzQS-WCerD3&Xfg7?@v95DNrk3^D+Ir Date: Thu, 6 Mar 2014 21:17:33 -0800 Subject: [PATCH 12/41] updates --- .ruby-version | 1 - midterm/.idea/workspace.xml | 130 ++++++++++++++++++++++++++++++++--- week7/homework/questions.txt | 8 ++- 3 files changed, 128 insertions(+), 11 deletions(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 9304515..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.1.0 diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index d9aab8a..ac8ca6d 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -14,8 +14,8 @@ - + - @@ -142,6 +142,7 @@ + @@ -162,7 +163,6 @@ - @@ -357,6 +357,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -382,7 +445,7 @@ - + @@ -398,11 +461,11 @@ - + - + @@ -424,6 +487,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -531,7 +643,7 @@ - + diff --git a/week7/homework/questions.txt b/week7/homework/questions.txt index d55387d..1445b22 100644 --- a/week7/homework/questions.txt +++ b/week7/homework/questions.txt @@ -1,9 +1,15 @@ - Please Read Chapters 23 and 24 DuckTyping and MetaProgramming Questions: 1. What is method_missing and how can it be used? +This missing_method is a built in Ruby hook method that is called when a method cannot be found. It raises an exception eith NoMethodError or NameError. +The missing_method can be overridden in your own class by writing your own missing_method in that class with your own behavior defined in that method. + 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? +An eigenclass (aka singleton class, aka anonymous class, aka. metaclass) is defined as 'an exclusive stash of methods, tailormade for that object and not shared with other objects' and can be used to define a class method. +REF: The Well Grounded Rubyist, by David A. Black + +A singletome method (aks class method) lives in the singleton class 3. When would you use DuckTypeing? How would you use it to improve your code? 4. What is the difference between a class method and an instance method? What is the difference between instance_eval and class_eval? 5. What is the difference between a singleton class and a singleton method? From c21262d48335561d9e946877c626c67261d622b1 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Tue, 11 Mar 2014 22:35:32 -0700 Subject: [PATCH 13/41] Final --- week7/homework/.idea/.name | 1 + week7/homework/.idea/encodings.xml | 5 + week7/homework/.idea/homework.iml | 162 ++++ week7/homework/.idea/misc.xml | 5 + week7/homework/.idea/modules.xml | 9 + .../homework/.idea/scopes/scope_settings.xml | 5 + week7/homework/.idea/vcs.xml | 7 + week7/homework/.idea/workspace.xml | 815 ++++++++++++++++++ .../features/step_definitions/pirate.rb | 10 + .../step_definitions/tic-tac-toe-steps.rb | 6 +- .../features/step_definitions/tic-tac-toe.rb | 126 +++ week7/homework/play_game.rb | 2 +- week7/homework/play_game.rb.orig | 22 + 13 files changed, 1171 insertions(+), 4 deletions(-) create mode 100644 week7/homework/.idea/.name create mode 100644 week7/homework/.idea/encodings.xml create mode 100644 week7/homework/.idea/homework.iml create mode 100644 week7/homework/.idea/misc.xml create mode 100644 week7/homework/.idea/modules.xml create mode 100644 week7/homework/.idea/scopes/scope_settings.xml create mode 100644 week7/homework/.idea/vcs.xml create mode 100644 week7/homework/.idea/workspace.xml create mode 100644 week7/homework/features/step_definitions/pirate.rb create mode 100644 week7/homework/features/step_definitions/tic-tac-toe.rb create mode 100644 week7/homework/play_game.rb.orig diff --git a/week7/homework/.idea/.name b/week7/homework/.idea/.name new file mode 100644 index 0000000..158b7eb --- /dev/null +++ b/week7/homework/.idea/.name @@ -0,0 +1 @@ +homework \ No newline at end of file diff --git a/week7/homework/.idea/encodings.xml b/week7/homework/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/week7/homework/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/homework/.idea/homework.iml b/week7/homework/.idea/homework.iml new file mode 100644 index 0000000..8057322 --- /dev/null +++ b/week7/homework/.idea/homework.iml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/homework/.idea/misc.xml b/week7/homework/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/week7/homework/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/homework/.idea/modules.xml b/week7/homework/.idea/modules.xml new file mode 100644 index 0000000..f766474 --- /dev/null +++ b/week7/homework/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/week7/homework/.idea/scopes/scope_settings.xml b/week7/homework/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/week7/homework/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/week7/homework/.idea/vcs.xml b/week7/homework/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/week7/homework/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/week7/homework/.idea/workspace.xml b/week7/homework/.idea/workspace.xml new file mode 100644 index 0000000..640c120 --- /dev/null +++ b/week7/homework/.idea/workspace.xml @@ -0,0 +1,815 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394167333043 + 1394167333043 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/features/step_definitions/tic-tac-toe.rb + 47 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/homework/features/step_definitions/pirate.rb b/week7/homework/features/step_definitions/pirate.rb new file mode 100644 index 0000000..424db3b --- /dev/null +++ b/week7/homework/features/step_definitions/pirate.rb @@ -0,0 +1,10 @@ +class PirateTranslator + def say(str) + @reply = "Ahoy Matey" + end + + def translate + @reply + "\n Shiber Me Timbers You Scurvey Dogs!!" + + end +end diff --git a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb b/week7/homework/features/step_definitions/tic-tac-toe-steps.rb index a3287c1..b404f38 100644 --- a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb +++ b/week7/homework/features/step_definitions/tic-tac-toe-steps.rb @@ -100,8 +100,8 @@ :A1 => :X, :A2 => :O, :A3 => :X, :B1 => :X, :B2 => :O, :B3 => :X, :C1 => :O, :C2 => :X, :C3 => :O - } - @game.determine_winner + } + @game.determine_winner end When /^there are no open spaces left on the board$/ do @@ -121,4 +121,4 @@ @game.board[arg1.to_sym] = ' ' @game.should_receive(:get_player_move).twice.and_return(@taken_spot, arg1) @game.player_move.should eq arg1.to_sym -end +end \ No newline at end of file diff --git a/week7/homework/features/step_definitions/tic-tac-toe.rb b/week7/homework/features/step_definitions/tic-tac-toe.rb new file mode 100644 index 0000000..c7806df --- /dev/null +++ b/week7/homework/features/step_definitions/tic-tac-toe.rb @@ -0,0 +1,126 @@ +class TicTacToe + + SYMBOLS = [:X,:O] + + + attr_accessor :player, :board + def initialize current_player=nil, player_s=nil + @current_player = current_player || [:player, :computer].sample + choose_symbols(player_s) + + @board = { + :A1=>" ",:A2=>" ",:A3=>" ", + :B1=>" ",:B2=>" ",:B3=>" ", + :C1=>" ",:C2=>" ",:C3=>" " + } + end + + + def welcome_player + "Welcome #{@player}" + end + + def current_player + {:computer => "Computer", :player => @player}[@current_player] + end + + def over? + false if spots_open? + true if player_won? + end + + def computer_move + + spot = open_spots.sample + @board[spot] = computer_symbol + @current_player = :player + end + + def indicate_palyer_turn + puts "#{@player}'s Move:" + #get_player_move + end + + def player_move + spot = get_player_move.to_sym + until open_spots.include?(spot) + puts "That spot is taken, please enter another spot:" + spot = get_player_move.to_sym + end + @board[spot] = player_symbol + + @current_player = :computer + spot + end + + def current_state + ret = " 1 | 2 | 3\n" + ret << "A | #{@board[:A1]}| #{@board[:A2]}| #{@board[:A3]}\n" + ret << "---|---|---|---\n" + ret << "B | #{@board[:B1]}| #{@board[:B2]}| #{@board[:B3]}\n" + ret << "---|---|---|---\n" + ret << "C | #{@board[:C1]}| #{@board[:C2]}| #{@board[:C3]}\n" + + end + + def determine_winner + true unless spots_open? + + if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + @winner = @board[:A1] + elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] + @winner = @board[:A2] + elsif @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + @winner = @board[:C1] + elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] + @winner = @board[:C1] + elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] + @winner = @board[:C1] + elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] + @winner = @board[:C1] + else + draw? + end + over? + end + + def player_won? + true if @winner = @player_symbol[:player] + end + + def draw? + true + end + + def player_symbol + @player_symbol[:player] + end + + def computer_symbol + @player_symbol[:computer] + end + + def get_player_move + gets.chomp + end + + def spots_open? + true if @board.values.any?{|v| v == " "} + end + + def open_spots + spots = Array.new + @board.each do |key, value| + if value == " " + spots << key + end + end + spots + end + + def choose_symbols(player_s) + player_s ||=SYMBOLS.sample + @player_symbol = {:computer => SYMBOLS.reject{|s| s==player_s}.first, :player => player_s} + end + +end diff --git a/week7/homework/play_game.rb b/week7/homework/play_game.rb index 0535830..7b99f10 100644 --- a/week7/homework/play_game.rb +++ b/week7/homework/play_game.rb @@ -10,7 +10,7 @@ when "Computer" @game.computer_move when @game.player - @game.indicate_palyer_turn + @game.indicate_player_turn @game.player_move end puts @game.current_state diff --git a/week7/homework/play_game.rb.orig b/week7/homework/play_game.rb.orig new file mode 100644 index 0000000..0535830 --- /dev/null +++ b/week7/homework/play_game.rb.orig @@ -0,0 +1,22 @@ +require './features/step_definitions/tic-tac-toe.rb' + +@game = TicTacToe.new +puts "What is your name?" +@game.player = gets.chomp +puts @game.welcome_player + +until @game.over? + case @game.current_player + when "Computer" + @game.computer_move + when @game.player + @game.indicate_palyer_turn + @game.player_move + end + puts @game.current_state + @game.determine_winner +end + +puts "You Won!" if @game.player_won? +puts "I Won!" if @game.computer_won? +puts "DRAW!" if @game.draw? From 8780a9e5ac9a6fb6c01aaf01ce7768fc26dd6053 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Tue, 11 Mar 2014 22:36:12 -0700 Subject: [PATCH 14/41] Final --- week7/homework/play_game.rb.orig | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 week7/homework/play_game.rb.orig diff --git a/week7/homework/play_game.rb.orig b/week7/homework/play_game.rb.orig deleted file mode 100644 index 0535830..0000000 --- a/week7/homework/play_game.rb.orig +++ /dev/null @@ -1,22 +0,0 @@ -require './features/step_definitions/tic-tac-toe.rb' - -@game = TicTacToe.new -puts "What is your name?" -@game.player = gets.chomp -puts @game.welcome_player - -until @game.over? - case @game.current_player - when "Computer" - @game.computer_move - when @game.player - @game.indicate_palyer_turn - @game.player_move - end - puts @game.current_state - @game.determine_winner -end - -puts "You Won!" if @game.player_won? -puts "I Won!" if @game.computer_won? -puts "DRAW!" if @game.draw? From 620b90d28391ebf7a258504cf3499a8a812249a3 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Wed, 12 Mar 2014 14:58:38 -0700 Subject: [PATCH 15/41] updates --- .version | 1 + cookbook-reader/.idea/.name | 1 + cookbook-reader/.idea/cookbook-reader.iml | 35 ++ cookbook-reader/.idea/encodings.xml | 5 + cookbook-reader/.idea/misc.xml | 5 + cookbook-reader/.idea/modules.xml | 9 + .../.idea/scopes/scope_settings.xml | 5 + cookbook-reader/.idea/vcs.xml | 7 + cookbook-reader/.idea/workspace.xml | 354 +++++++++++++++ cookbook-reader/bin/cookbook-reader | 5 + .../lib/cookbook-reader/options.rb | 37 ++ cookbook-reader/lib/cookbook-reader/parser.rb | 62 +++ week7/exercises/hello/.idea/.name | 1 + week7/exercises/hello/.idea/encodings.xml | 5 + week7/exercises/hello/.idea/hello.iml | 50 +++ week7/exercises/hello/.idea/misc.xml | 5 + week7/exercises/hello/.idea/modules.xml | 9 + .../hello/.idea/scopes/scope_settings.xml | 5 + week7/exercises/hello/.idea/vcs.xml | 7 + week7/exercises/hello/.idea/workspace.xml | 421 ++++++++++++++++++ .../hello/features/greeter_says_hello.feature | 10 + .../step_definitions/greeter_steps.rb | 17 + week7/exercises/hello/spec/greeter_spec.rb | 14 + week7/homework/.idea/workspace.xml | 86 ++-- .../features/step_definitions/tic-tac-toe.rb | 37 +- week7/homework/play_game.rb | 2 +- 26 files changed, 1133 insertions(+), 62 deletions(-) create mode 100644 .version create mode 100644 cookbook-reader/.idea/.name create mode 100644 cookbook-reader/.idea/cookbook-reader.iml create mode 100644 cookbook-reader/.idea/encodings.xml create mode 100644 cookbook-reader/.idea/misc.xml create mode 100644 cookbook-reader/.idea/modules.xml create mode 100644 cookbook-reader/.idea/scopes/scope_settings.xml create mode 100644 cookbook-reader/.idea/vcs.xml create mode 100644 cookbook-reader/.idea/workspace.xml create mode 100644 cookbook-reader/bin/cookbook-reader create mode 100644 cookbook-reader/lib/cookbook-reader/options.rb create mode 100644 cookbook-reader/lib/cookbook-reader/parser.rb create mode 100644 week7/exercises/hello/.idea/.name create mode 100644 week7/exercises/hello/.idea/encodings.xml create mode 100644 week7/exercises/hello/.idea/hello.iml create mode 100644 week7/exercises/hello/.idea/misc.xml create mode 100644 week7/exercises/hello/.idea/modules.xml create mode 100644 week7/exercises/hello/.idea/scopes/scope_settings.xml create mode 100644 week7/exercises/hello/.idea/vcs.xml create mode 100644 week7/exercises/hello/.idea/workspace.xml create mode 100644 week7/exercises/hello/features/greeter_says_hello.feature create mode 100644 week7/exercises/hello/features/step_definitions/greeter_steps.rb create mode 100644 week7/exercises/hello/spec/greeter_spec.rb diff --git a/.version b/.version new file mode 100644 index 0000000..9304515 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +ruby-2.1.0 diff --git a/cookbook-reader/.idea/.name b/cookbook-reader/.idea/.name new file mode 100644 index 0000000..5d5341c --- /dev/null +++ b/cookbook-reader/.idea/.name @@ -0,0 +1 @@ +cookbook-reader \ No newline at end of file diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml new file mode 100644 index 0000000..b8d0590 --- /dev/null +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/encodings.xml b/cookbook-reader/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/cookbook-reader/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/cookbook-reader/.idea/misc.xml b/cookbook-reader/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/cookbook-reader/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/cookbook-reader/.idea/modules.xml b/cookbook-reader/.idea/modules.xml new file mode 100644 index 0000000..8731703 --- /dev/null +++ b/cookbook-reader/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/cookbook-reader/.idea/scopes/scope_settings.xml b/cookbook-reader/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/cookbook-reader/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cookbook-reader/.idea/vcs.xml b/cookbook-reader/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/cookbook-reader/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml new file mode 100644 index 0000000..f3fd295 --- /dev/null +++ b/cookbook-reader/.idea/workspace.xml @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394649021318 + 1394649021318 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/lib/cookbook-reader/parser.rb + 41 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/bin/cookbook-reader b/cookbook-reader/bin/cookbook-reader new file mode 100644 index 0000000..fbca8a3 --- /dev/null +++ b/cookbook-reader/bin/cookbook-reader @@ -0,0 +1,5 @@ +#! /usr/bin/ruby +require 'cookbook-reader/parser' +parser = CookbookReader::Parser.new(ARGV) +parser.parse +parser.display_data diff --git a/cookbook-reader/lib/cookbook-reader/options.rb b/cookbook-reader/lib/cookbook-reader/options.rb new file mode 100644 index 0000000..cf26748 --- /dev/null +++ b/cookbook-reader/lib/cookbook-reader/options.rb @@ -0,0 +1,37 @@ +require 'optparse' + +module CookbookReader + class Options + + attr_reader :path_to_search + + def initialize(argv) + parse(argv) + end + + private + + def parse(argv) + OptionParser.new do |opts| + opts.banner = "Usage: cookbook-reader --path path ..." + + opts.on("-p", "--path path", String, "Path to search") do |path| + @path_to_search = path + end + + opts.on("-h", "--help", "Show this message") do + puts opts + exit + end + + begin + argv = ["-h"] if argv.empty? + opts.parse!(argv) + rescue OptionParser::ParseError => e + STDERR.puts e.message, "\n", opts + exit(-1) + end + end + end + end +end diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb new file mode 100644 index 0000000..2108a9d --- /dev/null +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -0,0 +1,62 @@ +require_relative 'options' +module CookbookReader + class Parser + def initialize(argv) + @options = Options.new(argv) + @top_list = [] + end + + def run + finder = Finder.from_file(@options.dictionary) + @options.words_to_find.each do |word| + anagrams = finder.lookup(word) + if anagrams + puts "Anagrams of #{word}: #{anagrams.join(', ')}" + else + puts "No anagrams of #{word} in #{@options.dictionary}" + end + end + end + + def parse + @metadata_list = Array.new + Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| + @metadata_list.push read_file filename + + + end + end + + def display_data + pp @top_list + end + + private + def read_file(filename) + @hash = {} + + @depends_list = {} + File.open(filename) do |fp| + fp.each do |line| + key, value = line.chomp.split(" ") + key = key.chomp('"').reverse.chomp('"').reverse + value = value.chomp('"').reverse.chomp('"').reverse + if key =~ /depends/ + @hash[key] = add_dependencies(line) + else + @hash[key] = value + end + end + end + @top_list.push @hash + + end + + def add_dependencies(line) + line.slice! "depends " + k, v = line.chomp.split(",") + @depends_list[k] = v + @depends_list + end + end +end diff --git a/week7/exercises/hello/.idea/.name b/week7/exercises/hello/.idea/.name new file mode 100644 index 0000000..b6fc4c6 --- /dev/null +++ b/week7/exercises/hello/.idea/.name @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/week7/exercises/hello/.idea/encodings.xml b/week7/exercises/hello/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/week7/exercises/hello/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/exercises/hello/.idea/hello.iml b/week7/exercises/hello/.idea/hello.iml new file mode 100644 index 0000000..ea67099 --- /dev/null +++ b/week7/exercises/hello/.idea/hello.iml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/exercises/hello/.idea/misc.xml b/week7/exercises/hello/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/week7/exercises/hello/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/exercises/hello/.idea/modules.xml b/week7/exercises/hello/.idea/modules.xml new file mode 100644 index 0000000..6e7c41b --- /dev/null +++ b/week7/exercises/hello/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/week7/exercises/hello/.idea/scopes/scope_settings.xml b/week7/exercises/hello/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/week7/exercises/hello/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/week7/exercises/hello/.idea/vcs.xml b/week7/exercises/hello/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/week7/exercises/hello/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/week7/exercises/hello/.idea/workspace.xml b/week7/exercises/hello/.idea/workspace.xml new file mode 100644 index 0000000..cfee28a --- /dev/null +++ b/week7/exercises/hello/.idea/workspace.xml @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394165119992 + 1394165119992 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/exercises/hello/features/greeter_says_hello.feature b/week7/exercises/hello/features/greeter_says_hello.feature new file mode 100644 index 0000000..8db8862 --- /dev/null +++ b/week7/exercises/hello/features/greeter_says_hello.feature @@ -0,0 +1,10 @@ +Feature: greater says hello + +In order to start learning RSpec and Cucumber +As a reader of the Rspec book +I want a greater to say hello + + Scenario: greeter says hello + Given a greeter + When I send it the greet message + Then I should see "Hello Cucumber!" diff --git a/week7/exercises/hello/features/step_definitions/greeter_steps.rb b/week7/exercises/hello/features/step_definitions/greeter_steps.rb new file mode 100644 index 0000000..fe7700e --- /dev/null +++ b/week7/exercises/hello/features/step_definitions/greeter_steps.rb @@ -0,0 +1,17 @@ +class CucumberGreeter + def greet + "Hello Cucumber!" + end +end + +Given /^a greeter$/ do + @greeter = CucumberGreeter.new +end + +When /^I send it the greet message$/ do + @message = @greeter.greet +end + +Then /^I should see "([^"]*)"$/ do |greeting| + @message.should == greeting +end diff --git a/week7/exercises/hello/spec/greeter_spec.rb b/week7/exercises/hello/spec/greeter_spec.rb new file mode 100644 index 0000000..a4eb1f1 --- /dev/null +++ b/week7/exercises/hello/spec/greeter_spec.rb @@ -0,0 +1,14 @@ +class RSpecGreeter + def greet + "Hello RSpec!" + end +end + +describe "RSpec Greeter" do + it "should say 'Hello RSpec!' when it receives the greet() message" do + greeter = RSpecGreeter.new + greeting = greeter.greet + greeting.should == "Hello RSpec!" + end +end + diff --git a/week7/homework/.idea/workspace.xml b/week7/homework/.idea/workspace.xml index 640c120..e7da4f1 100644 --- a/week7/homework/.idea/workspace.xml +++ b/week7/homework/.idea/workspace.xml @@ -12,11 +12,11 @@ + - - + - + - + - - + + - + - + - + - - + + - + @@ -132,8 +132,8 @@ @@ -225,7 +225,7 @@ - + @@ -488,7 +488,7 @@ - + @@ -496,7 +496,7 @@ - + @@ -528,11 +528,11 @@ file://$PROJECT_DIR$/features/step_definitions/tic-tac-toe.rb - 47 - - @@ -622,19 +622,14 @@ - - - - - - + - + - + @@ -651,14 +646,6 @@ - - - - - - - - @@ -770,42 +757,51 @@ - + - + + + - + - + - + - + - + - + - + - + + + + + + + + diff --git a/week7/homework/features/step_definitions/tic-tac-toe.rb b/week7/homework/features/step_definitions/tic-tac-toe.rb index c7806df..07237cd 100644 --- a/week7/homework/features/step_definitions/tic-tac-toe.rb +++ b/week7/homework/features/step_definitions/tic-tac-toe.rb @@ -26,7 +26,7 @@ def current_player def over? false if spots_open? - true if player_won? + true if player_won? || computer_won? end def computer_move @@ -38,7 +38,6 @@ def computer_move def indicate_palyer_turn puts "#{@player}'s Move:" - #get_player_move end def player_move @@ -64,32 +63,38 @@ def current_state end def determine_winner - true unless spots_open? + #return false if spots_open? - if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] && @board[:A1] != " " @winner = @board[:A1] - elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] + elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] && @board[:A2] != " " @winner = @board[:A2] - elsif @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] - @winner = @board[:C1] - elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] - @winner = @board[:C1] - elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] - @winner = @board[:C1] - elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] + elsif @board[:A3] == @board[:B3] && @board[:B3] == @board[:C3] && @board[:A3] != " " + @winner = @board[:A3] + elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] && @board[:A1] != " " + @winner = @board[:A1] + elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] && @board[:B1] != " " + @winner = @board[:B1] + elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] && @board[:C1] != " " @winner = @board[:C1] - else - draw? + #else + # @winner = "draw" end + #return false if spots_open? over? + true end def player_won? - true if @winner = @player_symbol[:player] + true if @winner == @player_symbol[:player] end def draw? - true + true unless player_won? || computer_won? + end + + def computer_won? + @winner == @player_symbol[:computer] end def player_symbol diff --git a/week7/homework/play_game.rb b/week7/homework/play_game.rb index 7b99f10..0535830 100644 --- a/week7/homework/play_game.rb +++ b/week7/homework/play_game.rb @@ -10,7 +10,7 @@ when "Computer" @game.computer_move when @game.player - @game.indicate_player_turn + @game.indicate_palyer_turn @game.player_move end puts @game.current_state From 8155e5fe693b1e9e08c64b558fb186867bc3237a Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:07:08 -0700 Subject: [PATCH 16/41] updtes --- .../.idea/.name | 0 .../.idea/cookbook-reader.iml | 70 +++ .../.idea/encodings.xml | 0 .../.idea/misc.xml | 0 .../.idea/modules.xml | 0 .../.idea/scopes/scope_settings.xml | 5 + .../.idea/vcs.xml | 0 cookbook-reader.orig/.idea/workspace.xml | 542 ++++++++++++++++++ cookbook-reader.orig/.ruby-gemset | 1 + cookbook-reader.orig/.ruby-version | 1 + cookbook-reader.orig/.travis.yml | 3 + cookbook-reader.orig/Gemfile | 3 + cookbook-reader.orig/Rakefile | 8 + cookbook-reader.orig/bin/cookbook-reader | 5 + .../lib/cookbook-reader/options.rb | 37 ++ .../lib/cookbook-reader/parser.rb | 82 +++ cookbook-reader.orig/spec/options_spec.rb | 9 + cookbook-reader.orig/spec/parser_spec.rb | 9 + cookbook-reader/.gitignore | 8 + cookbook-reader/.idea/cookbook-reader.iml | 143 +++++ cookbook-reader/.idea/workspace.xml | 488 ++++++++++++++-- cookbook-reader/.ruby-gemset | 1 + cookbook-reader/.ruby-version | 1 + cookbook-reader/.travis.yml | 3 + cookbook-reader/Gemfile | 3 + cookbook-reader/README.md | 7 + cookbook-reader/Rakefile | 7 + cookbook-reader/bin/cookbook-reader | 0 cookbook-reader/cookbook-reader.gemspec | 23 + cookbook-reader/lib/cookbook-reader/parser.rb | 34 +- cookbook-reader/spec/options_spec.rb | 19 + cookbook-reader/spec/parser_spec.rb | 15 + cookbook-reader/spec/spec_helper.rb | 12 + 33 files changed, 1481 insertions(+), 58 deletions(-) rename {cookbook-reader => cookbook-reader.orig}/.idea/.name (100%) create mode 100644 cookbook-reader.orig/.idea/cookbook-reader.iml rename {cookbook-reader => cookbook-reader.orig}/.idea/encodings.xml (100%) rename {cookbook-reader => cookbook-reader.orig}/.idea/misc.xml (100%) rename {cookbook-reader => cookbook-reader.orig}/.idea/modules.xml (100%) create mode 100644 cookbook-reader.orig/.idea/scopes/scope_settings.xml rename {cookbook-reader => cookbook-reader.orig}/.idea/vcs.xml (100%) create mode 100644 cookbook-reader.orig/.idea/workspace.xml create mode 100644 cookbook-reader.orig/.ruby-gemset create mode 100644 cookbook-reader.orig/.ruby-version create mode 100644 cookbook-reader.orig/.travis.yml create mode 100644 cookbook-reader.orig/Gemfile create mode 100644 cookbook-reader.orig/Rakefile create mode 100644 cookbook-reader.orig/bin/cookbook-reader create mode 100644 cookbook-reader.orig/lib/cookbook-reader/options.rb create mode 100644 cookbook-reader.orig/lib/cookbook-reader/parser.rb create mode 100644 cookbook-reader.orig/spec/options_spec.rb create mode 100644 cookbook-reader.orig/spec/parser_spec.rb create mode 100644 cookbook-reader/.gitignore create mode 100644 cookbook-reader/.ruby-gemset create mode 100644 cookbook-reader/.ruby-version create mode 100644 cookbook-reader/.travis.yml create mode 100644 cookbook-reader/Gemfile create mode 100644 cookbook-reader/README.md create mode 100644 cookbook-reader/Rakefile mode change 100644 => 100755 cookbook-reader/bin/cookbook-reader create mode 100644 cookbook-reader/cookbook-reader.gemspec create mode 100644 cookbook-reader/spec/options_spec.rb create mode 100644 cookbook-reader/spec/parser_spec.rb create mode 100644 cookbook-reader/spec/spec_helper.rb diff --git a/cookbook-reader/.idea/.name b/cookbook-reader.orig/.idea/.name similarity index 100% rename from cookbook-reader/.idea/.name rename to cookbook-reader.orig/.idea/.name diff --git a/cookbook-reader.orig/.idea/cookbook-reader.iml b/cookbook-reader.orig/.idea/cookbook-reader.iml new file mode 100644 index 0000000..2e175f9 --- /dev/null +++ b/cookbook-reader.orig/.idea/cookbook-reader.iml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/encodings.xml b/cookbook-reader.orig/.idea/encodings.xml similarity index 100% rename from cookbook-reader/.idea/encodings.xml rename to cookbook-reader.orig/.idea/encodings.xml diff --git a/cookbook-reader/.idea/misc.xml b/cookbook-reader.orig/.idea/misc.xml similarity index 100% rename from cookbook-reader/.idea/misc.xml rename to cookbook-reader.orig/.idea/misc.xml diff --git a/cookbook-reader/.idea/modules.xml b/cookbook-reader.orig/.idea/modules.xml similarity index 100% rename from cookbook-reader/.idea/modules.xml rename to cookbook-reader.orig/.idea/modules.xml diff --git a/cookbook-reader.orig/.idea/scopes/scope_settings.xml b/cookbook-reader.orig/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/cookbook-reader.orig/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cookbook-reader/.idea/vcs.xml b/cookbook-reader.orig/.idea/vcs.xml similarity index 100% rename from cookbook-reader/.idea/vcs.xml rename to cookbook-reader.orig/.idea/vcs.xml diff --git a/cookbook-reader.orig/.idea/workspace.xml b/cookbook-reader.orig/.idea/workspace.xml new file mode 100644 index 0000000..4bcc162 --- /dev/null +++ b/cookbook-reader.orig/.idea/workspace.xml @@ -0,0 +1,542 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394649021318 + 1394649021318 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader.orig/.ruby-gemset b/cookbook-reader.orig/.ruby-gemset new file mode 100644 index 0000000..1dfef02 --- /dev/null +++ b/cookbook-reader.orig/.ruby-gemset @@ -0,0 +1 @@ +cookbook-reader diff --git a/cookbook-reader.orig/.ruby-version b/cookbook-reader.orig/.ruby-version new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/cookbook-reader.orig/.ruby-version @@ -0,0 +1 @@ +2.1.0 diff --git a/cookbook-reader.orig/.travis.yml b/cookbook-reader.orig/.travis.yml new file mode 100644 index 0000000..938d4ef --- /dev/null +++ b/cookbook-reader.orig/.travis.yml @@ -0,0 +1,3 @@ +rvm: + - 2.1.0 +script: "rake spec" diff --git a/cookbook-reader.orig/Gemfile b/cookbook-reader.orig/Gemfile new file mode 100644 index 0000000..c80ee36 --- /dev/null +++ b/cookbook-reader.orig/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/cookbook-reader.orig/Rakefile b/cookbook-reader.orig/Rakefile new file mode 100644 index 0000000..23e6b46 --- /dev/null +++ b/cookbook-reader.orig/Rakefile @@ -0,0 +1,8 @@ +require "bundler/gem_tasks" +require 'rspec/core/rake_task' + +desc 'Run specs' + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = %w(--color) +end diff --git a/cookbook-reader.orig/bin/cookbook-reader b/cookbook-reader.orig/bin/cookbook-reader new file mode 100644 index 0000000..fbca8a3 --- /dev/null +++ b/cookbook-reader.orig/bin/cookbook-reader @@ -0,0 +1,5 @@ +#! /usr/bin/ruby +require 'cookbook-reader/parser' +parser = CookbookReader::Parser.new(ARGV) +parser.parse +parser.display_data diff --git a/cookbook-reader.orig/lib/cookbook-reader/options.rb b/cookbook-reader.orig/lib/cookbook-reader/options.rb new file mode 100644 index 0000000..cf26748 --- /dev/null +++ b/cookbook-reader.orig/lib/cookbook-reader/options.rb @@ -0,0 +1,37 @@ +require 'optparse' + +module CookbookReader + class Options + + attr_reader :path_to_search + + def initialize(argv) + parse(argv) + end + + private + + def parse(argv) + OptionParser.new do |opts| + opts.banner = "Usage: cookbook-reader --path path ..." + + opts.on("-p", "--path path", String, "Path to search") do |path| + @path_to_search = path + end + + opts.on("-h", "--help", "Show this message") do + puts opts + exit + end + + begin + argv = ["-h"] if argv.empty? + opts.parse!(argv) + rescue OptionParser::ParseError => e + STDERR.puts e.message, "\n", opts + exit(-1) + end + end + end + end +end diff --git a/cookbook-reader.orig/lib/cookbook-reader/parser.rb b/cookbook-reader.orig/lib/cookbook-reader/parser.rb new file mode 100644 index 0000000..f6727a5 --- /dev/null +++ b/cookbook-reader.orig/lib/cookbook-reader/parser.rb @@ -0,0 +1,82 @@ +require_relative 'options' +module CookbookReader + class Parser + def initialize(argv) + @options = Options.new(argv) + @top_list = [] + end + + def run + finder = Finder.from_file(@options.dictionary) + @options.words_to_find.each do |word| + anagrams = finder.lookup(word) + if anagrams + puts "Anagrams of #{word}: #{anagrams.join(', ')}" + else + puts "No anagrams of #{word} in #{@options.dictionary}" + end + end + end + + def parse + @metadata_list = Array.new + Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| + @metadata_list.push read_file filename + + + end + end + + def display_data + #pp @top_list + + @top_list.each do |element| + puts "Cookbook: #{element['name']}\n" + puts " Dependancies:" + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + puts "\n" + end + end + + private + def read_file(filename) + @hash = {} + + @depends_list = {} + File.open(filename) do |fp| + fp.each do |line| + key, value = line.chomp.split(" ") + key.strip! + value.strip! + key = key.chomp('"').reverse.chomp('"').reverse + value = value.chomp('"').reverse.chomp('"').reverse + + if key =~ /depends/ + @hash[key] = add_dependencies(line) + else + @hash[key] = value + end + end + end + @top_list.push @hash + + end + + def add_dependencies(line) + line.slice! "depends " + k, v = line.chomp.split(",") + v = "none" if v.nil? + k.strip! + v.strip! + v = v.chomp('"').reverse.chomp('"').reverse + v = v.chomp('"').reverse.chomp('"').reverse + k = k.chomp('"').reverse.chomp('"').reverse + k.strip! + v.strip! + @depends_list[k] = v + @depends_list + end + end +end diff --git a/cookbook-reader.orig/spec/options_spec.rb b/cookbook-reader.orig/spec/options_spec.rb new file mode 100644 index 0000000..eacccb6 --- /dev/null +++ b/cookbook-reader.orig/spec/options_spec.rb @@ -0,0 +1,9 @@ +require "../lib/cookbook-reader/options" + +describe CookbookReader::Options do + + it "executes a block and returns a string" do + pending + end + +end \ No newline at end of file diff --git a/cookbook-reader.orig/spec/parser_spec.rb b/cookbook-reader.orig/spec/parser_spec.rb new file mode 100644 index 0000000..4708c40 --- /dev/null +++ b/cookbook-reader.orig/spec/parser_spec.rb @@ -0,0 +1,9 @@ +require "../lib/cookbook-reader/parser" + +describe CookbookReader::Parser do + + it "executes a block and returns a string" do + pending + end + +end \ No newline at end of file diff --git a/cookbook-reader/.gitignore b/cookbook-reader/.gitignore new file mode 100644 index 0000000..f714d63 --- /dev/null +++ b/cookbook-reader/.gitignore @@ -0,0 +1,8 @@ +*.gem +.bundle +Gemfile.lock +pkg/* +coverage +*.swp +.idea/* +.DS_Store diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml index b8d0590..814918c 100644 --- a/cookbook-reader/.idea/cookbook-reader.iml +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -25,11 +25,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml index f3fd295..499517b 100644 --- a/cookbook-reader/.idea/workspace.xml +++ b/cookbook-reader/.idea/workspace.xml @@ -12,7 +12,11 @@ - + + + + + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -92,14 +132,38 @@ + + + + + + + + + Ruby + + + + + RubyResolve + + + + @@ -146,6 +210,20 @@ - + @@ -213,6 +291,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -236,12 +476,20 @@ - + + + + + - - + + + + + + @@ -255,20 +503,20 @@ - - + + - - + + - + - - - - - - + + + + + + @@ -295,18 +543,39 @@ - file://$PROJECT_DIR$/lib/cookbook-reader/parser.rb - 41 - - + + + + + + + + + + + + + + + + + + + + + @@ -321,30 +590,163 @@ + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.ruby-gemset b/cookbook-reader/.ruby-gemset new file mode 100644 index 0000000..1dfef02 --- /dev/null +++ b/cookbook-reader/.ruby-gemset @@ -0,0 +1 @@ +cookbook-reader diff --git a/cookbook-reader/.ruby-version b/cookbook-reader/.ruby-version new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/cookbook-reader/.ruby-version @@ -0,0 +1 @@ +2.1.0 diff --git a/cookbook-reader/.travis.yml b/cookbook-reader/.travis.yml new file mode 100644 index 0000000..938d4ef --- /dev/null +++ b/cookbook-reader/.travis.yml @@ -0,0 +1,3 @@ +rvm: + - 2.1.0 +script: "rake spec" diff --git a/cookbook-reader/Gemfile b/cookbook-reader/Gemfile new file mode 100644 index 0000000..c80ee36 --- /dev/null +++ b/cookbook-reader/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md new file mode 100644 index 0000000..c202db0 --- /dev/null +++ b/cookbook-reader/README.md @@ -0,0 +1,7 @@ +[![Build Status](https://secure.travis-ci.org/keviny22/cookbook-reader.png)](http://travis-ci.org/keviny22/cookbook-reader) + + +cookbook-reader +=============== + +A gem for reading a cookbook, for learning Ruby only diff --git a/cookbook-reader/Rakefile b/cookbook-reader/Rakefile new file mode 100644 index 0000000..c557124 --- /dev/null +++ b/cookbook-reader/Rakefile @@ -0,0 +1,7 @@ +require 'rspec/core/rake_task' + +desc 'Run specs' + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = %w(--color) +end diff --git a/cookbook-reader/bin/cookbook-reader b/cookbook-reader/bin/cookbook-reader old mode 100644 new mode 100755 diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec new file mode 100644 index 0000000..ec1ea32 --- /dev/null +++ b/cookbook-reader/cookbook-reader.gemspec @@ -0,0 +1,23 @@ +Gem::Specification.new do |s| + s.name = 'cookbook-reader' + s.version = '0.1.0' + s.date = '2014-03-12' + s.summary = "cookbook version parser" + s.description = "A gem that parses cookbook metadata" + s.authors = ["Kevin Young"] + s.email = 'kevin@young.net' + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] + + s.homepage = 'http://rubygems.org/gems/cookbook-reader' + s.license = 'MIT' + + s.add_development_dependency "fakefs", "~> 0.4.2" + s.add_development_dependency "rake" + s.add_development_dependency "rspec", "~> 2.13.0" + s.add_development_dependency "simplecov", "~> 0.7.1" + s.add_development_dependency "timecop", "~> 0.6.1" +end diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb index 2108a9d..72a74b3 100644 --- a/cookbook-reader/lib/cookbook-reader/parser.rb +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -6,29 +6,22 @@ def initialize(argv) @top_list = [] end - def run - finder = Finder.from_file(@options.dictionary) - @options.words_to_find.each do |word| - anagrams = finder.lookup(word) - if anagrams - puts "Anagrams of #{word}: #{anagrams.join(', ')}" - else - puts "No anagrams of #{word} in #{@options.dictionary}" - end - end - end - def parse @metadata_list = Array.new Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| @metadata_list.push read_file filename - - end end def display_data - pp @top_list + @top_list.each do |element| + puts "Cookbook: #{element['name']}\n" + puts " Dependancies:" + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + puts "\n" + end end private @@ -39,8 +32,11 @@ def read_file(filename) File.open(filename) do |fp| fp.each do |line| key, value = line.chomp.split(" ") + key.strip! + value.strip! key = key.chomp('"').reverse.chomp('"').reverse value = value.chomp('"').reverse.chomp('"').reverse + if key =~ /depends/ @hash[key] = add_dependencies(line) else @@ -55,6 +51,14 @@ def read_file(filename) def add_dependencies(line) line.slice! "depends " k, v = line.chomp.split(",") + v = "none" if v.nil? + k.strip! + v.strip! + v = v.chomp('"').reverse.chomp('"').reverse + v = v.chomp('"').reverse.chomp('"').reverse + k = k.chomp('"').reverse.chomp('"').reverse + k.strip! + v.strip! @depends_list[k] = v @depends_list end diff --git a/cookbook-reader/spec/options_spec.rb b/cookbook-reader/spec/options_spec.rb new file mode 100644 index 0000000..fd46607 --- /dev/null +++ b/cookbook-reader/spec/options_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module CookbookReader + describe Options do + + it "should call the given sub command" do + pending("I hate rpsec") + end + + it "should display help when passed --help" do + pending("I hate rpsec") + end + + it "should display help when passed nothing" do + pending("I hate rpsec") + end + + end +end diff --git a/cookbook-reader/spec/parser_spec.rb b/cookbook-reader/spec/parser_spec.rb new file mode 100644 index 0000000..fab5cbc --- /dev/null +++ b/cookbook-reader/spec/parser_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +module CookbookReader + describe Parser do + + it "should display the data" do + pending("I hate rpsec") + end + + it "should parse the data" do + pending("I hate rpsec") + end + + end +end \ No newline at end of file diff --git a/cookbook-reader/spec/spec_helper.rb b/cookbook-reader/spec/spec_helper.rb new file mode 100644 index 0000000..757b400 --- /dev/null +++ b/cookbook-reader/spec/spec_helper.rb @@ -0,0 +1,12 @@ + +require 'rubygems' +require 'bundler/setup' +require 'fakefs/safe' + + +require_relative '../lib/cookbook-reader/options' +require_relative '../lib/cookbook-reader/parser' + +['contexts'].each do |dir| + Dir[File.expand_path(File.join(File.dirname(__FILE__),dir,'*.rb'))].each {|f| require f} +end From 77d4184896dd096bd2962f3a17be715f3bc08e4a Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:31:41 -0700 Subject: [PATCH 17/41] updated_gemspec --- cookbook-reader/Gemfile | 2 +- cookbook-reader/cookbook-reader.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook-reader/Gemfile b/cookbook-reader/Gemfile index c80ee36..07177f9 100644 --- a/cookbook-reader/Gemfile +++ b/cookbook-reader/Gemfile @@ -1,3 +1,3 @@ source "http://rubygems.org" - +gem 'rspec', :require => 'spec' gemspec diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec index ec1ea32..716d2ee 100644 --- a/cookbook-reader/cookbook-reader.gemspec +++ b/cookbook-reader/cookbook-reader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'cookbook-reader' - s.version = '0.1.0' + s.version = '0.1.1' s.date = '2014-03-12' s.summary = "cookbook version parser" s.description = "A gem that parses cookbook metadata" From f13d274d17806e63c41b8e6064a7c33af619e375 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:41:00 -0700 Subject: [PATCH 18/41] updates --- .gitignore | 3 + cookbook-reader.orig/.idea/.name | 1 - .../.idea/cookbook-reader.iml | 70 --- cookbook-reader.orig/.idea/encodings.xml | 5 - cookbook-reader.orig/.idea/misc.xml | 5 - cookbook-reader.orig/.idea/modules.xml | 9 - .../.idea/scopes/scope_settings.xml | 5 - cookbook-reader.orig/.idea/vcs.xml | 7 - cookbook-reader.orig/.idea/workspace.xml | 542 ------------------ cookbook-reader.orig/.ruby-gemset | 1 - cookbook-reader.orig/.ruby-version | 1 - cookbook-reader.orig/.travis.yml | 3 - cookbook-reader.orig/Gemfile | 3 - cookbook-reader.orig/Rakefile | 8 - cookbook-reader.orig/bin/cookbook-reader | 5 - .../lib/cookbook-reader/options.rb | 37 -- .../lib/cookbook-reader/parser.rb | 82 --- cookbook-reader.orig/spec/options_spec.rb | 9 - cookbook-reader.orig/spec/parser_spec.rb | 9 - cookbook-reader/README.md | 13 +- 20 files changed, 15 insertions(+), 803 deletions(-) delete mode 100644 cookbook-reader.orig/.idea/.name delete mode 100644 cookbook-reader.orig/.idea/cookbook-reader.iml delete mode 100644 cookbook-reader.orig/.idea/encodings.xml delete mode 100644 cookbook-reader.orig/.idea/misc.xml delete mode 100644 cookbook-reader.orig/.idea/modules.xml delete mode 100644 cookbook-reader.orig/.idea/scopes/scope_settings.xml delete mode 100644 cookbook-reader.orig/.idea/vcs.xml delete mode 100644 cookbook-reader.orig/.idea/workspace.xml delete mode 100644 cookbook-reader.orig/.ruby-gemset delete mode 100644 cookbook-reader.orig/.ruby-version delete mode 100644 cookbook-reader.orig/.travis.yml delete mode 100644 cookbook-reader.orig/Gemfile delete mode 100644 cookbook-reader.orig/Rakefile delete mode 100644 cookbook-reader.orig/bin/cookbook-reader delete mode 100644 cookbook-reader.orig/lib/cookbook-reader/options.rb delete mode 100644 cookbook-reader.orig/lib/cookbook-reader/parser.rb delete mode 100644 cookbook-reader.orig/spec/options_spec.rb delete mode 100644 cookbook-reader.orig/spec/parser_spec.rb diff --git a/.gitignore b/.gitignore index e43b0f9..2e3dedd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +cookbooks +cookbook-reader.orig +cookbook-reader diff --git a/cookbook-reader.orig/.idea/.name b/cookbook-reader.orig/.idea/.name deleted file mode 100644 index 5d5341c..0000000 --- a/cookbook-reader.orig/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -cookbook-reader \ No newline at end of file diff --git a/cookbook-reader.orig/.idea/cookbook-reader.iml b/cookbook-reader.orig/.idea/cookbook-reader.iml deleted file mode 100644 index 2e175f9..0000000 --- a/cookbook-reader.orig/.idea/cookbook-reader.iml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader.orig/.idea/encodings.xml b/cookbook-reader.orig/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/cookbook-reader.orig/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/cookbook-reader.orig/.idea/misc.xml b/cookbook-reader.orig/.idea/misc.xml deleted file mode 100644 index 271c40f..0000000 --- a/cookbook-reader.orig/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/cookbook-reader.orig/.idea/modules.xml b/cookbook-reader.orig/.idea/modules.xml deleted file mode 100644 index 8731703..0000000 --- a/cookbook-reader.orig/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/cookbook-reader.orig/.idea/scopes/scope_settings.xml b/cookbook-reader.orig/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/cookbook-reader.orig/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/cookbook-reader.orig/.idea/vcs.xml b/cookbook-reader.orig/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/cookbook-reader.orig/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/cookbook-reader.orig/.idea/workspace.xml b/cookbook-reader.orig/.idea/workspace.xml deleted file mode 100644 index 4bcc162..0000000 --- a/cookbook-reader.orig/.idea/workspace.xml +++ /dev/null @@ -1,542 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1394649021318 - 1394649021318 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader.orig/.ruby-gemset b/cookbook-reader.orig/.ruby-gemset deleted file mode 100644 index 1dfef02..0000000 --- a/cookbook-reader.orig/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -cookbook-reader diff --git a/cookbook-reader.orig/.ruby-version b/cookbook-reader.orig/.ruby-version deleted file mode 100644 index 7ec1d6d..0000000 --- a/cookbook-reader.orig/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.1.0 diff --git a/cookbook-reader.orig/.travis.yml b/cookbook-reader.orig/.travis.yml deleted file mode 100644 index 938d4ef..0000000 --- a/cookbook-reader.orig/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -rvm: - - 2.1.0 -script: "rake spec" diff --git a/cookbook-reader.orig/Gemfile b/cookbook-reader.orig/Gemfile deleted file mode 100644 index c80ee36..0000000 --- a/cookbook-reader.orig/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "http://rubygems.org" - -gemspec diff --git a/cookbook-reader.orig/Rakefile b/cookbook-reader.orig/Rakefile deleted file mode 100644 index 23e6b46..0000000 --- a/cookbook-reader.orig/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -require "bundler/gem_tasks" -require 'rspec/core/rake_task' - -desc 'Run specs' - -RSpec::Core::RakeTask.new do |t| - t.rspec_opts = %w(--color) -end diff --git a/cookbook-reader.orig/bin/cookbook-reader b/cookbook-reader.orig/bin/cookbook-reader deleted file mode 100644 index fbca8a3..0000000 --- a/cookbook-reader.orig/bin/cookbook-reader +++ /dev/null @@ -1,5 +0,0 @@ -#! /usr/bin/ruby -require 'cookbook-reader/parser' -parser = CookbookReader::Parser.new(ARGV) -parser.parse -parser.display_data diff --git a/cookbook-reader.orig/lib/cookbook-reader/options.rb b/cookbook-reader.orig/lib/cookbook-reader/options.rb deleted file mode 100644 index cf26748..0000000 --- a/cookbook-reader.orig/lib/cookbook-reader/options.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'optparse' - -module CookbookReader - class Options - - attr_reader :path_to_search - - def initialize(argv) - parse(argv) - end - - private - - def parse(argv) - OptionParser.new do |opts| - opts.banner = "Usage: cookbook-reader --path path ..." - - opts.on("-p", "--path path", String, "Path to search") do |path| - @path_to_search = path - end - - opts.on("-h", "--help", "Show this message") do - puts opts - exit - end - - begin - argv = ["-h"] if argv.empty? - opts.parse!(argv) - rescue OptionParser::ParseError => e - STDERR.puts e.message, "\n", opts - exit(-1) - end - end - end - end -end diff --git a/cookbook-reader.orig/lib/cookbook-reader/parser.rb b/cookbook-reader.orig/lib/cookbook-reader/parser.rb deleted file mode 100644 index f6727a5..0000000 --- a/cookbook-reader.orig/lib/cookbook-reader/parser.rb +++ /dev/null @@ -1,82 +0,0 @@ -require_relative 'options' -module CookbookReader - class Parser - def initialize(argv) - @options = Options.new(argv) - @top_list = [] - end - - def run - finder = Finder.from_file(@options.dictionary) - @options.words_to_find.each do |word| - anagrams = finder.lookup(word) - if anagrams - puts "Anagrams of #{word}: #{anagrams.join(', ')}" - else - puts "No anagrams of #{word} in #{@options.dictionary}" - end - end - end - - def parse - @metadata_list = Array.new - Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| - @metadata_list.push read_file filename - - - end - end - - def display_data - #pp @top_list - - @top_list.each do |element| - puts "Cookbook: #{element['name']}\n" - puts " Dependancies:" - element['depends'].each do |name, version| - puts " #{name}, #{version}\n" - end - puts "\n" - end - end - - private - def read_file(filename) - @hash = {} - - @depends_list = {} - File.open(filename) do |fp| - fp.each do |line| - key, value = line.chomp.split(" ") - key.strip! - value.strip! - key = key.chomp('"').reverse.chomp('"').reverse - value = value.chomp('"').reverse.chomp('"').reverse - - if key =~ /depends/ - @hash[key] = add_dependencies(line) - else - @hash[key] = value - end - end - end - @top_list.push @hash - - end - - def add_dependencies(line) - line.slice! "depends " - k, v = line.chomp.split(",") - v = "none" if v.nil? - k.strip! - v.strip! - v = v.chomp('"').reverse.chomp('"').reverse - v = v.chomp('"').reverse.chomp('"').reverse - k = k.chomp('"').reverse.chomp('"').reverse - k.strip! - v.strip! - @depends_list[k] = v - @depends_list - end - end -end diff --git a/cookbook-reader.orig/spec/options_spec.rb b/cookbook-reader.orig/spec/options_spec.rb deleted file mode 100644 index eacccb6..0000000 --- a/cookbook-reader.orig/spec/options_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "../lib/cookbook-reader/options" - -describe CookbookReader::Options do - - it "executes a block and returns a string" do - pending - end - -end \ No newline at end of file diff --git a/cookbook-reader.orig/spec/parser_spec.rb b/cookbook-reader.orig/spec/parser_spec.rb deleted file mode 100644 index 4708c40..0000000 --- a/cookbook-reader.orig/spec/parser_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "../lib/cookbook-reader/parser" - -describe CookbookReader::Parser do - - it "executes a block and returns a string" do - pending - end - -end \ No newline at end of file diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md index c202db0..9dcc584 100644 --- a/cookbook-reader/README.md +++ b/cookbook-reader/README.md @@ -4,4 +4,15 @@ cookbook-reader =============== -A gem for reading a cookbook, for learning Ruby only +A gem for reading a cookbooks metadata, created for learning Ruby. +Currently displays all of the dependancies of all cookbooks in the path. + +Installation: + +`gem install cookbook-reader` + +Usage: + +cookbook-reader --path + + From 2318f9252720fb2e5f6c24f771bb15a9698af424 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 14:36:17 -0700 Subject: [PATCH 19/41] updates --- cookbook-reader/.gitignore | 1 - cookbook-reader/.idea/cookbook-reader.iml | 68 ++++---- cookbook-reader/.idea/workspace.xml | 165 +++++++++--------- cookbook-reader/README.md | 4 +- cookbook-reader/cookbook-reader.gemspec | 4 +- cookbook-reader/lib/cookbook-reader/parser.rb | 13 +- 6 files changed, 129 insertions(+), 126 deletions(-) diff --git a/cookbook-reader/.gitignore b/cookbook-reader/.gitignore index f714d63..0f43d20 100644 --- a/cookbook-reader/.gitignore +++ b/cookbook-reader/.gitignore @@ -1,6 +1,5 @@ *.gem .bundle -Gemfile.lock pkg/* coverage *.swp diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml index 814918c..e23f000 100644 --- a/cookbook-reader/.idea/cookbook-reader.iml +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -1,42 +1,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -45,7 +21,7 @@ - + @@ -56,22 +32,24 @@ + + - + - + - + @@ -80,7 +58,7 @@ - + @@ -91,9 +69,7 @@ - - @@ -134,6 +110,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml index 499517b..5be5391 100644 --- a/cookbook-reader/.idea/workspace.xml +++ b/cookbook-reader/.idea/workspace.xml @@ -15,7 +15,7 @@ - + @@ -30,15 +30,6 @@ - - - - - - - - - @@ -48,10 +39,10 @@ - + - + @@ -93,6 +84,15 @@ + + + + + + + + + @@ -135,9 +135,9 @@ @@ -266,43 +266,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + @@ -311,7 +287,7 @@ - + @@ -322,22 +298,24 @@ + + - + - + - + @@ -346,7 +324,7 @@ - + @@ -357,9 +335,7 @@ - - @@ -477,23 +453,39 @@ - + - - + + - + - + + @@ -504,18 +496,18 @@ - + - + - + @@ -547,11 +539,16 @@ 2 @@ -639,13 +636,6 @@ - - - - - - - @@ -681,72 +671,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md index 9dcc584..2936989 100644 --- a/cookbook-reader/README.md +++ b/cookbook-reader/README.md @@ -1,4 +1,6 @@ [![Build Status](https://secure.travis-ci.org/keviny22/cookbook-reader.png)](http://travis-ci.org/keviny22/cookbook-reader) +[![Gem Version](https://badge.fury.io/rb/cookbook-reader.png)](http://badge.fury.io/rb/cookbook-reader) +[![Code Climate](https://codeclimate.com/github/keviny22/cookbook-reader.png)](https://codeclimate.com/github/keviny22/cookbook-reader) cookbook-reader @@ -13,6 +15,6 @@ Installation: Usage: -cookbook-reader --path +cookbook-reader --path {path to cookbook directory} diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec index 716d2ee..eaeeab9 100644 --- a/cookbook-reader/cookbook-reader.gemspec +++ b/cookbook-reader/cookbook-reader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'cookbook-reader' - s.version = '0.1.1' + s.version = '0.1.2' s.date = '2014-03-12' s.summary = "cookbook version parser" s.description = "A gem that parses cookbook metadata" @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.homepage = 'http://rubygems.org/gems/cookbook-reader' + s.homepage = 'https://github.com/keviny22/cookbook-reader' s.license = 'MIT' s.add_development_dependency "fakefs", "~> 0.4.2" diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb index 72a74b3..300643d 100644 --- a/cookbook-reader/lib/cookbook-reader/parser.rb +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -17,8 +17,12 @@ def display_data @top_list.each do |element| puts "Cookbook: #{element['name']}\n" puts " Dependancies:" - element['depends'].each do |name, version| - puts " #{name}, #{version}\n" + if element['depends'] + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + else + puts " None\n" end puts "\n" end @@ -32,8 +36,9 @@ def read_file(filename) File.open(filename) do |fp| fp.each do |line| key, value = line.chomp.split(" ") - key.strip! - value.strip! + next if key.nil? || value.nil? + key.strip! unless key.nil? + value.strip! unless value.nil? key = key.chomp('"').reverse.chomp('"').reverse value = value.chomp('"').reverse.chomp('"').reverse From 60a5433b5cb6e5ae52b517a4fa3450a24c0659e2 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Wed, 15 Jan 2014 13:35:10 -0800 Subject: [PATCH 20/41] Update roster.txt --- week1/exercises/roster.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week1/exercises/roster.txt b/week1/exercises/roster.txt index 21b0964..3a58940 100644 --- a/week1/exercises/roster.txt +++ b/week1/exercises/roster.txt @@ -18,5 +18,5 @@ 16, Robert McCreary Mannino, rmccreary8@gmail.com, psytau, maalaoshi, rmccreary8@gmail.com 17, Rukia, rukk86@gmail.com, rukk86, no twitter, Rukia 18, -19, +19, Kevin Young, kevin@young.net, keviny22, null, KevinYoung 20, Zack Walkingstick, zackwalkingstick@gmail.com, zackwalkingstick, no twitter, @zack From 7fcb82b0945fd0e8ff567869cce13361536d80a8 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Wed, 15 Jan 2014 16:21:24 -0800 Subject: [PATCH 21/41] first commit --- .ruby-version | 2 +- week1/homework/questions.txt | 51 +++++++++++++++++++++++- week1/homework/strings_and_rspec_spec.rb | 14 ++++--- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/.ruby-version b/.ruby-version index c506e4e..9304515 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.0.0-p353 +ruby-2.1.0 diff --git a/week1/homework/questions.txt b/week1/homework/questions.txt index 2257bb9..c110442 100644 --- a/week1/homework/questions.txt +++ b/week1/homework/questions.txt @@ -3,13 +3,60 @@ Chapter 3 Classes, Objects, and Variables p.86-90 Strings (Strings section in Chapter 6 Standard Types) 1. What is an object? +In Ruby, objects are instances of the class which can be created using the +special method constructor called new. 2. What is a variable? +In Ruby, a variable is a name that is associated with a particular object; a +reference to an object +There are four types of variables, global, instance, local and constant 3. What is the difference between an object and a class? +Some may say they are the same thing, on object is just an instance of a +class. 4. What is a String? +Verbatim, “Ruby strings are simply sequences of characters. They normally hold +printable characters, but that is not a requirement; a string can also hold +binary data. Strings are objects of class String.“ -5. What are three messages that I can send to a string object? Hint: think methods +5. What are three messages that I can send to a string object? Hint: think +methods +You could use chop, delete, empty + +2.1.0 :010 > car="Ford F-150" + => "Ford F-150" +2.1.0 :011 > puts car.chop +Ford F-15 + => nil +2.1.0 :012 > +2.1.0 :013 > puts car.delete "150" +Ford F- + => nil +2.1.0 :014 > +2.1.0 :014 > puts car.empty? +false + => nil + + +6. What are two ways of defining a String literal? Bonus: What is the +difference between them? + +%q (single-quoted string) and %Q (double-quoted string) + +single-quoted string literals undergo the least substitution of the two, for +example. + + +2.1.0 :017 > car="ford" + => "ford" +2.1.0 :018 > model="f-150" + => "f-150" +2.1.0 :021 > puts %q{I drive an #{car}, #{model}} +I drive an #{car}, #{model} + => nil +2.1.0 :022 > puts %Q{I drive an #{car}, #{model}} +I drive an ford, f-150 + => nil +2.1.0 :023 > -6. What are two ways of defining a String literal? Bonus: What is the difference between them? diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index ea79e4c..0fd4cc8 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -12,14 +12,18 @@ before(:all) do @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" end - it "should be able to count the charaters" - it "should be able to split on the . charater" do - pending - result = #do something with @my_string here + + it "should be able to count the charaters" do + @my_string.should have(66).characters + end + + it "should be able to split on the . charater" do + result = @my_string.split('.') result.should have(2).items end + it "should be able to give the encoding of the string" do - pending 'helpful hint: should eq (Encoding.find("UTF-8"))' + @my_string.should eq (Encoding.find("UTF-8")) end end end From cfdfbc7f6cf275297f52727c026ce8fdad210f5a Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 16 Jan 2014 10:15:28 -0800 Subject: [PATCH 22/41] finished spec --- week1/homework/strings_and_rspec_spec.rb | 31 ++++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index 0fd4cc8..6e2965f 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -8,23 +8,22 @@ # (Hint: You should do the reading on Strings first) describe String do - context "When a string is defined" do - before(:all) do - @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" - end - - it "should be able to count the charaters" do - @my_string.should have(66).characters - end + context "When a string is defined" do + before(:all) do + @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" + end + + it "should be able to count the charaters" do + @my_string.should have(66).characters + end - it "should be able to split on the . charater" do - result = @my_string.split('.') - result.should have(2).items - end + it "should be able to split on the . charater" do + @my_string.split('.').should have(2).items + end - it "should be able to give the encoding of the string" do - @my_string.should eq (Encoding.find("UTF-8")) - end - end + it "should be able to give the encoding of the string" do + @my_string.encoding.should eq (Encoding.find("UTF-8")) + end + end end From 47fab1a189993cca93f97c7feab5aa39ba167337 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 23 Jan 2014 11:46:15 -0800 Subject: [PATCH 23/41] week2 --- week2/homework/questions.txt | 22 ++++++++++++++++++++++ week2/homework/simon_says.rb | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 week2/homework/simon_says.rb diff --git a/week2/homework/questions.txt b/week2/homework/questions.txt index 939e42d..343b96d 100644 --- a/week2/homework/questions.txt +++ b/week2/homework/questions.txt @@ -3,11 +3,33 @@ Containers, Blocks, and Iterators Sharing Functionality: Inheritance, Modules, and Mixins 1. What is the difference between a Hash and an Array? +A hash uses a key value pair, which is benifitial if you need to do lookups on +either. usually used when you have a one to one relationship, ex. +FirstName=Joe +LastName=Smith + +With an array, its is just a listing where each element in the array is +associated by an numerical index. This is useful if you have a listing of the +same times of items, ex. +Kids=sally,bobby,fred 2. When would you use an Array over a Hash and vice versa? +I use a hash when i would need to lookup a value based on its key, or vice +versa. 3. What is a module? Enumerable is a built in Ruby module, what is it? +a way of grouping together methods, classes, and constants +an enumerable is a standard mixin, which combines a bunch of methods, i like +the map enumerable which makes running blocks of code much cleaner 4. Can you inherit more than one thing in Ruby? How could you get around this problem? +use mixins 5. What is the difference between a Module and a Class? +ruby-doc.org says it best +Every class is also a module, but unlike modules a class may not be mixed-in +to another module (or class). Like a module, a class can be used as a +namespace. A class also inherits methods and constants from its superclass. +However, you can put a mix-in a module but not a class + + diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb new file mode 100644 index 0000000..5c57ab8 --- /dev/null +++ b/week2/homework/simon_says.rb @@ -0,0 +1,23 @@ +module SimonSays + def echo( statement ) + statement + end + + def shout( statement ) + statement.upcase + end + + def repeat( statement, amount = 2 ) + ([statement] * amount).join(" ") + end + + def start_of_word(statement, number) + statement[0, number] + end + + def first_word(statement) + a = statement.split + a[0] + end +end + From 62bd3dbe5dc152e4bcc199973739ef965f968313 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 23 Jan 2014 11:59:12 -0800 Subject: [PATCH 24/41] week2_fixed spaces --- week2/homework/simon_says.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb index 5c57ab8..6677d03 100644 --- a/week2/homework/simon_says.rb +++ b/week2/homework/simon_says.rb @@ -1,13 +1,13 @@ module SimonSays - def echo( statement ) + def echo(statement) statement end - def shout( statement ) + def shout(statement) statement.upcase end - def repeat( statement, amount = 2 ) + def repeat(statement, amount = 2) ([statement] * amount).join(" ") end From 84fc4fe153daa2c2f4b7b1e8131cbef712991a6f Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 6 Feb 2014 11:46:02 -0800 Subject: [PATCH 25/41] homework --- week3/homework/calculator.rb | 22 ++++++++++++++++++++++ week3/homework/questions.txt | 11 +++++++++++ week4/homework/questions.txt | 8 +++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 week3/homework/calculator.rb diff --git a/week3/homework/calculator.rb b/week3/homework/calculator.rb new file mode 100644 index 0000000..4d9e891 --- /dev/null +++ b/week3/homework/calculator.rb @@ -0,0 +1,22 @@ +class Calculator + def sum(numbers) + return 0 unless numbers.any? + numbers.inject{|sum,x| sum + x} + end + + def multiply(*numbers) + return 0 unless numbers.any? + numbers.flatten.inject{|multiply,x| multiply * x} + end + + def pow(*numbers) + return 0 unless numbers.any? + numbers.inject{|pow,x| pow ** x} + end + + def fac(number) + return 1 if number == 1 + return 1 if number == 0 + number * fac(number-1) + end +end diff --git a/week3/homework/questions.txt b/week3/homework/questions.txt index dfb158d..f8f651d 100644 --- a/week3/homework/questions.txt +++ b/week3/homework/questions.txt @@ -5,11 +5,22 @@ Please Read: - Chapter 22 The Ruby Language: basic types (symbols), variables and constants 1. What is a symbol? +A Ruby symbol is an identifier corresponding to a string of characters, often a +name. 2. What is the difference between a symbol and a string? +Mostly that a symbol is immutable, 3. What is a block and how do I call a block? +a block is a chunk of code with a begining or an end. you can call a block +using do ... end or with curly braces 4. How do I pass a block to a method? What is the method signature? +use yield to pass a block to a method. +A method signature tells you how to use/call that method 5. Where would you use regular expressions? +As little as possible :) +Generally when you are trying to match patterns then specific text. Like if +you are trying to detect if something fits the pattern off a social security +number or ip address, etc... diff --git a/week4/homework/questions.txt b/week4/homework/questions.txt index 187b3d3..36e4824 100644 --- a/week4/homework/questions.txt +++ b/week4/homework/questions.txt @@ -3,12 +3,18 @@ Chapter 10 Basic Input and Output The Rake Gem: http://rake.rubyforge.org/ 1. How does Ruby read files? +Many lines are read at one time into a buffer 2. How would you output "Hello World!" to a file called my_output.txt? +File.open("my_output.txt", 'w') { |file| file.write("Hello World!") } 3. What is the Directory class and what is it used for? +The Dir class is used for listing directories and its contents, traversing +through directories and creating/deleting directories 4. What is an IO object? +An IO object is something returned from calling the IO class. 5. What is rake and what is it used for? What is a rake task? - +rake is best used for automating tasks, a rake task a specific action defined +in the rake file From bb80d7551d36c83905e3334a8355e38708052a42 Mon Sep 17 00:00:00 2001 From: Kevin Young Date: Thu, 6 Feb 2014 11:48:15 -0800 Subject: [PATCH 26/41] homework --- .idea/.name | 1 + .idea/RubyWinter2014.iml | 141 +++++ .idea/encodings.xml | 5 + .idea/misc.xml | 5 + .idea/modules.xml | 9 + .idea/scopes/scope_settings.xml | 5 + .idea/vcs.xml | 7 + .idea/workspace.xml | 685 ++++++++++++++++++++++ week4/class_materials/odd_number_kevin.rb | 14 + week4/homework/worker.rb | 6 + 10 files changed, 878 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/RubyWinter2014.iml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scopes/scope_settings.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 week4/class_materials/odd_number_kevin.rb create mode 100644 week4/homework/worker.rb diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..fdb70fb --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +RubyWinter2014 \ No newline at end of file diff --git a/.idea/RubyWinter2014.iml b/.idea/RubyWinter2014.iml new file mode 100644 index 0000000..f925dd8 --- /dev/null +++ b/.idea/RubyWinter2014.iml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ea782b3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..241ede5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..7143d06 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,685 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1389931367465 + 1389931367465 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/week2/exercises/book.rb + 4 + + + file://$PROJECT_DIR$/week3/homework/calculator.rb + 19 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week4/class_materials/odd_number_kevin.rb b/week4/class_materials/odd_number_kevin.rb new file mode 100644 index 0000000..b3e6998 --- /dev/null +++ b/week4/class_materials/odd_number_kevin.rb @@ -0,0 +1,14 @@ +class OddNumberKevin + def initialize value + @value = value + end + + def succ + return OddNumberKevin.new(@value + 2) if @value.odd? + OddNumberKevin.new(@value + 1) + end + + def <=> other + @value + end +end \ No newline at end of file diff --git a/week4/homework/worker.rb b/week4/homework/worker.rb new file mode 100644 index 0000000..8f67700 --- /dev/null +++ b/week4/homework/worker.rb @@ -0,0 +1,6 @@ +class Worker + def self.work n = 1 + n.times.inject(nil){yield} + end +end + From e7f48557085025e03f71b4f7fb7ed6545c8dc5b9 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 12:31:28 -0800 Subject: [PATCH 27/41] updates --- midterm/.idea/.name | 1 + midterm/.idea/encodings.xml | 5 + midterm/.idea/midterm.iml | 105 ++++++ midterm/.idea/misc.xml | 5 + midterm/.idea/modules.xml | 9 + midterm/.idea/scopes/scope_settings.xml | 5 + midterm/.idea/vcs.xml | 7 + midterm/.idea/workspace.xml | 447 ++++++++++++++++++++++++ midterm/answers.txt | 71 ++++ midterm/even_number.rb | 16 + midterm/even_number_spec.rb | 20 ++ midterm/thanksgiving_dinner.rb | 34 ++ midterm/turkey.rb | 18 + 13 files changed, 743 insertions(+) create mode 100644 midterm/.idea/.name create mode 100644 midterm/.idea/encodings.xml create mode 100644 midterm/.idea/midterm.iml create mode 100644 midterm/.idea/misc.xml create mode 100644 midterm/.idea/modules.xml create mode 100644 midterm/.idea/scopes/scope_settings.xml create mode 100644 midterm/.idea/vcs.xml create mode 100644 midterm/.idea/workspace.xml create mode 100644 midterm/answers.txt create mode 100644 midterm/even_number.rb create mode 100644 midterm/even_number_spec.rb create mode 100644 midterm/thanksgiving_dinner.rb create mode 100644 midterm/turkey.rb diff --git a/midterm/.idea/.name b/midterm/.idea/.name new file mode 100644 index 0000000..dda36a8 --- /dev/null +++ b/midterm/.idea/.name @@ -0,0 +1 @@ +midterm \ No newline at end of file diff --git a/midterm/.idea/encodings.xml b/midterm/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/midterm/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/midterm/.idea/midterm.iml b/midterm/.idea/midterm.iml new file mode 100644 index 0000000..470f70a --- /dev/null +++ b/midterm/.idea/midterm.iml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/.idea/misc.xml b/midterm/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/midterm/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/midterm/.idea/modules.xml b/midterm/.idea/modules.xml new file mode 100644 index 0000000..cbe1fd7 --- /dev/null +++ b/midterm/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/midterm/.idea/scopes/scope_settings.xml b/midterm/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/midterm/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/midterm/.idea/vcs.xml b/midterm/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/midterm/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml new file mode 100644 index 0000000..5fbc307 --- /dev/null +++ b/midterm/.idea/workspace.xml @@ -0,0 +1,447 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1392852566659 + 1392852566659 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/answers.txt b/midterm/answers.txt new file mode 100644 index 0000000..46f9e32 --- /dev/null +++ b/midterm/answers.txt @@ -0,0 +1,71 @@ + - What are the three uses of the curly brackets {} in Ruby? +1. For string interpolation, ex + irb(main):001:0> name="fred" + => "fred" + irb(main):002:0> puts "Hello #{name}" + Hello fred + => nil + irb(main):003:0> + +2. They are the literal constructor for constructing a hash, ex. + irb(main):003:0> hash={"ford" => "mustang","dodge" => "charger"} + => {"ford"=>"mustang", "dodge"=>"charger"} + irb(main):004:0> puts hash + {"ford"=>"mustang", "dodge"=>"charger"} + => nil + irb(main):005:0> + +3. You can put a code block in curly braces to deliminate instead of using do/end + irb(main):006:0> array = [1,10,100] + => [1, 10, 100] + irb(main):008:0> puts array.map{|n|n+1} + 2 + 11 + 101 + => nil + irb(main):009:0> + + - What is a regular expression and what is a common use for them? + Regular Expressions can be used in Ruby to do pattern matching, substitution, pretty much any type of string manipulation. + + - What is the difference between how a String, a symbol, a FixNum, and a Float are stored in Ruby? + A symbol is a string that is stored as unique identifiers in memeory,meaning it is only stored once. + A string on the other hand can be changed so it is stored many times, making look ups take longer + A FixNum is stored as the value itself, in ruby 2.0 a float behaves like a FixNum + + - Are these two statements equivalent? Why or Why Not? + 1. x, y = "hello", "hello" + 2. x = y = "hello" + + Yes, in the sense that x = "hello" and y = "hello" in both cases. + +- What is the difference between a Range and an Array? + A range is sequential: a,b,c,d 1,2,3,4 etc + An array is a collection a,1,b,4,car,baby + +- Why would I use a Hash instead of an Array? + if you care about the relationship between a key and value a hash should be used. + if you just want to store a collection of things, an array should be used. + +- What is your favorite thing about Ruby so far? + It isn't strict on syntax, you dont have to declare everything + +- What is your least favorite thing about Ruby so far? + So many ways to do something, it turns into an artform especially when working in groups. it makes it more important to agree style. + + Programming Problems (10pts each): + - Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber. + - The EvenNumber class should: + - Only allow even numbers + - Get the next even number + - Compare even numbers + - Generate a range of even numbers +- Make the rspec tests in wish_list_spec.rb pass by writing a WishList class + - The WishList class should: + - Mixin Enumerable + - Define each so it returns wishes as strings with their index as part of the string + +Mid-Term Spec (50pts): +- Make the tests pass. + + diff --git a/midterm/even_number.rb b/midterm/even_number.rb new file mode 100644 index 0000000..507c4f6 --- /dev/null +++ b/midterm/even_number.rb @@ -0,0 +1,16 @@ +class EvenNumber + + def next(num) + return false if not num.even? + num + 2 + end + + def compare(num1,num2) + return false if not num.even? + return false if not num.even? + end + +end + +@evennumber = EvenNumber.new +puts @evennumber.next(3) diff --git a/midterm/even_number_spec.rb b/midterm/even_number_spec.rb new file mode 100644 index 0000000..bd9717a --- /dev/null +++ b/midterm/even_number_spec.rb @@ -0,0 +1,20 @@ +# - Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber. +# - The EvenNumber class should: +# - Only allow even numbers +# - Get the next even number +# - Compare even numbers +# - Generate a range of even numbers + +require "#{File.dirname(__FILE__)}/even_number" + +describe EvenNumber do + + before do + @evennumber = EvenNumber.new + end + + it "should only allow even numbers" do + @evennumber.should be_even + end + +end diff --git a/midterm/thanksgiving_dinner.rb b/midterm/thanksgiving_dinner.rb new file mode 100644 index 0000000..294f695 --- /dev/null +++ b/midterm/thanksgiving_dinner.rb @@ -0,0 +1,34 @@ +module Dinner;end +class ThanksgivingDinner + include Dinner + attr_accessor :menu, :guests + + def initialize(vegan) + @vegan = vegan + end + + def guests + end + + def seating_chart_size + 45 + end + + def menu + { :diet => :vegan, + :proteins => ["Tofurkey", "Hummus"], + :veggies => [:ginger_carrots , :potatoes, :yams], + :desserts => {:pies=>[:pumkin_pie], :other=>["Chocolate Moose"], :molds=>[:cranberry, :mango, :cherry]} + } + + end + + def whats_for_dinner + "Tonight we have proteins Tofurkey and Hummus, and veggies Ginger Carrots, Potatoes, and Yams." + end + + def whats_for_dessert + "Tonight we have 5 delicious desserts: Pumkin Pie, Chocolate Moose, and 3 molds: Cranberry and Mango and Cherry." + end + +end diff --git a/midterm/turkey.rb b/midterm/turkey.rb new file mode 100644 index 0000000..8fff844 --- /dev/null +++ b/midterm/turkey.rb @@ -0,0 +1,18 @@ +module Animal;end + class Turkey + include Animal + + def initialize(weight) + @weight = weight + end + + def weight + @weight + end + + def gobble_speak(message) + if message == "Hello I Am a Turkey. Please Don't Eat Me." + "Gobble Gobble Gobble gobble Gobble. Gobble Gobb'le Gobble Gobble." + end + end + end From 65f0d62cc0bfcb597cbccf09f92d443969acf194 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 15:23:45 -0800 Subject: [PATCH 28/41] updates --- midterm/.idea/midterm.iml | 37 ++++++++++ midterm/.idea/workspace.xml | 132 ++++++++++++++++++++++++------------ midterm/even_number.rb | 19 ++++-- midterm/even_number_spec.rb | 19 +++++- 4 files changed, 155 insertions(+), 52 deletions(-) diff --git a/midterm/.idea/midterm.iml b/midterm/.idea/midterm.iml index 470f70a..4801022 100644 --- a/midterm/.idea/midterm.iml +++ b/midterm/.idea/midterm.iml @@ -91,6 +91,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index 5fbc307..f89ab6b 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -12,9 +12,10 @@ + - - + + - + + @@ -393,51 +437,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/midterm/even_number.rb b/midterm/even_number.rb index 507c4f6..441bcc7 100644 --- a/midterm/even_number.rb +++ b/midterm/even_number.rb @@ -1,16 +1,23 @@ class EvenNumber def next(num) - return false if not num.even? + return false unless num.even? num + 2 end def compare(num1,num2) - return false if not num.even? - return false if not num.even? + return false unless num1.even? + return false unless num2.even? + true if num1 == num2 end + + def range(num1,num2) + return false unless num1.even? + return false unless num2.even? + (num1..num2).step(2) do |n| + n + end -end + end -@evennumber = EvenNumber.new -puts @evennumber.next(3) +end diff --git a/midterm/even_number_spec.rb b/midterm/even_number_spec.rb index bd9717a..ca9fe17 100644 --- a/midterm/even_number_spec.rb +++ b/midterm/even_number_spec.rb @@ -8,13 +8,28 @@ require "#{File.dirname(__FILE__)}/even_number" describe EvenNumber do - before do @evennumber = EvenNumber.new end it "should only allow even numbers" do - @evennumber.should be_even + @evennumber.next(3).should be_false + end + + it "should return the next even number" do + @evennumber.next(2).should equal 4 + end + + it "should compare even numbers" do + @evennumber.compare(2,2).should be_true + end + + it "should not return true of numbers are not the same" do + @evennumber.compare(2,4).should_not be_true + end + + it "should generate a range of even numbers" do + @evennumber.range(2,8).should be_a Range end end From bf25d4d5944c99a4cec0b8491b7b20f0224f5a3e Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 16:01:33 -0800 Subject: [PATCH 29/41] updates --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b0c658e..af000aa 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,4 @@ Gem Project Requirements [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/UWE-Ruby/rubywinter2014/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From dcf192e1735c7e77dc0a6053fe409ab0868ab2c6 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 20 Feb 2014 19:05:26 -0800 Subject: [PATCH 30/41] updates --- midterm/.idea/workspace.xml | 74 +++++++++++++++--- week6/homework/hola_keviny22/hola-0.0.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/hola-0.1.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/hola.gemspec | 13 +++ .../hola_keviny22/hola_keviny22-0.1.0.gem | Bin 0 -> 4096 bytes week6/homework/hola_keviny22/lib/hola.rb | 5 ++ 6 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 week6/homework/hola_keviny22/hola-0.0.0.gem create mode 100644 week6/homework/hola_keviny22/hola-0.1.0.gem create mode 100644 week6/homework/hola_keviny22/hola.gemspec create mode 100644 week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem create mode 100644 week6/homework/hola_keviny22/lib/hola.rb diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index f89ab6b..d9aab8a 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -14,8 +14,8 @@ - + - @@ -169,6 +169,7 @@ + @@ -365,9 +366,9 @@ - - - + + + @@ -381,8 +382,8 @@ - - + + @@ -393,7 +394,7 @@ - + @@ -423,6 +424,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -481,7 +531,7 @@ - + diff --git a/week6/homework/hola_keviny22/hola-0.0.0.gem b/week6/homework/hola_keviny22/hola-0.0.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..5803344ed1f5514366ae7b776453496447e3b516 GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk4xgQ1bJfuX69v8kyUgMp#3iHRwL zf&r}@glukUaY8f@({lvJcp)zuyWbn$Np&~KQ)u<%4-nsBpy)7vTQ1pd$6c=;~t)>m80mh{XuH_pH3 zvuf3$%^UcBALGC8srqr&8UcB+psM9leQsG7T$*&?rZnev5vBM}_Zqw0`3xU9va;`O zkeFF!7twf={mHB}`9%#}_b;w3`*Cx9-l^+$7tV*WpJQz?|ArScFmS{75y@aYh!lLExon^wPc%rpAPm| zOk~{@B;9Clv@!g*&ziC+4evbGdh$K9lenu|wDZ_w!xMHrabK-#59El2XMVYm^6{0y zfj7FkMW>3EZRuEca#F#gh~EaLH#IKo6Sz?>E3ww%ve=7fZ{0UcQPEal{r8W#yMN_% zJ+(}qe9dD*l3arEUUygAd3{UY=q$Te`{|A6MSiJE{jOt+pcU+0s+jM5{LGIl}5+wO0uKUKjkM>`Vu<=3Swz%aaUi->ENhWL#x`<5E_#Tf8d>^=l<7}U)2r?6mcz#^9MTj|9@r% zjh-Yg1`d2~AC;p#1d=mSle3FUbBpyV6LWKDQwo5pMtt?ZiJ=Kv{cmDsFk1gp9=SxA zfXM%;6Rg9S4R~07&ruTR@V^%S^2H0w#+1_`CVN8W$h8Yqy*-zazy0>pzi&(L=wE-G zZeR3NIo@vH`|Aha6!WcrbMtmVX?nh6gmT70{s_aeV<-Qn$^HB~J9>si)T%;#vrQQe z?B^o)T)2Hi&KF?&a9WGIhnoLE%zW<{g%5yrx( z<9s#mo>Wb_T(bH@OV0hk7QpX`N{2 gU2s)qy1bCQ#-BxuLb%7 literal 0 HcmV?d00001 diff --git a/week6/homework/hola_keviny22/hola-0.1.0.gem b/week6/homework/hola_keviny22/hola-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..0aadb8e996a38a2c7ce71b75149dd11eeb417cd0 GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk56gQ1bJfuX69v8g#wouRRbi5Y`} z0j(T_Y;I|BNn#PuN#z--sX53JXlz3A5WgWjho*h7a^<@@7;2WY1v4=p4ff5yVj!^h z{Q4Q+E(P03eNEvE@oQKW$K}M-qI7(wFV8=Z+~p;$Ki>DueW%B9McZ@9jdQcj^Y8hr zT6Jji2EO0N_~SiQKh9bs@LnvaYWY;3Th;}aCLOpb&B-sKB;Q$oq~?Yl<0HW<*QS?p zcTdcG-YhyJ*(*9S6=&NN$ed;9x?L6hDzi2Qi0u4A_> zZug8OhI^Mva2ty#?whj9v+~o{_>@`vlla<`=c|4>Z}KgVIjX30wzQx1GN&~^?CO6$ znlruf^PQL{uV*}8wD(7_lit7mr*7=%ikCSfY`ro0pg32{e$}$lKG`yRM{>2> z(fjptguie-%390AQ+fEUZL`arotM}AVNy(ft<}a%r33}e`@kG9kon)p#0WkA8=IPp z=6@+pcU*Z@#kxN5x<~7VzOawK%HEvsf1Ay`kl!g| zazBgG=Zde6Il}HgM1x$muVb#VPE%U!xOG;@{a5#%*e%^^*1%G~VcF4RHm9D=eCm9E z`>(>ClXrCca<Pd`|EUwKH;FiKxPFd2nvT*+(e4o6^jbCx(`<0#3ufP8K zk}JFtG{04oHBJO&kJ_R?M|~UC+)eT{<$xHevI-d zw)as-+E4mrG;P&hrx#+{@=f^PbuEwom2)K{Iu_~WoW2sKyFqa6D~r3ma;~%PoZNY{ zsx)bW4x4$9ird+hUf)FZZhC2Q3P(NME_&vnNz@V}=auCyUY(jP52n?B_mL0c mHfQ$fnL>8rO^=St&taDmU&Kg6V2vsn4S~@R7!8486aoP7)$yqS literal 0 HcmV?d00001 diff --git a/week6/homework/hola_keviny22/hola.gemspec b/week6/homework/hola_keviny22/hola.gemspec new file mode 100644 index 0000000..605a448 --- /dev/null +++ b/week6/homework/hola_keviny22/hola.gemspec @@ -0,0 +1,13 @@ +Gem::Specification.new do |s| + s.name = 'hola_keviny22' + s.version = '0.1.0' + s.date = '2014-02-20' + s.summary = "Hola!" + s.description = "A simple hello world gem" + s.authors = ["Kevin Young"] + s.email = 'kevin@young.net' + s.files = ["lib/hola.rb"] + s.homepage = + 'http://rubygems.org/gems/hola_keviny22' + s.license = 'MIT' +end diff --git a/week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem b/week6/homework/hola_keviny22/hola_keviny22-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..43e23bf60c1363b5e2360775ccc080cb4242ca6e GIT binary patch literal 4096 zcmc~zElEsCEJ@T$uVSDTFaQD*6B7my4Fu@4ftk4pgQ1bJfuX69iHV^xgMp#3iHQM& zf&r}@glukUaY8f@({lvJcp)zuyWWKnlmFiLQjcwG7^oo0x(goR1f% zIkmS;(>uA!TXXG+4MHEYS4vNHkNvIixn@C$h0JfKh4sren$KRWI(_HPk6V&8j&#lc zJYE0XO`X}#pDkLGJg@uPBhA*JKlMvDCa$e2H1L0Oq|0@`lfob0jjOHay<4Kb{O%Fi z+nd9Gedf2?8Rr`9rM-F>enKF2Eo;^7^hMImnKREU-FmIyU3wam%8zE%vw5c$uW@v- z|5Cg9{dDV&-Mgl2I4vHaSS4xD$>%Hanfv3;Gn}veLX_7P2Gy_nyx*qgE0;#sB8|Rm zV8Z_YpP7MAda4iu2Y$zo%2FHx$r-81*~O)~#d?*AxjD2c1wd6JzWU$9&g4Lw=+p-hHa4dT7Ee>JHZuSBeP}CMYx=g_TgBNcelz$ zZu|G`;Waz&zW@JAQuO?f&)+{kmCNp)XKTGiS=Vz0x1f|$_D-=V#?+WQ=AV1|^ZClT zwL&zuPMXrFdwCo8xiz_VCtp4KzgGIX{(7C(y}N{Gg;_3s{cV?9O@f*F`=jh`eB9IG z_wxz!JYL6qA$6S{mt%MP>|J7+$L(hQzQS-WCerD3&Xfg7?@v95DNrk3^D+Ir Date: Thu, 6 Mar 2014 21:17:33 -0800 Subject: [PATCH 31/41] updates --- .ruby-version | 1 - midterm/.idea/workspace.xml | 130 ++++++++++++++++++++++++++++++++--- week7/homework/questions.txt | 8 ++- 3 files changed, 128 insertions(+), 11 deletions(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 9304515..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.1.0 diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml index d9aab8a..ac8ca6d 100644 --- a/midterm/.idea/workspace.xml +++ b/midterm/.idea/workspace.xml @@ -14,8 +14,8 @@ - + - @@ -142,6 +142,7 @@ + @@ -162,7 +163,6 @@ - @@ -357,6 +357,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -382,7 +445,7 @@ - + @@ -398,11 +461,11 @@ - + - + @@ -424,6 +487,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -531,7 +643,7 @@ - + diff --git a/week7/homework/questions.txt b/week7/homework/questions.txt index d55387d..1445b22 100644 --- a/week7/homework/questions.txt +++ b/week7/homework/questions.txt @@ -1,9 +1,15 @@ - Please Read Chapters 23 and 24 DuckTyping and MetaProgramming Questions: 1. What is method_missing and how can it be used? +This missing_method is a built in Ruby hook method that is called when a method cannot be found. It raises an exception eith NoMethodError or NameError. +The missing_method can be overridden in your own class by writing your own missing_method in that class with your own behavior defined in that method. + 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? +An eigenclass (aka singleton class, aka anonymous class, aka. metaclass) is defined as 'an exclusive stash of methods, tailormade for that object and not shared with other objects' and can be used to define a class method. +REF: The Well Grounded Rubyist, by David A. Black + +A singletome method (aks class method) lives in the singleton class 3. When would you use DuckTypeing? How would you use it to improve your code? 4. What is the difference between a class method and an instance method? What is the difference between instance_eval and class_eval? 5. What is the difference between a singleton class and a singleton method? From 3787c1ba5b2fae918981fd479c29d8c36d4ddd6f Mon Sep 17 00:00:00 2001 From: keviny22 Date: Tue, 11 Mar 2014 22:35:32 -0700 Subject: [PATCH 32/41] Final --- week7/homework/.idea/.name | 1 + week7/homework/.idea/encodings.xml | 5 + week7/homework/.idea/homework.iml | 162 ++++ week7/homework/.idea/misc.xml | 5 + week7/homework/.idea/modules.xml | 9 + .../homework/.idea/scopes/scope_settings.xml | 5 + week7/homework/.idea/vcs.xml | 7 + week7/homework/.idea/workspace.xml | 815 ++++++++++++++++++ .../features/step_definitions/pirate.rb | 10 + .../step_definitions/tic-tac-toe-steps.rb | 6 +- .../features/step_definitions/tic-tac-toe.rb | 126 +++ week7/homework/play_game.rb | 2 +- week7/homework/play_game.rb.orig | 22 + 13 files changed, 1171 insertions(+), 4 deletions(-) create mode 100644 week7/homework/.idea/.name create mode 100644 week7/homework/.idea/encodings.xml create mode 100644 week7/homework/.idea/homework.iml create mode 100644 week7/homework/.idea/misc.xml create mode 100644 week7/homework/.idea/modules.xml create mode 100644 week7/homework/.idea/scopes/scope_settings.xml create mode 100644 week7/homework/.idea/vcs.xml create mode 100644 week7/homework/.idea/workspace.xml create mode 100644 week7/homework/features/step_definitions/pirate.rb create mode 100644 week7/homework/features/step_definitions/tic-tac-toe.rb create mode 100644 week7/homework/play_game.rb.orig diff --git a/week7/homework/.idea/.name b/week7/homework/.idea/.name new file mode 100644 index 0000000..158b7eb --- /dev/null +++ b/week7/homework/.idea/.name @@ -0,0 +1 @@ +homework \ No newline at end of file diff --git a/week7/homework/.idea/encodings.xml b/week7/homework/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/week7/homework/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/homework/.idea/homework.iml b/week7/homework/.idea/homework.iml new file mode 100644 index 0000000..8057322 --- /dev/null +++ b/week7/homework/.idea/homework.iml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/homework/.idea/misc.xml b/week7/homework/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/week7/homework/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/homework/.idea/modules.xml b/week7/homework/.idea/modules.xml new file mode 100644 index 0000000..f766474 --- /dev/null +++ b/week7/homework/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/week7/homework/.idea/scopes/scope_settings.xml b/week7/homework/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/week7/homework/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/week7/homework/.idea/vcs.xml b/week7/homework/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/week7/homework/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/week7/homework/.idea/workspace.xml b/week7/homework/.idea/workspace.xml new file mode 100644 index 0000000..640c120 --- /dev/null +++ b/week7/homework/.idea/workspace.xml @@ -0,0 +1,815 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394167333043 + 1394167333043 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/features/step_definitions/tic-tac-toe.rb + 47 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/homework/features/step_definitions/pirate.rb b/week7/homework/features/step_definitions/pirate.rb new file mode 100644 index 0000000..424db3b --- /dev/null +++ b/week7/homework/features/step_definitions/pirate.rb @@ -0,0 +1,10 @@ +class PirateTranslator + def say(str) + @reply = "Ahoy Matey" + end + + def translate + @reply + "\n Shiber Me Timbers You Scurvey Dogs!!" + + end +end diff --git a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb b/week7/homework/features/step_definitions/tic-tac-toe-steps.rb index a3287c1..b404f38 100644 --- a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb +++ b/week7/homework/features/step_definitions/tic-tac-toe-steps.rb @@ -100,8 +100,8 @@ :A1 => :X, :A2 => :O, :A3 => :X, :B1 => :X, :B2 => :O, :B3 => :X, :C1 => :O, :C2 => :X, :C3 => :O - } - @game.determine_winner + } + @game.determine_winner end When /^there are no open spaces left on the board$/ do @@ -121,4 +121,4 @@ @game.board[arg1.to_sym] = ' ' @game.should_receive(:get_player_move).twice.and_return(@taken_spot, arg1) @game.player_move.should eq arg1.to_sym -end +end \ No newline at end of file diff --git a/week7/homework/features/step_definitions/tic-tac-toe.rb b/week7/homework/features/step_definitions/tic-tac-toe.rb new file mode 100644 index 0000000..c7806df --- /dev/null +++ b/week7/homework/features/step_definitions/tic-tac-toe.rb @@ -0,0 +1,126 @@ +class TicTacToe + + SYMBOLS = [:X,:O] + + + attr_accessor :player, :board + def initialize current_player=nil, player_s=nil + @current_player = current_player || [:player, :computer].sample + choose_symbols(player_s) + + @board = { + :A1=>" ",:A2=>" ",:A3=>" ", + :B1=>" ",:B2=>" ",:B3=>" ", + :C1=>" ",:C2=>" ",:C3=>" " + } + end + + + def welcome_player + "Welcome #{@player}" + end + + def current_player + {:computer => "Computer", :player => @player}[@current_player] + end + + def over? + false if spots_open? + true if player_won? + end + + def computer_move + + spot = open_spots.sample + @board[spot] = computer_symbol + @current_player = :player + end + + def indicate_palyer_turn + puts "#{@player}'s Move:" + #get_player_move + end + + def player_move + spot = get_player_move.to_sym + until open_spots.include?(spot) + puts "That spot is taken, please enter another spot:" + spot = get_player_move.to_sym + end + @board[spot] = player_symbol + + @current_player = :computer + spot + end + + def current_state + ret = " 1 | 2 | 3\n" + ret << "A | #{@board[:A1]}| #{@board[:A2]}| #{@board[:A3]}\n" + ret << "---|---|---|---\n" + ret << "B | #{@board[:B1]}| #{@board[:B2]}| #{@board[:B3]}\n" + ret << "---|---|---|---\n" + ret << "C | #{@board[:C1]}| #{@board[:C2]}| #{@board[:C3]}\n" + + end + + def determine_winner + true unless spots_open? + + if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + @winner = @board[:A1] + elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] + @winner = @board[:A2] + elsif @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + @winner = @board[:C1] + elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] + @winner = @board[:C1] + elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] + @winner = @board[:C1] + elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] + @winner = @board[:C1] + else + draw? + end + over? + end + + def player_won? + true if @winner = @player_symbol[:player] + end + + def draw? + true + end + + def player_symbol + @player_symbol[:player] + end + + def computer_symbol + @player_symbol[:computer] + end + + def get_player_move + gets.chomp + end + + def spots_open? + true if @board.values.any?{|v| v == " "} + end + + def open_spots + spots = Array.new + @board.each do |key, value| + if value == " " + spots << key + end + end + spots + end + + def choose_symbols(player_s) + player_s ||=SYMBOLS.sample + @player_symbol = {:computer => SYMBOLS.reject{|s| s==player_s}.first, :player => player_s} + end + +end diff --git a/week7/homework/play_game.rb b/week7/homework/play_game.rb index 0535830..7b99f10 100644 --- a/week7/homework/play_game.rb +++ b/week7/homework/play_game.rb @@ -10,7 +10,7 @@ when "Computer" @game.computer_move when @game.player - @game.indicate_palyer_turn + @game.indicate_player_turn @game.player_move end puts @game.current_state diff --git a/week7/homework/play_game.rb.orig b/week7/homework/play_game.rb.orig new file mode 100644 index 0000000..0535830 --- /dev/null +++ b/week7/homework/play_game.rb.orig @@ -0,0 +1,22 @@ +require './features/step_definitions/tic-tac-toe.rb' + +@game = TicTacToe.new +puts "What is your name?" +@game.player = gets.chomp +puts @game.welcome_player + +until @game.over? + case @game.current_player + when "Computer" + @game.computer_move + when @game.player + @game.indicate_palyer_turn + @game.player_move + end + puts @game.current_state + @game.determine_winner +end + +puts "You Won!" if @game.player_won? +puts "I Won!" if @game.computer_won? +puts "DRAW!" if @game.draw? From 9040fbbd39a5ede88ec9c3467b1fee45d707a9ae Mon Sep 17 00:00:00 2001 From: keviny22 Date: Tue, 11 Mar 2014 22:36:12 -0700 Subject: [PATCH 33/41] Final --- week7/homework/play_game.rb.orig | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 week7/homework/play_game.rb.orig diff --git a/week7/homework/play_game.rb.orig b/week7/homework/play_game.rb.orig deleted file mode 100644 index 0535830..0000000 --- a/week7/homework/play_game.rb.orig +++ /dev/null @@ -1,22 +0,0 @@ -require './features/step_definitions/tic-tac-toe.rb' - -@game = TicTacToe.new -puts "What is your name?" -@game.player = gets.chomp -puts @game.welcome_player - -until @game.over? - case @game.current_player - when "Computer" - @game.computer_move - when @game.player - @game.indicate_palyer_turn - @game.player_move - end - puts @game.current_state - @game.determine_winner -end - -puts "You Won!" if @game.player_won? -puts "I Won!" if @game.computer_won? -puts "DRAW!" if @game.draw? From 8dde91d910dc98714f948a7adc9873458dc9ee24 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Wed, 12 Mar 2014 14:58:38 -0700 Subject: [PATCH 34/41] updates --- .version | 1 + cookbook-reader/.idea/.name | 1 + cookbook-reader/.idea/cookbook-reader.iml | 35 ++ cookbook-reader/.idea/encodings.xml | 5 + cookbook-reader/.idea/misc.xml | 5 + cookbook-reader/.idea/modules.xml | 9 + .../.idea/scopes/scope_settings.xml | 5 + cookbook-reader/.idea/vcs.xml | 7 + cookbook-reader/.idea/workspace.xml | 354 +++++++++++++++ cookbook-reader/bin/cookbook-reader | 5 + .../lib/cookbook-reader/options.rb | 37 ++ cookbook-reader/lib/cookbook-reader/parser.rb | 62 +++ week7/exercises/hello/.idea/.name | 1 + week7/exercises/hello/.idea/encodings.xml | 5 + week7/exercises/hello/.idea/hello.iml | 50 +++ week7/exercises/hello/.idea/misc.xml | 5 + week7/exercises/hello/.idea/modules.xml | 9 + .../hello/.idea/scopes/scope_settings.xml | 5 + week7/exercises/hello/.idea/vcs.xml | 7 + week7/exercises/hello/.idea/workspace.xml | 421 ++++++++++++++++++ .../hello/features/greeter_says_hello.feature | 10 + .../step_definitions/greeter_steps.rb | 17 + week7/exercises/hello/spec/greeter_spec.rb | 14 + week7/homework/.idea/workspace.xml | 86 ++-- .../features/step_definitions/tic-tac-toe.rb | 37 +- week7/homework/play_game.rb | 2 +- 26 files changed, 1133 insertions(+), 62 deletions(-) create mode 100644 .version create mode 100644 cookbook-reader/.idea/.name create mode 100644 cookbook-reader/.idea/cookbook-reader.iml create mode 100644 cookbook-reader/.idea/encodings.xml create mode 100644 cookbook-reader/.idea/misc.xml create mode 100644 cookbook-reader/.idea/modules.xml create mode 100644 cookbook-reader/.idea/scopes/scope_settings.xml create mode 100644 cookbook-reader/.idea/vcs.xml create mode 100644 cookbook-reader/.idea/workspace.xml create mode 100644 cookbook-reader/bin/cookbook-reader create mode 100644 cookbook-reader/lib/cookbook-reader/options.rb create mode 100644 cookbook-reader/lib/cookbook-reader/parser.rb create mode 100644 week7/exercises/hello/.idea/.name create mode 100644 week7/exercises/hello/.idea/encodings.xml create mode 100644 week7/exercises/hello/.idea/hello.iml create mode 100644 week7/exercises/hello/.idea/misc.xml create mode 100644 week7/exercises/hello/.idea/modules.xml create mode 100644 week7/exercises/hello/.idea/scopes/scope_settings.xml create mode 100644 week7/exercises/hello/.idea/vcs.xml create mode 100644 week7/exercises/hello/.idea/workspace.xml create mode 100644 week7/exercises/hello/features/greeter_says_hello.feature create mode 100644 week7/exercises/hello/features/step_definitions/greeter_steps.rb create mode 100644 week7/exercises/hello/spec/greeter_spec.rb diff --git a/.version b/.version new file mode 100644 index 0000000..9304515 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +ruby-2.1.0 diff --git a/cookbook-reader/.idea/.name b/cookbook-reader/.idea/.name new file mode 100644 index 0000000..5d5341c --- /dev/null +++ b/cookbook-reader/.idea/.name @@ -0,0 +1 @@ +cookbook-reader \ No newline at end of file diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml new file mode 100644 index 0000000..b8d0590 --- /dev/null +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/encodings.xml b/cookbook-reader/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/cookbook-reader/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/cookbook-reader/.idea/misc.xml b/cookbook-reader/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/cookbook-reader/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/cookbook-reader/.idea/modules.xml b/cookbook-reader/.idea/modules.xml new file mode 100644 index 0000000..8731703 --- /dev/null +++ b/cookbook-reader/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/cookbook-reader/.idea/scopes/scope_settings.xml b/cookbook-reader/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/cookbook-reader/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cookbook-reader/.idea/vcs.xml b/cookbook-reader/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/cookbook-reader/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml new file mode 100644 index 0000000..f3fd295 --- /dev/null +++ b/cookbook-reader/.idea/workspace.xml @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394649021318 + 1394649021318 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/lib/cookbook-reader/parser.rb + 41 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/bin/cookbook-reader b/cookbook-reader/bin/cookbook-reader new file mode 100644 index 0000000..fbca8a3 --- /dev/null +++ b/cookbook-reader/bin/cookbook-reader @@ -0,0 +1,5 @@ +#! /usr/bin/ruby +require 'cookbook-reader/parser' +parser = CookbookReader::Parser.new(ARGV) +parser.parse +parser.display_data diff --git a/cookbook-reader/lib/cookbook-reader/options.rb b/cookbook-reader/lib/cookbook-reader/options.rb new file mode 100644 index 0000000..cf26748 --- /dev/null +++ b/cookbook-reader/lib/cookbook-reader/options.rb @@ -0,0 +1,37 @@ +require 'optparse' + +module CookbookReader + class Options + + attr_reader :path_to_search + + def initialize(argv) + parse(argv) + end + + private + + def parse(argv) + OptionParser.new do |opts| + opts.banner = "Usage: cookbook-reader --path path ..." + + opts.on("-p", "--path path", String, "Path to search") do |path| + @path_to_search = path + end + + opts.on("-h", "--help", "Show this message") do + puts opts + exit + end + + begin + argv = ["-h"] if argv.empty? + opts.parse!(argv) + rescue OptionParser::ParseError => e + STDERR.puts e.message, "\n", opts + exit(-1) + end + end + end + end +end diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb new file mode 100644 index 0000000..2108a9d --- /dev/null +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -0,0 +1,62 @@ +require_relative 'options' +module CookbookReader + class Parser + def initialize(argv) + @options = Options.new(argv) + @top_list = [] + end + + def run + finder = Finder.from_file(@options.dictionary) + @options.words_to_find.each do |word| + anagrams = finder.lookup(word) + if anagrams + puts "Anagrams of #{word}: #{anagrams.join(', ')}" + else + puts "No anagrams of #{word} in #{@options.dictionary}" + end + end + end + + def parse + @metadata_list = Array.new + Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| + @metadata_list.push read_file filename + + + end + end + + def display_data + pp @top_list + end + + private + def read_file(filename) + @hash = {} + + @depends_list = {} + File.open(filename) do |fp| + fp.each do |line| + key, value = line.chomp.split(" ") + key = key.chomp('"').reverse.chomp('"').reverse + value = value.chomp('"').reverse.chomp('"').reverse + if key =~ /depends/ + @hash[key] = add_dependencies(line) + else + @hash[key] = value + end + end + end + @top_list.push @hash + + end + + def add_dependencies(line) + line.slice! "depends " + k, v = line.chomp.split(",") + @depends_list[k] = v + @depends_list + end + end +end diff --git a/week7/exercises/hello/.idea/.name b/week7/exercises/hello/.idea/.name new file mode 100644 index 0000000..b6fc4c6 --- /dev/null +++ b/week7/exercises/hello/.idea/.name @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/week7/exercises/hello/.idea/encodings.xml b/week7/exercises/hello/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/week7/exercises/hello/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/exercises/hello/.idea/hello.iml b/week7/exercises/hello/.idea/hello.iml new file mode 100644 index 0000000..ea67099 --- /dev/null +++ b/week7/exercises/hello/.idea/hello.iml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/exercises/hello/.idea/misc.xml b/week7/exercises/hello/.idea/misc.xml new file mode 100644 index 0000000..271c40f --- /dev/null +++ b/week7/exercises/hello/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/week7/exercises/hello/.idea/modules.xml b/week7/exercises/hello/.idea/modules.xml new file mode 100644 index 0000000..6e7c41b --- /dev/null +++ b/week7/exercises/hello/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/week7/exercises/hello/.idea/scopes/scope_settings.xml b/week7/exercises/hello/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/week7/exercises/hello/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/week7/exercises/hello/.idea/vcs.xml b/week7/exercises/hello/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/week7/exercises/hello/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/week7/exercises/hello/.idea/workspace.xml b/week7/exercises/hello/.idea/workspace.xml new file mode 100644 index 0000000..cfee28a --- /dev/null +++ b/week7/exercises/hello/.idea/workspace.xml @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394165119992 + 1394165119992 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week7/exercises/hello/features/greeter_says_hello.feature b/week7/exercises/hello/features/greeter_says_hello.feature new file mode 100644 index 0000000..8db8862 --- /dev/null +++ b/week7/exercises/hello/features/greeter_says_hello.feature @@ -0,0 +1,10 @@ +Feature: greater says hello + +In order to start learning RSpec and Cucumber +As a reader of the Rspec book +I want a greater to say hello + + Scenario: greeter says hello + Given a greeter + When I send it the greet message + Then I should see "Hello Cucumber!" diff --git a/week7/exercises/hello/features/step_definitions/greeter_steps.rb b/week7/exercises/hello/features/step_definitions/greeter_steps.rb new file mode 100644 index 0000000..fe7700e --- /dev/null +++ b/week7/exercises/hello/features/step_definitions/greeter_steps.rb @@ -0,0 +1,17 @@ +class CucumberGreeter + def greet + "Hello Cucumber!" + end +end + +Given /^a greeter$/ do + @greeter = CucumberGreeter.new +end + +When /^I send it the greet message$/ do + @message = @greeter.greet +end + +Then /^I should see "([^"]*)"$/ do |greeting| + @message.should == greeting +end diff --git a/week7/exercises/hello/spec/greeter_spec.rb b/week7/exercises/hello/spec/greeter_spec.rb new file mode 100644 index 0000000..a4eb1f1 --- /dev/null +++ b/week7/exercises/hello/spec/greeter_spec.rb @@ -0,0 +1,14 @@ +class RSpecGreeter + def greet + "Hello RSpec!" + end +end + +describe "RSpec Greeter" do + it "should say 'Hello RSpec!' when it receives the greet() message" do + greeter = RSpecGreeter.new + greeting = greeter.greet + greeting.should == "Hello RSpec!" + end +end + diff --git a/week7/homework/.idea/workspace.xml b/week7/homework/.idea/workspace.xml index 640c120..e7da4f1 100644 --- a/week7/homework/.idea/workspace.xml +++ b/week7/homework/.idea/workspace.xml @@ -12,11 +12,11 @@ + - - + - + - + - - + + - + - + - + - - + + - + @@ -132,8 +132,8 @@ @@ -225,7 +225,7 @@ - + @@ -488,7 +488,7 @@ - + @@ -496,7 +496,7 @@ - + @@ -528,11 +528,11 @@ file://$PROJECT_DIR$/features/step_definitions/tic-tac-toe.rb - 47 - - @@ -622,19 +622,14 @@ - - - - - - + - + - + @@ -651,14 +646,6 @@ - - - - - - - - @@ -770,42 +757,51 @@ - + - + + + - + - + - + - + - + - + - + - + + + + + + + + diff --git a/week7/homework/features/step_definitions/tic-tac-toe.rb b/week7/homework/features/step_definitions/tic-tac-toe.rb index c7806df..07237cd 100644 --- a/week7/homework/features/step_definitions/tic-tac-toe.rb +++ b/week7/homework/features/step_definitions/tic-tac-toe.rb @@ -26,7 +26,7 @@ def current_player def over? false if spots_open? - true if player_won? + true if player_won? || computer_won? end def computer_move @@ -38,7 +38,6 @@ def computer_move def indicate_palyer_turn puts "#{@player}'s Move:" - #get_player_move end def player_move @@ -64,32 +63,38 @@ def current_state end def determine_winner - true unless spots_open? + #return false if spots_open? - if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] + if @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] && @board[:A1] != " " @winner = @board[:A1] - elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] + elsif @board[:A2] == @board[:B2] && @board[:B2] == @board[:C2] && @board[:A2] != " " @winner = @board[:A2] - elsif @board[:A1] == @board[:B1] && @board[:B1] == @board[:C1] - @winner = @board[:C1] - elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] - @winner = @board[:C1] - elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] - @winner = @board[:C1] - elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] + elsif @board[:A3] == @board[:B3] && @board[:B3] == @board[:C3] && @board[:A3] != " " + @winner = @board[:A3] + elsif @board[:A1] == @board[:A2] && @board[:A2] == @board[:A3] && @board[:A1] != " " + @winner = @board[:A1] + elsif @board[:B1] == @board[:B2] && @board[:B2] == @board[:B3] && @board[:B1] != " " + @winner = @board[:B1] + elsif @board[:C1] == @board[:C2] && @board[:C2] == @board[:C3] && @board[:C1] != " " @winner = @board[:C1] - else - draw? + #else + # @winner = "draw" end + #return false if spots_open? over? + true end def player_won? - true if @winner = @player_symbol[:player] + true if @winner == @player_symbol[:player] end def draw? - true + true unless player_won? || computer_won? + end + + def computer_won? + @winner == @player_symbol[:computer] end def player_symbol diff --git a/week7/homework/play_game.rb b/week7/homework/play_game.rb index 7b99f10..0535830 100644 --- a/week7/homework/play_game.rb +++ b/week7/homework/play_game.rb @@ -10,7 +10,7 @@ when "Computer" @game.computer_move when @game.player - @game.indicate_player_turn + @game.indicate_palyer_turn @game.player_move end puts @game.current_state From 647dabf39e5140c18458d9e251d605edad648453 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:07:08 -0700 Subject: [PATCH 35/41] updtes --- .../.idea/.name | 0 .../.idea/cookbook-reader.iml | 70 +++ .../.idea/encodings.xml | 0 .../.idea/misc.xml | 0 .../.idea/modules.xml | 0 .../.idea/scopes/scope_settings.xml | 5 + .../.idea/vcs.xml | 0 cookbook-reader.orig/.idea/workspace.xml | 542 ++++++++++++++++++ cookbook-reader.orig/.ruby-gemset | 1 + cookbook-reader.orig/.ruby-version | 1 + cookbook-reader.orig/.travis.yml | 3 + cookbook-reader.orig/Gemfile | 3 + cookbook-reader.orig/Rakefile | 8 + cookbook-reader.orig/bin/cookbook-reader | 5 + .../lib/cookbook-reader/options.rb | 37 ++ .../lib/cookbook-reader/parser.rb | 82 +++ cookbook-reader.orig/spec/options_spec.rb | 9 + cookbook-reader.orig/spec/parser_spec.rb | 9 + cookbook-reader/.gitignore | 8 + cookbook-reader/.idea/cookbook-reader.iml | 143 +++++ cookbook-reader/.idea/workspace.xml | 488 ++++++++++++++-- cookbook-reader/.ruby-gemset | 1 + cookbook-reader/.ruby-version | 1 + cookbook-reader/.travis.yml | 3 + cookbook-reader/Gemfile | 3 + cookbook-reader/README.md | 7 + cookbook-reader/Rakefile | 7 + cookbook-reader/bin/cookbook-reader | 0 cookbook-reader/cookbook-reader.gemspec | 23 + cookbook-reader/lib/cookbook-reader/parser.rb | 34 +- cookbook-reader/spec/options_spec.rb | 19 + cookbook-reader/spec/parser_spec.rb | 15 + cookbook-reader/spec/spec_helper.rb | 12 + 33 files changed, 1481 insertions(+), 58 deletions(-) rename {cookbook-reader => cookbook-reader.orig}/.idea/.name (100%) create mode 100644 cookbook-reader.orig/.idea/cookbook-reader.iml rename {cookbook-reader => cookbook-reader.orig}/.idea/encodings.xml (100%) rename {cookbook-reader => cookbook-reader.orig}/.idea/misc.xml (100%) rename {cookbook-reader => cookbook-reader.orig}/.idea/modules.xml (100%) create mode 100644 cookbook-reader.orig/.idea/scopes/scope_settings.xml rename {cookbook-reader => cookbook-reader.orig}/.idea/vcs.xml (100%) create mode 100644 cookbook-reader.orig/.idea/workspace.xml create mode 100644 cookbook-reader.orig/.ruby-gemset create mode 100644 cookbook-reader.orig/.ruby-version create mode 100644 cookbook-reader.orig/.travis.yml create mode 100644 cookbook-reader.orig/Gemfile create mode 100644 cookbook-reader.orig/Rakefile create mode 100644 cookbook-reader.orig/bin/cookbook-reader create mode 100644 cookbook-reader.orig/lib/cookbook-reader/options.rb create mode 100644 cookbook-reader.orig/lib/cookbook-reader/parser.rb create mode 100644 cookbook-reader.orig/spec/options_spec.rb create mode 100644 cookbook-reader.orig/spec/parser_spec.rb create mode 100644 cookbook-reader/.gitignore create mode 100644 cookbook-reader/.ruby-gemset create mode 100644 cookbook-reader/.ruby-version create mode 100644 cookbook-reader/.travis.yml create mode 100644 cookbook-reader/Gemfile create mode 100644 cookbook-reader/README.md create mode 100644 cookbook-reader/Rakefile mode change 100644 => 100755 cookbook-reader/bin/cookbook-reader create mode 100644 cookbook-reader/cookbook-reader.gemspec create mode 100644 cookbook-reader/spec/options_spec.rb create mode 100644 cookbook-reader/spec/parser_spec.rb create mode 100644 cookbook-reader/spec/spec_helper.rb diff --git a/cookbook-reader/.idea/.name b/cookbook-reader.orig/.idea/.name similarity index 100% rename from cookbook-reader/.idea/.name rename to cookbook-reader.orig/.idea/.name diff --git a/cookbook-reader.orig/.idea/cookbook-reader.iml b/cookbook-reader.orig/.idea/cookbook-reader.iml new file mode 100644 index 0000000..2e175f9 --- /dev/null +++ b/cookbook-reader.orig/.idea/cookbook-reader.iml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/encodings.xml b/cookbook-reader.orig/.idea/encodings.xml similarity index 100% rename from cookbook-reader/.idea/encodings.xml rename to cookbook-reader.orig/.idea/encodings.xml diff --git a/cookbook-reader/.idea/misc.xml b/cookbook-reader.orig/.idea/misc.xml similarity index 100% rename from cookbook-reader/.idea/misc.xml rename to cookbook-reader.orig/.idea/misc.xml diff --git a/cookbook-reader/.idea/modules.xml b/cookbook-reader.orig/.idea/modules.xml similarity index 100% rename from cookbook-reader/.idea/modules.xml rename to cookbook-reader.orig/.idea/modules.xml diff --git a/cookbook-reader.orig/.idea/scopes/scope_settings.xml b/cookbook-reader.orig/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/cookbook-reader.orig/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cookbook-reader/.idea/vcs.xml b/cookbook-reader.orig/.idea/vcs.xml similarity index 100% rename from cookbook-reader/.idea/vcs.xml rename to cookbook-reader.orig/.idea/vcs.xml diff --git a/cookbook-reader.orig/.idea/workspace.xml b/cookbook-reader.orig/.idea/workspace.xml new file mode 100644 index 0000000..4bcc162 --- /dev/null +++ b/cookbook-reader.orig/.idea/workspace.xml @@ -0,0 +1,542 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1394649021318 + 1394649021318 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader.orig/.ruby-gemset b/cookbook-reader.orig/.ruby-gemset new file mode 100644 index 0000000..1dfef02 --- /dev/null +++ b/cookbook-reader.orig/.ruby-gemset @@ -0,0 +1 @@ +cookbook-reader diff --git a/cookbook-reader.orig/.ruby-version b/cookbook-reader.orig/.ruby-version new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/cookbook-reader.orig/.ruby-version @@ -0,0 +1 @@ +2.1.0 diff --git a/cookbook-reader.orig/.travis.yml b/cookbook-reader.orig/.travis.yml new file mode 100644 index 0000000..938d4ef --- /dev/null +++ b/cookbook-reader.orig/.travis.yml @@ -0,0 +1,3 @@ +rvm: + - 2.1.0 +script: "rake spec" diff --git a/cookbook-reader.orig/Gemfile b/cookbook-reader.orig/Gemfile new file mode 100644 index 0000000..c80ee36 --- /dev/null +++ b/cookbook-reader.orig/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/cookbook-reader.orig/Rakefile b/cookbook-reader.orig/Rakefile new file mode 100644 index 0000000..23e6b46 --- /dev/null +++ b/cookbook-reader.orig/Rakefile @@ -0,0 +1,8 @@ +require "bundler/gem_tasks" +require 'rspec/core/rake_task' + +desc 'Run specs' + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = %w(--color) +end diff --git a/cookbook-reader.orig/bin/cookbook-reader b/cookbook-reader.orig/bin/cookbook-reader new file mode 100644 index 0000000..fbca8a3 --- /dev/null +++ b/cookbook-reader.orig/bin/cookbook-reader @@ -0,0 +1,5 @@ +#! /usr/bin/ruby +require 'cookbook-reader/parser' +parser = CookbookReader::Parser.new(ARGV) +parser.parse +parser.display_data diff --git a/cookbook-reader.orig/lib/cookbook-reader/options.rb b/cookbook-reader.orig/lib/cookbook-reader/options.rb new file mode 100644 index 0000000..cf26748 --- /dev/null +++ b/cookbook-reader.orig/lib/cookbook-reader/options.rb @@ -0,0 +1,37 @@ +require 'optparse' + +module CookbookReader + class Options + + attr_reader :path_to_search + + def initialize(argv) + parse(argv) + end + + private + + def parse(argv) + OptionParser.new do |opts| + opts.banner = "Usage: cookbook-reader --path path ..." + + opts.on("-p", "--path path", String, "Path to search") do |path| + @path_to_search = path + end + + opts.on("-h", "--help", "Show this message") do + puts opts + exit + end + + begin + argv = ["-h"] if argv.empty? + opts.parse!(argv) + rescue OptionParser::ParseError => e + STDERR.puts e.message, "\n", opts + exit(-1) + end + end + end + end +end diff --git a/cookbook-reader.orig/lib/cookbook-reader/parser.rb b/cookbook-reader.orig/lib/cookbook-reader/parser.rb new file mode 100644 index 0000000..f6727a5 --- /dev/null +++ b/cookbook-reader.orig/lib/cookbook-reader/parser.rb @@ -0,0 +1,82 @@ +require_relative 'options' +module CookbookReader + class Parser + def initialize(argv) + @options = Options.new(argv) + @top_list = [] + end + + def run + finder = Finder.from_file(@options.dictionary) + @options.words_to_find.each do |word| + anagrams = finder.lookup(word) + if anagrams + puts "Anagrams of #{word}: #{anagrams.join(', ')}" + else + puts "No anagrams of #{word} in #{@options.dictionary}" + end + end + end + + def parse + @metadata_list = Array.new + Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| + @metadata_list.push read_file filename + + + end + end + + def display_data + #pp @top_list + + @top_list.each do |element| + puts "Cookbook: #{element['name']}\n" + puts " Dependancies:" + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + puts "\n" + end + end + + private + def read_file(filename) + @hash = {} + + @depends_list = {} + File.open(filename) do |fp| + fp.each do |line| + key, value = line.chomp.split(" ") + key.strip! + value.strip! + key = key.chomp('"').reverse.chomp('"').reverse + value = value.chomp('"').reverse.chomp('"').reverse + + if key =~ /depends/ + @hash[key] = add_dependencies(line) + else + @hash[key] = value + end + end + end + @top_list.push @hash + + end + + def add_dependencies(line) + line.slice! "depends " + k, v = line.chomp.split(",") + v = "none" if v.nil? + k.strip! + v.strip! + v = v.chomp('"').reverse.chomp('"').reverse + v = v.chomp('"').reverse.chomp('"').reverse + k = k.chomp('"').reverse.chomp('"').reverse + k.strip! + v.strip! + @depends_list[k] = v + @depends_list + end + end +end diff --git a/cookbook-reader.orig/spec/options_spec.rb b/cookbook-reader.orig/spec/options_spec.rb new file mode 100644 index 0000000..eacccb6 --- /dev/null +++ b/cookbook-reader.orig/spec/options_spec.rb @@ -0,0 +1,9 @@ +require "../lib/cookbook-reader/options" + +describe CookbookReader::Options do + + it "executes a block and returns a string" do + pending + end + +end \ No newline at end of file diff --git a/cookbook-reader.orig/spec/parser_spec.rb b/cookbook-reader.orig/spec/parser_spec.rb new file mode 100644 index 0000000..4708c40 --- /dev/null +++ b/cookbook-reader.orig/spec/parser_spec.rb @@ -0,0 +1,9 @@ +require "../lib/cookbook-reader/parser" + +describe CookbookReader::Parser do + + it "executes a block and returns a string" do + pending + end + +end \ No newline at end of file diff --git a/cookbook-reader/.gitignore b/cookbook-reader/.gitignore new file mode 100644 index 0000000..f714d63 --- /dev/null +++ b/cookbook-reader/.gitignore @@ -0,0 +1,8 @@ +*.gem +.bundle +Gemfile.lock +pkg/* +coverage +*.swp +.idea/* +.DS_Store diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml index b8d0590..814918c 100644 --- a/cookbook-reader/.idea/cookbook-reader.iml +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -25,11 +25,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml index f3fd295..499517b 100644 --- a/cookbook-reader/.idea/workspace.xml +++ b/cookbook-reader/.idea/workspace.xml @@ -12,7 +12,11 @@ - + + + + + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -92,14 +132,38 @@ + + + + + + + + + Ruby + + + + + RubyResolve + + + + @@ -146,6 +210,20 @@ - + @@ -213,6 +291,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -236,12 +476,20 @@ - + + + + + - - + + + + + + @@ -255,20 +503,20 @@ - - + + - - + + - + - - - - - - + + + + + + @@ -295,18 +543,39 @@ - file://$PROJECT_DIR$/lib/cookbook-reader/parser.rb - 41 - - + + + + + + + + + + + + + + + + + + + + + @@ -321,30 +590,163 @@ + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.ruby-gemset b/cookbook-reader/.ruby-gemset new file mode 100644 index 0000000..1dfef02 --- /dev/null +++ b/cookbook-reader/.ruby-gemset @@ -0,0 +1 @@ +cookbook-reader diff --git a/cookbook-reader/.ruby-version b/cookbook-reader/.ruby-version new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/cookbook-reader/.ruby-version @@ -0,0 +1 @@ +2.1.0 diff --git a/cookbook-reader/.travis.yml b/cookbook-reader/.travis.yml new file mode 100644 index 0000000..938d4ef --- /dev/null +++ b/cookbook-reader/.travis.yml @@ -0,0 +1,3 @@ +rvm: + - 2.1.0 +script: "rake spec" diff --git a/cookbook-reader/Gemfile b/cookbook-reader/Gemfile new file mode 100644 index 0000000..c80ee36 --- /dev/null +++ b/cookbook-reader/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md new file mode 100644 index 0000000..c202db0 --- /dev/null +++ b/cookbook-reader/README.md @@ -0,0 +1,7 @@ +[![Build Status](https://secure.travis-ci.org/keviny22/cookbook-reader.png)](http://travis-ci.org/keviny22/cookbook-reader) + + +cookbook-reader +=============== + +A gem for reading a cookbook, for learning Ruby only diff --git a/cookbook-reader/Rakefile b/cookbook-reader/Rakefile new file mode 100644 index 0000000..c557124 --- /dev/null +++ b/cookbook-reader/Rakefile @@ -0,0 +1,7 @@ +require 'rspec/core/rake_task' + +desc 'Run specs' + +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = %w(--color) +end diff --git a/cookbook-reader/bin/cookbook-reader b/cookbook-reader/bin/cookbook-reader old mode 100644 new mode 100755 diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec new file mode 100644 index 0000000..ec1ea32 --- /dev/null +++ b/cookbook-reader/cookbook-reader.gemspec @@ -0,0 +1,23 @@ +Gem::Specification.new do |s| + s.name = 'cookbook-reader' + s.version = '0.1.0' + s.date = '2014-03-12' + s.summary = "cookbook version parser" + s.description = "A gem that parses cookbook metadata" + s.authors = ["Kevin Young"] + s.email = 'kevin@young.net' + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] + + s.homepage = 'http://rubygems.org/gems/cookbook-reader' + s.license = 'MIT' + + s.add_development_dependency "fakefs", "~> 0.4.2" + s.add_development_dependency "rake" + s.add_development_dependency "rspec", "~> 2.13.0" + s.add_development_dependency "simplecov", "~> 0.7.1" + s.add_development_dependency "timecop", "~> 0.6.1" +end diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb index 2108a9d..72a74b3 100644 --- a/cookbook-reader/lib/cookbook-reader/parser.rb +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -6,29 +6,22 @@ def initialize(argv) @top_list = [] end - def run - finder = Finder.from_file(@options.dictionary) - @options.words_to_find.each do |word| - anagrams = finder.lookup(word) - if anagrams - puts "Anagrams of #{word}: #{anagrams.join(', ')}" - else - puts "No anagrams of #{word} in #{@options.dictionary}" - end - end - end - def parse @metadata_list = Array.new Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| @metadata_list.push read_file filename - - end end def display_data - pp @top_list + @top_list.each do |element| + puts "Cookbook: #{element['name']}\n" + puts " Dependancies:" + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + puts "\n" + end end private @@ -39,8 +32,11 @@ def read_file(filename) File.open(filename) do |fp| fp.each do |line| key, value = line.chomp.split(" ") + key.strip! + value.strip! key = key.chomp('"').reverse.chomp('"').reverse value = value.chomp('"').reverse.chomp('"').reverse + if key =~ /depends/ @hash[key] = add_dependencies(line) else @@ -55,6 +51,14 @@ def read_file(filename) def add_dependencies(line) line.slice! "depends " k, v = line.chomp.split(",") + v = "none" if v.nil? + k.strip! + v.strip! + v = v.chomp('"').reverse.chomp('"').reverse + v = v.chomp('"').reverse.chomp('"').reverse + k = k.chomp('"').reverse.chomp('"').reverse + k.strip! + v.strip! @depends_list[k] = v @depends_list end diff --git a/cookbook-reader/spec/options_spec.rb b/cookbook-reader/spec/options_spec.rb new file mode 100644 index 0000000..fd46607 --- /dev/null +++ b/cookbook-reader/spec/options_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module CookbookReader + describe Options do + + it "should call the given sub command" do + pending("I hate rpsec") + end + + it "should display help when passed --help" do + pending("I hate rpsec") + end + + it "should display help when passed nothing" do + pending("I hate rpsec") + end + + end +end diff --git a/cookbook-reader/spec/parser_spec.rb b/cookbook-reader/spec/parser_spec.rb new file mode 100644 index 0000000..fab5cbc --- /dev/null +++ b/cookbook-reader/spec/parser_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +module CookbookReader + describe Parser do + + it "should display the data" do + pending("I hate rpsec") + end + + it "should parse the data" do + pending("I hate rpsec") + end + + end +end \ No newline at end of file diff --git a/cookbook-reader/spec/spec_helper.rb b/cookbook-reader/spec/spec_helper.rb new file mode 100644 index 0000000..757b400 --- /dev/null +++ b/cookbook-reader/spec/spec_helper.rb @@ -0,0 +1,12 @@ + +require 'rubygems' +require 'bundler/setup' +require 'fakefs/safe' + + +require_relative '../lib/cookbook-reader/options' +require_relative '../lib/cookbook-reader/parser' + +['contexts'].each do |dir| + Dir[File.expand_path(File.join(File.dirname(__FILE__),dir,'*.rb'))].each {|f| require f} +end From 66b196b65239548dab26ec261afb3270852f5dd2 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:31:41 -0700 Subject: [PATCH 36/41] updated_gemspec --- cookbook-reader/Gemfile | 2 +- cookbook-reader/cookbook-reader.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook-reader/Gemfile b/cookbook-reader/Gemfile index c80ee36..07177f9 100644 --- a/cookbook-reader/Gemfile +++ b/cookbook-reader/Gemfile @@ -1,3 +1,3 @@ source "http://rubygems.org" - +gem 'rspec', :require => 'spec' gemspec diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec index ec1ea32..716d2ee 100644 --- a/cookbook-reader/cookbook-reader.gemspec +++ b/cookbook-reader/cookbook-reader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'cookbook-reader' - s.version = '0.1.0' + s.version = '0.1.1' s.date = '2014-03-12' s.summary = "cookbook version parser" s.description = "A gem that parses cookbook metadata" From c6973bdb9b6b88c3c9d0d92c0a1c331c852f3882 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 11:41:00 -0700 Subject: [PATCH 37/41] updates --- .gitignore | 3 + cookbook-reader.orig/.idea/.name | 1 - .../.idea/cookbook-reader.iml | 70 --- cookbook-reader.orig/.idea/encodings.xml | 5 - cookbook-reader.orig/.idea/misc.xml | 5 - cookbook-reader.orig/.idea/modules.xml | 9 - .../.idea/scopes/scope_settings.xml | 5 - cookbook-reader.orig/.idea/vcs.xml | 7 - cookbook-reader.orig/.idea/workspace.xml | 542 ------------------ cookbook-reader.orig/.ruby-gemset | 1 - cookbook-reader.orig/.ruby-version | 1 - cookbook-reader.orig/.travis.yml | 3 - cookbook-reader.orig/Gemfile | 3 - cookbook-reader.orig/Rakefile | 8 - cookbook-reader.orig/bin/cookbook-reader | 5 - .../lib/cookbook-reader/options.rb | 37 -- .../lib/cookbook-reader/parser.rb | 82 --- cookbook-reader.orig/spec/options_spec.rb | 9 - cookbook-reader.orig/spec/parser_spec.rb | 9 - cookbook-reader/README.md | 13 +- 20 files changed, 15 insertions(+), 803 deletions(-) delete mode 100644 cookbook-reader.orig/.idea/.name delete mode 100644 cookbook-reader.orig/.idea/cookbook-reader.iml delete mode 100644 cookbook-reader.orig/.idea/encodings.xml delete mode 100644 cookbook-reader.orig/.idea/misc.xml delete mode 100644 cookbook-reader.orig/.idea/modules.xml delete mode 100644 cookbook-reader.orig/.idea/scopes/scope_settings.xml delete mode 100644 cookbook-reader.orig/.idea/vcs.xml delete mode 100644 cookbook-reader.orig/.idea/workspace.xml delete mode 100644 cookbook-reader.orig/.ruby-gemset delete mode 100644 cookbook-reader.orig/.ruby-version delete mode 100644 cookbook-reader.orig/.travis.yml delete mode 100644 cookbook-reader.orig/Gemfile delete mode 100644 cookbook-reader.orig/Rakefile delete mode 100644 cookbook-reader.orig/bin/cookbook-reader delete mode 100644 cookbook-reader.orig/lib/cookbook-reader/options.rb delete mode 100644 cookbook-reader.orig/lib/cookbook-reader/parser.rb delete mode 100644 cookbook-reader.orig/spec/options_spec.rb delete mode 100644 cookbook-reader.orig/spec/parser_spec.rb diff --git a/.gitignore b/.gitignore index e43b0f9..2e3dedd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +cookbooks +cookbook-reader.orig +cookbook-reader diff --git a/cookbook-reader.orig/.idea/.name b/cookbook-reader.orig/.idea/.name deleted file mode 100644 index 5d5341c..0000000 --- a/cookbook-reader.orig/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -cookbook-reader \ No newline at end of file diff --git a/cookbook-reader.orig/.idea/cookbook-reader.iml b/cookbook-reader.orig/.idea/cookbook-reader.iml deleted file mode 100644 index 2e175f9..0000000 --- a/cookbook-reader.orig/.idea/cookbook-reader.iml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader.orig/.idea/encodings.xml b/cookbook-reader.orig/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/cookbook-reader.orig/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/cookbook-reader.orig/.idea/misc.xml b/cookbook-reader.orig/.idea/misc.xml deleted file mode 100644 index 271c40f..0000000 --- a/cookbook-reader.orig/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/cookbook-reader.orig/.idea/modules.xml b/cookbook-reader.orig/.idea/modules.xml deleted file mode 100644 index 8731703..0000000 --- a/cookbook-reader.orig/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/cookbook-reader.orig/.idea/scopes/scope_settings.xml b/cookbook-reader.orig/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/cookbook-reader.orig/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/cookbook-reader.orig/.idea/vcs.xml b/cookbook-reader.orig/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/cookbook-reader.orig/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/cookbook-reader.orig/.idea/workspace.xml b/cookbook-reader.orig/.idea/workspace.xml deleted file mode 100644 index 4bcc162..0000000 --- a/cookbook-reader.orig/.idea/workspace.xml +++ /dev/null @@ -1,542 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1394649021318 - 1394649021318 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader.orig/.ruby-gemset b/cookbook-reader.orig/.ruby-gemset deleted file mode 100644 index 1dfef02..0000000 --- a/cookbook-reader.orig/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -cookbook-reader diff --git a/cookbook-reader.orig/.ruby-version b/cookbook-reader.orig/.ruby-version deleted file mode 100644 index 7ec1d6d..0000000 --- a/cookbook-reader.orig/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.1.0 diff --git a/cookbook-reader.orig/.travis.yml b/cookbook-reader.orig/.travis.yml deleted file mode 100644 index 938d4ef..0000000 --- a/cookbook-reader.orig/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -rvm: - - 2.1.0 -script: "rake spec" diff --git a/cookbook-reader.orig/Gemfile b/cookbook-reader.orig/Gemfile deleted file mode 100644 index c80ee36..0000000 --- a/cookbook-reader.orig/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "http://rubygems.org" - -gemspec diff --git a/cookbook-reader.orig/Rakefile b/cookbook-reader.orig/Rakefile deleted file mode 100644 index 23e6b46..0000000 --- a/cookbook-reader.orig/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -require "bundler/gem_tasks" -require 'rspec/core/rake_task' - -desc 'Run specs' - -RSpec::Core::RakeTask.new do |t| - t.rspec_opts = %w(--color) -end diff --git a/cookbook-reader.orig/bin/cookbook-reader b/cookbook-reader.orig/bin/cookbook-reader deleted file mode 100644 index fbca8a3..0000000 --- a/cookbook-reader.orig/bin/cookbook-reader +++ /dev/null @@ -1,5 +0,0 @@ -#! /usr/bin/ruby -require 'cookbook-reader/parser' -parser = CookbookReader::Parser.new(ARGV) -parser.parse -parser.display_data diff --git a/cookbook-reader.orig/lib/cookbook-reader/options.rb b/cookbook-reader.orig/lib/cookbook-reader/options.rb deleted file mode 100644 index cf26748..0000000 --- a/cookbook-reader.orig/lib/cookbook-reader/options.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'optparse' - -module CookbookReader - class Options - - attr_reader :path_to_search - - def initialize(argv) - parse(argv) - end - - private - - def parse(argv) - OptionParser.new do |opts| - opts.banner = "Usage: cookbook-reader --path path ..." - - opts.on("-p", "--path path", String, "Path to search") do |path| - @path_to_search = path - end - - opts.on("-h", "--help", "Show this message") do - puts opts - exit - end - - begin - argv = ["-h"] if argv.empty? - opts.parse!(argv) - rescue OptionParser::ParseError => e - STDERR.puts e.message, "\n", opts - exit(-1) - end - end - end - end -end diff --git a/cookbook-reader.orig/lib/cookbook-reader/parser.rb b/cookbook-reader.orig/lib/cookbook-reader/parser.rb deleted file mode 100644 index f6727a5..0000000 --- a/cookbook-reader.orig/lib/cookbook-reader/parser.rb +++ /dev/null @@ -1,82 +0,0 @@ -require_relative 'options' -module CookbookReader - class Parser - def initialize(argv) - @options = Options.new(argv) - @top_list = [] - end - - def run - finder = Finder.from_file(@options.dictionary) - @options.words_to_find.each do |word| - anagrams = finder.lookup(word) - if anagrams - puts "Anagrams of #{word}: #{anagrams.join(', ')}" - else - puts "No anagrams of #{word} in #{@options.dictionary}" - end - end - end - - def parse - @metadata_list = Array.new - Dir.glob("#{@options.path_to_search}/**/metadata.rb") do |filename| - @metadata_list.push read_file filename - - - end - end - - def display_data - #pp @top_list - - @top_list.each do |element| - puts "Cookbook: #{element['name']}\n" - puts " Dependancies:" - element['depends'].each do |name, version| - puts " #{name}, #{version}\n" - end - puts "\n" - end - end - - private - def read_file(filename) - @hash = {} - - @depends_list = {} - File.open(filename) do |fp| - fp.each do |line| - key, value = line.chomp.split(" ") - key.strip! - value.strip! - key = key.chomp('"').reverse.chomp('"').reverse - value = value.chomp('"').reverse.chomp('"').reverse - - if key =~ /depends/ - @hash[key] = add_dependencies(line) - else - @hash[key] = value - end - end - end - @top_list.push @hash - - end - - def add_dependencies(line) - line.slice! "depends " - k, v = line.chomp.split(",") - v = "none" if v.nil? - k.strip! - v.strip! - v = v.chomp('"').reverse.chomp('"').reverse - v = v.chomp('"').reverse.chomp('"').reverse - k = k.chomp('"').reverse.chomp('"').reverse - k.strip! - v.strip! - @depends_list[k] = v - @depends_list - end - end -end diff --git a/cookbook-reader.orig/spec/options_spec.rb b/cookbook-reader.orig/spec/options_spec.rb deleted file mode 100644 index eacccb6..0000000 --- a/cookbook-reader.orig/spec/options_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "../lib/cookbook-reader/options" - -describe CookbookReader::Options do - - it "executes a block and returns a string" do - pending - end - -end \ No newline at end of file diff --git a/cookbook-reader.orig/spec/parser_spec.rb b/cookbook-reader.orig/spec/parser_spec.rb deleted file mode 100644 index 4708c40..0000000 --- a/cookbook-reader.orig/spec/parser_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "../lib/cookbook-reader/parser" - -describe CookbookReader::Parser do - - it "executes a block and returns a string" do - pending - end - -end \ No newline at end of file diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md index c202db0..9dcc584 100644 --- a/cookbook-reader/README.md +++ b/cookbook-reader/README.md @@ -4,4 +4,15 @@ cookbook-reader =============== -A gem for reading a cookbook, for learning Ruby only +A gem for reading a cookbooks metadata, created for learning Ruby. +Currently displays all of the dependancies of all cookbooks in the path. + +Installation: + +`gem install cookbook-reader` + +Usage: + +cookbook-reader --path + + From 00d6435bcda75d43932993486bfe470e6f3babb4 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 14:36:17 -0700 Subject: [PATCH 38/41] updates --- cookbook-reader/.gitignore | 1 - cookbook-reader/.idea/cookbook-reader.iml | 68 ++++---- cookbook-reader/.idea/workspace.xml | 165 +++++++++--------- cookbook-reader/README.md | 4 +- cookbook-reader/cookbook-reader.gemspec | 4 +- cookbook-reader/lib/cookbook-reader/parser.rb | 13 +- 6 files changed, 129 insertions(+), 126 deletions(-) diff --git a/cookbook-reader/.gitignore b/cookbook-reader/.gitignore index f714d63..0f43d20 100644 --- a/cookbook-reader/.gitignore +++ b/cookbook-reader/.gitignore @@ -1,6 +1,5 @@ *.gem .bundle -Gemfile.lock pkg/* coverage *.swp diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml index 814918c..e23f000 100644 --- a/cookbook-reader/.idea/cookbook-reader.iml +++ b/cookbook-reader/.idea/cookbook-reader.iml @@ -1,42 +1,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -45,7 +21,7 @@ - + @@ -56,22 +32,24 @@ + + - + - + - + @@ -80,7 +58,7 @@ - + @@ -91,9 +69,7 @@ - - @@ -134,6 +110,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml index 499517b..5be5391 100644 --- a/cookbook-reader/.idea/workspace.xml +++ b/cookbook-reader/.idea/workspace.xml @@ -15,7 +15,7 @@ - + @@ -30,15 +30,6 @@ - - - - - - - - - @@ -48,10 +39,10 @@ - + - + @@ -93,6 +84,15 @@ + + + + + + + + + @@ -135,9 +135,9 @@ @@ -266,43 +266,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + @@ -311,7 +287,7 @@ - + @@ -322,22 +298,24 @@ + + - + - + - + @@ -346,7 +324,7 @@ - + @@ -357,9 +335,7 @@ - - @@ -477,23 +453,39 @@ - + - - + + - + - + + @@ -504,18 +496,18 @@ - + - + - + @@ -547,11 +539,16 @@ 2 @@ -639,13 +636,6 @@ - - - - - - - @@ -681,72 +671,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + diff --git a/cookbook-reader/README.md b/cookbook-reader/README.md index 9dcc584..2936989 100644 --- a/cookbook-reader/README.md +++ b/cookbook-reader/README.md @@ -1,4 +1,6 @@ [![Build Status](https://secure.travis-ci.org/keviny22/cookbook-reader.png)](http://travis-ci.org/keviny22/cookbook-reader) +[![Gem Version](https://badge.fury.io/rb/cookbook-reader.png)](http://badge.fury.io/rb/cookbook-reader) +[![Code Climate](https://codeclimate.com/github/keviny22/cookbook-reader.png)](https://codeclimate.com/github/keviny22/cookbook-reader) cookbook-reader @@ -13,6 +15,6 @@ Installation: Usage: -cookbook-reader --path +cookbook-reader --path {path to cookbook directory} diff --git a/cookbook-reader/cookbook-reader.gemspec b/cookbook-reader/cookbook-reader.gemspec index 716d2ee..eaeeab9 100644 --- a/cookbook-reader/cookbook-reader.gemspec +++ b/cookbook-reader/cookbook-reader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'cookbook-reader' - s.version = '0.1.1' + s.version = '0.1.2' s.date = '2014-03-12' s.summary = "cookbook version parser" s.description = "A gem that parses cookbook metadata" @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.homepage = 'http://rubygems.org/gems/cookbook-reader' + s.homepage = 'https://github.com/keviny22/cookbook-reader' s.license = 'MIT' s.add_development_dependency "fakefs", "~> 0.4.2" diff --git a/cookbook-reader/lib/cookbook-reader/parser.rb b/cookbook-reader/lib/cookbook-reader/parser.rb index 72a74b3..300643d 100644 --- a/cookbook-reader/lib/cookbook-reader/parser.rb +++ b/cookbook-reader/lib/cookbook-reader/parser.rb @@ -17,8 +17,12 @@ def display_data @top_list.each do |element| puts "Cookbook: #{element['name']}\n" puts " Dependancies:" - element['depends'].each do |name, version| - puts " #{name}, #{version}\n" + if element['depends'] + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + else + puts " None\n" end puts "\n" end @@ -32,8 +36,9 @@ def read_file(filename) File.open(filename) do |fp| fp.each do |line| key, value = line.chomp.split(" ") - key.strip! - value.strip! + next if key.nil? || value.nil? + key.strip! unless key.nil? + value.strip! unless value.nil? key = key.chomp('"').reverse.chomp('"').reverse value = value.chomp('"').reverse.chomp('"').reverse From d42da6c2242b8b53ac1fc0bf0668d615811fe7de Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 14:47:43 -0700 Subject: [PATCH 39/41] updates --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e3dedd..cde7c7a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ cookbooks cookbook-reader.orig cookbook-reader +.idea From e0972ab413c05349001c8ae88073c52942b85f70 Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 14:49:30 -0700 Subject: [PATCH 40/41] updates --- .idea/.name | 1 - .idea/RubyWinter2014.iml | 141 --- .idea/encodings.xml | 5 - .idea/misc.xml | 5 - .idea/modules.xml | 9 - .idea/scopes/scope_settings.xml | 5 - .idea/vcs.xml | 7 - .idea/workspace.xml | 685 --------------- cookbook-reader/.idea/cookbook-reader.iml | 178 ---- .../.idea/scopes/scope_settings.xml | 5 - cookbook-reader/.idea/workspace.xml | 753 ---------------- midterm/.idea/.name | 1 - midterm/.idea/encodings.xml | 5 - midterm/.idea/midterm.iml | 142 --- midterm/.idea/misc.xml | 5 - midterm/.idea/modules.xml | 9 - midterm/.idea/scopes/scope_settings.xml | 5 - midterm/.idea/vcs.xml | 7 - midterm/.idea/workspace.xml | 653 -------------- week7/exercises/hello/.idea/.name | 1 - week7/exercises/hello/.idea/encodings.xml | 5 - week7/exercises/hello/.idea/hello.iml | 50 -- week7/exercises/hello/.idea/misc.xml | 5 - week7/exercises/hello/.idea/modules.xml | 9 - .../hello/.idea/scopes/scope_settings.xml | 5 - week7/exercises/hello/.idea/vcs.xml | 7 - week7/exercises/hello/.idea/workspace.xml | 421 --------- week7/homework/.idea/.name | 1 - week7/homework/.idea/encodings.xml | 5 - week7/homework/.idea/homework.iml | 162 ---- week7/homework/.idea/misc.xml | 5 - week7/homework/.idea/modules.xml | 9 - .../homework/.idea/scopes/scope_settings.xml | 5 - week7/homework/.idea/vcs.xml | 7 - week7/homework/.idea/workspace.xml | 811 ------------------ 35 files changed, 4129 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/RubyWinter2014.iml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/scopes/scope_settings.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml delete mode 100644 cookbook-reader/.idea/cookbook-reader.iml delete mode 100644 cookbook-reader/.idea/scopes/scope_settings.xml delete mode 100644 cookbook-reader/.idea/workspace.xml delete mode 100644 midterm/.idea/.name delete mode 100644 midterm/.idea/encodings.xml delete mode 100644 midterm/.idea/midterm.iml delete mode 100644 midterm/.idea/misc.xml delete mode 100644 midterm/.idea/modules.xml delete mode 100644 midterm/.idea/scopes/scope_settings.xml delete mode 100644 midterm/.idea/vcs.xml delete mode 100644 midterm/.idea/workspace.xml delete mode 100644 week7/exercises/hello/.idea/.name delete mode 100644 week7/exercises/hello/.idea/encodings.xml delete mode 100644 week7/exercises/hello/.idea/hello.iml delete mode 100644 week7/exercises/hello/.idea/misc.xml delete mode 100644 week7/exercises/hello/.idea/modules.xml delete mode 100644 week7/exercises/hello/.idea/scopes/scope_settings.xml delete mode 100644 week7/exercises/hello/.idea/vcs.xml delete mode 100644 week7/exercises/hello/.idea/workspace.xml delete mode 100644 week7/homework/.idea/.name delete mode 100644 week7/homework/.idea/encodings.xml delete mode 100644 week7/homework/.idea/homework.iml delete mode 100644 week7/homework/.idea/misc.xml delete mode 100644 week7/homework/.idea/modules.xml delete mode 100644 week7/homework/.idea/scopes/scope_settings.xml delete mode 100644 week7/homework/.idea/vcs.xml delete mode 100644 week7/homework/.idea/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index fdb70fb..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -RubyWinter2014 \ No newline at end of file diff --git a/.idea/RubyWinter2014.iml b/.idea/RubyWinter2014.iml deleted file mode 100644 index f925dd8..0000000 --- a/.idea/RubyWinter2014.iml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ea782b3..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 241ede5..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index c80f219..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 7143d06..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,685 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1389931367465 - 1389931367465 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/week2/exercises/book.rb - 4 - - - file://$PROJECT_DIR$/week3/homework/calculator.rb - 19 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader/.idea/cookbook-reader.iml b/cookbook-reader/.idea/cookbook-reader.iml deleted file mode 100644 index e23f000..0000000 --- a/cookbook-reader/.idea/cookbook-reader.iml +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cookbook-reader/.idea/scopes/scope_settings.xml b/cookbook-reader/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/cookbook-reader/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/cookbook-reader/.idea/workspace.xml b/cookbook-reader/.idea/workspace.xml deleted file mode 100644 index 5be5391..0000000 --- a/cookbook-reader/.idea/workspace.xml +++ /dev/null @@ -1,753 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ruby - - - - - RubyResolve - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1394649021318 - 1394649021318 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/spec/options_spec.rb - 2 - - - file://$PROJECT_DIR$/lib/cookbook-reader/parser.rb - 51 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/midterm/.idea/.name b/midterm/.idea/.name deleted file mode 100644 index dda36a8..0000000 --- a/midterm/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -midterm \ No newline at end of file diff --git a/midterm/.idea/encodings.xml b/midterm/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/midterm/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/midterm/.idea/midterm.iml b/midterm/.idea/midterm.iml deleted file mode 100644 index 4801022..0000000 --- a/midterm/.idea/midterm.iml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/midterm/.idea/misc.xml b/midterm/.idea/misc.xml deleted file mode 100644 index 271c40f..0000000 --- a/midterm/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/midterm/.idea/modules.xml b/midterm/.idea/modules.xml deleted file mode 100644 index cbe1fd7..0000000 --- a/midterm/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/midterm/.idea/scopes/scope_settings.xml b/midterm/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/midterm/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/midterm/.idea/vcs.xml b/midterm/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/midterm/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/midterm/.idea/workspace.xml b/midterm/.idea/workspace.xml deleted file mode 100644 index ac8ca6d..0000000 --- a/midterm/.idea/workspace.xml +++ /dev/null @@ -1,653 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1392852566659 - 1392852566659 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/week7/exercises/hello/.idea/.name b/week7/exercises/hello/.idea/.name deleted file mode 100644 index b6fc4c6..0000000 --- a/week7/exercises/hello/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -hello \ No newline at end of file diff --git a/week7/exercises/hello/.idea/encodings.xml b/week7/exercises/hello/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/week7/exercises/hello/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/week7/exercises/hello/.idea/hello.iml b/week7/exercises/hello/.idea/hello.iml deleted file mode 100644 index ea67099..0000000 --- a/week7/exercises/hello/.idea/hello.iml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/week7/exercises/hello/.idea/misc.xml b/week7/exercises/hello/.idea/misc.xml deleted file mode 100644 index 271c40f..0000000 --- a/week7/exercises/hello/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/week7/exercises/hello/.idea/modules.xml b/week7/exercises/hello/.idea/modules.xml deleted file mode 100644 index 6e7c41b..0000000 --- a/week7/exercises/hello/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/week7/exercises/hello/.idea/scopes/scope_settings.xml b/week7/exercises/hello/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/week7/exercises/hello/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/week7/exercises/hello/.idea/vcs.xml b/week7/exercises/hello/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/week7/exercises/hello/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/week7/exercises/hello/.idea/workspace.xml b/week7/exercises/hello/.idea/workspace.xml deleted file mode 100644 index cfee28a..0000000 --- a/week7/exercises/hello/.idea/workspace.xml +++ /dev/null @@ -1,421 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1394165119992 - 1394165119992 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/week7/homework/.idea/.name b/week7/homework/.idea/.name deleted file mode 100644 index 158b7eb..0000000 --- a/week7/homework/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -homework \ No newline at end of file diff --git a/week7/homework/.idea/encodings.xml b/week7/homework/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/week7/homework/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/week7/homework/.idea/homework.iml b/week7/homework/.idea/homework.iml deleted file mode 100644 index 8057322..0000000 --- a/week7/homework/.idea/homework.iml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/week7/homework/.idea/misc.xml b/week7/homework/.idea/misc.xml deleted file mode 100644 index 271c40f..0000000 --- a/week7/homework/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/week7/homework/.idea/modules.xml b/week7/homework/.idea/modules.xml deleted file mode 100644 index f766474..0000000 --- a/week7/homework/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/week7/homework/.idea/scopes/scope_settings.xml b/week7/homework/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/week7/homework/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/week7/homework/.idea/vcs.xml b/week7/homework/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/week7/homework/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/week7/homework/.idea/workspace.xml b/week7/homework/.idea/workspace.xml deleted file mode 100644 index e7da4f1..0000000 --- a/week7/homework/.idea/workspace.xml +++ /dev/null @@ -1,811 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1394167333043 - 1394167333043 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/features/step_definitions/tic-tac-toe.rb - 67 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 093640b37054cb9135d44c89e288cd30181f773f Mon Sep 17 00:00:00 2001 From: keviny22 Date: Thu, 13 Mar 2014 14:53:24 -0700 Subject: [PATCH 41/41] updates --- .idea/.name | 1 - .idea/RubyWinter2014.iml | 141 ------- .idea/encodings.xml | 5 - .idea/misc.xml | 5 - .idea/modules.xml | 9 - .idea/scopes/scope_settings.xml | 5 - .idea/vcs.xml | 7 - .idea/workspace.xml | 685 -------------------------------- 8 files changed, 858 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/RubyWinter2014.iml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/scopes/scope_settings.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index fdb70fb..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -RubyWinter2014 \ No newline at end of file diff --git a/.idea/RubyWinter2014.iml b/.idea/RubyWinter2014.iml deleted file mode 100644 index f925dd8..0000000 --- a/.idea/RubyWinter2014.iml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ea782b3..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 241ede5..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index c80f219..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 7143d06..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,685 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1389931367465 - 1389931367465 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/week2/exercises/book.rb - 4 - - - file://$PROJECT_DIR$/week3/homework/calculator.rb - 19 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -