ConFoo Montreal 2018
@sophiedeziel
About anywhere!
Are you solving common problems?
Have some cool scripts?
Small number of variations Gemspec, licence, readme, etc
# Make dir and git init commands
> bundle gem has_prerequisite
> cd has_prerequisite
> git commit -Am "init the gem"
> cd ..
> rails plugin new has_prerequisite --skip-test --dummy-path=spec/dummy
> cd has_prerequisite
> git add -p
> git commit -m "init the rails specific setup of the gem"
Gem::Specification.new do |s|
s.name = 'hola'
s.version = '0.0.0'
s.date = '2010-04-28'
s.summary = "Hola!"
s.description = "A simple hello world gem"
s.authors = ["Nick Quaranto"]
s.email = 'nick@quaran.to'
s.files = ["lib/hola.rb"]
s.homepage = 'http://rubygems.org/gems/hola'
s.license = 'MIT'
end
I decided to keep the dependency on Active Support but not Devise.
So I have to implement similar methods
Failures:
1) HasPrerequisite redirection it redirects to the path when the prerequisite is not met
Failure/Error: store_location_for(:user, request.fullpath)
NoMethodError:
undefined method `store_location_for' for #<#<Class:0x007f9d98a359e8>:0x007f9d9b931238>
# ./lib/has_prerequisite.rb:36:in `perform_checks'
# ./spec/has_prerequisite_spec.rb:43:in `block (2 levels) in <top (required)>'
# ./spec/has_prerequisite_spec.rb:55:in `block (3 levels) in <top (required)>'
module HasPrerequisite
class Railtie > ::Rails::Railtie
initializer "has_prerequisite.configure_view_controller" do |app|
ActiveSupport.on_load :action_controller do
include HasPrerequisite
end
end
end
end
gem 'has_prerequisite', path: '~/dev/has_prerequisite'
> bundle install
=> It will use your gem
> rspec
gem 'has_prerequisite'
> gem build has_prerequisite.gemspec
Successfully built RubyGem
Name: has_prerequisite
Version: 0.0.0
File: has_prerequisite-0.0.0.gem
> gem install ./has_prerequisite-0.0.0.gem
Successfully installed has_prerequisite-0.0.0
1 gem installed
I recommend following Semantic Versioning
MAJOR . MINOR . PATCH
When to publish 1.0.0 ?
Tip: you can always use the labels (1.0.0.beta, 1.0.0.rc.1, 1.0.0.pre, 1.0.0.racecar-1)
choosealicense.com
contributor-covenant.org
Run your own with `gem server`
Gemfurry
Note: configure .gemspec to avoid accidental pushes to Rubygems.org
→ bundle exec rake release
has_prerequisite 0.0.1 built to pkg/has_prerequisite-0.0.1.gem.
Tagged v0.0.1.
Pushed git commits and tags.
Pushed has_prerequisite 0.0.1 to rubygems.org.
@sophiedeziel
Official guide:
guides.rubygems.org/publishing/
Moving code to lib folder:
justinweiss.com/articles/a-guide-to-extracting-your-first-ruby-gem/
PR for open-source: