class Umbrella::Validator
Attributes
fix[R]
framework_target_name[R]
import_files[R]
project_file_path[R]
project_files[R]
umbrella_header[R]
Public Class Methods
new(options)
click to toggle source
# File lib/umbrellalinter/validator.rb, line 15 def initialize(options) @import_files = options.fetch(:import_files) @project_files = options.fetch(:project_files) @fix = options.fetch(:fix) @project_file_path = options.fetch(:project_file_path) @umbrella_header = options.fetch(:umbrella_header) @framework_target_name = options.fetch(:framework_target_name) end
perform(options)
click to toggle source
# File lib/umbrellalinter/validator.rb, line 11 def self.perform(options) new(options).perform end
Public Instance Methods
validate()
click to toggle source
# File lib/umbrellalinter/validator.rb, line 24 def validate # First we need to validate that all the import files in umbrella header are set as public. @import_files.each { |filename| unless @project_files.key?(filename) if @fix t_file = Tempfile.new('filename_temp.txt') File.open(@project_file_path, 'r') do |f| file_found = false f.each_line{ |line| if line.include? filename + " */;" file_found = true puts "Changing the scope of " + filename + " to" +" Public".green newline = line.slice(0..(line.index(filename + " */;"))) newline = newline + filename.chop + " */;" + " settings = {ATTRIBUTES = (Public, ); }; };" t_file.puts newline else t_file.puts line end } unless file_found puts "Couldn't find ".red + filename.red + " in your project. Make sure you didn't misspell it or removed it.".red end end t_file.close FileUtils.mv(t_file.path, @project_file_path) else puts filename.red + " needs to be set as Public or your consumers won't be able to import it.".red end end } @project_files.each do |filename, scope| unless @import_files.include? filename if @fix unless filename.include? File.basename( umbrella_header ) puts "Adding ".green + filename.green + " to Umbrella Header".green File.open(@umbrella_header, 'a') do |f1| f1.write("\n#import <" + File.basename( umbrella_header, ".*" ) + "/" + filename + ">") end end else puts filename.red + "is Public and needs to be added to the umbrella header".red end end end end