Module: RoSupport::RoGuard
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ro_support/ro_guard.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.def_meth(name, &blk) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ro_support/ro_guard.rb', line 13 def def_meth(name, &blk) define_method(:"#{name}") do |*args| blk.call *args end define_singleton_method(:"#{name}") do |*args| blk.call *args end Pry::Command.send :define_method, :"#{name}" do |*args| blk.call *args end end |
Instance Method Details
#handle(file, &blk) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/ro_support/ro_guard.rb', line 97 def handle(file, &blk) #puts "Handling #{paths.flatten}" r = paths.flatten.grep /#{file}$/ unless r.empty? r.each do |*args| blk.call *args end end end |
#paths ⇒ Object
86 87 88 89 90 |
# File 'lib/ro_support/ro_guard.rb', line 86 def paths @paths.flatten! if @paths.respond_to?(:flatten!) @paths.uniq! if @paths.respond_to?(:uniq!) @paths ||= [] end |
#run_on_modifications(paths) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ro_support/ro_guard.rb', line 50 def run_on_modifications(paths) super if defined? super @paths = paths Out.out "paths:#{paths} file:#{File.basename __FILE__} line:#{__LINE__}", "green" handle(%r{Guardfile|(^lib/guard_helpers/(.+)\.rb)}) do guard_reset end handle(%r{README.md.erb}) do ctn = File.read("README.md.erb") result = ERB.new(ctn).result(binding) Out.out("writting README.md") File.write("README.md", result) end unless Dir['**'].grep(%r{(.+)\.gemspec}).empty? bash "rake install" end end |
#start ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ro_support/ro_guard.rb', line 38 def start super if defined? super commands = Pry::CommandSet.new do block_command "install" do |*args| system "rake install" output.out "nimabi" end end Pry::Commands.import commands end |