File: Guardfile

package info (click to toggle)
ruby-oembed 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 3,468 kB
  • sloc: ruby: 2,351; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
guard "bundler" do
  watch("Gemfile")
end

group :red_green_refactor, :halt_on_fail => true do
  guard "rspec", :cmd => "bundle exec rspec" do
    watch(%r{^spec/.+_spec\.rb$})
    watch(%r{^spec/cassettes/.+.yml$}) { "spec" }
    watch(%r{^lib/(.+)\.rb$}) do |m|
      # Split up the file path into an Array
      path_parts = []
      remaining_path = m[1]
      while File.dirname(remaining_path) != '.'
        remaining_path, file = File.split(remaining_path)
        path_parts << file
      end
      path_parts << remaining_path
      path_parts.reverse!

      # Specs don't contain an oembed subdir
      path_parts.shift
      # Special case for formatter specs
      if path_parts.include?('formatter') && path_parts.include?('backends')
        path_parts.delete('backends')
        path_parts.last.gsub!(/$/, "_backend")
      end
      # Add on the _spec.rb postfix
      path_parts.last.gsub!(/$/, "_spec.rb")

      f = File.join("spec", *path_parts)
      puts "#{m.inspect} => #{f.inspect}"
      f
    end
  end
end