Merken

Crushing It With Rake Tasks

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
and then it behind the and within a day at thank you all for coming after lunch and no there's lots of good choices as hard to so many tracks and workshops going at the same time and so I appreciate your being here could the system receipts taken I'm very clock and then Ruby for about a decade I like to
run i currently work it's Tablelands Reggie research and build prototypes I really to try to make travel surplus there is a travel company I like to be outside the worst possible
but were not entirely but today we're here to talk about rate selective is a Ruby scripting utility are really used to streamline tasks repetitive tedious task it can be considered a Ruby version of make the Unix a build automation tool and similar to make we have a rate file like the makefile up but the rate file is written in Ruby so you can do all these things in was created by John
wiring who unfortunately passed away god February 2014 and I still miss Mrs. spirit and misses implants is energy this was 1 of his last
week's others a new TV show called rake but it's confusing because it wasn't about Ruby or build on a mission which is unfortunate because it may be it could have been a good ship the a rate can
help us manage our databases
if you don't hear else then probably used Davis migrations interviews rate and I would say really this is probably the the biggest killer feature in rails database migrations so here we have a
migration from the rails 5 beta 0 this was C 3 um so of course remake a blog oops it works I we got timestamps period I will have to fields a title in the body it would be great if all blogs short these are just strings so the bar 255 but so we want create a stable to do that will use bundle exec rate Phoebe migrate you'll know the inclusion there bundle exact ranking is a Ruby scripting utility so you could just run rate but really rails that we want this to work in the context of our Rails apps Jim filed the Bundler can help us with that is so bundle exec break the library so we're at NEC em around the create post migration and it's going to create table 1st the regret 0 right remind maybe a indecisive like me you change fields Chinese names add fields you really know where this this is going quite so I want and a permalink to my it because we want tweet about all the 50 things we have said will people that come from a blog so it's incredibly migration which is reasonable but we can also edit our existing migration not talk to me about why and when we make those choices much to say solid Karen adjust but this new field and there so the couple ways that we can revert this thing rewrite it the 1st we issues DB roll back finally was a great db role that so that can reverse the migration so Active record understands how to do lots of things you can do create was 1 of the things that knows how to do but if it's not something that is a reversal migration you have to seperate up and down separately so that would run the down so we do that 1 was a great deal your back we say OK we've got discrete post migration going to revert surrender dropped the 2 the and dropping a table we you delete a table we do it's able to do it on state also but as a cases development right that you would do this and production the other day we can do this by analyzing great DB migrate reduce this is great you know roll back and roll forward again so it is retain that create pre-post migration it will just table and will create stable surrender later date Redleaf they wanted Leon data this can recreate table so what does it you have a fresh sailor has also phonetic except for the this is superheavy I use this a lot who we got this blog blogpost that commonly and it's going to go viral because and we have robust at Ceret Serena an index to the posts stable on the permalinks and we don't table stand every time we look at that field still stays bad right boy introduce a new database object and so when we will which a rollback Active Record is gonna say a few hundred and do all the things that they did sort of drop the index and I'm gonna drop table of course if you drop the table it would drop all that's objects you just in the database but at record is going to be thorough and so it's an explicitly drop everything that is created they're
going to have a bad time story the guy survives he's so a different strategy for
him to drop the database that we created the re right finally seperate DB drop the B 3 dB migrate you can see we can run multiple tasks serially 1 after another I'm and yes this is heavy-handed this is totally scorched earth here but again were in development for doing a early development we just created this table we don't really know where we're going yet and so it's OK so you're asking their what when can change it can change migration right and of course the answer in computer science is always a defense so limitations new fields are totally fine you have a new database objects and so you can rerun that new objects so a new index of foreign key you're for whatever reason you express 2nd table and that migration that's we had to drop the databases and if you've already committed and pushed don't change that's a bad thing so I'll take a migration every when I'm mean in initial development of such and figure out what I'm doing but what subset that stake in the ground and it's fixed and were category create new migrations but create 10 migrations while trying to figure out we know when he's being state
let's keep going with break and database management they were talking about advanced
database sitting we create and you realize that
you get a cease-fire it's empty it was like this has these comments that tells you have got these tasks like 40 dBc DB server the you when you run the state you run the DBC task was gonna take whatever's in there right so that the example here it's rare create a couple of movies and record and we can and this great the problem is each time we run this it's going to rewrite everything is in there and star wars and all rings you know the trilogies but without the multiple as star wars movies in the database so active record has a vector instead we can use instead create we can use 1st or create so where we have this where conditions when that is not satisfied when they cannot find record FIL created otherwise it'll just return whatever instances or instances of finds the 1st great actually return the object window 1st 9 6 recently shipped in we finally got absurd yeah a which is data or inserts on serving as maybe is comprised of a of its inactive record to support that the 1st afraid is as really which you want your and you can safely rewrite this seen task so why not the things all the time because we can run multiple tasks serially 1 after another 1 I mentioned a race is completely yesterday every time we can safely run the DB migrate task but sometimes if it if there is nothing to be done that it is what do you think and we cannot say if run our seats task multiple times because if it does everything you needs to create it just what do you think the the we can also create a custom rate test the this was gonna take a CSV file and loaded and the sees is the file has a header row that happens to match the fields in the table which is handy I custom converter there so we feel that is blank the cockroach empty string I will be converted to and all the database and states plus there's a much that there was no 3rd piece by piece gotta attest to this in the DB seed namespace you can that's the namespaces and so that's how you get seat in the task is import airports this can load the reels environment the but real look and see if there are in the airports are already loaded varying records we're gonna assume that this task is already right we don't have to do we could do that 1st to create 11 work just fine but there are lots of reports right that we allow lookups scale-free logic to those in the industry and regenerate a lot a lot and we don't really know what that is so what is the naive and assume if there are any airports then were good CSCL other Ruby standard library but is really handy so for each given a file name will open the file and read line-by-line record-by-record but which to told us there's a header row so we'll take that back and it takes each row in basically makes the hatch so the header the field names will be the key values in the hash values will be the data from that particular record and converted to a simple just so that looks like what I'm expecting a hash key to look like a buffer for hash systems unaccustomed converter there this is also a really anything this is the opposite but so if there is data in the field if it's not in all but it is empty industry corporate then let's make it all right which is returned the field I so that way we get good null values in the database understands so the table chock-full of just empty strings but what is that so pump that hatch and therefore create because the field names are the same as the column headers you can pop a hash directly and Active Record create and it will create the records for you get together again we can then 1st to create here but I don't want you 8 thousand lookups way for that to happen record by record and generate all that long the syslog unnecessary work the so here it is again customer castle load sees the file and important if in history to today invoke very fast when was that because we want this to run with the Rails apps GEM file as context rate DB seed important airports so the DBC namespace so that becomes part of the name yeah to find a
way and maybe we did do 1st to create a larger certainly get a handle for too
much longer well very test for that in results to take a look at a large
directory and this one's actually not but you can see that test long is significantly bigger than the development log you running tests a lot maybe you got a god running it certainly say very rigid tests and so they can quickly grow so bundle is break law clear will go through interval open up and truncate each file and that what directory but what did you any output you be nice that told you what files it's clearing and how much space saved would that arouses open source so we could have gone so the Kentucky afterwards you so this recall the things because we can run multiple tasks serially why not make sure databases up-to-date analogically every time so below that grade DB migrate the you Block clear again we can safely rerun the migrant task we can safely rerun the seed task rails can also tell us we
cylinder to we sprinkle for ourselves through our
finally set rate notes that go through and look at all the to do so and fix these that's you've put in all files there's also an optimized tag and actually use that mediation so we do that in a test project here that I made it follows a great notes we see in that hosts model I've got to do as usual align number is line to them online 3 about a fixed me that just says this reasonable fix we the follow got to do for myself to create some what posts so you see the line number in the file of each of your notable notes documentation goes beyond comets Europe can tell you things about self was and know how do you have you use it the rats file In the rounds this 1 the 1st places that I work when I pick up a legacy rolls out or just arose actinide that in right or that I forgot that road so let's look at a rats while this is an old 1 from 1 from old work out you see there's got a couple get actions on a gate controller we've got a readings resource the resource is a problem API that we're exposed off another apt to talk to and other resources gives us the 7 Golden actions for free and that create new edit show update and destroy and then we also defined a route wrapped system I just goes so you look almost 3 thousand or QR my awesome app . com and the notice something so when isn't regrets we see all around and see those to get actions on the gate control we see the severed all actions for readings and we see our graph now that really is index is actually not going to return anything it's just a the 204 and empty OK there's no body but so seeing seeing a wraps the name droughts seen the URL so that you have in your app is really handy within specified in the custom names in neurons which you could do that so that in your app you would refer to these you could refer to these out these routs as gate manifest EuroLaw gate manifest the crowd I think you can do that the and so you could but that and lead to a redirect all those things as a app it's big you have more outs you might wanna filter or because this is just a year command line script and utility we can J. commits together we can hide that output into another command this so do but is a great crowds high factor graph with the keyword gates OECD wrap it has that gate keyword anywhere in the line so we have to date grants with the big rats wow this is really an the cat we can also use rake to
update our projects and this is a little bit
like sorcery finally set radio
rails up-to-date the you right that Mr. it's potentially heavy-handed again to go through this still look at all files in your app Arabia version is to take a all the new files these to create or he changes in files that you have already and so this the rails for the syntax rules 5 changes to bomb was rate after that date so run that on 1 of our apps indices figure through much files and say where you got that I was to create a new secret key couldn't care I guess it environments development and we see that the are active job queue name they wanted to be changed so the camel case for a state cases and we want to accept why have a meeting changes in this file and so it's safe to accept its infancy i say yes here are the options that you get file-by-file yes you can accept no you can choose to not accepted or you can just step on everything or you see a did so I well used it that death and if it's a father made changes in the I'll decide how I want to know how approach maybe a copy and the change or maybe other stuff on the file and look at the gate death and see what I just thought it's safe to run this and see what needs to be changed without stepping on anything but you also get a project under version control so if you do step on something you can always revert so the
rate is a Ruby scripting utility it was not just for rails reduce off the
rails all you have to do is include the region and have a rate 5 similarly we can use bundler it's a plain ordinary project so it is a very simple right
at the description of this tacit says hello the task is hello and is who puts who have so you run that low and it says hello to vary from the test when a 2nd task world have put them in a namespace now because they're similar tasks so namespaces away we can group like tasks together and it becomes part of the name like some force so great risk of low says low break rest cough world says world got 3rd task here in this would have some dependencies I it doesn't have a block it doesn't have its own body because it doesn't need to do things In addition so when you run this phrase test 1st going to go run the hello task then it's going around the world task and then it could have a body it would run whatever is in that block so we run that rate rose cough phrase it's going to run the hello task say hello going around the world taxes who puts world called so now I have a 4th forgone tricky here this task takes a parameter takes an argument now has 1 arguments remain in that block it's incoming odds hatch similar to in a controller we had the prince hash the odds hatched in the right thing and you need to call whatever you want to find the variables block but the thing is would called odds so it's a rate rose staff customer low variance and say hello bear high here's how we would write it In a Ruby script you can invoke great tasks from inside Ruby all you have to do is require a break load the rate file and then raped task the name task done invoking then if the great task has parameters than they would go in the prince's therefore invoke this also shows how to use Bundler in a plane over rescript again just prior Bundler when the that require we could have had the rate file in the germ followed the rake Jim defined in the in the gym file and then it would have been required but I wanted to charge separately so we run that Ruby script in the context of our file bundle exact Ruby cleared don't be in it says hello there because that's what all 6 and finally we had default tasks that we if you just run rate is going to complain because it says I know what to do I have a default tasks so we given a default task is on the global namespace for that rate file and so the default task is grass cough hello the so we're on rank it says hello we can ask for a file was so great about you and it'll say what those Ray Price coupled the list of the tasks in it says will use all the tasks that I have this is where the description light comes in here handy yeah any description the you any rate as that doesn't have a description of it Wallace is still there will still run controlled use it just will be listed at the break my faculty real ships with a bunch of rate tasks out there just open source right so we can work after the in real time Jim and live rails tasks and so those are all of the rate files that should throughout because open source we go play in the code so here is that long task and you can see all it does it's really simple images with a large directory it's a list of files and so this is where we would go if we wanted to do something like Prof out the name of the file as it is doing something to a fast that to see how much space we're saying this is where that would go it we could Singapore quest if we decided that that we liked it and maybe gets pulled into the next version of to rate is an automation tool we can streamline common tasks so remember we did that we we ranked all things do migrate seed lot clear well we have streamlined that we can create a clustering task that just as Forest in rats has a back there's a real generator for clustering tasks so when you run generators or we just run rails G. Rose generate it'll tell you his went ahead during the year the rails chief task and says here's how you this thing so let's generate task put in the DB namespace and color task streamline the create a file and the task of the called db . right what and when you do that you get this empty file is a lot of boilerplate take care for you you got descriptions such fill in the to do and then you get the task streamlined its going load the reels of our for you that I have to do is fill in that block war you was tested we have everything we need perfect so we filet and so the description is was gonna run on these things and then I change it to the hash mark the older hash syntactic is just like that but but if you like the syntax that's school we can still be friends it's fine but so this streamlined when I have 3 dependencies we no longer need to load the reels environment because DB right rate will do that for us so streamlined already migrate DB seed and log clear that we don't need it to do anything else and so we don't need that block will that by we can ask our rails and now would you know how do it we can filter it for rate tax that has the word DB in anywhere in the line and they can say 0 hey cool about this new task rate be streamlined it would actually be highlighted that that C C is actually there so we're going to go we can write the rate at and it works so it's going to migrated table so creates table the promisees would have reacted for that and then look at the long directory it's empty so it did all the things were going to go other streamlining tedium sorts of things uh Sienna micro-services set that 1 time and we used after could communicate between services and there's a calculated token of they had timestamp and it is so to test 1 of the child services had to have a valid token his campaign so memory task to calculate a valid after this so I could just use curl up to to test this documented before we had doctor machine but back in like Fig days but a really big break from out to help with all the container management and access to use some of those tasks to help with cleanup we saw learning file it's a database we can also load full production databases were a local development database here's a custom right test that will download production database for few and loaded into your local development database she's a series of 3 test was the thing on the other suspected that is the 1st task they got capture backups below the reels environment and that's asterisk you to capture the PG back up so percentages just go make a G . and stored somewhere we can be downloaded at this down the backup test that's going to go as the capture backup test to capture back up and then we'll use Perl to download that down to have a noun local file system and our 3rd task load industries PG load PG store to load that don't file the taking in all the variables from the rails environment and this is to temperate following a really needed in our code so will delete that file within hours right again the so customer tested doubt production down the production her a few data and the locally but status I if you have since data in a production database that maybe you don't want to walk around in your laptop it is handy there is value in being able to 1st test code against real production there and so if you profile coder fewer do some perf testing this is a really good way to do that or choose a staging environment also a good idea said we do to talk about rate for database management and maintenance we've talked about rate for project management and maintenance was talking a 1st plenary projects rate
can help us make a project projects for manageable and make a life force to that's Lake Champlain of Burlington Vermont 1 of the places if you have
questions I would love to talk you come up and talk to me afterwards of also
nearly finished writing this book data visualization a rough cut will be available online soon on safari books and so that it is for JSI thing if you want them to be thing then we can talk about that as well thank you what
question you feel that the the the the and in my ball
Weg <Topologie>
Task
Güte der Anpassung
Physikalisches System
Auswahlaxiom
Computeranimation
Task
Task
Softwarewerkzeug
Gebäude <Mathematik>
Versionsverwaltung
Softwarewerkzeug
Stromlinie <Strömungsmechanik>
Stromlinie <Strömungsmechanik>
Elektronische Publikation
Bitrate
Computeranimation
Prototyping
Systemprogrammierung
Energiedichte
Gebäude <Mathematik>
Bitrate
Computeranimation
Faserbündel
Stabilitätstheorie <Logik>
Web log
Zurücksetzung <Transaktion>
Diskrete Gruppe
Ranking
Computeranimation
Zeitstempel
Datenhaltung
Datensatz
Reverse Engineering
Migration <Informatik>
Programmbibliothek
Kontrollstruktur
Zeitstempel
Gleitendes Mittel
Tropfen
Inklusion <Mathematik>
Softwareentwickler
Auswahlaxiom
Datenhaltung
Softwarewerkzeug
Migration <Informatik>
Biprodukt
Bitrate
Kontextbezogenes System
Frequenz
Quick-Sort
Zeichenkette
Objekt <Kategorie>
Datenfeld
Twitter <Softwareplattform>
Rechter Winkel
Automatische Indexierung
Faserbündel
Zeichenkette
Aggregatzustand
Tabelle <Informatik>
Objekt <Kategorie>
Faserbündel
Mathematisierung
Besprechung/Interview
Computeranimation
Task
Migration <Informatik>
Inverser Limes
Softwareentwickler
Informatik
Figurierte Zahl
Kategorie <Mathematik>
Datenhaltung
Mathematisierung
Indexberechnung
Migration <Informatik>
Objekt <Kategorie>
Teilmenge
Arithmetisches Mittel
Datenfeld
Körper <Physik>
Automatische Indexierung
Rechter Winkel
Zurücksetzung <Transaktion>
Schlüsselverwaltung
Tabelle <Informatik>
Aggregatzustand
Umsetzung <Informatik>
Einfügungsdämpfung
Symboltabelle
Computeranimation
Datenmanagement
Bildschirmfenster
Kontrollstruktur
Lambda-Kalkül
E-Mail
Softwaretest
Namensraum
Datenhaltung
Güte der Anpassung
Programmierumgebung
Zeiger <Informatik>
Bitrate
Kontextbezogenes System
Web log
Datenfeld
Rechter Winkel
Analog-Digital-Umsetzer
Konditionszahl
Programmierumgebung
Schlüsselverwaltung
Zeichenkette
Tabelle <Informatik>
Instantiierung
Aggregatzustand
Lesen <Datenverarbeitung>
Standardabweichung
Faserbündel
E-Mail
Mathematische Logik
Datenhaltung
Task
Puffer <Netzplantechnik>
Datensatz
Multiplikation
Task
Unterring
Migration <Informatik>
Hash-Algorithmus
Programmbibliothek
Zeiger <Informatik>
Drei
Elektronische Publikation
Raum-Zeit
Default
Vektorraum
Physikalisches System
Elektronische Publikation
Design by Contract
Objekt <Kategorie>
Last
Mereologie
Hill-Differentialgleichung
Mini-Disc
Verkehrsinformation
Faserbündel
Softwaretest
Resultante
Open Source
Datenhaltung
p-Block
Elektronische Publikation
Gesetz <Physik>
Raum-Zeit
Computeranimation
Gradient
Task
Grundsätze ordnungsmäßiger Datenverarbeitung
Kontrollstruktur
Softwareentwickler
Verzeichnisdienst
Stab
Funktion <Mathematik>
Faserbündel
Freeware
Gruppenoperation
Zahlenbereich
Unrundheit
Patch <Software>
Computeranimation
Informationsmodellierung
Schätzung
COM
Skript <Programm>
Gerade
Funktion <Mathematik>
Softwaretest
App <Programm>
Graph
Softwarewerkzeug
Routing
Physikalisches System
Elektronische Publikation
Bitrate
Dateiformat
Teilbarkeit
Mustersprache
Verknüpfungsglied
Wurzel <Mathematik>
Automatische Indexierung
Rechter Winkel
Projektive Ebene
Computerunterstützte Übersetzung
Lesen <Datenverarbeitung>
Kreiszylinder
Faserbündel
App <Programm>
Bit
Mathematisierung
Versionsverwaltung
Schlussregel
Bitrate
Elektronische Publikation
Computeranimation
Konfiguration <Informatik>
Verknüpfungsglied
Verbandstheorie
Prozess <Informatik>
Projektive Ebene
Warteschlange
Softwareentwickler
Figurierte Zahl
Schlüsselverwaltung
Programmierumgebung
Aggregatzustand
Stellenring
Fakultät <Mathematik>
Datenmanagement
Raum-Zeit
Computeranimation
Deskriptive Statistik
Last
Standardabweichung
Softwarewartung
Computersicherheit
Speicherabzug
Statistische Analyse
Skript <Programm>
Kontrollstruktur
Dateiverwaltung
Gerade
Softwaretest
Addition
Namensraum
Bitrate
Biprodukt
Kontextbezogenes System
Computervirus
Gruppenoperation
Motion Capturing
Generator <Informatik>
Dienst <Informatik>
Token-Ring
Forcing
Rechter Winkel
Festspeicher
Programmierumgebung
Faserbündel
Tabelle <Informatik>
Faserbündel
Stromlinie <Strömungsmechanik>
Datensicherung
Datenhaltung
Virtuelle Maschine
Variable
Rangstatistik
Reelle Zahl
Migration <Informatik>
Hash-Algorithmus
Varianz
Open Source
Raum-Zeit
Default
Softwarewerkzeug
Elektronische Publikation
Echtzeitsystem
Gamecontroller
Wort <Informatik>
Kantenfärbung
PRINCE2
Textbaustein
Streaming <Kommunikationstechnik>
Konfiguration <Informatik>
Versionsverwaltung
Datensicherung
Login
Datenmanagement
Total <Mathematik>
Zeitstempel
Default
Folge <Mathematik>
Parametersystem
Motion Capturing
Datenhaltung
Stellenring
Reihe
Ähnlichkeitsgeometrie
p-Block
Programmierumgebung
Softwarewartung
Funktion <Mathematik>
Projektive Ebene
Verzeichnisdienst
Ebene
Stab
Code
Task
Physikalisches System
Task
Notebook-Computer
Softwareentwickler
Speicher <Informatik>
Bildgebendes Verfahren
Wald <Graphentheorie>
Elektronische Publikation
Rechenzeit
Logarithmus
Konfigurationsraum
Mailing-Liste
Migration <Informatik>
Quick-Sort
Last
Mereologie
Parametersystem
GRASS <Programm>
Mini-Disc
Brennen <Datenverarbeitung>
Stab
Videospiel
Datenmanagement
Forcing
Visualisierung
Projektive Ebene
Visualisierung
Schnitt <Graphentheorie>
Computeranimation
Videokonferenz
Computeranimation

Metadaten

Formale Metadaten

Titel Crushing It With Rake Tasks
Serientitel RailsConf 2016
Teil 47
Anzahl der Teile 89
Autor Clark, Barrett
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/31506
Herausgeber Confreaks, LLC
Erscheinungsjahr 2016
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Although bundle exec rake db:migrate is probably the single biggest killer feature in Rails, there is a lot more to rake. Rails offers several rake tasks to help with everyday project management, like redoing a migration because you changed your mind on one of the columns, clearing your log files because they get so big, and listing out the TODOs and FIXMEs. What's even more awesome that all that is that you can create your own rake tasks. Got a tedious command-line process? Write a rake task for it!

Ähnliche Filme

Loading...