Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Rename Ruby project to Rubygem, make Bundler mutator.
Browse files Browse the repository at this point in the history
Among other things, this removes some more boilterplate in the
Shantyfile by discovering things when we can.
  • Loading branch information
nathankleyn committed Jan 20, 2015
1 parent ac9436f commit 2b9db68
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
8 changes: 0 additions & 8 deletions Shantyfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
# FIXME: This shouldn't need to be required, can be auto-discovered.
require 'shanty/projects/ruby'
require 'shanty/plugins/bundler'
require 'shanty/plugins/rspec'
require 'shanty/plugins/rubocop'

type RubyProject
plugin ::Shanty::BundlerPlugin
plugin ::Shanty::RspecPlugin
plugin ::Shanty::RubocopPlugin
4 changes: 4 additions & 0 deletions lib/shanty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

require 'shanty/cli'
require 'shanty/discoverers/shantyfile'
require 'shanty/discoverers/rubygem'
require 'shanty/graph'
require 'shanty/mutators/bundler'
require 'shanty/mutators/git'
require 'shanty/plugins/rspec'
require 'shanty/plugins/rubocop'
require 'shanty/task_env'
require 'shanty/task_sets/basic'

Expand Down
17 changes: 17 additions & 0 deletions lib/shanty/discoverers/rubygem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'shanty/discoverer'
require 'shanty/projects/rubygem'

module Shanty
# Public: Discoverer for Shantyfiles
# will create a a project for every Shantyfile it finds in
# a directory
class RubygemDiscoverer < Discoverer
def discover
Dir['**/*.gemspec'].map do |path|
create_project_template(File.absolute_path(File.dirname(path))) do |project_template|
project_template.type = RubygemProject
end
end
end
end
end
13 changes: 13 additions & 0 deletions lib/shanty/mutators/bundler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'shanty/mutator'
require 'shanty/plugins/bundler'

module Shanty
# Bundler mutator
class BundlerMutator < Mutator
def mutate(graph)
graph.each do |project|
BundlerPlugin.add_to_project(project) if File.exist?(File.join(project.path, 'Gemfile'))
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Shanty
# Public: Represents a projects created with the Ruby language.
class RubyProject < Project
class RubygemProject < Project
subscribe :build, :on_build

def on_build
Expand Down

0 comments on commit 2b9db68

Please sign in to comment.