Module: GuardHelpers::BasicHelper::ClassMethods
- Defined in:
- lib/guard_helpers/basic_helper.rb
Instance Method Summary collapse
- #bash_build ⇒ Object
- #create_open_file(dir, ext = "rb") ⇒ Object
- #file_read(file) ⇒ Object
- #file_write(file, ctn) ⇒ Object
- #guard_reset ⇒ Object
- #notify(msg, image = "success") ⇒ Object
- #require_include_all_guard_helpers(guardfile_path) ⇒ Object
- #write_bashrc ⇒ Object
Instance Method Details
#bash_build ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/guard_helpers/basic_helper.rb', line 113 def bash_build notify "bash build" BashBuilder.build write_bashrc Out.out "rake install file:#{::File.basename __FILE__} line:#{__LINE__}", "green" unless ::RoFile.change_recently?("pkg", 3) bashs "rake install" end end |
#create_open_file(dir, ext = "rb") ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/guard_helpers/basic_helper.rb', line 76 def create_open_file(dir, ext="rb") ::Pry::Commands.pry_cmd dir, "create a #{dir}/(.+).#{ext}" do |name| file = File.join(dir, "#{name}.#{ext}") #Out.out "Dir.pwd:#{Dir.pwd} ","","file:#{File.basename __FILE__} line:#{__LINE__}", "green" unless File.exist?(file) dirname = File.dirname(file) FileUtils.mkpath dirname FileUtils.touch(file) FileUtils.chmod(755, file) end bash "#{::RoDefault.editor} #{file}" end end |
#file_read(file) ⇒ Object
94 95 96 97 |
# File 'lib/guard_helpers/basic_helper.rb', line 94 def file_read(file) File.read(file) notify "read #{file}" end |
#file_write(file, ctn) ⇒ Object
99 100 101 102 103 |
# File 'lib/guard_helpers/basic_helper.rb', line 99 def file_write (file, ctn) File.write(file, ctn) notify "writing #{file} success" end |
#guard_reset ⇒ Object
90 91 92 |
# File 'lib/guard_helpers/basic_helper.rb', line 90 def guard_reset Kernel.system "bundle exec guard " end |
#notify(msg, image = "success") ⇒ Object
125 126 127 128 |
# File 'lib/guard_helpers/basic_helper.rb', line 125 def notify(msg, image="success") Out.out msg ::Guard::Notifier.notify msg, image: image end |
#require_include_all_guard_helpers(guardfile_path) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/guard_helpers/basic_helper.rb', line 66 def require_include_all_guard_helpers(guardfile_path) paths = File.('../lib/guard_helpers/**', guardfile_path) Dir[paths].each do |path| require path guard_helper_module_name = File.basename(path).gsub(%r{\.\w+$}, "").camelize guard_helper_module = ::GuardHelpers.const_get(:"#{guard_helper_module_name}") self.send(:include, guard_helper_module) end end |