SlideShare una empresa de Scribd logo
1 de 57
$ rake intro

                                  Presented By Dane Harrigan

                                       http://codequietly.com




Monday, August 16, 2010
Topics




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task
                    ‣ With Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task
                    ‣ With Namespaces
                    ‣ Accepting Arguments




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task
                    ‣ With Namespaces
                    ‣ Accepting Arguments
                    ‣ With Dependencies




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task
                    ‣ With Namespaces
                    ‣ Accepting Arguments
                    ‣ With Dependencies
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task
                    ‣ With Namespaces
                    ‣ Accepting Arguments
                    ‣ With Dependencies
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task    ‣ Multiple dependencies
                    ‣ With Namespaces
                    ‣ Accepting Arguments
                    ‣ With Dependencies
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task    ‣ Multiple dependencies
                    ‣ With Namespaces       ‣ Instance variables
                    ‣ Accepting Arguments
                    ‣ With Dependencies
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task    ‣ Multiple dependencies
                    ‣ With Namespaces       ‣ Instance variables
                    ‣ Accepting Arguments   ‣ That reads from
                                              STDIN
                    ‣ With Dependencies
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task    ‣ Multiple dependencies
                    ‣ With Namespaces       ‣ Instance variables
                    ‣ Accepting Arguments   ‣ That reads from
                                              STDIN
                    ‣ With Dependencies
                                            ‣ Interact with Rails
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Topics

                    ‣ Making a Rake Task    ‣ Multiple dependencies
                    ‣ With Namespaces       ‣ Instance variables


                                THOR
                    ‣ Accepting Arguments
                    ‣ With Dependencies
                                            ‣ That reads from
                                              STDIN
                                            ‣ Interact with Rails
                    ‣ Dependencies from
                      other Namespaces




Monday, August 16, 2010
Getting Started

                           ‣ Making a Rake Task
                           ‣ Accepting Arguments
                           ‣ With Dependencies




Monday, August 16, 2010
task :greeting do
           puts 'Hello Ruby Community!'
         end




                                            intro-to-rake/01/Rakefile

         $ rake -T
         (in /Users/Dane/Projects/intro-to-rake/01)

         $ rake greeting
         (in /Users/Dane/Projects/intro-to-rake/01)
         Hello Ruby Community!



                                          intro-to-rake/01/command.sh


Monday, August 16, 2010                                     Sub-Title
desc 'Greets the Ruby Community' # <-- key point
               task :greeting do
                 puts 'Hello Ruby Community!'
               end




                                                       intro-to-rake/02/Rakefile

         $ rake -T
         (in /Users/Dane/Projects/intro-to-rake/02)
         rake greeting # Greets the Ruby Community




                                                     intro-to-rake/02/command.sh


Monday, August 16, 2010                                                Sub-Title
desc 'Greets the Ruby Community'
         task :greeting, :name do |command, args| # <-- key point
           puts "command: #{command}"             # <-- key point
           puts "Hello #{args[:name]}!"           # <-- key point
         end




                                                   intro-to-rake/03/Rakefile

         $ rake -T
         (in /Users/Dane/Projects/intro-to-rake/03)
         rake greeting[name] # Greets the Ruby Community

         $ rake greeting[‘Ruby Community’]
         (in /Users/Dane/Projects/intro-to-rake/03)
         command: greeting
         Hello Ruby Community!
                                                  intro-to-rake/03/command.sh


Monday, August 16, 2010                                             Sub-Title
desc 'Greets the Ruby Community'
               task :greeting, :first, :second do |command, args|# <- key
               point
                 puts "command: #{command}"
                 puts "Hello #{args[:first]} #{args[:second]}!"
               end




                                                     intro-to-rake/04/command.sh

         $ rake greeting[Ruby,Community]
         (in /Users/Dane/Projects/intro-to-rake/04)
         command: greeting
         Hello Ruby Community!




                                                     intro-to-rake/04/command.sh


Monday, August 16, 2010                                                Sub-Title
desc 'Greets the Ruby Community'
               task :greeting, :name do |command, args|
                 puts "Hello #{args[:name]}!"
               end

         desc 'Ask how you are doing'
         task :question => :greeting do # <-- key point
           puts 'How are you?'
         end


                                                          intro-to-rake/05/Rakefile

         $ rake question
         (in /Users/Dane/Projects/intro-to-rake/05)
         Hello !
         How are you?




                                                     intro-to-rake/05/command.sh


Monday, August 16, 2010                                                   Sub-Title
desc 'Greets the Ruby Community'
               task :greeting, :name do |command, args|
                 puts "Hello #{args[:name]}!"
               end

               desc 'Ask how you are doing'
               task :question do
                 Rake::Task[:greeting].invoke('Ruby Community') # <-- key
               point
                 puts 'How are you?'

                                                          intro-to-rake/06/Rakefile

         $ rake question
         (in /Users/Dane/Projects/intro-to-rake/06)
         Hello Ruby Community!
         How are you?




                                                     intro-to-rake/06/command.sh


Monday, August 16, 2010                                                   Sub-Title
desc 'Greets the Ruby Community'
         task :greeting, :name do |command, args|
           puts "Hello #{args[:name]}!"
           Rake::Task[:greeting].reenable # <-- key point
         end

         desc 'Ask how you are doing'
         task :question do
           Rake::Task[:greeting].invoke('Ruby Community')
           Rake::Task[:greeting].invoke('Ruby Community')
           puts 'How are you?'
         end




                                                   intro-to-rake/07/Rakefile

Monday, August 16, 2010
$ rake question
         (in /Users/Dane/Projects/intro-to-rake/07)
         Hello Ruby Community!
         Hello Ruby Community!
         How are you?

         $ rake greeting[‘Ruby Community’]
         (in /Users/Dane/Projects/intro-to-rake/07)
         Hello Ruby Community!




                                          intro-to-rake/07/command.sh

Monday, August 16, 2010
desc 'Greets the Ruby Community'
               task :greeting do |command, args|
                 puts "Hello #{args[:name]}!"
               end

         desc 'Ask how you are doing'
         task :question do
           Rake::Task[:greeting].execute(:name => 'Ruby Community') # <--
           puts 'How are you?'
         end

                                                    intro-to-rake/08/Rakefile

         $ rake question
         (in /Users/Dane/Projects/intro-to-rake/07)
         Hello Ruby Community!
         How are you?

         $ rake greeting['Ruby Community']
         (in /Users/Dane/Projects/intro-to-rake/07)
         Hello !
                                                   intro-to-rake/08/command.sh


Monday, August 16, 2010                                              Sub-Title
invoke and execute


                          ?
         do the same thing?


Monday, August 16, 2010
Monday, August 16, 2010
                          !
                          No.
desc 'Will display "first"'
         task :first do
           puts '** First **'
         end

         desc 'Will display "second"'
         task :second => :first do    # <-- key point
           puts '** Second **'
         end

         desc 'Will display "third"'
         task :third do
           Rake::Task[:second].invoke # <-- key point
           puts '** Third **'
         end




                                                   intro-to-rake/09/Rakefile

Monday, August 16, 2010
$ rake first
         (in /Users/Dane/Projects/intro-to-rake/08)
         ** First **

         $ rake second
         (in /Users/Dane/Projects/intro-to-rake/08)
         ** First **
         ** Second **

         $ rake third
         (in /Users/Dane/Projects/intro-to-rake/08)
         ** First **
         ** Second **
         ** Third **




                                          intro-to-rake/09/command.sh

Monday, August 16, 2010
desc 'Will display "first"'
               task :first do
                 puts '** First **'
               end

               desc 'Will display "second"'
               task :second => :first do      # <-- key point
                 puts '** Second **'
               end

               desc 'Will display "third"'
               task :third do
                 Rake::Task[:second].execute # <-- key point
                 puts '** Third **'
               end




                                                        intro-to-rake/10/Rakefile

Monday, August 16, 2010
$ rake first
         (in /Users/Dane/Projects/intro-to-rake/09)
         ** First **

         $ rake second
         (in /Users/Dane/Projects/intro-to-rake/09)
         ** First **
         ** Second **

         $ rake third
         (in /Users/Dane/Projects/intro-to-rake/09)
         ** Second **
         ** Third **




                                          intro-to-rake/10/command.sh

Monday, August 16, 2010
Getting Fancy

                          ‣ With Namespaces
                          ‣ Dependencies from
                            other Namespaces




Monday, August 16, 2010
namespace :numbers do         # <-- key point
                 desc 'Will display "first"'
                 task :first do
                   puts '** First **'
                 end

                 desc 'Will display "second"'
                 task :second => :first do   # <-- key point
                   puts '** Second **'
                 end
               end




                                                       intro-to-rake/11/Rakefile

