Module: Decidim::DecidimAwesome::SystemChecker
- Defined in:
- lib/decidim/decidim_awesome/system_checker.rb
Class Method Summary collapse
- .each ⇒ Object
- .each_file ⇒ Object
- .exists?(spec, file) ⇒ Boolean
-
.overrides ⇒ Object
List of files overriden by this plugin overriden files has to match MD5 calculation to be sure is the same as the expected.
- .valid?(spec, file) ⇒ Boolean
Class Method Details
.each ⇒ Object
27 28 29 |
# File 'lib/decidim/decidim_awesome/system_checker.rb', line 27 def each(&) to_h.each(&) end |
.each_file ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/decidim/decidim_awesome/system_checker.rb', line 31 def each_file each do |_, props| props.files.each do |file, signatures| yield "#{props.spec.gem_dir}#{file}", signatures end end end |
.exists?(spec, file) ⇒ Boolean
39 40 41 |
# File 'lib/decidim/decidim_awesome/system_checker.rb', line 39 def exists?(spec, file) File.exist?("#{spec.gem_dir}#{file}") end |
.overrides ⇒ Object
List of files overriden by this plugin overriden files has to match MD5 calculation to be sure is the same as the expected
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/decidim/decidim_awesome/system_checker.rb', line 9 def overrides return @overrides if @overrides # rubocop:disable Rails/DynamicFindBy checksums = YAML.load_file("#{__dir__}/checksums.yml") @overrides = checksums.map do |package, files| props = { spec: ::Gem::Specification.find_by_name(package), files: files.transform_values(&:values) } [package, to_struct(props)] end # rubocop:enable Rails/DynamicFindBy @overrides = to_struct(@overrides.to_h) end |
.valid?(spec, file) ⇒ Boolean
43 44 45 |
# File 'lib/decidim/decidim_awesome/system_checker.rb', line 43 def valid?(spec, file) find_signatures("#{spec.gem_dir}#{file}").detect { |s| md5("#{spec.gem_dir}#{file}") == s } end |