text:
package net.openhft.chronicle.queue;

import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.core.time.SetTimeProvider;
import net.openhft.chronicle.queue.impl.single.InternalAppender;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import net.openhft.chronicle.wire.DocumentContext;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static net.openhft.chronicle.bytes.Bytes.from;
import static net.openhft.chronicle.core.time.SystemTimeProvider.CLOCK;
import static net.openhft.chronicle.queue.rollcycles.TestRollCycles.TEST4_SECONDLY;
import static net.openhft.chronicle.queue.rollcycles.TestRollCycles.TEST_SECONDLY;
import static org.junit.Assert.*;

public class ChronicleQueueIndexTest extends QueueTestCommon {

    @Test
    public void checkTheEOFisWrittenToPreQueueFileWritingDocumentMetadata() {

        final Consumer<InternalAppender> writer = appender -> {
            try (DocumentContext wd = appender.writingDocument(true)) {
                wd.wire().write("key").writeDouble(1);
            }
        };
        checkTheEOFisWrittenToPreQueueFileInner(writer, (tp, rollCycle) -> tp.advanceMillis(2 * rollCycle.lengthInMillis()), writer);
    }

    @Test
    public void checkTheEOFisWrittenToPreQueueFileWritingDocument() {
        final Consumer<InternalAppender> writer = appender -> {
            try (DocumentContext wd = appender.writingDocument()) {
                wd.wire().write("key").writeDouble(1);
            }
        };
        checkTheEOFisWrittenToPreQueueFileInner(writer, (tp, rollCycle) -> tp.advanceMillis(2 * rollCycle.lengthInMillis()), writer);
    }

    private void checkTheEOFisWrittenToPreQueueFileInner(Consumer<InternalAppender> writer1,
                                                         BiConsumer<SetTimeProvider, RollCycle> tpConsumer,
                                                         Consumer<InternalAppender> writer2) {
        SetTimeProvider tp = new SetTimeProvider(1_000_000_000);

        File file1 = getTmpDir();
        RollCycles rollCycle = RollCycles.DEFAULT;
        try (ChronicleQueue queue = SingleChronicleQueueBuilder.builder()
                .path(file1)
                .rollCycle(rollCycle)
                .timeProvider(tp)
                .testBlockSize()
                .build()) {
            InternalAppender appender = (InternalAppender) queue.acquireAppender();

            writer1.accept(appender);

            Assert.assertFalse(hasEOFAtEndOfFile(file1));
        }

        tpConsumer.accept(tp, rollCycle);

        try (ChronicleQueue queue = SingleChronicleQueueBuilder.builder()
                .path(file1)
                .rollCycle(rollCycle)
                .timeProvider(tp)
                .testBlockSize()
                .build()) {
            InternalAppender appender = (InternalAppender) queue.acquireAppender();

//            assertFalse(hasEOFAtEndOfFile(file1));

            writer2.accept(appender);

            // Simulate the end of the day i.e the queue closes the day rolls
            // (note the change of index from 18264 to 18265)

            assertTrue(hasEOFAtEndOfFile(file1));
        }
    }

    protected boolean hasEOFAtEndOfFile(final File file) {

        try (ChronicleQueue queue123 = SingleChronicleQueueBuilder.builder()
                .path(file).build()) {
            String dump = queue123.dump();
            // System.out.println(dump);
            return dump.contains(" EOF") && dump.contains("--- !!not-ready-meta-data");
        }
    }

    @Test
    public void testIndexQueue() {

        File file1 = getTmpDir();
        file1.deleteOnExit();
        try (ChronicleQueue queue = SingleChronicleQueueBuilder.builder()
                .path(file1)
                .rollCycle(RollCycles.DEFAULT)
                .build()) {
            InternalAppender appender = (InternalAppender) queue.acquireAppender();

            Bytes<byte[]> hello_world = Bytes.from("Hello World 1");
            appender.writeBytes(RollCycles.DEFAULT.toIndex(18264, 0L), hello_world);
            hello_world.releaseLast();
            hello_world = Bytes.from("Hello World 2");
            appender.writeBytes(RollCycles.DEFAULT.toIndex(18264, 1L), hello_world);
            hello_world.releaseLast();

            // Simulate the end of the day i.e the queue closes the day rolls
            // (note the change of index from 18264 to 18265)
        }
        try (ChronicleQueue queue = SingleChronicleQueueBuilder.builder()
                .path(file1)
                .rollCycle(RollCycles.DEFAULT)
                .build()) {
            InternalAppender appender = (InternalAppender) queue.acquireAppender();

            // add a message for the new day
            Bytes<byte[]> hello_world = Bytes.from("Hello World 3");
            appender.writeBytes(RollCycles.DEFAULT.toIndex(18265, 0L), hello_world);
            hello_world.releaseLast();

            final ExcerptTailer tailer = queue.createTailer();

            final Bytes<?> forRead = Bytes.elasticByteBuffer();
            try {
                final List<String> results = new ArrayList<>();
                while (tailer.readBytes(forRead)) {
                    results.add(forRead.to8bitString());
                    forRead.clear();
                }
                assertTrue(results.toString(), results.contains("Hello World 1"));
                assertTrue(results.contains("Hello World 2"));
                // The reader fails to read the third message. The reason for this is
                // that there was no EOF marker placed at end of the 18264 indexed file
                // so when the reader started reading through the queues it got stuck on
                // that file and never progressed to the latest queue file.
                assertTrue(results.contains("Hello World 3"));
            } finally {
                forRead.releaseLast();
            }
        }
    }

    @Test
    public void read5thMessageTest() {
        SetTimeProvider stp = new SetTimeProvider();
        stp.currentTimeMillis(CLOCK.currentTimeMillis());
        try (final ChronicleQueue queue = ChronicleQueue
                .singleBuilder(getTmpDir())
                .rollCycle(TEST_SECONDLY)
                .timeProvider(stp)
                .build()) {

            final ExcerptAppender appender = queue.acquireAppender();

            int i = 0;
            String msg = "world ";
            for (int j = 0; j < 8; j++) {
                try (DocumentContext dc = appender.writingDocument()) {
                    dc.wire().write("hello").text(msg + (i++));
                    // long indexWritten = dc.index();
                }
                stp.advanceMillis(1500);
            }

            // get the current cycle
            int cycle;
            final ExcerptTailer tailer = queue.createTailer();
            try (DocumentContext documentContext = tailer.readingDocument()) {
                long index = documentContext.index();
                cycle = queue.rollCycle().toCycle(index + 1);
            }

            long index = queue.rollCycle().toIndex(cycle, 5);
            assertFalse(tailer.moveToIndex(index));
            try (DocumentContext dc = tailer.readingDocument()) {
                // there is no 5th message in that cycle.
                assertFalse(dc.isPresent());
            }

            // wind to start
            long index0 = queue.rollCycle().toIndex(cycle, 0);
            assertTrue(tailer.moveToIndex(index0));

            // skip four messages
            for (int j = 0; j < 4; j++)
                try (DocumentContext dc = tailer.readingDocument()) {
                    assertTrue(dc.isPresent());
                    final String hello = dc.wire().read("hello").text();
                    System.out.println(hello);
                }
            try (DocumentContext dc = tailer.readingDocument()) {
                assertTrue(dc.isPresent());
                String s5 = dc.wire().read("hello").text();
                // System.out.println(s5);
                assertEquals(msg + 4, s5);
            }
        }
    }

    // https://github.com/OpenHFT/Chronicle-Queue/issues/822
    @Test
    public void writeReadMetadata() {
        try (final ChronicleQueue queue = ChronicleQueue
                .singleBuilder(getTmpDir())
                .rollCycle(TEST4_SECONDLY)
                .testBlockSize()
                .build()) {

            final ExcerptAppender appender = queue.acquireAppender();
            final ExcerptTailer tailer = queue.createTailer();

            boolean metadata = true;
            try (DocumentContext dc = appender.writingDocument(metadata)) {
                dc.wire().write("a").text("hello");
            }
            try (DocumentContext dc = tailer.readingDocument(metadata)) {
                Assert.assertTrue(dc.isPresent());
            }
        }
    }

    private void driver0(String[] strings, boolean[] meta, SetTimeProvider stp, long millis) {

        assert (strings.length == meta.length);

        try (final ChronicleQueue queue = ChronicleQueue
                .singleBuilder(getTmpDir())
                .rollCycle(TEST4_SECONDLY)
                .timeProvider(stp)
                .testBlockSize()
                .build()) {

            final ExcerptAppender appender = queue.acquireAppender();

            for (int i = 0; i < strings.length; ++i) {
                try (DocumentContext dc = appender.writingDocument(meta[i])) {
                    dc.wire().write("key").text(strings[i]);
                }
                stp.advanceMillis(millis);
            }
//            System.out.println(queue.dump());

            // read all (meta + data)
            List<String> allReads = readKeyed(queue, true);
            assertEquals(Arrays.asList(strings), allReads);

            // just data
            List<String> dataReads = readKeyed(queue, false);
            final List<String> expectedData = IntStream.range(0, strings.length)
                    .filter(i -> !meta[i])
                    .mapToObj(i -> strings[i])
                    .collect(Collectors.toList());
            assertEquals(expectedData, dataReads);
        }
    }

    @NotNull
    private List<String> readKeyed(ChronicleQueue queue, boolean includeMetaData) {
        try (ExcerptTailer tailer = queue.createTailer()) {
            List<String> allReads = new ArrayList<>();
            for (; ; ) {
                try (DocumentContext dc = tailer.readingDocument(includeMetaData)) {
                    if (!dc.isPresent())
                        return allReads;

                    final Wire wire = dc.wire();
                    final String key = wire.readEvent(String.class);
                    if (!key.equals("key"))
                        continue;
                    String str = wire.getValueIn().text();
                    allReads.add(str);
                }
            }
        }
    }

    private void driver(String[] strings, boolean[] meta) {
        // run each test twice - once with all entries in the same cycle, and again with just one entry per cycle
        SetTimeProvider stp = new SetTimeProvider(1000_000_000L);
        driver0(strings, meta, stp, 0);
        driver0(strings, meta, stp, 1500);
    }

    @Test
    public void D() {
        driver(
                new String[]{"data-1"},
                new boolean[]{false}
        );
    }

    @Test
    public void M() {
        driver(
                new String[]{"data-1"},
                new boolean[]{true}
        );
    }

    @Test
    public void DDD() {
        driver(
                new String[]{"data-1", "data-2", "data-3"},
                new boolean[]{false, false, false}
        );
    }

    @Test
    public void DDM() {
        driver(
                new String[]{"data-1", "data-2", "meta-1"},
                new boolean[]{false, false, true}
        );
    }

    @Test
    public void DMD() {
        driver(
                new String[]{"data-1", "meta-1", "data-2"},
                new boolean[]{false, true, false}
        );
    }

