SlideShare uma empresa Scribd logo
1 de 15
Ruby
Week 5
Review

• Git
• Objects
• RSpec
• Complex Data
Git
• git init
• git add
• git commit
• git log
• .gitignore
Github / Git Remotes
• Fork
• Pull Request
• git remote
• git clone
• git branch (grb)
Objects

• new / initialize
• method signatures
• relationships
RSpec

• describe
• it
• matchers
• Relationship between our code and RSpec
IO

• Input and Output
• Reading in, Writing out
• Working with the external (real!) world
Files
•   file = File.open(“test_file”, “r+”)
•   "r" Read-only, starts at beginning of file (default)
•   "r+" Read-write, starts at beginning of file
•    "w" Write-only, truncates existing file to zero
    length or creates a new file for writing
•    "w+" Read-write, truncates existing file to zero
    length or creates a new file for reading and
    writing
Files with Blocks
• File.open(“test_file”, “r+”) do |r|
 • r << “Add some text”
• end
• f = File.open(“roster.txt”)
• f.each{ |line| puts line}
• f.map{|line| line.split(‘,’).first}
Files
• f = File.open(“roster.txt”)
• f.gets (get a line)
• f.pos (character position)
• f.rewind (pos = 0)
• f.read (file as a string)
• f.readlines (array of each line as a string)
Directories
•   Dir.pwd
•   Dir.chdir(“..”)
•   All files: Dir[“*”] All hidden files: Dir[“.*”]
•   d = Dir.new(“.”)
•   Dir.mkdir(“test”)
•   d.entries
•   d.count
•   d.each{|f| puts f}
Rakefile

• Ruby Make
• Ruby scripting
• Ordered Tasks (configuration!)
Rake tasks

• task :name => [:dependency] do
 • <ruby code>
• end
Exercise
• Create a task that reads all the lines in
  names and outputs them
• Create a task that creates a class directory
• Create a task dependent on the class
  directory task that makes a directory in the
  class directory for each name in names
Homework

• Do the midterm!
• Ask me questions!

Mais conteúdo relacionado

Mais procurados

What is the best full text search engine for Python?
What is the best full text search engine for Python?What is the best full text search engine for Python?
What is the best full text search engine for Python?Andrii Soldatenko
 
Head First Java Chapter 7
Head First Java Chapter 7Head First Java Chapter 7
Head First Java Chapter 7Tom Henricksen
 
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...Codemotion
 
PyCon Russian 2015 - Dive into full text search with python.
PyCon Russian 2015 - Dive into full text search with python.PyCon Russian 2015 - Dive into full text search with python.
PyCon Russian 2015 - Dive into full text search with python.Andrii Soldatenko
 
Building social network with Neo4j and Python
Building social network with Neo4j and PythonBuilding social network with Neo4j and Python
Building social network with Neo4j and PythonAndrii Soldatenko
 
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Ontico
 
A Year With MongoDB: The Tips
A Year With MongoDB: The TipsA Year With MongoDB: The Tips
A Year With MongoDB: The TipsRizky Abdilah
 
Introduction to Redis - LA Hacker News
Introduction to Redis - LA Hacker NewsIntroduction to Redis - LA Hacker News
Introduction to Redis - LA Hacker NewsMichael Parker
 
Redis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamRedis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamCodemotion
 
C# Development (Sam Corder)
C# Development (Sam Corder)C# Development (Sam Corder)
C# Development (Sam Corder)MongoSF
 

Mais procurados (16)

What is the best full text search engine for Python?
What is the best full text search engine for Python?What is the best full text search engine for Python?
What is the best full text search engine for Python?
 
Getting triples from records: the role of ISBD
Getting triples from records: the role of ISBDGetting triples from records: the role of ISBD
Getting triples from records: the role of ISBD
 
Head First Java Chapter 7
Head First Java Chapter 7Head First Java Chapter 7
Head First Java Chapter 7
 
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...
Developing and maintaining a Java GraphQL back-end: The less obvious - Bojan ...
 
PyCon Russian 2015 - Dive into full text search with python.
PyCon Russian 2015 - Dive into full text search with python.PyCon Russian 2015 - Dive into full text search with python.
PyCon Russian 2015 - Dive into full text search with python.
 
