text:
(function($){

  /**
   * Pieces of code taken from resumable.js at https://github.com/23/resumable.js
   * */

  /**
   * Detect if the browser has support for the File API calls we need.
   * @private
   * */
  var isFileAPISuppported = function(){
    return typeof File !== "undefined" && (File.prototype.mozSlice || File.prototype.webkitSlice);
  };

  var UploadableChunk = function(url, chunkProvider, maxNumberOfRetries){
    Ooyala.Client.EventDispatcher.call(this);
    this.url = url;
    this.chunkProvider = chunkProvider;
    this.maxNumberOfRetries = maxNumberOfRetries;
    this.retriesSoFar = 0;
  };

  $.extend(UploadableChunk.prototype, new Ooyala.Client.EventDispatcher(), {
    upload: function(error){
      //Dumb retries. We don't care about the underlying error, we just try again until we hit the retries limit.
      if(this.retriesSoFar > this.numberOfRetries){
        this.dispatchEvent("error", [error]);
      }
      else{
        this.retriesSoFar++;
        this.transferBytesOverTheWire();
      }
    },

    /**
     * This function does the heavy lifting of sending the bytes over to the uploading endpoint.
     * @private
     * */
    transferBytesOverTheWire: function(){
      var matchResults = this.url.match(/.+\/(.+)-([^&]+)/);
      var startByte = parseInt(matchResults[1], 10);
      var endByte = parseInt(matchResults[2], 10) + 1;
      var numberOfBytes = endByte - startByte + 1;
      var that = this;

      var onComplete = function(){
        that.chunkProvider.detach("complete", onComplete);
        var bytes = that.chunkProvider.data;

        var xhr = new XMLHttpRequest();
        xhr.addEventListener("load", function(){that.dispatchEvent("complete");});
        xhr.addEventListener("error", function(e){that.upload(e);}); //Retry

        xhr.open("POST", that.url);

        if(window.Blob && document.getElementById("flashChunkProvider")==null){
          var data = new FormData();
          data.append("chunk", bytes);
          xhr.send(data);
        }
        else{

          var boundary = "--------------------------" + Math.random().toString().replace("0.","");

          var body = "--" + boundary + '\r\nContent-Disposition: form-data; name="file"; filename="blob"\r\nContent-Type: application/octet-stream' + (document.getElementById('flashChunkProvider')?
          '; Content-Transfer-Encoding: base64':'')+
          '\r\n\r\n' + bytes + "\r\n--" + boundary + "--\r\n";

          xhr.setRequestHeader("content-type", "multipart/form-data; charset=x-user-defined-binary; boundary=" + boundary);

          xhr.send(body);
        }
      };

      this.chunkProvider.on("complete", onComplete);

      this.chunkProvider.getChunk(startByte, endByte);
    }
  });

  /**
   * HTMLUploader Object to interact with either the HTML5 File API if available or fallback
   * to Flash file slicing and doing a chunked upload via HTTP.
   * */
  var HTMLUploader = Ooyala.Client.HTMLUploader = function(browseButton, options){
    Ooyala.Client.Uploader.call(this);
    this.chunksUploaded = 0;
    this.chunkProvider = null;
    this.totalChunks = this.uploadingURLs.length;
    this.currentChunks = [];
    this.shouldStopBecauseOfError = false;
    this.browseButton = browseButton;
    this.chunkSize = 1*1024*1024;
    var that = this;

    var defaults = {
      maxChunkRetries: 3,
      maxNumberOfConcurrnetChunks: 1
    };

    this.options = $.extend(defaults, options);

    if(isFileAPISuppported()){
      this.chunkProvider = new Ooyala.Client.HTML5ChunkProvider(this.file, this.browseButton);
    }
    else{
      throw new Error("Your browser does not support HTML5 file APIs.");
    }

    this.chunkProvider.on("fileSelected", function(){
       that.file = that.chunkProvider.file;
       window.uploader.file = that.chunkProvider.file;
     });
  };

    $.extend(Ooyala.Client.HTMLUploader.prototype, new Ooyala.Client.Uploader, {
    /**
     * Start uploading the selected file.
     * */
    upload: function(){
     this.totalChunks = this.uploadingURLs.length;
      for(var i = 0; i < this.options.maxNumberOfConcurrnetChunks; i++){
        this.uploadNextChunk();
      }
    },

    /**
     * Upload the next chunk fetch from either the HTML5 or Flash chunk providers
     * */
    uploadNextChunk: function(){
      var that = this;
      var urlToUpload = this.uploadingURLs.pop();

      this.dispatchEvent("progress");

      //Stop if we are done uploading chunks and dispatch complete event.
      if(!urlToUpload){
        this.dispatchEvent("complete");
        return;
      }

      //Stop if there has been an error trying to upload a chunk.
      if(this.shouldStopBecauseOfError){
        return;
      }

      var uploadableChunk = new UploadableChunk(urlToUpload, this.chunkProvider, that.options.maxChunkRetries);
      //Upload the next chunk if this one has completed uploading
      uploadableChunk.on("complete", function(){
      that.chunksUploaded++;
      that.uploadNextChunk();
      });

      //If an error is thrown by one of the chunks,
      //set the flag to stop the ingestion.
      uploadableChunk.on("error", function(e){
        that.dispatchEvent("error", [e]);
        that.shouldStopBecauseOfError = true;
      });

      uploadableChunk.upload();

    },

    progress: function(){
      return this.chunksUploaded == 0 ? 0 : (this.chunksUploaded / this.totalChunks);
    }
  });
}).call(this, jQuery);


