Hanami Ruby Framework - A first look

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to Kota catch-up my name is Jamie Jones and in this video we're going to be checking out Phenom II which is a new ruby framework so basically it can't end it for rails but they're doing things a little bit differently and so basically I thought why not just clone it down or install it and just see what a bare-bones project is like and do some kind of quick comparisons with that so this is tsunami you can find a hanami RB sorry hanami RB doll I'm going to go through and to see everything with what it's like because it is 1.0 it's still very early days but it has been like this for a while now so going to go and install hanami great that's installed and let's actually create a new application using their example here okay great so we've got a bunch of files here I think I'll actually just go through these in them itself so it's seeding into bookshelf then let's open our slide by so let's go to the gem file first and just see what what everything's kind of comprised of so we've got Reiki as a dependency here very much very common for review applications these days have tsunami itself in an ally model which is the database back stuff then we have the PG gem which is actually used for for basically communicating with Postgres itself it's the glue the bridging kind of gem then in our development environment we have shotgun which is for hot reloading that code then in our tests and development environments we have dot end which is for using to load dot n files so if you've ever worked on a project that uses environment variables it gets kind of frustrating if you have to export them near terminal all the time so there are tools and a lot of frameworks and stuff have this now and in particular in Ruby we have dot ends which is a gem that will actually look into your root directory and see if there's a dot end file and it will load that up based on the environment all you just have a dot ends for everything you actually use Foreman which will that when it loads up as well and this allows you to use environment variables in a clean safe way without mucking up anything else on your system so the next up in tests we have mini tests which is built into or at least comes with Ruby to think it was Ruby 2 or 2.1 Canyon so you don't need to use r-spec it does have an aspect like syntax as well if you want to use that version otherwise you can use test unit then we have capybara for all our front-end testing and here it looks in like in production you can use the premise server if you want to and that's kind of my default these days if we go into the config ru file and it's basically just loading up an army app itself as well as the environment so let's go through to the config environment I have a look here so including the bundler anar me the model itself then the actual application and the website of the application so this is this is kind of interesting so if I go back a little bit here in your C on the left hand side I've got Apps config DB leave public spec and then if we go into apps we've got app spread this presents show it to all but it's actually apps folder then web and this is something I'm seeing in Phoenix applications itself so thanks has this approach now especially since West 1.3 so the latest version of Phoenix has this similar approach as well so you're actually having different apps so previously you might have a web portion you won't have an API portion that all be split up and it's basically separating those concerns into their own dual sections which is nice to see so that's a bit of a difference from rails itself where it will have app app and then all that related logic so an interesting looking change on that so back in our environment file now we're defining or we're actually mounting the application here slash so that's very much like how you mount engines in rails so that's interesting to see how they're mounting the actual web application part but assume you could then do like web api or something at slash api they'll be interesting to see and really nice if they actually do that next up is the model so we're just defining everything for all database so it the specifying it the adapter getting a diabase URL which that database URL i'm assuming oxide and looked at the docs of this but it will probably something like we actually specify the username password everything in a single string instead of actually specifying everything like a username password etc the next we have is our migration is just including where those are sign of the schema then we have our mailers we're just specifying where our mailers are in development just setting up the debugging levels and then our mail our environment settings for actual production so very minimal kind of setup for the environment file there's not too much there but it's showing that its simplicity really is key here and there's not a lot that you really do need for at least booting the application getting it going i'd say it's similar is to rails client application setup although it is split up into other files but very very similar set up in terms of how simple it is laid out so now let's just have a quick look at live and see if there's anything in here we got our bookshelf just defining it as a module then we go to entities and mailers and repository so the repositories are actually like database so you where your model stuff goes and I believe entities might be related up to check that one out again this is just a first look for me as well public very much where we very much the same as rails that's where you point things out spec we can see here we have a spec helper very standard they're just loading up mini tests and a features help us so we're loading in capybara and the DSL and basically passing that in allowing many tests to be able to use that DSL so we can do those that front-end testing so let's go across to the apps flash webs folder and as you can see we've got views templates controls nothing in there config which I have our routes let's say look at a route here so a good an example route which looks like it's just sending it 200 response saying everything's okay and then actually just rendering text and no templates or anything like that and it's actually passing the environment with it now this is something I find really interesting is passing the environment around it's very much similar I've seen in Phoenix because I think playing around with Phoenix an elixir a bit that possibly connection around so the connections kind of like the main important thing and passing that through because it makes testing and a bunch of other things a lot easier so they're doing something similar here with environment flight environment itself so if you go into application or are being click that one we're loading the helpers and the assets and then we're going through our applications this is our web application and we can see here we're manually loading things in sort of loading the controllers and the views which is pretty interesting to know there's no client order loading their loading our routes which is really nice to see here is actually specify this scheme so whether it be HTTP HDPE HBS and then setting all the hosts up here this is it's quite a nice take on instead of having like a bunch of yam all files and another kind of configuration going around we are cookies and get set everything up there so what else have we got body passes can force us cell to make sure that that page TPS is always used we're seeing the actual layout that's going to use by all the views assuming that should be nicely over writable same as specifying the relative path to the templates directory assets they've got a bunch of ones that got built in you can switch out to use something like aqua file your yui closure it's quite nice there so we got stylesheet same thing i've go to assets sources you know multiple sources there security is an interesting thing so this is something they talked about back if I go back here secure by default deploy applications that rely on the latest browser technology such as content security policy or CST X frame headers automatic escape in to protect your users against the most common security threats this is something you don't see too often in frameworks and it's nice to see actually being included there and actually leaving links to all the various security articles or and so you can find out more about these so it's giving a little education as well again a whole bunch of CSP stuff and it's really nice to see like a lot of this you probably actually won't need to change all it looks pretty much like the defaults of what you need and you just have to tweak it to suit your own kind of needs that I think for most people you won't hear to touch that basically agains prune the views going through the environments that not too much there so it's a 326 line file for the web application itself but that it's not really that big like if you look at it and see what's going on there if you take all the comments out it's actually pretty small which is good to see that it's keeping it fairly simple but still allow you to be more of a robust framework so as we can see we under views so views load and then we're including the actual web layout so from what I can see here this is very much very similar to Phoenix itself where you're actually loading in view first with rails are actually seeing view as the the view for that little bit that you're loading and that's all your markup and stuff like that inside whereas this isn't quite the case in this one so then from here view would then go to the template very much like Phoenix from what I can see so that might allow doing some more decoration and stuff like that in place then we have a template which is just plain old ARB very very similar we're seeing a yield here and they're loading in a favicon by fault which is nice so basically that's it so it's a pretty small kind of framework does feel very much like like Sinatra itself a very simple application but still very robust there's a lot there that we're not seeing that's handled by a tsunami itself as well as harming model so I think I'll need to dive in this deeper and actually start working on more of an actual application and doing some comparisons there for most kind of first first thoughts first touches on it I think it's I wouldn't say it's for beginners I think there's a bit more involved in a bit more already known knowledge about how the web works you're looking at something like this that might be a bit more daunting for someone who's very new so it might be something worth just evaluating and seeing how you go but I really do think it's more pitched at at least in my opinion to intermediate to experienced developers that know a little bit more about what's going on there are some parts which I think you're not gonna have to worry about but as you can see the content security policies and stuff like that that's that's more of an advanced topic for anyone who's creating things and I see a lot of fairly new developers starting off with Ruby now and actually going for rails and I think this would might be a bit more hands-on than what they're used to now that there is definitely positives for that and then benefits but I think there's many science is more of a stumbling block for people in you but that's essentially it I'd love to know if you've been playing around this for a while now I've got anything any kind of wise comments or words or anything that I may have interpreted wrong please leave them in the comment section below but I think I'm going to do a follow-up video to this find actually creating a basic application with an army and going through that and then doing another comparison again to Rails meeting a side-by-side working so I'd love to know if you want to see that leave a comment in the comment section below I'll leave a like to other the awesomes I know if if this is something or more of a video you want to kind of see progress more and go forward in the future other than that please subscribe if you're enjoying it and yeah check out the podcast you go and check that out that's at Co Capcom or you can find an iTunes Co to catch up that's essentially it and we'll catch the next video [Music]
Info
Channel: Coder Catchup
Views: 2,688
Rating: 4.9245281 out of 5
Keywords: web design, website design, web development, website development, web applications, web apps, web dev
Id: iBBLxA27KQE
Channel Id: undefined
Length: 12min 51sec (771 seconds)
Published: Sun Apr 09 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.