Building social network with Neo4j and Python
Building social network with Neo4j and PythonBuilding social network with Neo4j and Python
Building social network with Neo4j and Python
 
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
Полнотекстовый поиск в PostgreSQL за миллисекунды (Олег Бартунов, Александр К...
 
Discovering python search engines
Discovering python search enginesDiscovering python search engines
Discovering python search engines
 
Drill 1.0
Drill 1.0Drill 1.0
Drill 1.0
 
Intro
IntroIntro
Intro
 
A Year With MongoDB: The Tips
A Year With MongoDB: The TipsA Year With MongoDB: The Tips
A Year With MongoDB: The Tips
 
Introduction to Redis - LA Hacker News
Introduction to Redis - LA Hacker NewsIntroduction to Redis - LA Hacker News
Introduction to Redis - LA Hacker News
 
Redis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamRedis - for duplicate detection on real time stream
Redis - for duplicate detection on real time stream
 
C# Development (Sam Corder)
C# Development (Sam Corder)C# Development (Sam Corder)
C# Development (Sam Corder)
 
Python and MongoDB
Python and MongoDBPython and MongoDB
Python and MongoDB
 
Discovering python search engine
Discovering python search engineDiscovering python search engine
Discovering python search engine
 

Destaque

Destaque (7)

Week6
Week6Week6
Week6
 
Week10
Week10Week10
Week10
 
Nginx caching
Nginx cachingNginx caching
Nginx caching
 
Week4
Week4Week4
Week4
 
Week7
Week7Week7
Week7
 
Week3
Week3Week3
Week3
 
Week9
Week9Week9
Week9
 

Semelhante a RUBY-WEEK5-REVIEW

File and directories in python
File and directories in pythonFile and directories in python
File and directories in pythonLifna C.S
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyiststchandy
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Steven Francia
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.C. Tobin Magle
 
Fabric
FabricFabric
FabricJS Lee
 
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Ahmed El-Arabawy
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in RSamuel Bosch
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 
Advanced geoprocessing with Python
Advanced geoprocessing with PythonAdvanced geoprocessing with Python
Advanced geoprocessing with PythonChad Cooper
 

Semelhante a RUBY-WEEK5-REVIEW (20)

Python3
Python3Python3
Python3
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
Ruby1_full
Ruby1_fullRuby1_full
Ruby1_full
 
Ruby1_full
Ruby1_fullRuby1_full
Ruby1_full
 
Python - Lecture 9
Python - Lecture 9Python - Lecture 9
Python - Lecture 9
 
Python redis talk
Python redis talkPython redis talk
Python redis talk
 
Python Kick Start
Python Kick StartPython Kick Start
Python Kick Start
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.
 
Fabric
FabricFabric
Fabric
 
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in R
 
04 standard class library c#
04 standard class library c#04 standard class library c#
04 standard class library c#
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Advanced geoprocessing with Python
Advanced geoprocessing with PythonAdvanced geoprocessing with Python
Advanced geoprocessing with Python
 

Mais de reneedv

Fill Up your Bookshelves!
Fill Up your Bookshelves! Fill Up your Bookshelves!
Fill Up your Bookshelves! reneedv
 
Dealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> PeopleDealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> Peoplereneedv
 
Whose Wife Are You?
Whose Wife Are You?Whose Wife Are You?
Whose Wife Are You?reneedv
 
How I Learned to Smell Code
How I Learned to Smell CodeHow I Learned to Smell Code
How I Learned to Smell Codereneedv
 
RailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop IntroRailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop Introreneedv
 

Mais de reneedv (7)

Week2
Week2Week2
Week2
 
Week1
Week1Week1
Week1
 
Fill Up your Bookshelves!
Fill Up your Bookshelves! Fill Up your Bookshelves!
Fill Up your Bookshelves!
 
Dealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> PeopleDealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> People
 
Whose Wife Are You?
Whose Wife Are You?Whose Wife Are You?
Whose Wife Are You?
 
How I Learned to Smell Code
How I Learned to Smell CodeHow I Learned to Smell Code
How I Learned to Smell Code
 
RailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop IntroRailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop Intro
 

RUBY-WEEK5-REVIEW

  • 2. Review • Git • Objects • RSpec • Complex Data
  • 3. Git • git init • git add • git commit • git log • .gitignore
  • 4. Github / Git Remotes • Fork • Pull Request • git remote • git clone • git branch (grb)
  • 5. Objects • new / initialize • method signatures • relationships
  • 6. RSpec • describe • it • matchers • Relationship between our code and RSpec
  • 7. IO • Input and Output • Reading in, Writing out • Working with the external (real!) world
  • 8. Files • file = File.open(“test_file”, “r+”) • "r" Read-only, starts at beginning of file (default) • "r+" Read-write, starts at beginning of file • "w" Write-only, truncates existing file to zero length or creates a new file for writing • "w+" Read-write, truncates existing file to zero length or creates a new file for reading and writing
  • 9. Files with Blocks • File.open(“test_file”, “r+”) do |r| • r << “Add some text” • end • f = File.open(“roster.txt”) • f.each{ |line| puts line} • f.map{|line| line.split(‘,’).first}
  • 10. Files • f = File.open(“roster.txt”) • f.gets (get a line) • f.pos (character position) • f.rewind (pos = 0) • f.read (file as a string) • f.readlines (array of each line as a string)
  • 11. Directories • Dir.pwd • Dir.chdir(“..”) • All files: Dir[“*”] All hidden files: Dir[“.*”] • d = Dir.new(“.”) • Dir.mkdir(“test”) • d.entries • d.count • d.each{|f| puts f}
  • 12. Rakefile • Ruby Make • Ruby scripting • Ordered Tasks (configuration!)
  • 13. Rake tasks • task :name => [:dependency] do • <ruby code> • end
  • 14. Exercise • Create a task that reads all the lines in names and outputs them • Create a task that creates a class directory • Create a task dependent on the class directory task that makes a directory in the class directory for each name in names
  • 15. Homework • Do the midterm! • Ask me questions!

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n