Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

boilerplate

  • Loading branch information...
commit 7bbce764535b4ee77d186997d028e0dbd57b391f 1 parent 97f3627
Ryan Carver rcarver authored

Showing 3 changed files with 194 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  LICENSE
  2. +129 0 Rakefile
  3. +64 0 fontvariationdescription.gemspec
1  LICENSE
... ... @@ -0,0 +1 @@
  1 +Copyright (c) Small Batch Inc
129 Rakefile
... ... @@ -0,0 +1,129 @@
  1 +require 'rubygems'
  2 +require 'rake'
  3 +require 'date'
  4 +
  5 +#############################################################################
  6 +#
  7 +# Helper functions
  8 +#
  9 +#############################################################################
  10 +
  11 +def name
  12 + @name ||= Dir['*.gemspec'].first.split('.').first
  13 +end
  14 +
  15 +def version
  16 + line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
  17 + line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
  18 +end
  19 +
  20 +def date
  21 + Date.today.to_s
  22 +end
  23 +
  24 +def rubyforge_project
  25 + name
  26 +end
  27 +
  28 +def gemspec_file
  29 + "#{name}.gemspec"
  30 +end
  31 +
  32 +def gem_file
  33 + "#{name}-#{version}.gem"
  34 +end
  35 +
  36 +def replace_header(head, header_name)
  37 + head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
  38 +end
  39 +
  40 +#############################################################################
  41 +#
  42 +# Standard tasks
  43 +#
  44 +#############################################################################
  45 +
  46 +task :default => :test
  47 +
  48 +require 'rake/testtask'
  49 +Rake::TestTask.new(:test) do |test|
  50 + test.libs << 'lib' << 'test'
  51 + test.pattern = 'test/**/*_test.rb'
  52 + test.verbose = true
  53 +end
  54 +
  55 +desc "Open an irb session preloaded with this library"
  56 +task :console do
  57 + sh "irb -rubygems -r ./lib/#{name}.rb"
  58 +end
  59 +
  60 +#############################################################################
  61 +#
  62 +# Custom tasks (add your own tasks here)
  63 +#
  64 +#############################################################################
  65 +
  66 +
  67 +
  68 +#############################################################################
  69 +#
  70 +# Packaging tasks
  71 +#
  72 +#############################################################################
  73 +
  74 +task :release => :build do
  75 + unless `git branch` =~ /^\* master$/
  76 + puts "You must be on the master branch to release!"
  77 + exit!
  78 + end
  79 + sh "git commit --allow-empty -a -m 'Release #{version}'"
  80 + sh "git tag v#{version}"
  81 + sh "git push --tags origin master"
  82 + sh "gem push pkg/#{name}-#{version}.gem"
  83 +end
  84 +
  85 +task :build => :gemspec do
  86 + sh "mkdir -p pkg"
  87 + sh "gem build #{gemspec_file}"
  88 + sh "mv #{gem_file} pkg"
  89 +end
  90 +
  91 +task :gemspec => :validate do
  92 + # read spec file and split out manifest section
  93 + spec = File.read(gemspec_file)
  94 + head, manifest, tail = spec.split(" # = MANIFEST =\n")
  95 +
  96 + # replace name version and date
  97 + replace_header(head, :name)
  98 + replace_header(head, :version)
  99 + replace_header(head, :date)
  100 + #comment this out if your rubyforge_project has a different name
  101 + replace_header(head, :rubyforge_project)
  102 +
  103 + # determine file list from git ls-files
  104 + files = `git ls-files`.
  105 + split("\n").
  106 + sort.
  107 + reject { |file| file =~ /^\./ }.
  108 + reject { |file| file =~ /^(rdoc|pkg)/ }.
  109 + map { |file| " #{file.gsub(/\s/, '\ ')}" }.
  110 + join("\n")
  111 +
  112 + # piece file back together and write
  113 + manifest = " s.files = %w[\n#{files}\n ]\n"
  114 + spec = [head, manifest, tail].join(" # = MANIFEST =\n")
  115 + File.open(gemspec_file, 'w') { |io| io.write(spec) }
  116 + puts "Updated #{gemspec_file}"
  117 +end
  118 +
  119 +task :validate do
  120 + libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
  121 + unless libfiles.empty?
  122 + puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
  123 + exit!
  124 + end
  125 + unless Dir['VERSION*'].empty?
  126 + puts "A `VERSION` file at root level violates Gem best practices."
  127 + exit!
  128 + end
  129 +end
64 fontvariationdescription.gemspec
... ... @@ -0,0 +1,64 @@
  1 +## This is the rakegem gemspec template. Make sure you read and understand
  2 +## all of the comments. Some sections require modification, and others can
  3 +## be deleted if you don't need them. Once you understand the contents of
  4 +## this file, feel free to delete any comments that begin with two hash marks.
  5 +## You can find comprehensive Gem::Specification documentation, at
  6 +## http://docs.rubygems.org/read/chapter/20
  7 +Gem::Specification.new do |s|
  8 + s.specification_version = 2 if s.respond_to? :specification_version=
  9 + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  10 + s.rubygems_version = '1.3.5'
  11 +
  12 + ## Leave these as is they will be modified for you by the rake gemspec task.
  13 + ## If your rubyforge_project name is different, then edit it and comment out
  14 + ## the sub! line in the Rakefile
  15 + s.name = 'fontvariationdescription'
  16 + s.version = '0.9.0'
  17 + s.date = '2010-05-17'
  18 + s.rubyforge_project = 'fontvariationdescription'
  19 +
  20 + ## Make sure your summary is short. The description may be as long
  21 + ## as you like.
  22 + s.summary = "Unambiguously, compactly and clearly describe font in CSS"
  23 + s.description = <<END
  24 +Font Variation Description addresses the need to describe a font in CSS by
  25 +way of its font descriptions such as font-style and font-weight.
  26 +END
  27 +
  28 + ## List the primary authors. If there are a bunch of authors, it's probably
  29 + ## better to set the email to an email list or something. If you don't have
  30 + ## a custom homepage, consider using your GitHub URL or the like.
  31 + s.authors = ["Ryan Carver"]
  32 + s.email = 'ryan@typekit.com'
  33 + s.homepage = 'http://github.com/typekit/fontvariationdescription'
  34 +
  35 + ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
  36 + ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
  37 + s.require_paths = %w[lib]
  38 +
  39 + ## Specify any RDoc options here. You'll want to add your README and
  40 + ## LICENSE files to the extra_rdoc_files list.
  41 + s.rdoc_options = ["--charset=UTF-8"]
  42 + s.extra_rdoc_files = %w[README.md LICENSE]
  43 +
  44 + ## Leave this section as-is. It will be automatically generated from the
  45 + ## contents of your Git repository via the gemspec task. DO NOT REMOVE
  46 + ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
  47 + # = MANIFEST =
  48 + s.files = %w[
  49 + README.md
  50 + compact.yml
  51 + expand.yml
  52 + lib/fontvariationdescription.rb
  53 + lib/fontvariationdescription/compactor.rb
  54 + lib/fontvariationdescription/expander.rb
  55 + test/compactor_test.rb
  56 + test/expander_test.rb
  57 + test/test_helper.rb
  58 + ]
  59 + # = MANIFEST =
  60 +
  61 + ## Test files will be grabbed from the file list. Make sure the path glob
  62 + ## matches what you actually use.
  63 + s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
  64 +end

0 comments on commit 7bbce76

Please sign in to comment.
Something went wrong with that request. Please try again.