thor_tasks 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/tasks/spec.thor CHANGED
@@ -1,6 +1,8 @@
1
1
  class Spec < Thor
2
2
  include Thor::Actions
3
3
 
4
+ AVAILABLE_TYPES = ['controllers', 'helpers', 'models', 'requests', 'routing', 'views']
5
+
4
6
  desc "all", "runs all your specs"
5
7
  method_option :bundle, :type => :boolean, :aliases => "-b"
6
8
  def all
@@ -53,30 +55,29 @@ class Spec < Thor
53
55
  desc "list [TYPE}]", "lists specs for TYPE, see thor spec:list --help for more info."
54
56
  method_options :help => false
55
57
  def list(name = "*")
56
- available_types = [
57
- 'controllers', 'helpers', 'models', 'requests', 'routing', 'views'
58
- ]
59
58
  if options[:help]
60
59
  puts "Available types for thor spec:list are"
61
- available_types.each do |t|
60
+ AVAILABLE_TYPES.each do |t|
62
61
  puts " #{t}"
63
62
  end
64
63
  puts "Running thor spec:list without specifying a type will list all specs from all types."
65
64
  return
66
65
  end
67
66
 
68
- lastType = ""
69
- currentType = ""
70
- Dir["spec/#{name}/*_spec.rb"].each do |f|
71
- spec = File.basename(f, "_spec.rb")
72
- dir = File.dirname(f).split("/")
73
- currentType = dir[dir.length-1]
74
- spec = spec.rpartition("_")[0] if ['controllers', 'helpers', 'routing'].include? currentType
75
- if currentType != lastType
76
- print "\n\x1b[38;5;10m#{currentType}\x1b[0m\n"
77
- lastType = currentType
67
+ paths = Dir["spec/#{name}/**/"].sort.reject { |p| p if !AVAILABLE_TYPES.include?(p.split("/")[1]) }
68
+ paths.each do |p|
69
+ path = p.split("/")
70
+ l = path.length
71
+ # the following prints an indented path in a color that is relative to the
72
+ # levels of indentation
73
+ print "#{' ' * (l-2)}\x1b[38;5;1#{l-1}m#{path[l-1]}\x1b[0m\n"
74
+ files = Dir["#{p}*_spec.rb"].sort
75
+ files.each do |f|
76
+ spec = File.basename(f, "_spec.rb")
77
+ spec = spec.rpartition("_")[0] if ['controllers', 'helpers', 'routing'].include? path[1]
78
+ print "#{' ' * (l-1)}#{spec}\n" # prints the spec with indentation
78
79
  end
79
- puts " #{spec}"
80
+ print "\n" unless files.length == 0
80
81
  end
81
82
  end
82
83
  end
@@ -1,3 +1,3 @@
1
1
  module ThorTasks
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Haynes