Monday, August 16, 2010
$ rake -T
         (in /Users/Dane/Projects/intro-to-rake/10)
         rake numbers:first   # Will display "first"
         rake numbers:second # Will display "second"

         $ rake numbers:first
         (in /Users/Dane/Projects/intro-to-rake/10)
         ** First **

         $ rake numbers:second
         (in /Users/Dane/Projects/intro-to-rake/10)
         ** First **
         ** Second **




                                          intro-to-rake/11/command.sh

Monday, August 16, 2010
namespace :numbers do
                 desc 'Will display "first"'
                 task :first do
                   puts '** First **'
                 end

                 desc 'Will display "second"'
                 task :second do
                   Rake::Task['numbers:first'].invoke # <-- key point
                   puts '** Second **'
                 end
               end




                                                       intro-to-rake/12/Rakefile

Monday, August 16, 2010
$ rake numbers:first
         (in /Users/Dane/Projects/intro-to-rake/11)
         ** First **

         $ rake numbers:second
         (in /Users/Dane/Projects/intro-to-rake/11)
         ** First **
         ** Second **




                                          intro-to-rake/12/command.sh

Monday, August 16, 2010
namespace :group do            # <-- key point
                 namespace :numbers do
                   desc 'Will display "first"'
                   task :first do
                     puts '** First **'
                   end

                   desc 'Will display "second"'
                   task :second => :first do # <-- key point
                     puts '** Second **'
                   end
                 end
               end




                                                       intro-to-rake/13/Rakefile

Monday, August 16, 2010
$ rake -T
         (in /Users/Dane/Projects/intro-to-rake/12)
         rake group:numbers:first   # Will display "first"
         rake group:numbers:second # Will display "second"

         $ rake group:numbers:first
         (in /Users/Dane/Projects/intro-to-rake/12)
         ** First **

         $ rake group:numbers:second
         (in /Users/Dane/Projects/intro-to-rake/12)
         ** First **
         ** Second **




                                          intro-to-rake/13/command.sh

Monday, August 16, 2010
namespace :group do
                 namespace :numbers do
                   desc 'Will display "first"'
                   task :first do
                     puts '** First **'
                   end
                 end
               end

               desc 'Will display "second"'
               task :second => 'group:numbers:first' do # <-- key point
                 puts '** Second **'
               end




                                                       intro-to-rake/14/Rakefile

Monday, August 16, 2010
$ rake group:numbers:first
         (in /Users/Dane/Projects/intro-to-rake/13)
         ** First **

         $ rake second
         (in /Users/Dane/Projects/intro-to-rake/13)
         ** First **
         ** Second **




                                          intro-to-rake/14/command.sh

Monday, August 16, 2010
namespace :group do
                 desc 'This will displays numbers'
                 task :numbers do      # <-- key point
                   puts "*** "+(1..10).to_a.join(' ')+" ***"
                 end

                 namespace :numbers do # <-- key point
                   desc 'Will display "first"'
                   task :first do
                     puts '** First **'
                   end
                 end
               end




                                                         intro-to-rake/15/Rakefile

Monday, August 16, 2010
$ rake group:numbers
         (in /Users/Dane/Projects/intro-to-rake/15)
         *** 1 2 3 4 5 6 7 8 9 10 ***

         $ rake group:numbers:first
         (in /Users/Dane/Projects/intro-to-rake/15)
         ** First **




                                          intro-to-rake/15/command.sh

Monday, August 16, 2010
Monday, August 16, 2010
                            !
                          Time check.
Now We’re Fancy

                            ‣ Instance variables
                            ‣ Multiple dependencies




Monday, August 16, 2010
task :first do
                 @name = 'Ruby Community' # <-- key point
               end

               task :second => :first do
                 puts "*** #{@name} ***" # <-- key point
               end



                                                       intro-to-rake/16/Rakefile

         $ rake second
         (in /Users/Dane/Projects/intro-to-rake/16)
         *** Ruby Community ***




                                                     intro-to-rake/16/command.sh


Monday, August 16, 2010                                                Sub-Title
task :first do
                 @name = 'Ruby Community'          # <-- key point
               end

               task :second do
                 @name = 'Nooby Community'         # <-- key point
               end

               task :third => [:first, :second] do # <-- key point
                 puts "*** #{@name} ***"           # <-- key point
               end




                                                       intro-to-rake/17/Rakefile

Monday, August 16, 2010
$ rake third
         (in /Users/Dane/Projects/intro-to-rake/17)
         *** Nooby Community ***




                                          intro-to-rake/17/command.sh

