 Sometimes when people hear lens wrinkles, they think we ran classes. That is not what we ran, we ran care of them. My slides aren't black all the time. I'm really glad to be here from Memphis. I have to confess though, I'm terrified of public speaking to the point that when I was in college, I took my public speaking class online. So I'm going to be here and give this a shot. Today I'm mostly going to be talking about Ruby. I've at least worked with Ruby before. Cool, yay. So yeah, it's Ruby having talk. So I apologize in advance that Ruby is everything. If you're not a web development board, Ruby, here are the top six games on iTunes right now. You can go download. You should have about 30 minutes to advance in those. Anyway, so we are, the tools is a Ruby on Rails shop. Today we make a lot of comparison to Rails because it's kind of my home a little bit. Me personally, I was actually a little late to the Ruby party. I showed up in 2012. But four years later, I still love it. So I write Ruby. It's still a lot of fun to me. But like I said, kind of along with Ruby, I do a lot of Rails. I would, wow, you can't say that at all. And like most Rails developers, to me what I see it seems like you came out to Ruby because of it. But yeah, there's also some other Ruby frameworks out there. If you actually Google alternative Ruby frameworks, one of the PJ's articles comes up and Elisa Nacha is popular. Micro framework. There's also Katrina, I don't know if I'm saying that right. I actually covered that one much. Built on top of Sinatra, which you can choose which you like. Cuba, micro framework, I guess a lot with APIs. I listed Volt, but I marked it up because Volt actually doesn't seem to be after much development right now. But it lets you run, let your own Ruby client and server side, it's kind of cool. And there's a few others that I've listed, but from that list, there are a few things that are missing. There's one thing that kind of stands out to be this missing. We don't necessarily have a ton of options for, I guess, more opinionated full stack frameworks. I'm scared you're using full stack now today. But there is one I found and it's called Anami. And we'll go ahead and just read you what Anami is. This is from their website. It's a Ruby, a ModelDController web framework comprised of many micro libraries. It has a simple, stable API, minimal DSL, and prioritizes the use of plain objects over magical, over complicated classes with too much responsibility. So the guy who created Anami's is Luca. He actually had a chance to talk to him this week and he was super nice and threw out questions for me. He may have heard of this project. It was called Lotus for a little while. Somebody from IBM was like, hey, maybe don't use that name. And so now it's called Anami. But I was asking him, I said, hey, if I'm talking to a group of people and maybe they don't know about Anami, what's like, what do you want to walk away with? There's nothing. He gave me a few things. Once you know that Anami is full featured, we'll try to take a look at some of that today. It's lightweight. Actually, that's how it started until we just started with Rack and then just started taking the smallest steps to be lightweight from there. It's built for long-term applications. So it's designed that the transportation grows and your features grow that it's easier to maintain. And then also it's built so you can write testable code. I don't have so much time to go over stuff and frameworks as a whole are just important to cover everything. So the one thing I'm just going to say is that don't focus too much on the actual code. It may be easier or you may not. More or less, I kind of want to talk about Anami's architectural approach to things. I think it's kind of interesting. Like I said today, to be a code that we walk through and more or less looking for the architecture things. There is a warning, I guess, on the website. It says, this is actually a clue to itself. This is a warning that whether you are a total beginner or an experienced developer this learning process can be hard. After 10 years you develop a way of working and it can be painful for you to change however without changing the challenge. So with that all said, let's take a look at Anami. As any good Ruby project we can install it. Jam is called Anami and it has 20 dependencies that you rely on. I don't know if you can see but there's really two sections. You have some actual Anami gyms and they're all the router, controller, view, models. They're all based on individual models. But then you also have these gyms that start with Drive. Anami started working with Drive RV recently. And I haven't done a ton of research. Oh no, I haven't drive every website but it's my HTTPS so we're all screwed. Alright, never mind. So we'll keep on so creating an Anami application just like a Rails application or similar as we have command line tools so we can say not a good bookshelf and it will create all the files. I should also mention that these examples are from Anami's website. I figure I can write my own application on that pretty good already. So once we do that this is what our root directory looks like. Gym file, rig file. We have apps directory which we'll look at. Config directory, rack file, database directory, live directory and then a spec folder. So once you do that you just want to install all your indices installed and Anami's server will actually start up. Anami server port 2300 and this is where you get after all that. So not too bad to actually just get something on the page but what I'm going to do today I'm going to walk through just building a feature and we're going to do it tester and development stuff we're going to try and write the test to fail and then pass. So our first test and we want to we'll just read it when we visit the home page we want to check that pay flow successfully. So when we visit the root URL the body should just have the word bookshelf on it. Simple enough, run that fails just like you want it cool, so let's just walk through the steps and get bookshelf on the page. So we need a wrap so pretty standard route you just want we want our root whenever you visit just the entry point of sight to go to the home controller and an index action easy enough, feels like standard to me so there let's make a home controller and this is where things for me were kind of like what is happening now and it's actually kind of cool and so if you look in our apps directory we have a web app we have a controllers directory then instead of having just a home controller filled with a bunch of actions we actually have a home directory and then our action which is index is its own Ruby class so what happens here is we have that class of a module its name is base web controller is home and then whenever we whenever we hit this it's actually looking for that call method so we define that passing the primes and then to give our actual a non-name functionality instead of inheriting from something like application controller something like that we're actually including a module web action so when I first looked at this it was really confused about but it starts to kind of make sense the more I looked at it because everything's really isolated so when I started having more actions with their own classes and for me I started thinking about all the time I've written private methods and controllers that are just like to want an action and then all of a sudden my controllers were huge so the next we need to add is a view and it rails a lot so it rails we would just from there we have a template it would just be like index or just we have home directory index dot html erb or handle but here we actually have another class so it follows the same kind of structured view as home index class name space and web views home module and then we're including web view and people will hit this a little bit later on but what this file does is it'll actually get rid of the template but what's nice is you can keep some of your logic out of your actual template and put it to this file so that said we add our html we're not rendering any data right now so it's just an h1 tag so that's easy enough if we step back and we look at our test well when we visit the home when we visit the reader's site and it goes to that controller that controller calls that view and that view renders that template that has a bookshelf on it then we're passing now so that's kind of a high level review at least the html part of the thing but from there it's not very exciting we work with data so let's make a model from here on out from Anami's co-generators so what we can do here we'll just say Anami generate model and we want to make a book so one thing I'll go ahead and point out here is that we created a new book entity and a book repository so Anami actually separates your logic and your persistence layer and we'll kind of like attack here so there's a slide that says that and then the two act together so something like active record and then just that persistence is magically there here it's a little more explicit so your actual model doesn't know anything about how it's stored in database but the two work together so entities are repositories but before I move any further some of what I'm about to show and I'll try to point out is about to change Anami is in 0.8 version right now and I think they're working towards 1.0 so some of the core principles entities are repositories so the same but take that with a grain of salt so entities is something really close to a plane doesn't know anything about database structure and it focuses on behaviors that we want from it and only then how to see them so if we look at the entity that was generated for us in the book sure enough it's just a class name book we define some attributes so we want a book to have a title and an author and then we just want to bring in the anomaly related functionality by including Anami entity an example of what that brings in is it's automatically going to have an attribute right now don't know what you're supposed to call that and then there's an example of a test a little backwards on TDD but we can just say hey if we say book.new past the title we're factoring then the book title should be more factoring sure enough it doesn't then it would just be like I don't know what you're talking about so that's where the attribute is going to apply the entities so you're in that test it passes okay cool so we've gone down to the HTTP layer we've looked at entities but we actually want to say that it's such a database because otherwise we're entity we can only take it so far so how do we do that? repositories are what read and write are all straight from the database so sure enough all we need to do first is get our database set up demand one is the nominee we create we'll have an entity database but now we need a books table underneath it so handy another handy tool is to generate migration we're going to create a books table well migration so it's a method called create tables we're going to create tables, we're going to create books we're passing a block we have a primary key like the home title we don't want it to ever be known we don't want it to be known we don't want it to be known pretty standard we migrate fancy there I'll show you, I think it's something that's going to change so right now we have the two separated so you don't know how to internet right now they use the data map to do that you would in your bookshelf.rb file which is the project file that we directory there's already a method there called mapping it's what you would just say I have a collection called books and for every I want that to map up with both repository that's how the two work together save the database both of the database these are the attributes that I'm expecting that should match the column but like you said I think that's about to change so wasn't that too much alright so just to kind of show how the two work together we open up a rebel and both repository not all well we have nothing in our database so it returns to your right so let's try and save a book we'll save look.new, give it a title and we'll save that to a variable turn it off there's our book object well if we want to persist that to the database typically if you have this and like an active writer type of art you can call save but here we explicitly say both repository and we pass in our entity and then you'll notice and it returns title author but now it has an ID attribute because it's in our database and we pass back my ID so then also you can save both repository not fine, pass the ID so that's how the two work together a real high level overview of that okay I'll be ahead of myself here so we're about 20 minutes in we're going to go ahead and start data in the TDD approach like any project that ever starts with TDD stop halfway through and we're going to just kind of roll through here so now we have data it's your database we have entities we have all these things so I'll start trying to do it together a little bit so this is our I should say template's home index HTMLERB so all we're doing is we're saying well there's any books let's loop through who did it with the title and the author if there's no books, hey there's no books yeah so it's pretty simple PRB code so at this point though we're calling books how do we get books down that layer to the template so here what we're doing this is the same controller from earlier but all we're doing now is we're calling a method expose and we're saying books so what that expose method does is actually allow you to access that from the template so we have this variable books equals book repository.all if that expose method wasn't there the template would have no idea what books is so instead of just everything that's variable being available to the template we actually have more control over what we allow through so if you hold the site down well that's what it would look like and at this point when I was first starting I was so thrilled to get this far but there's one other thing we have time for so I'm going to look at let's look at actually we know how to save and to teach for database we know all the new stuff now let's first just gather the more important forms because we're web developers so Anami has another seal after this that we can generate an action and it's in our web folder which I was finding at the end we want it to be books controller with a new action so we run that Anami impends this route to the routes file for us so get books new, maps with books controller new then in our template we open up a form method so this looks a little different from the way other web frameworks do forms we still have form 4 it's for a book and when you submit it it should go to, it should post to books but instead of chopping it up where you close off an ARB tag it's an HTML which will then close it off or open up again a lot of open and closing this is just in one full set of ruby code so you can pull div, give it a class and then passing your attributes for label and text field so this will actually build that form for you in just one valid ruby method and so this will give us this we have a form so if we hit submit just gonna blow up we'll add another action we'll say create method and we want it to actually be the method type post because we're submitting our form so once again this will append to the routes file for us it'll actually go be post method now instead of get when we post a book it should take us to books controller create action same slide so similar to how we had when we did new we exposed book and then what we're doing now though is when we actually call this we'll work our way down that call method so we say both repository.create we want to save this to the database we just want a new entity book.new and pass it on so pretty standard code there and then we're done let's just re-drive to the home page so shake off when you run this you hit enter save it to a database so I mentioned that I would come back to that web folder so you'll notice that the apps folder is portalized so there's a couple of apps inside of one anomaly application so this is nice like if you had an admin dashboard or something like that you can actually separate that out so instead of apps web you have apps admin so you can isolate all the different maybe areas of your application but they all share the same entities and repositories because your entities repositories are a little bit longer that's just something I wanted to mention pretty neat so kind of wrap it up I said this thing was full featured I went through a little bit of it so let's just list out some of the features these are all you're available each of you have five helpers so you've got four hidden field, number of field all the things you kind of expect from a form and these are all the other things it covers you've got parameters montage, sharing, even share code between apps things like that a lot of stuff that we don't have time to cover today so really the thing that if anything I want you to take away from one anomaly how it's different from other applications is that it's less magic so you could say that anomaly kind of gets more explicit and very implicit to me I kind of enjoy that I still like working in Rails a lot but it's nice to have something else to work with in Ruby really I guess it kind of comes down to your preference some people like the magic, some people like being explicit I like the balance of both so if you're interested in Konami website has just that's what all these code samples were pulled from you can check it out on Github it's actually the first open source project that I was able to contribute to so that was kind of cool they're on Twitter and then they've got githubchats which had it out at gamirb.org that's actually all I have so maybe I will be back on schedule so I'm not going to ask you a question because I'm super awkward so if you want to come up to me I'm not going to ask you a question because I'm going to talk but right here so thank you guys