From 3a7848da9e9ce9acfd59b36fe47e1bce841a3161 Mon Sep 17 00:00:00 2001 From: Alexey Pokhozhaev Date: Fri, 2 Oct 2015 15:12:13 +0300 Subject: [PATCH] Little bit cleaned up. Dry in rake tasks. Fix $LOAD_PATH --- Gemfile | 2 +- Rakefile | 31 +++++++++---------------- middleman-core/.gemtest | 0 middleman-core/.rspec | 1 - middleman-core/Rakefile | 7 +----- middleman-core/lib/middleman-core.rb | 4 ---- middleman-core/middleman-core.gemspec | 6 +++-- middleman/.gemtest | 0 middleman/Rakefile | 6 +---- middleman/features/.gitkeep | 0 middleman/fixtures/.gitkeep | 0 middleman/middleman.gemspec | 8 +++---- middleman/spec/middleman/future_spec.rb | 0 middleman/spec/spec_helper.rb | 0 14 files changed, 22 insertions(+), 43 deletions(-) delete mode 100644 middleman-core/.gemtest delete mode 100644 middleman-core/.rspec delete mode 100644 middleman/.gemtest delete mode 100644 middleman/features/.gitkeep delete mode 100644 middleman/fixtures/.gitkeep delete mode 100644 middleman/spec/middleman/future_spec.rb delete mode 100644 middleman/spec/spec_helper.rb diff --git a/Gemfile b/Gemfile index 08de2a54..2c8a8e9e 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,6 @@ gem 'simplecov', '~> 0.10', require: false gem 'coveralls', '~> 0.8', require: false # Middleman itself -gem 'middleman', path: 'middleman' gem 'middleman-core', path: 'middleman-core' +gem 'middleman', path: 'middleman' gem 'middleman-sprockets', github: 'middleman/middleman-sprockets', branch: 'v3-stable-real' diff --git a/Rakefile b/Rakefile index 78c26691..89546ff3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,17 +1,17 @@ require 'rake' -require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__) - -ROOT = File.expand_path(File.dirname(__FILE__)) -GEM_NAME = 'middleman' - -middleman_gems = %w(middleman-core middleman) -GEM_PATHS = middleman_gems.freeze +require 'middleman-core/version' def sh_rake(command) sh "#{Gem.ruby} -S rake #{command}", verbose: true end +def within_each_gem(&block) + %w(middleman-core middleman).each do |dir| + Dir.chdir(dir) { block.call } + end +end + desc 'Displays the current version' task :version do puts "Current version: #{Middleman::VERSION}" @@ -28,32 +28,23 @@ end desc 'Release all middleman gems' task publish: :push do puts 'Pushing to rubygems...' - GEM_PATHS.each do |dir| - Dir.chdir(dir) { sh_rake('release') } - end + within_each_gem { sh_rake('release') } end desc 'Generate documentation for all middleman gems' task :doc do - GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" } - end + within_each_gem { sh_rake('yard') } end desc 'Run tests for all middleman gems' task :test do Rake::Task['rubocop'].invoke - - GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" } - end + within_each_gem { sh_rake('test') } end desc 'Run specs for all middleman gems' task :spec do - GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake spec" } - end + within_each_gem { sh_rake('spec') } end require 'rubocop/rake_task' diff --git a/middleman-core/.gemtest b/middleman-core/.gemtest deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/.rspec b/middleman-core/.rspec deleted file mode 100644 index 4e1e0d2f..00000000 --- a/middleman-core/.rspec +++ /dev/null @@ -1 +0,0 @@ ---color diff --git a/middleman-core/Rakefile b/middleman-core/Rakefile index 5cbeb120..a093ee44 100644 --- a/middleman-core/Rakefile +++ b/middleman-core/Rakefile @@ -1,6 +1 @@ -# coding:utf-8 -RAKE_ROOT = __FILE__ - -GEM_NAME = ENV['NAME'] || 'middleman-core' - -require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') +require_relative '../gem_rake_helper' diff --git a/middleman-core/lib/middleman-core.rb b/middleman-core/lib/middleman-core.rb index 8170fefb..5a1e7294 100644 --- a/middleman-core/lib/middleman-core.rb +++ b/middleman-core/lib/middleman-core.rb @@ -1,9 +1,5 @@ # rubocop:disable FileName -# Setup our load paths -libdir = File.expand_path(File.dirname(__FILE__)) -$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) - # Top-level Middleman namespace module Middleman # Backwards compatibility namespace diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 844e6de9..7c5d6d0b 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -1,5 +1,7 @@ -# -*- encoding: utf-8 -*- -require File.expand_path("../lib/middleman-core/version", __FILE__) +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +require "middleman-core/version" Gem::Specification.new do |s| s.name = "middleman-core" diff --git a/middleman/.gemtest b/middleman/.gemtest deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman/Rakefile b/middleman/Rakefile index 120b9c7c..a093ee44 100644 --- a/middleman/Rakefile +++ b/middleman/Rakefile @@ -1,5 +1 @@ -# coding:utf-8 -RAKE_ROOT = __FILE__ - -GEM_NAME = 'middleman' -require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') +require_relative '../gem_rake_helper' diff --git a/middleman/features/.gitkeep b/middleman/features/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman/fixtures/.gitkeep b/middleman/fixtures/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 11e4e871..b34ebfbb 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -1,6 +1,7 @@ -# -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +require "middleman-core/version" Gem::Specification.new do |s| s.name = "middleman" @@ -14,7 +15,6 @@ Gem::Specification.new do |s| s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." s.files = `git ls-files -z`.split("\0") - s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") s.require_paths = ["lib"] s.required_ruby_version = '>= 1.9.3' diff --git a/middleman/spec/middleman/future_spec.rb b/middleman/spec/middleman/future_spec.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman/spec/spec_helper.rb b/middleman/spec/spec_helper.rb deleted file mode 100644 index e69de29b..00000000