Method: Deal::Text#initialize

Defined in:
lib/deal/command/text.rb

#initialize(argv) ⇒ Text

Returns a new instance of Text.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/deal/command/text.rb', line 31

def initialize(argv)
    super
    configs = argv.option('config')
    @include = argv.option('include',"")
    @signs = argv.option('signs',"").split('|')
    @include_paths = argv.option('include_paths',"" ).split('|')
    @exclude_paths = argv.option('exclude_paths',"" ).split('|')
    @judge_types = argv.option('judge_types',"" ).split('|')
    @replace = argv.option('replace','')
    @judge_action = argv.option('judge_action','abort')
    @configs = []
    if configs
        if FileTest.exist? configs
            configs = File.read(configs)
            begin
                configs = JSON.parse(configs)
            rescue Exception => e
                puts e.message
                puts e.backtrace.inspect
            end

            for config in configs
                config = DealRule.new(config)
                @configs.push config
            end
        else
            logE "file:#{configs} not exist"
            return
        end
    else
        config = {}
        config["signs"] = @signs
        config["include_paths"] = @include_paths
        config["exclude_paths"] = @exclude_paths
        config["judge_types"] = @judge_types
        config["replace"] = @replace
        config["judge_action"] = @judge_action
        config = DealRule.new(config)
        @configs.push config
    end


    @judge_count = 0
    @total_count = 0
    @progress = 0.0

    @jump_file = {}
    @results = []

    @input = argv.option('input')
    @input = Dir.glob(@input,)


end