codercmp 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/codercmp +8 -3
- data/lib/codercompanion.rb +231 -313
- data/lib/codercompanion/api.rb +20 -13
- data/lib/codercompanion/cachehandler.rb +26 -26
- data/lib/codercompanion/java/java_parser.rb +1 -1
- data/lib/codercompanion/java/java_tree_walker.rb +1 -2
- data/lib/codercompanion/language_parser.rb +8 -3
- data/lib/codercompanion/ruby/ruby_parser.rb +1 -2
- data/lib/codercompanion/ruby/ruby_tree_walker.rb +4 -4
- data/lib/codercompanion/tree_walker.rb +2 -1
- data/lib/codercompanion/visual_message.rb +66 -0
- data/lib/codercompanion_version.rb +1 -1
- metadata +31 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 33f172e7819122536245dbe189b28fcf0c146160
         | 
| 4 | 
            +
              data.tar.gz: acfcd56950dc3c875d2d3ff4becbb6a5c3e64196
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: acf252f2ca33a3dd64f8b1a5d6a6f18ebdd5db0e5c945bcdba39d7e8ff20b4ea7d6525742ebe1a5a76713e1b62530857f5dce63309aeae6cd364e7fb76c80375
         | 
| 7 | 
            +
              data.tar.gz: 115addcac50bfbac07452c93db2274a3e7b6482c3f6d0560bdd20695fcfa536d104ff0747b421ac0fe4e69c252c5db0c2f305692c04203d321ffdba145d5813b
         | 
    
        data/bin/codercmp
    CHANGED
    
    | @@ -56,9 +56,14 @@ INFO | |
