public
Description: Merb Plugins: Even more modules to hook up your Merb installation
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-plugins.git
merb-plugins / merb_stories / rspec_generators / story / story_generator.rb
d117d44f » benburkert 2008-02-13 including hassox's changes ... 1 class StoryGenerator < Merb::GeneratorBase
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 2
d117d44f » benburkert 2008-02-13 including hassox's changes ... 3 attr_reader :story_name, :story_path, :step_name, :path_levels, :full_story_path
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 4
5 def initialize(runtime_args, runtime_options = {})
d117d44f » benburkert 2008-02-13 including hassox's changes ... 6 @base = File.dirname(__FILE__)
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 7 super
d117d44f » benburkert 2008-02-13 including hassox's changes ... 8 name = runtime_args.shift.split "/"
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 9 @story_name = name.pop
10 @story_path = name.empty? ? nil : name.join("/")
11 @step_name = @story_path.nil? ? @story_name : (@story_path.gsub("/", "_") + "_" + @story_name)
12 @path_levels = @story_path.nil? ? 0 : @story_path.split("/").size
d117d44f » benburkert 2008-02-13 including hassox's changes ... 13 @full_story_path = @story_path.nil? ? @story_name : File.join(@story_path, @story_name)
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 14 end
15
16 def manifest
17 record do |m|
d117d44f » benburkert 2008-02-13 including hassox's changes ... 18 @m = m
19 @assigns = {
20 :story_name => self.story_name,
21 :story_path => self.story_path,
22 :step_name => self.step_name,
23 :path_levels => self.path_levels,
24 :full_story_path => self.full_story_path
25 }
26
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 27 if( !File.exists?('stories/stories/all.rb') ) # So it doesn't get destroyed when you do a destroy script
d117d44f » benburkert 2008-02-13 including hassox's changes ... 28 m.dependency "merb_story_setup", [""]
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 29 end
d117d44f » benburkert 2008-02-13 including hassox's changes ... 30
2fc4927f » benburkert 2008-02-13 [merb_rspec] Fix for simple... 31 m.directory File.join("stories", "stories", self.story_path) unless self.story_path.nil?
d117d44f » benburkert 2008-02-13 including hassox's changes ... 32
33 copy_dirs
34 copy_files
35
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 36 end
37 end
38
39 protected
40 def banner
41 <<-EOS
42 Creates a stub for a rSpec text story spec in merb.
43
44 USAGE: #{$0} #{spec.name} my_story"
45
46 EXAMPLE:
47 #{$0} #{spec.name} my_story
48 #{$0} #{spec.name} story_group/specific_story
49 EOS
d117d44f » benburkert 2008-02-13 including hassox's changes ... 50 end
41d0db49 » benburkert 2008-02-12 readded rspec_generators fo... 51 end