stddtool 0.0.9 → 0.1.0.1
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/lib/stddtool.rb +68 -25
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 212b8f7cbfab0c4580463bb42f5b3ef7546b67bb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ad70bf67159e02aaa7e3295394797907933ea7b7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 390622f6900933a6237bd0ab8a18eb533f55eeb58086dccca9dc6fd10eb43c5d6a19f6ad6d4fa018748d965452921abef4a16bd9471f0471d6d14c03759fe49d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c051a4ad6f54a844b006cccb29e744e8b199dd7a9eddc755f173011b8a6b0858c3ddf3a58550684c048c5309c6c439ecec7234bcef6c977c280d3e9e7d88bea6
         
     | 
    
        data/lib/stddtool.rb
    CHANGED
    
    | 
         @@ -1,7 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
       1 
2 
     | 
    
         
             
            # features/support/twitter_formatter.rb
         
     | 
| 
       2 
3 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'json'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'ostruct'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'cucumber/formatter/io'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'gherkin/formatter/argument'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'base64'
         
     | 
| 
       5 
9 
     | 
    
         | 
| 
       6 
10 
     | 
    
         
             
              class STDDTool
         
     | 
| 
       7 
11 
     | 
    
         | 
| 
         @@ -9,13 +13,33 @@ require 'json' 
     | 
|
| 
       9 
13 
     | 
    
         
             
                  @buildnr = ENV['BUILD']
         
     | 
| 
       10 
14 
     | 
    
         
             
                  @url = ENV['URL']
         
     | 
| 
       11 
15 
     | 
    
         
             
                  @job = ENV['JOBNAME']
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @proxy = ENV['http_proxy'] ? URI.parse('http://'+ENV['http_proxy']) : OpenStruct.new
         
     | 
| 
       12 
17 
     | 
    
         
             
                  # Generate string as runId
         
     | 
| 
       13 
18 
     | 
    
         
             
                  o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
         
     | 
| 
       14 
19 
     | 
    
         
             
                  @runID = (0...50).map{ o[rand(o.length)] }.join
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 20 
     | 
    
         
            +
                  @delayed_messages = []
         
     | 
| 
      
 21 
     | 
    
         
            +
                  p @runID
         
     | 
| 
      
 22 
     | 
    
         
            +
                  p "Initiating STDDTool formatter"
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def embed(src, mime_type, label)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  p "got embedding"
         
     | 
| 
      
 27 
     | 
    
         
            +
                  case(mime_type)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  when /^image\/(png|gif|jpg|jpeg)/
         
     | 
| 
      
 29 
     | 
    
         
            +
                    buf = Base64.encode64(open(src) { |io| io.read })
         
     | 
| 
      
 30 
     | 
    
         
            +
                    embeddingObj=EmbeddingObj.new(mime_type,buf)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    p "starts to post embedding"
         
     | 
| 
      
 32 
     | 
    
         
            +
                    postEmbedding(@scenarioID,embeddingObj)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    p "posted embedding to scenario with id : #{@scenarioID}"
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def puts(message)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @delayed_messages << message
         
     | 
| 
       17 
39 
     | 
    
         
             
                end
         
     | 
| 
       18 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       19 
43 
     | 
    
         
             
                def before_feature(feature)
         
     | 
| 
       20 
44 
     | 
    
         
             
                  # puts feature.source_tag_names
         
     | 
| 
       21 
45 
     | 
    
         
             
                  featureObj=FeatureObj.new(@job,@buildnr,feature.title,feature.description,feature.file,feature.source_tag_names,@runID)
         
     | 
| 
         @@ -31,6 +55,7 @@ require 'json' 
     | 
|
| 
       31 
55 
     | 
    
         
             
                  end
         
     | 
| 
       32 
56 
     | 
    
         | 
| 
       33 
57 
     | 
    
         
             
                def before_step(step)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  @delayed_messages = []
         
     | 
| 
       34 
59 
     | 
    
         
             
                  @start_time = Time.now
         
     | 
| 
       35 
60 
     | 
    
         
             
                end
         
     | 
| 
       36 
61 
     | 
    
         | 
| 
         @@ -39,8 +64,8 @@ require 'json' 
     | 
|
| 
       39 
64 
     | 
    
         
             
                end
         
     | 
| 
       40 
65 
     | 
    
         | 
| 
       41 
66 
     | 
    
         
             
                def scenario_name(keyword, name, file_colon_line, source_indent)
         
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
                  scenarioObj=ScenarioObj.new(@featureID,keyword,name)
         
     | 
| 
      
 67 
     | 
    
         
            +
                  p "scenario #{name}"
         
     | 
| 
      
 68 
     | 
    
         
            +
                  scenarioObj=ScenarioObj.new(@featureID,keyword,name,@embedding)
         
     | 
| 
       44 
69 
     | 
    
         
             
                  postScenario(scenarioObj)
         
     | 
| 
       45 
70 
     | 
    
         
             
                end
         
     | 
| 
       46 
71 
     | 
    
         | 
| 
         @@ -52,18 +77,14 @@ require 'json' 
     | 
|
| 
       52 
77 
     | 
    
         
             
                     step_name = step_match.format_args(lambda{|param| "*#{param}*"})
         
     | 
| 
       53 
78 
     | 
    
         
             
                    # message = "#{step_name} #{status}"
         
     | 
| 
       54 
79 
     | 
    
         
             
                    # puts keyword + " "  + message
         
     | 
| 
       55 
     | 
    
         
            -
                    stepObj=StepObj.new(keyword,step_name,status,exception, @duration)
         
     | 
| 
      
 80 
     | 
    
         
            +
                    stepObj=StepObj.new(keyword,step_name,status,exception, @duration,@delayed_messages)
         
     | 
| 
       56 
81 
     | 
    
         
             
                    postStep(@scenarioID,stepObj)
         
     | 
| 
       57 
82 
     | 
    
         
             
                  end
         
     | 
| 
       58 
83 
     | 
    
         
             
                end
         
     | 
| 
       59 
84 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
         
     | 
| 
       61 
     | 
    
         
            -
                 
         
     | 
| 
       62 
     | 
    
         
            -
                end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
85 
     | 
    
         
             
                def postFeature(featureObj)
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                  http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  uri = URI.parse(@url)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  http = Net::HTTP::Proxy(@proxy.host, @proxy.port).new(uri.host, uri.port)
         
     | 
| 
       67 
88 
     | 
    
         
             
                  request = Net::HTTP::Post.new("/collectionapi/features")
         
     | 
| 
       68 
89 
     | 
    
         
             
                  request.add_field('X-Auth-Token', '97f0ad9e24ca5e0408a269748d7fe0a0')
         
     | 
| 
       69 
90 
     | 
    
         
             
                  request.body = featureObj.to_json
         
     | 
| 
         @@ -72,13 +93,13 @@ require 'json' 
     | 
|
| 
       72 
93 
     | 
    
         
             
                    when /20\d/
         
     | 
| 
       73 
94 
     | 
    
         
             
                      #success
         
     | 
| 
       74 
95 
     | 
    
         
             
                    else
         
     | 
| 
       75 
     | 
    
         
            -
                       
     | 
| 
      
 96 
     | 
    
         
            +
                      p response.body
         
     | 
| 
       76 
97 
     | 
    
         
             
                      exit 
         
     | 
| 
       77 
98 
     | 
    
         
             
                  end
         
     | 
| 
       78 
99 
     | 
    
         
             
                  parsed = JSON.parse(response.body)
         
     | 
| 
       79 
100 
     | 
    
         | 
| 
       80 
101 
     | 
    
         
             
                  if parsed["error"]
         
     | 
| 
       81 
     | 
    
         
            -
                     
     | 
| 
      
 102 
     | 
    
         
            +
                    p parsed["error"]
         
     | 
| 
       82 
103 
     | 
    
         
             
                  end
         
     | 
| 
       83 
104 
     | 
    
         
             
                  @featureID =  parsed["_id"]
         
     | 
| 
       84 
105 
     | 
    
         | 
| 
         @@ -90,14 +111,20 @@ require 'json' 
     | 
|
| 
       90 
111 
     | 
    
         
             
                  path = "/collectionapi/scenarios/#{scenarioID}"
         
     | 
| 
       91 
112 
     | 
    
         
             
                  req = Net::HTTP::Put.new(path, initheader = { 'X-Auth-Token' => '97f0ad9e24ca5e0408a269748d7fe0a0'})
         
     | 
| 
       92 
113 
     | 
    
         
             
                  req.body = stepObj.to_json
         
     | 
| 
       93 
     | 
    
         
            -
                  response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
      
 114 
     | 
    
         
            +
                  response = Net::HTTP::Proxy(@proxy.host, @proxy.port).new(uri.host, uri.port).start {|http| http.request(req) }
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
       95 
116 
     | 
    
         | 
| 
      
 117 
     | 
    
         
            +
                def postEmbedding(scenarioID,embeddingObj)
         
     | 
| 
      
 118 
     | 
    
         
            +
                  uri = URI.parse(@url)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  path = "/collectionapi/scenarios/#{scenarioID}"
         
     | 
| 
      
 120 
     | 
    
         
            +
                  req = Net::HTTP::Put.new(path, initheader = { 'X-Auth-Token' => '97f0ad9e24ca5e0408a269748d7fe0a0'})
         
     | 
| 
      
 121 
     | 
    
         
            +
                  req.body = embeddingObj.to_json
         
     | 
| 
      
 122 
     | 
    
         
            +
                  response = Net::HTTP::Proxy(@proxy.host, @proxy.port).new(uri.host, uri.port).start {|http| http.request(req) }
         
     | 
| 
       96 
123 
     | 
    
         
             
                end
         
     | 
| 
       97 
124 
     | 
    
         | 
| 
       98 
125 
     | 
    
         
             
                def postScenario(scenarioObj)
         
     | 
| 
       99 
126 
     | 
    
         
             
                  uri = URI.parse(@url)
         
     | 
| 
       100 
     | 
    
         
            -
                  http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
      
 127 
     | 
    
         
            +
                  http = Net::HTTP::Proxy(@proxy.host, @proxy.port).new(uri.host, uri.port)
         
     | 
