1 00:00:00,025 --> 00:00:06,004 [SOUND] The Gem command does many things in addition to installing 2 00:00:06,004 --> 00:00:12,314 Gems it can tell you what versions of the Gem are installed search for 3 00:00:12,314 --> 00:00:16,759 Gems tell you about your environment and more. 4 00:00:16,759 --> 00:00:21,259 Let's checkout the Gem command in a bit more depth now using workspaces. 5 00:00:22,370 --> 00:00:25,340 Let's go ahead and see what the Gem command really does. 6 00:00:26,530 --> 00:00:29,770 We can get a list of all the different commands inside of the Gem command by 7 00:00:29,770 --> 00:00:31,330 typing gem help. 8 00:00:32,570 --> 00:00:35,620 And it will show us exactly what Ruby Gems is. 9 00:00:37,250 --> 00:00:41,400 What we need more is gem help commands. 10 00:00:41,400 --> 00:00:44,380 And that will list all of the different Gem commands that we have to work with. 11 00:00:50,100 --> 00:00:52,620 So we type that in, and we can see that we have 12 00:00:52,620 --> 00:00:57,180 quite a few different things that we can do with Ruby Gems. 13 00:00:57,180 --> 00:01:01,400 Now not all of them are going to apply to what we're doing in this course. 14 00:01:01,400 --> 00:01:05,470 We're mainly looking at how to install and use gems. 15 00:01:05,470 --> 00:01:10,130 However, if we were creating our own gems, Ruby Gems command gives us 16 00:01:10,130 --> 00:01:14,380 a bunch of different options for working with them, such as build and certify. 17 00:01:15,970 --> 00:01:22,090 Now the commands that we need to be cognizant of are gem check, 18 00:01:22,090 --> 00:01:26,562 cleanup, environment, fetch, install, 19 00:01:26,562 --> 00:01:31,290 list, outdated, pristine, and uninstall. 20 00:01:31,290 --> 00:01:36,490 There's also the option to search gems as well as list gems. 21 00:01:36,490 --> 00:01:38,560 So I'm gonna clear my screen here. 22 00:01:39,850 --> 00:01:44,670 And if we want help on a gem command, we could say gem help and 23 00:01:44,670 --> 00:01:45,950 then the name of the command. 24 00:01:47,490 --> 00:01:49,960 Now, we're already kind of familiar with the install command. 25 00:01:51,350 --> 00:01:56,370 If we say gem help install, it will show us different options for installation. 26 00:01:59,790 --> 00:02:03,790 Now we can see there are quite a few flags that come along with install. 27 00:02:05,110 --> 00:02:09,270 The most common one that we'll use is the -v flag which stands for 28 00:02:09,270 --> 00:02:11,820 installing a specific version of a gem. 29 00:02:13,390 --> 00:02:18,610 Another option that you'll use quite a bit is --no 30 00:02:18,610 --> 00:02:23,370 document If you've been following along with this outside of work spaces, 31 00:02:23,370 --> 00:02:27,903 you might have noticed that gems are being installed with documentation. 32 00:02:27,903 --> 00:02:32,800 Now the documentation is another Ruby command that you can use 33 00:02:32,800 --> 00:02:34,890 to get help with the gem. 34 00:02:36,390 --> 00:02:38,890 Now, the kind of help that you'll get by using that, 35 00:02:38,890 --> 00:02:42,650 is the same thing as looking at the documentation on a web page. 36 00:02:43,720 --> 00:02:48,701 For speed, we've disabled the no document setting in work spaces. 37 00:02:51,671 --> 00:02:57,086 Now we can also pass around the directory where binary files are located, 38 00:02:57,086 --> 00:02:58,930 if that comes with a gem. 39 00:03:00,290 --> 00:03:04,029 For the most part, we won't be using many of the different options. 40 00:03:05,150 --> 00:03:09,240 In the case of a gem which you wanna install locally, as opposed to remotely. 41 00:03:09,240 --> 00:03:12,070 You can use -l. 42 00:03:12,070 --> 00:03:16,375 We didn't need to do that because the gem was in the same location as we were, 43 00:03:16,375 --> 00:03:17,667 when we installed it. 44 00:03:20,533 --> 00:03:23,185 Let's go ahead and look at the gem environment command. 45 00:03:24,410 --> 00:03:27,550 This will tell you everything you need to know about Ruby Gems. 46 00:03:30,530 --> 00:03:35,100 And if I scroll up here, we can see, this is our current Ruby Gems environment. 47 00:03:36,100 --> 00:03:40,232 The version of Ruby Gems we're using in Workspaces is 2.2.2. 48 00:03:40,232 --> 00:03:43,906 Our Ruby version is 2.1.5 and 49 00:03:43,906 --> 00:03:49,580 this shows, where Gems will be installed. 50 00:03:49,580 --> 00:03:54,397 For the purposes of work spaces, it's installed into the .local directory. 51 00:03:55,700 --> 00:03:59,150 Don't be alarmed if this is different on your computer 52 00:03:59,150 --> 00:04:01,330 if you're following along on your own computer. 53 00:04:03,180 --> 00:04:06,220 And then we can see the other various options 54 00:04:06,220 --> 00:04:08,680 That are occurring in our GEM environment. 55 00:04:10,110 --> 00:04:15,730 Now I'm going to clear my screen here and type GEM list. 56 00:04:16,890 --> 00:04:20,700 Now, the Gem list command, as you could assume from the name, 57 00:04:20,700 --> 00:04:23,370 lists our installed lists. 58 00:04:23,370 --> 00:04:28,220 And then, in parentheses, right after the name of the Gem, 59 00:04:28,220 --> 00:04:30,430 is the version of the Gem that's currently installed. 60 00:04:31,750 --> 00:04:34,070 If we go back, to the Ruby Money Gem, 61 00:04:36,120 --> 00:04:40,000 we can see that there are other possible options for versions of this Gem. 62 00:04:41,060 --> 00:04:46,740 So let's say we wanted to install version 6.6.0 We coud say gem 63 00:04:46,740 --> 00:04:52,470 install money and then -v for version. 64 00:04:52,470 --> 00:04:54,600 And the version number we want to install. 65 00:04:55,820 --> 00:05:00,290 This would be useful in the case where an application that you're coding against 66 00:05:00,290 --> 00:05:03,630 is built using an older version of the gem. 67 00:05:03,630 --> 00:05:06,053 And the API might have changed. 68 00:05:09,235 --> 00:05:12,440 Now we can see that that version of money was installed. 69 00:05:13,720 --> 00:05:17,600 So if I clear my screen and then do gem list once again, 70 00:05:17,600 --> 00:05:21,650 we can see that two versions now exist in our list. 71 00:05:22,760 --> 00:05:25,868 If we had an old version of an gem installed, 72 00:05:25,868 --> 00:05:29,231 we could use the update command to update a gem. 73 00:05:35,080 --> 00:05:40,280 And we can see that this updated our rake gem to 10.4.2. 74 00:05:42,410 --> 00:05:47,986 Now if we list it again, we can see that that installed the new version of rake, 75 00:05:47,986 --> 00:05:50,195 and the old one is kept as well. 76 00:05:55,601 --> 00:06:00,360 We could search for a gem just like on the Ruby Gems website. 77 00:06:00,360 --> 00:06:03,590 And we could also install any of these that we see in the list.