Module: Contrast::Api::Decorators::Library::ClassMethods
- Defined in:
- lib/contrast/api/decorators/library.rb
Overview
Used to add class methods to the Library class on inclusion of the decorator
Instance Method Summary collapse
- #build(digest, gem_specification) ⇒ Object
- #build_manifest(spec) ⇒ Object
- #date_to_ms(date) ⇒ Object
-
#file_count(path) ⇒ Object
These are all the code files that are located in the Gem directory loaded by the current environment; this includes more than Ruby files.
Instance Method Details
#build(digest, gem_specification) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/contrast/api/decorators/library.rb', line 18 def build digest, gem_specification msg = new msg.file_path = Contrast::Utils::StringUtils.force_utf8(gem_specification.name) msg.hash_code = Contrast::Utils::StringUtils.force_utf8(digest) msg.version = Contrast::Utils::StringUtils.force_utf8(gem_specification.version) msg.manifest = Contrast::Utils::StringUtils.force_utf8(build_manifest(gem_specification)) msg.external_ms = date_to_ms(gem_specification.date) msg.internal_ms = msg.external_ms msg.url = Contrast::Utils::StringUtils.force_utf8(gem_specification.homepage) msg.class_count = file_count(gem_specification.full_gem_path.to_s) msg.used_class_count = 0 msg end |
#build_manifest(spec) ⇒ Object
38 39 40 41 42 |
# File 'lib/contrast/api/decorators/library.rb', line 38 def build_manifest spec Contrast::Utils::StringUtils.force_utf8(spec.to_yaml.to_s) rescue StandardError nil end |
#date_to_ms(date) ⇒ Object
44 45 46 |
# File 'lib/contrast/api/decorators/library.rb', line 44 def date_to_ms date (date.to_f * 1000.0).to_i end |
#file_count(path) ⇒ Object
These are all the code files that are located in the Gem directory loaded by the current environment; this includes more than Ruby files
34 35 36 |
# File 'lib/contrast/api/decorators/library.rb', line 34 def file_count path Contrast::Utils::Sha256Builder.instance.files(path).length end |