Class: MetaProject::Project::XForge::XFile
- Inherits:
-
Object
- Object
- MetaProject::Project::XForge::XFile
- Defined in:
- lib/meta_project/project/xforge/xfile.rb
Overview
:nodoc:
Constant Summary collapse
- FILE_TYPES =
extension => [mime_type, rubyforge_bin_type_id, rubyforge_src_type_id]
{ ".deb" => ["application/octet-stream", 1000], # all of these can be source or binary ".rpm" => ["application/octet-stream", 2000, 5100], ".zip" => ["application/octet-stream", 3000, 5000], ".bz2" => ["application/octet-stream", 3100, 5010], ".gz" => ["application/octet-stream", 3110, 5020], ".jpg" => ["application/octet-stream", 8000], ".jpeg" => ["application/octet-stream", 8000], ".txt" => ["text/plain", 8100, 8100], ".html" => ["text/html", 8200, 8200], ".pdf" => ["application/octet-stream", 8300], ".ebuild" => ["application/octet-stream", 1300], ".exe" => ["application/octet-stream", 1100], ".dmg" => ["application/octet-stream", 1200], ".gem" => ["application/octet-stream", 1400], ".sig" => ["application/octet-stream", 8150] }
Instance Attribute Summary collapse
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#bin_type_id ⇒ Object
readonly
Returns the value of attribute bin_type_id.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#src_type_id ⇒ Object
readonly
Returns the value of attribute src_type_id.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(filename) ⇒ XFile
constructor
A new instance of XFile.
Constructor Details
#initialize(filename) ⇒ XFile
Returns a new instance of XFile.
31 32 33 34 35 36 37 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 31 def initialize(filename) @filename = filename @basename = File.basename(filename) @ext = File.extname(filename) @content_type = FILE_TYPES[@ext][0] @bin_type_id = FILE_TYPES[@ext][1] end |
Instance Attribute Details
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
29 30 31 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 29 def basename @basename end |
#bin_type_id ⇒ Object (readonly)
Returns the value of attribute bin_type_id.
29 30 31 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 29 def bin_type_id @bin_type_id end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
29 30 31 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 29 def content_type @content_type end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
29 30 31 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 29 def ext @ext end |
#src_type_id ⇒ Object (readonly)
Returns the value of attribute src_type_id.
29 30 31 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 29 def src_type_id @src_type_id end |
Instance Method Details
#data ⇒ Object
39 40 41 |
# File 'lib/meta_project/project/xforge/xfile.rb', line 39 def data File.open(@filename, "rb") { |file| file.read } end |