text:
require File.dirname(__FILE__) + '/spec_helper'
require 'yggdrasil_server'

describe Yggdrasil, 'check' do
  before(:all) do
    puts '-------- check'
    prepare_environment
    init_yggdrasil
    `rm -f /tmp/yggdrasil-test/A`
    `echo foo >> /tmp/yggdrasil-test/B`
    `echo bar > /tmp/yggdrasil-test/C`
    Yggdrasil.command(%w{add /tmp/yggdrasil-test/C})
  end

  it 'should display check result by "check"' do
    cmd = %w{check --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:A tmp/yggdrasil-test/C
1:D tmp/yggdrasil-test/A
2:M tmp/yggdrasil-test/B
OK? [A|q|<num to diff>]:#{' '}
EOS
  end

  it 'should display check result by "c"' do
    cmd = %w{c --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:A tmp/yggdrasil-test/C
1:D tmp/yggdrasil-test/A
2:M tmp/yggdrasil-test/B
OK? [A|q|<num to diff>]:#{' '}
EOS
  end

  it 'should display check result by "status"' do
    cmd = %w{status --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:A tmp/yggdrasil-test/C
1:D tmp/yggdrasil-test/A
2:M tmp/yggdrasil-test/B
OK? [A|q|<num to diff>]:#{' '}
EOS
  end

  it 'should display check result by "stat"' do
    cmd = %w{stat --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:A tmp/yggdrasil-test/C
1:D tmp/yggdrasil-test/A
2:M tmp/yggdrasil-test/B
OK? [A|q|<num to diff>]:#{' '}
EOS
  end

  it 'should display check result by "st"' do
    cmd = %w{st --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:A tmp/yggdrasil-test/C
1:D tmp/yggdrasil-test/A
2:M tmp/yggdrasil-test/B
OK? [A|q|<num to diff>]:#{' '}
EOS

    `echo hoge > /tmp/yggdrasil-test/A`
    `echo hoge >> /tmp/yggdrasil-test/A`
    `echo foo > /tmp/yggdrasil-test/B`
    `echo foo >> /tmp/yggdrasil-test/B`
    `rm -f /tmp/yggdrasil-test/C`
  end

  it 'should fail by spell miss of path' do
    cmd = %w{st --username hoge --password foo /hoge}
    err = catch_err do
      lambda{Yggdrasil.command(cmd)}.should raise_error(SystemExit)
    end
    err.should == "#{File.basename($0)} error: no such file of directory:/hoge\n\n"
  end

  it 'should fail by spell miss of option' do
    cmd = %w{st --username hoge --password foo --hoge}
    err = catch_err do
      lambda{Yggdrasil.command(cmd)}.should raise_error(SystemExit)
    end
    err.should == "#{File.basename($0)} error: invalid options: --hoge\n\n"
  end

  it 'should execute checker and svn add the result' do
    puts "\n---- should execute checker and svn add the result"
    `echo 'echo hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/hoge`

    cmd = %w{check --username hoge --password foo --non-interactive}
    out = catch_out {Yggdrasil.command(cmd, "Y\n")}
    out.gsub! /[ ]+/, ' '
    out.should == <<"EOS"
10 files checked.
A 0 tmp/yggdrasil-test/.yggdrasil
A 0 tmp/yggdrasil-test/.yggdrasil/checker
A 0 tmp/yggdrasil-test/.yggdrasil/checker/hoge
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result/hoge

Index: tmp/yggdrasil-test/.yggdrasil/checker/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker/hoge	(revision 0)
+++ tmp/yggdrasil-test/.yggdrasil/checker/hoge	(revision 0)
@@ -0,0 +1 @@
+echo hoge

Property changes on: tmp/yggdrasil-test/.yggdrasil/checker/hoge
___________________________________________________________________
Added: svn:executable
 + *

Index: tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(revision 0)
+++ tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(revision 0)
@@ -0,0 +1 @@
+hoge

Yggdrasil check: NG!!!
EOS
  end

  it 'should not fail yggdrasil by checker failure' do
    puts "\n---- should not fail yggdrasil by checker failure"
    `echo 'hoge hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/hoge`

    cmd = %w{check --username hoge --password foo --non-interactive}
    out = catch_out {Yggdrasil.command(cmd, "Y\n")}

    `echo 'echo hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/hoge`

    out.gsub! /[ ]+/, ' '
    out.should == <<"EOS"
9 files checked.
A 0 tmp/yggdrasil-test/.yggdrasil
A 0 tmp/yggdrasil-test/.yggdrasil/checker
A 0 tmp/yggdrasil-test/.yggdrasil/checker/hoge
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result/hoge

Index: tmp/yggdrasil-test/.yggdrasil/checker/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker/hoge	(revision 0)
+++ tmp/yggdrasil-test/.yggdrasil/checker/hoge	(revision 0)
@@ -0,0 +1 @@
+hoge hoge

Property changes on: tmp/yggdrasil-test/.yggdrasil/checker/hoge
___________________________________________________________________
Added: svn:executable
 + *

Index: tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(revision 0)
+++ tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(revision 0)
@@ -0,0 +1 @@
+/tmp/yggdrasil-test/.yggdrasil/checker/hoge: line 1: hoge: command not found

Yggdrasil check: NG!!!
EOS
  end

  it 'should commit the checker result' do
    puts "\n---- should commit the checker result"
    cmd = %w{commit / --username hoge --password foo --non-interactive -m add\ checker}
    out = catch_out {Yggdrasil.command cmd}

    out.should == <<"EOS"
Adding         tmp/yggdrasil-test/.yggdrasil
Adding         tmp/yggdrasil-test/.yggdrasil/checker
Adding         tmp/yggdrasil-test/.yggdrasil/checker/hoge
Adding         tmp/yggdrasil-test/.yggdrasil/checker_result
Adding         tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
Transmitting file data ..
Committed revision 4.
EOS
  end

  it 'should delete result if checker deleted' do
    puts "\n---- should delete result if checker deleted"
    `rm -f /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
    cmd = %w{check --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "A\n")}
    out.gsub! /[ ]+/, ' '
    out.should == <<"EOS"

0:D tmp/yggdrasil-test/.yggdrasil/checker/hoge
1:D tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
OK? [A|q|<num to diff>]:#{' '}
9 files checked.
D 4 tmp/yggdrasil-test/.yggdrasil/checker/hoge
D 4 tmp/yggdrasil-test/.yggdrasil/checker_result/hoge

Index: tmp/yggdrasil-test/.yggdrasil/checker/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker/hoge	(revision 4)
+++ tmp/yggdrasil-test/.yggdrasil/checker/hoge	(working copy)
@@ -1 +0,0 @@
-echo hoge

Index: tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
===================================================================
--- tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(revision 4)
+++ tmp/yggdrasil-test/.yggdrasil/checker_result/hoge	(working copy)
@@ -1 +0,0 @@
-hoge

Yggdrasil check: NG!!!
EOS
  end

  it 'should commit the checker result(delete)' do
    puts "\n---- should commit the checker result(delete)"
    cmd = %w{commit / --username hoge --password foo --non-interactive -m delete\ checker}
    out = catch_out {Yggdrasil.command cmd}

    out.should == <<"EOS"
Deleting       tmp/yggdrasil-test/.yggdrasil/checker/hoge
Deleting       tmp/yggdrasil-test/.yggdrasil/checker_result/hoge

Committed revision 5.
EOS
  end

  it 'should record check result by yggdrasil server (add)' do
    puts "\n---- should record check result by yggdrasil server (add)"

    prepare_environment

    sock = 0
    begin
      sock = TCPSocket.open('localhost', 4000)
    rescue
      puts 'OK. no server'
    else
      puts 'NG. zombie server. try quit'
      sock.puts('quit')
      sock.close
    end

    YggdrasilServer.command %w{init} +
                          %w{--port 4000} +
                          %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/}+
                          %w{--ro-username hoge --ro-password foo},
                      "\n\n"
    fork do
      YggdrasilServer.command %w{debug}
    end

    sleep 1
    Yggdrasil.command %w{init --debug --server localhost:4000} +
                          %w{--username hoge --password foo},
                      "Y\nhoge\nfoo\n"

    Yggdrasil.command %w{check --non-interactive}

    sleep 2
    File.exist?('/tmp/yggdrasil-test/.yggdrasil/results').should be_true
    files = Dir.entries('/tmp/yggdrasil-test/.yggdrasil/results')
    result_files = files.select{|file| %r{^#{Socket.gethostname}} =~ file}
    result_files.size.should == 1
    out = `cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`
    out.gsub! /[ ]+/, ' '
    out.should == <<"EOS"

EOS
  end

  it 'should record check result by yggdrasil server (modify)' do
    puts "\n---- should record check result by yggdrasil server (modify)"

    `echo hoge > /tmp/yggdrasil-test/A`
    Yggdrasil.command %w{add /tmp/yggdrasil-test/A}
    Yggdrasil.command %w{commit --username hoge --password foo /},
                      "Y\nHOGE\n"

    `echo foo >> /tmp/yggdrasil-test/A`
    Yggdrasil.command %w{check}, "A\n"

    sleep 1
    files = Dir.entries('/tmp/yggdrasil-test/.yggdrasil/results')
    result_files = files.select{|file| %r{^#{Socket.gethostname}} =~ file}
    out = `cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`
    out.gsub! /[ ]+/, ' '
    out.should == <<"EOS"
M 2 tmp/yggdrasil-test/A

Index: tmp/yggdrasil-test/A
===================================================================
--- tmp/yggdrasil-test/A	(revision 2)
+++ tmp/yggdrasil-test/A	(working copy)
@@ -1 +1,2 @@
 hoge
+foo

EOS
  end

  it 'should record check result by yggdrasil server (OK)' do
    puts "\n---- should record check result by yggdrasil server (OK)"

    Yggdrasil.command %w{commit --username hoge --password foo} +
                          %w{-m HOGE --non-interactive}

    Yggdrasil.command %w{check --non-interactive}

    sleep 1
    files = Dir.entries('/tmp/yggdrasil-test/.yggdrasil/results')
    result_files = files.select{|file| %r{^#{Socket.gethostname}} =~ file}
    `cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`.should == "\n"
  end

  it 'should ERROR if repo config mismatch' do
    puts "\n---- should ERROR if repo config mismatch"

    `echo repo=hoge.hoge.com >> /tmp/yggdrasil-test/.yggdrasil/config`

    err = catch_err do
      lambda{Yggdrasil.command(%w{check --non-interactive})}.should raise_error(SystemExit)
    end
    err.should == <<"EOS"
rspec error: mismatch repo config with server setting.
config: hoge.hoge.com
server: svn://localhost/tmp/yggdrasil-test/svn-repo/servers/yggdrasil-dev.kusu.myhome.cx

EOS
    `grep -v repo=hoge.hoge.com < /tmp/yggdrasil-test/.yggdrasil/config > /tmp/yggdrasil-test/.yggdrasil/config_`
    `mv /tmp/yggdrasil-test/.yggdrasil/config_ /tmp/yggdrasil-test/.yggdrasil/config`
  end

  it 'should recover delete flag' do
    pending 'under construction...'
    puts "\n---- should recover delete flag"

    `mkdir /tmp/yggdrasil-test/c`
    `echo bar > /tmp/yggdrasil-test/c/C`

    Yggdrasil.command %w{add /tmp/yggdrasil-test/c/C}
    Yggdrasil.command %w{commit --username hoge --password foo} +
                          %w{-m BAR --non-interactive}

    `mv /tmp/yggdrasil-test/c /tmp/yggdrasil-test/cc`
    cmd = %w{c --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

0:D tmp/yggdrasil-test/c
1:D tmp/yggdrasil-test/c/C
OK? [A|q|<num to diff>]:#{' '}
EOS

    `mv /tmp/yggdrasil-test/cc /tmp/yggdrasil-test/c`
    cmd = %w{c --username hoge --password foo}
    out = catch_out {Yggdrasil.command(cmd, "q\n")}
    out.should == <<"EOS"

EOS
  end

  it 'should ignore .(dot) files' do
    puts "\n---- should ignore .(dot) files"

    `echo 'echo hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/.aaa`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/.aaa`

    `mkdir -p /tmp/yggdrasil-test/.yggdrasil/checker/.bbb`
    `echo 'echo hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/.bbb/hoge`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/.bbb/hoge`

    `mkdir -p /tmp/yggdrasil-test/.yggdrasil/checker/ccc`
    `echo 'echo ccc' > /tmp/yggdrasil-test/.yggdrasil/checker/ccc/.ccc`
    `chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/ccc/.ccc`

    cmd = %w{check --username hoge --password foo --non-interactive}
    out = catch_out {Yggdrasil.command cmd}

    out.should == <<"EOS"
3 files checked.
Yggdrasil check: OK.
EOS
  end

  after(:all) do
    sock = TCPSocket.open('localhost', 4000)
    sock.puts('quit')
    sock.close
    Process.waitall
  end
end

redpajama_set_name: RedPajamaGithub


text:
PWD=$(shell pwd)
ROLE_NAME=weareinteractive.pm2
ROLE_PATH=/etc/ansible/roles/$(ROLE_NAME)
TEST_VERSION=ansible --version
TEST_SYNTAX=ansible-playbook -v -i 'localhost,' -c local $(ROLE_PATH)/tests/main.yml --syntax-check
TEST_PLAYBOOK=ansible-playbook -vvvv -i 'localhost,' -c local $(ROLE_PATH)/tests/main.yml
TEST_IDEMPOTENT=$(TEST_PLAYBOOK) | grep -q 'failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
TEST_CMD=$(TEST_VERSION); $(TEST_SYNTAX); $(TEST_DEPS); $(TEST_PLAYBOOK); $(TEST_IDEMPOTENT)

ubuntu%: TEST_DEPS=apt-get update && \
	apt-get install -y gnupg python curl && \
	curl -sL http://deb.nodesource.com/setup_11.x | bash - && \
	apt-get install -y nodejs

ubuntu18.04: dist=ubuntu-18.04
ubuntu18.04: .run

ubuntu16.04: dist=ubuntu-16.04
ubuntu16.04: .run

debian%: TEST_DEPS=apt-get update && \
	apt-get install -y gnupg python curl && \
	curl -sL http://deb.nodesource.com/setup_11.x | bash - && \
	apt-get install -y nodejs

debian9: dist=debian-9
debian9: .run

centos%: TEST_DEPS=curl -sL https://rpm.nodesource.com/setup_11.x | bash - && \
	yum install -y nodejs
centos7: dist=centos-7
centos7: .run

.run:
	# RUN: $(TEST_CMD)
	# docker run -it --rm -v $(PWD):$(ROLE_PATH) ansiblecheck/ansiblecheck:$(dist) /bin/bash
	@docker run -it --rm -v $(PWD):$(ROLE_PATH) ansiblecheck/ansiblecheck:$(dist) /bin/bash -c "$(TEST_CMD)"


text:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
    <PreferenceCategory
        android:title="@string/pref_sound"
        android:key="pref_key_sound_settings">
    <CheckBoxPreference
        android:defaultValue="true"
        android:key="sound"
        android:title="@string/sound_enabled" />
    </PreferenceCategory>
</PreferenceScreen>