Class: Rrr::Run
- Inherits:
-
Object
- Object
- Rrr::Run
- Defined in:
- lib/cli.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
readonly
Returns the value of attribute datetime.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #collection ⇒ Object
- #init ⇒ Object
-
#initialize(files) ⇒ Run
constructor
A new instance of Run.
- #list ⇒ Object
- #rspec ⇒ Object
- #run ⇒ Object
- #touch ⇒ Object
Constructor Details
#initialize(files) ⇒ Run
Returns a new instance of Run.
11 12 13 14 |
# File 'lib/cli.rb', line 11 def initialize(files) @files = files init && touch && run end |
Instance Attribute Details
#datetime ⇒ Object (readonly)
Returns the value of attribute datetime.
9 10 11 |
# File 'lib/cli.rb', line 9 def datetime @datetime end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
9 10 11 |
# File 'lib/cli.rb', line 9 def files @files end |
Instance Method Details
#collection ⇒ Object
46 47 48 49 50 |
# File 'lib/cli.rb', line 46 def collection @collection ||= begin files.empty? ? list : files end end |
#init ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cli.rb', line 16 def init @datetime = begin Time.parse(File.open('.rrr', 'r').read) rescue Time.now end end |
#list ⇒ Object
30 31 32 33 |
# File 'lib/cli.rb', line 30 def list file_list = FileList.new('spec/**/*_spec.rb') file_list.select{|file| File.ctime(file) > datetime} end |
#rspec ⇒ Object
52 53 54 |
# File 'lib/cli.rb', line 52 def rspec "rspec" end |
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cli.rb', line 35 def run if collection.empty? puts "INFO: no recent changes in specs ... running all specs\nINFO: #{rspec}" command = rspec else command = "#{rspec} #{collection.join(' ')}" puts "rrr: #{command}" end system(command) end |
#touch ⇒ Object
24 25 26 27 28 |
# File 'lib/cli.rb', line 24 def touch File.open('.rrr', 'w') do |file| file.write(Time.now) end end |