Sha256: c114d47e57988c2c8d09936b1e935d5fa994615e07fb9cad62717cf877b3f10a

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

# -*- coding: UTF-8 -*-

require 'ansi'

module BuildTool

        module StateHelper

            # Needed for both Module and Command History
            STARTED = 0
            CANCELED_BY_USER = 1
            FINISHED_SUCCESSFUL = 2
            FINISHED_WITH_ERRORS = 3

            def state_str
                self.class.state_str( self.state )
            end

            def state_char
                self.class.state_char( self.state )
            end

            module ClassMethods

                def state_str( state )
                    case state
                    when STARTED
                        "STARTED"
                    when CANCELED_BY_USER
                        ANSI::Code.red { "CANCELED" }
                    when FINISHED_SUCCESSFUL
                        ANSI::Code.green { "SUCCESS" }
                    when FINISHED_WITH_ERRORS
                        ANSI::Code.red { "ERRORS" }
                    else
                        "#{state.to_s}?"
                    end
                end

                def state_char( state )
                    case state
                    when STARTED
                        "R"
                    when CANCELED_BY_USER
                        ANSI::Code.red { "C" }
                    when FINISHED_SUCCESSFUL
                        ANSI::Code.green { "S" }
                    when FINISHED_WITH_ERRORS
                        ANSI::Code.red { "E" }
                    else
                        "#{state.to_s}?"
                    end
                end
            end

            def self.included( klass )
                klass.extend ClassMethods
            end

        end


end # module BuildTool

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
build-tool-0.6.9 lib/build-tool/state_helper.rb
build-tool-0.6.8 lib/build-tool/state_helper.rb
build-tool-0.6.7 lib/build-tool/state_helper.rb
build-tool-0.6.6 lib/build-tool/state_helper.rb
build-tool-0.6.5 lib/build-tool/state_helper.rb
build-tool-0.6.4 lib/build-tool/state_helper.rb
build-tool-0.6.3 lib/build-tool/state_helper.rb
build-tool-0.6.2 lib/build-tool/state_helper.rb
build-tool-0.6.1 lib/build-tool/state_helper.rb
build-tool-0.6.0 lib/build-tool/state_helper.rb
build-tool-0.6.0.rc2 lib/build-tool/state_helper.rb
build-tool-0.6.0.rc1 lib/build-tool/state_helper.rb