    @Test
    public void DMM() {
        driver(
                new String[]{"data-1", "meta-1", "meta-2"},
                new boolean[]{false, true, true}
        );
    }

    @Test
    public void MMM() {
        driver(
                new String[]{"meta-1", "meta-2", "meta-3"},
                new boolean[]{true, true, true}
        );
    }

    @Test
    public void MMD() {
        driver(
                new String[]{"meta-1", "meta-2", "data-1"},
                new boolean[]{true, true, false}
        );
    }

    @Test
    public void MDM() {
        driver(
                new String[]{"meta-1", "data-1", "meta-2"},
                new boolean[]{true, false, true}
        );
    }

    @Test
    public void MDD() {
        driver(
                new String[]{"meta-1", "data-1", "data-2"},
                new boolean[]{true, false, false}
        );
    }
}


text:
package com.streamsets.pipeline.stage.processor.kv;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.streamsets.pipeline.api.impl.Utils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Optional;

public class LookupUtils {
  private static final Logger LOG = LoggerFactory.getLogger(LookupUtils.class);

  private LookupUtils() {}

  @NotNull
  @SuppressWarnings("unchecked")
  public static<Key, Value> LoadingCache<Key, Value> buildCache(CacheLoader<Key, Value> cacheLoader, CacheConfig conf) {
    if(conf.retryOnCacheMiss) {
      throw new IllegalArgumentException("This stage does not support retry on cache miss feature.");
    }

    return createBuilder(conf).build(cacheLoader);
  }

  @NotNull
  @SuppressWarnings("unchecked")
  public static<Key, Value> LoadingCache<Key, Optional<Value>> buildCache(
    CacheLoader<Key, Optional<Value>> cacheLoader,
    CacheConfig conf,
    Optional<Value> defaultValue
  ) {
    return new OptionalLoadingCache(
      !conf.retryOnCacheMiss,
      createBuilder(conf).build(cacheLoader),
      defaultValue
    );
  }

  private static CacheBuilder createBuilder(CacheConfig conf) {
    CacheBuilder cacheBuilder = CacheBuilder.newBuilder();

    if(!conf.enabled) {
      // If cache is disabled, simply set size to zero
      conf.maxSize = 0;
    } else if(conf.maxSize == -1) {
      conf.maxSize = Long.MAX_VALUE;
    }

    // recordStats is available only in Guava 12.0 and above, but
    // CDH still uses guava 11.0. Hence the reflection.
    if(LOG.isDebugEnabled()) {
      try {
        Method m = CacheBuilder.class.getMethod("recordStats");
        if (m != null) {
          m.invoke(cacheBuilder);
        }
      } catch (NoSuchMethodException|IllegalAccessException|InvocationTargetException e) {
        // We're intentionally ignoring any reflection errors as we might be running
        // with old guava on class path.
      }
    }

    // CacheBuilder doesn't support specifying type thus suffers from erasure, so
    // we build it with this if / else logic.
    if (conf.evictionPolicyType == EvictionPolicyType.EXPIRE_AFTER_ACCESS) {
      cacheBuilder
          .maximumSize(conf.maxSize)
          .expireAfterAccess(conf.expirationTime, conf.timeUnit)
      ;
    } else if (conf.evictionPolicyType == EvictionPolicyType.EXPIRE_AFTER_WRITE) {
      cacheBuilder
          .maximumSize(conf.maxSize)
          .expireAfterWrite(conf.expirationTime, conf.timeUnit)
      ;
    } else {
      throw new IllegalArgumentException(
          Utils.format("Unrecognized EvictionPolicyType: '{}'", conf.evictionPolicyType)
      );
    }

    return cacheBuilder;
  }
}

redpajama_set_name: RedPajamaGithub


text:
# encoding: utf-8
require 'git'
require 'fileutils'
require 'rexml/document'
require_relative 'repository'

class Artifact
  attr_reader :name, :coordinates

  def initialize(name, coordinates)
    @name = name
    @coordinates = coordinates
  end

  class Coordinates
    attr_reader :groupId, :artifactId, :packaging, :version
    def initialize(groupId, artifactId, packaging = :jar, version = nil)
      @groupId = groupId
      @artifactId = artifactId
      @packaging = packaging.nil? ? :jar : packaging.to_sym
      @version = version
    end

    def self.parse(coordinates_str)
      # The * spreads the array across the arguments of the constructor
      new(*coordinates_str.split(':'))
    end

    def to_maven_dep(opts = {})
      scope = opts[:scope] || :compile
      include_version = opts[:include_version].nil? ? true : opts[:include_version]
      buf = "<dependency>\n".
          concat("  <groupId>#{@groupId}</groupId>\n").
          concat("  <artifactId>#{@artifactId}</artifactId>\n")
      buf.concat("  <version>#{@version}</version>\n") if include_version and !version.nil?
      buf.concat("  <type>#{@packaging}</type>\n") if !packaging.to_sym.eql? :jar
      buf.concat("  <scope>#{scope}</scope>\n") if !scope.to_sym.eql? :compile
      buf.concat("</dependency>")
    end

    def to_url(base_url = 'http://repo1.maven.org/maven2')
      [base_url, @groupId.gsub('.', '/'), @artifactId, @version,
          @artifactId + '-' + @version + '.' + @packaging.to_s] * '/'
    end

    #https://repository.jboss.org/nexus/content/repositories/unzip/org/jboss/arquillian/core/arquillian-core-api/1.1.5.Final/arquillian-core-api-1.1.5.Final-javadoc.jar-unzip/index.html
    def to_javadoc_url(base_url = 'https://repository.jboss.org/nexus/content/repositories/unzip')
      [base_url, @groupId.gsub('.', '/'), @artifactId, @version,
        @artifactId + '-' + @version + '-javadoc' + '.' + @packaging.to_s + '-unzip/index.html'] * '/'
      end

    def to_pom_url(base_url = 'http://repo1.maven.org/maven2')
      [base_url, @groupId.gsub('.', '/'), @artifactId, @version,
          @artifactId + '-' + @version + '.' + @packaging.to_s].join('/').gsub(/\.jar$/, '.pom')
    end

    def to_relative
      [@artifactId, @packaging.to_s, @version] * ':'
    end

    def to_s
      [@groupId, @artifactId, @packaging.to_s, @version] * ':'
    end
  end
end

module Awestruct::Extensions::Repository::Visitors
  module Clone
    include Base

    def visit(repository, site)
      repos_dir = nil
      if site.repos_dir
        repos_dir = site.repos_dir
      else
        repos_dir = File.join(site.tmp_dir, 'repos')
      end
      if !File.directory? repos_dir
        FileUtils.mkdir_p(repos_dir)
      end
      clone_dir = File.join(repos_dir, repository.path)
      rc = nil
      if !File.directory? clone_dir
        puts "Cloning repository #{repository.clone_url} -> #{clone_dir}"
        rc = Git.clone(repository.clone_url, clone_dir)
        if repository.master_branch.nil?
          rc.checkout(repository.master_branch)
        else
          repository.master_branch = rc.current_branch
        end
      else
        puts "Using cloned repository #{clone_dir}"
        rc = Git.open(clone_dir)
        master_branch = repository.master_branch
        if master_branch.nil?
          master_branch = rc.branches.find{|b| !b.remote and  !(b.name.include? 'detached' or b.name.include? 'no branch')}.name
          repository.master_branch = master_branch
        end
        rc.checkout(master_branch)
        begin
          # attempt a light pull
          rc.pull('origin')
        rescue
          # do hard reset to master branch, some forced change might have occured upstream
          rc.fetch('origin')
          rc.reset_hard("origin/#{master_branch}")
        end
      end
      repository.clone_dir = clone_dir
      repository.client = rc
    end
  end

  module RepositoryHelpers
    # Retrieves the contributors between the two commits, filtering
    # by the relative path, if present
    def self.resolve_contributors_between(site, repository, sha1, sha2)
      range_author_index = {}
      RepositoryHelpers.resolve_commits_between(repository, sha1, sha2).map {|c|
        # we'll use email as the key to finding their identity; the sha we just need temporarily
        # clear out bogus characters from email and downcase
        OpenStruct.new({:name => c.author.name, :email => c.author.email.downcase.gsub(/[^\w@\.\(\)]/, ''), :commits => 0, :sha => c.sha})
      }.each {|e|
        # This loop both grabs unique authors by email and counts their commits
        if !range_author_index.has_key? e.email
          range_author_index[e.email] = e
        end
        range_author_index[e.email].commits += 1
      }

      range_author_index.values.each {|e|
        # this loop registers author in global index if not present
        if repository.host.eql? 'github.com'
          site.git_author_index[e.email] ||= OpenStruct.new({
            :email => e.email,
            :name => e.name,
            :sample_commit_sha => e.sha,
            :sample_commit_url => RepositoryHelpers.build_commit_url(repository, e.sha, 'json'),
            :commits => 0,
            :repositories => []
          })
          site.git_author_index[e.email].commits += e.commits
          site.git_author_index[e.email].repositories |= [repository.html_url]
        end
        e.delete_field('sha')
      }.sort {|a, b| a.name <=> b.name}
    end

    # Retrieves the commits in the range, filtered on the relative
    # path in the repository, if present
    def self.resolve_commits_between(repository, sha1, sha2)
      rc = repository.client
      log = rc.log(nil).path(repository.relative_path)
      if sha1.nil?
        log = log.object(sha2)
      else
        log = log.between(sha1, sha2)
      end
    end

    def self.build_commit_url(repository, sha, ext)
      if "html".eql? ext
        url = repository.html_url + '/commit/' + sha + '.' + ext
      elsif !repository.commits_url.nil?
        url = repository.commits_url.gsub(/\{.*/, "/#{sha}")
      else
        url = repository.html_url + '/commit/' + sha + '.' + ext
      end
      return url
    end
  end

  module MavenHelpers

    # Traverse all modules recursivly in a repository from a given rev:root
    def self.traverse_modules(rev, repository)
      pomrev = nil
      begin
        pomrev = repository.client.revparse("#{rev}pom.xml")
      rescue
        puts "info: missing pom.xml in #{rev}"
        return
      end
      pom = REXML::Document.new(repository.client.cat_file(pomrev))
      yield rev, pom

      unique_modules = Set.new
      pom.each_element('/project/modules/module') do |mod|
        unique_modules << mod.text()
      end
      pom.each_element('/project/profiles/profile/modules/module') do |mod|
        unique_modules << mod.text()
      end

      unique_modules.each do |submodule|
        MavenHelpers.traverse_modules("#{rev}#{submodule}/", repository) { |y, x| yield(y, x)}
      end
    end

    def self.to_relative_sub_path(rev, relative_repository_path)
      rev.gsub(/.*:/, '').gsub(relative_repository_path, '')
    end
  end

  # SEMI-HACK think about how best to curate & display info about these special repos
  # FIXME at least try to make GenericMavenComponent build on this one; perhaps a website component?
  module GenericComponent
    include Base
    def handles(repository)
      repository.path == 'arquillian-showcase' or
          !File.exist? File.join(repository.clone_dir, repository.relative_path, 'pom.xml')
    end

    def visit(repository, site)
      rc = repository.client
      c = OpenStruct.new({
        :repository => repository,
        :basepath => repository.path.eql?(repository.owner) ? repository.path : repository.path.sub(/^#{repository.owner}-/, ''),
        :owner => repository.owner,
        :name => repository.name,
        :desc => repository.desc,
        :contributors => []
      })
      # FIXME not dry (from below)!
      RepositoryHelpers.resolve_contributors_between(site, repository, nil, rc.revparse('HEAD')).each do |contrib|
        i = c.contributors.index {|n| n.email == contrib.email}
        if i.nil?
          c.contributors << contrib
        else
          c.contributors[i].commits += contrib.commits
        end
      end
    end
  end

  module GenericGradleComponent
    include Base

    def initialize
      @root_head_build = nil
    end

    def handles(repository)
      repository.path != 'arquillian-showcase' and
          File.exist? File.join(repository.clone_dir, repository.relative_path, 'build.gradle')
    end

    def visit(repository, site)
      rc = repository.client
      c = OpenStruct.new({
        :repository => repository,
        :basepath => repository.path.eql?(repository.owner) ? repository.path : repository.path.sub(/^#{repository.owner}-/, ''),
        :key => repository.path.split('-').last, # this is how components are matched in jira
        :owner => repository.owner,
        :html_url => repository.relative_path.empty? ? repository.html_url : "#{repository.html_url}/tree/#{repository.master_branch}/#{repository.relative_path.chomp('/')}",
        :external => !repository.owner =~ /arquillian|shrinkwrap/,
        :name => resolve_name(repository),
        :desc => repository.desc,
        :groupId => resolve_group_id(repository),
        :parent => true,
        :lead => resolve_current_lead(repository, site.component_leads),
        # we should not assume the license for external modules (hardcoding is not ideal either)
        :license => ['jbossas', 'wildfly' 'jsfunit'].include?(repository.owner) ? 'LGPL-2.1' : 'Apache-2.0',
        :releases => [],
        :contributors => []
      })
      prev_sha = nil
      rc.tags.select {|t|
          # supports formats: 1.0.0.Alpha1
          #t.name =~ /^[1-9]\d*\.\d+\.\d+\.((Alpha|Beta|CR)[1-9]\d*|Final)$/
          # supports formats: 1.0.0.Alpha1 or 1.0.0-alpha-1 or with prefix- or 1.0.0 or 0.1
          t.name =~ /^([a-z]+-?)?[0-9]\d*\.\d+(\.\d+)?([\.-]((alpha|beta|cr)-?[1-9]\d*|final))?$/i
      }.sort_by{|t| rc.gcommit(t).author_date}.each do |t|
        # skip tag if arquillian has nothing to do with it
        next if repository.relative_path and rc.log(1).object(t.name).path(repository.relative_path).size.zero?
        # for some reason, we have to use ^0 to get to the actual commit, can't use t.sha
        sha = rc.revparse(t.name + '^0')
        commit = rc.gcommit(sha)
        committer = commit.committer
        release = OpenStruct.new({
          :tag => t.name,
          :version => t.name.gsub(/^([a-z]+-?)/, ''),
          :key => (c.key.eql?('core') ? '' : c.key + '_') + t.name, # jira release version key, should we add owner?
          #:license => 'track?',
          :sha => sha,
          :html_url => RepositoryHelpers.build_commit_url(repository, sha, 'html'),
          :json_url => RepositoryHelpers.build_commit_url(repository, sha, 'json'),
          :date => commit.author_date,
          :released_by => OpenStruct.new({
            :name => committer.name,
            :email => committer.email.downcase
          }),
          :contributors => RepositoryHelpers.resolve_contributors_between(site, repository, prev_sha, sha),
          :published_artifacts => []
        })
        release.compiledeps = []
        c.releases << release
        prev_sha = sha
      end
      c.latest_version = (!c.releases.empty? ? c.releases.last.version : resolve_head_version(repository))
      c.latest_tag = (!c.releases.empty? ? c.releases.last.tag : 'HEAD')
      c.releases.each do |r|
        # FIXME not dry!
        r.contributors.each do |contrib|
          i = c.contributors.index {|n| n.email == contrib.email}
          if i.nil?
            c.contributors << contrib
          else
            c.contributors[i].commits += contrib.commits
          end
        end
      end

      # FIXME not dry!
      RepositoryHelpers.resolve_contributors_between(site, repository, prev_sha, rc.revparse('HEAD')).each do |contrib|
        i = c.contributors.index {|n| n.email == contrib.email}
        if i.nil?
          c.contributors << contrib
        else
          c.contributors[i].commits += contrib.commits
        end
      end

      # we can be pretty sure we'll have at least one commit, otherwise why the repository ;)
      last = rc.log(1).path(repository.relative_path).first
      c.last_commit = OpenStruct.new({
        :author => last.author,
        :date => last.date,
        :message => last.message,
        :sha => last.sha,
        :html_url => RepositoryHelpers.build_commit_url(repository, last.sha, 'html'),
        :json_url => RepositoryHelpers.build_commit_url(repository, last.sha, 'json')
      })
      c.unreleased_commits = RepositoryHelpers.resolve_commits_between(repository, prev_sha, rc.revparse('HEAD')).size

      c.modules = []
      site.components[repository.path] = c
    end

    def resolve_name(repository)
      build = load_root_head_build(repository)
      name = $1 if build =~ /root.+'name',.+'(.+)'/

      # FIXME note misspelling of Aggregator in Drone extension
      name.nil? ? repository.path : name.gsub(/[ :]*(Aggregator|Agreggator|Parent|module)+/, '')
    end

    def resolve_group_id(repository)
      build = load_root_head_build(repository)
      $1 if build =~ /group = '(.+arquillian.+)'/
    end

    def resolve_head_version(repository)
      build = load_root_head_build(repository)
      build.root.text('version')
    end

    def resolve_head_version(repository)
      build = load_root_head_build(repository)
      $1 if build =~ /version = '(.+)'/
    end

    def load_root_head_build(repository)
      @root_head_build ||= repository.client.cat_file(repository.client.revparse("HEAD:#{repository.relative_path}build.gradle"))
    end

    def resolve_current_lead(repository, component_leads)
      if !component_leads.nil? and component_leads.has_key? repository.path
        lead = component_leads[repository.path]
      else
        if lead.nil?
          # FIXME parameterize (keep in mind the JIRA extension hits most of the leads)
          if repository.path.eql? 'arquillian-gradle-plugin'
            lead = OpenStruct.new({
              :name => 'Benjamin Muschko',
              :github_id => 'bmuschko'
            })
          end
        end
        # update the global index (why not?)
        if !lead.nil?
          component_leads[repository.path] = lead
        end
      end
      lead
    end
  end

  module GenericMavenComponent
    include Base

    def initialize
      @root_head_pom = nil
    end

    def handles(repository)
      repository.path != 'arquillian-showcase' and
          repository.path != 'arquillian-container-reloaded' and
          File.exist? File.join(repository.clone_dir, repository.relative_path, 'pom.xml')
      #repository.path =~ /^arquillian-(core$|(testrunner|container|extension)-.+$)/ and
      #    repository.path != 'arquillian-testrunner-jbehave'
    end

    def visit(repository, site)
      @root_head_pom = nil
      rc = repository.client
      c = OpenStruct.new({
        :repository => repository,
        :basepath => repository.path.eql?(repository.owner) ? repository.path : repository.path.sub(/^#{repository.owner}-/, ''),
        :key => repository.path.split('-').last, # this is how components are matched in jira
        :owner => repository.owner,
        :html_url => repository.relative_path.empty? ? repository.html_url : "#{repository.html_url}/tree/#{repository.master_branch}/#{repository.relative_path.chomp('/')}",
        :external => !repository.owner =~ /arquillian|shrinkwrap/,
        :name => resolve_name(repository),
        :desc => repository.desc,
        :groupId => resolve_group_id(repository),
        :parent => true,
        :lead => resolve_current_lead(repository, site.component_leads),
        # we should not assume the license for external modules (hardcoding is not ideal either)
        :license => ['jbossas', 'wildfly' 'jsfunit'].include?(repository.owner) ? 'LGPL-2.1' : 'Apache-2.0',
        :releases => [],
        :contributors => []
      })
      prev_sha = nil
      rc.tags.select {|t|
          # supports formats: 1.0.0.Alpha1
          #t.name =~ /^[1-9]\d*\.\d+\.\d+\.((Alpha|Beta|CR)[1-9]\d*|Final)$/
          # supports formats: 1.0.0.Alpha1 or 1.0.0-alpha-1 or with prefix- or 1.0.0 or 0.1
          t.name =~ /^([a-z]+-?)?[0-9]\d*\.\d+(\.\d+)?([\.-]((alpha|beta|cr)-?[1-9]\d*|final))?$/i
      }.sort_by{|t| rc.gcommit(t).author_date}.each do |t|
        # skip tag if arquillian has nothing to do with it
        next if repository.relative_path and rc.log(1).object(t.name).path(repository.relative_path).size.zero?
        # for some reason, we have to use ^0 to get to the actual commit, can't use t.sha
        sha = rc.revparse(t.name + '^0')
        commit = rc.gcommit(sha)
        committer = commit.committer
        release = OpenStruct.new({
          :tag => t.name,
          :version => t.name.gsub(/^([a-z]+-?)/, ''),
          :key => (c.key.eql?('core') ? '' : c.key + '_') + t.name, # jira release version key, should we add owner?
          #:license => 'track?',
          :sha => sha,
          :html_url => RepositoryHelpers.build_commit_url(repository, sha, 'html'),
          :json_url => RepositoryHelpers.build_commit_url(repository, sha, 'json'),
          :date => commit.author_date,
          :released_by => OpenStruct.new({
            :name => committer.name,
            :email => committer.email.downcase
          }),
          :contributors => RepositoryHelpers.resolve_contributors_between(site, repository, prev_sha, sha),
          :published_artifacts => []
        })
        if site.resolve_published_artifacts and repository.owner =~ /arquillian|shrinkwrap/
          resolve_published_artifacts(site.dir, repository, release)
        end
        # not assigning to release for now since it can be very space intensive
        #if site.release_notes_by_version.has_key? release.key
        #  release.issues = site.release_notes_by_version[release.key]
        #end
        depversions = resolve_dep_versions(repository, release.tag)
        release.compiledeps = []
        {
          'arquillian' => 'Arquillian Core',
          'arquillian_core' => 'Arquillian Core',
          'jboss_arquillian_core' => 'Arquillian Core',
          'org_jboss_arquillian' => 'Arquillian Core',
          'org_jboss_arquillian_core' => 'Arquillian Core',
          'arquillian_drone' => 'Arquillian Drone Extension',
          'arquillian_warp' => 'Arquillian Warp',
          'arquillian_graphene' => 'Graphene',
          'arquillian_transaction' => 'Arquillian Transaction Extension',
          'org_jboss_arquillian_graphene' => 'Graphene',
          'shrinkwrap_shrinkwrap' => 'ShrinkWrap',
          'jboss_shrinkwrap' => 'ShrinkWrap',
          'shrinkwrap' => 'ShrinkWrap',
          'shrinkwrap_descriptors' => 'ShrinkWrap Descriptors',
          'shrinkwrap_descriptor' => 'ShrinkWrap Descriptors',
          'shrinkwrap_resolver' => 'ShrinkWrap Resolver',
          'selenium' => 'Selenium',
          'junit_junit' => 'JUnit',
          'testng_testng' => 'TestNG',
          'spock' => 'Spock'
        }.each do |key, name|
          if depversions.has_key? key
            release.compiledeps << OpenStruct.new({:name => name, :key => key, :version => depversions[key]})
          end
        end
        c.releases << release
        prev_sha = sha
      end
      c.latest_version = (!c.releases.empty? ? c.releases.last.version : resolve_head_version(repository))
      c.latest_tag = (!c.releases.empty? ? c.releases.last.tag : 'HEAD')
      c.releases.each do |r|
        # FIXME not dry!
        r.contributors.each do |contrib|
          i = c.contributors.index {|n| n.email == contrib.email}
          if i.nil?
            c.contributors << contrib
          else
            c.contributors[i].commits += contrib.commits
          end
        end
      end
      # FIXME not dry!
      RepositoryHelpers.resolve_contributors_between(site, repository, prev_sha, rc.revparse('HEAD')).each do |contrib|
        i = c.contributors.index {|n| n.email == contrib.email}
        if i.nil?
          c.contributors << contrib
        else
          c.contributors[i].commits += contrib.commits
        end
      end

      # we can be pretty sure we'll have at least one commit, otherwise why the repository ;)
      last = rc.log(1).path(repository.relative_path).first
      c.last_commit = OpenStruct.new({
        :author => last.author,
        :date => last.date,
        :message => last.message,
        :sha => last.sha,
        :html_url => RepositoryHelpers.build_commit_url(repository, last.sha, 'html'),
        :json_url => RepositoryHelpers.build_commit_url(repository, last.sha, 'json')
      })
      c.unreleased_commits = RepositoryHelpers.resolve_commits_between(repository, prev_sha, rc.revparse('HEAD')).size

      c.modules = []
      site.components[repository.path] = c
    end

    def resolve_name(repository)
      pom = load_root_head_pom(repository)
      name = pom.root.text('name')
      # FIXME note misspelling of Aggregator in Drone extension
      name.nil? ? repository.path : name.gsub(/[ :]*(Aggregator|Agreggator|Parent|module|and Build)+/, '').strip
    end

    def resolve_group_id(repository)
      pom = load_root_head_pom(repository)
      pom.root.text('groupId') || pom.root.elements['parent'].text('groupId')
    end

    def resolve_head_version(repository)
      pom = load_root_head_pom(repository)
      pom.root.text('version')
    end

    # QUESTION should we track lead by release version? (for historical reasons)
    def resolve_current_lead(repository, component_leads)
      if !component_leads.nil? and component_leads.has_key? repository.path
        lead = component_leads[repository.path]
      else
        lead = nil
        pom = load_root_head_pom(repository)
        pom.each_element('/project/developers/developer') do |dev|
          # capture first developer as fallback lead
          if lead.nil? and !dev.text('email').nil?
            lead = OpenStruct.new({:name => dev.text('name'), :email => dev.text('email').downcase})
          end

          if !dev.elements['roles'].nil?
            if !dev.elements['roles'].elements.find { |role| role.name.eql? 'role' and role.text =~ / Lead/ }.nil?
              lead = OpenStruct.new({:name => dev.text('name'), :email => dev.text('email').downcase})
              break
            end
          end
        end
        if lead.nil?
          # FIXME parameterize (keep in mind the JIRA extension hits most of the leads)
          if repository.path.eql? 'jboss-as' or repository.path.eql? 'wildfly'
            lead = OpenStruct.new({
              :name => 'Jason T. Greene',
              :jboss_username => 'jason.greene'
            })
          elsif repository.path.eql? 'plugin-arquillian'
            lead = OpenStruct.new({
              :name => 'Paul Bakker',
              :jboss_username => 'pbakker'
            })
          elsif repository.path.eql? 'arquillian-graphene'
            lead = OpenStruct.new({
              :name => 'Lukáš Fryč',
              :jboss_username => 'lfryc'
            })
          elsif repository.path.eql? 'arquillian-cube'
            lead = OpenStruct.new({
              :name => 'Alex Soto',
              :jboss_username => 'lordofthejars'
            })
          elsif repository.owner.eql? 'arquillian'
            lead = OpenStruct.new({
              :name => 'Aslak Knutsen',
              :jboss_username => 'aslak'
            })
          elsif repository.path.eql? 'resolver'
            lead = OpenStruct.new({
              :name => 'Karel Piwko',
              :jboss_username => 'kpiwko'
            })
          elsif repository.path.eql? 'descriptors-docker'
            lead = OpenStruct.new({
              :name => 'George Gastaldi',
              :jboss_username => 'gastaldi'
            })
          elsif repository.path.eql? 'shrinkwrap-osgi'
            lead = OpenStruct.new({
              :name => 'Carlos Sierra Andrés',
              :jboss_username => 'csierra'
            })
          elsif repository.owner.eql? 'shrinkwrap'
            lead = OpenStruct.new({
              :name => 'Andrew Lee Rubinger',
              :jboss_username => 'alrubinger'
            })
          elsif repository.path.eql? 'tomee'
            lead = OpenStruct.new({
              :name => 'David Blevins',
              :jboss_username => 'dblevins'
            })
          end
        end
        # update the global index (why not?)
        if !lead.nil?
          component_leads[repository.path] = lead
        end
      end
      lead
    end

    def resolve_dep_versions(repository, rev)
      rc = repository.client
      versions = {}
      # FIXME Android extension defines versions in android-bom/pom.xml
      ['pom.xml', 'build/pom.xml', 'android-bom/pom.xml', "#{repository.relative_path}pom.xml"].each do |path|
        # skip if path is not present in this revision
        #next if rc.log(1).object(rev).path(path).size.zero?
        pom_content = nil
        begin
          pom_content = rc.cat_file(rc.revparse("#{rev}:#{path}"))
        rescue
          next
        end
        pom = REXML::Document.new(pom_content)
        pom.each_element('/project/properties/*') do |prop|
          if (prop.name.start_with? 'version.' or prop.name.end_with? '.version') and
              not prop.name =~ /[\._]plugin$/ and
              not prop.name =~ /\.maven[\._]/
            versions[prop.name.sub(/\.?version\.?/, '').gsub('.', '_')] = prop.text
          end
        end
      end
      versions
    end

    def resolve_published_artifacts(sitedir, repository, release)
      parent_path = "#{release.tag}:#{repository.relative_path}"
      begin
        repository.client.revparse "#{parent_path}pom.xml"
      rescue
        return
      end

      MavenHelpers.traverse_modules(parent_path, repository) do |pathrev, pom|
        artifactId = pom.root.text('artifactId')
        #puts "#{artifactId} -> #{version}"
        packaging = (pom.root.text('packaging') || "jar").to_sym

        next unless artifactId =~ /.*bom|.*depchain.*|graphene/ or packaging == :jar
        next if artifactId =~/.*(ftest.*|inttest|example.*|build|build-config|build-resources)/
        next unless packaging == :pom || :jar

        version = pom.root.text('version') || pom.root.elements['parent'].text('version')
        groupId = pom.root.text('groupId') || pom.root.elements['parent'].text('groupId')
        release.published_artifacts ||= []
        release.published_artifacts << Artifact::Coordinates.new(groupId, artifactId, packaging, version)
      end
    end

    def load_root_head_pom(repository)
      @root_head_pom ||= REXML::Document.new(
        repository.client.cat_file(repository.client.revparse("HEAD:#{repository.relative_path}pom.xml"))
      )
    end
  end

  # Combine Bom and Depchain in a common /scan Maven tree Base
  module BomModule
    include Base

    def handles(repository)
      true # we don't know until we do a full scan
    end

    def visit(repository, site)
      c = site.components[repository.path]
      if !c.nil? and !c.releases.nil? and c.releases.size > 0
        rev = c.latest_tag
        parent_path = "#{rev}:#{repository.relative_path}"
        # verify pom exists in this rev
        begin
          repository.client.revparse "#{parent_path}pom.xml"
        rescue
          return
        end
        MavenHelpers.traverse_modules(parent_path, repository) do |pathrev, pom|
          artifactId = pom.text('/project/artifactId')
          unless artifactId.index('bom').nil?
            name = pom.root.text('name')
            groupId = pom.root.text('groupId') || pom.root.elements['parent'].text('groupId')
            c.bom = Artifact::Coordinates.new(groupId, artifactId, :pom, c.latest_version)
            return
          end
        end
      end
    end
  end

  module DepchainModule
    include Base

    def handles(repository)
      true # we don't know until we do a full scan
    end

    def visit(repository, site)
      c = site.components[repository.path]
      if !c.nil? and !c.releases.nil? and c.releases.size > 0
        rev = c.latest_tag
        parent_path = "#{rev}:#{repository.relative_path}"
        # verify pom exists in this rev
        begin
          repository.client.revparse "#{parent_path}pom.xml"
        rescue
          return
        end
        MavenHelpers.traverse_modules(parent_path, repository) do |pathrev, pom|
          artifactId = pom.text('/project/artifactId')
          name = pom.text('/project/name')
          #puts "#{name.to_s} > #{artifactId}"
          # Some have x-module-depchain and others x-module
          unless "#{artifactId} #{name.to_s.downcase}".index('depchain').nil?
            name = pom.root.text('name')
            packaging = pom.root.text('packaging') || "pom"
            groupId = pom.root.text('groupId') || pom.root.elements['parent'].text('groupId')
            c.depchains ||= []
            c.depchains << Artifact.new(name, Artifact::Coordinates.new(groupId, artifactId, packaging.to_sym, c.latest_version))
          end
        end
      end
    end
  end

  module PlatformComponent
    include Base

    def handles(repository)
      repository.path == 'arquillian-core'
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'platform'
      c.type_name = c.type.humanize.titleize
      c.name = 'Arquillian Core'
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        :basepath => c.repository.path.match(/-([^-]+)$/)[1],
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      m.artifacts = [
        Artifact.new('JUnit Integration',
            Artifact::Coordinates.new('org.jboss.arquillian.junit', 'arquillian-junit-container')),
        Artifact.new('TestNG Integration',
            Artifact::Coordinates.new('org.jboss.arquillian.testng', 'arquillian-testng-container'))
      ]
      c.modules << m
      site.modules[c.type] << m
    end

  end

  module TestRunnerComponent
    include Base

    def handles(repository)
      repository.path =~ /^arquillian\-testrunner\-.+/ and
          File.exist? File.join(repository.clone_dir, 'pom.xml')
      #repository.path =~ /^arquillian\-testrunner\-.+/ and
      #    repository.path != 'arquillian-testrunner-jbehave'
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'test_runner'
      c.type_name = c.type.humanize.titleize
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        :basepath => c.repository.path.match(/-([^-]+)$/)[1],
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      c.modules << m
      site.modules[c.type] << m
    end
  end

  module ContainerComponent
    include Base

    def handles(repository)
      repository.path != 'arquillian-container-reloaded' and
          (repository.path =~ /^arquillian\-container\-.+/ or ['jboss-as', 'wildfly-arquillian', 'tomee'].include? repository.path)
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'container_adapter'
      c.type_name = c.type.humanize.titleize
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      containers = resolve_container_adapters(repository, c)
      containers.each do |container|
        container.component = c
        populate_container_info(repository, c, container)
        # temporary hack!!! can we make this more generic?
        c.family = container.vendor
        c.modules << container
        site.modules[c.type] << container
      end
    end

    # NOTE we are not showing container adapters that are only in SNAPSHOT unless the
    # component (repository) itself has not yet been released
    def resolve_container_adapters(repository, component)
      vendor = (repository.path == 'jboss-as' ? 'jbossas7' : repository.path.match(/([^-]+)$/)[1])
      vendor = 'wildfly' if repository.path == 'wildfly-arquillian'
      adapters = []
      rev = component.latest_tag
      rev = "HEAD" unless rev
      begin
        pomrev = repository.client.revparse("#{rev}:#{repository.relative_path}pom.xml")
      rescue
        puts "Using HEAD for #{repository.path} since repository structure is inconsistent at #{rev}"
        rev = "HEAD"
        pomrev = repository.client.revparse("#{rev}:#{repository.relative_path}pom.xml")
      end
      module_cnt = 0
      parent_path = ("#{rev}:#{repository.relative_path}")
      MavenHelpers.traverse_modules(parent_path, repository) do |pathrev, pom|
        mod = pom.text('/project/artifactId')
        # Need a sub extension point to clean up for specific containers
        if mod =~ /.*?-(remote|managed|embedded)(-(.+))?$/ and !(repository.path == 'tomee' and mod =~ /.*webapp.*/)
          (management, min_version) = [$1, $3]
          module_cnt += 1
          adapters << OpenStruct.new({
            :relative_path => MavenHelpers.to_relative_sub_path(pathrev, repository.relative_path),
            :basepath => mod.sub(/container(?=-)/, vendor),
            :vendor => vendor,
            :management => management,
            :min_version => min_version
          })
        elsif mod.eql? 'arquillian-openshift' or
          (mod.eql? 'arquillian-openshift-express' and !(pom.text('/project/name') =~ /.*Relocation/)) or
          mod.eql? 'arquillian-cloudbees'
          # FIXME this should be openshift-remote
          module_cnt += 1
          adapters << OpenStruct.new({
            :relative_path => MavenHelpers.to_relative_sub_path(pathrev, repository.relative_path),
            :basepath => mod,
            :vendor => vendor,
            :management => 'remote'
          })
        elsif mod.eql? 'arquillian-container-chameleon'
          # FIXME this should be openshift-remote
          module_cnt += 1
          adapters << OpenStruct.new({
            :relative_path => MavenHelpers.to_relative_sub_path(pathrev, repository.relative_path),
            :basepath => mod,
            :vendor => vendor,
            :management => 'any'
          })
        end
      end
      adapters
    end

    def populate_container_info(repository, component, container)
      rc = repository.client
      container.enrichers = []
      rev = component.latest_tag
      pomrev = nil
      begin
        pomrev = repository.client.revparse("#{rev}:#{repository.relative_path}#{container.relative_path}pom.xml")
      rescue
        puts "Using HEAD for #{repository.path} since repository structure is inconsistent at #{rev}"
        pomrev = repository.client.revparse("HEAD:#{repository.relative_path}#{container.relative_path}pom.xml")
      end
      pom = REXML::Document.new(rc.cat_file(pomrev))
      container.name = pom.root.text('name').sub(/ Container$/, '\0 Adapter').sub(/^Arquillian Container (.*)/, 'Arquillian \1 Container Adapter')
      if repository.path == 'jboss-as'
        container.name = container.name.sub(/.*Arquillian /, 'Arquillian JBoss AS 7 ')
      elsif repository.path == 'wildfly-arquillian'
        container.name = container.name.sub(/.*Arquillian /, 'Arquillian WildFly ')
      elsif repository.path == 'tomee'
        container.name = container.name.sub(/.*:: /, 'Arquillian TomEE ')
        container.name = container.name.sub(/ Adaptor/, ' Container Adapter')
        container.name = container.name + ' Container Adapter' unless container.name =~/Adapter/
        container.name = container.name.sub(/TomEE /, '') if container.name =~/openejb/i
      end
      container.desc = pom.root.text('description') || '!!!Missing description!!!'
      container.artifacts = [
        Artifact.new(container.name,
            Artifact::Coordinates.new(component.groupId, pom.root.text('artifactId'), :jar, component.latest_version))
      ]
      # FIXME also need to check common submodule
      pom.each_element('/project/dependencies/dependency') do |dep|
        if dep.text('groupId').eql? 'org.jboss.arquillian.testenricher'
          container.enrichers << dep.text('artifactId').sub(/^arquillian-testenricher-/, '')
        elsif dep.text('groupId').eql? 'org.jboss.arquillian.protocol'
          container.protocol = dep.text('artifactId').sub(/^arquillian-protocol-/, '')
        end
      end
    end
  end

  module ExtensionComponent
    include Base

    def handles(repository)
      repository.path =~ /^(arquillian-extension-.+|jsfunit|arquillian-graphene|arquillian-droidium|arquillian-spacelift|arquillian-recorder|arquillian-cube|arquillian-governor)$/
    end

    def visit(repository, site)
      c = site.components[repository.path]
      return if c.nil?
      c.type = 'extension'
      c.type_name = c.type.humanize.titleize
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        #:basepath => c.repository.path.match(/-([^-]+)$/)[1],
        :basepath => c.repository.path.split('-').last,
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      resolve_extension_artifacts(repository, m)
      c.modules << m
      site.modules[c.type] << m
    end

    def resolve_extension_artifacts(repository, mod)
      return unless mod.component.depchains.nil?
      rc = repository.client
      rev = mod.component.latest_tag
      pom = REXML::Document.new(rc.cat_file(rc.revparse("#{rev}:#{repository.relative_path}pom.xml")))
      count = 0
      primary = nil
      pom.each_element('/project/modules/module') do |m|
        count += 1
        if (m.text.eql? 'impl' or m.text.end_with? '-impl')
          primary = m.text
        end
      end
      primarypom = nil
      if count.zero?
        primarypom = pom
      elsif !primary.nil?
        primarypom = REXML::Document.new(rc.cat_file(rc.revparse("#{rev}:#{repository.relative_path}#{primary}/pom.xml")))
      elsif !count.zero? and primary.nil?
        pom.each_element('/project/modules/module') do |m|
          unless m.text.eql? 'impl' or m.text.end_with? '-impl' or m.text.end_with? 'api' or m.text.end_with? 'spi' or m.text.include? 'ftest'
            primarypom = REXML::Document.new(rc.cat_file(rc.revparse("#{rev}:#{repository.relative_path}#{m.text}/pom.xml")))
          end
        end
      end
      if !primarypom.nil?
        artifactId = primarypom.root.text('artifactId')
        name = primarypom.root.text('name')
        packaging = primarypom.root.text('packaging')
        groupId = pom.root.text('groupId') || pom.root.elements['parent'].text('groupId')
        mod.artifacts = [
          Artifact.new(name, Artifact::Coordinates.new(groupId, artifactId, packaging, mod.component.latest_version))
        ]
      end
    end
  end

  # QUICK HACK! -> too much boilerplate
  module PluginComponent
    include Base

    def handles(repository)
      repository.path =~ /^(arquillian-maven|plugin-arquillian|arquillian-gradle-plugin)$/
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'tool_plugin'
      c.type_name = c.type.humanize.titleize
      # temporarily fix broken name
      c.name = 'Arquillian Forge Plugin' if c.name.eql? 'plugin-arquillian'
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        :basepath => c.repository.path,
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      c.modules << m
      site.modules[c.type] << m
    end
  end

  module ShrinkWrapComponent
    include Base

    def handles(repository)
      repository.owner.eql? 'shrinkwrap'
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'shrinkwrap'
      c.type_name = c.type.humanize.titleize
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        :basepath => c.repository.path,
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      c.modules << m
      site.modules[c.type] << m
    end
  end

  module ArquillianTCKComponent
    include Base

    def handles(repository)
      repository.path =~ /^(arquillian-tck)$/
    end

    def visit(repository, site)
      c = site.components[repository.path]
      c.type = 'TCK'
      c.type_name = c.type.humanize.titleize
      if site.modules[c.type].nil?
        site.modules[c.type] = []
      end
      m = OpenStruct.new({
        :basepath => c.repository.path,
        :name => c.name,
        :desc => c.desc,
        :component => c
      })
      c.modules << m
      site.modules[c.type] << m
    end
  end
end


text:
package com.shirish.sortingAlgo;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author shirish
 *
 */
public class QuickSortTest {

    /**
     * @throws java.lang.Exception
     */
    @BeforeClass
    public static void setUpBeforeClass() throws Exception {

    }

    /**
     * @throws java.lang.Exception
     */
    @AfterClass
    public static void tearDownAfterClass() throws Exception {

    }

    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {

    }

    /**
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {

    }

    /**
     * Test method for {@link com.shirish.sortingAlgo.QuickSort#quickSort(int[])}.
     */
    @Test
    public void testQuickSort() {
        try {
            QuickSort qs = new QuickSort();
            int[] listToSort = qs.prepareAlist();
            qs.quickSort( listToSort );
        }
        catch ( Exception e ) {
            e.printStackTrace();
            fail( "Not yet implemented" );
        }

    }

}


text:
package org.apache.activemq.usage;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.apache.activemq.ConfigurationException;
import org.junit.Test;

import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.util.DefaultTestAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class StoreUsageLimitsTest {

    final int WAIT_TIME_MILLS = 20 * 1000;
    private static final String limitsLogLevel = "warn";
    final String toMatch = new String(Long.toString(Long.MAX_VALUE / (1024 * 1024)));

    protected BrokerService createBroker() throws Exception {
        BrokerService broker = new BrokerService();
        broker.setPersistent(false);
        broker.getSystemUsage().getMemoryUsage().setLimit(Long.MAX_VALUE);
        broker.getSystemUsage().setCheckLimitsLogLevel(limitsLogLevel);
        broker.deleteAllMessages();
        return broker;
    }

    @Test
    public void testCheckLimitsLogLevel() throws Exception {

        final CountDownLatch foundMessage = new CountDownLatch(1);
        DefaultTestAppender appender = new DefaultTestAppender() {
            @Override
            public void doAppend(LoggingEvent event) {
                String message = (String) event.getMessage();
                if (message.contains(toMatch) && event.getLevel().equals(Level.WARN)) {
                    foundMessage.countDown();
                }
            }
        };

        Logger.getRootLogger().addAppender(appender);
        BrokerService brokerService = createBroker();
        brokerService.start();
        brokerService.stop();

        assertTrue("Fount log message", foundMessage.await(WAIT_TIME_MILLS, TimeUnit.MILLISECONDS));

        Logger.getRootLogger().removeAppender(appender);
    }

    @Test
    public void testCheckLimitsFailStart() throws Exception {

        final CountDownLatch foundMessage = new CountDownLatch(1);
        DefaultTestAppender appender = new DefaultTestAppender() {
            @Override
            public void doAppend(LoggingEvent event) {
                String message = (String) event.getMessage();
                if (message.contains(toMatch) && event.getLevel().equals(Level.ERROR)) {
                    foundMessage.countDown();
                }
            }
        };

        Logger.getRootLogger().addAppender(appender);
        BrokerService brokerService = createBroker();
        brokerService.setAdjustUsageLimits(false);
        try {
            brokerService.start();
            fail("expect ConfigurationException");
        } catch (ConfigurationException expected) {
            assertTrue("exception message match", expected.getLocalizedMessage().contains(toMatch));
        }
        brokerService.stop();

        assertTrue("Fount log message", foundMessage.await(WAIT_TIME_MILLS, TimeUnit.MILLISECONDS));

        Logger.getRootLogger().removeAppender(appender);
    }
}


text:
require 'spec_helper'

describe "default feed json templates" do
  before(:each) do
    @feed = PachubeDataFormats::Feed.new(feed_as_(:hash))
    @feed.datastreams.each do |ds|
      ds.current_value = "I \n , will , break , you"
      ds.datapoints.each do |dp|
        dp.value = "one,data,point"
      end
    end
  end

  context "2 (used by API v2)" do
    it "should be the default" do
      @feed.generate_csv("2").should == @feed.to_csv
    end

    it "should represent Pachube JSON" do
      @feed.datastreams.each do |ds|
        ds.datapoints = []
      end
      csv = @feed.generate_csv("2")
      expected_csv = @feed.datastreams.collect do |datastream|
        CSV.generate_line([datastream.id, datastream.updated.iso8601(6), datastream.current_value])
      end.join("\n")
      csv.should == expected_csv
    end

    it "should allow representing full Pachube JSON" do
      @feed.datastreams.each do |ds|
        ds.datapoints = []
      end
      csv = @feed.generate_csv("2", :full => true)
      expected_csv = @feed.datastreams.collect do |datastream|
        CSV.generate_line([@feed.id, datastream.id, datastream.updated.iso8601(6), datastream.current_value])
      end.join("\n")
      csv.should == expected_csv
    end

    it "should represent Pachube JSON with datapoints" do
      csv = @feed.generate_csv("2")
      expected_csv = @feed.datastreams.collect do |datastream|
        if datastream.datapoints.any?
          datastream.datapoints.collect {|dp| CSV.generate_line([datastream.id, dp.at.iso8601(6), dp.value]) }
        else
          CSV.generate_line([datastream.id, datastream.updated.iso8601(6), datastream.current_value])
        end
      end.join("\n")
      csv.should == expected_csv
    end

    it "should allow representing full Pachube JSON with datapoints" do
      csv = @feed.generate_csv("2", :full => true)
      expected_csv = @feed.datastreams.collect do |datastream|
        if datastream.datapoints.any?
          datastream.datapoints.collect {|dp| CSV.generate_line([@feed.id, datastream.id, dp.at.iso8601(6), dp.value]) }
        else
          CSV.generate_line([@feed.id, datastream.id, datastream.updated.iso8601(6), datastream.current_value])
        end
      end.join("\n")
      csv.should == expected_csv
    end
  end

  context "0.6-alpha (used by API v1)" do

    it "should represent Pachube JSON" do
      csv = @feed.generate_csv("1")
      expected_csv = @feed.datastreams.collect do |datastream|
        CSV.generate_line([datastream.current_value])
      end.join(",")
      csv.should == expected_csv
    end

  end
end


text:
<sample>
    <para>Java base project</para>
</sample>


text:
MusicPlayer::MusicPlayer() : _music(), _fileNames(), _volume(2.0f)
{
	_fileNames[Music::MenuTheme] = config::MGE_MUSIC_PATH + "1.wav";
	_fileNames[Music::Level1] = config::MGE_MUSIC_PATH + "level.wav";
}

void MusicPlayer::Play(Music::ID pTheme, bool pRepeat)
{
	std::string filename = _fileNames[pTheme];
	if (!_music.openFromFile(filename))
		std::cout << ("Music " + filename + " could not be loaded.") << std::endl;

	_music.setVolume(_volume);
	_music.setLoop(pRepeat);
	_music.play();
}

void MusicPlayer::Stop()
{
	_music.stop();
}

void MusicPlayer::SetPaused(bool pPaused)
{
	if (pPaused) {
		_music.pause();
	}
	else {
		_music.play();
	}
}

void MusicPlayer::SetVolume(float pVolume)
{
	_music.setVolume(pVolume);
}


text:
<?php

/* @Framework/Form/button_label.html.php */
class __TwigTemplate_2e2c3f181f03700ffe5a76608969a830d1d577edd1c5d93acb4e6ee825b181fb extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
    }

    public function getTemplateName()
    {
        return "@Framework/Form/button_label.html.php";
    }

    public function getDebugInfo()
    {
        return array ();
    }

    /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
    public function getSource()
    {
        @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);

        return $this->getSourceContext()->getCode();
    }

    public function getSourceContext()
    {
        return new Twig_Source("", "@Framework/Form/button_label.html.php", "C:\\wamp64\\www\\Symfony\\vendor\\symfony\\symfony\\src\\Symfony\\Bundle\\FrameworkBundle\\Resources\\views\\Form\\button_label.html.php");
    }
}


text:
<?php

namespace NicklasW\PkmGoApi\Handlers\RequestHandler\Exceptions;

use Exception;

class ResponseException extends \Exception {

    /**
     * AuthenticationException constructor.
     *
     * @param string    $message
     * @param int       $code
     * @param Exception $previous
     */
    public function __construct($message = '', $code = 0, Exception $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }

}


text:
fastlane documentation
================
# Installation
```
sudo gem install fastlane
```
# Available Actions
## iOS
### ios test
```
fastlane ios test
```
Runs all the tests
### ios snapshot
```
fastlane ios snapshot
```
Make screenshots
### ios beta
```
fastlane ios beta
```
Submit a new Beta Build to Apple TestFlight

This will also make sure the profile is up to date
### ios appstore
```
fastlane ios appstore
```
Deploy a new version to the App Store

----

This README.md is auto-generated and will be re-generated every time to run [fastlane](https://fastlane.tools).
More information about fastlane can be found on [https://fastlane.tools](https://fastlane.tools).
The documentation of fastlane can be found on [GitHub](https://github.com/fastlane/fastlane/tree/master/fastlane).


text:
/*jshint browser:true, jquery:true*/
/*global confirm:true*/
define([
  'jquery',
  'Magento_Ui/js/modal/confirm',
  'jquery/ui',
  'mage/translate'
], function ($, confirm) {
  'use strict';

  $.widget('hipay.card', {
    /**
     * Options common to all instances of this widget.
     *
     * @type {Object}
     */
    options: {
      deleteConfirmMessage: $.mage.__(
        'Are you sure you want to delete this card?'
      )
    },

    /**
     * Bind event handlers fordeleting cards.
     *
     * @private
     */
    _create: function () {
      var options = this.options,
        deleteCard = options.deleteCard;

      if (deleteCard) {
        $(document).on('click', deleteCard, this._deleteCard.bind(this));
      }
    },

    /**
     * Delete the card whose id is specified in a data attribute after confirmation from the user.
     *
     * @private
     * @param   {Event}
     * @return  {Boolean}
     */
    _deleteCard: function (e) {
      var self = this;

      confirm({
        content: this.options.deleteConfirmMessage,
        actions: {
          confirm: function () {
            if (typeof $(e.target).parent().data('card') !== 'undefined') {
              window.location =
                self.options.deleteUrlPrefix +
                $(e.target).parent().data('card');
            } else {
              window.location =
                self.options.deleteUrlPrefix + $(e.target).data('card');
            }
          }
        }
      });

      return false;
    }
  });

  return $.hipay.card;
});


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;

using OSharp.Utility.Secutiry;

namespace OSharp.Web.Net.Alipay
{
    /// <summary>
    /// 支付宝通知处理类,处理支付宝各接口通知返回
    /// </summary>
    public class AlipayNotify
    {
        #region 字段

        private const string HttpsVerifyUrl = "https://mapi.alipay.com/gateway.do?service=notify_verify&";
        private readonly string _inputCharset; //字符编码格式
        private readonly string _key; //商户的私钥
        private readonly string _partner; //合作身份者ID
        private readonly string _signType; //签名方式
        private readonly SortedDictionary<string, string> _paras;

        //支付宝消息验证地址

        #endregion

        #region 构造函数

        /// <summary>
        /// 初始化一个 支付宝通知处理类 的新实例
        /// </summary>
        /// <param name="paras">通知返回参数的有序字典</param>
        public AlipayNotify(SortedDictionary<string, string> paras)
        {
            _partner = AlipayConfig.Partner.Trim();
            _key = AlipayConfig.Key.Trim();
            _inputCharset = AlipayConfig.InputCharset.Trim().ToLower();
            _signType = AlipayConfig.SignType.Trim().ToUpper();
            _paras = paras;
        }

        #endregion

        #region 属性

        /// <summary>
        /// 获取 支付宝通知信息
        /// </summary>
        public AlipayNotifyInfo NotifyInfo { get; private set; }

        #endregion

        /// <summary>
        /// 验证消息是否是支付宝发出的合法消息
        /// </summary>
        /// <param name="notifyId">通知验证ID</param>
        /// <param name="sign">支付宝生成的签名结果</param>
        /// <returns>验证结果</returns>
        public bool Verify(string notifyId, string sign)
        {
            //获取返回时的签名验证结果
            bool isSign = GetSignVerify(sign);
            //获取是否是支付宝服务器发来的请求的验证结果
            string responseText = "true";
            if (!string.IsNullOrEmpty(notifyId))
            {
                responseText = GetResponseText(notifyId);
            }

            //写日志记录(若要调试,请取消下面两行注释)
            string word = "responseTxt=" + responseText + "\n isSign=" + isSign + "\n 返回回来的参数:" + GetPreSignStr() + "\n ";
            AlipayCore.LogResult(word);

            //判断responseText是否为true,isSign是否为true
            //responseText的结果不是true,与服务器设置问题、合作身份者ID,notify_id一分钟失效有关
            //isSign不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
            bool isVerify = responseText == "true" && isSign;
            if (isVerify)
            {
                NotifyInfo = new AlipayNotifyInfo(_paras);
            }
            return isVerify;
        }

        /// <summary>
        /// 获取待签名字符串(调试用)
        /// </summary>
        /// <returns>待签名字符串</returns>
        public string GetPreSignStr()
        {
            //过滤空值、sign与signType参数
            Dictionary<string, string> dictPara = AlipayCore.FilterPara(_paras);
            //获取待签名字符串
            string preSignStr = AlipayCore.CreateLinkString(dictPara);
            return preSignStr;
        }

        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="sign">对比签名结果的方式</param>
        /// <returns>签名验证结果</returns>
        private bool GetSignVerify(string sign)
        {
            //过滤空值、sign与signType参数
            Dictionary<string, string> dictPara = AlipayCore.FilterPara(_paras);
            //获取待签名字符串
            string perSignStr = AlipayCore.CreateLinkString(dictPara);
            bool isSign = false;
            if (!string.IsNullOrEmpty(sign))
            {
                switch (_signType)
                {
                    case "MD5":
                        isSign = Md5Verify(perSignStr, sign, _key, _inputCharset);
                        break;
                }
            }
            return isSign;
        }

        /// <summary>
        /// 获取是否是支付宝服务器发来的请求的验证结果
        /// </summary>
        /// <param name="notifyId">通知验证ID</param>
        /// <returns>验证结果</returns>
        private string GetResponseText(string notifyId)
        {
            string veryfyUrl = HttpsVerifyUrl + "partner=" + _partner + "&notify_id=" + notifyId;

            //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
            string responseTxt = GetHttp(veryfyUrl, 120000);

            return responseTxt;
        }

        /// <summary>
        /// 获取远程服务器ATN结果
        /// </summary>
        /// <param name="strUrl">指定URL路径地址</param>
        /// <param name="timeout">超时时间设置</param>
        /// <returns>服务器ATN结果</returns>
        private string GetHttp(string strUrl, int timeout)
        {
            string strResult = string.Empty;
            try
            {
                HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(strUrl);
                myReq.Timeout = timeout;
                HttpWebResponse httpWResp = (HttpWebResponse)myReq.GetResponse();
                Stream myStream = httpWResp.GetResponseStream();
                if (myStream != null)
                {
                    StreamReader sr = new StreamReader(myStream, Encoding.Default);
                    StringBuilder strBuilder = new StringBuilder();
                    while (-1 != sr.Peek())
                    {
                        strBuilder.Append(sr.ReadLine());
                    }

                    strResult = strBuilder.ToString();
                }
            }
            catch (Exception exp)
            {
                strResult = "错误:" + exp.Message;
            }

            return strResult;
        }

        private static bool Md5Verify(string prestr, string sign, string key, string inputCharset)
        {
            Encoding encoding = Encoding.GetEncoding(inputCharset);
            string mysign = HashHelper.GetMd5(prestr + key, encoding);
            return mysign == sign;
        }
    }
}


text:
<?php

if (!defined('OSE_FRAMEWORK') && !defined('OSEFWDIR') && !defined('_JEXEC'))
{
 die('Direct Access Not Allowed');
}
require_once (OSE_FWCONTROLLERS. ODS. 'BaseController.php');
class ClamavController extends BaseController {
	public $layout = '//layouts/main';
	public $clamstatus = '';
	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function __construct($id,$module=null)
	{

		parent::__construct($id,$module=null);
		$this -> getModel () ;
		$this -> model -> isDBReady();
	}
}
?>


text:
package com.palantir.typescript.text;

import static com.google.common.base.Preconditions.checkNotNull;

import org.eclipse.jface.text.DefaultTextHover;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHoverExtension;
import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.widgets.Shell;

/**
 * Determines what to display when hovering over the text.
 *
 * @author dcicerone
 */
public final class TextHover extends DefaultTextHover implements ITextHoverExtension, ITextHoverExtension2 {

    private final TypeScriptEditor editor;

    public TextHover(ISourceViewer sourceViewer, TypeScriptEditor editor) {
        super(sourceViewer);

        checkNotNull(editor);

        this.editor = editor;
    }

    @Override
    protected boolean isIncluded(Annotation annotation) {
        // suppress quick diff annotations since they are noisy and mostly useless
        if (annotation.getType().startsWith("org.eclipse.ui.workbench.texteditor.quickdiff")) {
            return false;
        }

        return true;
    }

    @Override
    @SuppressWarnings("deprecation")
    public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
        String hoverInfo = super.getHoverInfo(textViewer, hoverRegion);

        // get the quick info
        if (hoverInfo == null) {
            int offset = hoverRegion.getOffset();

            return this.editor.getLanguageService().getQuickInfoAtPosition(offset);
        }

        return hoverInfo;
    }

    @Override
    public IInformationControlCreator getHoverControlCreator() {
        return new IInformationControlCreator() {
            @Override
            public IInformationControl createInformationControl(Shell parent) {
                return new HoverInformationControl(parent, false);
            }
        };
    }
}


text:
using Aurora.Settings;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;

namespace Aurora.Profiles.Desktop
{
    public enum InteractiveEffects
    {
        [Description("None")]
        None = 0,
        [Description("Key Wave")]
        Wave = 1,
        [Description("Key Wave (Filled)")]
        Wave_Filled = 3,
        [Description("Key Fade")]
        KeyPress = 2,
        [Description("Arrow Flow")]
        ArrowFlow = 4,
        [Description("Key Wave (Rainbow)")]
        Wave_Rainbow = 5,
    }

    public class DesktopSettings : ProfileSettings
    {
        //Effects
        ////CPU
        public bool cpu_usage_enabled;
        public Color cpu_used_color;
        public Color cpu_free_color;
        public bool cpu_free_color_transparent;
        public PercentEffectType cpu_usage_effect_type;
        public KeySequence cpu_sequence;

        ////Ram
        public bool ram_usage_enabled;
        public Color ram_used_color;
        public Color ram_free_color;
        public bool ram_free_color_transparent;
        public PercentEffectType ram_usage_effect_type;
        public KeySequence ram_sequence;

        //// Shortcut Assistant
        public bool shortcuts_assistant_enabled;
        public bool shortcuts_assistant_bim_bg;
        public Color ctrl_key_color;
        public KeySequence ctrl_key_sequence;
        public Color win_key_color;
        public KeySequence win_key_sequence;
        public Color alt_key_color;
        public KeySequence alt_key_sequence;

        //// Lighting Areas
        public List<ColorZone> lighting_areas;

        //// Interactive Effects
        public bool interactive_effects_enabled;
        public InteractiveEffects interactive_effect_type;
        public bool interactive_effects_random_primary_color;
        public Color interactive_effect_primary_color;
        public bool interactive_effects_random_secondary_color;
        public Color interactive_effect_secondary_color;
        public float interactive_effect_speed;
        public int interactive_effect_width;
        public bool interactive_effects_mouse_clicking;

        public DesktopSettings()
        {
            isEnabled = true;

            Layers = new System.Collections.ObjectModel.ObservableCollection<Settings.Layers.Layer>()
            {
                new Settings.Layers.Layer("Shortcut Assistant", new Settings.Layers.ShortcutAssistantLayerHandler()
                {
                    Properties = new Settings.Layers.ShortcutAssistantLayerHandlerProperties()
                }),
                new Settings.Layers.Layer("CPU Usage", new Settings.Layers.PercentLayerHandler()
                {
                    Properties = new Settings.Layers.PercentLayerHandlerProperties()
                    {
                        _PrimaryColor =  Color.FromArgb(0, 205, 255),
                        _SecondaryColor = Color.FromArgb(0, 65, 80),
                        _PercentType = PercentEffectType.Progressive_Gradual,
                        _Sequence = new KeySequence(new Devices.DeviceKeys[] {
                            Devices.DeviceKeys.F1, Devices.DeviceKeys.F2, Devices.DeviceKeys.F3, Devices.DeviceKeys.F4,
                            Devices.DeviceKeys.F5, Devices.DeviceKeys.F6, Devices.DeviceKeys.F7, Devices.DeviceKeys.F8,
                            Devices.DeviceKeys.F9, Devices.DeviceKeys.F10, Devices.DeviceKeys.F11, Devices.DeviceKeys.F12
                        }),
                        _BlinkThreshold = 0.0,
                        _BlinkDirection = false,
                        _VariablePath = "LocalPCInfo/CPUUsage",
                        _MaxVariablePath = "100"
                    },
                }),
                new Settings.Layers.Layer("RAM Usage", new Settings.Layers.PercentLayerHandler()
                {
                    Properties = new Settings.Layers.PercentLayerHandlerProperties()
                    {
                        _PrimaryColor =  Color.FromArgb(255, 80, 0),
                        _SecondaryColor = Color.FromArgb(90, 30, 0),
                        _PercentType = PercentEffectType.Progressive_Gradual,
                        _Sequence = new KeySequence(new Devices.DeviceKeys[] {
                            Devices.DeviceKeys.ONE, Devices.DeviceKeys.TWO, Devices.DeviceKeys.THREE, Devices.DeviceKeys.FOUR,
                            Devices.DeviceKeys.FIVE, Devices.DeviceKeys.SIX, Devices.DeviceKeys.SEVEN, Devices.DeviceKeys.EIGHT,
                            Devices.DeviceKeys.NINE, Devices.DeviceKeys.ZERO, Devices.DeviceKeys.MINUS, Devices.DeviceKeys.EQUALS
                        }),
                        _BlinkThreshold = 0.0,
                        _BlinkDirection = false,
                        _VariablePath = "LocalPCInfo/MemoryUsed",
                        _MaxVariablePath = "LocalPCInfo/MemoryTotal"
                    },
                }),
                new Settings.Layers.Layer("Interactive Layer", new Settings.Layers.InteractiveLayerHandler()
                {
                    Properties = new Settings.Layers.InteractiveLayerHandlerProperties()
                    {
                        _InteractiveEffect = InteractiveEffects.Wave_Filled,
                        _PrimaryColor = Color.FromArgb(0, 255, 0),
                        _RandomPrimaryColor = true,
                        _SecondaryColor = Color.FromArgb(255, 0, 0),
                        _RandomSecondaryColor = true,
                        _EffectSpeed = 5.0f,
                        _EffectWidth = 2,
                        _TriggerOnMouseClick = false
                    }
                }
                )
            };

            //Effects
            //// CPU
            cpu_usage_enabled = true;
            cpu_used_color = Color.FromArgb(0, 205, 255);
            cpu_free_color = Color.FromArgb(0, 65, 80);
            cpu_free_color_transparent = false;
            cpu_usage_effect_type = PercentEffectType.Progressive_Gradual;
            cpu_sequence = new KeySequence(new Devices.DeviceKeys[] {
                Devices.DeviceKeys.F1, Devices.DeviceKeys.F2, Devices.DeviceKeys.F3, Devices.DeviceKeys.F4,
                Devices.DeviceKeys.F5, Devices.DeviceKeys.F6, Devices.DeviceKeys.F7, Devices.DeviceKeys.F8,
                Devices.DeviceKeys.F9, Devices.DeviceKeys.F10, Devices.DeviceKeys.F11, Devices.DeviceKeys.F12
            });

            //// Ram
            ram_usage_enabled = true;
            ram_used_color = Color.FromArgb(255, 80, 0);
            ram_free_color = Color.FromArgb(90, 30, 0);
            ram_free_color_transparent = false;
            ram_usage_effect_type = PercentEffectType.Progressive_Gradual;
            ram_sequence = new KeySequence(new Devices.DeviceKeys[] {
                Devices.DeviceKeys.ONE, Devices.DeviceKeys.TWO, Devices.DeviceKeys.THREE, Devices.DeviceKeys.FOUR,
                Devices.DeviceKeys.FIVE, Devices.DeviceKeys.SIX, Devices.DeviceKeys.SEVEN, Devices.DeviceKeys.EIGHT,
                Devices.DeviceKeys.NINE, Devices.DeviceKeys.ZERO, Devices.DeviceKeys.MINUS, Devices.DeviceKeys.EQUALS
            });

            //// Shortcuts Assistant
            shortcuts_assistant_enabled = true;
            shortcuts_assistant_bim_bg = false;
            ctrl_key_color = Color.Red;
            ctrl_key_sequence = new KeySequence(new Devices.DeviceKeys[] {
                Devices.DeviceKeys.C, Devices.DeviceKeys.V, Devices.DeviceKeys.X, Devices.DeviceKeys.Y,
                Devices.DeviceKeys.LEFT_ALT, Devices.DeviceKeys.RIGHT_ALT, Devices.DeviceKeys.A, Devices.DeviceKeys.Z
            });
            win_key_color = Color.Blue;
            win_key_sequence = new KeySequence(new Devices.DeviceKeys[] {
                Devices.DeviceKeys.R, Devices.DeviceKeys.E, Devices.DeviceKeys.M, Devices.DeviceKeys.D,
                Devices.DeviceKeys.ARROW_UP, Devices.DeviceKeys.ARROW_DOWN, Devices.DeviceKeys.ARROW_LEFT, Devices.DeviceKeys.ARROW_RIGHT,
                Devices.DeviceKeys.TAB
            });
            alt_key_color = Color.Yellow;
            alt_key_sequence = new KeySequence(new Devices.DeviceKeys[] {
                Devices.DeviceKeys.F4, Devices.DeviceKeys.E, Devices.DeviceKeys.V, Devices.DeviceKeys.LEFT_CONTROL,
                Devices.DeviceKeys.RIGHT_CONTROL, Devices.DeviceKeys.TAB
            });

            //// Lighting Areas
            lighting_areas = new List<ColorZone>();

            //// Interactive Effects
            interactive_effects_enabled = false;
            interactive_effect_type = InteractiveEffects.None;
            interactive_effect_primary_color = Color.FromArgb(0, 255, 0);
            interactive_effects_random_primary_color = false;
            interactive_effect_secondary_color = Color.FromArgb(255, 0, 0);
            interactive_effects_random_secondary_color = false;
            interactive_effect_speed = 1.0f;
            interactive_effect_width = 2;
            interactive_effects_mouse_clicking = false;
        }
    }
}


text:
layout: example
categories: example/v1.0.0
version: v1.0.0
title: Leaflet Heat
description: Initially draw heatmap data on a map and allow a users mouse movement to draw their own.
tags:
  - plugins
---


text:
# Modals

Controls a modal's opened status with a `data-modal-open` attribute. The html element also gets a `data-{modalName}-open` class when a modal is open.

Modals can be used with data attributes or the JavaScript API.

Note: We don't add any styles to the modals. You should use the data-modal-open attribute to toggle visibility with CSS.

## Example

#### HTML

```
<button data-modal-opener="checkout-modal">Open modal</button>

<div data-modal="checkout-modal">
  <button data-modal-closer="checkout-modal">Close modal</button>
  <div>Content here!</div>
</div>

<style>
    [data-modal="checkout-modal"] { display: none; }
    [data-modal="checkout-modal"][data-modal-open="true"] { display: block; }
</style>
```

#### JavaScript

```js
import modals from '@optimistdigital/core-js/lib/modals';

/**
 * Initialize modal logic
 */
modals.init();

/**
 * Event listeners can be used to react to the modal opening and closing
 */
window.addEventListener('modal:opened', evt => console.log(evt.detail.name));
window.addEventListener('modal:closed', evt => console.log(evt.detail.name));

/**
 * JS API can be used to open and close the modal
 */
modals.openModal('checkout-modal');
modals.closeModal('checkout-modal'); // Passing in DOM node works too
```

## Data attributes

| Attribute                                       | Description                                                                                |
| ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| data-modal="modal name"                         | Modal's name. This will be the modal's container.                                                                       |
| data-modal-[toggler/opener/closer]="modal name" | Toggles/opens/closes the modal when clicked. Can be placed anywhere in the DOM                                          |
| data-modal-open="false"                         | Gets automatically placed on the modal's container. Keeps track of whether the modal is open or not. Defaults to false. |
| data-close-on-esc="true"                        | Whether or not pressing escape should close the modal. True by default.                                                 |

## JavaScript API

| Function           | Description                                                 |
| ------------------ | ----------------------------------------------------------- |
| init(options)      | Initializes modal logic. This should only be called once.   |
| openModal(modal)   | Opens the modal. Takes the modal name or container DOM node |
| closeModal(modal)  | Closes the modal                                            |
| toggleModal(modal) | Toggles the modal                                           |

## Events

| Event                                       | event.detail                                                     | Description                                         |
| ------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------------------- |
| window.addEventListener('modal:closed', cb) | `{type: "modal:opened", $modal: DOMElement, name: "modal-name"}` | Dispatched when a modal changes from open to closed |
| window.addEventListener('modal:opened', cb) | `{type: "modal:closed", $modal: DOMElement, name: "modal-name"}` | Dispatched when a modal changes from closed to open |


text:
<?php
namespace freebeats\CustomerBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="customer")
 * @author sergio
 */
class Customer
{
	/**
	 * @ORM\Id
	 * @ORM\Column(type="integer")
	 * @ORM\GeneratedValue(strategy="AUTO")
	 */
	protected $id;

	/**
	 * @ORM\Column(type="string", length=100)
	 */
	protected $firstName;

	/**
	 * @ORM\Column(type="string", length=100)
	 */
	protected $lastName;

	/**
	 * @ORM\Column(type="string", length=255)
	 */
	protected $email;

	/**
	 * @ORM\Column(type="text")
	 */
	protected $address;

	/**
	 * @ORM\Column(type="string", length=100)
	 */
	protected $postalCode;

	/**
	 * @ORM\Column(type="string", length=100)
	 */
	protected $city;

	/**
	 * @ORM\Column(type="string", length=100)
	 */
	protected $country;

    /**
     * Get id
     *
     * @return Integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set firstName
     *
     * @param string $firstName
     * @return Customer
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;

        return $this;
    }

    /**
     * Get firstName
     *
     * @return string
     */
    public function getFirstName()
    {
        return $this->firstName;
    }

    /**
     * Set lastName
     *
     * @param string $lastName
     * @return Customer
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;

        return $this;
    }

    /**
     * Get lastName
     *
     * @return string
     */
    public function getLastName()
    {
        return $this->lastName;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return Customer
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

    /**
     * Get email
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set address
     *
     * @param string $address
     * @return Customer
     */
    public function setAddress($address)
    {
        $this->address = $address;

        return $this;
    }

    /**
     * Get address
     *
     * @return string
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * Set postalCode
     *
     * @param string $postalCode
     * @return Customer
     */
    public function setPostalCode($postalCode)
    {
        $this->postalCode = $postalCode;

        return $this;
    }

    /**
     * Get postalCode
     *
     * @return string
     */
    public function getPostalCode()
    {
        return $this->postalCode;
    }

    /**
     * Set city
     *
     * @param string $city
     * @return Customer
     */
    public function setCity($city)
    {
        $this->city = $city;

        return $this;
    }

    /**
     * Get city
     *
     * @return string
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * Set country
     *
     * @param string $country
     * @return Customer
     */
    public function setCountry($country)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * Get country
     *
     * @return string
     */
    public function getCountry()
    {
        return $this->country;
    }
}


text:
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.sendgrid.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

//////////////////////////////////////////////////////////////////
//  Retrieve the totals for each email statistic metric for all subusers.
// GET /subusers/stats/sums

public class RetrieveTotalsForEachEmail {
  public static void main(String[] args) throws IOException {
    try {
      SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
      Request request = new Request();
      request.setMethod(Method.GET);
      request.setEndpoint("subusers/stats/sums");
      request.addQueryParam("end_date", "2016-04-01");
      request.addQueryParam("aggregated_by", "day");
      request.addQueryParam("limit", "1");
      request.addQueryParam("sort_by_metric", "test_string");
      request.addQueryParam("offset", "1");
      request.addQueryParam("start_date", "2016-01-01");
      request.addQueryParam("sort_by_direction", "asc");
      Response response = sg.api(request);
      System.out.println(response.getStatusCode());
      System.out.println(response.getBody());
      System.out.println(response.getHeaders());
    } catch (IOException ex) {
      throw ex;
    }
  }
}


text:
namespace SingleplayerEngine.Graphics
{
    public interface IScenes : ISystem
    {
        void MouseDown(string button, int x, int y);
        void MouseUp(string button, int x, int y);
        void MouseMove(int x, int y);
        void KeyDown(string key);
        void KeyUp(string key);
    }
}