<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Hassan Khan on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Hassan Khan on Medium]]></description>
        <link>https://medium.com/@hsklogix?source=rss-317786c1d3e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LhQc6zwb1Zpe5fSdWwrTHw.png</url>
            <title>Stories by Muhammad Hassan Khan on Medium</title>
            <link>https://medium.com/@hsklogix?source=rss-317786c1d3e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:15:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hsklogix/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create your first ruby gem with 4 easy steps]]></title>
            <link>https://medium.com/@hsklogix/create-your-first-ruby-gem-with-4-easy-steps-22229da93353?source=rss-317786c1d3e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/22229da93353</guid>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[create]]></category>
            <dc:creator><![CDATA[Muhammad Hassan Khan]]></dc:creator>
            <pubDate>Thu, 26 May 2022 11:44:05 GMT</pubDate>
            <atom:updated>2022-05-26T11:44:05.002Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*VNj-6IQMlqaIfzEegRF7mA.jpeg" /><figcaption>Photo by <a href="https://turleyjewelers.com/blog/ruby-the-fiery-seductress">Turley Jewelers</a></figcaption></figure><p>In this article, I’ll cover 4 easy steps to create a gem and publish it on <a href="http://rubygem.org/">RubyGem.org</a></p><p><strong>Prerequisites:</strong></p><ul><li>Good understanding of ruby language.</li><li>An account on <a href="http://rubygems.org/">RubyGems.org</a></li><li>Knowledge of Rspecs <strong>(Optional)</strong></li></ul><p>Many of us have always wondered how cool is that to create our own gem! Well, thanks to the tools baked right into RubyGems. With just 4 simple steps we can create our own gem, so either if you have some independent service/module that you think can be used as a gem, or you just need to learn how you can create a gem, then luckily, you are at the right place ;)</p><p>Let’s now jump right into it:</p><h4>Step 1: Creating a project and naming your gem</h4><p>Let’s create a simple gem project using the following two commands:</p><blockquote>gem install bundler</blockquote><blockquote>bundle gem &lt;your_name&gt;_hello_world</blockquote><p>I am creating “hsk_hello_world” as an example which should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNQrhvUySIZLaknlLRGO_w.png" /></figure><p>Secondly, we need to decide on a name for our gem and try to keep it unique and precise. <a href="http://rubygems.org/">RubyGems.org</a> doesn’t allow duplicates, so we need to make sure that. Let’s create a simple gem “Hello World”; We can name it “&lt;your_name&gt;_hello_world” to keep it unique.</p><p>Code for gems is placed within the <strong>lib</strong> directory. Our newly created project contains the <strong>hsk_hello_world.rb</strong> file in it. Your directory structure should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IApQ6q8DBXWV4laoSU3ADw.png" /></figure><h4>Step 2: Adding the code</h4><p>We can now add the code in our ruby file. For an example, see below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22aMWoaBB9hq1TH43g8XHA.png" /></figure><blockquote>You should push the code into some public git repo which you’ll require for next step.</blockquote><h4>Step 3: Adding the gemspec</h4><p>You’ll be seeing a gemspec file on your root folder which should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXwdnjrbusNAyVRqnhPOGA.png" /></figure><p>For our sample gem, we’ve specified the following fields:</p><ul><li>authors: A gem&#39;s author(s).</li><li>email: An email address.</li><li>summary: A short gem&#39;s description</li><li>homepage: The URL of the gem&#39;s home page.</li><li>metadata[&quot;source_code_uri&quot;]: The gem&#39;s source code URI. We&#39;ll use the same value as for the homepage.</li></ul><p>Add this information to your gemspec file.</p><h4>Step 4: Build and Publish your gem</h4><p>For building your gem you need to run the following command:</p><blockquote>gem build hsk_hello_world.gemspec</blockquote><p>It will create a “.gem” file in your folder.</p><p>Then you can publish your gem with the simple command below:</p><blockquote>gem push hsk_hello_world-0.1.0.gem</blockquote><p>You’ll write your gem name for your case.</p><p>It’ll look something like the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFyzkoRkSlfNDfvPkMFEAw.png" /></figure><p>and then you can search your gem on <a href="http://rubygems.org/">RubyGems.org</a> like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6y23hqAK5qp2ycoGwlTMQ.png" /></figure><h4>Hurrah!!! You just pushed your first gem to <a href="http://rubygems.org/">RubyGems.org</a>.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*NchzP_EhNsT9ZqI3jYdomQ.gif" /></figure><h4>Things you could also be doing:</h4><p>For testing, you can locally install your gem using the following command:</p><blockquote>gem install hsk_hello_world-0.1.0.gem</blockquote><p>and then you can test that in “IRB” like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*cWjgzy5Rp-qBlT0tw79V5Q.png" /></figure><p>For additional instructions and official documentation, check out the <a href="https://guides.rubygems.org/make-your-own-gem/">official guide to making your gem</a> at RubyGems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22229da93353" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>