Class: Gitrob::Models::Blob
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Gitrob::Models::Blob
- Defined in:
- lib/gitrob/models/blob.rb
Constant Summary collapse
- SHA_REGEX =
/[a-f0-9]{40}/
- TEST_BLOB_INDICATORS =
%w(test spec fixture mock stub fake demo sample)
- LARGE_BLOB_THRESHOLD =
102_400
Instance Method Summary collapse
- #extension ⇒ Object
- #filename ⇒ Object
- #history_html_url ⇒ Object
- #html_url ⇒ Object
- #large? ⇒ Boolean
- #test_blob? ⇒ Boolean
- #validate ⇒ Object
Instance Method Details
#extension ⇒ Object
26 27 28 |
# File 'lib/gitrob/models/blob.rb', line 26 def extension File.extname(path)[1..-1] end |
#filename ⇒ Object
22 23 24 |
# File 'lib/gitrob/models/blob.rb', line 22 def filename File.basename(path) end |
#history_html_url ⇒ Object
41 42 43 |
# File 'lib/gitrob/models/blob.rb', line 41 def history_html_url "#{repository.html_url}/commits/#{repository.default_branch}/#{path}" end |
#html_url ⇒ Object
37 38 39 |
# File 'lib/gitrob/models/blob.rb', line 37 def html_url "#{repository.html_url}/blob/#{repository.default_branch}/#{path}" end |
#large? ⇒ Boolean
45 46 47 |
# File 'lib/gitrob/models/blob.rb', line 45 def large? size.to_i > LARGE_BLOB_THRESHOLD end |
#test_blob? ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/gitrob/models/blob.rb', line 30 def test_blob? TEST_BLOB_INDICATORS.each do |indicator| return true if path.downcase.include?(indicator) end false end |
#validate ⇒ Object
16 17 18 19 20 |
# File 'lib/gitrob/models/blob.rb', line 16 def validate super validates_presence [:path, :size, :sha] validates_format SHA_REGEX, :sha end |