Interestings
HTML5 Definition Complete
http://www.w3.org/2012/12/html5-cr
The W3C has finished adding features to the HTML5 definition, and appears to be on target for full release in 2014, after a period of interoperability testing.
http://www.w3.org/2012/12/html5-cr
The W3C has finished adding features to the HTML5 definition, and appears to be on target for full release in 2014, after a period of interoperability testing.
Before we start, the .gemspec itself only appears once. Here it is, as generated by bundle init and hand-tweaked for relevance:
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "your_gem/version"
Gem::Specification.new do |s|
s.name = "your-gem"
s.version = YourGem::VERSION
s.authors = ["Your Name"]
s.email = ["you@example.com"]
s.homepage = "https://github.com/you/should-use-github"
s.summary = "Describe this gem like you're talking to me."
s.description = "Describe this gem like you're talking to your mom."
s.require_paths = ["lib"]
s.files = `git ls-files`.split("n")
s.test_files = `git ls-files -- spec/*`.split("n")
s.add_dependency "hashie", "~> 2.0"
s.add_development_dependency "rspec", "~> 2.12"
end
But what does all this mean? Moreover, how do all these crazy bits fit together?
The most important component of any gemspec is the list of files that it includes when building the gem. After all, a .gem file is just a tarball with a metadata header written in Ruby. Here’s how we make that happen:
s.files = ['file/one', 'file/two']
s.test_files = ['spec/one', 'spec/two']
Let’s exploit part of git to give us the list of files. Don’t use git on your project? Start using git. Problem solved! Here’s what it gives us:
$ git ls-files
.gitignore
.rvmrc
Gemfile
LICENSE
README.md
your-gem.gemspec
lib/your_gem.rb
lib/your_gem/version.rb
spec/lib/your_gem.rb
spec/spec_helper.rb
We can make this output into a Ruby array of strings quite simply:
`git ls-files`.split("n")
Now, gems are laid out in a conventional way. That means a lib directory, a spec directory and some predictable files. That means nobody has to guess where your files are, which is fantastic!
Now let’s say you want to exclude your .rvmrc and .gitignore, because those files aren’t really all that important:
`git ls-files`.split("n") - %w(.rvmrc .gitignore)
Note: exclude Gemfile.lock from git, even though it might exist in your directory. This is conventional.
Your gem’s classes are called YourGem, while they live in files named your_gem. As a matter of taste, I believe gems should be named your-gem. There’s an argument to be made that gem names should match their requires (i.e., the gem should be named your_gem).
The first component here is the version number for your gem. In this example, the your_gem/version.rb looks like this:
module YourGem
VERSION = "0.1.0"
end
This is a Semantic Versioning string, and it’s the Simplest Thing that Could Possibly Work for a version.
This is the fun part. I’m of the opinion that dependencies should be as loose as possible until they’re not, but that throwing them away by doing >= 0 is the wrong approach.
For example, the above file will pull in RSpec as a dependency, but require any version that matches a pattern like 2.y.z, as long as y is above 12. Note that z is allowed to be anything, which allows patch versions to be included.
Of course, this means that everyone in the community has to play along and not break their gem on a minor version bump. Also, the community now includes you!
So now you’ve got a conventional gem with loosely-required dependencies. How do you know if these change? Well, if you’re on github, you can use Gemnasium to watch for new dependency versions and see if anything’s broken!
Dropping a new version of your gem is as easy as gem release with @svenfuchs‘s gem-release gem.
While I don’t necessarily think CamelCase is the best way to name your coffeescript files, I was unhappy that we weren’t consistent on my project.
I was going to write a pure find/sed/mv script but found Mac OS X’s sed doesn’t support text transforms like L so I finally delved into ruby -n:
find . -iname *_*.coffee | ruby -ne 'puts "mv #{$_.chomp} #{$_.gsub(/_(.)/) { $1.upcase }}"' | bash
As of git 1.8.0, git rebase learned “–edit-todo”. This is something you can use to edit the todo list while in the middle of a rebase. For example, if you mark a commit as e (for edit) when you initially edit the todo list, when git stops at that commit allowing you to edit it you can then git rebase --edit-todo to edit the remaining portion of the todo list.
If you set up some bindings such as
viewClass = Backbone.View.extend({...})
view1 = new viewClass();
view2 = new viewClass();
model.bind("event", view1.myFunction, view1)
model.bind("event", view2.myFunction, view2)
and then want to unbind one of the callbacks…
model.off("event", view1.myFunction)
you will unbind both callbacks. You need to use
model.off("event", view1.myFunction, view1)
This is fundamentally because of javascript prototypes that mean view1.myFunction == view2.myFunction
Ruby 1.9 regexs can match Unicode Categories . Not filtering out Joëlle in your validations has never been so easy (/p{L}/)!
Railsbridge is a monthly-ish workshop to teach programming, primarily focused at women.
December’s Railsbridge event will be at Pivotal SF on December 14-15.
All you pivots in the office know tons about Ruby and Rails. Please come to the workshop to spread your knowledge and be awesome!
I want to TDD contenteditable, where a DT element can be changed and it’s underlying resource receives an PUT. Is this even possible?
Last month we introduced an exciting integration between Tracker and Wazoku’s awesome idea software. Wazoku is ideally suited to all you Product Managers looking for the tools to capture the best product ideas from across the business, filter and prioritise them and then in a single click create the story in Tracker.
To truly grok this integration we are running some demo webinars in the new year. Register here to reserve your seat – This webinar will cover the basics of idea management and showcase the integration between the two products. There’ll also be opportunities to discuss the application and answer any questions.
Also, don’t forget that Wazoku have very kindly offered all Tracker users an exclusive discount of £0.75 / $0.50 per user per month. You can access a free trial here (don’t forget to enter the promo code PTPC25F).
Let the ideas flow and hope to see you in January on the webinar!
Today’s github outage drove us to try ssh urls instead of the https urls we were using. A pleasant speed improvement in deployment time resulted.