Module: Pod::Extension::Development::DSL

Included in:
Pods, Source
Defined in:
lib/cocoapods-extension/development/dsl.rb

Instance Method Summary collapse

Instance Method Details

#run(url) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods-extension/development/dsl.rb', line 42

def run url
    contents = File.exist?(url) ? File.open(url, 'r:utf-8', &:read) : nil
    # Work around for Rubinius incomplete encoding in 1.9 mode
    if !contents.nil? && contents.respond_to?(:encoding) && contents.encoding.name != 'UTF-8'
        contents.encode!('UTF-8')
    end
    if !contents.nil? && contents.tr!('“”‘’‛', %(""'''))
        # Changes have been made
        CoreUI.warn "Smart quotes were detected and ignored in your #{File.basename(url)}. " \
                    'To avoid issues in the future, you should not use ' \
                    'TextEdit for editing it. If you are not using TextEdit, ' \
                    'you should turn off smart quotes in your editor of choice.'
    end
    unless contents.nil?
        begin
            eval(contents, nil, url.to_s)
        rescue Exception => e
            message = "Invalid `#{File.basename(url)}` file: #{e.message}"
            raise DSLError.new(message, url, e, contents)
        end
    end
end