| 
       101 
128 
     | 
    
         
             
                  request = Net::HTTP::Post.new("/collectionapi/scenarios")
         
     | 
| 
       102 
129 
     | 
    
         
             
                  request.add_field('X-Auth-Token', '97f0ad9e24ca5e0408a269748d7fe0a0')
         
     | 
| 
       103 
130 
     | 
    
         
             
                  request.body = scenarioObj.to_json
         
     | 
| 
         @@ -143,28 +170,44 @@ end 
     | 
|
| 
       143 
170 
     | 
    
         | 
| 
       144 
171 
     | 
    
         | 
| 
       145 
172 
     | 
    
         
             
            class StepObj
         
     | 
| 
       146 
     | 
    
         
            -
              def initialize(keyword, name, status,exception,duration)
         
     | 
| 
      
 173 
     | 
    
         
            +
              def initialize(keyword, name, status,exception,duration,messages)
         
     | 
| 
       147 
174 
     | 
    
         
             
                @step_keyword=keyword
         
     | 
| 
       148 
175 
     | 
    
         
             
                @step_name=name
         
     | 
| 
       149 
176 
     | 
    
         
             
                @step_status=status
         
     | 
| 
       150 
177 
     | 
    
         
             
                @step_exception = exception
         
     | 
| 
       151 
178 
     | 
    
         
             
                @step_duration = duration
         
     | 
| 
      
 179 
     | 
    
         
            +
                @step_messages = messages
         
     | 
| 
       152 
180 
     | 
    
         
             
              end
         
     | 
| 
       153 
181 
     | 
    
         
             
              def to_json
         
     | 
| 
       154 
     | 
    
         
            -
                  {'$addToSet' =>  
     | 
| 
       155 
     | 
    
         
            -
                    ' 
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
      
 182 
     | 
    
         
            +
                  {'$addToSet' => 
         
     | 
| 
      
 183 
     | 
    
         
            +
                    {'steps' =>{'keyword' => @step_keyword,
         
     | 
| 
      
 184 
     | 
    
         
            +
                                'name' => @step_name ,
         
     | 
| 
      
 185 
     | 
    
         
            +
                                'result' => {'status' =>@step_status,'error_message'=> @step_exception,'duration'=>@step_duration},
         
     | 
| 
      
 186 
     | 
    
         
            +
                                'messages' => @step_messages
         
     | 
| 
      
 187 
     | 
    
         
            +
                              }
         
     | 
| 
      
 188 
     | 
    
         
            +
                    }
         
     | 
| 
      
 189 
     | 
    
         
            +
                  }.to_json
         
     | 
| 
       158 
190 
     | 
    
         
             
              end
         
     | 
| 
       159 
191 
     | 
    
         
             
            end
         
     | 
| 
       160 
192 
     | 
    
         | 
| 
       161 
193 
     | 
    
         
             
            class ScenarioObj
         
     | 
| 
       162 
     | 
    
         
            -
              def initialize(featureID,keyword, name)
         
     | 
| 
      
 194 
     | 
    
         
            +
              def initialize(featureID,keyword, name,embedding)
         
     | 
| 
       163 
195 
     | 
    
         
             
                @feature_ID = featureID
         
     | 
| 
       164 
196 
     | 
    
         
             
                @scenario_keyword=keyword
         
     | 
| 
       165 
197 
     | 
    
         
             
                @scenario_name=name
         
     | 
| 
      
 198 
     | 
    
         
            +
                @scenario_embedding = embedding
         
     | 
| 
       166 
199 
     | 
    
         
             
              end
         
     | 
| 
       167 
200 
     | 
    
         
             
              def to_json
         
     | 
| 
       168 
     | 
    
         
            -
                  {'featureId' => @feature_ID,'keyword' => @scenario_keyword, 'name' => @scenario_name}.to_json
         
     | 
| 
      
 201 
     | 
    
         
            +
                  {'featureId' => @feature_ID,'keyword' => @scenario_keyword, 'name' => @scenario_name,'embedding' => @scenario_embedding }.to_json
         
     | 
| 
       169 
202 
     | 
    
         
             
              end
         
     | 
| 
       170 
     | 
    
         
            -
            end
         
     | 
| 
      
 203 
     | 
    
         
            +
            end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            class EmbeddingObj
         
     | 
| 
      
 206 
     | 
    
         
            +
              def initialize(mime_type,data)
         
     | 
| 
      
 207 
     | 
    
         
            +
                @mime_type = mime_type
         
     | 
| 
      
 208 
     | 
    
         
            +
                @data=data
         
     | 
| 
      
 209 
     | 
    
         
            +
              end
         
     | 
| 
      
 210 
     | 
    
         
            +
              def to_json
         
     | 
| 
      
 211 
     | 
    
         
            +
                  {'$addToSet' =>{'embeddings' =>{'mime_type' => @mime_type,'data' => @data}}}.to_json
         
     | 
| 
      
 212 
     | 
    
         
            +
              end
         
     | 
| 
      
 213 
     | 
    
         
            +
            end
         
     |