Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
fix broke features
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Sep 21, 2012
1 parent fcbd9e9 commit 4dffaa2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
10 changes: 3 additions & 7 deletions ruby-tools/jpi/features/create-new-plugin.feature
@@ -1,18 +1,14 @@

Feature: Generating a new Jenkins Ruby Plugin

Creating a new Ruby plugin for Jenkins needs to be as simple as running a single command
that will generate a project skeleton. This skeleton will come complete with git repository and all
the goodies that you need to do your plugin develompent.

Scenario: The directory skeleton is generated
When I run `jpi new cuke-plugin`
When I run `jpi new cuke`
Then I should see this structure
"""
[-] cuke-plugin
| [+] .git
| .gitignore
| Gemfile
| Rakefile
| cuke-plugin.pluginspec
| Gemfile
| cuke.pluginspec
"""
38 changes: 20 additions & 18 deletions ruby-tools/jpi/features/support/directory_structure.rb
@@ -1,24 +1,25 @@

class DirectoryStructure
def initialize(structure)

@root = context = DirChild.new('.')
context = DirChild.new('.')

structure.each_line do |line|
if line =~ /(\[[-+]\]|\|)?\s+(\.?\w+)$/
if line =~ /^(\[\-+\]|\ \|\ )\s+(.+)$/
op, name = $1, $2
case op
when "[+]"
context.add(DirChild.new name)
when "[-]"
new_context = DirChild.new name
context.add(new_context)
context = new_context
when "|"
context.add(FileChild.new name)
end
child = case op
when "[+]"
DirChild.new name
when "[-]"
# TODO: make to tree structure
DirChild.new name
when " | "
FileChild.new name
end
context.add child
end
end

@root = context
end

def matches?(dir)
Expand All @@ -28,22 +29,23 @@ def matches?(dir)
Entry = Struct.new(:name)

class DirChild < Entry
attr_accessor :entries

def initialize(name)
super(name)
@entries = []
end

def add(entry)
@entries << entries
@entries << entry
end

def matches?(realdir)
entries = Dir.new(realdir).entries
!@entries.detect {|e| !entries.map{|e| File.basename(e)}.member?(e)}
real_entries = Dir.glob(realdir + '/**/*').map{|e| File.basename(e) }
(@entries.map(&:name) <=> real_entries) < 1
end
end

class FileChild < Entry

end
end
end
1 change: 0 additions & 1 deletion ruby-tools/jpi/features/support/workdir.rb
Expand Up @@ -11,4 +11,3 @@ def work_dir
FileUtils.mkdir_p work_dir
@dirs = [work_dir]
end

0 comments on commit 4dffaa2

Please sign in to comment.