Sha256: d997894eb985291a877070dab8a8672b218d85be5f1dc995551776ee5365b8dc
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
# frozen_string_literal: true ## # Usage example: # # result = ConvenientService::Examples::Standard::V1::Gemfile::Services::FormatGemsWithoutEnvs.result( # parsed_content: { # gems: [ # { # envs: [], # line: %(gem "bootsnap", ">= 1.4.4", require: false) # }, # { # envs: [], # line: %(gem "pg") # }, # { # envs: [], # line: %(gem "rails", "~> 6.1.3", ">= 6.1.3.2") # }, # { # envs: [], # line: %(gem "webpacker", "~> 5.0") # }, # { # envs: [], # line: %(gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]) # } # ] # } # ) # # NOTE: Check the corresponding spec file to see more examples. # module ConvenientService module Examples module Standard module V1 class Gemfile module Services class FormatGemsWithoutEnvs EMPTY_LINE = "" ENTER = "\n" include ConvenientService::Standard::V1::Config attr_reader :parsed_content def initialize(parsed_content:) @parsed_content = parsed_content end def result success(formatted_content: format_content) end private def format_content return "" if gems_without_envs.none? gems_without_envs .map { |gem| gem[:line] } .reduce(EMPTY_LINE.dup) { |content, line| content << line << ENTER } end def gems_without_envs @gems_without_envs ||= parsed_content[:gems].to_a.select { |gem| gem[:envs].none? } end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems