<commit_before>require "thor"

require "java"
require "hot_bunnies"
require "multi_json"
require 'travis/worker'

module Travis
  class Worker
    module Cli
      # These tasks are used for development and only for development.
      # They have many limitations and SHOULD NOT be considered good
      # programming style or examples for adding new commands to Travis Worker CLI.
      class Development < Thor
        namespace "travis:worker:dev"



        desc "build_ruby", "Publish a sample Ruby build job"
        method_option :slug,   :default => "ruby-amqp/amq-protocol"
        method_option :commit, :default => "bc0a938c19d18e2e6973debe2b5bc4a1bd8ea469"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_ruby
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id     => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch],
              :config => {
                :language     => "ruby",
                :rvm          => "1.8.7",
                :script       => "bundle exec rspec spec",
                :bundler_args => "--without development"
              }
            }
          }
          puts payload.inspect

          publish(payload, "builds.common", self.options[:n].to_i)
        end




        desc "build_clojure", "Publish a sample Clojure build job"
        method_option :slug,   :default => "michaelklishin/urly"
        method_option :commit, :default => "d487ca890f6e7c358274a32f722506bd5568fdfc"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_clojure
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id       => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch],
              :config => {
                :language => "clojure"
              }
            }
          }
          puts payload.inspect

          publish(payload, "builds.common", self.options[:n].to_i)
        end



        desc "build_node", "Publish a sample Node build job"
        method_option :slug,   :default => "Shopify/batman"
        method_option :commit, :default => "06b3b093a7137311"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_node
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id       => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch],
              :config => {
                :language => "javascript_with_nodejs",
                :node_js => "0.5.5",
                :script => "cake test"
              }
            }
          }
          puts payload.inspect

          publish(payload, "builds", self.options[:n].to_i)
        end



        desc "config", "Publish a sample config job"
        method_option :slug,   :default => "ruby-amqp/amq-protocol"
        method_option :commit, :default => "e54c27a8d1c0f4df0fc9"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def config
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id     => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch]
            }
          }
          puts payload.inspect

          publish(payload, "builds.configure", self.options[:n].to_i)
        end



        protected

        def publish(payload, routing_key, n = 1)
          connection = HotBunnies.connect(:vhost => "travisci.development", :username => "travisci_worker", :password => "<PASSWORD>")
          channel    = connection.create_channel
          exchange   = channel.default_exchange

          n.times { exchange.publish(MultiJson.encode(payload), :routing_key => routing_key) }

          sleep(1.0)
          channel.close
          connection.close

          java.lang.System.exit(0)
        end

      end # Development
    end
  end # Worker
end # Travis
<commit_msg>Update message payloads in development tasks<commit_after>require "thor"

require "java"
require "hot_bunnies"
require "multi_json"
require 'travis/worker'

module Travis
  class Worker
    module Cli
      # These tasks are used for development and only for development.
      # They have many limitations and SHOULD NOT be considered good
      # programming style or examples for adding new commands to Travis Worker CLI.
      class Development < Thor
        namespace "travis:worker:dev"



        desc "build_ruby", "Publish a sample Ruby build job"
        method_option :slug,   :default => "ruby-amqp/amq-protocol"
        method_option :commit, :default => "bc0a938c19d18e2e6973debe2b5bc4a1bd8ea469"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_ruby
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id     => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch]
            },
            :config => {
              :language     => "ruby",
              :rvm          => "1.8.7",
              :script       => "bundle exec rspec spec",
              :bundler_args => "--without development"
            }
          }

          publish(payload, "builds.common", self.options[:n].to_i)
        end




        desc "build_clojure", "Publish a sample Clojure build job"
        method_option :slug,   :default => "michaelklishin/urly"
        method_option :commit, :default => "d487ca890f6e7c358274a32f722506bd5568fdfc"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_clojure
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id       => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch]
            },
            :config => {
              :language => "clojure",
              :script   => "lein javac, test"
            }
          }

          publish(payload, "builds.common", self.options[:n].to_i)
        end



        desc "build_node", "Publish a sample Node build job"
        method_option :slug,   :default => "mmalecki/node-functions"
        method_option :commit, :default => "103362faa086fb8646bd67343d363cf3f1baafeb"
        method_option :branch, :default => "master"
        method_option :n,      :default => 1
        def build_node
          payload = {
            :repository => {
              :slug => self.options[:slug]
            },
            :build => {
              :id       => 1,
              :commit => self.options[:commit],
              :branch => self.options[:branch]
            },
            :config => {
              :language => "node_js",
              :node_js => "0.4"
            }
          }

          publish(payload, "builds.node_js", self.options[:n].to_i)
        end



        protected

        def publish(payload, routing_key, n = 1)
          puts payload.inspect

          connection = HotBunnies.connect(:vhost => "travisci.development", :username => "travisci_worker", :password => "<PASSWORD>")
          channel    = connection.create_channel
          exchange   = channel.default_exchange

          n.times { exchange.publish(MultiJson.encode(payload), :routing_key => routing_key) }

          sleep(1.0)
          channel.close
          connection.close

          java.lang.System.exit(0)
        end

      end # Development
    end
  end # Worker
end # Travis

{'fraction_non_alphanumeric': 0.11152278621711745, 'fraction_numerical': 0.021365938001729035, 'mean_word_length': 1.6266623418747972, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7374172', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2257, 'n_words': 522}