| 56 56 | 
             
                    options[:no_color] = !val
         | 
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 | 
            -
                opts.on( "--show-output", " | 
| 59 | 
            +
                opts.on( "--show-output", "Display the output after parsing the project") do
         | 
| 60 60 | 
             
                    options[:show_output] = true
         | 
| 61 61 | 
             
                end 
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                opts.on( "--output-file FILE", "-o FILE", "Output to a json file instead of uploading to codercompanion") do |file_name|
         | 
| 64 | 
            +
                    puts file_name
         | 
| 65 | 
            +
                    options[:output_file] = file_name
         | 
| 66 | 
            +
                end
         | 
| 62 67 |  | 
| 63 68 | 
             
                opts.on( "--dry-run", "Performs dry run. Does not actually upload data. The purpose of this command is to test the parsing of your files. " +
         | 
| 64 69 | 
             
                            "Becomes even more useful when used with --show-output to see the result of the parse") do
         | 
| @@ -73,7 +78,7 @@ INFO | |
| 73 78 | 
             
                end
         | 
| 74 79 |  | 
| 75 80 | 
             
                opts.on( "--languages", "-l", "Get the supported languages") do
         | 
| 76 | 
            -
                    CoderCompanion.display_supported_languages
         | 
| 81 | 
            +
                    CoderCompanion::CLI.display_supported_languages
         | 
| 77 82 | 
             
                    exit 0
         | 
| 78 83 | 
             
                end
         | 
| 79 84 |  | 
| @@ -94,7 +99,7 @@ option_parser.parse! | |
| 94 99 |  | 
| 95 100 | 
             
            options[:exclude] = exclude
         | 
| 96 101 | 
             
            begin
         | 
| 97 | 
            -
                CoderCompanion:: | 
| 102 | 
            +
                CoderCompanion::CLI.new(options, location).run
         | 
| 98 103 | 
             
            rescue CoderCompanion::CoderCompanionException => e
         | 
| 99 104 | 
             
                CoderCompanion::j_print CoderCompanion::error_format(e.message)
         | 
| 100 105 | 
             
                exit 1
         | 
    
        data/lib/codercompanion.rb
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # TODO: change to use instance instead of static/class methods for all
         | 
| 2 1 | 
             
            $:.push File.expand_path(File.dirname(__FILE__) )
         | 
| 3 2 |  | 
| 4 3 | 
             
            require 'yard'
         | 
| @@ -11,6 +10,7 @@ require 'treetop' | |
| 11 10 | 
             
            require 'colored'
         | 
| 12 11 | 
             
            require 'aws-sdk'
         | 
| 13 12 | 
             
            require 'codercompanion/codercompanion_exception'
         | 
| 13 | 
            +
            require 'codercompanion/visual_message'
         | 
| 14 14 | 
             
            require 'codercompanion/ruby/ruby_annotations'
         | 
| 15 15 | 
             
            require 'codercompanion/languages'
         | 
| 16 16 | 
             
            require 'codercompanion/parser_factory'
         | 
| @@ -36,375 +36,293 @@ end | |
| 36 36 |  | 
| 37 37 | 
             
            module CoderCompanion
         | 
| 38 38 |  | 
| 39 | 
            -
                BASEPATH            = File.expand_path('..', File.dirname(__FILE__) )
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                STATUS_OK           = 200
         | 
| 42 | 
            -
                USER_NOT_FOUND      = 461
         | 
| 43 | 
            -
                PROJECT_NOT_FOUND   = 510
         | 
| 44 | 
            -
                GENERIC_ERROR       = 500
         | 
| 45 | 
            -
             | 
| 46 39 | 
             
                CONFIG_FILE_NAME    = 'codercmp.conf'
         | 
| 47 40 |  | 
| 48 | 
            -
                 | 
| 49 | 
            -
                @@options                           = {}
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                # @return [Hash]
         | 
| 52 | 
            -
                @@config                            = nil
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                # @return [String]
         | 
| 55 | 
            -
                @@visit_config_location_message     = ""
         | 
| 41 | 
            +
                @@no_color                          = false
         | 
| 56 42 |  | 
| 57 | 
            -
                 | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
                @@api = CoderCompanion::API.new
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                def self.init
         | 
| 64 | 
            -
            =begin
         | 
| 65 | 
            -
            -----------------------------------------------------------------------------------------------
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                                               __-¯--__
         | 
| 68 | 
            -
                                          __-¯¯        ¯¯--__
         | 
| 69 | 
            -
                                     __-¯¯                   ¯¯-___,
         | 
| 70 | 
            -
                                   /¯-__                   __-¯¯__  |
         | 
| 71 | 
            -
                                   |    ¯¯--__        __-¯¯__-¯¯  | |
         | 
| 72 | 
            -
                                   |          ¯--__-¯¯__-¯¯       | |
         | 
| 73 | 
            -
                                   |             | r¯¯       ¯¯   | |
         | 
| 74 | 
            -
                                   |             | |   O          | |
         | 
| 75 | 
            -
                                   L             | |            _-| |
         | 
| 76 | 
            -
                                    `~__         | |       __-¯¯__-¯¯ 
         | 
| 77 | 
            -
                                        `~__     | |  __-¯¯__-¯¯  __-¯¯`~__
         | 
| 78 | 
            -
                                            `~__ | '¯¯__-¯¯  __-¯¯         ;-
         | 
| 79 | 
            -
                                                `L_-¯¯  __-¯¯         __-¯¯
         | 
| 80 | 
            -
                                                   __-¯¯         __-¯¯
         | 
| 81 | 
            -
                                                  `~_       __-¯¯
         | 
| 82 | 
            -
                                                     `~__-¯¯
         | 
| 83 | 
            -
                        #{special_format("R u n n i n g   C o d e r   C o m p a n i o n   u p l o a d e r")}
         | 
| 84 | 
            -
                    
         | 
| 85 | 
            -
            -----------------------------------------------------------------------------------------------
         | 
| 86 | 
            -
            =end
         | 
| 87 | 
            -
                    j_print <<INFO 
         | 
| 88 | 
            -
            -----------------------------------------------------------------------------------------------
         | 
| 43 | 
            +
                class << self
         | 
| 44 | 
            +
                    def j_print(string)
         | 
| 45 | 
            +
                        puts string if !silent_run
         | 
| 46 | 
            +
                    end
         | 
| 89 47 |  | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
            -----------------------------------------------------------------------------------------------
         | 
| 93 | 
            -
            INFO
         | 
| 94 | 
            -
                    @@visit_config_location_message = error_format("Please visit ") + error_url_format("http://codercompanion.com") + error_format(" for more info")
         | 
| 95 | 
            -
                    
         | 
| 96 | 
            -
                    # Using config_filename otherwise default to 'codercmp.conf' in pwd
         | 
| 97 | 
            -
                    config_filename = @@options[:config_file] ? @@options[:config_file] : "#{CONFIG_FILE_NAME}"
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                    file = nil
         | 
| 100 | 
            -
                    begin
         | 
| 101 | 
            -
                        file = File.open(config_filename)
         | 
| 102 | 
            -
                    rescue => e
         | 
| 103 | 
            -
                        j_print e.to_s
         | 
| 104 | 
            -
                        raise CoderCompanionException.new(error_format("An error occured while trying to open the configuration file"))
         | 
| 48 | 
            +
                    def j_print_inline(string)
         | 
| 49 | 
            +
                        print string if !silent_run
         | 
| 105 50 | 
             
                    end
         | 
| 106 51 |  | 
| 107 | 
            -
                     | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
                        j_print error_format e.to_s
         | 
| 111 | 
            -
                        raise CoderCompanionException.new(error_format("could not parse your config file. ") + @@visit_config_location_message)
         | 
| 52 | 
            +
                    # @param [String] string
         | 
| 53 | 
            +
                    def special_format(string)
         | 
| 54 | 
            +
                        return no_color ? string : string.white_on_black.bold
         | 
| 112 55 | 
             
                    end
         | 
| 113 | 
            -
                    
         | 
| 114 | 
            -
                    verify_config_file
         | 
| 115 | 
            -
                end
         | 
| 116 56 |  | 
| 117 | 
            -
             | 
| 118 | 
            -
                     | 
| 119 | 
            -
             | 
| 57 | 
            +
                    # @param [String] string
         | 
| 58 | 
            +
                    def warning_format(string)
         | 
| 59 | 
            +
                        return no_color ? string : string.black_on_yellow.bold
         | 
| 60 | 
            +
                    end
         | 
| 120 61 |  | 
| 121 | 
            -
             | 
| 122 | 
            -
                     | 
| 123 | 
            -
             | 
| 62 | 
            +
                    # @param [String] string
         | 
| 63 | 
            +
                    def error_format(string)
         | 
| 64 | 
            +
                        return no_color ? string : string.white_on_red.bold
         | 
| 65 | 
            +
                    end
         | 
| 124 66 |  | 
| 125 | 
            -
             | 
| 126 | 
            -
                     | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
                # @return [CoderCompanion::CacheHandler]
         | 
| 130 | 
            -
                def self.cache_handler
         | 
| 131 | 
            -
                    @@cache_handler
         | 
| 132 | 
            -
                end
         | 
| 67 | 
            +
                    # @param [String] string
         | 
| 68 | 
            +
                    def error_url_format(string)
         | 
| 69 | 
            +
                        return no_color ? string : string.yellow_on_red.bold.underline
         | 
| 70 | 
            +
                    end
         | 
| 133 71 |  | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 72 | 
            +
                    # @param [String] string
         | 
| 73 | 
            +
                    def red_format(string)
         | 
| 74 | 
            +
                        return no_color ? string : string.red_on_black.bold
         | 
| 75 | 
            +
                    end
         | 
| 138 76 |  | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 77 | 
            +
                    # @param [String] string
         | 
| 78 | 
            +
                    def notification_format(string)
         | 
| 79 | 
            +
                        return no_color ? string : string.yellow_on_black
         | 
| 80 | 
            +
                    end
         | 
| 143 81 |  | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 82 | 
            +
                    # @param [String] string
         | 
| 83 | 
            +
                    def success_format(string)
         | 
| 84 | 
            +
                        return no_color ? string : string.green_on_black.bold
         | 
| 85 | 
            +
                    end
         | 
| 148 86 |  | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 87 | 
            +
                    def pretty_inspect(thing)
         | 
| 88 | 
            +
                        begin 
         | 
| 89 | 
            +
                            thing.awesome_inspect
         | 
| 90 | 
            +
                        rescue
         | 
| 91 | 
            +
                            thing.inspect
         | 
| 92 | 
            +
                        end
         | 
| 93 | 
            +
                    end
         | 
| 153 94 |  | 
| 154 | 
            -
             | 
| 155 | 
            -
                     | 
| 156 | 
            -
             | 
| 95 | 
            +
                    # @param no_color [Boolean]
         | 
| 96 | 
            +
                    def no_color=(no_color)
         | 
| 97 | 
            +
                        @@no_color = no_color
         | 
| 98 | 
            +
                    end
         | 
| 99 | 
            +
                    
         | 
| 100 | 
            +
                    # @return [Boolean]
         | 
| 101 | 
            +
                    def no_color
         | 
| 102 | 
            +
                        @@no_color
         | 
| 103 | 
            +
                    end
         | 
| 157 104 |  | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 105 | 
            +
                    # @param silent_run [Boolean]
         | 
| 106 | 
            +
                    def silent_run=(silent_run)
         | 
| 107 | 
            +
                        @@silent_run = silent_run
         | 
| 108 | 
            +
                    end
         | 
| 162 109 |  | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 110 | 
            +
                    # @return [Boolean]
         | 
| 111 | 
            +
                    def silent_run
         | 
| 112 | 
            +
                        @@silent_run
         | 
| 113 | 
            +
                    end
         | 
| 166 114 | 
             
                end
         | 
| 167 115 |  | 
| 168 | 
            -
                 | 
| 169 | 
            -
             | 
| 170 | 
            -
                    @@language = language
         | 
| 171 | 
            -
                end
         | 
| 116 | 
            +
                class CLI
         | 
| 117 | 
            +
                    attr_reader :cache_handler, :src_folder, :api, :options, :config, :language
         | 
| 172 118 |  | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 119 | 
            +
                    def initialize(options = {}, location)
         | 
| 120 | 
            +
                        @options = options
         | 
| 121 | 
            +
                        @src_folder = location
         | 
| 122 | 
            +
                        @cache_handler = CacheHandler.new options[:dry_run]
         | 
| 177 123 |  | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 124 | 
            +
                        CoderCompanion.no_color = options[:no_color]
         | 
| 125 | 
            +
                        CoderCompanion.silent_run = options[:silent_run]
         | 
| 126 | 
            +
                
         | 
| 127 | 
            +
                        print_greeting
         | 
| 128 | 
            +
                        @config = parse_config_file
         | 
| 129 | 
            +
                        verify_config @config
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                        @api = API.new({
         | 
| 132 | 
            +
                            :access_key     => @config["project"]["access_key"],
         | 
| 133 | 
            +
                            :access_id      => @config["user"]["access_id"],
         | 
| 134 | 
            +
                            :host           => @config["host"]
         | 
| 135 | 
            +
                        })
         | 
| 136 | 
            +
                    end
         | 
| 182 137 |  | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 138 | 
            +
                    # @return [Boolean]
         | 
| 139 | 
            +
                    def dry_run?
         | 
| 140 | 
            +
                        options[:dry_run]
         | 
| 141 | 
            +
                    end
         | 
| 187 142 |  | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 143 | 
            +
                    # @return [String]
         | 
| 144 | 
            +
                    def output_file
         | 
| 145 | 
            +
                        options[:output_file]
         | 
| 146 | 
            +
                    end
         | 
| 192 147 |  | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 148 | 
            +
                    # @return [Boolean]
         | 
| 149 | 
            +
                    def fresh_run
         | 
| 150 | 
            +
                        options[:fresh_run]
         | 
| 151 | 
            +
                    end
         | 
| 197 152 |  | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
                     | 
| 201 | 
            -
                end
         | 
| 153 | 
            +
                    def excluded
         | 
| 154 | 
            +
                        options[:exclude]
         | 
| 155 | 
            +
                    end
         | 
| 202 156 |  | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
                     | 
| 206 | 
            -
                end
         | 
| 157 | 
            +
                    def print_greeting
         | 
| 158 | 
            +
                        ::CoderCompanion.j_print VisualMessage.get_greeting_text
         | 
| 159 | 
            +
                    end
         | 
| 207 160 |  | 
| 208 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 161 | 
            +
                    def parse_config_file
         | 
| 162 | 
            +
                        @@visit_config_location_message = ::CoderCompanion.error_format("Please visit ") + ::CoderCompanion.error_url_format("http://codercompanion.com") + ::CoderCompanion.error_format(" for more info")
         | 
| 163 | 
            +
                        
         | 
| 164 | 
            +
                        # Using config_filename otherwise default to 'codercmp.conf' in pwd
         | 
| 165 | 
            +
                        config_filename = options[:config_file] ? options[:config_file] : "#{CONFIG_FILE_NAME}"
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                        file = nil
         | 
| 168 | 
            +
                        begin
         | 
| 169 | 
            +
                            file = File.open(config_filename)
         | 
| 170 | 
            +
                        rescue => e
         | 
| 171 | 
            +
                            ::CoderCompanion.j_print e.to_s
         | 
| 172 | 
            +
                            raise CoderCompanionException.new(::CoderCompanion.error_format("An error occured while trying to open the configuration file"))
         | 
| 173 | 
            +
                        end
         | 
| 212 174 |  | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 175 | 
            +
                        begin
         | 
| 176 | 
            +
                            return JSON.parse(file.read)
         | 
| 177 | 
            +
                        rescue => e
         | 
| 178 | 
            +
                            ::CoderCompanion.j_print ::CoderCompanion.error_format e.to_s
         | 
| 179 | 
            +
                            raise CoderCompanionException.new(::CoderCompanion.error_format("could not parse your config file. ") + @@visit_config_location_message)
         | 
| 180 | 
            +
                        end
         | 
| 181 | 
            +
                        
         | 
| 182 | 
            +
                    end
         | 
| 217 183 |  | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 184 | 
            +
                    def verify_config config
         | 
| 185 | 
            +
                        ::CoderCompanion.j_print ::CoderCompanion.notification_format("Verifying Config file...")
         | 
| 186 | 
            +
                        error = false
         | 
| 187 | 
            +
                        if config
         | 
| 188 | 
            +
                            if config["project"]
         | 
| 189 | 
            +
                                if config["project"]["access_key"] == nil || config["project"]["access_key"].match(/^\s*$/)
         | 
| 190 | 
            +
                                    ::CoderCompanion.j_print ::CoderCompanion.error_format("No access_key for project specified.")
         | 
| 191 | 
            +
                                    error = true
         | 
| 192 | 
            +
                                end
         | 
| 227 193 |  | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 194 | 
            +
                                is_supported = true
         | 
| 195 | 
            +
                                @language = config["project"]["language"]
         | 
| 196 | 
            +
                                if language == nil || language.match(/^\s*$/)
         | 
| 197 | 
            +
                                    ::CoderCompanion.j_print ::CoderCompanion.error_format("No language specified in your config file.")
         | 
| 198 | 
            +
                                    error = true
         | 
| 199 | 
            +
                                elsif !Languages.is_supported?(language)
         | 
| 200 | 
            +
                                    is_supported = false
         | 
| 201 | 
            +
                                    ::CoderCompanion.j_print ::CoderCompanion.error_format("#{language} is not a supported language")
         | 
| 202 | 
            +
                                    ::CoderCompanion.j_print ::CoderCompanion.notification_format("To see a list of supported languages run: \n\tcodercmp --language\n")
         | 
| 203 | 
            +
                                    error = true
         | 
| 204 | 
            +
                                end
         | 
| 205 | 
            +
                            else
         | 
| 206 | 
            +
                                ::CoderCompanion.j_print ::CoderCompanion.error_format("Project not found in config file. ") 
         | 
| 237 207 | 
             
                                error = true
         | 
| 238 208 | 
             
                            end
         | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
                                languages = CoderCompanion::Languages.supported_languages
         | 
| 243 | 
            -
                                language_details = nil
         | 
| 244 | 
            -
                                languages.each do |lang|
         | 
| 245 | 
            -
                                    language_details = (lang[:key] == language) ? lang : nil
         | 
| 246 | 
            -
                                    if language_details
         | 
| 247 | 
            -
                                        break
         | 
| 248 | 
            -
                                    end
         | 
| 249 | 
            -
                                end
         | 
| 250 | 
            -
                                if language_details && language_details[:annotation_required] && (self.annotation == nil || self.annotation.match(/^\s*$/))
         | 
| 251 | 
            -
                                    j_print error_format("#{self.language} is supported but must make use of ONE of the following annotations styles: #{language_details[:valid_annotation].join(", ")}")
         | 
| 209 | 
            +
                            if config["user"]
         | 
| 210 | 
            +
                                if config["user"]["access_id"] == nil || config["user"]["access_id"] == ""
         | 
| 211 | 
            +
                                    ::CoderCompanion.j_print ::CoderCompanion.error_format("No access_id for project specified.")
         | 
| 252 212 | 
             
                                    error = true
         | 
| 253 213 | 
             
                                end
         | 
| 214 | 
            +
                            else
         | 
| 215 | 
            +
                                ::CoderCompanion.j_print ::CoderCompanion.error_format("User info not found")
         | 
| 216 | 
            +
                                error = true
         | 
| 254 217 | 
             
                            end
         | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
                            j_print error_format("Project not found in config file. ") 
         | 
| 258 | 
            -
                            error = true
         | 
| 259 | 
            -
                        end
         | 
| 260 | 
            -
                        if @@config["user"]
         | 
| 261 | 
            -
                            if @@config["user"]["access_id"] == nil || @@config["user"]["access_id"] == ""
         | 
| 262 | 
            -
                                j_print error_format("No access_id for project specified.")
         | 
| 218 | 
            +
                            if config["host"] == nil || config["host"] == ""
         | 
| 219 | 
            +
                                ::CoderCompanion.j_print ::CoderCompanion.error_format("Host not found")
         | 
| 263 220 | 
             
                                error = true
         | 
| 264 221 | 
             
                            end
         | 
| 265 | 
            -
                        else
         | 
| 266 | 
            -
                            j_print error_format("User info not found")
         | 
| 267 | 
            -
                            error = true
         | 
| 268 222 | 
             
                        end
         | 
| 269 | 
            -
                        if @@config["host"] == nil || @@config["host"] == ""
         | 
| 270 | 
            -
                            j_print error_format("Host not found")
         | 
| 271 | 
            -
                            error = true
         | 
| 272 | 
            -
                        end
         | 
| 273 | 
            -
                    end
         | 
| 274 | 
            -
             | 
| 275 | 
            -
                    if error
         | 
| 276 | 
            -
                        raise CoderCompanionException.new(@@visit_config_location_message)
         | 
| 277 | 
            -
                    end
         | 
| 278 | 
            -
             | 
| 279 | 
            -
                    j_print success_format("Config file Successfully Verified")
         | 
| 280 | 
            -
                end
         | 
| 281 | 
            -
             | 
| 282 | 
            -
                def self.pretty_inspect(thing)
         | 
| 283 | 
            -
                    begin 
         | 
| 284 | 
            -
                        thing.awesome_inspect
         | 
| 285 | 
            -
                    rescue
         | 
| 286 | 
            -
                        thing.inspect
         | 
| 287 | 
            -
                    end
         | 
| 288 | 
            -
                end
         | 
| 289 | 
            -
             | 
| 290 | 
            -
                def self.display_supported_languages
         | 
| 291 | 
            -
                    languages = CoderCompanion::Languages.supported_languages
         | 
| 292 | 
            -
            puts <<INFO
         | 
| 293 | 
            -
            ---------------------------------------------------------------------------------------------
         | 
| 294 | 
            -
             | 
| 295 | 
            -
                                #{CoderCompanion::notification_format("CoderCompanion Supported Languages (2015-05-30)")}
         | 
| 296 | 
            -
             | 
| 297 | 
            -
            ---------------------------------------------------------------------------------------------
         | 
| 298 | 
            -
            INFO
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                    languages.each do |lang|
         | 
| 301 223 |  | 
| 302 | 
            -
             | 
| 224 | 
            +
                        if error
         | 
| 225 | 
            +
                            raise CoderCompanionException.new(@@visit_config_location_message)
         | 
| 226 | 
            +
                        end
         | 
| 303 227 |  | 
| 304 | 
            -
             | 
| 305 | 
            -
                    
         | 
| 306 | 
            -
            INFO
         | 
| 228 | 
            +
                        ::CoderCompanion.j_print ::CoderCompanion.success_format("Config file Successfully Verified")
         | 
| 307 229 | 
             
                    end
         | 
| 308 | 
            -
                end
         | 
| 309 | 
            -
             | 
| 310 | 
            -
                def self.run
         | 
| 311 | 
            -
                    if self.dry_run?
         | 
| 312 | 
            -
                       
         | 
| 313 | 
            -
            j_print <<INFO
         | 
| 314 | 
            -
             | 
| 315 | 
            -
            #{notification_format("Performing dry run:")}
         | 
| 316 | 
            -
                - No cache use
         | 
| 317 | 
            -
                - No upload           
         | 
| 318 | 
            -
             | 
| 319 | 
            -
            INFO
         | 
| 320 230 |  | 
| 231 | 
            +
                    def self.display_supported_languages
         | 
| 232 | 
            +
                        languages = CoderCompanion::Languages.supported_languages
         | 
| 233 | 
            +
                        puts VisualMessage.supported_languages_header
         | 
| 234 | 
            +
                        languages.each do |lang|
         | 
| 235 | 
            +
                            puts VisualMessage.supported_language_row lang
         | 
| 236 | 
            +
                        end
         | 
| 321 237 | 
             
                    end
         | 
| 322 238 |  | 
| 239 | 
            +
                    def run
         | 
| 240 | 
            +
                        if self.dry_run?
         | 
| 241 | 
            +
                            CoderCompanion.j_print VisualMessage.dry_run_text
         | 
| 242 | 
            +
                        end
         | 
| 323 243 |  | 
| 324 | 
            -
             | 
| 325 | 
            -
             | 
| 326 | 
            -
             | 
| 327 | 
            -
                        
         | 
| 328 | 
            -
                    p = CoderCompanion::ParserFactory.get_parser(self.language)
         | 
| 244 | 
            +
                        cache_handler.load_cache(fresh_run)
         | 
| 245 | 
            +
                            
         | 
| 246 | 
            +
                        p = CoderCompanion::ParserFactory.get_parser(language)
         | 
| 329 247 |  | 
| 330 | 
            -
             | 
| 331 | 
            -
             | 
| 248 | 
            +
                        # Running test for different languages
         | 
| 249 | 
            +
                        uploadable = p.create_project_json(src_folder, excluded, cache_handler)
         | 
| 332 250 |  | 
| 333 | 
            -
             | 
| 334 | 
            -
             | 
| 335 | 
            -
             | 
| 251 | 
            +
                        if options[:show_output]
         | 
| 252 | 
            +
                            ap uploadable
         | 
| 253 | 
            +
                        end
         | 
| 336 254 |  | 
| 337 | 
            -
             | 
| 338 | 
            -
             | 
| 339 | 
            -
             | 
| 340 | 
            -
             | 
| 255 | 
            +
                        if !uploadable
         | 
| 256 | 
            +
                            ::CoderCompanion.j_print ::CoderCompanion.error_format("Something went wrong while trying to create uploadable")
         | 
| 257 | 
            +
                            return
         | 
| 258 | 
            +
                        end
         | 
| 341 259 |  | 
| 342 260 |  | 
| 343 | 
            -
             | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
                        file_rel_path = './test_upload.codercompanion'
         | 
| 348 | 
            -
                        File.open(file_rel_path, 'w+') {|f| f.write(uploadable.to_json) }
         | 
| 261 | 
            +
                        if !dry_run? 
         | 
| 262 | 
            +
                            #puts pretty_inspect(uploadable)
         | 
| 263 | 
            +
                            # Maybe wrap this in a begin--rescue block
         | 
| 264 | 
            +
                            # Uncomment this
         | 
| 349 265 |  | 
| 350 | 
            -
             | 
| 266 | 
            +
                            file_rel_path = './test_upload.codercompanion'
         | 
| 267 | 
            +
                            if output_file
         | 
| 268 | 
            +
                                ::CoderCompanion.j_print ::CoderCompanion.notification_format("saving output to #{output_file}")
         | 
| 269 | 
            +
                                file_rel_path = output_file
         | 
| 270 | 
            +
                            end
         | 
| 271 | 
            +
                            File.open(file_rel_path, 'w+') {|f| f.write(uploadable.to_json) }
         | 
| 272 | 
            +
                            
         | 
| 273 | 
            +
                            if output_file
         | 
| 274 | 
            +
                                ::CoderCompanion.j_print ::CoderCompanion.success_format("Successfully saved the output")
         | 
| 275 | 
            +
                                return
         | 
| 276 | 
            +
                            end
         | 
| 277 | 
            +
                            #zip file here
         | 
| 351 278 |  | 
| 352 | 
            -
             | 
| 279 | 
            +
                            ::CoderCompanion.j_print ::CoderCompanion.notification_format("uploading to #{config["host"]}...")
         | 
| 353 280 |  | 
| 354 | 
            -
             | 
| 355 | 
            -
             | 
| 356 | 
            -
             | 
| 281 | 
            +
                            # Uncomment this
         | 
| 282 | 
            +
                            # Upload file to be processed
         | 
| 283 | 
            +
                            upload(file_rel_path)
         | 
| 357 284 |  | 
| 358 | 
            -
             | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 285 | 
            +
                            File.delete(file_rel_path)
         | 
| 286 | 
            +
                            cache_handler.write_cached_data
         | 
| 287 | 
            +
                            ::CoderCompanion.j_print ::CoderCompanion.success_format("Uploaded your changes successfully")
         | 
| 288 | 
            +
                        end
         | 
| 361 289 | 
             
                    end
         | 
| 362 | 
            -
                end
         | 
| 363 290 |  | 
| 364 | 
            -
             | 
| 365 | 
            -
             | 
| 366 | 
            -
             | 
| 367 | 
            -
             | 
| 368 | 
            -
             | 
| 369 | 
            -
             | 
| 291 | 
            +
                    def upload(file)
         | 
| 292 | 
            +
                        response = api.get_temporary_access_key
         | 
| 293 | 
            +
                        unless response
         | 
| 294 | 
            +
                            File.delete(file)
         | 
| 295 | 
            +
                            raise CoderCompanion::CoderCompanionException, "Failed to upload project"
         | 
| 296 | 
            +
                        end
         | 
| 370 297 |  | 
| 371 | 
            -
             | 
| 372 | 
            -
             | 
| 373 | 
            -
             | 
| 374 | 
            -
             | 
| 375 | 
            -
             | 
| 376 | 
            -
             | 
| 377 | 
            -
             | 
| 378 | 
            -
             | 
| 379 | 
            -
             | 
| 380 | 
            -
             | 
| 381 | 
            -
             | 
| 382 | 
            -
             | 
| 383 | 
            -
             | 
| 384 | 
            -
             | 
| 385 | 
            -
             | 
| 386 | 
            -
             | 
| 387 | 
            -
             | 
| 388 | 
            -
             | 
| 389 | 
            -
             | 
| 390 | 
            -
             | 
| 391 | 
            -
             | 
| 392 | 
            -
             | 
| 393 | 
            -
             | 
| 394 | 
            -
             | 
| 395 | 
            -
             | 
| 396 | 
            -
             | 
| 397 | 
            -
             | 
| 298 | 
            +
                        response_data = JSON.parse(response)["data"]
         | 
| 299 | 
            +
                        credentials = response_data["credentials"]
         | 
| 300 | 
            +
                        region = response_data["region"]
         | 
| 301 | 
            +
                        s3_bucket = response_data["s3_bucket"]
         | 
| 302 | 
            +
                        s3_client = CoderCompanion::S3Client.new(
         | 
| 303 | 
            +
                            :session_token => credentials["session_token"], 
         | 
| 304 | 
            +
                            :access_key_id => credentials["access_key_id"], 
         | 
| 305 | 
            +
                            :secret_access_key => credentials["secret_access_key"], 
         | 
| 306 | 
            +
                            :region => region, 
         | 
| 307 | 
            +
                            :s3_bucket => s3_bucket 
         | 
| 308 | 
            +
                        )
         | 
| 309 | 
            +
             | 
| 310 | 
            +
                        current_time = Time.now.utc.strftime("%Y-%m-%d:%H:%M:%S")
         | 
| 311 | 
            +
                        key = "#{config["user"]["access_id"]}/#{config["project"]["access_key"]}/#{current_time}/upload"
         | 
| 312 | 
            +
             | 
| 313 | 
            +
                        # put object using the s3_client
         | 
| 314 | 
            +
                        result = s3_client.put_object(file, key)
         | 
| 315 | 
            +
                        unless result
         | 
| 316 | 
            +
                            File.delete(file)
         | 
| 317 | 
            +
                            raise CoderCompanion::CoderCompanionException, "Failed to upload file to S3"
         | 
| 318 | 
            +
                        end 
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                        # notify the api that we have uploaded the file to s3
         | 
| 321 | 
            +
                        response = api.notify_s3_upload(key)
         | 
| 322 | 
            +
                        unless response
         | 
| 323 | 
            +
                            File.delete(file)
         | 
| 324 | 
            +
                            raise CoderCompanion::CoderCompanionException, "Failed to complete upload. It is possible our servers are down"
         | 
| 325 | 
            +
                        end
         | 
| 398 326 | 
             
                    end
         | 
| 399 327 | 
             
                end
         | 
| 400 | 
            -
             | 
| 401 | 
            -
                def self.start(options, location)
         | 
| 402 | 
            -
                    @@options = options
         | 
| 403 | 
            -
                    
         | 
| 404 | 
            -
                    @@src_folder = location
         | 
| 405 | 
            -
                    
         | 
| 406 | 
            -
                    self.init
         | 
| 407 | 
            -
                    self.run
         | 
| 408 | 
            -
                end
         | 
| 409 | 
            -
             | 
| 410 328 | 
             
            end
         | 
    
        data/lib/codercompanion/api.rb
    CHANGED
    
    | @@ -1,18 +1,25 @@ | |
| 1 1 | 
             
            module CoderCompanion
         | 
| 2 2 | 
             
                class API
         | 
| 3 | 
            -
                     | 
| 4 | 
            -
             | 
| 3 | 
            +
                    STATUS_OK           = 200
         | 
| 4 | 
            +
                    USER_NOT_FOUND      = 461
         | 
| 5 | 
            +
                    PROJECT_NOT_FOUND   = 510
         | 
| 6 | 
            +
                    GENERIC_ERROR       = 500
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                    attr_reader :config
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                    def initialize(config={})
         | 
| 11 | 
            +
                        @config = config
         | 
| 5 12 | 
             
                    end
         | 
| 6 13 |  | 
| 7 14 | 
             
                    def upload(file)
         | 
| 8 15 | 
             
                        response = nil
         | 
| 9 16 | 
             
                        begin
         | 
| 10 | 
            -
                            response = RestClient.post( | 
| 11 | 
            -
                                                        :access_key =>  | 
| 17 | 
            +
                            response = RestClient.post(config[:host] + '/update_project.json', :myfile => File.new(file),# /Users/oseghale/Projects/JinglePage/JingleParser/test_upload.jingle'), 
         | 
| 18 | 
            +
                                                        :access_key => config[:access_key], :access_id => config[:access_id]) { |response, request, result, &block|
         | 
| 12 19 | 
             
                                return response.code || nil 
         | 
| 13 20 | 
             
                            }
         | 
| 14 21 | 
             
                        rescue
         | 
| 15 | 
            -
                            return  | 
| 22 | 
            +
                            return GENERIC_ERROR
         | 
| 16 23 |  | 
| 17 24 | 
             
                        end
         | 
| 18 25 |  | 
| @@ -20,10 +27,10 @@ module CoderCompanion | |
| 20 27 |  | 
| 21 28 | 
             
                    def get_temporary_access_key
         | 
| 22 29 | 
             
                        begin 
         | 
| 23 | 
            -
                            RestClient.post("#{ | 
| 24 | 
            -
                                        :access_key =>  | 
| 25 | 
            -
                                        :access_id =>  | 
| 26 | 
            -
                                return (response.code ==  | 
| 30 | 
            +
                            RestClient.post("#{config[:host]}/project/get_temporary_access_key.json", 
         | 
| 31 | 
            +
                                        :access_key => config[:access_key], 
         | 
| 32 | 
            +
                                        :access_id => config[:access_id]) { |response, request, result, &block|
         | 
| 33 | 
            +
                                return (response.code == STATUS_OK) ? response : nil
         | 
| 27 34 | 
             
                            }
         | 
| 28 35 | 
             
                        rescue
         | 
| 29 36 | 
             
                            return nil
         | 
| @@ -32,11 +39,11 @@ module CoderCompanion | |
| 32 39 |  | 
| 33 40 | 
             
                    def notify_s3_upload(key)
         | 
| 34 41 | 
             
                        begin 
         | 
| 35 | 
            -
                            RestClient.post("#{ | 
| 42 | 
            +
                            RestClient.post("#{config[:host]}/project/notify_project_upload.json", 
         | 
| 36 43 | 
             
                                        :s3_key => key,
         | 
| 37 | 
            -
                                        :access_key =>  | 
| 38 | 
            -
                                        :access_id =>  | 
| 39 | 
            -
                                return (response.code ==  | 
| 44 | 
            +
                                        :access_key => config[:access_key], 
         | 
| 45 | 
            +
                                        :access_id => config[:access_id]) { |response, request, result, &block|
         | 
| 46 | 
            +
                                return (response.code == STATUS_OK) ? response : nil
         | 
| 40 47 | 
             
                            }
         | 
| 41 48 | 
             
                        rescue
         | 
| 42 49 | 
             
                            return nil
         | 
| @@ -4,9 +4,12 @@ module CoderCompanion | |
| 4 4 |  | 
| 5 5 | 
             
                    # @return [Object]
         | 
| 6 6 | 
             
                    attr_accessor :file_cache
         | 
| 7 | 
            +
                    
         | 
| 8 | 
            +
                    attr_reader :dry_run
         | 
| 7 9 |  | 
| 8 | 
            -
                    def initialize
         | 
| 10 | 
            +
                    def initialize(dry_run=false)
         | 
| 9 11 | 
             
                        @file_cache = {}
         | 
| 12 | 
            +
                        @dry_run = dry_run
         | 
| 10 13 | 
             
                    end
         | 
| 11 14 |  | 
| 12 15 | 
             
                    # @return [File, nil]
         | 
| @@ -22,12 +25,11 @@ module CoderCompanion | |
| 22 25 |  | 
| 23 26 | 
             
                    # @param fresh_run [Boolean] should we use cache for this run?
         | 
| 24 27 | 
             
                    def load_cache(fresh_run)
         | 
| 25 | 
            -
                        if  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
                            end
         | 
| 28 | 
            +
                        return if dry_run
         | 
| 29 | 
            +
                        if fresh_run
         | 
| 30 | 
            +
                            delete_cache
         | 
| 31 | 
            +
                        else
         | 
| 32 | 
            +
                            find_cache    
         | 
| 31 33 | 
             
                        end
         | 
| 32 34 | 
             
                    end
         | 
| 33 35 |  | 
| @@ -42,36 +44,34 @@ module CoderCompanion | |
| 42 44 | 
             
                    end
         | 
| 43 45 |  | 
| 44 46 | 
             
                    def delete_cache
         | 
| 45 | 
            -
                        if  | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
                            end
         | 
| 47 | 
            +
                        return if dry_run
         | 
| 48 | 
            +
                        begin
         | 
| 49 | 
            +
                            File.delete(CACHE_DIR + '/cache.data')
         | 
| 50 | 
            +
                            CoderCompanion::j_print CoderCompanion::warning_format("Running a fresh sesh")
         | 
| 51 | 
            +
                        rescue
         | 
| 52 | 
            +
                            CoderCompanion::j_print CoderCompanion::warning_format("No cache to delete. Running a fresh sesh")
         | 
| 52 53 | 
             
                        end
         | 
| 53 54 | 
             
                    end
         | 
| 54 55 |  | 
| 55 56 | 
             
                    # @param [String] file_path
         | 
| 56 57 | 
             
                    def update_cache_path(file_path)
         | 
| 57 | 
            -
                        if  | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
                             | 
| 61 | 
            -
                            self.file_cache[file_path] = encrypt(File.open(file_path).read)
         | 
| 58 | 
            +
                        return if dry_run
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                        if !self.file_cache
         | 
| 61 | 
            +
                            self.file_cache = {}
         | 
| 62 62 | 
             
                        end
         | 
| 63 | 
            +
                        self.file_cache[file_path] = encrypt(File.open(file_path).read)
         | 
| 63 64 | 
             
                    end
         | 
| 64 65 |  | 
| 65 66 | 
             
                    # @return [nil]
         | 
| 66 67 | 
             
                    def write_cached_data
         | 
| 67 | 
            -
                        if  | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                            end
         | 
| 71 | 
            -
                            File.open(CACHE_DIR + '/cache.data', 'w+') do |f| 
         | 
| 72 | 
            -
                                f.write(self.file_cache.to_json)
         | 
| 73 | 
            -
                            end 
         | 
| 68 | 
            +
                        return if dry_run
         | 
| 69 | 
            +
                        if !Dir.exists?(CACHE_DIR)
         | 
| 70 | 
            +
                            Dir.mkdir(CACHE_DIR)
         | 
| 74 71 | 
             
                        end
         | 
| 72 | 
            +
                        File.open(CACHE_DIR + '/cache.data', 'w+') do |f| 
         | 
| 73 | 
            +
                            f.write(self.file_cache.to_json)
         | 
| 74 | 
            +
                        end 
         | 
| 75 75 | 
             
                    end
         | 
| 76 76 |  | 
| 77 77 | 
             
                    # @return [JSON]
         | 
| @@ -20,7 +20,6 @@ module CoderCompanion | |
| 20 20 | 
             
                        end
         | 
| 21 21 |  | 
| 22 22 | 
             
                        def parse_file(file)
         | 
| 23 | 
            -
                            CoderCompanion::j_print_inline CoderCompanion::success_format '.'
         | 
| 24 23 | 
             
                            data = File.open(file).read
         | 
| 25 24 | 
             
                            tree = @parser.parse(data)
         | 
| 26 25 |  | 
| @@ -47,6 +46,7 @@ module CoderCompanion | |
| 47 46 | 
             
                            end
         | 
| 48 47 |  | 
| 49 48 | 
             
                            ast = self.build_tree(tree)
         | 
| 49 | 
            +
                            CoderCompanion::j_print_inline CoderCompanion::success_format '.'
         | 
| 50 50 | 
             
                            {:type => 'source', :body => ast, :file_path => file}
         | 
| 51 51 | 
             
                        end
         | 
| 52 52 |  | 
| @@ -27,10 +27,9 @@ module CoderCompanion | |
| 27 27 | 
             
                            return value
         | 
| 28 28 | 
             
                        end
         | 
| 29 29 |  | 
| 30 | 
            -
                        def create_uploadable(results)
         | 
| 30 | 
            +
                        def create_uploadable(results, cache_handler)
         | 
| 31 31 | 
             
                            obj = {}
         | 
| 32 32 | 
             
                            results.each do |source|
         | 
| 33 | 
            -
                                cache_handler = CoderCompanion.cache_handler
         | 
| 34 33 | 
             
                                modified = cache_handler.is_file_modified?(source[:file_path])
         | 
| 35 34 | 
             
                                cache_handler.update_cache_path(source[:file_path])
         | 
| 36 35 | 
             
                                source[:body].each do |element|
         | 
| @@ -3,16 +3,21 @@ module CoderCompanion | |
| 3 3 |  | 
| 4 4 | 
             
                    # @return [TreeWalker]
         | 
| 5 5 | 
             
                    attr_reader :tree_walker
         | 
| 6 | 
            +
                    
         | 
| 7 | 
            +
                    # @return [Array<String>]
         | 
| 8 | 
            +
                    attr_accessor :excluded
         | 
| 6 9 |  | 
| 7 10 | 
             
                    # Parses and creates the json that will be uploaded
         | 
| 8 11 | 
             
                    # @param [String] dir_name
         | 
| 12 | 
            +
                    # @param [Array<String>] excluded_files
         | 
| 9 13 | 
             
                    # @return [Hash]
         | 
| 10 | 
            -
                    def create_project_json(dir_name)
         | 
| 14 | 
            +
                    def create_project_json(dir_name, excluded_files, cache_handler)
         | 
| 15 | 
            +
                        self.excluded = excluded_files
         | 
| 11 16 | 
             
                        files = get_parseable_files(dir_name)
         | 
| 12 17 | 
             
                        CoderCompanion::j_print CoderCompanion::notification_format("Parsing files...")
         | 
| 13 18 | 
             
                        results = parse(files)
         | 
| 14 19 | 
             
                        CoderCompanion::j_print CoderCompanion::success_format("\nSuccessfully parsed source code")
         | 
| 15 | 
            -
                        tree_walker.create_uploadable(results)
         | 
| 20 | 
            +
                        tree_walker.create_uploadable(results, cache_handler)
         | 
| 16 21 | 
             
                    end
         | 
| 17 22 |  | 
| 18 23 | 
             
                    # Parse the files 
         | 
| @@ -34,7 +39,7 @@ module CoderCompanion | |
| 34 39 | 
             
                        Dir.foreach(dir_name) do |item|
         | 
| 35 40 | 
             
                            next if item == '.' or item == '..'
         | 
| 36 41 | 
             
                            path = File.join(dir_name, item).gsub(/^(\.\/)?/, '') # Remove the leading ./ in the file name
         | 
| 37 | 
            -
                            next if  | 
| 42 | 
            +
                            next if excluded.include?(path)
         | 
| 38 43 | 
             
                            if File.directory?(path)
         | 
| 39 44 | 
             
                                construct_array(path, res_arr)
         | 
| 40 45 | 
             
                            else
         | 
| @@ -1,5 +1,3 @@ | |
| 1 | 
            -
            require 'byebug'
         | 
| 2 | 
            -
            require 'rdoc/rdoc'
         | 
| 3 1 | 
             
            module CoderCompanion
         | 
| 4 2 | 
             
                module Ruby
         | 
| 5 3 | 
             
                    class RubyParser < LanguageParser
         | 
| @@ -38,6 +36,7 @@ module CoderCompanion | |
| 38 36 | 
             
                            YARD::Registry.clear
         | 
| 39 37 | 
             
                            YARD.parse(file)
         | 
| 40 38 | 
             
                            results = YARD::Registry.all(:root, :module, :class, :method, :classvariable)
         | 
| 39 | 
            +
                            CoderCompanion::j_print_inline CoderCompanion::success_format '.'
         | 
| 41 40 | 
             
                            {:type => 'source', :body => results, :file_path => file}
         | 
| 42 41 | 
             
                        end
         | 
| 43 42 | 
             
                    end
         | 
| @@ -3,17 +3,17 @@ module CoderCompanion | |
| 3 3 | 
             
                    class RubyTreeWalker < CoderCompanion::TreeWalker
         | 
| 4 4 |  | 
| 5 5 | 
             
                        # @param [Array<Hash>] results
         | 
| 6 | 
            +
                        # @param [CacheHandler] cache_handler
         | 
| 6 7 | 
             
                        # @return [Hash] 
         | 
| 7 | 
            -
                        def create_uploadable(results)
         | 
| 8 | 
            -
                            return build(results) 
         | 
| 8 | 
            +
                        def create_uploadable(results, cache_handler)
         | 
| 9 | 
            +
                            return build(results, cache_handler) 
         | 
| 9 10 | 
             
                        end
         | 
| 10 11 |  | 
| 11 12 | 
             
                        # @param results [Array<Hash>] the results from parsing the code
         | 
| 12 13 | 
             
                        # @return [Hash]
         | 
| 13 | 
            -
                        def build(results)
         | 
| 14 | 
            +
                        def build(results, cache_handler)
         | 
| 14 15 | 
             
                            obj = {}
         | 
| 15 16 | 
             
                            results.each do |source|
         | 
| 16 | 
            -
                                cache_handler = CoderCompanion.cache_handler
         | 
| 17 17 | 
             
                                modified = cache_handler.is_file_modified?(source[:file_path])
         | 
| 18 18 | 
             
                                cache_handler.update_cache_path(source[:file_path])
         | 
| 19 19 |  | 
| @@ -1,7 +1,8 @@ | |
| 1 1 | 
             
            module CoderCompanion
         | 
| 2 2 | 
             
                class TreeWalker
         | 
| 3 3 | 
             
                    # @param [Array<Hash>] results The result hash to be converted into an uploadeable
         | 
| 4 | 
            -
                     | 
| 4 | 
            +
                    # @param cache_handler [CacheHandler]
         | 
| 5 | 
            +
                    def create_uploadable(results, cache_handler)
         | 
| 5 6 | 
             
                        raise NotImplementedError, "#{self.class}: 'create_uploadable' must be overriden"
         | 
| 6 7 | 
             
                    end
         | 
| 7 8 | 
             
                end
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            module CoderCompanion
         | 
| 2 | 
            +
                module VisualMessage
         | 
| 3 | 
            +
                    
         | 
| 4 | 
            +
                    def self.get_greeting_text
         | 
| 5 | 
            +
            =begin
         | 
| 6 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                                               __-¯--__
         | 
| 9 | 
            +
                                          __-¯¯        ¯¯--__
         | 
| 10 | 
            +
                                     __-¯¯                   ¯¯-___,
         | 
| 11 | 
            +
                                   /¯-__                   __-¯¯__  |
         | 
| 12 | 
            +
                                   |    ¯¯--__        __-¯¯__-¯¯  | |
         | 
| 13 | 
            +
                                   |          ¯--__-¯¯__-¯¯       | |
         | 
| 14 | 
            +
                                   |             | r¯¯       ¯¯   | |
         | 
| 15 | 
            +
                                   |             | |   O          | |
         | 
| 16 | 
            +
                                   L             | |            _-| |
         | 
| 17 | 
            +
                                    `~__         | |       __-¯¯__-¯¯ 
         | 
| 18 | 
            +
                                        `~__     | |  __-¯¯__-¯¯  __-¯¯`~__
         | 
| 19 | 
            +
                                            `~__ | '¯¯__-¯¯  __-¯¯         ;-
         | 
| 20 | 
            +
                                                `L_-¯¯  __-¯¯         __-¯¯
         | 
| 21 | 
            +
                                                   __-¯¯         __-¯¯
         | 
| 22 | 
            +
                                                  `~_       __-¯¯
         | 
| 23 | 
            +
                                                     `~__-¯¯
         | 
| 24 | 
            +
                        #{special_format("R u n n i n g   C o d e r   C o m p a n i o n   u p l o a d e r")}
         | 
| 25 | 
            +
                    
         | 
| 26 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 27 | 
            +
            =end
         | 
| 28 | 
            +
                    return <<INFO 
         | 
| 29 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                        #{::CoderCompanion.special_format("R u n n i n g   C o d e r   C o m p a n i o n   u p l o a d e r")}
         | 
| 32 | 
            +
                    
         | 
| 33 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 34 | 
            +
            INFO
         | 
| 35 | 
            +
                    end       
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    def self.supported_languages_header
         | 
| 38 | 
            +
                        return <<INFO
         | 
| 39 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                                #{CoderCompanion::notification_format("CoderCompanion Supported Languages (2015-05-30)")}
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            -----------------------------------------------------------------------------------------------
         | 
| 44 | 
            +
            INFO
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    def self.supported_language_row lang
         | 
| 48 | 
            +
                        return <<INFO
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    Language: #{::CoderCompanion.notification_format(lang[:key])}\t\t|\t Requires Annotations: #{lang[:annotation_required] ? ::CoderCompanion.success_format("YES") : ::CoderCompanion.red_format("NO") }\t\t|\tAnnotations Style(s): #{(lang[:annotation_required]) ? ::CoderCompanion.notification_format(lang[:valid_annotation].join(", ")) : ::CoderCompanion.notification_format("N/A")}
         | 
| 51 | 
            +
                    
         | 
| 52 | 
            +
            INFO
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    def self.dry_run_text
         | 
| 56 | 
            +
                        return <<INFO
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            #{CoderCompanion.notification_format("Performing dry run:")}
         | 
| 59 | 
            +
                - No cache use
         | 
| 60 | 
            +
                - No upload           
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            INFO
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    end
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: codercmp
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.9. | 
| 4 | 
            +
              version: 0.9.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sega Okhiria
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-07- | 
| 11 | 
            +
            date: 2015-07-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: treetop
         | 
| @@ -94,6 +94,34 @@ dependencies: | |
| 94 94 | 
             
                - - ~>
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 96 | 
             
                    version: 0.8.7
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: json
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - '>='
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: aws-sdk
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ~>
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '2'
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ~>
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '2'
         | 
| 97 125 | 
             
            description: codercmp is a gem intended for use as a command line interface to parse
         | 
| 98 126 | 
             
              and upload code architecture and object structure to CoderCompanion.
         | 
| 99 127 | 
             
            email:
         | 
| @@ -125,6 +153,7 @@ files: | |
| 125 153 | 
             
            - lib/codercompanion/ruby/ruby_tree_walker.rb
         | 
| 126 154 | 
             
            - lib/codercompanion/s3_client.rb
         | 
| 127 155 | 
             
            - lib/codercompanion/tree_walker.rb
         | 
| 156 | 
            +
            - lib/codercompanion/visual_message.rb
         | 
| 128 157 | 
             
            - lib/codercompanion_version.rb
         | 
| 129 158 | 
             
            homepage: ''
         | 
| 130 159 | 
             
            licenses:
         |