Module: Rascut::Utils
- Included in:
- Asdoc::Generator, Asdoc::Httpd, Command, Httpd
- Defined in:
- lib/rascut/utils.rb
Defined Under Namespace
Classes: ProcHandler
Class Method Summary collapse
- .asdoc_home ⇒ Object
- .home ⇒ Object
- .path_escape(name) ⇒ Object
- .rascut_db(readonly = false) ⇒ Object
- .rascut_db_path ⇒ Object
- .rascut_db_read(&block) ⇒ Object
Class Method Details
.asdoc_home ⇒ Object
25 26 27 28 29 |
# File 'lib/rascut/utils.rb', line 25 def asdoc_home path = home.join('asdoc') path.mkpath path end |
.home ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rascut/utils.rb', line 9 def home if ENV['HOME'] home = Pathname.new ENV['HOME'] elsif ENV['USERPROFILE'] # win32 home = Pathname.new ENV['USERPROFILE'] else raise 'HOME dir not found.' end home = home.join('.rascut') home.mkpath home end |
.path_escape(name) ⇒ Object
50 51 52 |
# File 'lib/rascut/utils.rb', line 50 def path_escape(name) URI.encode(name.to_s.gsub('/', '_'), /[^\w_\-]/) end |
.rascut_db(readonly = false) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rascut/utils.rb', line 37 def rascut_db(readonly = false) db = PStore.new home.join('rascut.db').to_s db.transaction(readonly) do yield db end end |
.rascut_db_path ⇒ Object
32 33 34 |
# File 'lib/rascut/utils.rb', line 32 def rascut_db_path home.join('rascut.db') end |
.rascut_db_read(&block) ⇒ Object
45 46 47 |
# File 'lib/rascut/utils.rb', line 45 def rascut_db_read(&block) rascut_db(true, &block) end |