Monday, August 16, 2010
Get Crazy

                          ‣ Interact with Rails




Monday, August 16, 2010
:environment


Monday, August 16, 2010
Get Calm

                          ‣ Reading from STDIN




Monday, August 16, 2010
require 'rubygems'
               require 'highline/import'

               task :bootstrap do
                 user = ask('What is your username? ')
                 pass = ask('What is your password? ') { |q| q.echo =
               false }

                 puts "Username: #{user}"
                 puts "Password: #{pass}"
               end




                                                       intro-to-rake/18/Rakefile

Monday, August 16, 2010
$ rake bootstrap
         (in /Users/Dane/Projects/intro-to-rake/18)
         What is your username? dharrigan
         What is your password?
         Username: dharrigan
         Password: password




                                          intro-to-rake/18/command.sh

Monday, August 16, 2010
Monday, August 16, 2010
                          !
                          THOR
class MyApp < Thor
                 desc :first, 'This is my first task'
                 def first
                   say 'First!'
                 end

                    desc :second, 'This is my second task'
                    def second
                      invoke :first
                      say 'second!'
                    end
         end




                                                             intro-to-rake/19/Thorfile

Monday, August 16, 2010
$ thor list
         my_app
         ------
         <path>/thor my_app:first    # This is my first task
         <path>/thor my_app:second   # This is my second task

         $ thor my_app:second
         First!
         second!




                                           intro-to-rake/19/command.sh

Monday, August 16, 2010
class MyApp < Thor
                 desc :first, 'This is my first task'
                 def first(name)
                   say name
                   say 'First!'
                 end

                 desc :second, 'This is my second task'
                 def second
                   invoke :first, ['Ruby Community'] # <-- key point
                   say 'second!'
                 end
               end




                                                        intro-to-rake/20/Thorfile

Monday, August 16, 2010
$ thor my_app:first 'Ruby Community'
         Ruby Community
         First!

         $ thor my_app:second
         Ruby Community
         First!
         second!




                                          intro-to-rake/20/command.sh

Monday, August 16, 2010
class MyApp < Thor
           desc :first, 'This is my first task'
           method_options :name => :string # <-- key point
           def first
             say options[:name]            # <-- key point
             say 'First!'
           end
         end


                                                   intro-to-rake/21/Thorfile

         $ thor my_app:first --name 'Ruby Community'
         Ruby Community
         First!




                                                  intro-to-rake/21/command.sh


Monday, August 16, 2010                                             Sub-Title
$ rake about

         Dane Harrigan

         dane.harrigan@gmail.com
         Twitter: @daneharrigan
         Github: http://github.com/daneharrigan
         Website: http://codequietly.com

         ---

         Code examples are available at Github:

         http://github.com/daneharrigan/presentations/




                                            intro-to-rake/command.sh

Monday, August 16, 2010

Más contenido relacionado

Destacado

银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材liang47
 
ค่ายพี่น้อง ครั้งที่ 4
ค่ายพี่น้อง ครั้งที่ 4ค่ายพี่น้อง ครั้งที่ 4
ค่ายพี่น้อง ครั้งที่ 4freeclub
 
百度互联网创业俱乐部搜索引擎优化指南
百度互联网创业俱乐部搜索引擎优化指南百度互联网创业俱乐部搜索引擎优化指南
百度互联网创业俱乐部搜索引擎优化指南liang47
 
Social networking in library services
Social networking in library servicesSocial networking in library services
Social networking in library servicesfreeclub
 
สภาเศรษฐกิจ กีฬาแห่งชาติ
สภาเศรษฐกิจ กีฬาแห่งชาติสภาเศรษฐกิจ กีฬาแห่งชาติ
สภาเศรษฐกิจ กีฬาแห่งชาติGoldberryBeauty
 
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคม
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคมแนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคม
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคมfreeclub
 
แนวข้อสอบWb
แนวข้อสอบWbแนวข้อสอบWb
แนวข้อสอบWbfreeclub
 
Dulitha Dharmaratne - Portfolio
Dulitha Dharmaratne - PortfolioDulitha Dharmaratne - Portfolio
Dulitha Dharmaratne - Portfolioronrulz99
 

Destacado (9)

银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材
 
ค่ายพี่น้อง ครั้งที่ 4
ค่ายพี่น้อง ครั้งที่ 4ค่ายพี่น้อง ครั้งที่ 4
ค่ายพี่น้อง ครั้งที่ 4
 
