SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

En vedette

银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材银行业务介绍与软件开发培训教材
银行业务介绍与软件开发培训教材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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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