1 00:00:00,000 --> 00:00:04,552 [MUSIC] 2 00:00:04,552 --> 00:00:09,409 In Ruby, a Gem is a library that contains a specific piece of functionality 3 00:00:09,409 --> 00:00:13,430 as well as any files or assets related to that functionality. 4 00:00:14,480 --> 00:00:17,520 Gems can be found for all sorts of common things that you'd want to do 5 00:00:17,520 --> 00:00:22,150 in an application, things like handling money and currency, integrating with 6 00:00:22,150 --> 00:00:26,790 credit card processing, tools to make Ruby coding even easier, and more. 7 00:00:27,890 --> 00:00:29,370 You could write these things yourself, 8 00:00:29,370 --> 00:00:32,920 but one big benefit to using a Gem instead is that it saves time. 9 00:00:34,110 --> 00:00:37,173 The main place that gems are found is rubygems.org. 10 00:00:37,173 --> 00:00:41,354 Let's take a quick look at RubyGems now. 11 00:00:41,354 --> 00:00:45,653 Now here we have the main rubygems.org website. 12 00:00:45,653 --> 00:00:47,953 Now the instructions on here are pretty clear. 13 00:00:47,953 --> 00:00:52,890 You can find, install, and even publish your own RubyGems. 14 00:00:53,950 --> 00:00:56,820 Now, the main focus of this site is the big search 15 00:00:56,820 --> 00:00:59,160 box right in the center of the screen. 16 00:00:59,160 --> 00:01:02,300 This is how you'll find most of the Gems that you want to work with. 17 00:01:03,840 --> 00:01:08,280 Let's say we wanted to install a Gem to work with money and currency. 18 00:01:09,370 --> 00:01:15,180 We can search Gems and find money, if only it were that easy in real life. 19 00:01:16,290 --> 00:01:20,250 Now once we search, we see any exact matches for 20 00:01:20,250 --> 00:01:25,460 Gem names that come up and then, a small description of what the library does. 21 00:01:25,460 --> 00:01:29,380 Here, we see it's a Ruby library for dealing with money and 22 00:01:29,380 --> 00:01:30,860 currency conversion. 23 00:01:32,100 --> 00:01:36,170 Over on the right-hand side of the screen, we'll see the number of downloads. 24 00:01:36,170 --> 00:01:41,160 Now this can be a good indicator of the popularity of a particular Gem. 25 00:01:41,160 --> 00:01:44,820 Gems with more downloads will be more popular, and 26 00:01:44,820 --> 00:01:49,510 it can be reasonably assumed that they're maintained more often than other Gems. 27 00:01:50,970 --> 00:01:55,960 Now as we scroll down this page, we'll see less exact matches and 28 00:01:55,960 --> 00:01:58,500 these results are paginated, so 29 00:01:58,500 --> 00:02:02,910 this is only displaying one through 30, of 134 total Gems. 30 00:02:04,380 --> 00:02:09,640 Now as we scroll down, we see the less exact matches, money-rails 31 00:02:09,640 --> 00:02:13,720 provides integration of Ruby money in a rails application. 32 00:02:15,730 --> 00:02:18,055 Once we find a Gem that we want, we can click into it and 33 00:02:18,055 --> 00:02:19,565 see a more thorough description. 34 00:02:19,565 --> 00:02:24,426 On the left side, the most recent versions will be shown. 35 00:02:24,426 --> 00:02:29,390 Now we can see that this Gem is up to version 6.6.1, and 36 00:02:29,390 --> 00:02:34,869 the most recent version was released on July 27th, 2015. 37 00:02:34,869 --> 00:02:40,609 If we click in, we can see all of the different versions of this Gem, 38 00:02:40,609 --> 00:02:45,469 and it was released originally on June 8th, 2005. 39 00:02:45,469 --> 00:02:50,320 So this Gem has been released and maintained for about ten years. 40 00:02:51,970 --> 00:02:57,470 On the right side of the screen, we have runtime and development dependencies. 41 00:02:57,470 --> 00:03:01,850 A runtime dependency will only be installed if the Gem 42 00:03:01,850 --> 00:03:05,170 needs to be used in an application. 43 00:03:05,170 --> 00:03:11,280 So we can see that the Ruby Money Gem depends on the i18n Gem. 44 00:03:11,280 --> 00:03:14,179 i18n stands for internationalization. 45 00:03:15,430 --> 00:03:19,396 Now we only need that gem to be installed as well if we're just going to use 46 00:03:19,396 --> 00:03:20,249 the Money Gem. 47 00:03:20,249 --> 00:03:22,649 However, you'll see below that, 48 00:03:22,649 --> 00:03:26,732 there's a development dependency section of the screen and 49 00:03:26,732 --> 00:03:32,270 this shows that the Gem depends on bundler, kramdown, rake, rspec, and yard. 50 00:03:33,920 --> 00:03:36,930 We only need to worry about those if we plan 51 00:03:36,930 --> 00:03:39,930 on doing development against this Gem. 52 00:03:41,210 --> 00:03:42,959 In order to just use it, 53 00:03:42,959 --> 00:03:47,860 all that we would need installed besides the Gem itself is i18n. 54 00:03:47,860 --> 00:03:49,617 When we install the Gem, 55 00:03:49,617 --> 00:03:54,480 any dependencies that are needed at runtime will also be installed. 56 00:03:55,730 --> 00:03:58,460 We'll learn a little bit more about that later. 57 00:04:01,600 --> 00:04:06,710 Now we can also see if we click back to the homepage, there's a stats section. 58 00:04:06,710 --> 00:04:07,890 If we click in there, 59 00:04:07,890 --> 00:04:12,161 we can see the most popular Gems that have been downloaded on rubygems.org. 60 00:04:12,161 --> 00:04:15,468 This is based on the total number of downloads and 61 00:04:15,468 --> 00:04:18,140 we can see the most popular Gem is Rake. 62 00:04:19,220 --> 00:04:23,361 Rake comes with Ruby and is a task runner. 63 00:04:23,361 --> 00:04:28,531 The scope of Rake is a little bit outside of this course, 64 00:04:28,531 --> 00:04:33,490 but it is one of the most popular Gems as well as Rails. 65 00:04:33,490 --> 00:04:34,974 You may have heard of Ruby on Rails. 66 00:04:38,715 --> 00:04:42,535 Now if there's another functionality that we want, we can search for Gems. 67 00:04:42,535 --> 00:04:48,054 Let's say we want to use a Gem for interpreting JSON outside of the standard 68 00:04:48,054 --> 00:04:54,350 library, well, we could search for and find many different JSON Gems. 69 00:04:54,350 --> 00:04:59,030 And then we could click into them and read a little bit more about them if we want to 70 00:04:59,030 --> 00:05:03,730 and make the determination about whether or not we wanna use these in our programs. 71 00:05:05,630 --> 00:05:09,487 Another source for finding Gems to work on is Ruby toolbox. 72 00:05:10,990 --> 00:05:14,800 The Ruby toolbox shows Gems by category and popularity. 73 00:05:16,300 --> 00:05:21,960 We could click on the categories section, and it will have by name and by group. 74 00:05:23,240 --> 00:05:27,170 So for example, if we were looking for a different testing framework, 75 00:05:27,170 --> 00:05:30,977 we could click in to the testing framework section and then, 76 00:05:30,977 --> 00:05:37,140 Unit Test Frameworks and this will show us ranked by order of popularity, 77 00:05:37,140 --> 00:05:40,580 the different Gems that are available as a testing framework. 78 00:05:41,870 --> 00:05:46,118 We can see that the RSpec Gem is one of the most popular. 79 00:05:46,118 --> 00:05:49,180 It had it's first release about seven years ago, and the most 80 00:05:49,180 --> 00:05:53,340 current version was released about a month ago, as of the time of this recording. 81 00:05:54,600 --> 00:05:58,040 It will also show the number of watchers and forks on GitHub. 82 00:05:59,400 --> 00:06:02,450 As we scroll down, we see other testing frameworks as well, 83 00:06:02,450 --> 00:06:06,920 and the description of the Gem is right below the Gem Name.