百度互联网创业俱乐部搜索引擎优化指南
百度互联网创业俱乐部搜索引擎优化指南百度互联网创业俱乐部搜索引擎优化指南
百度互联网创业俱乐部搜索引擎优化指南
 
Social networking in library services
Social networking in library servicesSocial networking in library services
Social networking in library services
 
สภาเศรษฐกิจ กีฬาแห่งชาติ
สภาเศรษฐกิจ กีฬาแห่งชาติสภาเศรษฐกิจ กีฬาแห่งชาติ
สภาเศรษฐกิจ กีฬาแห่งชาติ
 
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคม
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคมแนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคม
แนวโน้มในการให้บริการสารสนเทศบนเครือข่ายสังคม
 
แนวข้อสอบWb
แนวข้อสอบWbแนวข้อสอบWb
แนวข้อสอบWb
 
Dulitha Dharmaratne - Portfolio
Dulitha Dharmaratne - PortfolioDulitha Dharmaratne - Portfolio
Dulitha Dharmaratne - Portfolio
 
2012 part1
2012 part12012 part1
2012 part1
 

Similar a Intro to Rake

Mirah & Dubious Talk Ruby|Web 2010
Mirah & Dubious Talk Ruby|Web 2010Mirah & Dubious Talk Ruby|Web 2010
Mirah & Dubious Talk Ruby|Web 2010baroquebobcat
 
Enterprise rails hosting 3 ways to scale - 2011-10
Enterprise rails hosting   3 ways to scale - 2011-10 Enterprise rails hosting   3 ways to scale - 2011-10
Enterprise rails hosting 3 ways to scale - 2011-10 Avarteq
 
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Mike Desjardins
 
Web Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexWeb Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexBrian Hogan
 
Introducing JSONpedia
Introducing JSONpediaIntroducing JSONpedia
Introducing JSONpediaSpazioDati
 
Caelum dicas web 2010
Caelum dicas web 2010Caelum dicas web 2010
Caelum dicas web 2010Fabio Akita
 
Ruby semweb 2011-12-06
Ruby semweb 2011-12-06Ruby semweb 2011-12-06
Ruby semweb 2011-12-06Gregg Kellogg
 

Similar a Intro to Rake (10)

Ruby off Rails
Ruby off RailsRuby off Rails
Ruby off Rails
 
Mirah & Dubious Talk Ruby|Web 2010
Mirah & Dubious Talk Ruby|Web 2010Mirah & Dubious Talk Ruby|Web 2010
Mirah & Dubious Talk Ruby|Web 2010
 
Enterprise rails hosting 3 ways to scale - 2011-10
Enterprise rails hosting   3 ways to scale - 2011-10 Enterprise rails hosting   3 ways to scale - 2011-10
Enterprise rails hosting 3 ways to scale - 2011-10
 
Ruby off Rails
Ruby off RailsRuby off Rails
Ruby off Rails
 
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
 
Web Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexWeb Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To Complex
 
Introducing JSONpedia
Introducing JSONpediaIntroducing JSONpedia
Introducing JSONpedia
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Caelum dicas web 2010
Caelum dicas web 2010Caelum dicas web 2010
Caelum dicas web 2010
 
