Module: DragonrubyEgg::Executable
- Defined in:
- lib/dragonruby_egg/executable.rb
Class Method Summary collapse
- .docs ⇒ Object
- .dragonruby(arg) ⇒ Object
- .egg ⇒ Object
- .find_root_path(root = '/') ⇒ Object
- .install(repo_module, path) ⇒ Object
- .new_project(name, path) ⇒ Object
- .root_path?(path) ⇒ Boolean
- .web_brower ⇒ Object
Class Method Details
.docs ⇒ Object
45 46 47 48 49 |
# File 'lib/dragonruby_egg/executable.rb', line 45 def docs root_path = Event::emit(:root_path) doc_file = File.join(root_path, Constants::DR_DOCS) system("#{web_brower} #{doc_file} &") end |
.dragonruby(arg) ⇒ Object
39 40 41 42 43 |
# File 'lib/dragonruby_egg/executable.rb', line 39 def dragonruby arg root_path = Event::emit(:root_path) path = File.join(root_path, Constants::DR_EXES[:dr]) system("#{path} #{arg}") end |
.egg ⇒ Object
51 52 53 54 |
# File 'lib/dragonruby_egg/executable.rb', line 51 def egg root_path = Event::emit(:root_path) system("#{web_brower} #{Constants::DRE_URL} &") end |
.find_root_path(root = '/') ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dragonruby_egg/executable.rb', line 17 def find_root_path(root = '/') paths = Dir.glob( "#{root}/**/#{Constants::DR_EXES[:dr]}", File::FNM_DOTMATCH ) paths.each do |path| if File.exist?(path) r_path = File.dirname(path) if root_path?(r_path) return r_path end end end return nil end |
.install(repo_module, path) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/dragonruby_egg/executable.rb', line 56 def install repo_module, path module_url = Modules.get_module_url(repo_module) unless module_url return end module_path = "#{path}/modules/#{repo_module}" is_install = system("git clone --recurse-submodules #{module_url}.git '#{module_path}'") if is_install Event.print('INSTALL', "The '#{repo_module}' module " + "has been installed in this '.#{module_path.sub(path, '')}' folder.") end IO.change_paths(module_path, repo_module) Event.print('INSTALL', "All paths for this '#{repo_module}' module have been changed.") end |
.new_project(name, path) ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/dragonruby_egg/executable.rb', line 73 def new_project name, path root_path = Event::emit(:root_path) unless path path = Dir.pwd end is_copy = system("cp -r '#{root_path}/mygame' '#{path}/#{name}'") if is_copy Event.print('NEW', "The '#{name}' project has been created.") end end |
.root_path?(path) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dragonruby_egg/executable.rb', line 5 def root_path? path exes = Constants::DR_EXES.map { |_,v| File.join(path, v) } exes.each do |exe| is_existing = File.exist?(exe) && File.executable?(exe) unless is_existing return false end end return true end |
.web_brower ⇒ Object
34 35 36 37 |
# File 'lib/dragonruby_egg/executable.rb', line 34 def web_brower %x(xdg-settings get default-web-browser) .sub(/\..*$/, '').rstrip end |