Ruby semweb 2011-12-06
Ruby semweb 2011-12-06Ruby semweb 2011-12-06
Ruby semweb 2011-12-06
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Intro to Rake

  • 1. $ rake intro Presented By Dane Harrigan http://codequietly.com Monday, August 16, 2010
  • 3. Topics ‣ Making a Rake Task Monday, August 16, 2010
  • 4. Topics ‣ Making a Rake Task ‣ With Namespaces Monday, August 16, 2010
  • 5. Topics ‣ Making a Rake Task ‣ With Namespaces ‣ Accepting Arguments Monday, August 16, 2010
  • 6. Topics ‣ Making a Rake Task ‣ With Namespaces ‣ Accepting Arguments ‣ With Dependencies Monday, August 16, 2010
  • 7. Topics ‣ Making a Rake Task ‣ With Namespaces ‣ Accepting Arguments ‣ With Dependencies ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 8. Topics ‣ Making a Rake Task ‣ With Namespaces ‣ Accepting Arguments ‣ With Dependencies ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 9. Topics ‣ Making a Rake Task ‣ Multiple dependencies ‣ With Namespaces ‣ Accepting Arguments ‣ With Dependencies ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 10. Topics ‣ Making a Rake Task ‣ Multiple dependencies ‣ With Namespaces ‣ Instance variables ‣ Accepting Arguments ‣ With Dependencies ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 11. Topics ‣ Making a Rake Task ‣ Multiple dependencies ‣ With Namespaces ‣ Instance variables ‣ Accepting Arguments ‣ That reads from STDIN ‣ With Dependencies ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 12. Topics ‣ Making a Rake Task ‣ Multiple dependencies ‣ With Namespaces ‣ Instance variables ‣ Accepting Arguments ‣ That reads from STDIN ‣ With Dependencies ‣ Interact with Rails ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 13. Topics ‣ Making a Rake Task ‣ Multiple dependencies ‣ With Namespaces ‣ Instance variables THOR ‣ Accepting Arguments ‣ With Dependencies ‣ That reads from STDIN ‣ Interact with Rails ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 14. Getting Started ‣ Making a Rake Task ‣ Accepting Arguments ‣ With Dependencies Monday, August 16, 2010
  • 15. task :greeting do puts 'Hello Ruby Community!' end intro-to-rake/01/Rakefile $ rake -T (in /Users/Dane/Projects/intro-to-rake/01) $ rake greeting (in /Users/Dane/Projects/intro-to-rake/01) Hello Ruby Community! intro-to-rake/01/command.sh Monday, August 16, 2010 Sub-Title
  • 16. desc 'Greets the Ruby Community' # <-- key point task :greeting do puts 'Hello Ruby Community!' end intro-to-rake/02/Rakefile $ rake -T (in /Users/Dane/Projects/intro-to-rake/02) rake greeting # Greets the Ruby Community intro-to-rake/02/command.sh Monday, August 16, 2010 Sub-Title
  • 17. desc 'Greets the Ruby Community' task :greeting, :name do |command, args| # <-- key point puts "command: #{command}" # <-- key point puts "Hello #{args[:name]}!" # <-- key point end intro-to-rake/03/Rakefile $ rake -T (in /Users/Dane/Projects/intro-to-rake/03) rake greeting[name] # Greets the Ruby Community $ rake greeting[‘Ruby Community’] (in /Users/Dane/Projects/intro-to-rake/03) command: greeting Hello Ruby Community! intro-to-rake/03/command.sh Monday, August 16, 2010 Sub-Title
  • 18. desc 'Greets the Ruby Community' task :greeting, :first, :second do |command, args|# <- key point puts "command: #{command}" puts "Hello #{args[:first]} #{args[:second]}!" end intro-to-rake/04/command.sh $ rake greeting[Ruby,Community] (in /Users/Dane/Projects/intro-to-rake/04) command: greeting Hello Ruby Community! intro-to-rake/04/command.sh Monday, August 16, 2010 Sub-Title
  • 19. desc 'Greets the Ruby Community' task :greeting, :name do |command, args| puts "Hello #{args[:name]}!" end desc 'Ask how you are doing' task :question => :greeting do # <-- key point puts 'How are you?' end intro-to-rake/05/Rakefile $ rake question (in /Users/Dane/Projects/intro-to-rake/05) Hello ! How are you? intro-to-rake/05/command.sh Monday, August 16, 2010 Sub-Title
  • 20. desc 'Greets the Ruby Community' task :greeting, :name do |command, args| puts "Hello #{args[:name]}!" end desc 'Ask how you are doing' task :question do Rake::Task[:greeting].invoke('Ruby Community') # <-- key point puts 'How are you?' intro-to-rake/06/Rakefile $ rake question (in /Users/Dane/Projects/intro-to-rake/06) Hello Ruby Community! How are you? intro-to-rake/06/command.sh Monday, August 16, 2010 Sub-Title
  • 21. desc 'Greets the Ruby Community' task :greeting, :name do |command, args| puts "Hello #{args[:name]}!" Rake::Task[:greeting].reenable # <-- key point end desc 'Ask how you are doing' task :question do Rake::Task[:greeting].invoke('Ruby Community') Rake::Task[:greeting].invoke('Ruby Community') puts 'How are you?' end intro-to-rake/07/Rakefile Monday, August 16, 2010
  • 22. $ rake question (in /Users/Dane/Projects/intro-to-rake/07) Hello Ruby Community! Hello Ruby Community! How are you? $ rake greeting[‘Ruby Community’] (in /Users/Dane/Projects/intro-to-rake/07) Hello Ruby Community! intro-to-rake/07/command.sh Monday, August 16, 2010
  • 23. desc 'Greets the Ruby Community' task :greeting do |command, args| puts "Hello #{args[:name]}!" end desc 'Ask how you are doing' task :question do Rake::Task[:greeting].execute(:name => 'Ruby Community') # <-- puts 'How are you?' end intro-to-rake/08/Rakefile $ rake question (in /Users/Dane/Projects/intro-to-rake/07) Hello Ruby Community! How are you? $ rake greeting['Ruby Community'] (in /Users/Dane/Projects/intro-to-rake/07) Hello ! intro-to-rake/08/command.sh Monday, August 16, 2010 Sub-Title
  • 24. invoke and execute ? do the same thing? Monday, August 16, 2010
  • 25. Monday, August 16, 2010 ! No.
  • 26. desc 'Will display "first"' task :first do puts '** First **' end desc 'Will display "second"' task :second => :first do # <-- key point puts '** Second **' end desc 'Will display "third"' task :third do Rake::Task[:second].invoke # <-- key point puts '** Third **' end intro-to-rake/09/Rakefile Monday, August 16, 2010
  • 27. $ rake first (in /Users/Dane/Projects/intro-to-rake/08) ** First ** $ rake second (in /Users/Dane/Projects/intro-to-rake/08) ** First ** ** Second ** $ rake third (in /Users/Dane/Projects/intro-to-rake/08) ** First ** ** Second ** ** Third ** intro-to-rake/09/command.sh Monday, August 16, 2010
  • 28. desc 'Will display "first"' task :first do puts '** First **' end desc 'Will display "second"' task :second => :first do # <-- key point puts '** Second **' end desc 'Will display "third"' task :third do Rake::Task[:second].execute # <-- key point puts '** Third **' end intro-to-rake/10/Rakefile Monday, August 16, 2010
  • 29. $ rake first (in /Users/Dane/Projects/intro-to-rake/09) ** First ** $ rake second (in /Users/Dane/Projects/intro-to-rake/09) ** First ** ** Second ** $ rake third (in /Users/Dane/Projects/intro-to-rake/09) ** Second ** ** Third ** intro-to-rake/10/command.sh Monday, August 16, 2010
  • 30. Getting Fancy ‣ With Namespaces ‣ Dependencies from other Namespaces Monday, August 16, 2010
  • 31. namespace :numbers do # <-- key point desc 'Will display "first"' task :first do puts '** First **' end desc 'Will display "second"' task :second => :first do # <-- key point puts '** Second **' end end intro-to-rake/11/Rakefile Monday, August 16, 2010
  • 32. $ rake -T (in /Users/Dane/Projects/intro-to-rake/10) rake numbers:first # Will display "first" rake numbers:second # Will display "second" $ rake numbers:first (in /Users/Dane/Projects/intro-to-rake/10) ** First ** $ rake numbers:second (in /Users/Dane/Projects/intro-to-rake/10) ** First ** ** Second ** intro-to-rake/11/command.sh Monday, August 16, 2010
  • 33. namespace :numbers do desc 'Will display "first"' task :first do puts '** First **' end desc 'Will display "second"' task :second do Rake::Task['numbers:first'].invoke # <-- key point puts '** Second **' end end intro-to-rake/12/Rakefile Monday, August 16, 2010
  • 34. $ rake numbers:first (in /Users/Dane/Projects/intro-to-rake/11) ** First ** $ rake numbers:second (in /Users/Dane/Projects/intro-to-rake/11) ** First ** ** Second ** intro-to-rake/12/command.sh Monday, August 16, 2010
  • 35. namespace :group do # <-- key point namespace :numbers do desc 'Will display "first"' task :first do puts '** First **' end desc 'Will display "second"' task :second => :first do # <-- key point puts '** Second **' end end end intro-to-rake/13/Rakefile Monday, August 16, 2010
  • 36. $ rake -T (in /Users/Dane/Projects/intro-to-rake/12) rake group:numbers:first # Will display "first" rake group:numbers:second # Will display "second" $ rake group:numbers:first (in /Users/Dane/Projects/intro-to-rake/12) ** First ** $ rake group:numbers:second (in /Users/Dane/Projects/intro-to-rake/12) ** First ** ** Second ** intro-to-rake/13/command.sh Monday, August 16, 2010
  • 37. namespace :group do namespace :numbers do desc 'Will display "first"' task :first do puts '** First **' end end end desc 'Will display "second"' task :second => 'group:numbers:first' do # <-- key point puts '** Second **' end intro-to-rake/14/Rakefile Monday, August 16, 2010
  • 38. $ rake group:numbers:first (in /Users/Dane/Projects/intro-to-rake/13) ** First ** $ rake second (in /Users/Dane/Projects/intro-to-rake/13) ** First ** ** Second ** intro-to-rake/14/command.sh Monday, August 16, 2010
  • 39. namespace :group do desc 'This will displays numbers' task :numbers do # <-- key point puts "*** "+(1..10).to_a.join(' ')+" ***" end namespace :numbers do # <-- key point desc 'Will display "first"' task :first do puts '** First **' end end end intro-to-rake/15/Rakefile Monday, August 16, 2010
  • 40. $ rake group:numbers (in /Users/Dane/Projects/intro-to-rake/15) *** 1 2 3 4 5 6 7 8 9 10 *** $ rake group:numbers:first (in /Users/Dane/Projects/intro-to-rake/15) ** First ** intro-to-rake/15/command.sh Monday, August 16, 2010
  • 41. Monday, August 16, 2010 ! Time check.
  • 42. Now We’re Fancy ‣ Instance variables ‣ Multiple dependencies Monday, August 16, 2010
  • 43. task :first do @name = 'Ruby Community' # <-- key point end task :second => :first do puts "*** #{@name} ***" # <-- key point end intro-to-rake/16/Rakefile $ rake second (in /Users/Dane/Projects/intro-to-rake/16) *** Ruby Community *** intro-to-rake/16/command.sh Monday, August 16, 2010 Sub-Title
  • 44. task :first do @name = 'Ruby Community' # <-- key point end task :second do @name = 'Nooby Community' # <-- key point end task :third => [:first, :second] do # <-- key point puts "*** #{@name} ***" # <-- key point end intro-to-rake/17/Rakefile Monday, August 16, 2010
  • 45. $ rake third (in /Users/Dane/Projects/intro-to-rake/17) *** Nooby Community *** intro-to-rake/17/command.sh Monday, August 16, 2010
  • 46. Get Crazy ‣ Interact with Rails Monday, August 16, 2010
  • 48. Get Calm ‣ Reading from STDIN Monday, August 16, 2010
  • 49. require 'rubygems' require 'highline/import' task :bootstrap do user = ask('What is your username? ') pass = ask('What is your password? ') { |q| q.echo = false } puts "Username: #{user}" puts "Password: #{pass}" end intro-to-rake/18/Rakefile Monday, August 16, 2010
  • 50. $ rake bootstrap (in /Users/Dane/Projects/intro-to-rake/18) What is your username? dharrigan What is your password? Username: dharrigan Password: password intro-to-rake/18/command.sh Monday, August 16, 2010
  • 51. Monday, August 16, 2010 ! THOR
  • 52. class MyApp < Thor desc :first, 'This is my first task' def first say 'First!' end desc :second, 'This is my second task' def second invoke :first say 'second!' end end intro-to-rake/19/Thorfile Monday, August 16, 2010
  • 53. $ thor list my_app ------ <path>/thor my_app:first # This is my first task <path>/thor my_app:second # This is my second task $ thor my_app:second First! second! intro-to-rake/19/command.sh Monday, August 16, 2010
  • 54. class MyApp < Thor desc :first, 'This is my first task' def first(name) say name say 'First!' end desc :second, 'This is my second task' def second invoke :first, ['Ruby Community'] # <-- key point say 'second!' end end intro-to-rake/20/Thorfile Monday, August 16, 2010
  • 55. $ thor my_app:first 'Ruby Community' Ruby Community First! $ thor my_app:second Ruby Community First! second! intro-to-rake/20/command.sh Monday, August 16, 2010
  • 56. class MyApp < Thor desc :first, 'This is my first task' method_options :name => :string # <-- key point def first say options[:name] # <-- key point say 'First!' end end intro-to-rake/21/Thorfile $ thor my_app:first --name 'Ruby Community' Ruby Community First! intro-to-rake/21/command.sh Monday, August 16, 2010 Sub-Title
  • 57. $ rake about Dane Harrigan dane.harrigan@gmail.com Twitter: @daneharrigan Github: http://github.com/daneharrigan Website: http://codequietly.com --- Code examples are available at Github: http://github.com/daneharrigan/presentations/ intro-to-rake/command.sh Monday, August 16, 2010