├── .bashrc ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── bundle ├── bundler │ └── setup.rb └── ruby │ ├── bin │ ├── httparty │ └── httparty.bat │ ├── cache │ ├── gerry-0.0.3.gem │ ├── gerry-0.0.4.gem │ ├── httparty-0.13.5.gem │ ├── json-1.8.3.gem │ └── multi_xml-0.5.5.gem │ ├── extensions │ └── x64-mingw32 │ │ ├── 2.1.0 │ │ └── json-1.8.3 │ │ │ ├── gem.build_complete │ │ │ ├── gem_make.out │ │ │ └── json │ │ │ └── ext │ │ │ ├── generator.so │ │ │ └── parser.so │ │ └── 2.2.0 │ │ └── json-1.8.3 │ │ ├── gem.build_complete │ │ ├── gem_make.out │ │ └── json │ │ └── ext │ │ ├── generator.so │ │ └── parser.so │ ├── gems │ ├── gerry-0.1.2 │ │ ├── README.md │ │ ├── Rakefile │ │ ├── lib │ │ │ ├── gerry.rb │ │ │ └── gerry │ │ │ │ ├── client.rb │ │ │ │ ├── client │ │ │ │ ├── access.rb │ │ │ │ ├── accounts.rb │ │ │ │ ├── changes.rb │ │ │ │ ├── groups.rb │ │ │ │ ├── projects.rb │ │ │ │ └── request.rb │ │ │ │ └── version.rb │ │ └── spec │ │ │ ├── access_spec.rb │ │ │ ├── accounts_spec.rb │ │ │ ├── changes_spec.rb │ │ │ ├── fixtures │ │ │ ├── access_rights.json │ │ │ ├── account_groups.json │ │ │ ├── capabilities.json │ │ │ ├── changes.json │ │ │ ├── changes_batch_0.json │ │ │ ├── changes_batch_1.json │ │ │ ├── changes_batch_2.json │ │ │ ├── group_members.json │ │ │ ├── groups.json │ │ │ ├── open_changes.json │ │ │ ├── project_head.json │ │ │ ├── projects.json │ │ │ └── query_capabilities.json │ │ │ ├── groups_spec.rb │ │ │ ├── projects_spec.rb │ │ │ ├── request_spec.rb │ │ │ └── spec_helper.rb │ ├── httparty-0.13.5 │ │ ├── .gitignore │ │ ├── .rubocop.yml │ │ ├── .rubocop_todo.yml │ │ ├── .simplecov │ │ ├── .travis.yml │ │ ├── Gemfile │ │ ├── Guardfile │ │ ├── History │ │ ├── MIT-LICENSE │ │ ├── README.md │ │ ├── Rakefile │ │ ├── bin │ │ │ └── httparty │ │ ├── cucumber.yml │ │ ├── examples │ │ │ ├── README.md │ │ │ ├── aaws.rb │ │ │ ├── basic.rb │ │ │ ├── crack.rb │ │ │ ├── custom_parsers.rb │ │ │ ├── delicious.rb │ │ │ ├── google.rb │ │ │ ├── headers_and_user_agents.rb │ │ │ ├── logging.rb │ │ │ ├── nokogiri_html_parser.rb │ │ │ ├── rescue_json.rb │ │ │ ├── rubyurl.rb │ │ │ ├── stackexchange.rb │ │ │ ├── tripit_sign_in.rb │ │ │ ├── twitter.rb │ │ │ └── whoismyrep.rb │ │ ├── features │ │ │ ├── basic_authentication.feature │ │ │ ├── command_line.feature │ │ │ ├── deals_with_http_error_codes.feature │ │ │ ├── digest_authentication.feature │ │ │ ├── handles_compressed_responses.feature │ │ │ ├── handles_multiple_formats.feature │ │ │ ├── steps │ │ │ │ ├── env.rb │ │ │ │ ├── httparty_response_steps.rb │ │ │ │ ├── httparty_steps.rb │ │ │ │ ├── mongrel_helper.rb │ │ │ │ └── remote_service_steps.rb │ │ │ ├── supports_read_timeout_option.feature │ │ │ ├── supports_redirection.feature │ │ │ └── supports_timeout_option.feature │ │ ├── httparty.gemspec │ │ ├── lib │ │ │ ├── httparty.rb │ │ │ └── httparty │ │ │ │ ├── connection_adapter.rb │ │ │ │ ├── cookie_hash.rb │ │ │ │ ├── exceptions.rb │ │ │ │ ├── hash_conversions.rb │ │ │ │ ├── logger │ │ │ │ ├── apache_logger.rb │ │ │ │ ├── curl_logger.rb │ │ │ │ └── logger.rb │ │ │ │ ├── module_inheritable_attributes.rb │ │ │ │ ├── net_digest_auth.rb │ │ │ │ ├── parser.rb │ │ │ │ ├── request.rb │ │ │ │ ├── response.rb │ │ │ │ ├── response │ │ │ │ └── headers.rb │ │ │ │ └── version.rb │ │ ├── script │ │ │ └── release │ │ ├── spec │ │ │ ├── fixtures │ │ │ │ ├── delicious.xml │ │ │ │ ├── empty.xml │ │ │ │ ├── google.html │ │ │ │ ├── ssl │ │ │ │ │ ├── generate.sh │ │ │ │ │ ├── generated │ │ │ │ │ │ ├── 1fe462c2.0 │ │ │ │ │ │ ├── bogushost.crt │ │ │ │ │ │ ├── ca.crt │ │ │ │ │ │ ├── ca.key │ │ │ │ │ │ ├── selfsigned.crt │ │ │ │ │ │ ├── server.crt │ │ │ │ │ │ └── server.key │ │ │ │ │ └── openssl-exts.cnf │ │ │ │ ├── twitter.csv │ │ │ │ ├── twitter.json │ │ │ │ ├── twitter.xml │ │ │ │ └── undefined_method_add_node_for_nil.xml │ │ │ ├── httparty │ │ │ │ ├── connection_adapter_spec.rb │ │ │ │ ├── cookie_hash_spec.rb │ │ │ │ ├── exception_spec.rb │ │ │ │ ├── hash_conversions_spec.rb │ │ │ │ ├── logger │ │ │ │ │ ├── apache_logger_spec.rb │ │ │ │ │ ├── curl_logger_spec.rb │ │ │ │ │ └── logger_spec.rb │ │ │ │ ├── net_digest_auth_spec.rb │ │ │ │ ├── parser_spec.rb │ │ │ │ ├── request_spec.rb │ │ │ │ ├── response_spec.rb │ │ │ │ └── ssl_spec.rb │ │ │ ├── httparty_spec.rb │ │ │ ├── spec_helper.rb │ │ │ └── support │ │ │ │ ├── ssl_test_helper.rb │ │ │ │ ├── ssl_test_server.rb │ │ │ │ └── stub_response.rb │ │ └── website │ │ │ ├── css │ │ │ └── common.css │ │ │ └── index.html │ ├── json-1.8.3 │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGES │ │ ├── COPYING │ │ ├── COPYING-json-jruby │ │ ├── GPL │ │ ├── Gemfile │ │ ├── README-json-jruby.markdown │ │ ├── README.rdoc │ │ ├── Rakefile │ │ ├── TODO │ │ ├── VERSION │ │ ├── data │ │ │ ├── example.json │ │ │ ├── index.html │ │ │ └── prototype.js │ │ ├── diagrams │ │ │ └── .keep │ │ ├── ext │ │ │ └── json │ │ │ │ ├── ext │ │ │ │ ├── fbuffer │ │ │ │ │ └── fbuffer.h │ │ │ │ ├── generator │ │ │ │ │ ├── .RUBYARCHDIR.-.json.-.ext.time │ │ │ │ │ ├── depend │ │ │ │ │ ├── extconf.rb │ │ │ │ │ ├── generator-x64-mingw32.def │ │ │ │ │ ├── generator.c │ │ │ │ │ ├── generator.h │ │ │ │ │ └── generator.so │ │ │ │ └── parser │ │ │ │ │ ├── .RUBYARCHDIR.-.json.-.ext.time │ │ │ │ │ ├── depend │ │ │ │ │ ├── extconf.rb │ │ │ │ │ ├── parser-x64-mingw32.def │ │ │ │ │ ├── parser.c │ │ │ │ │ ├── parser.h │ │ │ │ │ ├── parser.rl │ │ │ │ │ └── parser.so │ │ │ │ └── extconf.rb │ │ ├── install.rb │ │ ├── java │ │ │ └── src │ │ │ │ └── json │ │ │ │ └── ext │ │ │ │ ├── ByteListTranscoder.java │ │ │ │ ├── Generator.java │ │ │ │ ├── GeneratorMethods.java │ │ │ │ ├── GeneratorService.java │ │ │ │ ├── GeneratorState.java │ │ │ │ ├── OptionsReader.java │ │ │ │ ├── Parser.java │ │ │ │ ├── Parser.rl │ │ │ │ ├── ParserService.java │ │ │ │ ├── RuntimeInfo.java │ │ │ │ ├── StringDecoder.java │ │ │ │ ├── StringEncoder.java │ │ │ │ └── Utils.java │ │ ├── json-java.gemspec │ │ ├── json.gemspec │ │ ├── json_pure.gemspec │ │ ├── lib │ │ │ ├── json.rb │ │ │ └── json │ │ │ │ ├── add │ │ │ │ ├── bigdecimal.rb │ │ │ │ ├── complex.rb │ │ │ │ ├── core.rb │ │ │ │ ├── date.rb │ │ │ │ ├── date_time.rb │ │ │ │ ├── exception.rb │ │ │ │ ├── ostruct.rb │ │ │ │ ├── range.rb │ │ │ │ ├── rational.rb │ │ │ │ ├── regexp.rb │ │ │ │ ├── struct.rb │ │ │ │ ├── symbol.rb │ │ │ │ └── time.rb │ │ │ │ ├── common.rb │ │ │ │ ├── ext.rb │ │ │ │ ├── ext │ │ │ │ ├── .keep │ │ │ │ ├── generator.so │ │ │ │ └── parser.so │ │ │ │ ├── generic_object.rb │ │ │ │ ├── pure.rb │ │ │ │ ├── pure │ │ │ │ ├── generator.rb │ │ │ │ └── parser.rb │ │ │ │ └── version.rb │ │ ├── tests │ │ │ ├── fixtures │ │ │ │ ├── fail1.json │ │ │ │ ├── fail10.json │ │ │ │ ├── fail11.json │ │ │ │ ├── fail12.json │ │ │ │ ├── fail13.json │ │ │ │ ├── fail14.json │ │ │ │ ├── fail18.json │ │ │ │ ├── fail19.json │ │ │ │ ├── fail2.json │ │ │ │ ├── fail20.json │ │ │ │ ├── fail21.json │ │ │ │ ├── fail22.json │ │ │ │ ├── fail23.json │ │ │ │ ├── fail24.json │ │ │ │ ├── fail25.json │ │ │ │ ├── fail27.json │ │ │ │ ├── fail28.json │ │ │ │ ├── fail3.json │ │ │ │ ├── fail4.json │ │ │ │ ├── fail5.json │ │ │ │ ├── fail6.json │ │ │ │ ├── fail7.json │ │ │ │ ├── fail8.json │ │ │ │ ├── fail9.json │ │ │ │ ├── pass1.json │ │ │ │ ├── pass15.json │ │ │ │ ├── pass16.json │ │ │ │ ├── pass17.json │ │ │ │ ├── pass2.json │ │ │ │ ├── pass26.json │ │ │ │ └── pass3.json │ │ │ ├── setup_variant.rb │ │ │ ├── test_json.rb │ │ │ ├── test_json_addition.rb │ │ │ ├── test_json_encoding.rb │ │ │ ├── test_json_fixtures.rb │ │ │ ├── test_json_generate.rb │ │ │ ├── test_json_generic_object.rb │ │ │ ├── test_json_string_matching.rb │ │ │ └── test_json_unicode.rb │ │ └── tools │ │ │ ├── fuzz.rb │ │ │ └── server.rb │ └── multi_xml-0.5.5 │ │ ├── .yardopts │ │ ├── CHANGELOG.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── Rakefile │ │ ├── lib │ │ ├── multi_xml.rb │ │ └── multi_xml │ │ │ ├── parsers │ │ │ ├── libxml.rb │ │ │ ├── libxml2_parser.rb │ │ │ ├── nokogiri.rb │ │ │ ├── ox.rb │ │ │ └── rexml.rb │ │ │ └── version.rb │ │ ├── multi_xml.gemspec │ │ └── spec │ │ ├── helper.rb │ │ ├── multi_xml_spec.rb │ │ ├── parser_shared_example.rb │ │ └── speed.rb │ └── specifications │ ├── gerry-0.0.3.gemspec │ ├── gerry-0.1.2.gemspec │ ├── httparty-0.13.5.gemspec │ ├── json-1.8.3.gemspec │ └── multi_xml-0.5.5.gemspec ├── gerrit ├── count-active-owners.rb ├── count-active-projects.rb ├── gerrit-clone.sh ├── gerrit-push-for.sh ├── list-groups.rb ├── list-users.sh ├── repo-clean.sh ├── set-head.rb └── set-parent.sh ├── git ├── .gitconfig ├── git-alias ├── git-author-count ├── git-authorship ├── git-blob-hash ├── git-branch-owners ├── git-check-blacklist ├── git-cherry-pick-branch ├── git-cherry-pick-path ├── git-commit-signoff.txt ├── git-commit-size ├── git-contains-symlinks ├── git-count-cc-merges ├── git-diff-all ├── git-diff-last ├── git-find-least-modifications ├── git-hash-blob ├── git-list-branches-with-contained-commits.sh ├── git-list-reviewers ├── git-list-tags ├── git-log-json ├── git-log-other-than ├── git-merge-customizations ├── git-prompt.sh ├── git-rename-remote-branch ├── git-set-author-committer ├── git-show-merge-resolution ├── git-split-arbitrary-paths └── git-test-rebase-merge-commits ├── github ├── github-clone-org.sh └── github-delete-workflow-runs.sh ├── gradle ├── github-dependency-graph-gradle-plugin.init.gradle ├── github-dependency-graph-gradle-plugin.sh ├── gradlew_bootstrap.sh └── gradlew_update.sh ├── kotlin ├── .gitignore ├── build.gradle.kts ├── json-schema-to-kotlinx-serialization.main.kts ├── openapi-to-kotlinx-serialization.main.kts ├── remove-default-gradle-build-script-imports.main.kts └── scancode-licensedb-statistics.main.kts ├── linux └── watch_and_copy.sh ├── maven ├── inject-maven-plugin-from-jar.sh └── list_pom_deps.sh └── text ├── ensure_final_newline.sh └── trim_trailing_whitespaces.sh /.bashrc: -------------------------------------------------------------------------------- 1 | git_ps1() { 2 | __git_ps1 "%s" 3 | } 4 | 5 | hg_ps1() { 6 | hg prompt "{branch}{ at {bookmark}}{ (status: {status})} " 2> /dev/null 7 | } 8 | 9 | export PS1='\n\[\033[33m\]\w\[\033[0m\] \[\033[32m\]$(git_ps1)$(hg_ps1)\[\033[0m\]\n$ ' 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org/' 2 | gem 'gerry' 3 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | gerry (0.1.2) 5 | httparty 6 | httparty (0.21.0) 7 | mini_mime (>= 1.0.0) 8 | multi_xml (>= 0.5.2) 9 | mini_mime (1.1.2) 10 | multi_xml (0.6.0) 11 | 12 | PLATFORMS 13 | ruby 14 | x64-mingw32 15 | 16 | DEPENDENCIES 17 | gerry 18 | 19 | BUNDLED WITH 20 | 1.10.6 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sebastian Schuberth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a loose collection of miscellaneous scripts (mostly Bash or Ruby) for development work with Git and Hg version control, Gerrit code review, and the Android OS. 2 | 3 | The scripts are tested best with the "Git Bash" that comes with "Git for Windows" but should run just fine under Linux and / or Mac OS X. 4 | -------------------------------------------------------------------------------- /bundle/bundler/setup.rb: -------------------------------------------------------------------------------- 1 | require 'rbconfig' 2 | # ruby 1.8.7 doesn't define RUBY_ENGINE 3 | ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' 4 | path = File.expand_path('..', __FILE__) 5 | $:.unshift "#{path}/../#{ruby_engine}/gems/json-1.8.3/C/Users/seschube/Development/GitHub/dev-scripts/bundle/ruby/2.1.0/extensions/x64-mingw32/2.1.0/json-1.8.3" 6 | $:.unshift "#{path}/../#{ruby_engine}/gems/json-1.8.3/lib" 7 | $:.unshift "#{path}/../#{ruby_engine}/gems/multi_xml-0.5.5/lib" 8 | $:.unshift "#{path}/../#{ruby_engine}/gems/httparty-0.13.5/lib" 9 | $:.unshift "#{path}/../#{ruby_engine}/gems/gerry-0.1.2/lib" 10 | -------------------------------------------------------------------------------- /bundle/ruby/bin/httparty: -------------------------------------------------------------------------------- 1 | #! ruby 2 | # 3 | # This file was generated by RubyGems. 4 | # 5 | # The application 'httparty' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'rubygems' 10 | 11 | version = ">= 0" 12 | 13 | if ARGV.first 14 | str = ARGV.first 15 | str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding 16 | if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then 17 | version = $1 18 | ARGV.shift 19 | end 20 | end 21 | 22 | gem 'httparty', version 23 | load Gem.bin_path('httparty', 'httparty', version) 24 | -------------------------------------------------------------------------------- /bundle/ruby/bin/httparty.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | @"C:\Ruby\bin\ruby.exe" "%~dpn0" %* 3 | -------------------------------------------------------------------------------- /bundle/ruby/cache/gerry-0.0.3.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/cache/gerry-0.0.3.gem -------------------------------------------------------------------------------- /bundle/ruby/cache/gerry-0.0.4.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/cache/gerry-0.0.4.gem -------------------------------------------------------------------------------- /bundle/ruby/cache/httparty-0.13.5.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/cache/httparty-0.13.5.gem -------------------------------------------------------------------------------- /bundle/ruby/cache/json-1.8.3.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/cache/json-1.8.3.gem -------------------------------------------------------------------------------- /bundle/ruby/cache/multi_xml-0.5.5.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/cache/multi_xml-0.5.5.gem -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/gem.build_complete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/gem.build_complete -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/gem_make.out: -------------------------------------------------------------------------------- 1 | C:/Ruby21-x64/bin/ruby.exe -r ./siteconf20150710-6892-cabvle.rb extconf.rb 2 | creating Makefile 3 | 4 | make "DESTDIR=" clean 5 | 6 | make "DESTDIR=" 7 | make: Nothing to be done for `all'. 8 | 9 | make "DESTDIR=" install 10 | installing default libraries 11 | -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/json/ext/generator.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/json/ext/generator.so -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/json/ext/parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.1.0/json-1.8.3/json/ext/parser.so -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/gem.build_complete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/gem.build_complete -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/gem_make.out: -------------------------------------------------------------------------------- 1 | C:/Ruby/bin/ruby.exe -r ./siteconf20150810-11412-mi0qt2.rb extconf.rb 2 | creating Makefile 3 | 4 | make "DESTDIR=" clean 5 | 6 | make "DESTDIR=" 7 | make: Nothing to be done for `all'. 8 | 9 | make "DESTDIR=" install 10 | -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/json/ext/generator.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/json/ext/generator.so -------------------------------------------------------------------------------- /bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/json/ext/parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/extensions/x64-mingw32/2.2.0/json-1.8.3/json/ext/parser.so -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | require 'bundler/gem_tasks' 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | 8 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry.rb: -------------------------------------------------------------------------------- 1 | require_relative 'gerry/client' 2 | 3 | module Gerry 4 | class << self 5 | # Alias for Gerry::Client.new 6 | # 7 | # @return [Gerry::Client] 8 | def new(url, username = nil, password = nil) 9 | Gerry::Client.new(url, username, password) 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | require 'json' 3 | 4 | module Gerry 5 | class Client 6 | include HTTParty 7 | headers 'Accept' => 'application/json' 8 | 9 | require_relative 'client/access' 10 | require_relative 'client/accounts' 11 | require_relative 'client/changes' 12 | require_relative 'client/groups' 13 | require_relative 'client/projects' 14 | require_relative 'client/request' 15 | 16 | include Access 17 | include Accounts 18 | include Changes 19 | include Groups 20 | include Projects 21 | include Request 22 | 23 | def initialize(url, username = nil, password = nil) 24 | self.class.base_uri(url) 25 | 26 | if username && password 27 | @username = username 28 | @password = password 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/access.rb: -------------------------------------------------------------------------------- 1 | require 'erb' 2 | 3 | module Gerry 4 | class Client 5 | module Access 6 | # Get access rights for the specified project 7 | # 8 | # @param [VarArgs] projects the project names 9 | # @return [Hash] the list of access rights 10 | def access(*projects) 11 | projects = projects.flatten.map { |name| ERB::Util.url_encode(name) } 12 | url = "/access/?project=#{projects.join('&project=')}" 13 | get(url) 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/accounts.rb: -------------------------------------------------------------------------------- 1 | module Gerry 2 | class Client 3 | module Accounts 4 | # Get the account info for the specified account ID. 5 | # 6 | # @param [String] account_id the account. 7 | # @return [Hash] the account info. 8 | def account_info(account_id) 9 | url = "/accounts/#{account_id}" 10 | get(url) 11 | end 12 | 13 | # Get the global capabilities that are enabled for the calling user. 14 | # 15 | # @param [Array] options the query parameters. 16 | # @return [Hash] the account capabilities. 17 | def account_capabilities(options = []) 18 | url = '/accounts/self/capabilities' 19 | 20 | if options.empty? 21 | return get(url) 22 | end 23 | 24 | options = map_options(options) 25 | get("#{url}?#{options}") 26 | end 27 | 28 | # Get all groups that contain the specified account as a member 29 | # 30 | # @param [String] account_id the account 31 | # @return [Enumberable] the groups 32 | def groups_for_account(account_id) 33 | url = "/accounts/#{account_id}/groups/" 34 | get(url) 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/changes.rb: -------------------------------------------------------------------------------- 1 | require 'cgi' 2 | 3 | module Gerry 4 | class Client 5 | module Changes 6 | # Get changes visible to the caller. 7 | # 8 | # @param [Array] options the query parameters. 9 | # @return [Hash] the changes. 10 | def changes(options = []) 11 | endpoint = '/changes/' 12 | url = endpoint 13 | 14 | if !options.empty? 15 | url += '?' + map_options(options) 16 | end 17 | 18 | response = get(url) 19 | return response unless response.last(1).delete('_more_changes') 20 | 21 | # Get the original start parameter, if any, else start from 0. 22 | query = URI.parse(url).query 23 | query = query ? CGI.parse(query) : { 'S' => ['0'] } 24 | start = query['S'].join.to_i 25 | 26 | # Keep getting data until there are no more changes. 27 | loop do 28 | # Replace the start parameter, using the original start as an offset. 29 | query['S'] = ["#{start + response.size}"] 30 | url = endpoint + '?' + map_options(query) 31 | 32 | response.concat(get(url)) 33 | return response unless response.last.delete('_more_changes') 34 | end 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/groups.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | module Gerry 4 | class Client 5 | module Groups 6 | # Get all groups 7 | # 8 | # @return [Hash] the groups 9 | def groups 10 | url = '/groups/' 11 | get(url) 12 | end 13 | 14 | # Get all members for a group 15 | # 16 | # @param [Array] options the query parameters 17 | # @return [Array] the members 18 | def group_members(group_id, options = []) 19 | url = "/groups/#{group_id}/members/" 20 | 21 | if options.empty? 22 | return get(url) 23 | end 24 | 25 | options = map_options(options) 26 | get("#{url}?#{options}") 27 | end 28 | 29 | # Get the directly included groups of a group 30 | # 31 | # @return [Array] the included groups 32 | def included_groups(group_id) 33 | url = "/groups/#{group_id}/groups/" 34 | get(url) 35 | end 36 | 37 | # Create a new group 38 | # 39 | # @return [Hash] the group details 40 | def create_group(name, description, visible, owner_id=nil) 41 | url = "/groups/#{name}" 42 | body = { 43 | description: description, 44 | visible_to_all: visible, 45 | } 46 | body[:owner_id] = owner_id unless owner_id.nil? || owner_id.empty? 47 | put(url, body) 48 | end 49 | 50 | # Adds one or more users to a group 51 | # 52 | # @param [String] group_id the group id 53 | # @param [Enumberable] users the list of users identified by email address 54 | # @return [Hash] the account info details for each user added 55 | def add_to_group(group_id, users) 56 | url = "/groups/#{group_id}/members" 57 | body = { 58 | members: users 59 | } 60 | post(url, body) 61 | end 62 | 63 | def remove_from_group(group_id, users) 64 | url = "/groups/#{group_id}/members.delete" 65 | body = { 66 | members: users 67 | } 68 | post(url, body) 69 | end 70 | end 71 | end 72 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/client/projects.rb: -------------------------------------------------------------------------------- 1 | module Gerry 2 | class Client 3 | module Projects 4 | # Get the projects accessible by the caller. 5 | # 6 | # @return [Hash] the projects. 7 | def projects 8 | get('/projects/') 9 | end 10 | 11 | # Get the projects that start with the specified prefix 12 | # and accessible by the caller. 13 | # 14 | # @param [String] name the project name. 15 | # @return [Hash] the projects. 16 | def find_project(name) 17 | get("/projects/#{name}") 18 | end 19 | 20 | # Get the symbolic HEAD ref for the specified project. 21 | # 22 | # @param [String] project the project name. 23 | # @return [String] the current ref to which HEAD points to. 24 | def get_head(project) 25 | get("/projects/#{project}/HEAD") 26 | end 27 | 28 | # Set the symbolic HEAD ref for the specified project to 29 | # point to the specified branch. 30 | # 31 | # @param [String] project the project name. 32 | # @param [String] branch the branch to point to. 33 | # @return [String] the new ref to which HEAD points to. 34 | def set_head(project, branch) 35 | url = "/projects/#{project}/HEAD" 36 | body = { 37 | ref: 'refs/heads/' + branch 38 | } 39 | put(url, body) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/lib/gerry/version.rb: -------------------------------------------------------------------------------- 1 | module Gerry 2 | 3 | VERSION = "0.1.2" 4 | 5 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/access_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe '.list_access_rights' do 4 | it 'lists the access rights for projects' do 5 | projects = ['All-Projects', 'MyProject'] 6 | stub = stub_get("/access/?project=#{projects.join('&project=')}", 'access_rights.json') 7 | 8 | client = MockGerry.new 9 | access_rights = client.access(projects) 10 | expect(stub).to have_been_requested 11 | 12 | expect(access_rights['All-Projects']['revision']).to eq('edd453d18e08640e67a8c9a150cec998ed0ac9aa') 13 | expect(access_rights['MyProject']['revision']).to eq('61157ed63e14d261b6dca40650472a9b0bd88474') 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/accounts_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe '.account_capabilities' do 4 | it 'should fetch all account capabilities' do 5 | stub = stub_get('/accounts/self/capabilities', 'capabilities.json') 6 | 7 | client = MockGerry.new 8 | capabilities = client.account_capabilities 9 | 10 | expect(capabilities['queryLimit']['min']).to eq(0) 11 | expect(capabilities['queryLimit']['max']).to eq(500) 12 | end 13 | 14 | it 'should fetch some account capabilities' do 15 | stub = stub_get('/accounts/self/capabilities?q=createAccount&q=createGroup', 'query_capabilities.json') 16 | 17 | client = MockGerry.new 18 | capabilities = client.account_capabilities(['q=createAccount', 'q=createGroup']) 19 | expect(stub).to have_been_requested 20 | 21 | expect(capabilities['createAccount']).to eq(true) 22 | expect(capabilities['createGroup']).to eq(true) 23 | end 24 | end 25 | 26 | describe '.groups_for_account' do 27 | it "fetches all groups for which the account is a member" do 28 | user = "jane.roe@example.com" 29 | 30 | stub = stub_get("/accounts/#{user}/groups/", "account_groups.json") 31 | 32 | client = MockGerry.new 33 | new_group = client.groups_for_account(user) 34 | expect(stub).to have_been_requested 35 | end 36 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/changes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe '.changes' do 4 | it 'should fetch all changes' do 5 | stub = stub_get('/changes/', 'changes.json') 6 | 7 | client = MockGerry.new 8 | changes = client.changes 9 | 10 | expect(stub).to have_been_requested 11 | 12 | expect(changes[0]['project']).to eq('awesome') 13 | expect(changes[0]['branch']).to eq('master') 14 | 15 | expect(changes[1]['project']).to eq('clean') 16 | expect(changes[1]['subject']).to eq('Refactor code') 17 | expect(changes[1]['owner']['name']).to eq('Batman') 18 | end 19 | 20 | it 'should fetch all changes in batches' do 21 | stub_batch_0 = stub_get('/changes/', 'changes_batch_0.json') 22 | stub_batch_1 = stub_get('/changes/?S=1', 'changes_batch_1.json') 23 | stub_batch_2 = stub_get('/changes/?S=2', 'changes_batch_2.json') 24 | 25 | client = MockGerry.new 26 | changes = client.changes 27 | 28 | expect(stub_batch_0).to have_been_requested 29 | expect(stub_batch_1).to have_been_requested 30 | 31 | expect(changes[0]['project']).to eq('awesome') 32 | expect(changes[0]['branch']).to eq('master') 33 | expect(changes[0]['owner']['name']).to eq('The Duke') 34 | 35 | expect(changes[1]['project']).to eq('clean') 36 | expect(changes[1]['subject']).to eq('Refactor code') 37 | expect(changes[1]['owner']['name']).to eq('Batman') 38 | 39 | expect(changes[2]['project']).to eq('X') 40 | expect(changes[2]['subject']).to eq('Remove unused imports') 41 | expect(changes[2]['owner']['name']).to eq('Bill') 42 | end 43 | 44 | it 'should fetch all open changes' do 45 | stub = stub_get('/changes/?q=is:open+owner:self', 'open_changes.json') 46 | 47 | client = MockGerry.new 48 | changes = client.changes(['q=is:open+owner:self']) 49 | 50 | expect(stub).to have_been_requested 51 | 52 | expect(changes[0]['status']).to eq('OPEN') 53 | expect(changes[0]['owner']['name']).to eq('The Duke') 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/account_groups.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "kind": "gerritcodereview#group", 5 | "id": "global%3AAnonymous-Users", 6 | "url": "#/admin/groups/uuid-global%3AAnonymous-Users", 7 | "options": { 8 | }, 9 | "description": "Any user, signed-in or not", 10 | "group_id": 2, 11 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 12 | }, 13 | { 14 | "kind": "gerritcodereview#group", 15 | "id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", 16 | "url": "#/admin/groups/uuid-834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", 17 | "options": { 18 | "visible_to_all": true 19 | }, 20 | "group_id": 6, 21 | "owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7" 22 | }, 23 | { 24 | "kind": "gerritcodereview#group", 25 | "id": "global%3ARegistered-Users", 26 | "url": "#/admin/groups/uuid-global%3ARegistered-Users", 27 | "options": { 28 | }, 29 | "description": "Any signed-in user", 30 | "group_id": 3, 31 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 32 | } 33 | ] -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/capabilities.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | { 3 | "queryLimit": { 4 | "min": 0, 5 | "max": 500 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/changes.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "project": "awesome", 5 | "branch": "master", 6 | "id": "Idd8747a5ea93bb9bddf7695bab25670be135f777", 7 | "subject": "Add an awesome feature", 8 | "status": "NEW", 9 | "created": "2012-09-12 15:54:21.531000000", 10 | "updated": "2012-10-13 01:34:40.511000000", 11 | "_sortkey": "00115dfe00009334", 12 | "_number": 3, 13 | "owner": { 14 | "name": "The Duke" 15 | } 16 | }, 17 | { 18 | "project": "clean", 19 | "branch": "master", 20 | "id": "Idac803deea68faa1294b3fa5bf814277e899f075", 21 | "subject": "Refactor code", 22 | "status": "NEW", 23 | "created": "2012-09-12 15:51:30.605000000", 24 | "updated": "2012-10-13 00:45:26.431000000", 25 | "_sortkey": "00205dcddd00937d", 26 | "_number": 42, 27 | "owner": { 28 | "name": "Batman" 29 | } 30 | } 31 | ] -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/changes_batch_0.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "project": "awesome", 5 | "branch": "master", 6 | "id": "Idd8747a5ea93bb9bddf7695bab25670be135f777", 7 | "subject": "Add an awesome feature", 8 | "status": "NEW", 9 | "created": "2012-09-12 15:54:21.531000000", 10 | "updated": "2012-10-13 01:34:40.511000000", 11 | "_sortkey": "00115dfe00009334", 12 | "_number": 3, 13 | "owner": { 14 | "name": "The Duke" 15 | }, 16 | "_more_changes": true 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/changes_batch_1.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "project": "clean", 5 | "branch": "master", 6 | "id": "Idac803deea68faa1294b3fa5bf814277e899f075", 7 | "subject": "Refactor code", 8 | "status": "NEW", 9 | "created": "2012-09-12 15:51:30.605000000", 10 | "updated": "2012-10-13 00:45:26.431000000", 11 | "_sortkey": "00205dcddd00937d", 12 | "_number": 42, 13 | "owner": { 14 | "name": "Batman" 15 | }, 16 | "_more_changes": true 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/changes_batch_2.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "project": "X", 5 | "branch": "default", 6 | "id": "Ieb185f4da8725ae35e9f940e614c6eaa7b88eff5", 7 | "subject": "Remove unused imports", 8 | "status": "NEW", 9 | "created": "2016-01-11 15:51:30.605000000", 10 | "updated": "2016-02-12 00:45:26.431000000", 11 | "_sortkey": "002e4203000187d5", 12 | "_number": 4711, 13 | "owner": { 14 | "name": "Bill" 15 | } 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/group_members.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "_account_id": 1000097, 5 | "name": "Jane Roe", 6 | "email": "jane.roe@example.com", 7 | "username": "jane" 8 | }, 9 | { 10 | "_account_id": 1000096, 11 | "name": "John Doe", 12 | "email": "john.doe@example.com", 13 | "username": "john" 14 | } 15 | ] -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/groups.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | { 3 | "Administrators": { 4 | "kind": "gerritcodereview#group", 5 | "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389", 6 | "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389", 7 | "options": { 8 | }, 9 | "description": "Gerrit Site Administrators", 10 | "group_id": 1, 11 | "owner": "Administrators", 12 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 13 | }, 14 | "Anonymous Users": { 15 | "kind": "gerritcodereview#group", 16 | "id": "global%3AAnonymous-Users", 17 | "url": "#/admin/groups/uuid-global%3AAnonymous-Users", 18 | "options": { 19 | }, 20 | "description": "Any user, signed-in or not", 21 | "group_id": 2, 22 | "owner": "Administrators", 23 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 24 | }, 25 | "MyProject_Committers": { 26 | "kind": "gerritcodereview#group", 27 | "id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", 28 | "url": "#/admin/groups/uuid-834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", 29 | "options": { 30 | "visible_to_all": true 31 | }, 32 | "group_id": 6, 33 | "owner": "MyProject_Committers", 34 | "owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7" 35 | }, 36 | "Non-Interactive Users": { 37 | "kind": "gerritcodereview#group", 38 | "id": "5057f3cbd3519d6ab69364429a89ffdffba50f73", 39 | "url": "#/admin/groups/uuid-5057f3cbd3519d6ab69364429a89ffdffba50f73", 40 | "options": { 41 | }, 42 | "description": "Users who perform batch actions on Gerrit", 43 | "group_id": 4, 44 | "owner": "Administrators", 45 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 46 | }, 47 | "Project Owners": { 48 | "kind": "gerritcodereview#group", 49 | "id": "global%3AProject-Owners", 50 | "url": "#/admin/groups/uuid-global%3AProject-Owners", 51 | "options": { 52 | }, 53 | "description": "Any owner of the project", 54 | "group_id": 5, 55 | "owner": "Administrators", 56 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 57 | }, 58 | "Registered Users": { 59 | "kind": "gerritcodereview#group", 60 | "id": "global%3ARegistered-Users", 61 | "url": "#/admin/groups/uuid-global%3ARegistered-Users", 62 | "options": { 63 | }, 64 | "description": "Any signed-in user", 65 | "group_id": 3, 66 | "owner": "Administrators", 67 | "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" 68 | } 69 | } -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/open_changes.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | [ 3 | { 4 | "project": "awesome", 5 | "branch": "master", 6 | "id": "Idd8747a5ea93bb9bddf7695bab25670be135f777", 7 | "subject": "Add an awesome feature", 8 | "status": "OPEN", 9 | "created": "2012-09-12 15:54:21.531000000", 10 | "updated": "2012-10-13 01:34:40.511000000", 11 | "_sortkey": "00115dfe00009334", 12 | "_number": 3, 13 | "owner": { 14 | "name": "The Duke" 15 | } 16 | } 17 | ] -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/project_head.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | "refs/heads/stable" 3 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/projects.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | { 3 | "awesome": { 4 | "description": "Awesome project" 5 | }, 6 | "clean": { 7 | "description": "Clean code!" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/fixtures/query_capabilities.json: -------------------------------------------------------------------------------- 1 | )]}' 2 | { 3 | "createAccount": true, 4 | "createGroup": true 5 | } -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/projects_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe '.projects' do 4 | it 'should fetch all projects' do 5 | stub = stub_get('/projects/', 'projects.json') 6 | 7 | client = MockGerry.new 8 | projects = client.projects 9 | 10 | expect(stub).to have_been_requested 11 | 12 | expect(projects['awesome']['description']).to eq('Awesome project') 13 | expect(projects['clean']['description']).to eq('Clean code!') 14 | end 15 | 16 | it 'should fetch a project' do 17 | stub = stub_get('/projects/awesome', 'projects.json') 18 | 19 | client = MockGerry.new 20 | projects = client.find_project('awesome') 21 | 22 | expect(stub).to have_been_requested 23 | 24 | expect(projects['awesome']['description']).to eq('Awesome project') 25 | end 26 | 27 | it 'should resolve the symbolic HEAD ref of a project' do 28 | project = 'awesome' 29 | stub = stub_get("/projects/#{project}/HEAD", 'project_head.json') 30 | 31 | client = MockGerry.new 32 | branch = client.get_head(project) 33 | 34 | expect(stub).to have_been_requested 35 | 36 | expect(branch).to eq('refs/heads/stable') 37 | end 38 | 39 | it 'should define the symbolic HEAD ref of a project' do 40 | project = 'awesome' 41 | branch = 'stable' 42 | input = { 43 | ref: 'refs/heads/' + branch 44 | } 45 | stub = stub_put("/projects/#{project}/HEAD", input.to_json, get_fixture('project_head.json')) 46 | 47 | client = MockGerry.new 48 | new_branch = client.set_head(project, branch) 49 | 50 | expect(stub).to have_been_requested 51 | 52 | expect(new_branch).to eq('refs/heads/' + branch) 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe '.map_options' do 4 | it 'should map the query options' do 5 | 6 | client = MockGerry.new 7 | options = client.map_options(['q=createAccount', 'q=createGroup']) 8 | 9 | expect(options).to eq('q=createAccount&q=createGroup') 10 | end 11 | end 12 | 13 | describe '.get' do 14 | it 'should request projects as anoymous' do 15 | stub = stub_get('/projects/', 'projects.json') 16 | 17 | client = MockGerry.new 18 | client.projects 19 | 20 | expect(stub).to have_been_requested 21 | end 22 | 23 | it 'should request projects as user' do 24 | username = 'gerry' 25 | password = 'whoop' 26 | 27 | body = get_fixture('projects.json') 28 | 29 | stub = stub_request(:get, "http://localhost/a/projects/"). 30 | with(:headers => {'Accept'=>'application/json'}). 31 | to_return(:status => 200, :body => body, :headers => {}) 32 | 33 | client = Gerry.new(MockGerry::URL, 'gerry', 'whoop') 34 | projects = client.projects 35 | 36 | # twice because the first is the auth challenge and then the actual request 37 | expect(stub).to have_been_requested.twice 38 | 39 | expect(projects['awesome']['description']).to eq('Awesome project') 40 | expect(projects['clean']['description']).to eq('Clean code!') 41 | end 42 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/gerry-0.1.2/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "rspec/expectations" 2 | require 'webmock/rspec' 3 | 4 | require_relative '../lib/gerry' 5 | 6 | class MockGerry < Gerry::Client 7 | URL = 'http://localhost' 8 | 9 | def initialize 10 | super(URL) 11 | end 12 | end 13 | 14 | def get_fixture(filename) 15 | return '' if filename.empty? 16 | file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename) 17 | File.read(file_path) 18 | end 19 | 20 | def stub_get(url, filename) 21 | body = get_fixture(filename) 22 | stub_request(:get, "#{MockGerry::URL}#{url}"). 23 | to_return(:status => 200, :body => "#{body}", :headers => {'Content-Type' => 'application/json'}) 24 | end 25 | 26 | def stub_put(url, body, response_body=nil) 27 | response = { 28 | status: 200, 29 | headers: { 30 | 'Content-Type' => 'application/json' 31 | }, 32 | body: response_body 33 | } 34 | stub_request(:put, "#{MockGerry::URL}#{url}"). 35 | with(:body => body, :headers => { 'Content-Type' => 'application/json' }). 36 | to_return(response) 37 | end 38 | 39 | def stub_post(url, body, response_body=nil) 40 | response = { 41 | status: 200, 42 | headers: { 43 | 'Content-Type' => 'application/json' 44 | }, 45 | body: response_body 46 | } 47 | stub_request(:post, "#{MockGerry::URL}#{url}"). 48 | with(:body => body, :headers => { 'Content-Type' => 'application/json' }). 49 | to_return(response) 50 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | .DS_Store 3 | .yardoc/ 4 | doc/ 5 | tmp/ 6 | log/ 7 | pkg/ 8 | *.swp 9 | /.bundle 10 | .rvmrc 11 | coverage 12 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/.simplecov: -------------------------------------------------------------------------------- 1 | SimpleCov.start "test_frameworks" -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | - 2.0.0 5 | notifications: 6 | email: false 7 | bundler_args: --without development 8 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gemspec 3 | 4 | gem 'rake' 5 | gem 'fakeweb', '~> 1.3' 6 | gem 'mongrel', '1.2.0.pre2' 7 | 8 | group :development do 9 | gem 'guard' 10 | gem 'guard-rspec' 11 | gem 'guard-bundler' 12 | end 13 | 14 | group :test do 15 | gem 'rspec', '~> 3.1' 16 | gem 'simplecov', require: false 17 | gem 'aruba' 18 | gem 'cucumber', '~> 1.3.17' 19 | end 20 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/Guardfile: -------------------------------------------------------------------------------- 1 | rspec_options = { 2 | version: 1, 3 | all_after_pass: false, 4 | all_on_start: false 5 | } 6 | 7 | guard 'rspec', rspec_options do 8 | watch(%r{^spec/.+_spec\.rb$}) 9 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 10 | watch('spec/spec_helper.rb') { "spec" } 11 | end 12 | 13 | guard 'bundler' do 14 | watch('Gemfile') 15 | watch(/^.+\.gemspec/) 16 | end 17 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 John Nunemaker 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/README.md: -------------------------------------------------------------------------------- 1 | # httparty 2 | 3 | Makes http fun again! 4 | 5 | ## Install 6 | 7 | ``` 8 | gem install httparty 9 | ``` 10 | 11 | ## Requirements 12 | 13 | * Ruby 1.9.3 or higher 14 | * multi_xml 15 | * You like to party! 16 | 17 | ## Examples 18 | 19 | ```ruby 20 | # Use the class methods to get down to business quickly 21 | response = HTTParty.get('https://api.stackexchange.com/2.2/questions?site=stackoverflow') 22 | 23 | puts response.body, response.code, response.message, response.headers.inspect 24 | 25 | # Or wrap things up in your own class 26 | class StackExchange 27 | include HTTParty 28 | base_uri 'api.stackexchange.com' 29 | 30 | def initialize(service, page) 31 | @options = { query: {site: service, page: page} } 32 | end 33 | 34 | def questions 35 | self.class.get("/2.2/questions", @options) 36 | end 37 | 38 | def users 39 | self.class.get("/2.2/users", @options) 40 | end 41 | end 42 | 43 | stack_exchange = StackExchange.new("stackoverflow", 1) 44 | puts stack_exchange.questions 45 | puts stack_exchange.users 46 | ``` 47 | 48 | See the [examples directory](http://github.com/jnunemaker/httparty/tree/master/examples) for even more goodies. 49 | 50 | ## Command Line Interface 51 | 52 | httparty also includes the executable `httparty` which can be 53 | used to query web services and examine the resulting output. By default 54 | it will output the response as a pretty-printed Ruby object (useful for 55 | grokking the structure of output). This can also be overridden to output 56 | formatted XML or JSON. Execute `httparty --help` for all the 57 | options. Below is an example of how easy it is. 58 | 59 | ``` 60 | httparty "https://api.stackexchange.com/2.2/questions?site=stackoverflow" 61 | ``` 62 | 63 | ## Help and Docs 64 | 65 | * https://groups.google.com/forum/#!forum/httparty-gem 66 | * http://rdoc.info/projects/jnunemaker/httparty 67 | * http://stackoverflow.com/questions/tagged/httparty 68 | 69 | ## Contributing 70 | 71 | * Fork the project. 72 | * Run `bundle` 73 | * Run `bundle exec rake` 74 | * Make your feature addition or bug fix. 75 | * Add tests for it. This is important so I don't break it in a future version unintentionally. 76 | * Run `bundle exec rake` (No, REALLY :)) 77 | * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull) 78 | * Send me a pull request. Bonus points for topic branches. 79 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/Rakefile: -------------------------------------------------------------------------------- 1 | begin 2 | require 'rspec/core/rake_task' 3 | RSpec::Core::RakeTask.new(:spec) 4 | rescue LoadError 5 | end 6 | 7 | require 'cucumber/rake/task' 8 | Cucumber::Rake::Task.new(:features) 9 | 10 | task default: [:spec, :features] 11 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/cucumber.yml: -------------------------------------------------------------------------------- 1 | default: features --format progress 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/README.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | * [Amazon Book Search](aaws.rb) 4 | * Httparty included into poro class 5 | * Uses `get` requests 6 | * Transforms query params to uppercased params 7 | 8 | * [Google Search](google.rb) 9 | * Httparty included into poro class 10 | * Uses `get` requests 11 | 12 | * [Crack Custom Parser](crack.rb) 13 | * Creates a custom parser for XML using crack gem 14 | * Uses `get` request 15 | 16 | * [Create HTML Nokogiri parser](nokogiri_html_parser.rb) 17 | * Adds Html as a format 18 | * passed the body of request to Nokogiri 19 | 20 | * [More Custom Parsers](custom_parsers.rb) 21 | * Create an additional parser for atom or make it the ONLY parser 22 | 23 | * [Basic Auth, Delicious](delicious.rb) 24 | * Basic Auth, shows how to merge those into options 25 | * Uses `get` requests 26 | 27 | * [Passing Headers, User Agent](headers_and_user_agents.rb) 28 | * Use the class method of Httparty 29 | * Pass the User-Agent in the headers 30 | * Uses `get` requests 31 | 32 | * [Basic Post Request](basic.rb) 33 | * Httparty included into poro class 34 | * Uses `post` requests 35 | 36 | * [Access Rubyurl Shortener](rubyurl.rb) 37 | * Httparty included into poro class 38 | * Uses `post` requests 39 | 40 | * [Add a custom log file](logging.rb) 41 | * create a log file and have httparty log requests 42 | 43 | * [Accessing StackExchange](stackexchange.rb) 44 | * Httparty included into poro class 45 | * Creates methods for different endpoints 46 | * Uses `get` requests 47 | 48 | * [Accessing Tripit](tripit_sign_in.rb) 49 | * Httparty included into poro class 50 | * Example of using `debug_output` to see headers/urls passed 51 | * Getting and using Cookies 52 | * Uses `get` requests 53 | 54 | * [Accessing Twitter](twitter.rb) 55 | * Httparty included into poro class 56 | * Basic Auth 57 | * Loads settings from a config file 58 | * Uses `get` requests 59 | * Uses `post` requests 60 | 61 | * [Accessing WhoIsMyRep](whoismyrep.rb) 62 | * Httparty included into poro class 63 | * Uses `get` requests 64 | * Two ways to pass params to get, inline on the url or in query hash 65 | 66 | * [Rescue Json Error](rescue_json.rb) 67 | * Rescue errors due to parsing response -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/aaws.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'active_support' 3 | 4 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 5 | require File.join(dir, 'httparty') 6 | require 'pp' 7 | config = YAML.load(File.read(File.join(ENV['HOME'], '.aaws'))) 8 | 9 | module AAWS 10 | class Book 11 | include HTTParty 12 | base_uri 'http://ecs.amazonaws.com' 13 | default_params Service: 'AWSECommerceService', Operation: 'ItemSearch', SearchIndex: 'Books' 14 | 15 | def initialize(key) 16 | self.class.default_params AWSAccessKeyId: key 17 | end 18 | 19 | def search(options = {}) 20 | raise ArgumentError, 'You must search for something' if options[:query].blank? 21 | 22 | # amazon uses nasty camelized query params 23 | options[:query] = options[:query].inject({}) { |h, q| h[q[0].to_s.camelize] = q[1]; h } 24 | 25 | # make a request and return the items (NOTE: this doesn't handle errors at this point) 26 | self.class.get('/onca/xml', options)['ItemSearchResponse']['Items'] 27 | end 28 | end 29 | end 30 | 31 | aaws = AAWS::Book.new(config[:access_key]) 32 | pp aaws.search(query: {title: 'Ruby On Rails'}) 33 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/basic.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | 5 | # You can also use post, put, delete, head, options in the same fashion 6 | response = HTTParty.get('https://api.stackexchange.com/2.2/questions?site=stackoverflow') 7 | puts response.body, response.code, response.message, response.headers.inspect 8 | 9 | # An example post to a minimal rails app in the development environment 10 | # Note that "skip_before_filter :verify_authenticity_token" must be set in the 11 | # "pears" controller for this example 12 | 13 | class Partay 14 | include HTTParty 15 | base_uri 'http://localhost:3000' 16 | end 17 | 18 | options = { 19 | body: { 20 | pear: { # your resource 21 | foo: '123', # your columns/data 22 | bar: 'second', 23 | baz: 'last thing' 24 | } 25 | } 26 | } 27 | 28 | pp Partay.post('/pears.xml', options) 29 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/crack.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'crack' 3 | 4 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 5 | require File.join(dir, 'httparty') 6 | require 'pp' 7 | 8 | class Rep 9 | include HTTParty 10 | 11 | parser( 12 | proc do |body, format| 13 | Crack::XML.parse(body) 14 | end 15 | ) 16 | end 17 | 18 | pp Rep.get('http://whoismyrepresentative.com/getall_mems.php?zip=46544') 19 | pp Rep.get('http://whoismyrepresentative.com/getall_mems.php', query: {zip: 46544}) 20 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/custom_parsers.rb: -------------------------------------------------------------------------------- 1 | class ParseAtom 2 | include HTTParty 3 | 4 | # Support Atom along with the default parsers: xml, json, etc. 5 | class Parser::Atom < HTTParty::Parser 6 | SupportedFormats.merge!({"application/atom+xml" => :atom}) 7 | 8 | protected 9 | 10 | # perform atom parsing on body 11 | def atom 12 | body.to_atom 13 | end 14 | end 15 | 16 | parser Parser::Atom 17 | end 18 | 19 | class OnlyParseAtom 20 | include HTTParty 21 | 22 | # Only support Atom 23 | class Parser::OnlyAtom < HTTParty::Parser 24 | SupportedFormats = {"application/atom+xml" => :atom} 25 | 26 | protected 27 | 28 | # perform atom parsing on body 29 | def atom 30 | body.to_atom 31 | end 32 | end 33 | 34 | parser Parser::OnlyAtom 35 | end 36 | 37 | class SkipParsing 38 | include HTTParty 39 | 40 | # Parse the response body however you like 41 | class Parser::Simple < HTTParty::Parser 42 | def parse 43 | body 44 | end 45 | end 46 | 47 | parser Parser::Simple 48 | end 49 | 50 | class AdHocParsing 51 | include HTTParty 52 | parser( 53 | proc do |body, format| 54 | case format 55 | when :json 56 | body.to_json 57 | when :xml 58 | body.to_xml 59 | else 60 | body 61 | end 62 | end 63 | ) 64 | end 65 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/delicious.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | config = YAML.load(File.read(File.join(ENV['HOME'], '.delicious'))) 5 | 6 | class Delicious 7 | include HTTParty 8 | base_uri 'https://api.del.icio.us/v1' 9 | 10 | def initialize(u, p) 11 | @auth = {username: u, password: p} 12 | end 13 | 14 | # query params that filter the posts are: 15 | # tag (optional). Filter by this tag. 16 | # dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ). 17 | # url (optional). Filter by this url. 18 | # ie: posts(query: {tag: 'ruby'}) 19 | def posts(options = {}) 20 | options.merge!({basic_auth: @auth}) 21 | self.class.get('/posts/get', options) 22 | end 23 | 24 | # query params that filter the posts are: 25 | # tag (optional). Filter by this tag. 26 | # count (optional). Number of items to retrieve (Default:15, Maximum:100). 27 | def recent(options = {}) 28 | options.merge!({basic_auth: @auth}) 29 | self.class.get('/posts/recent', options) 30 | end 31 | end 32 | 33 | delicious = Delicious.new(config['username'], config['password']) 34 | pp delicious.posts(query: {tag: 'ruby'}) 35 | pp delicious.recent 36 | 37 | delicious.recent['posts']['post'].each { |post| puts post['href'] } 38 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/google.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | 5 | class Google 6 | include HTTParty 7 | format :html 8 | end 9 | 10 | # google.com redirects to www.google.com so this is live test for redirection 11 | pp Google.get('http://google.com') 12 | 13 | puts '', '*' * 70, '' 14 | 15 | # check that ssl is requesting right 16 | pp Google.get('https://www.google.com') 17 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/headers_and_user_agents.rb: -------------------------------------------------------------------------------- 1 | # To send custom user agents to identify your application to a web service (or mask as a specific browser for testing), send "User-Agent" as a hash to headers as shown below. 2 | 3 | require 'httparty' 4 | 5 | APPLICATION_NAME = "Httparty" 6 | response = HTTParty.get('http://example.com', headers: {"User-Agent" => APPLICATION_NAME}) 7 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/logging.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'logger' 4 | require 'pp' 5 | 6 | my_logger = Logger.new "httparty.log" 7 | 8 | my_logger.info "Logging can be used on the main HTTParty class. It logs redirects too." 9 | HTTParty.get "http://google.com", logger: my_logger 10 | 11 | my_logger.info '*' * 70 12 | 13 | my_logger.info "It can be used also on a custom class." 14 | 15 | class Google 16 | include HTTParty 17 | logger ::Logger.new "httparty.log" 18 | end 19 | 20 | Google.get "http://google.com" 21 | 22 | my_logger.info '*' * 70 23 | 24 | my_logger.info "The default formatter is :apache. The :curl formatter can also be used." 25 | my_logger.info "You can tell wich method to call on the logger too. It is info by default." 26 | HTTParty.get "http://google.com", logger: my_logger, log_level: :debug, log_format: :curl 27 | 28 | my_logger.info '*' * 70 29 | 30 | my_logger.info "These configs are also available on custom classes." 31 | class Google 32 | include HTTParty 33 | logger ::Logger.new("httparty.log"), :debug, :curl 34 | end 35 | 36 | Google.get "http://google.com" 37 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/nokogiri_html_parser.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'nokogiri' 3 | 4 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 5 | require File.join(dir, 'httparty') 6 | require 'pp' 7 | 8 | class HtmlParserIncluded < HTTParty::Parser 9 | def html 10 | Nokogiri::HTML(body) 11 | end 12 | end 13 | 14 | class Page 15 | include HTTParty 16 | parser HtmlParserIncluded 17 | end 18 | 19 | pp Page.get('http://www.google.com') 20 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/rescue_json.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | 4 | # Take note of the "; 1" at the end of the following line. It's required only if 5 | # running this in IRB, because IRB will try to inspect the variable named 6 | # "request", triggering the exception. 7 | request = HTTParty.get 'https://rubygems.org/api/v1/versions/doesnotexist.json' ; 1 8 | 9 | # Check an exception due to parsing the response 10 | # because HTTParty evaluate the response lazily 11 | begin 12 | request.inspect 13 | # This would also suffice by forcing the request to be parsed: 14 | # request.parsed_response 15 | rescue => e 16 | puts "Rescued #{e.inspect}" 17 | end 18 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/rubyurl.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | 5 | class Rubyurl 6 | include HTTParty 7 | base_uri 'rubyurl.com' 8 | 9 | def self.shorten(website_url) 10 | post('/api/links.json', query: { link: { website_url: website_url } }) 11 | end 12 | end 13 | 14 | pp Rubyurl.shorten('http://istwitterdown.com/') 15 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/stackexchange.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | 5 | class StackExchange 6 | include HTTParty 7 | base_uri 'api.stackexchange.com' 8 | 9 | def initialize(service, page) 10 | @options = { query: {site: service, page: page} } 11 | end 12 | 13 | def questions 14 | self.class.get("/2.2/questions", @options) 15 | end 16 | 17 | def users 18 | self.class.get("/2.2/users", @options) 19 | end 20 | end 21 | 22 | stack_exchange = StackExchange.new("stackoverflow", 1) 23 | pp stack_exchange.questions 24 | pp stack_exchange.users 25 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/tripit_sign_in.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | 4 | class TripIt 5 | include HTTParty 6 | base_uri 'http://www.tripit.com' 7 | debug_output 8 | 9 | def initialize(email, password) 10 | @email = email 11 | response = self.class.get('/account/login') 12 | response = self.class.post( 13 | '/account/login', 14 | body: { 15 | login_email_address: email, 16 | login_password: password 17 | }, 18 | headers: {'Cookie' => response.headers['Set-Cookie']} 19 | ) 20 | @cookie = response.request.options[:headers]['Cookie'] 21 | end 22 | 23 | def account_settings 24 | self.class.get('/account/edit', headers: {'Cookie' => @cookie}) 25 | end 26 | 27 | def logged_in? 28 | account_settings.include? "You're logged in as #{@email}" 29 | end 30 | end 31 | 32 | tripit = TripIt.new('email', 'password') 33 | puts "Logged in: #{tripit.logged_in?}" 34 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/twitter.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | config = YAML.load(File.read(File.join(ENV['HOME'], '.twitter'))) 5 | 6 | class Twitter 7 | include HTTParty 8 | base_uri 'twitter.com' 9 | 10 | def initialize(u, p) 11 | @auth = {username: u, password: p} 12 | end 13 | 14 | # which can be :friends, :user or :public 15 | # options[:query] can be things like since, since_id, count, etc. 16 | def timeline(which = :friends, options = {}) 17 | options.merge!({basic_auth: @auth}) 18 | self.class.get("/statuses/#{which}_timeline.json", options) 19 | end 20 | 21 | def post(text) 22 | options = { query: {status: text}, basic_auth: @auth } 23 | self.class.post('/statuses/update.json', options) 24 | end 25 | end 26 | 27 | twitter = Twitter.new(config['email'], config['password']) 28 | pp twitter.timeline 29 | # pp twitter.timeline(:friends, query: {since_id: 868482746}) 30 | # pp twitter.timeline(:friends, query: 'since_id=868482746') 31 | # pp twitter.post('this is a test of 0.2.0') 32 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/examples/whoismyrep.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | require File.join(dir, 'httparty') 3 | require 'pp' 4 | 5 | class Rep 6 | include HTTParty 7 | end 8 | 9 | pp Rep.get('http://whoismyrepresentative.com/getall_mems.php?zip=46544') 10 | pp Rep.get('http://whoismyrepresentative.com/getall_mems.php', query: {zip: 46544}) 11 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/basic_authentication.feature: -------------------------------------------------------------------------------- 1 | Feature: Basic Authentication 2 | 3 | As a developer 4 | I want to be able to use a service that requires Basic Authentication 5 | Because that is not an uncommon requirement 6 | 7 | Scenario: Passing no credentials to a page requiring Basic Authentication 8 | Given a restricted page at '/basic_auth.html' 9 | When I call HTTParty#get with '/basic_auth.html' 10 | Then it should return a response with a 401 response code 11 | 12 | Scenario: Passing proper credentials to a page requiring Basic Authentication 13 | Given a remote service that returns 'Authenticated Page' 14 | And that service is accessed at the path '/basic_auth.html' 15 | And that service is protected by Basic Authentication 16 | And that service requires the username 'jcash' with the password 'maninblack' 17 | When I call HTTParty#get with '/basic_auth.html' and a basic_auth hash: 18 | | username | password | 19 | | jcash | maninblack | 20 | Then the return value should match 'Authenticated Page' 21 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/deals_with_http_error_codes.feature: -------------------------------------------------------------------------------- 1 | Feature: Deals with HTTP error codes 2 | 3 | As a developer 4 | I want to be informed of non-successful responses 5 | Because sometimes thing explode 6 | And I should probably know what happened 7 | 8 | Scenario: A response of '404 - Not Found' 9 | Given a remote service that returns a 404 status code 10 | And that service is accessed at the path '/404_service.html' 11 | When I call HTTParty#get with '/404_service.html' 12 | Then it should return a response with a 404 response code 13 | 14 | Scenario: A response of '500 - Internal Server Error' 15 | Given a remote service that returns a 500 status code 16 | And that service is accessed at the path '/500_service.html' 17 | When I call HTTParty#get with '/500_service.html' 18 | Then it should return a response with a 500 response code 19 | 20 | Scenario: A non-successful response where I need the body 21 | Given a remote service that returns a 400 status code 22 | And the response from the service has a body of 'Bad response' 23 | And that service is accessed at the path '/400_service.html' 24 | When I call HTTParty#get with '/400_service.html' 25 | Then it should return a response with a 400 response code 26 | And the return value should match 'Bad response' 27 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/digest_authentication.feature: -------------------------------------------------------------------------------- 1 | Feature: Digest Authentication 2 | 3 | As a developer 4 | I want to be able to use a service that requires Digest Authentication 5 | Because that is not an uncommon requirement 6 | 7 | Scenario: Passing no credentials to a page requiring Digest Authentication 8 | Given a restricted page at '/digest_auth.html' 9 | When I call HTTParty#get with '/digest_auth.html' 10 | Then it should return a response with a 401 response code 11 | 12 | Scenario: Passing proper credentials to a page requiring Digest Authentication 13 | Given a remote service that returns 'Digest Authenticated Page' 14 | And that service is accessed at the path '/digest_auth.html' 15 | And that service is protected by Digest Authentication 16 | And that service requires the username 'jcash' with the password 'maninblack' 17 | When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash: 18 | | username | password | 19 | | jcash | maninblack | 20 | Then the return value should match 'Digest Authenticated Page' 21 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/handles_compressed_responses.feature: -------------------------------------------------------------------------------- 1 | Feature: Handles Compressed Responses 2 | 3 | In order to save bandwidth 4 | As a developer 5 | I want to uncompress compressed responses 6 | 7 | Scenario: Supports deflate encoding 8 | Given a remote deflate service 9 | And the response from the service has a body of '

Some HTML

' 10 | And that service is accessed at the path '/deflate_service.html' 11 | When I call HTTParty#get with '/deflate_service.html' 12 | Then the return value should match '

Some HTML

' 13 | 14 | Scenario: Supports gzip encoding 15 | Given a remote gzip service 16 | And the response from the service has a body of '

Some HTML

' 17 | And that service is accessed at the path '/gzip_service.html' 18 | When I call HTTParty#get with '/gzip_service.html' 19 | Then the return value should match '

Some HTML

' 20 | 21 | Scenario: Supports HEAD request with gzip encoding 22 | Given a remote gzip service 23 | And that service is accessed at the path '/gzip_head.gz.js' 24 | When I call HTTParty#head with '/gzip_head.gz.js' 25 | Then it should return a response with a 200 response code 26 | Then it should return a response with a gzip content-encoding 27 | Then it should return a response with a blank body 28 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/steps/env.rb: -------------------------------------------------------------------------------- 1 | require 'mongrel' 2 | require './lib/httparty' 3 | require 'rspec/expectations' 4 | require 'aruba/cucumber' 5 | 6 | def run_server(port) 7 | @host_and_port = "0.0.0.0:#{port}" 8 | @server = Mongrel::HttpServer.new("0.0.0.0", port) 9 | @server.run 10 | @request_options = {} 11 | end 12 | 13 | def new_port 14 | server = TCPServer.new('0.0.0.0', nil) 15 | port = server.addr[1] 16 | ensure 17 | server.close 18 | end 19 | 20 | Before('~@command_line') do 21 | port = ENV["HTTPARTY_PORT"] || new_port 22 | run_server(port) 23 | end 24 | 25 | After do 26 | @server.stop if @server 27 | end 28 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/steps/httparty_response_steps.rb: -------------------------------------------------------------------------------- 1 | # Not needed anymore in ruby 2.0, but needed to resolve constants 2 | # in nested namespaces. This is taken from rails :) 3 | def constantize(camel_cased_word) 4 | names = camel_cased_word.split('::') 5 | names.shift if names.empty? || names.first.empty? 6 | 7 | constant = Object 8 | names.each do |name| 9 | constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) 10 | end 11 | constant 12 | end 13 | 14 | Then /it should return an? (\w+)$/ do |class_string| 15 | expect(@response_from_httparty).to be_a(class_string.class) 16 | end 17 | 18 | Then /the return value should match '(.*)'/ do |expected_text| 19 | expect(@response_from_httparty.parsed_response).to eq(expected_text) 20 | end 21 | 22 | Then /it should return a Hash equaling:/ do |hash_table| 23 | expect(@response_from_httparty).to be_a(Hash) 24 | expect(@response_from_httparty.keys.length).to eq(hash_table.rows.length) 25 | hash_table.hashes.each do |pair| 26 | key, value = pair["key"], pair["value"] 27 | expect(@response_from_httparty.keys).to include(key) 28 | expect(@response_from_httparty[key]).to eq(value) 29 | end 30 | end 31 | 32 | Then /it should return an Array equaling:/ do |array| 33 | expect(@response_from_httparty).to be_a(Array) 34 | expect(@response_from_httparty.parsed_response).to eq(array.raw) 35 | end 36 | 37 | Then /it should return a response with a (\d+) response code/ do |code| 38 | expect(@response_from_httparty.code).to eq(code.to_i) 39 | end 40 | 41 | Then /it should return a response with a (.*) content\-encoding$/ do |content_type| 42 | expect(@response_from_httparty.headers['content-encoding']).to eq('gzip') 43 | end 44 | 45 | Then /it should return a response with a blank body$/ do 46 | expect(@response_from_httparty.body).to be_nil 47 | end 48 | 49 | Then /it should raise (?:an|a) ([\w:]+) exception/ do |exception| 50 | expect(@exception_from_httparty).to_not be_nil 51 | expect(@exception_from_httparty).to be_a constantize(exception) 52 | end 53 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/steps/httparty_steps.rb: -------------------------------------------------------------------------------- 1 | When /^I set my HTTParty timeout option to (\d+)$/ do |timeout| 2 | @request_options[:timeout] = timeout.to_i 3 | end 4 | 5 | When /^I set my HTTParty open_timeout option to (\d+)$/ do |timeout| 6 | @request_options[:open_timeout] = timeout.to_i 7 | end 8 | 9 | When /^I set my HTTParty read_timeout option to (\d+)$/ do |timeout| 10 | @request_options[:read_timeout] = timeout.to_i 11 | end 12 | 13 | When /I call HTTParty#get with '(.*)'$/ do |url| 14 | begin 15 | @response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}", @request_options) 16 | rescue HTTParty::RedirectionTooDeep, Timeout::Error => e 17 | @exception_from_httparty = e 18 | end 19 | end 20 | 21 | When /^I call HTTParty#head with '(.*)'$/ do |url| 22 | begin 23 | @response_from_httparty = HTTParty.head("http://#{@host_and_port}#{url}", @request_options) 24 | rescue HTTParty::RedirectionTooDeep, Timeout::Error => e 25 | @exception_from_httparty = e 26 | end 27 | end 28 | 29 | When /I call HTTParty#get with '(.*)' and a basic_auth hash:/ do |url, auth_table| 30 | h = auth_table.hashes.first 31 | @response_from_httparty = HTTParty.get( 32 | "http://#{@host_and_port}#{url}", 33 | basic_auth: { username: h["username"], password: h["password"] } 34 | ) 35 | end 36 | 37 | When /I call HTTParty#get with '(.*)' and a digest_auth hash:/ do |url, auth_table| 38 | h = auth_table.hashes.first 39 | @response_from_httparty = HTTParty.get( 40 | "http://#{@host_and_port}#{url}", 41 | digest_auth: { username: h["username"], password: h["password"] } 42 | ) 43 | end 44 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/supports_read_timeout_option.feature: -------------------------------------------------------------------------------- 1 | Feature: Supports the read timeout option 2 | In order to handle inappropriately slow response times 3 | As a developer 4 | I want my request to raise an exception after my specified read_timeout as elapsed 5 | 6 | Scenario: A long running response 7 | Given a remote service that returns '

Some HTML

' 8 | And that service is accessed at the path '/long_running_service.html' 9 | And that service takes 2 seconds to generate a response 10 | When I set my HTTParty read_timeout option to 1 11 | And I call HTTParty#get with '/long_running_service.html' 12 | Then it should raise a Timeout::Error exception 13 | And I wait for the server to recover 14 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/supports_redirection.feature: -------------------------------------------------------------------------------- 1 | Feature: Supports Redirection 2 | 3 | As a developer 4 | I want to work with services that may redirect me 5 | And I want it to follow a reasonable number of redirects 6 | Because sometimes web services do that 7 | 8 | Scenario: A service that redirects once 9 | Given a remote service that returns 'Service Response' 10 | And that service is accessed at the path '/landing_service.html' 11 | And the url '/redirector.html' redirects to '/landing_service.html' 12 | When I call HTTParty#get with '/redirector.html' 13 | Then the return value should match 'Service Response' 14 | 15 | # TODO: Look in to why this actually fails... 16 | Scenario: A service that redirects to a relative URL 17 | 18 | Scenario: A service that redirects infinitely 19 | Given the url '/first.html' redirects to '/second.html' 20 | And the url '/second.html' redirects to '/first.html' 21 | When I call HTTParty#get with '/first.html' 22 | Then it should raise an HTTParty::RedirectionTooDeep exception 23 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/features/supports_timeout_option.feature: -------------------------------------------------------------------------------- 1 | Feature: Supports the timeout option 2 | In order to handle inappropriately slow response times 3 | As a developer 4 | I want my request to raise an exception after my specified timeout as elapsed 5 | 6 | Scenario: A long running response 7 | Given a remote service that returns '

Some HTML

' 8 | And that service is accessed at the path '/long_running_service.html' 9 | And that service takes 2 seconds to generate a response 10 | When I set my HTTParty timeout option to 1 11 | And I call HTTParty#get with '/long_running_service.html' 12 | Then it should raise a Timeout::Error exception 13 | And I wait for the server to recover 14 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/httparty.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $LOAD_PATH.push File.expand_path("../lib", __FILE__) 3 | require "httparty/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "httparty" 7 | s.version = HTTParty::VERSION 8 | s.platform = Gem::Platform::RUBY 9 | s.licenses = ['MIT'] 10 | s.authors = ["John Nunemaker", "Sandro Turriate"] 11 | s.email = ["nunemaker@gmail.com"] 12 | s.homepage = "http://jnunemaker.github.com/httparty" 13 | s.summary = 'Makes http fun! Also, makes consuming restful web services dead easy.' 14 | s.description = 'Makes http fun! Also, makes consuming restful web services dead easy.' 15 | 16 | s.required_ruby_version = '>= 1.9.3' 17 | 18 | s.add_dependency 'json', "~> 1.8" 19 | s.add_dependency 'multi_xml', ">= 0.5.2" 20 | 21 | # If this line is removed, all hard partying will cease. 22 | s.post_install_message = "When you HTTParty, you must party hard!" 23 | 24 | s.files = `git ls-files`.split("\n") 25 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 26 | s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } 27 | s.require_paths = ["lib"] 28 | end 29 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/cookie_hash.rb: -------------------------------------------------------------------------------- 1 | class HTTParty::CookieHash < Hash #:nodoc: 2 | CLIENT_COOKIES = %w(path expires domain path secure httponly) 3 | 4 | def add_cookies(value) 5 | case value 6 | when Hash 7 | merge!(value) 8 | when String 9 | value.split('; ').each do |cookie| 10 | array = cookie.split('=', 2) 11 | self[array[0].to_sym] = array[1] 12 | end 13 | else 14 | raise "add_cookies only takes a Hash or a String" 15 | end 16 | end 17 | 18 | def to_cookie_string 19 | delete_if { |k, v| CLIENT_COOKIES.include?(k.to_s.downcase) }.collect { |k, v| "#{k}=#{v}" }.join("; ") 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/exceptions.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | # @abstact Exceptions raised by HTTParty inherit from Error 3 | class Error < StandardError; end 4 | 5 | # Exception raised when you attempt to set a non-existant format 6 | class UnsupportedFormat < Error; end 7 | 8 | # Exception raised when using a URI scheme other than HTTP or HTTPS 9 | class UnsupportedURIScheme < Error; end 10 | 11 | # @abstract Exceptions which inherit from ResponseError contain the Net::HTTP 12 | # response object accessible via the {#response} method. 13 | class ResponseError < Error 14 | # Returns the response of the last request 15 | # @return [Net::HTTPResponse] A subclass of Net::HTTPResponse, e.g. 16 | # Net::HTTPOK 17 | attr_reader :response 18 | 19 | # Instantiate an instance of ResponseError with a Net::HTTPResponse object 20 | # @param [Net::HTTPResponse] 21 | def initialize(response) 22 | @response = response 23 | end 24 | end 25 | 26 | # Exception that is raised when request has redirected too many times. 27 | # Calling {#response} returns the Net:HTTP response object. 28 | class RedirectionTooDeep < ResponseError; end 29 | end 30 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/hash_conversions.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | module HashConversions 3 | # @return This hash as a query string 4 | # 5 | # @example 6 | # { name: "Bob", 7 | # address: { 8 | # street: '111 Ruby Ave.', 9 | # city: 'Ruby Central', 10 | # phones: ['111-111-1111', '222-222-2222'] 11 | # } 12 | # }.to_params 13 | # #=> "name=Bob&address[city]=Ruby Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111 Ruby Ave." 14 | def self.to_params(hash) 15 | hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop 16 | end 17 | 18 | # @param key The key for the param. 19 | # @param value The value for the param. 20 | # 21 | # @return This key value pair as a param 22 | # 23 | # @example normalize_param(:name, "Bob Jones") #=> "name=Bob%20Jones&" 24 | def self.normalize_param(key, value) 25 | param = '' 26 | stack = [] 27 | 28 | if value.respond_to?(:to_ary) 29 | param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join 30 | elsif value.respond_to?(:to_hash) 31 | stack << [key, value.to_hash] 32 | else 33 | param << "#{key}=#{ERB::Util.url_encode(value.to_s)}&" 34 | end 35 | 36 | stack.each do |parent, hash| 37 | hash.each do |k, v| 38 | if v.respond_to?(:to_hash) 39 | stack << ["#{parent}[#{k}]", v.to_hash] 40 | else 41 | param << normalize_param("#{parent}[#{k}]", v) 42 | end 43 | end 44 | end 45 | 46 | param 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/logger/apache_logger.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | module Logger 3 | class ApacheLogger #:nodoc: 4 | TAG_NAME = HTTParty.name 5 | 6 | attr_accessor :level, :logger, :current_time 7 | 8 | def initialize(logger, level) 9 | @logger = logger 10 | @level = level.to_sym 11 | end 12 | 13 | def format(request, response) 14 | current_time = Time.now.strftime("%Y-%m-%d %H:%M:%S %z") 15 | http_method = request.http_method.name.split("::").last.upcase 16 | path = request.path.to_s 17 | content_length = response.respond_to?(:headers) ? response.headers['Content-Length'] : response['Content-Length'] 18 | @logger.send @level, "[#{TAG_NAME}] [#{current_time}] #{response.code} \"#{http_method} #{path}\" #{content_length || '-'} " 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/logger/curl_logger.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | module Logger 3 | class CurlLogger #:nodoc: 4 | TAG_NAME = HTTParty.name 5 | OUT = ">" 6 | IN = "<" 7 | 8 | attr_accessor :level, :logger, :current_time 9 | 10 | def initialize(logger, level) 11 | @logger = logger 12 | @level = level.to_sym 13 | end 14 | 15 | def format(request, response) 16 | messages = [] 17 | time = Time.now.strftime("%Y-%m-%d %H:%M:%S %z") 18 | http_method = request.http_method.name.split("::").last.upcase 19 | path = request.path.to_s 20 | 21 | messages << print(time, OUT, "#{http_method} #{path}") 22 | 23 | if request.options[:headers] && request.options[:headers].size > 0 24 | request.options[:headers].each do |k, v| 25 | messages << print(time, OUT, "#{k}: #{v}") 26 | end 27 | end 28 | 29 | messages << print(time, OUT, request.raw_body) 30 | messages << print(time, OUT, "") 31 | messages << print(time, IN, "HTTP/#{response.http_version} #{response.code}") 32 | 33 | headers = response.respond_to?(:headers) ? response.headers : response 34 | response.each_header do |response_header| 35 | messages << print(time, IN, "#{response_header.capitalize}: #{headers[response_header]}") 36 | end 37 | 38 | messages << print(time, IN, "\n#{response.body}") 39 | 40 | @logger.send @level, messages.join("\n") 41 | end 42 | 43 | def print(time, direction, line) 44 | "[#{TAG_NAME}] [#{time}] #{direction} #{line}" 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/logger/logger.rb: -------------------------------------------------------------------------------- 1 | require 'httparty/logger/apache_logger' 2 | require 'httparty/logger/curl_logger' 3 | 4 | module HTTParty 5 | module Logger 6 | def self.build(logger, level, formatter) 7 | level ||= :info 8 | formatter ||= :apache 9 | 10 | case formatter 11 | when :curl 12 | Logger::CurlLogger.new(logger, level) 13 | else 14 | Logger::ApacheLogger.new(logger, level) 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/module_inheritable_attributes.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | module ModuleInheritableAttributes #:nodoc: 3 | def self.included(base) 4 | base.extend(ClassMethods) 5 | end 6 | 7 | # borrowed from Rails 3.2 ActiveSupport 8 | def self.hash_deep_dup(hash) 9 | duplicate = hash.dup 10 | 11 | duplicate.each_pair do |key, value| 12 | duplicate[key] = if value.is_a?(Hash) 13 | hash_deep_dup(value) 14 | elsif value.is_a?(Proc) 15 | duplicate[key] = value.dup 16 | else 17 | value 18 | end 19 | end 20 | 21 | duplicate 22 | end 23 | 24 | module ClassMethods #:nodoc: 25 | def mattr_inheritable(*args) 26 | @mattr_inheritable_attrs ||= [:mattr_inheritable_attrs] 27 | @mattr_inheritable_attrs += args 28 | 29 | args.each do |arg| 30 | module_eval %(class << self; attr_accessor :#{arg} end) 31 | end 32 | 33 | @mattr_inheritable_attrs 34 | end 35 | 36 | def inherited(subclass) 37 | super 38 | @mattr_inheritable_attrs.each do |inheritable_attribute| 39 | ivar = "@#{inheritable_attribute}" 40 | subclass.instance_variable_set(ivar, instance_variable_get(ivar).clone) 41 | 42 | if instance_variable_get(ivar).respond_to?(:merge) 43 | method = <<-EOM 44 | def self.#{inheritable_attribute} 45 | duplicate = ModuleInheritableAttributes.hash_deep_dup(#{ivar}) 46 | #{ivar} = superclass.#{inheritable_attribute}.merge(duplicate) 47 | end 48 | EOM 49 | 50 | subclass.class_eval method 51 | end 52 | end 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/response/headers.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | class Response #:nodoc: 3 | class Headers 4 | include ::Net::HTTPHeader 5 | 6 | def initialize(header = {}) 7 | @header = header 8 | end 9 | 10 | def ==(other) 11 | @header == other 12 | end 13 | 14 | def inspect 15 | @header.inspect 16 | end 17 | 18 | def method_missing(name, *args, &block) 19 | if @header.respond_to?(name) 20 | @header.send(name, *args, &block) 21 | else 22 | super 23 | end 24 | end 25 | 26 | def respond_to?(method, include_all = false) 27 | super || @header.respond_to?(method, include_all) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/lib/httparty/version.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | VERSION = "0.13.5" 3 | end 4 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/script/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #/ Usage: release 3 | #/ 4 | #/ Tag the version in the repo and push the gem. 5 | #/ 6 | 7 | set -e 8 | cd $(dirname "$0")/.. 9 | 10 | [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && { 11 | grep '^#/' <"$0"| cut -c4- 12 | exit 0 13 | } 14 | 15 | gem_name=httparty 16 | 17 | # Build a new gem archive. 18 | rm -rf $gem_name-*.gem 19 | gem build -q $gem_name.gemspec 20 | 21 | # Make sure we're on the master branch. 22 | (git branch | grep -q '* master') || { 23 | echo "Only release from the master branch." 24 | exit 1 25 | } 26 | 27 | # Figure out what version we're releasing. 28 | tag=v`ls $gem_name-*.gem | sed "s/^$gem_name-\(.*\)\.gem$/\1/"` 29 | 30 | echo "Releasing $tag" 31 | 32 | # Make sure we haven't released this version before. 33 | git fetch -t origin 34 | 35 | (git tag -l | grep -q "$tag") && { 36 | echo "Whoops, there's already a '${tag}' tag." 37 | exit 1 38 | } 39 | 40 | # Tag it and bag it. 41 | gem push $gem_name-*.gem && git tag "$tag" && 42 | git push origin master && git push origin "$tag" 43 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/empty.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/httparty-0.13.5/spec/fixtures/empty.xml -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -d "generated" ] ; then 5 | echo >&2 "error: 'generated' directory already exists. Delete it first." 6 | exit 1 7 | fi 8 | 9 | mkdir generated 10 | 11 | # Generate the CA private key and certificate 12 | openssl req -batch -subj '/CN=INSECURE Test Certificate Authority' -newkey rsa:1024 -new -x509 -days 999999 -keyout generated/ca.key -nodes -out generated/ca.crt 13 | 14 | # Create symlinks for ssl_ca_path 15 | c_rehash generated 16 | 17 | # Generate the server private key and self-signed certificate 18 | openssl req -batch -subj '/CN=localhost' -newkey rsa:1024 -new -x509 -days 999999 -keyout generated/server.key -nodes -out generated/selfsigned.crt 19 | 20 | # Generate certificate signing request with bogus hostname 21 | openssl req -batch -subj '/CN=bogo' -new -days 999999 -key generated/server.key -nodes -out generated/bogushost.csr 22 | 23 | # Sign the certificate requests 24 | openssl x509 -CA generated/ca.crt -CAkey generated/ca.key -set_serial 1 -in generated/selfsigned.crt -out generated/server.crt -clrext -extfile openssl-exts.cnf -extensions cert -days 999999 25 | openssl x509 -req -CA generated/ca.crt -CAkey generated/ca.key -set_serial 1 -in generated/bogushost.csr -out generated/bogushost.crt -clrext -extfile openssl-exts.cnf -extensions cert -days 999999 26 | 27 | # Remove certificate signing requests 28 | rm -f generated/*.csr 29 | 30 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/1fe462c2.0: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICbTCCAdagAwIBAgIJAIAeO9TXtJ45MA0GCSqGSIb3DQEBBQUAMC4xLDAqBgNV 3 | BAMTI0lOU0VDVVJFIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MCAXDTEwMTAy 4 | MDEzNDYyM1oYDzQ3NDgwOTE1MTM0NjIzWjAuMSwwKgYDVQQDEyNJTlNFQ1VSRSBU 5 | ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw 6 | gYkCgYEA3lkBcd352qiIIzqnyvvJj59cx1dnzMyjnuaK2cRH420rBfukLE2MbOVr 7 | 9nYq/7CdjqXpE8uFAF+UTSIK6MWZ/bidkr2xd/et/Ce2pVIVxH+rt3pJz3wZhC3H 8 | Yz+HU4CD2iI9wAzsb6mMV7md1fjlYfir4SBGGPTkcqUJUp2/tQMCAwEAAaOBkDCB 9 | jTAdBgNVHQ4EFgQUy0Lz6RgmtpywlBOXdPABQArp358wXgYDVR0jBFcwVYAUy0Lz 10 | 6RgmtpywlBOXdPABQArp35+hMqQwMC4xLDAqBgNVBAMTI0lOU0VDVVJFIFRlc3Qg 11 | Q2VydGlmaWNhdGUgQXV0aG9yaXR5ggkAgB471Ne0njkwDAYDVR0TBAUwAwEB/zAN 12 | BgkqhkiG9w0BAQUFAAOBgQCmi3JQm+EIWjkRlyz9sijkYS+Ps4opmd/weeaXwa4E 13 | gVBWJGyiduB+kBnfv61+/tDjlrbjBDH5dP8suczHQL8gox4zGgjw64KH4o1ujZYR 14 | cEPbhnUpwbXu7yItlajBZfpFefjF5P0Ao2iEzQldDy0D6nQ19h5QANvQxqweTPQp 15 | pw== 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/bogushost.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICBTCCAW6gAwIBAgIBATANBgkqhkiG9w0BAQUFADAuMSwwKgYDVQQDEyNJTlNF 3 | Q1VSRSBUZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTAgFw0xMDEwMjAxMzQ2MjNa 4 | GA80NzQ4MDkxNTEzNDYyM1owDzENMAsGA1UEAxMEYm9nbzCBnzANBgkqhkiG9w0B 5 | AQEFAAOBjQAwgYkCgYEAr6b0ZBrRrVvPmPbQv36Jnj5jv00ZkhimXrmbv9Z1AdIZ 6 | WSsBpMd8TP7exE5OR5/DaxKmiZqVskgRyRkLm52/Dkt7Ncrzr5I3unHnMqsAv/28 7 | 5fGlYoRxnkCGMse/6NOFgCemRFw/bglxPNAGrFYKStameBRbCm0dCgtlvcwzdf8C 8 | AwEAAaNQME4wDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUddLPFtGmb0aFWbTl2kAo 9 | xD+fd6kwHwYDVR0jBBgwFoAUy0Lz6RgmtpywlBOXdPABQArp358wDQYJKoZIhvcN 10 | AQEFBQADgYEAosqpPVsFu6cOIhGFT85Y1wwRUaihO0vWO7ghBU5ScuRU3tuvyJDZ 11 | Z/HoAMXV6XZjVZzRosjtPjFbyWkZYjUqJJRMyEaRiGArWe6urKLzwnD6R9O3eNa5 12 | 7bgFhzZ5WBldJmtq4A3oNqBuvgZkYM6NVKvS4UoakkTliHB21/mDOSY= 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICbTCCAdagAwIBAgIJAIAeO9TXtJ45MA0GCSqGSIb3DQEBBQUAMC4xLDAqBgNV 3 | BAMTI0lOU0VDVVJFIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MCAXDTEwMTAy 4 | MDEzNDYyM1oYDzQ3NDgwOTE1MTM0NjIzWjAuMSwwKgYDVQQDEyNJTlNFQ1VSRSBU 5 | ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw 6 | gYkCgYEA3lkBcd352qiIIzqnyvvJj59cx1dnzMyjnuaK2cRH420rBfukLE2MbOVr 7 | 9nYq/7CdjqXpE8uFAF+UTSIK6MWZ/bidkr2xd/et/Ce2pVIVxH+rt3pJz3wZhC3H 8 | Yz+HU4CD2iI9wAzsb6mMV7md1fjlYfir4SBGGPTkcqUJUp2/tQMCAwEAAaOBkDCB 9 | jTAdBgNVHQ4EFgQUy0Lz6RgmtpywlBOXdPABQArp358wXgYDVR0jBFcwVYAUy0Lz 10 | 6RgmtpywlBOXdPABQArp35+hMqQwMC4xLDAqBgNVBAMTI0lOU0VDVVJFIFRlc3Qg 11 | Q2VydGlmaWNhdGUgQXV0aG9yaXR5ggkAgB471Ne0njkwDAYDVR0TBAUwAwEB/zAN 12 | BgkqhkiG9w0BAQUFAAOBgQCmi3JQm+EIWjkRlyz9sijkYS+Ps4opmd/weeaXwa4E 13 | gVBWJGyiduB+kBnfv61+/tDjlrbjBDH5dP8suczHQL8gox4zGgjw64KH4o1ujZYR 14 | cEPbhnUpwbXu7yItlajBZfpFefjF5P0Ao2iEzQldDy0D6nQ19h5QANvQxqweTPQp 15 | pw== 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/ca.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXgIBAAKBgQDeWQFx3fnaqIgjOqfK+8mPn1zHV2fMzKOe5orZxEfjbSsF+6Qs 3 | TYxs5Wv2dir/sJ2OpekTy4UAX5RNIgroxZn9uJ2SvbF39638J7alUhXEf6u3eknP 4 | fBmELcdjP4dTgIPaIj3ADOxvqYxXuZ3V+OVh+KvhIEYY9ORypQlSnb+1AwIDAQAB 5 | AoGBAL147VFCDlM1gGU865V+wIFCFQbNxedwjxGuda4io/v6oEoF6R3Tq5F0Y27v 6 | va6Lq4fOe/LhYGI0EKU2GEPJd3F2wA21r+81InPKAkqYI5CDQtKDDNLviur8ZVKF 7 | i3UzutjeYoCqmWeHaKPD6w5DtqeBieem7LTWRyXlFtHZV/nBAkEA8nsMOSd1+JTm 8 | ZT4HDsEFQrN8mIFUUioFSHPut2CwzvTEW+hTkLQiog3bua4n7uQOFImR63X9qMsh 9 | IjZRJQNmowJBAOq+mQdnRWYKl0SYb++Eb3uW6L4h1zsW375+caKo9omtpeqDW/y0 10 | BWyY0q4DPkm3yU26Yr+b2JijISrml9/8PiECQQDHuXyG8y7jktn3GFE94NURbL+6 11 | 6gPnLX9ufzdoSjc4MDowrbtvHEDOlHWgioeP6L6EQhA0DtrhlnbzNCRARX3bAkEA 12 | jQOsF+dwqAjKr/lGnMKY2cxgyf64NZXbGKsKhmUrnK9E0SjR9G8MJx1yyffGzi/q 13 | bJf/xAzRw3eTcBsPtwznIQJAHq5MOK7oaUuO+6cbsZYpOYOOkKIvDLiOtdSr7LTI 14 | DziH/fpzB0VhCmFhhEQwHhlB4t3m66A9TelHmhrCDsIaLA== 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/selfsigned.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICHTCCAYagAwIBAgIJALT/G+ylQljIMA0GCSqGSIb3DQEBBQUAMBQxEjAQBgNV 3 | BAMTCWxvY2FsaG9zdDAgFw0xMDEwMjAxMzQ2MjNaGA80NzQ4MDkxNTEzNDYyM1ow 4 | FDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB 5 | gQCvpvRkGtGtW8+Y9tC/fomePmO/TRmSGKZeuZu/1nUB0hlZKwGkx3xM/t7ETk5H 6 | n8NrEqaJmpWySBHJGQubnb8OS3s1yvOvkje6cecyqwC//bzl8aVihHGeQIYyx7/o 7 | 04WAJ6ZEXD9uCXE80AasVgpK1qZ4FFsKbR0KC2W9zDN1/wIDAQABo3UwczAdBgNV 8 | HQ4EFgQUddLPFtGmb0aFWbTl2kAoxD+fd6kwRAYDVR0jBD0wO4AUddLPFtGmb0aF 9 | WbTl2kAoxD+fd6mhGKQWMBQxEjAQBgNVBAMTCWxvY2FsaG9zdIIJALT/G+ylQljI 10 | MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAlOCBO54S88mD3VYviER6 11 | V+lkd7iWmdas2wUUDeMKA9CxnirWi7ne2U7wQH/5FJ1j3ImSfjb4h/98xiVJE84e 12 | Ld7mb61g/M4g4b62kt0HK8/cGUxfuz5zwIfi28qJq3ow6AFEq1fywbJvUAnnamwU 13 | cZF/qoVfJhus2mXjYc4hFWg= 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICCjCCAXOgAwIBAgIBATANBgkqhkiG9w0BAQUFADAuMSwwKgYDVQQDEyNJTlNF 3 | Q1VSRSBUZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTAgFw0xMDEwMjAxMzQ2MjNa 4 | GA80NzQ4MDkxNTEzNDYyM1owFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqG 5 | SIb3DQEBAQUAA4GNADCBiQKBgQCvpvRkGtGtW8+Y9tC/fomePmO/TRmSGKZeuZu/ 6 | 1nUB0hlZKwGkx3xM/t7ETk5Hn8NrEqaJmpWySBHJGQubnb8OS3s1yvOvkje6cecy 7 | qwC//bzl8aVihHGeQIYyx7/o04WAJ6ZEXD9uCXE80AasVgpK1qZ4FFsKbR0KC2W9 8 | zDN1/wIDAQABo1AwTjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBR10s8W0aZvRoVZ 9 | tOXaQCjEP593qTAfBgNVHSMEGDAWgBTLQvPpGCa2nLCUE5d08AFACunfnzANBgkq 10 | hkiG9w0BAQUFAAOBgQCR4Oor0YAvK0tNFrOLtqmC6D0F5IYCyu7komk7JGn9L4nn 11 | 7VyVxd4MXdc1r1v+WP5JtnA9ZjMmEmH9gl4gwR/Cu+TMkArsq0Z8mREOLNL8pwpx 12 | Zxgk0CwacYR9RQcpuJ9nSDzVoO5ecYkb5C9q7gwgqbmCzr7oz/rwTqRwiUZCVQ== 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/generated/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQCvpvRkGtGtW8+Y9tC/fomePmO/TRmSGKZeuZu/1nUB0hlZKwGk 3 | x3xM/t7ETk5Hn8NrEqaJmpWySBHJGQubnb8OS3s1yvOvkje6cecyqwC//bzl8aVi 4 | hHGeQIYyx7/o04WAJ6ZEXD9uCXE80AasVgpK1qZ4FFsKbR0KC2W9zDN1/wIDAQAB 5 | AoGALIdgkTgTS6VovVhklwcXEBy04LxE7Tp+gqj/COTvCKUgc/BpHELOCh7ajl1j 6 | jti7i5tQyLV9mZKXn6lPvgWBd0w+p6VhM4NFA97CoodEJm2ckFC9zUABCh9dOpbm 7 | 8KzF7hdpYWgJJchwwZ60tbcP7K1DkiNX6Kk9qKQEWvitMBECQQDpOSzzLldcEU9l 8 | ze/nG2+rf6ecaPnKeafY8R2qVils8I7ZJAW3+0bNT5gQs7rT7aWo8vMvrXq++lWb 9 | JkNV6hK9AkEAwM5wsmg7REmAaDwgUBq5mNt963/uG2ihAODFS70lYT23UYl5Y3rD 10 | s3qU4ntG4DvWIQgPdwdstzDh9fMBVXa1awJBAID1WoOE5k1ETRDP1I2HwDGmPnng 11 | Ge75YfQ1LuAXEITqZzJuFrNqv/Waw0zI9M9moqlO3WVJmYusRFWrzKPe8EkCQEwC 12 | FlN+275z63csHOD3aCtmfCGW8VtEyBP8iErvagkHt3khZQVepD/hF0ihqLNFY4jq 13 | EI6wEp+1WZ8ICYKTpbkCQQDhl5QLdy5Xo3k3agCnB9nktSzs2iqFvsGvfOAW4628 14 | iThKTNua6bBvbdiG0Vh2Sv0XBYVJoHB3WnTVgFyPJaaF 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/ssl/openssl-exts.cnf: -------------------------------------------------------------------------------- 1 | [ca] 2 | basicConstraints=critical,CA:true 3 | subjectKeyIdentifier=hash 4 | authorityKeyIdentifier=keyid:always,issuer:always 5 | 6 | [cert] 7 | basicConstraints=critical,CA:false 8 | subjectKeyIdentifier=hash 9 | authorityKeyIdentifier=keyid,issuer 10 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/twitter.csv: -------------------------------------------------------------------------------- 1 | "name","url","id","description","protected","screen_name","followers_count","profile_image_url","location" 2 | "Magic 8 Bot",,"17656026","ask me a question","false","magic8bot","90","http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg", -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/fixtures/undefined_method_add_node_for_nil.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/httparty/exception_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 2 | 3 | RSpec.describe HTTParty::Error do 4 | subject { described_class } 5 | 6 | describe '#ancestors' do 7 | subject { super().ancestors } 8 | it { is_expected.to include(StandardError) } 9 | end 10 | 11 | describe HTTParty::UnsupportedFormat do 12 | describe '#ancestors' do 13 | subject { super().ancestors } 14 | it { is_expected.to include(HTTParty::Error) } 15 | end 16 | end 17 | 18 | describe HTTParty::UnsupportedURIScheme do 19 | describe '#ancestors' do 20 | subject { super().ancestors } 21 | it { is_expected.to include(HTTParty::Error) } 22 | end 23 | end 24 | 25 | describe HTTParty::ResponseError do 26 | describe '#ancestors' do 27 | subject { super().ancestors } 28 | it { is_expected.to include(HTTParty::Error) } 29 | end 30 | end 31 | 32 | describe HTTParty::RedirectionTooDeep do 33 | describe '#ancestors' do 34 | subject { super().ancestors } 35 | it { is_expected.to include(HTTParty::ResponseError) } 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/httparty/hash_conversions_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe HTTParty::HashConversions do 2 | describe ".to_params" do 3 | it "creates a params string from a hash" do 4 | hash = { 5 | name: "bob", 6 | address: { 7 | street: '111 ruby ave.', 8 | city: 'ruby central', 9 | phones: ['111-111-1111', '222-222-2222'] 10 | } 11 | } 12 | expect(HTTParty::HashConversions.to_params(hash)).to eq("name=bob&address[street]=111%20ruby%20ave.&address[city]=ruby%20central&address[phones][]=111-111-1111&address[phones][]=222-222-2222") 13 | end 14 | end 15 | 16 | describe ".normalize_param" do 17 | context "value is an array" do 18 | it "creates a params string" do 19 | expect( 20 | HTTParty::HashConversions.normalize_param(:people, ["Bob Jones", "Mike Smith"]) 21 | ).to eq("people[]=Bob%20Jones&people[]=Mike%20Smith&") 22 | end 23 | end 24 | 25 | context "value is hash" do 26 | it "creates a params string" do 27 | expect( 28 | HTTParty::HashConversions.normalize_param(:person, { name: "Bob Jones" }) 29 | ).to eq("person[name]=Bob%20Jones&") 30 | end 31 | end 32 | 33 | context "value is a string" do 34 | it "creates a params string" do 35 | expect( 36 | HTTParty::HashConversions.normalize_param(:name, "Bob Jones") 37 | ).to eq("name=Bob%20Jones&") 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/httparty/logger/apache_logger_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')) 2 | 3 | RSpec.describe HTTParty::Logger::ApacheLogger do 4 | let(:subject) { described_class.new(logger_double, :info) } 5 | let(:logger_double) { double('Logger') } 6 | let(:request_double) { double('Request', http_method: Net::HTTP::Get, path: "http://my.domain.com/my_path") } 7 | let(:request_time) { Time.new.strftime("%Y-%m-%d %H:%M:%S %z") } 8 | 9 | before do 10 | subject.current_time = request_time 11 | expect(logger_double).to receive(:info).with(log_message) 12 | end 13 | 14 | describe "#format" do 15 | let(:log_message) { "[HTTParty] [#{request_time}] 302 \"GET http://my.domain.com/my_path\" - " } 16 | 17 | it "formats a response in a style that resembles apache's access log" do 18 | response_double = double( 19 | code: 302, 20 | :[] => nil 21 | ) 22 | 23 | subject.format(request_double, response_double) 24 | end 25 | 26 | context 'when there is a parsed response' do 27 | let(:log_message) { "[HTTParty] [#{request_time}] 200 \"GET http://my.domain.com/my_path\" 512 "} 28 | 29 | it "can handle the Content-Length header" do 30 | # Simulate a parsed response that is an array, where accessing a string key will raise an error. See Issue #299. 31 | response_double = double( 32 | code: 200, 33 | headers: { 'Content-Length' => 512 } 34 | ) 35 | allow(response_double).to receive(:[]).with('Content-Length').and_raise(TypeError.new('no implicit conversion of String into Integer')) 36 | 37 | subject.format(request_double, response_double) 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/httparty/logger/curl_logger_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')) 2 | 3 | RSpec.describe HTTParty::Logger::CurlLogger do 4 | describe "#format" do 5 | it "formats a response in a style that resembles a -v curl" do 6 | logger_double = double 7 | expect(logger_double).to receive(:info).with( 8 | /\[HTTParty\] \[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\ [+-]\d{4}\] > GET http:\/\/localhost/) 9 | 10 | subject = described_class.new(logger_double, :info) 11 | 12 | stub_http_response_with("google.html") 13 | 14 | response = HTTParty::Request.new.perform 15 | subject.format(response.request, response) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/httparty/logger/logger_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')) 2 | 3 | RSpec.describe HTTParty::Logger do 4 | describe ".build" do 5 | subject { HTTParty::Logger } 6 | 7 | it "defaults level to :info" do 8 | logger_double = double 9 | expect(subject.build(logger_double, nil, nil).level).to eq(:info) 10 | end 11 | 12 | it "defaults format to :apache" do 13 | logger_double = double 14 | expect(subject.build(logger_double, nil, nil)).to be_an_instance_of(HTTParty::Logger::ApacheLogger) 15 | end 16 | 17 | it "builds :curl style logger" do 18 | logger_double = double 19 | expect(subject.build(logger_double, nil, :curl)).to be_an_instance_of(HTTParty::Logger::CurlLogger) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "simplecov" 2 | SimpleCov.start 3 | 4 | require "httparty" 5 | require "fakeweb" 6 | 7 | def file_fixture(filename) 8 | open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename}")).read 9 | end 10 | 11 | Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each {|f| require f} 12 | 13 | RSpec.configure do |config| 14 | config.include HTTParty::StubResponse 15 | config.include HTTParty::SSLTestHelper 16 | 17 | config.before(:suite) do 18 | FakeWeb.allow_net_connect = false 19 | end 20 | 21 | config.after(:suite) do 22 | FakeWeb.allow_net_connect = true 23 | end 24 | 25 | config.expect_with :rspec do |expectations| 26 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 27 | end 28 | 29 | config.mock_with :rspec do |mocks| 30 | mocks.verify_partial_doubles = false 31 | end 32 | 33 | config.filter_run :focus 34 | config.run_all_when_everything_filtered = true 35 | 36 | config.disable_monkey_patching! 37 | 38 | config.warnings = true 39 | 40 | if config.files_to_run.one? 41 | config.default_formatter = 'doc' 42 | end 43 | 44 | config.profile_examples = 10 45 | 46 | config.order = :random 47 | 48 | Kernel.srand config.seed 49 | end 50 | 51 | RSpec::Matchers.define :use_ssl do 52 | match(&:use_ssl?) 53 | end 54 | 55 | RSpec::Matchers.define :use_cert_store do |cert_store| 56 | match do |connection| 57 | connection.cert_store == cert_store 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/support/ssl_test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | 3 | module HTTParty 4 | module SSLTestHelper 5 | def ssl_verify_test(mode, ca_basename, server_cert_filename, options = {}) 6 | options = { 7 | format: :json, 8 | timeout: 30 9 | }.merge(options) 10 | 11 | if mode 12 | ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__) 13 | raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path) 14 | options[mode] = ca_path 15 | end 16 | 17 | begin 18 | test_server = SSLTestServer.new( 19 | rsa_key: File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)), 20 | cert: File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__))) 21 | 22 | test_server.start 23 | 24 | if mode 25 | ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__) 26 | raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path) 27 | return HTTParty.get("https://localhost:#{test_server.port}/", options) 28 | else 29 | return HTTParty.get("https://localhost:#{test_server.port}/", options) 30 | end 31 | ensure 32 | test_server.stop if test_server 33 | end 34 | 35 | test_server = SSLTestServer.new({ 36 | rsa_key: path.join('server.key').read, 37 | cert: path.join(server_cert_filename).read 38 | }) 39 | 40 | test_server.start 41 | 42 | HTTParty.get("https://localhost:#{test_server.port}/", options) 43 | ensure 44 | test_server.stop if test_server 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /bundle/ruby/gems/httparty-0.13.5/spec/support/ssl_test_server.rb: -------------------------------------------------------------------------------- 1 | require 'openssl' 2 | require 'socket' 3 | require 'thread' 4 | 5 | # NOTE: This code is garbage. It probably has deadlocks, it might leak 6 | # threads, and otherwise cause problems in a real system. It's really only 7 | # intended for testing HTTParty. 8 | class SSLTestServer 9 | attr_accessor :ctx # SSLContext object 10 | attr_reader :port 11 | 12 | def initialize(options = {}) 13 | @ctx = OpenSSL::SSL::SSLContext.new 14 | @ctx.cert = OpenSSL::X509::Certificate.new(options[:cert]) 15 | @ctx.key = OpenSSL::PKey::RSA.new(options[:rsa_key]) 16 | @ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Don't verify client certificate 17 | @port = options[:port] || 0 18 | @thread = nil 19 | @stopping_mutex = Mutex.new 20 | @stopping = false 21 | end 22 | 23 | def start 24 | @raw_server = TCPServer.new(@port) 25 | 26 | if @port == 0 27 | @port = Socket.getnameinfo(@raw_server.getsockname, Socket::NI_NUMERICHOST | Socket::NI_NUMERICSERV)[1].to_i 28 | end 29 | 30 | @ssl_server = OpenSSL::SSL::SSLServer.new(@raw_server, @ctx) 31 | 32 | @stopping_mutex.synchronize { 33 | return if @stopping 34 | @thread = Thread.new { thread_main } 35 | } 36 | 37 | nil 38 | end 39 | 40 | def stop 41 | @stopping_mutex.synchronize { 42 | return if @stopping 43 | @stopping = true 44 | } 45 | @thread.join 46 | end 47 | 48 | private 49 | 50 | def thread_main 51 | until @stopping_mutex.synchronize { @stopping } 52 | (rr, _, _) = select([@ssl_server.to_io], nil, nil, 0.1) 53 | 54 | next unless rr && rr.include?(@ssl_server.to_io) 55 | 56 | socket = @ssl_server.accept 57 | 58 | Thread.new { 59 | header = [] 60 | 61 | until (line = socket.readline).rstrip.empty? 62 | header << line 63 | end 64 | 65 | response = < 'json' 6 | gemspec :name => 'json_pure' 7 | gemspec :name => 'json-java' 8 | 9 | gem 'utils' 10 | gem 'test-unit' 11 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/README-json-jruby.markdown: -------------------------------------------------------------------------------- 1 | JSON-JRuby 2 | ========== 3 | 4 | JSON-JRuby is a port of Florian Frank's native 5 | [`json` library](http://json.rubyforge.org/) to JRuby. 6 | It aims to be a perfect drop-in replacement for `json_pure`. 7 | 8 | 9 | Development version 10 | =================== 11 | 12 | The latest version is available from the 13 | [Git repository](http://github.com/mernen/json-jruby/tree): 14 | 15 | git clone git://github.com/mernen/json-jruby.git 16 | 17 | 18 | Compiling 19 | ========= 20 | 21 | You'll need JRuby version 1.2 or greater to build JSON-JRuby. 22 | Its path must be set on the `jruby.dir` property of 23 | `nbproject/project.properties` (defaults to `../jruby`). 24 | 25 | Additionally, you'll need [Ant](http://ant.apache.org/), and 26 | [Ragel](http://www.cs.queensu.ca/~thurston/ragel/) 6.4 or greater. 27 | 28 | Then, from the folder where the sources are located, type: 29 | 30 | ant clean jar 31 | 32 | to clean any leftovers from previous builds and generate the `.jar` files. 33 | To generate a RubyGem, specify the `gem` action rather than `jar`. 34 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/TODO: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/VERSION: -------------------------------------------------------------------------------- 1 | 1.8.3 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/data/example.json: -------------------------------------------------------------------------------- 1 | {"a":2,"b":3.141,"TIME":"2007-03-14T11:52:40","c":"c","d":[1,"b",3.14],"COUNT":666,"e":{"foo":"bar"},"foo":"B\u00e4r","g":"\u677e\u672c\u884c\u5f18","h":1000.0,"bar":"\u00a9 \u2260 \u20ac!","i":0.001,"j":"\ud840\udc01"} 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/data/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Javascript Example 6 | 7 | 8 | 9 | 10 | 11 |

Fetching object from server

12 |
13 | Wait...
14 | 15 |
16 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/diagrams/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/diagrams/.keep -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/.RUBYARCHDIR.-.json.-.ext.time: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/.RUBYARCHDIR.-.json.-.ext.time -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/depend: -------------------------------------------------------------------------------- 1 | generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | $defs << "-DJSON_GENERATOR" 4 | create_makefile 'json/ext/generator' 5 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/generator-x64-mingw32.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Init_generator 3 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/generator.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/ext/json/ext/generator/generator.so -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/.RUBYARCHDIR.-.json.-.ext.time: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/.RUBYARCHDIR.-.json.-.ext.time -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/depend: -------------------------------------------------------------------------------- 1 | parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | create_makefile 'json/ext/parser' 4 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/parser-x64-mingw32.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Init_parser 3 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/ext/json/ext/parser/parser.so -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/ext/json/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | create_makefile('json') 3 | 4 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/install.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | include FileUtils::Verbose 5 | require 'rbconfig' 6 | include\ 7 | begin 8 | RbConfig 9 | rescue NameError 10 | Config 11 | end 12 | 13 | sitelibdir = CONFIG["sitelibdir"] 14 | cd 'lib' do 15 | install('json.rb', sitelibdir) 16 | mkdir_p File.join(sitelibdir, 'json') 17 | for file in Dir['json/**/*}'] 18 | d = File.join(sitelibdir, file) 19 | mkdir_p File.dirname(d) 20 | install(file, d) 21 | end 22 | end 23 | warn " *** Installed PURE ruby library." 24 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/java/src/json/ext/GeneratorService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is copyrighted work by Daniel Luz . 3 | * 4 | * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files 5 | * for details. 6 | */ 7 | package json.ext; 8 | 9 | import java.io.IOException; 10 | import java.lang.ref.WeakReference; 11 | 12 | import org.jruby.Ruby; 13 | import org.jruby.RubyClass; 14 | import org.jruby.RubyModule; 15 | import org.jruby.runtime.load.BasicLibraryService; 16 | 17 | /** 18 | * The service invoked by JRuby's {@link org.jruby.runtime.load.LoadService LoadService}. 19 | * Defines the JSON::Ext::Generator module. 20 | * @author mernen 21 | */ 22 | public class GeneratorService implements BasicLibraryService { 23 | public boolean basicLoad(Ruby runtime) throws IOException { 24 | runtime.getLoadService().require("json/common"); 25 | RuntimeInfo info = RuntimeInfo.initRuntime(runtime); 26 | 27 | info.jsonModule = new WeakReference(runtime.defineModule("JSON")); 28 | RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext"); 29 | RubyModule generatorModule = jsonExtModule.defineModuleUnder("Generator"); 30 | 31 | RubyClass stateClass = 32 | generatorModule.defineClassUnder("State", runtime.getObject(), 33 | GeneratorState.ALLOCATOR); 34 | stateClass.defineAnnotatedMethods(GeneratorState.class); 35 | info.generatorStateClass = new WeakReference(stateClass); 36 | 37 | RubyModule generatorMethods = 38 | generatorModule.defineModuleUnder("GeneratorMethods"); 39 | GeneratorMethods.populate(info, generatorMethods); 40 | 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/java/src/json/ext/ParserService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is copyrighted work by Daniel Luz . 3 | * 4 | * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files 5 | * for details. 6 | */ 7 | package json.ext; 8 | 9 | import java.io.IOException; 10 | import java.lang.ref.WeakReference; 11 | 12 | import org.jruby.Ruby; 13 | import org.jruby.RubyClass; 14 | import org.jruby.RubyModule; 15 | import org.jruby.runtime.load.BasicLibraryService; 16 | 17 | /** 18 | * The service invoked by JRuby's {@link org.jruby.runtime.load.LoadService LoadService}. 19 | * Defines the JSON::Ext::Parser class. 20 | * @author mernen 21 | */ 22 | public class ParserService implements BasicLibraryService { 23 | public boolean basicLoad(Ruby runtime) throws IOException { 24 | runtime.getLoadService().require("json/common"); 25 | RuntimeInfo info = RuntimeInfo.initRuntime(runtime); 26 | 27 | info.jsonModule = new WeakReference(runtime.defineModule("JSON")); 28 | RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext"); 29 | RubyClass parserClass = 30 | jsonExtModule.defineClassUnder("Parser", runtime.getObject(), 31 | Parser.ALLOCATOR); 32 | parserClass.defineAnnotatedMethods(Parser.class); 33 | return true; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/json-java.gemspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env jruby 2 | require "rubygems" 3 | 4 | spec = Gem::Specification.new do |s| 5 | s.name = "json" 6 | s.version = File.read("VERSION").chomp 7 | s.summary = "JSON implementation for JRuby" 8 | s.description = "A JSON implementation as a JRuby extension." 9 | s.author = "Daniel Luz" 10 | s.email = "dev+ruby@mernen.com" 11 | s.homepage = "http://json-jruby.rubyforge.org/" 12 | s.platform = 'java' 13 | s.rubyforge_project = "json-jruby" 14 | s.licenses = ["Ruby"] 15 | 16 | s.files = Dir["{docs,lib,tests}/**/*"] 17 | end 18 | 19 | if $0 == __FILE__ 20 | Gem::Builder.new(spec).build 21 | else 22 | spec 23 | end 24 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json.rb: -------------------------------------------------------------------------------- 1 | require 'json/common' 2 | 3 | ## 4 | # = JavaScript Object Notation (JSON) 5 | # 6 | # JSON is a lightweight data-interchange format. It is easy for us 7 | # humans to read and write. Plus, equally simple for machines to generate or parse. 8 | # JSON is completely language agnostic, making it the ideal interchange format. 9 | # 10 | # Built on two universally available structures: 11 | # 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array. 12 | # 2. An ordered list of values. More commonly called an _array_, vector, sequence or list. 13 | # 14 | # To read more about JSON visit: http://json.org 15 | # 16 | # == Parsing JSON 17 | # 18 | # To parse a JSON string received by another application or generated within 19 | # your existing application: 20 | # 21 | # require 'json' 22 | # 23 | # my_hash = JSON.parse('{"hello": "goodbye"}') 24 | # puts my_hash["hello"] => "goodbye" 25 | # 26 | # Notice the extra quotes '' around the hash notation. Ruby expects 27 | # the argument to be a string and can't convert objects like a hash or array. 28 | # 29 | # Ruby converts your string into a hash 30 | # 31 | # == Generating JSON 32 | # 33 | # Creating a JSON string for communication or serialization is 34 | # just as simple. 35 | # 36 | # require 'json' 37 | # 38 | # my_hash = {:hello => "goodbye"} 39 | # puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}" 40 | # 41 | # Or an alternative way: 42 | # 43 | # require 'json' 44 | # puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}" 45 | # 46 | # JSON.generate only allows objects or arrays to be converted 47 | # to JSON syntax. to_json, however, accepts many Ruby classes 48 | # even though it acts only as a method for serialization: 49 | # 50 | # require 'json' 51 | # 52 | # 1.to_json => "1" 53 | # 54 | module JSON 55 | require 'json/version' 56 | 57 | begin 58 | require 'json/ext' 59 | rescue LoadError 60 | require 'json/pure' 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/bigdecimal.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::BigDecimal) or require 'bigdecimal' 5 | 6 | class BigDecimal 7 | # Import a JSON Marshalled object. 8 | # 9 | # method used for JSON marshalling support. 10 | def self.json_create(object) 11 | BigDecimal._load object['b'] 12 | end 13 | 14 | # Marshal the object to JSON. 15 | # 16 | # method used for JSON marshalling support. 17 | def as_json(*) 18 | { 19 | JSON.create_id => self.class.name, 20 | 'b' => _dump, 21 | } 22 | end 23 | 24 | # return the JSON value 25 | def to_json(*) 26 | as_json.to_json 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/complex.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::Complex) or require 'complex' 5 | 6 | class Complex 7 | 8 | # Deserializes JSON string by converting Real value r, imaginary 9 | # value i, to a Complex object. 10 | def self.json_create(object) 11 | Complex(object['r'], object['i']) 12 | end 13 | 14 | # Returns a hash, that will be turned into a JSON object and represent this 15 | # object. 16 | def as_json(*) 17 | { 18 | JSON.create_id => self.class.name, 19 | 'r' => real, 20 | 'i' => imag, 21 | } 22 | end 23 | 24 | # Stores class name (Complex) along with real value r and imaginary value i as JSON string 25 | def to_json(*) 26 | as_json.to_json 27 | end 28 | end -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/core.rb: -------------------------------------------------------------------------------- 1 | # This file requires the implementations of ruby core's custom objects for 2 | # serialisation/deserialisation. 3 | 4 | require 'json/add/date' 5 | require 'json/add/date_time' 6 | require 'json/add/exception' 7 | require 'json/add/range' 8 | require 'json/add/regexp' 9 | require 'json/add/struct' 10 | require 'json/add/symbol' 11 | require 'json/add/time' 12 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/date.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'date' 5 | 6 | # Date serialization/deserialization 7 | class Date 8 | 9 | # Deserializes JSON string by converting Julian year y, month 10 | # m, day d and Day of Calendar Reform sg to Date. 11 | def self.json_create(object) 12 | civil(*object.values_at('y', 'm', 'd', 'sg')) 13 | end 14 | 15 | alias start sg unless method_defined?(:start) 16 | 17 | # Returns a hash, that will be turned into a JSON object and represent this 18 | # object. 19 | def as_json(*) 20 | { 21 | JSON.create_id => self.class.name, 22 | 'y' => year, 23 | 'm' => month, 24 | 'd' => day, 25 | 'sg' => start, 26 | } 27 | end 28 | 29 | # Stores class name (Date) with Julian year y, month m, day 30 | # d and Day of Calendar Reform sg as JSON string 31 | def to_json(*args) 32 | as_json.to_json(*args) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/date_time.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'date' 5 | 6 | # DateTime serialization/deserialization 7 | class DateTime 8 | 9 | # Deserializes JSON string by converting year y, month m, 10 | # day d, hour H, minute M, second S, 11 | # offset of and Day of Calendar Reform sg to DateTime. 12 | def self.json_create(object) 13 | args = object.values_at('y', 'm', 'd', 'H', 'M', 'S') 14 | of_a, of_b = object['of'].split('/') 15 | if of_b and of_b != '0' 16 | args << Rational(of_a.to_i, of_b.to_i) 17 | else 18 | args << of_a 19 | end 20 | args << object['sg'] 21 | civil(*args) 22 | end 23 | 24 | alias start sg unless method_defined?(:start) 25 | 26 | # Returns a hash, that will be turned into a JSON object and represent this 27 | # object. 28 | def as_json(*) 29 | { 30 | JSON.create_id => self.class.name, 31 | 'y' => year, 32 | 'm' => month, 33 | 'd' => day, 34 | 'H' => hour, 35 | 'M' => min, 36 | 'S' => sec, 37 | 'of' => offset.to_s, 38 | 'sg' => start, 39 | } 40 | end 41 | 42 | # Stores class name (DateTime) with Julian year y, month m, 43 | # day d, hour H, minute M, second S, 44 | # offset of and Day of Calendar Reform sg as JSON string 45 | def to_json(*args) 46 | as_json.to_json(*args) 47 | end 48 | end 49 | 50 | 51 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/exception.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Exception serialization/deserialization 6 | class Exception 7 | 8 | # Deserializes JSON string by constructing new Exception object with message 9 | # m and backtrace b serialized with to_json 10 | def self.json_create(object) 11 | result = new(object['m']) 12 | result.set_backtrace object['b'] 13 | result 14 | end 15 | 16 | # Returns a hash, that will be turned into a JSON object and represent this 17 | # object. 18 | def as_json(*) 19 | { 20 | JSON.create_id => self.class.name, 21 | 'm' => message, 22 | 'b' => backtrace, 23 | } 24 | end 25 | 26 | # Stores class name (Exception) with message m and backtrace array 27 | # b as JSON string 28 | def to_json(*args) 29 | as_json.to_json(*args) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/ostruct.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'ostruct' 5 | 6 | # OpenStruct serialization/deserialization 7 | class OpenStruct 8 | 9 | # Deserializes JSON string by constructing new Struct object with values 10 | # v serialized by to_json. 11 | def self.json_create(object) 12 | new(object['t'] || object[:t]) 13 | end 14 | 15 | # Returns a hash, that will be turned into a JSON object and represent this 16 | # object. 17 | def as_json(*) 18 | klass = self.class.name 19 | klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" 20 | { 21 | JSON.create_id => klass, 22 | 't' => table, 23 | } 24 | end 25 | 26 | # Stores class name (OpenStruct) with this struct's values v as a 27 | # JSON string. 28 | def to_json(*args) 29 | as_json.to_json(*args) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/range.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Range serialization/deserialization 6 | class Range 7 | 8 | # Deserializes JSON string by constructing new Range object with arguments 9 | # a serialized by to_json. 10 | def self.json_create(object) 11 | new(*object['a']) 12 | end 13 | 14 | # Returns a hash, that will be turned into a JSON object and represent this 15 | # object. 16 | def as_json(*) 17 | { 18 | JSON.create_id => self.class.name, 19 | 'a' => [ first, last, exclude_end? ] 20 | } 21 | end 22 | 23 | # Stores class name (Range) with JSON array of arguments a which 24 | # include first (integer), last (integer), and 25 | # exclude_end? (boolean) as JSON string. 26 | def to_json(*args) 27 | as_json.to_json(*args) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/rational.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::Rational) or require 'rational' 5 | 6 | class Rational 7 | # Deserializes JSON string by converting numerator value n, 8 | # denominator value d, to a Rational object. 9 | def self.json_create(object) 10 | Rational(object['n'], object['d']) 11 | end 12 | 13 | # Returns a hash, that will be turned into a JSON object and represent this 14 | # object. 15 | def as_json(*) 16 | { 17 | JSON.create_id => self.class.name, 18 | 'n' => numerator, 19 | 'd' => denominator, 20 | } 21 | end 22 | 23 | # Stores class name (Rational) along with numerator value n and denominator value d as JSON string 24 | def to_json(*) 25 | as_json.to_json 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/regexp.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Regexp serialization/deserialization 6 | class Regexp 7 | 8 | # Deserializes JSON string by constructing new Regexp object with source 9 | # s (Regexp or String) and options o serialized by 10 | # to_json 11 | def self.json_create(object) 12 | new(object['s'], object['o']) 13 | end 14 | 15 | # Returns a hash, that will be turned into a JSON object and represent this 16 | # object. 17 | def as_json(*) 18 | { 19 | JSON.create_id => self.class.name, 20 | 'o' => options, 21 | 's' => source, 22 | } 23 | end 24 | 25 | # Stores class name (Regexp) with options o and source s 26 | # (Regexp or String) as JSON string 27 | def to_json(*) 28 | as_json.to_json 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/struct.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Struct serialization/deserialization 6 | class Struct 7 | 8 | # Deserializes JSON string by constructing new Struct object with values 9 | # v serialized by to_json. 10 | def self.json_create(object) 11 | new(*object['v']) 12 | end 13 | 14 | # Returns a hash, that will be turned into a JSON object and represent this 15 | # object. 16 | def as_json(*) 17 | klass = self.class.name 18 | klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" 19 | { 20 | JSON.create_id => klass, 21 | 'v' => values, 22 | } 23 | end 24 | 25 | # Stores class name (Struct) with Struct values v as a JSON string. 26 | # Only named structs are supported. 27 | def to_json(*args) 28 | as_json.to_json(*args) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/symbol.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Symbol serialization/deserialization 6 | class Symbol 7 | # Returns a hash, that will be turned into a JSON object and represent this 8 | # object. 9 | def as_json(*) 10 | { 11 | JSON.create_id => self.class.name, 12 | 's' => to_s, 13 | } 14 | end 15 | 16 | # Stores class name (Symbol) with String representation of Symbol as a JSON string. 17 | def to_json(*a) 18 | as_json.to_json(*a) 19 | end 20 | 21 | # Deserializes JSON string by converting the string value stored in the object to a Symbol 22 | def self.json_create(o) 23 | o['s'].to_sym 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/add/time.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Time serialization/deserialization 6 | class Time 7 | 8 | # Deserializes JSON string by converting time since epoch to Time 9 | def self.json_create(object) 10 | if usec = object.delete('u') # used to be tv_usec -> tv_nsec 11 | object['n'] = usec * 1000 12 | end 13 | if method_defined?(:tv_nsec) 14 | at(object['s'], Rational(object['n'], 1000)) 15 | else 16 | at(object['s'], object['n'] / 1000) 17 | end 18 | end 19 | 20 | # Returns a hash, that will be turned into a JSON object and represent this 21 | # object. 22 | def as_json(*) 23 | nanoseconds = [ tv_usec * 1000 ] 24 | respond_to?(:tv_nsec) and nanoseconds << tv_nsec 25 | nanoseconds = nanoseconds.max 26 | { 27 | JSON.create_id => self.class.name, 28 | 's' => tv_sec, 29 | 'n' => nanoseconds, 30 | } 31 | end 32 | 33 | # Stores class name (Time) with number of seconds since epoch and number of 34 | # microseconds for Time as JSON string 35 | def to_json(*args) 36 | as_json.to_json(*args) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/ext.rb: -------------------------------------------------------------------------------- 1 | if ENV['SIMPLECOV_COVERAGE'].to_i == 1 2 | require 'simplecov' 3 | SimpleCov.start do 4 | add_filter "/tests/" 5 | end 6 | end 7 | require 'json/common' 8 | 9 | module JSON 10 | # This module holds all the modules/classes that implement JSON's 11 | # functionality as C extensions. 12 | module Ext 13 | require 'json/ext/parser' 14 | require 'json/ext/generator' 15 | $DEBUG and warn "Using Ext extension for JSON." 16 | JSON.parser = Parser 17 | JSON.generator = Generator 18 | end 19 | 20 | JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) 21 | end 22 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/ext/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/lib/json/ext/.keep -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/ext/generator.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/lib/json/ext/generator.so -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/ext/parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sschuberth/dev-scripts/d42d1028c59c25946375c9e75be02caa37af9a50/bundle/ruby/gems/json-1.8.3/lib/json/ext/parser.so -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/generic_object.rb: -------------------------------------------------------------------------------- 1 | require 'ostruct' 2 | 3 | module JSON 4 | class GenericObject < OpenStruct 5 | class << self 6 | alias [] new 7 | 8 | def json_creatable? 9 | @json_creatable 10 | end 11 | 12 | attr_writer :json_creatable 13 | 14 | def json_create(data) 15 | data = data.dup 16 | data.delete JSON.create_id 17 | self[data] 18 | end 19 | 20 | def from_hash(object) 21 | case 22 | when object.respond_to?(:to_hash) 23 | result = new 24 | object.to_hash.each do |key, value| 25 | result[key] = from_hash(value) 26 | end 27 | result 28 | when object.respond_to?(:to_ary) 29 | object.to_ary.map { |a| from_hash(a) } 30 | else 31 | object 32 | end 33 | end 34 | 35 | def load(source, proc = nil, opts = {}) 36 | result = ::JSON.load(source, proc, opts.merge(:object_class => self)) 37 | result.nil? ? new : result 38 | end 39 | 40 | def dump(obj, *args) 41 | ::JSON.dump(obj, *args) 42 | end 43 | end 44 | self.json_creatable = false 45 | 46 | def to_hash 47 | table 48 | end 49 | 50 | def [](name) 51 | table[name.to_sym] 52 | end 53 | 54 | def []=(name, value) 55 | __send__ "#{name}=", value 56 | end 57 | 58 | def |(other) 59 | self.class[other.to_hash.merge(to_hash)] 60 | end 61 | 62 | def as_json(*) 63 | { JSON.create_id => self.class.name }.merge to_hash 64 | end 65 | 66 | def to_json(*a) 67 | as_json.to_json(*a) 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/pure.rb: -------------------------------------------------------------------------------- 1 | if ENV['SIMPLECOV_COVERAGE'].to_i == 1 2 | require 'simplecov' 3 | SimpleCov.start do 4 | add_filter "/tests/" 5 | end 6 | end 7 | require 'json/common' 8 | require 'json/pure/parser' 9 | require 'json/pure/generator' 10 | 11 | module JSON 12 | # This module holds all the modules/classes that implement JSON's 13 | # functionality in pure ruby. 14 | module Pure 15 | $DEBUG and warn "Using Pure library for JSON." 16 | JSON.parser = Parser 17 | JSON.generator = Generator 18 | end 19 | 20 | JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) 21 | end 22 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/lib/json/version.rb: -------------------------------------------------------------------------------- 1 | module JSON 2 | # JSON version 3 | VERSION = '1.8.3' 4 | VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: 5 | VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: 6 | VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: 7 | VERSION_BUILD = VERSION_ARRAY[2] # :nodoc: 8 | end 9 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail1.json: -------------------------------------------------------------------------------- 1 | "A JSON payload should be an object or array, not a string." -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail10.json: -------------------------------------------------------------------------------- 1 | {"Extra value after close": true} "misplaced quoted value" -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail11.json: -------------------------------------------------------------------------------- 1 | {"Illegal expression": 1 + 2} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail12.json: -------------------------------------------------------------------------------- 1 | {"Illegal invocation": alert()} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail13.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot have leading zeroes": 013} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail14.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot be hex": 0x14} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail18.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail19.json: -------------------------------------------------------------------------------- 1 | {"Missing colon" null} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail2.json: -------------------------------------------------------------------------------- 1 | ["Unclosed array" -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail20.json: -------------------------------------------------------------------------------- 1 | {"Double colon":: null} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail21.json: -------------------------------------------------------------------------------- 1 | {"Comma instead of colon", null} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail22.json: -------------------------------------------------------------------------------- 1 | ["Colon instead of comma": false] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail23.json: -------------------------------------------------------------------------------- 1 | ["Bad value", truth] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail24.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail25.json: -------------------------------------------------------------------------------- 1 | ["tab character in string "] 2 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail27.json: -------------------------------------------------------------------------------- 1 | ["line 2 | break"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail28.json: -------------------------------------------------------------------------------- 1 | ["line\ 2 | break"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail3.json: -------------------------------------------------------------------------------- 1 | {unquoted_key: "keys must be quoted"} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail4.json: -------------------------------------------------------------------------------- 1 | ["extra comma",] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail5.json: -------------------------------------------------------------------------------- 1 | ["double extra comma",,] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail6.json: -------------------------------------------------------------------------------- 1 | [ , "<-- missing value"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail7.json: -------------------------------------------------------------------------------- 1 | ["Comma after the close"], -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail8.json: -------------------------------------------------------------------------------- 1 | ["Extra close"]] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/fail9.json: -------------------------------------------------------------------------------- 1 | {"Extra comma": true,} -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass1.json: -------------------------------------------------------------------------------- 1 | [ 2 | "JSON Test Pattern pass1", 3 | {"object with 1 member":["array with 1 element"]}, 4 | {}, 5 | [], 6 | -42, 7 | true, 8 | false, 9 | null, 10 | { 11 | "integer": 1234567890, 12 | "real": -9876.543210, 13 | "e": 0.123456789e-12, 14 | "E": 1.234567890E+34, 15 | "": 23456789012E666, 16 | "zero": 0, 17 | "one": 1, 18 | "space": " ", 19 | "quote": "\"", 20 | "backslash": "\\", 21 | "controls": "\b\f\n\r\t", 22 | "slash": "/ & \/", 23 | "alpha": "abcdefghijklmnopqrstuvwyz", 24 | "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", 25 | "digit": "0123456789", 26 | "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", 27 | "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", 28 | "true": true, 29 | "false": false, 30 | "null": null, 31 | "array":[ ], 32 | "object":{ }, 33 | "address": "50 St. James Street", 34 | "url": "http://www.JSON.org/", 35 | "comment": "// /* */": " ", 37 | " s p a c e d " :[1,2 , 3 38 | 39 | , 40 | 41 | 4 , 5 , 6 ,7 ], 42 | "compact": [1,2,3,4,5,6,7], 43 | "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", 44 | "quotes": "" \u0022 %22 0x22 034 "", 45 | "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" 46 | : "A key can be any string" 47 | }, 48 | 0.5 ,98.6 49 | , 50 | 99.44 51 | , 52 | 53 | 1066 54 | 55 | 56 | ,"rosebud"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass15.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \x15"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass16.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \'"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass17.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \017"] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass2.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass26.json: -------------------------------------------------------------------------------- 1 | ["tab\ character\ in\ string\ "] -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/fixtures/pass3.json: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": { 3 | "The outermost value": "must be an object or array.", 4 | "In this test": "It is an object." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/setup_variant.rb: -------------------------------------------------------------------------------- 1 | case ENV['JSON'] 2 | when 'pure' 3 | $:.unshift 'lib' 4 | require 'json/pure' 5 | when 'ext' 6 | $:.unshift 'ext', 'lib' 7 | require 'json/ext' 8 | else 9 | $:.unshift 'ext', 'lib' 10 | require 'json' 11 | end 12 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/test_json_fixtures.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require 'test/unit' 5 | require File.join(File.dirname(__FILE__), 'setup_variant') 6 | 7 | class TestJSONFixtures < Test::Unit::TestCase 8 | def setup 9 | fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json') 10 | passed, failed = Dir[fixtures].partition { |f| f['pass'] } 11 | @passed = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort 12 | @failed = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort 13 | end 14 | 15 | def test_passing 16 | for name, source in @passed 17 | begin 18 | assert JSON.parse(source), 19 | "Did not pass for fixture '#{name}': #{source.inspect}" 20 | rescue => e 21 | warn "\nCaught #{e.class}(#{e}) for fixture '#{name}': #{source.inspect}\n#{e.backtrace * "\n"}" 22 | raise e 23 | end 24 | end 25 | end 26 | 27 | def test_failing 28 | for name, source in @failed 29 | assert_raises(JSON::ParserError, JSON::NestingError, 30 | "Did not fail for fixture '#{name}': #{source.inspect}") do 31 | JSON.parse(source) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tests/test_json_string_matching.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require 'test/unit' 5 | require File.join(File.dirname(__FILE__), 'setup_variant') 6 | require 'stringio' 7 | require 'time' 8 | 9 | class TestJSONStringMatching < Test::Unit::TestCase 10 | include JSON 11 | 12 | class TestTime < ::Time 13 | def self.json_create(string) 14 | Time.parse(string) 15 | end 16 | 17 | def to_json(*) 18 | %{"#{strftime('%FT%T%z')}"} 19 | end 20 | 21 | def ==(other) 22 | to_i == other.to_i 23 | end 24 | end 25 | 26 | def test_match_date 27 | t = TestTime.new 28 | t_json = [ t ].to_json 29 | assert_equal [ t ], 30 | JSON.parse(t_json, :create_additions => true, 31 | :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) 32 | assert_equal [ t.strftime('%FT%T%z') ], 33 | JSON.parse(t_json, :create_additions => true, 34 | :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) 35 | assert_equal [ t.strftime('%FT%T%z') ], 36 | JSON.parse(t_json, 37 | :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /bundle/ruby/gems/json-1.8.3/tools/server.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require 'webrick' 5 | include WEBrick 6 | $:.unshift 'ext' 7 | $:.unshift 'lib' 8 | require 'json' 9 | 10 | class JSONServlet < HTTPServlet::AbstractServlet 11 | @@count = 1 12 | 13 | def do_GET(req, res) 14 | obj = { 15 | "TIME" => Time.now.strftime("%FT%T"), 16 | "foo" => "Bär", 17 | "bar" => "© ≠ €!", 18 | 'a' => 2, 19 | 'b' => 3.141, 20 | 'COUNT' => @@count += 1, 21 | 'c' => 'c', 22 | 'd' => [ 1, "b", 3.14 ], 23 | 'e' => { 'foo' => 'bar' }, 24 | 'g' => "松本行弘", 25 | 'h' => 1000.0, 26 | 'i' => 0.001, 27 | 'j' => "\xf0\xa0\x80\x81", 28 | } 29 | res.body = JSON.generate obj 30 | res['Content-Type'] = "application/json" 31 | end 32 | end 33 | 34 | def create_server(err, dir, port) 35 | dir = File.expand_path(dir) 36 | err.puts "Surf to:", "http://#{Socket.gethostname}:#{port}" 37 | 38 | s = HTTPServer.new( 39 | :Port => port, 40 | :DocumentRoot => dir, 41 | :Logger => WEBrick::Log.new(err), 42 | :AccessLog => [ 43 | [ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ], 44 | [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ], 45 | [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ] 46 | ] 47 | ) 48 | s.mount("/json", JSONServlet) 49 | s 50 | end 51 | 52 | default_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data')) 53 | dir = ARGV.shift || default_dir 54 | port = (ARGV.shift || 6666).to_i 55 | s = create_server(STDERR, dir, 6666) 56 | t = Thread.new { s.start } 57 | trap(:INT) do 58 | s.shutdown 59 | t.join 60 | exit 61 | end 62 | sleep 63 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/.yardopts: -------------------------------------------------------------------------------- 1 | --no-private 2 | --protected 3 | --markup markdown 4 | - 5 | CHANGELOG.md 6 | CONTRIBUTING.md 7 | LICENSE.md 8 | README.md 9 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | In the spirit of [free software][free-sw] , **everyone** is encouraged to help 3 | improve this project. 4 | 5 | [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html 6 | 7 | Here are some ways *you* can contribute: 8 | 9 | * by using alpha, beta, and prerelease versions 10 | * by reporting bugs 11 | * by suggesting new features 12 | * by writing or editing documentation 13 | * by writing specifications 14 | * by writing code (**no patch is too small**: fix typos, add comments, clean up 15 | inconsistent whitespace) 16 | * by refactoring code 17 | * by resolving [issues][] 18 | * by reviewing patches 19 | 20 | [issues]: https://github.com/sferik/multi_xml/issues 21 | 22 | ## Submitting an Issue 23 | We use the [GitHub issue tracker][issues] to track bugs and features. Before 24 | submitting a bug report or feature request, check to make sure it hasn't 25 | already been submitted. When submitting a bug report, please include a [Gist][] 26 | that includes a stack trace and any details that may be necessary to reproduce 27 | the bug, including your gem version, Ruby version, and operating system. 28 | Ideally, a bug report should include a pull request with failing specs. 29 | 30 | [gist]: https://gist.github.com/ 31 | 32 | ## Submitting a Pull Request 33 | 1. [Fork the repository.][fork] 34 | 2. [Create a topic branch.][branch] 35 | 3. Add specs for your unimplemented feature or bug fix. 36 | 4. Run `bundle exec rake spec`. If your specs pass, return to step 3. 37 | 5. Implement your feature or bug fix. 38 | 6. Run `bundle exec rake spec`. If your specs fail, return to step 5. 39 | 7. Run `open coverage/index.html`. If your changes are not completely covered 40 | by your tests, return to step 3. 41 | 8. Add documentation for your feature or bug fix. 42 | 9. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go 43 | back to step 8. 44 | 10. Add, commit, and push your changes. 45 | 11. [Submit a pull request.][pr] 46 | 47 | [fork]: http://help.github.com/fork-a-repo/ 48 | [branch]: http://learn.github.com/p/branching.html 49 | [pr]: http://help.github.com/send-pull-requests/ 50 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2013 Erik Michaels-Ober 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | Bundler::GemHelper.install_tasks 3 | 4 | require 'rspec/core/rake_task' 5 | RSpec::Core::RakeTask.new(:spec) 6 | 7 | task :test => :spec 8 | task :default => :spec 9 | 10 | namespace :doc do 11 | require 'yard' 12 | YARD::Rake::YardocTask.new do |task| 13 | task.files = ['lib/**/*.rb', '-', 'LICENSE.md'] 14 | task.options = [ 15 | '--no-private', 16 | '--protected', 17 | '--output-dir', 'doc/yard', 18 | '--markup', 'markdown', 19 | ] 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/lib/multi_xml/parsers/libxml.rb: -------------------------------------------------------------------------------- 1 | require 'libxml' unless defined?(LibXML) 2 | require 'multi_xml/parsers/libxml2_parser' 3 | 4 | module MultiXml 5 | module Parsers 6 | module Libxml #:nodoc: 7 | include Libxml2Parser 8 | 9 | extend self 10 | 11 | def parse_error() ::LibXML::XML::Error end 12 | 13 | def parse(xml) 14 | node_to_hash(LibXML::XML::Parser.io(xml).parse.root) 15 | end 16 | 17 | def each_child(node, &block) 18 | node.each_child(&block) 19 | end 20 | 21 | def each_attr(node, &block) 22 | node.each_attr(&block) 23 | end 24 | 25 | def node_name(node) 26 | node.name 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/lib/multi_xml/parsers/libxml2_parser.rb: -------------------------------------------------------------------------------- 1 | module MultiXml 2 | module Parsers 3 | module Libxml2Parser #:nodoc: 4 | # Convert XML document to hash 5 | # 6 | # node:: 7 | # The XML node object to convert to a hash. 8 | # 9 | # hash:: 10 | # Hash to merge the converted element into. 11 | def node_to_hash(node, hash={}) 12 | node_hash = {MultiXml::CONTENT_ROOT => ''} 13 | 14 | name = node_name(node) 15 | 16 | # Insert node hash into parent hash correctly. 17 | case hash[name] 18 | when Array then hash[name] << node_hash 19 | when Hash then hash[name] = [hash[name], node_hash] 20 | when nil then hash[name] = node_hash 21 | end 22 | 23 | # Handle child elements 24 | each_child(node) do |c| 25 | if c.element? 26 | node_to_hash(c, node_hash) 27 | elsif c.text? || c.cdata? 28 | node_hash[MultiXml::CONTENT_ROOT] << c.content 29 | end 30 | end 31 | 32 | # Remove content node if it is empty 33 | if node_hash[MultiXml::CONTENT_ROOT].strip.empty? 34 | node_hash.delete(MultiXml::CONTENT_ROOT) 35 | end 36 | 37 | # Handle attributes 38 | each_attr(node) do |a| 39 | key = node_name(a) 40 | 41 | node_hash[key] = if v = node_hash[key] 42 | [a.value, v] 43 | else 44 | a.value 45 | end 46 | end 47 | 48 | hash 49 | end 50 | 51 | # Parse an XML Document IO into a simple hash. 52 | # xml:: 53 | # XML Document IO to parse 54 | def parse(xml) 55 | raise NotImplementedError, "inheritor should define #{__method__}" 56 | end 57 | 58 | # :stopdoc: 59 | private 60 | 61 | def each_child(*args) 62 | raise NotImplementedError, "inheritor should define #{__method__}" 63 | end 64 | 65 | def each_attr(*args) 66 | raise NotImplementedError, "inheritor should define #{__method__}" 67 | end 68 | 69 | def node_name(*args) 70 | raise NotImplementedError, "inheritor should define #{__method__}" 71 | end 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/lib/multi_xml/parsers/nokogiri.rb: -------------------------------------------------------------------------------- 1 | require 'nokogiri' unless defined?(Nokogiri) 2 | require 'multi_xml/parsers/libxml2_parser' 3 | 4 | module MultiXml 5 | module Parsers 6 | module Nokogiri #:nodoc: 7 | include Libxml2Parser 8 | 9 | extend self 10 | 11 | def parse_error() ::Nokogiri::XML::SyntaxError end 12 | 13 | def parse(xml) 14 | doc = ::Nokogiri::XML(xml) 15 | raise doc.errors.first if doc.errors.length > 0 16 | node_to_hash(doc.root) 17 | end 18 | 19 | def each_child(node, &block) 20 | node.children.each(&block) 21 | end 22 | 23 | def each_attr(node, &block) 24 | node.attribute_nodes.each(&block) 25 | end 26 | 27 | def node_name(node) 28 | node.node_name 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/lib/multi_xml/version.rb: -------------------------------------------------------------------------------- 1 | module MultiXml 2 | VERSION = "0.5.5" unless defined?(MultiXML::VERSION) 3 | end 4 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/multi_xml.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'multi_xml/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.add_development_dependency 'bundler', '~> 1.0' 8 | spec.author = "Erik Michaels-Ober" 9 | spec.cert_chain = ['certs/sferik.pem'] 10 | spec.description = %q{Provides swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML.} 11 | spec.email = 'sferik@gmail.com' 12 | spec.files = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile multi_xml.gemspec) 13 | spec.files += Dir.glob("lib/**/*.rb") 14 | spec.files += Dir.glob("spec/**/*") 15 | spec.homepage = 'https://github.com/sferik/multi_xml' 16 | spec.licenses = ['MIT'] 17 | spec.name = 'multi_xml' 18 | spec.require_paths = ['lib'] 19 | spec.required_rubygems_version = '>= 1.3.5' 20 | spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/ 21 | spec.summary = %q{A generic swappable back-end for XML parsing} 22 | spec.test_files = Dir.glob("spec/**/*") 23 | spec.version = MultiXml::VERSION 24 | end 25 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/spec/helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | require 'coveralls' 3 | 4 | SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ 5 | SimpleCov::Formatter::HTMLFormatter, 6 | Coveralls::SimpleCov::Formatter 7 | ] 8 | SimpleCov.start 9 | 10 | require 'multi_xml' 11 | require 'rspec' 12 | 13 | RSpec.configure do |config| 14 | config.expect_with :rspec do |c| 15 | c.syntax = :expect 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/spec/multi_xml_spec.rb: -------------------------------------------------------------------------------- 1 | require 'helper' 2 | require 'parser_shared_example' 3 | 4 | class MockDecoder; end 5 | 6 | describe "MultiXml" do 7 | context "Parsers" do 8 | it "picks a default parser" do 9 | expect(MultiXml.parser).to be_kind_of(Module) 10 | expect(MultiXml.parser).to respond_to(:parse) 11 | end 12 | 13 | it "defaults to the best available gem" do 14 | # Clear cache variable already set by previous tests 15 | MultiXml.send(:remove_instance_variable, :@parser) 16 | expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Ox') 17 | end 18 | 19 | it "is settable via a symbol" do 20 | MultiXml.parser = :rexml 21 | expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Rexml') 22 | end 23 | 24 | it "is settable via a class" do 25 | MultiXml.parser = MockDecoder 26 | expect(MultiXml.parser.name).to eq('MockDecoder') 27 | end 28 | end 29 | 30 | [['LibXML', 'libxml'], 31 | ['REXML', 'rexml/document'], 32 | ['Nokogiri', 'nokogiri'], 33 | ['Ox', 'ox']].each do |parser| 34 | begin 35 | require parser.last 36 | context "#{parser.first} parser" do 37 | it_behaves_like "a parser", parser.first 38 | end 39 | rescue LoadError => e 40 | puts "Tests not run for #{parser.first} due to a LoadError" 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /bundle/ruby/gems/multi_xml-0.5.5/spec/speed.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby -wW1 2 | 3 | $: << '.' 4 | $: << '../lib' 5 | 6 | if __FILE__ == $0 7 | while (i = ARGV.index('-I')) 8 | x,path = ARGV.slice!(i, 2) 9 | $: << path 10 | end 11 | end 12 | 13 | require 'optparse' 14 | require 'stringio' 15 | require 'multi_xml' 16 | 17 | begin 18 | require 'libxml' 19 | rescue Exception => e 20 | end 21 | begin 22 | require 'nokogiri' 23 | rescue Exception => e 24 | end 25 | begin 26 | require 'ox' 27 | rescue Exception => e 28 | end 29 | 30 | $verbose = 0 31 | $parsers = [] 32 | $iter = 10 33 | 34 | opts = OptionParser.new 35 | opts.on("-v", "increase verbosity") { $verbose += 1 } 36 | opts.on("-p", "--parser [String]", String, "parser to test") { |p| $parsers = [p] } 37 | opts.on("-i", "--iterations [Int]", Integer, "iterations") { |i| $iter = i } 38 | opts.on("-h", "--help", "Show this display") { puts opts; Process.exit!(0) } 39 | files = opts.parse(ARGV) 40 | 41 | if $parsers.empty? 42 | $parsers << 'libxml' if defined?(::LibXML) 43 | $parsers << 'nokogiri' if defined?(::Nokogiri) 44 | $parsers << 'ox' if defined?(::Ox) 45 | end 46 | 47 | files.each do |filename| 48 | times = { } 49 | xml = File.read(filename) 50 | $parsers.each do |p| 51 | MultiXml.parser = p 52 | start = Time.now 53 | $iter.times do |i| 54 | io = StringIO.new(xml) 55 | MultiXml.parse(io) 56 | end 57 | dt = Time.now - start 58 | times[p] = Time.now - start 59 | end 60 | times.each do |p,t| 61 | puts "%8s took %0.3f seconds to parse %s %d times." % [p, t, filename, $iter] 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /bundle/ruby/specifications/gerry-0.0.3.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # stub: gerry 0.0.3 ruby lib 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "gerry" 6 | s.version = "0.0.3" 7 | 8 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 9 | s.require_paths = ["lib"] 10 | s.authors = ["Fabian Mettler", "Andrew Erickson", "Travis Truman"] 11 | s.date = "2015-06-12" 12 | s.description = " Simple Ruby wrapper for the Gerrit Code Review REST-API.\n" 13 | s.email = "trumant@gmail.com" 14 | s.homepage = "http://github.com/trumant/gerry" 15 | s.rubygems_version = "2.4.5" 16 | s.summary = "Simple Ruby wrapper for the Gerrit Code Review REST-API." 17 | 18 | s.installed_by_version = "2.4.5" if s.respond_to? :installed_by_version 19 | 20 | if s.respond_to? :specification_version then 21 | s.specification_version = 4 22 | 23 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 24 | s.add_runtime_dependency(%q, [">= 0"]) 25 | s.add_development_dependency(%q, [">= 0"]) 26 | s.add_development_dependency(%q, ["~> 3.1.0"]) 27 | s.add_development_dependency(%q, [">= 0"]) 28 | s.add_development_dependency(%q, [">= 0"]) 29 | s.add_development_dependency(%q, [">= 0"]) 30 | s.add_development_dependency(%q, [">= 0"]) 31 | s.add_development_dependency(%q, [">= 0"]) 32 | else 33 | s.add_dependency(%q, [">= 0"]) 34 | s.add_dependency(%q, [">= 0"]) 35 | s.add_dependency(%q, ["~> 3.1.0"]) 36 | s.add_dependency(%q, [">= 0"]) 37 | s.add_dependency(%q, [">= 0"]) 38 | s.add_dependency(%q, [">= 0"]) 39 | s.add_dependency(%q, [">= 0"]) 40 | s.add_dependency(%q, [">= 0"]) 41 | end 42 | else 43 | s.add_dependency(%q, [">= 0"]) 44 | s.add_dependency(%q, [">= 0"]) 45 | s.add_dependency(%q, ["~> 3.1.0"]) 46 | s.add_dependency(%q, [">= 0"]) 47 | s.add_dependency(%q, [">= 0"]) 48 | s.add_dependency(%q, [">= 0"]) 49 | s.add_dependency(%q, [">= 0"]) 50 | s.add_dependency(%q, [">= 0"]) 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /bundle/ruby/specifications/gerry-0.1.2.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # stub: gerry 0.1.2 ruby lib 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "gerry" 6 | s.version = "0.1.2" 7 | 8 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 9 | s.require_paths = ["lib"] 10 | s.authors = ["Fabian Mettler", "Andrew Erickson", "Travis Truman"] 11 | s.date = "2015-08-03" 12 | s.description = " Simple Ruby wrapper for the Gerrit Code Review REST-API.\n" 13 | s.email = "trumant@gmail.com" 14 | s.homepage = "http://github.com/trumant/gerry" 15 | s.rubygems_version = "2.4.5" 16 | s.summary = "Simple Ruby wrapper for the Gerrit Code Review REST-API." 17 | 18 | s.installed_by_version = "2.4.5" if s.respond_to? :installed_by_version 19 | 20 | if s.respond_to? :specification_version then 21 | s.specification_version = 4 22 | 23 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 24 | s.add_runtime_dependency(%q, [">= 0"]) 25 | s.add_development_dependency(%q, [">= 0"]) 26 | s.add_development_dependency(%q, ["~> 3.1.0"]) 27 | s.add_development_dependency(%q, [">= 0"]) 28 | s.add_development_dependency(%q, [">= 0"]) 29 | s.add_development_dependency(%q, [">= 0"]) 30 | s.add_development_dependency(%q, [">= 0"]) 31 | s.add_development_dependency(%q, [">= 0"]) 32 | else 33 | s.add_dependency(%q, [">= 0"]) 34 | s.add_dependency(%q, [">= 0"]) 35 | s.add_dependency(%q, ["~> 3.1.0"]) 36 | s.add_dependency(%q, [">= 0"]) 37 | s.add_dependency(%q, [">= 0"]) 38 | s.add_dependency(%q, [">= 0"]) 39 | s.add_dependency(%q, [">= 0"]) 40 | s.add_dependency(%q, [">= 0"]) 41 | end 42 | else 43 | s.add_dependency(%q, [">= 0"]) 44 | s.add_dependency(%q, [">= 0"]) 45 | s.add_dependency(%q, ["~> 3.1.0"]) 46 | s.add_dependency(%q, [">= 0"]) 47 | s.add_dependency(%q, [">= 0"]) 48 | s.add_dependency(%q, [">= 0"]) 49 | s.add_dependency(%q, [">= 0"]) 50 | s.add_dependency(%q, [">= 0"]) 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /bundle/ruby/specifications/httparty-0.13.5.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # stub: httparty 0.13.5 ruby lib 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "httparty" 6 | s.version = "0.13.5" 7 | 8 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 9 | s.require_paths = ["lib"] 10 | s.authors = ["John Nunemaker", "Sandro Turriate"] 11 | s.date = "2015-05-19" 12 | s.description = "Makes http fun! Also, makes consuming restful web services dead easy." 13 | s.email = ["nunemaker@gmail.com"] 14 | s.executables = ["httparty"] 15 | s.files = ["bin/httparty"] 16 | s.homepage = "http://jnunemaker.github.com/httparty" 17 | s.licenses = ["MIT"] 18 | s.post_install_message = "When you HTTParty, you must party hard!" 19 | s.required_ruby_version = Gem::Requirement.new(">= 1.9.3") 20 | s.rubygems_version = "2.4.5" 21 | s.summary = "Makes http fun! Also, makes consuming restful web services dead easy." 22 | 23 | s.installed_by_version = "2.4.5" if s.respond_to? :installed_by_version 24 | 25 | if s.respond_to? :specification_version then 26 | s.specification_version = 4 27 | 28 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 29 | s.add_runtime_dependency(%q, ["~> 1.8"]) 30 | s.add_runtime_dependency(%q, [">= 0.5.2"]) 31 | else 32 | s.add_dependency(%q, ["~> 1.8"]) 33 | s.add_dependency(%q, [">= 0.5.2"]) 34 | end 35 | else 36 | s.add_dependency(%q, ["~> 1.8"]) 37 | s.add_dependency(%q, [">= 0.5.2"]) 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /bundle/ruby/specifications/json-1.8.3.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # stub: json 1.8.3 ruby lib 3 | # stub: ext/json/ext/generator/extconf.rbext/json/ext/parser/extconf.rbext/json/extconf.rb 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "json" 7 | s.version = "1.8.3" 8 | 9 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 10 | s.require_paths = ["lib"] 11 | s.authors = ["Florian Frank"] 12 | s.date = "2015-06-01" 13 | s.description = "This is a JSON implementation as a Ruby extension in C." 14 | s.email = "flori@ping.de" 15 | s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"] 16 | s.extra_rdoc_files = ["README.rdoc"] 17 | s.files = ["README.rdoc", "ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"] 18 | s.homepage = "http://flori.github.com/json" 19 | s.licenses = ["Ruby"] 20 | s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.rdoc"] 21 | s.rubygems_version = "2.4.5" 22 | s.summary = "JSON Implementation for Ruby" 23 | 24 | s.installed_by_version = "2.4.5" if s.respond_to? :installed_by_version 25 | 26 | if s.respond_to? :specification_version then 27 | s.specification_version = 4 28 | 29 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 30 | s.add_development_dependency(%q, [">= 0"]) 31 | s.add_development_dependency(%q, ["~> 0.3.16"]) 32 | else 33 | s.add_dependency(%q, [">= 0"]) 34 | s.add_dependency(%q, ["~> 0.3.16"]) 35 | end 36 | else 37 | s.add_dependency(%q, [">= 0"]) 38 | s.add_dependency(%q, ["~> 0.3.16"]) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /bundle/ruby/specifications/multi_xml-0.5.5.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # stub: multi_xml 0.5.5 ruby lib 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "multi_xml" 6 | s.version = "0.5.5" 7 | 8 | s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version= 9 | s.require_paths = ["lib"] 10 | s.authors = ["Erik Michaels-Ober"] 11 | s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ8wDQYDVQQDDAZzZmVy\naWsxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2NvbTAe\nFw0xMzAyMDMxMDAyMjdaFw0xNDAyMDMxMDAyMjdaMD0xDzANBgNVBAMMBnNmZXJp\nazEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl0x5dx8uKxi7TkrIuyBUTJVB\nv1o93nUB9j/y4M96gV2rYwAci1JPBseNd6Fybzjo3YGuHl7EQHuSHNaf1p2lxew/\ny60JXIJBBgPcDK/KCP4NUHofm0jfoYD+H5uNJfHCNq7/ZsTxOtE3Ra92s0BCMTpm\nwBMMlWR5MtdEhIYuBO4XhnejYgH0L/7BL2lymntVnsr/agdQoojQCN1IQmsRJvrR\nduZRO3tZvoIo1pBc4JEehDuqCeyBgPLOqMoKtQlold1TQs1kWUBK7KWMFEhKC/Kg\nzyzKRHQo9yDYwOvYngoBLY+T/lwCT4dyssdhzRbfnxAhaKu4SAssIwaC01yVowID\nAQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBS0ruDfRak5ci1OpDNX/ZdDEkIs\niTALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAHHSMs/MP0sOaLkEv4Jo\nzvkm3qn5A6t0vaHx774cmejyMU+5wySxRezspL7ULh9NeuK2OhU+Oe3TpqrAg5TK\nR8GQILnVu2FemGA6sAkPDlcPtgA6ieI19PZOF6HVLmc/ID/dP/NgZWWzEeqQKmcK\n2+HM+SEEDhZkScYekw4ZOe164ZtZG816oAv5x0pGitSIkumUp7V8iEZ/6ehr7Y9e\nXOg4eeun5L/JjmjARoW2kNdvkRD3c2EeSLqWvQRsBlypHfhs6JJuLlyZPGhU3R/v\nSf3lVKpBCWgRpGTvy45XVpB+59y33PJmEuQ1PTEOYvQyao9UKMAAaAN/7qWQtjl0\nhlw=\n-----END CERTIFICATE-----\n"] 12 | s.date = "2013-08-06" 13 | s.description = "Provides swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML." 14 | s.email = "sferik@gmail.com" 15 | s.homepage = "https://github.com/sferik/multi_xml" 16 | s.licenses = ["MIT"] 17 | s.rubygems_version = "2.4.5" 18 | s.summary = "A generic swappable back-end for XML parsing" 19 | 20 | s.installed_by_version = "2.4.5" if s.respond_to? :installed_by_version 21 | 22 | if s.respond_to? :specification_version then 23 | s.specification_version = 3 24 | 25 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 26 | s.add_development_dependency(%q, ["~> 1.0"]) 27 | else 28 | s.add_dependency(%q, ["~> 1.0"]) 29 | end 30 | else 31 | s.add_dependency(%q, ["~> 1.0"]) 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /gerrit/count-active-owners.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative '../bundle/bundler/setup' 4 | 5 | require 'gerry' 6 | require 'set' 7 | 8 | uri_str, age = ARGV 9 | if uri_str.nil? || age.nil? 10 | script = File.basename(__FILE__) 11 | puts < 13 | Example : #{script} [user:password@]host[:port] 3mon 14 | 15 | Rationale : Count the number of owners whose change(s) have been merged 16 | in the given age period backwards from now. 17 | EOT 18 | exit(1) 19 | end 20 | 21 | uri_str = 'https://' + uri_str unless uri_str.start_with?('https://', 'http://') 22 | uri = URI.parse(uri_str) 23 | 24 | uri.user = ENV['USER'] || ENV['USERNAME'] if uri.user.nil? 25 | uri.password = ENV['GERRIT_HTTP_PASSWORD'] if uri.password.nil? 26 | 27 | Gerry::Client.default_options.update(verify: false) 28 | client = Gerry.new("#{uri.scheme}://#{uri.host}", uri.user, uri.password) 29 | 30 | owner_ids = Set.new 31 | changes = client.changes(["q=status:merged+-age:#{age}"]) 32 | changes.each do |change| 33 | owner_ids << change['owner']['_account_id'] 34 | end 35 | 36 | puts "Number of active owners in the last #{age}: #{owner_ids.size}" 37 | -------------------------------------------------------------------------------- /gerrit/count-active-projects.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative '../bundle/bundler/setup' 4 | 5 | require 'gerry' 6 | require 'set' 7 | 8 | uri_str, age = ARGV 9 | if uri_str.nil? || age.nil? 10 | script = File.basename(__FILE__) 11 | puts < 13 | Example : #{script} [user:password@]host[:port] 3mon 14 | 15 | Rationale : Count the number of owners whose change(s) have been merged 16 | in the given age period backwards from now. 17 | EOT 18 | exit(1) 19 | end 20 | 21 | uri_str = 'https://' + uri_str unless uri_str.start_with?('https://', 'http://') 22 | uri = URI.parse(uri_str) 23 | 24 | uri.user = ENV['USER'] || ENV['USERNAME'] if uri.user.nil? 25 | uri.password = ENV['GERRIT_HTTP_PASSWORD'] if uri.password.nil? 26 | 27 | Gerry::Client.default_options.update(verify: false) 28 | client = Gerry.new("#{uri.scheme}://#{uri.host}", uri.user, uri.password) 29 | 30 | projects = Set.new 31 | changes = client.changes(["q=status:merged+-age:#{age}"]) 32 | changes.each do |change| 33 | projects << change['project'] 34 | end 35 | 36 | puts "Number of active projects in the last #{age}: #{projects.size}" 37 | -------------------------------------------------------------------------------- /gerrit/gerrit-clone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while [ -n "$1" ]; do 4 | case "$1" in 5 | --help) 6 | help=true 7 | ;; 8 | -*) 9 | echo "Error: Invalid option \"$1\"." 10 | exit 2 11 | ;; 12 | *) 13 | # Stop parsing options on the first non-option argument. 14 | break 15 | ;; 16 | esac 17 | 18 | shift 19 | done 20 | 21 | if [ -n "$help" -o $# -ne 2 ]; then 22 | echo "Rationale" 23 | echo " Clone all projects matching the given regex pattern from Gerrit." 24 | echo 25 | echo "Usage" 26 | echo " $(basename $0) " 27 | echo 28 | echo "Example" 29 | echo " $(basename $0) review.openstack.org openstack-attic/akanda" 30 | echo 31 | echo "Options" 32 | echo " --help" 33 | echo " Show this help." 34 | exit 1 35 | fi 36 | 37 | host=$(echo $1 | cut -d":" -f1) 38 | port=$(echo $1 | cut -d":" -f2 -s) 39 | [ -z "$port" ] && port=29418 40 | 41 | pattern=$2 42 | matches=$(ssh -p $port $host gerrit ls-projects --type code | grep -E $pattern) 43 | 44 | if [ -z "$matches" ]; then 45 | echo "No matching projects found." 46 | exit 3 47 | fi 48 | 49 | echo "$matches" 50 | echo 51 | read -p "Do you want to clone these projects? [(Y)es/(n)o] " -n 1 -r 52 | 53 | if [ "$REPLY" != "n" -a "$REPLY" != "N" ]; then 54 | echo "$matches" | xargs -I % -n 1 -P 8 git clone -q ssh://$host:$port/% % 55 | fi 56 | -------------------------------------------------------------------------------- /gerrit/list-users.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Rationale" 5 | echo " List all registered Gerrit users." 6 | echo 7 | echo "Usage" 8 | echo " $(basename $0) " 9 | exit 1 10 | fi 11 | 12 | port=29418 13 | host=$1 14 | 15 | ssh -p $port $host 'gerrit gsql --format PRETTY -c "select full_name,preferred_email from accounts"' 16 | -------------------------------------------------------------------------------- /gerrit/repo-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | die() { 4 | echo "$@" >&2 5 | exit 1 6 | } 7 | 8 | [ -d ".repo" ] || die "Error: Please change to the root of the repo working tree." 9 | 10 | rm -rf build/ 11 | repo forall -p -c git clean -fdx 12 | -------------------------------------------------------------------------------- /gerrit/set-head.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative '../bundle/bundler/setup' 4 | 5 | require 'gerry' 6 | 7 | uri_str, project, branch = ARGV 8 | if uri_str.nil? or project.nil? or branch.nil? 9 | script = File.basename(__FILE__) 10 | puts "Usage : #{script} " 11 | puts "Example : #{script} [user:password@]host[:port] android master" 12 | exit 13 | end 14 | 15 | uri_str = 'https://' + uri_str unless uri_str.start_with?('https://', 'http://') 16 | uri = URI.parse(uri_str) 17 | 18 | uri.user = ENV['USER'] || ENV['USERNAME'] if uri.user.nil? 19 | uri.password = ENV['GERRIT_HTTP_PASSWORD'] if uri.password.nil? 20 | 21 | Gerry::Client.default_options.update(verify: false) 22 | client = Gerry.new("#{uri.scheme}://#{uri.host}", uri.user, uri.password) 23 | 24 | puts 'HEAD now points to ' + client.set_head(project, branch) 25 | -------------------------------------------------------------------------------- /gerrit/set-parent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 3 ]; then 4 | echo "Rationale" 5 | echo " Set the parent of projects matching a pattern." 6 | echo 7 | echo "Usage" 8 | echo " $(basename $0) " 9 | echo 10 | echo "Example" 11 | echo " $(basename $0) android-review.googlesource.com device Platform-Unrestricted-Projects" 12 | exit 1 13 | fi 14 | 15 | port=29418 16 | host=$1 17 | pattern=$2 18 | parent=$3 19 | 20 | projects=$(ssh -p $port $host gerrit ls-projects | grep "$pattern") 21 | 22 | echo 23 | echo "$projects" 24 | echo 25 | read -p "Do you want to change the parent for these projects? [(Y)es/(n)o] " -n 1 -r 26 | echo 27 | 28 | if [ "$REPLY" != "n" -a "$REPLY" != "N" ]; then 29 | echo "$projects" | xargs ssh -p $port $host gerrit set-project-parent --parent $parent 30 | fi 31 | -------------------------------------------------------------------------------- /git/git-alias: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Git Compare Differences 4 | function git_cmp_diffs() { 5 | if [ $(git show $1 | git patch-id | cut -c 40) != $(git show $2 | git patch-id | cut -c 40) ]; then 6 | echo "Diffs are NOT equal." 7 | else 8 | echo "Diffs ARE equal." 9 | fi 10 | } 11 | 12 | alias gcd='git_cmp_diffs' 13 | 14 | # Git Is Merged 15 | function git_is_merged() { 16 | revlist=$(git rev-list -1 $1 --not $2) 17 | if [ $? -eq 0 ]; then 18 | if [ "$revlist" = "" ]; then 19 | echo "$(basename $1) IS merged into $(basename $2)." 20 | else 21 | echo "$(basename $1) is NOT merged into $(basename $2)." 22 | fi 23 | fi 24 | } 25 | 26 | alias gim='git_is_merged' 27 | -------------------------------------------------------------------------------- /git/git-author-count: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NUM_DAYS=${1:-14} 4 | REV=${2:-HEAD} 5 | 6 | LAST_COMMIT_DATE=$(git log -1 --date=unix --pretty=format:%cd $REV) 7 | SECONDS_FOR_DAYS=$((60 * 60 * 24 * $NUM_DAYS)) 8 | SINCE=$(($LAST_COMMIT_DATE - $SECONDS_FOR_DAYS)) 9 | 10 | REV_NAME=$(git name-rev --name-only $REV) 11 | DATE=$(date --date=@$SINCE "+%Y-%m-%d %H:%M:%S") 12 | echo "Unique authors within $NUM_DAYS day(s) from the latest commit on '$REV_NAME' (since $DATE):" 13 | 14 | git shortlog -sne --since=$SINCE $REV | wc -l 15 | -------------------------------------------------------------------------------- /git/git-authorship: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git ls-files -s $@ | grep -v "^16000" | cut -f2- | \ 4 | xargs -n1 git blame --line-porcelain HEAD | sed -nr 's,^author (.*),\1,p' | \ 5 | sort | uniq -c | sort -nr 6 | -------------------------------------------------------------------------------- /git/git-blob-hash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script return the Git-style SHA1 of the blob for a given file. 4 | 5 | infile=$1 6 | 7 | git ls-tree HEAD $infile | cut -f1 | cut -d' ' -f3 8 | -------------------------------------------------------------------------------- /git/git-branch-owners: -------------------------------------------------------------------------------- 1 | #/!bin/sh 2 | 3 | ALL_BRANCHES=$(git for-each-ref --format='%(refname:short)' refs/heads refs/remotes) 4 | UPSTREAM_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) 5 | 6 | for BRANCH in $ALL_BRANCHES; do 7 | OWNER=$(git shortlog -n $BRANCH --not $UPSTREAM_BRANCH | head -1 | cut -d '(' -f 1) 8 | OWNER=$(echo $OWNER) 9 | [ -n "$OWNER" ] && echo "$BRANCH ($OWNER)" 10 | done 11 | -------------------------------------------------------------------------------- /git/git-check-blacklist: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Space-separated list of blacklisted word. 4 | BLACKLIST=${1:-secret password} 5 | BLACKLIST_ARGS="${BLACKLIST/ / --grep=}" 6 | BLACKLIST_PATTERN="(${BLACKLIST/ /|})" 7 | 8 | echo -e "Searching commit messages for blacklisted words...\n" 9 | git log --all --format=full --grep=$BLACKLIST_ARGS -i 10 | 11 | echo -e "\n--\n" 12 | 13 | echo -e "Searching commits for blacklisted words...\n" 14 | git rev-list --all | ( 15 | while read REVISION; do 16 | git grep -i -E $BLACKLIST_PATTERN $REVISION 17 | done 18 | ) 19 | 20 | echo -e "\n--\n" 21 | 22 | echo -e "Searching commits for blacklisted paths...\n" 23 | git rev-list --all | ( 24 | while read REVISION; do 25 | GIT_PATHS=$(git ls-tree -r --name-only $REVISION | grep -E $BLACKLIST_PATTERN) 26 | if [ -n "$GIT_PATHS" ]; then 27 | for GIT_PATH in "$GIT_PATHS"; do 28 | echo -e "$REVISION:\n$GIT_PATH" 29 | done 30 | fi 31 | done 32 | ) 33 | -------------------------------------------------------------------------------- /git/git-cherry-pick-branch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script requires bash for some advanced string matching. 4 | 5 | if [ $# -lt 2 ]; then 6 | echo "Rationale : Cherry-pick only those changes in a branch that affect a certain path" 7 | echo "Usage : $(basename $0) [resume]" 8 | exit 1 9 | fi 10 | 11 | die() { 12 | echo >&2 "$@" 13 | exit 255 14 | } 15 | 16 | commits=$(git rev-list --reverse --topo-order --no-merges $1 -- $2) 17 | words=$(echo $commits | wc -w) 18 | 19 | # Trim whitespaces. 20 | count=$(echo $words) 21 | 22 | if [[ $# -ge 3 && $commits == *$3* ]]; then 23 | skip=true 24 | resume=$3 25 | echo "Resuming picking after $resume ..." 26 | else 27 | skip=false 28 | fi 29 | 30 | i=0 31 | for sha1 in $commits; do 32 | let i++ 33 | 34 | if [[ $skip != true ]]; then 35 | echo $(printf "(%03d of %03d)" $i $count) $sha1 36 | 37 | # Save a huge amount of time for vastly different trees by using the 38 | # "resolve" merge strategy to avoid rename detection. However, this may 39 | # may lead to unnecessary conflicts sometimes, and it segfaults with 40 | # Git 1.7.5.1 (a fix is underway). 41 | #git cherry-pick --strategy=resolve $sha1 > /dev/null 2>&1 || (git commit -C $sha1 -o $2 && git reset --hard HEAD) > /dev/null || die "Error cherry-picking $sha1." 42 | 43 | # This is an alternate method without using git cherry-pick at all. 44 | $(dirname $0)/git-cherry-pick-path.sh $sha1 $2 > /dev/null || die "Error cherry-picking $sha1." 45 | fi 46 | 47 | if [[ $sha1 == $resume* ]]; then 48 | skip=false 49 | fi 50 | done 51 | -------------------------------------------------------------------------------- /git/git-cherry-pick-path: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 2 ]; then 4 | echo "Rationale : Cherry-pick only those changes in a commit that affect a certain path." 5 | echo "Usage : $(basename $0) " 6 | exit 1 7 | fi 8 | 9 | # If getting the diff to the previous commit fails (e.g. when picking the root commit), checkout instead. 10 | (git diff $1^ $1 -- $2 | git apply --index) 2> /dev/null || git checkout $1 -- $2 && git commit -C $1 -n -q 11 | -------------------------------------------------------------------------------- /git/git-commit-signoff.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Signed-off-by: Sebastian Schuberth 4 | 5 | # To use this configure git like 6 | # 7 | # $ git config (--global) commit.template /git-commit-signoff.txt 8 | -------------------------------------------------------------------------------- /git/git-commit-size: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Rationale : Get the total size of all files added by the specified commit." 5 | echo "Usage : $(basename $0) " 6 | exit 1 7 | fi 8 | 9 | blob_sizes=$(git diff-tree -r -c -M -C --no-commit-id $1 | grep " A " | cut -d " " -f 4 | git cat-file --batch-check | cut -d " " -f 3) 10 | total_size=0 11 | 12 | for size in $blob_sizes; do 13 | let total_size+=size 14 | done 15 | 16 | if [ $total_size -gt 0 ]; then 17 | total_size_kib=$(echo $total_size | awk '{printf "%.2f",$1/1024}') 18 | total_size_mib=$(echo $total_size_kib | awk '{printf "%.2f",$1/1024}') 19 | echo "The commit adds files totalling in $total_size bytes ($total_size_kib KiB, $total_size_mib MiB)." 20 | else 21 | echo "The commit does not add any files." 22 | fi 23 | -------------------------------------------------------------------------------- /git/git-contains-symlinks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dir=${1:-.}/.git 4 | 5 | if git --git-dir=$dir ls-tree -r HEAD | grep -q ^12; then 6 | path=$(dirname $(readlink -f $dir)) 7 | echo "Repository at '$path' contains symbolic links." 8 | fi 9 | -------------------------------------------------------------------------------- /git/git-count-cc-merges: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script requires bash for array functionality. 4 | 5 | # Get the list of branches and convert it to an array. 6 | branches=$(git for-each-ref --format='%(refname:short)' refs/heads/) 7 | branches=( $branches ) 8 | N=${#branches[*]} 9 | 10 | cc_merges=0 11 | 12 | # Loop over all combinations of two branches. 13 | for ((i=0; i" 6 | exit 1 7 | fi 8 | 9 | git diff $(git log --pretty=oneline -1 $1 | cut -b 1-40)^ $1 10 | -------------------------------------------------------------------------------- /git/git-find-least-modifications: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for COMMIT in $(git rev-list $1); do 4 | MOD_FILES=$(git diff --diff-filter=M --name-only $COMMIT | wc -l) 5 | if [ -z "$MIN" -o ]; then 6 | MIN=$MOD_FILES 7 | BEST=$COMMIT 8 | elif [ $MOD_FILES -lt $MIN ]; then 9 | MIN=$MOD_FILES 10 | BEST=$COMMIT 11 | fi 12 | done 13 | 14 | echo "Best matching commit is $BEST with $MIN modified files." 15 | -------------------------------------------------------------------------------- /git/git-hash-blob: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script calculates the Git-style SHA1 for a blob / file like "git hash-object $1" does. 4 | 5 | infile=$1 6 | outfile=$(mktemp) 7 | 8 | if !(dos2unix -n "$infile" "$outfile" 2>&1 | grep -q "Skipping binary file"); then 9 | infile=$outfile 10 | fi 11 | 12 | (stat --printf="blob %s\0" "$infile"; cat "$infile") | sha1sum -b | cut -d" " -f1 13 | 14 | rm -f "$outfile" 15 | -------------------------------------------------------------------------------- /git/git-list-branches-with-contained-commits.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | UPSTREAM_BRANCH=${2:-origin/main} 4 | REMOTE_BRANCHES=$(git branch -r -l origin/* | grep -vE "(HEAD|$UPSTREAM_BRANCH)") 5 | CHECK_BRANCHES=${1:-$REMOTE_BRANCHES} 6 | 7 | NUM_BRANCHES=$(echo "$CHECK_BRANCHES" | wc -l) 8 | BRANCH_COUNTER=0 9 | 10 | for BRANCH in $CHECK_BRANCHES; do 11 | BRANCH_COUNTER=$((BRANCH_COUNTER + 1)) 12 | echo -n "[$BRANCH_COUNTER/$NUM_BRANCHES] Commits of branch $BRANCH " 13 | 14 | UNEQUAL_LINES=$(git range-diff $UPSTREAM_BRANCH...$BRANCH | grep -v " = " | wc -l) 15 | 16 | if [ $UNEQUAL_LINES -eq 0 ]; then 17 | echo "ARE contained in $UPSTREAM_BRANCH." 18 | else 19 | echo "are NOT contained in $UPSTREAM_BRANCH." 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /git/git-list-reviewers: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 1 ]; then 4 | echo "Rationale : Lists potential reviewers for given commits (wraps git-contacts)." 5 | echo "Usage : $(basename $0) (||)..." 6 | exit 1 7 | fi 8 | 9 | for arg in "$@"; do 10 | if [ ! -f "$arg" ]; then 11 | if [[ "$arg" != *..* ]]; then 12 | # Use different semantics than git-contacts if this is a single commit. 13 | git contacts $arg^..$arg 14 | continue 15 | fi 16 | fi 17 | 18 | # Fall back to just calling git-contacts as-is. 19 | git contacts $arg 20 | done 21 | -------------------------------------------------------------------------------- /git/git-list-tags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Rationale : Lists all (lightweight) tags matching a pattern in reverse chronological order." 5 | echo "Usage : $(basename $0) " 6 | exit 1 7 | fi 8 | 9 | # See http://stackoverflow.com/a/13293965/1127485 for use with Jenkins. 10 | git log --tags=$1 --no-walk --pretty="format:%d" | grep -o $1 11 | -------------------------------------------------------------------------------- /git/git-log-json: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # See https://til.simonwillison.net/jq/git-log-json. 4 | 5 | git log --pretty=format:'%H%x00%an <%ae>%x00%ad%x00%s%x00' | \ 6 | jq -R -s '[split("\n")[:-1] | map(split("\u0000")) | .[] | { 7 | "commit": .[0], 8 | "author": .[1], 9 | "date": .[2], 10 | "message": .[3] 11 | }]' 12 | -------------------------------------------------------------------------------- /git/git-log-other-than: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 2 ]; then 4 | echo "Rationale : Lists all commits that touch any files other than those matching a regex pattern." 5 | echo "Usage : $(basename $0) " 6 | exit 1 7 | fi 8 | 9 | for commit in $(git rev-list $1); do 10 | names=$(git show --pretty="format:" --name-only $commit | tail -n +2) 11 | if echo "$names" | grep -qv $2; then 12 | echo "$commit touches other files" 13 | fi 14 | done 15 | -------------------------------------------------------------------------------- /git/git-merge-customizations: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | UPSTREAM_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) 4 | CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) 5 | TARGET_BRANCH=${CURRENT_BRANCH%-test} 6 | 7 | CUSTOMIZATION_BRANCHES=$(git for-each-ref --format="%(refname)" "refs/remotes/**/$TARGET_BRANCH-customizations/*") 8 | 9 | if [ -z "$CUSTOMIZATION_BRANCHES" ]; then 10 | echo "There are no customizations for branch '$TARGET_BRANCH', aborting." 11 | exit 1 12 | fi 13 | 14 | echo "Resetting branch to '$UPSTREAM_BRANCH'..." 15 | git reset --hard $UPSTREAM_BRANCH 16 | 17 | echo "Merging the following branches into '$CURRENT_BRANCH'..." 18 | for BRANCH in $CUSTOMIZATION_BRANCHES; do 19 | echo $BRANCH 20 | done 21 | 22 | git merge --no-ff $CUSTOMIZATION_BRANCHES 23 | -------------------------------------------------------------------------------- /git/git-prompt.sh: -------------------------------------------------------------------------------- 1 | #PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]' # set window title 2 | PS1='\[\033]0;`basename ${PWD//[^[:ascii:]]/?}`\007\]' # set window title 3 | PS1="$PS1"'\n' # new line 4 | PS1="$PS1"'\[\033[32m\]' # change to green 5 | PS1="$PS1"'\u@\h ' # user@host 6 | PS1="$PS1"'\[\033[35m\]' # change to purple 7 | PS1="$PS1"'$MSYSTEM ' # show MSYSTEM 8 | PS1="$PS1"'\[\033[33m\]' # change to brownish yellow 9 | PS1="$PS1"'\w' # current working directory 10 | if test -z "$WINELOADERNOEXEC" 11 | then 12 | GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)" 13 | COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}" 14 | COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}" 15 | COMPLETION_PATH="$COMPLETION_PATH/share/git/completion" 16 | if test -f "$COMPLETION_PATH/git-prompt.sh" 17 | then 18 | . "$COMPLETION_PATH/git-completion.bash" 19 | . "$COMPLETION_PATH/git-prompt.sh" 20 | PS1="$PS1"'\[\033[36m\]' # change color to cyan 21 | PS1="$PS1"'`__git_ps1`' # bash function 22 | fi 23 | fi 24 | PS1="$PS1"'\[\033[0m\]' # change color 25 | PS1="$PS1"'\n' # new line 26 | PS1="$PS1"'$ ' # prompt: always $ 27 | -------------------------------------------------------------------------------- /git/git-rename-remote-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 3 ]; then 4 | echo "Rationale : Rename a branch on the server without checking it out." 5 | echo "Usage : $(basename $0) " 6 | echo "Example : $(basename $0) origin master release" 7 | exit 1 8 | fi 9 | 10 | git push $1 $1/$2:refs/heads/$3 :$2 11 | -------------------------------------------------------------------------------- /git/git-set-author-committer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 -a $# -ne 3 -a $# -ne 5 ]; then 4 | echo "Rationale : Set the author and committer name and email for a number of recent commits." 5 | echo "Usage : $(basename $0) [ [ ]]" 6 | exit 1 7 | fi 8 | 9 | if [ $# -eq 1 ]; then 10 | an="$(git config user.name)" 11 | ae="$(git config user.email)" 12 | else 13 | an=$2 14 | ae=$3 15 | fi 16 | 17 | if [ $# -ne 5 ]; then 18 | cn=$an 19 | ce=$ae 20 | else 21 | cn=$4 22 | ce=$5 23 | fi 24 | 25 | if [ $(git rev-list HEAD | wc -l) -eq $1 ]; then 26 | # We need to rewrite all commits including the root commit. 27 | range="-- --all" 28 | else 29 | range="HEAD~$1..HEAD" 30 | fi 31 | 32 | FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --env-filter "GIT_AUTHOR_NAME='$an'; GIT_AUTHOR_EMAIL='$ae'; GIT_COMMITTER_NAME='$cn'; GIT_COMMITTER_EMAIL='$ce';" $range 33 | -------------------------------------------------------------------------------- /git/git-show-merge-resolution: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -lt 1 -o $# -gt 2 ]; then 4 | echo "Rationale : Show the merge commit resolution in the configured merge tool." 5 | echo "Usage : $(basename $0) [-c] " 6 | echo "Options : -c (Show conflicts only.)" 7 | exit 1 8 | fi 9 | 10 | die() { 11 | echo >&2 "$@" 12 | exit 255 13 | } 14 | 15 | if [ "$1" = "-c" ]; then 16 | conflicts_only=true 17 | shift 18 | else 19 | conflicts_only=false 20 | fi 21 | 22 | ours=$1^1 23 | theirs=$1^2 24 | base=$(git merge-base $ours $theirs) 25 | 26 | if $conflicts_only; then 27 | files=$(git show $1 | grep "diff --cc" | cut -d " " -f 3-) 28 | else 29 | files=$(git merge-tree $base $ours $theirs | grep -A 3 "changed in both" | grep "base" | cut -d " " -f 8-) 30 | fi 31 | 32 | if [ -n "$files" ]; then 33 | count=$(echo "$files" | wc -l) 34 | count=$(echo $count) 35 | else 36 | count=0 37 | fi 38 | 39 | if $conflicts_only; then 40 | if [ $count = "0" ]; then 41 | echo "There were no conflicting files in that merge commit." 42 | elif [ $count = "1" ]; then 43 | echo "There was one conflicting file in that merge commit:" 44 | else 45 | echo "There were $count conflicting files in that merge commit:" 46 | fi 47 | else 48 | if [ $count = "0" ]; then 49 | echo "There were no files concurrently changed in both parents." 50 | elif [ $count = "1" ]; then 51 | echo "There was one file concurrently changed in both parents:" 52 | else 53 | echo "There were $count files concurrently changed in both parents:" 54 | fi 55 | fi 56 | 57 | for f in "$files"; do 58 | echo "$f" 59 | done 60 | 61 | TOOL_MODE=merge 62 | : ${MERGE_TOOL_LIB=$(git --exec-path)/git-mergetool--lib} 63 | . "$MERGE_TOOL_LIB" 64 | 65 | merge_tool=$(get_merge_tool "$merge_tool") || die "Error: No merge tool configured." 66 | 67 | check_unchanged () { 68 | status=0 69 | } 70 | 71 | for f in $files; do 72 | LOCAL="/tmp/$f.LOCAL" 73 | BASE="/tmp/$f.BASE" 74 | REMOTE="/tmp/$f.REMOTE" 75 | MERGED="/tmp/$1.MERGED" 76 | 77 | # Silence the call to "touch" in "merge_cmd ()". 78 | BACKUP="/tmp/$1.BACKUP" 79 | 80 | mkdir -p $(dirname $LOCAL) && git show $ours:"$f" > $LOCAL 81 | mkdir -p $(dirname $BASE) && git show $base:"$f" > $BASE 82 | mkdir -p $(dirname $REMOTE) && git show $theirs:"$f" > $REMOTE 83 | mkdir -p $(dirname $MERGED) && git show $1:"$f" > $MERGED 84 | 85 | run_merge_tool "$merge_tool" "true" 86 | done 87 | -------------------------------------------------------------------------------- /git/git-split-arbitrary-paths: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Credits go to http://jimmy.schementi.com/splitting-up-a-git-repo. 4 | 5 | PATHS_TO_KEEP="$@" 6 | git filter-branch -f --index-filter "git rm --ignore-unmatch --cached -qr -- . && git reset -q \$GIT_COMMIT -- $PATHS_TO_KEEP" --prune-empty -- HEAD 7 | -------------------------------------------------------------------------------- /git/git-test-rebase-merge-commits: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -d test ]; then 4 | echo "The test directory already exists, please delete it manually." 5 | exit 1 6 | fi 7 | 8 | mkdir test 9 | cd test 10 | 11 | # Create a repo with an initial commit. 12 | git init 13 | echo "line 1" > readme.txt 14 | git add . 15 | git commit -m "Initial commit" 16 | 17 | # Create branches A and B with additional non-conflicting commits each. 18 | git co -b A master 19 | echo "A" > A.txt 20 | git add . 21 | git commit -m "Add A.txt" 22 | 23 | # Create branches A and B with additional non-conflicting commits each. 24 | git co -b B master 25 | echo "B" > B.txt 26 | git add . 27 | git commit -m "Add B.txt" 28 | 29 | # Merge B into A and create yet another commit on A. 30 | git checkout A 31 | git merge B 32 | echo "A2" > A2.txt 33 | git add . 34 | git commit -m "Add A2.txt" 35 | 36 | # Create another commit on master. 37 | git checkout master 38 | echo "line 2" >> readme.txt 39 | git commit -a -m "Second commit" 40 | 41 | echo -e "\nHistory looks like this:" 42 | git log --graph --all --oneline 43 | read -n1 -p "Press any key to continue ..." -s 44 | 45 | # Rebase A onto the current master. 46 | echo -e "\nRebasing A onto the current master without preserving merges ..." 47 | git checkout A 48 | git rebase master 49 | 50 | echo -e "\nNow history looks like this:" 51 | git log --graph --oneline 52 | read -n1 -p "Press any key to continue ..." -s 53 | 54 | echo -e "\nRebasing A onto the current master with preserving merges ..." 55 | git reset --hard ORIG_HEAD 56 | git rebase -p master 57 | 58 | echo -e "\nNow history looks like this:" 59 | git log --graph --oneline 60 | -------------------------------------------------------------------------------- /github/github-clone-org.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! which jq > /dev/null 2>&1; then 4 | echo "This script depends on https://stedolan.github.io/jq/." 5 | echo "Please put the 'jq' executable into your PATH." 6 | exit 1 7 | fi 8 | 9 | if [ $# -ne 1 ]; then 10 | echo "Rationale : Clone all public repositories of a GitHub organization." 11 | echo "Usage : $(basename $0) " 12 | exit 1 13 | fi 14 | 15 | ORG=$1 16 | 17 | URLS=$(curl -s https://api.github.com/orgs/$1/repos | jq -r '.[].clone_url' | tr -d '\r') 18 | 19 | for URL in $URLS; do 20 | DIRNAME=$(basename "$URL" .git) 21 | if [ -d $DIRNAME -o -f $DIRNAME.lnk ]; then 22 | echo "Skipping '$DIRNAME' as the target already exists." 23 | continue 24 | fi 25 | 26 | echo "Cloning to '$DIRNAME'..." 27 | git clone -q $URL 28 | done 29 | -------------------------------------------------------------------------------- /github/github-delete-workflow-runs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WORKFLOW=$1 4 | 5 | gh run list --limit 500 --workflow "$WORKFLOW" --json databaseId | jq -r ".[] | .databaseId | @sh" | xargs -I{} gh run delete "{}" 6 | -------------------------------------------------------------------------------- /gradle/github-dependency-graph-gradle-plugin.init.gradle: -------------------------------------------------------------------------------- 1 | // This uses the Gradle plugin from https://github.com/gradle/github-dependency-graph-gradle-plugin. 2 | // 3 | // Running this like 4 | // 5 | // $ ./gradlew -I ~/Downloads/github-dependency-graph-gradle-plugin.init.gradle ForceDependencyResolutionPlugin_resolveAllDependencies 6 | // 7 | // creates these two files: 8 | // 9 | // - ./build/reports/dependency-graph-snapshots/dependency-graph.json 10 | // - ./build/reports/dependency-graph-snapshots/dependency-list.txt 11 | 12 | initscript { 13 | repositories { 14 | maven { 15 | url = uri("https://plugins.gradle.org/m2/") 16 | } 17 | } 18 | 19 | dependencies { 20 | classpath("org.gradle:github-dependency-graph-gradle-plugin:1.3.1") 21 | } 22 | } 23 | 24 | apply plugin: org.gradle.dependencygraph.simple.SimpleDependencyGraphPlugin 25 | -------------------------------------------------------------------------------- /gradle/github-dependency-graph-gradle-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)" 4 | 5 | pushd $1 > /dev/null 6 | 7 | ./gradlew -I $SCRIPT_DIR/github-dependency-graph-gradle-plugin.init.gradle ForceDependencyResolutionPlugin_resolveAllDependencies 8 | cat ./build/reports/dependency-graph-snapshots/dependency-graph.json 9 | 10 | popd > /dev/null 11 | -------------------------------------------------------------------------------- /gradle/gradlew_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! which jq > /dev/null 2>&1; then 4 | echo "This script depends on https://stedolan.github.io/jq/." 5 | echo "Please put the 'jq' executable into your PATH." 6 | exit 1 7 | fi 8 | 9 | current=$(curl -s https://services.gradle.org/versions/current) 10 | 11 | version=$(echo $current | jq -r '.version') 12 | echo "The most recent Gradle version is $version." 13 | 14 | if [ -n "$2" ]; then 15 | version=$2 16 | echo "Using provided Gradle version $version." 17 | fi 18 | 19 | dist_type_min_version=3.1 20 | if [ $(echo -e "$version\n$dist_type_min_version" | sort -V | head -1) = $dist_type_min_version ]; then 21 | [ -z $1 ] && dist_type="bin" || dist_type="all" 22 | echo "Will use the '$dist_type' distribution type." 23 | dist_type="--distribution-type $dist_type" 24 | fi 25 | 26 | dist=$(ls -d ~/.gradle/wrapper/dists/gradle-$version-*/*/gradle-$version 2> /dev/null) 27 | if [ $? -eq 0 ]; then 28 | dist=$(echo "$dist" | head -1) 29 | echo "Found version in cache at $dist." 30 | gradle=$dist/bin/gradle 31 | else 32 | url=$(echo $current | jq -r '.downloadUrl') 33 | echo "Downloading version from $url." 34 | zip=$(mktemp --suffix .zip) 35 | curl -o $zip -L -s $url 36 | unzip -o -q $zip -d /tmp 37 | gradle=/tmp/gradle-$version/bin/gradle 38 | fi 39 | 40 | # In the end, ensure the Gradle wrapper is executable, e.g. if a previously existing one was overwritten. 41 | $gradle --no-daemon --configure-on-demand wrapper --gradle-version $version $dist_type && chmod a+x gradlew 42 | 43 | if [ -f "$zip" ]; then 44 | rm -r $zip /tmp/gradle-$version 45 | fi 46 | -------------------------------------------------------------------------------- /gradle/gradlew_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)" 4 | 5 | for i in $(find . -type d -exec [ -f {}/gradlew ] \; -print -prune); do 6 | echo "Entering directory $i..." 7 | pushd $i > /dev/null 8 | $SCRIPT_DIR/gradlew_bootstrap.sh all 9 | popd > /dev/null 10 | done 11 | -------------------------------------------------------------------------------- /kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle/ 2 | /.idea/ 3 | /gradle/ 4 | gradlew 5 | gradlew.bat 6 | -------------------------------------------------------------------------------- /kotlin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | // This is a dummy file to make Fleet recognize `.main.kts` scripts in this folder, see 2 | // https://youtrack.jetbrains.com/issue/FL-22261. 3 | -------------------------------------------------------------------------------- /kotlin/json-schema-to-kotlinx-serialization.main.kts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env kotlin 2 | 3 | @file:DependsOn("com.github.ajalt.clikt:clikt-jvm:5.0.3") 4 | @file:DependsOn("net.pwall.json:json-kotlin-schema-codegen:0.116") 5 | 6 | import com.github.ajalt.clikt.core.CliktCommand 7 | import com.github.ajalt.clikt.core.Context 8 | import com.github.ajalt.clikt.core.context 9 | import com.github.ajalt.clikt.core.main 10 | import com.github.ajalt.clikt.output.MordantHelpFormatter 11 | import com.github.ajalt.clikt.parameters.arguments.argument 12 | import com.github.ajalt.clikt.parameters.options.default 13 | import com.github.ajalt.clikt.parameters.options.option 14 | import com.github.ajalt.clikt.parameters.types.file 15 | import com.github.ajalt.mordant.rendering.Theme 16 | 17 | import java.io.File 18 | import java.net.URI 19 | 20 | import net.pwall.json.schema.codegen.CodeGenerator 21 | 22 | object : CliktCommand(name = __FILE__.name) { 23 | val schema by argument() 24 | 25 | val packageName by option() 26 | .default("com.example") 27 | 28 | val outputDirectory by option() 29 | .file(mustExist = false, canBeFile = false, canBeDir = true, mustBeWritable = true, mustBeReadable = false, canBeSymlink = true) 30 | .default(File(".")) 31 | 32 | init { 33 | context { 34 | helpFormatter = { MordantHelpFormatter(context = it, "*", showDefaultValues = true) } 35 | } 36 | } 37 | 38 | override fun help(context: Context): String = 39 | "This command takes a JSON schema (either a URI or a file) as the input and produces matching code for Kotlin data classes as the output." 40 | 41 | override fun run() { 42 | val schemaUri = URI.create(schema).takeIf { it.isAbsolute } ?: File(schema).toURI() 43 | 44 | val codeGenerator = CodeGenerator().apply { 45 | basePackageName = packageName 46 | baseDirectoryName = outputDirectory.path 47 | } 48 | 49 | runCatching { 50 | codeGenerator.generate(schemaUri) 51 | }.onFailure { 52 | echo(Theme.Default.danger(it.message.orEmpty())) 53 | } 54 | } 55 | }.main(args) 56 | -------------------------------------------------------------------------------- /kotlin/openapi-to-kotlinx-serialization.main.kts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env kotlin 2 | 3 | @file:DependsOn("com.github.ajalt.clikt:clikt-jvm:5.0.3") 4 | @file:DependsOn("org.openapitools:openapi-generator:7.12.0") 5 | 6 | import com.github.ajalt.clikt.core.CliktCommand 7 | import com.github.ajalt.clikt.core.Context 8 | import com.github.ajalt.clikt.core.context 9 | import com.github.ajalt.clikt.core.main 10 | import com.github.ajalt.clikt.output.MordantHelpFormatter 11 | import com.github.ajalt.clikt.parameters.arguments.argument 12 | import com.github.ajalt.clikt.parameters.options.default 13 | import com.github.ajalt.clikt.parameters.options.option 14 | import com.github.ajalt.clikt.parameters.types.file 15 | import com.github.ajalt.mordant.rendering.Theme 16 | 17 | import java.io.File 18 | 19 | import org.openapitools.codegen.DefaultGenerator 20 | import org.openapitools.codegen.config.CodegenConfigurator 21 | 22 | object : CliktCommand(name = __FILE__.name) { 23 | val schema by argument() 24 | 25 | val outputDirectory by option() 26 | .file(mustExist = false, canBeFile = false, canBeDir = true, mustBeWritable = true, mustBeReadable = false, canBeSymlink = true) 27 | .default(File(".")) 28 | 29 | init { 30 | context { 31 | helpFormatter = { MordantHelpFormatter(context = it, "*", showDefaultValues = true) } 32 | } 33 | } 34 | 35 | override fun help(context: Context): String = 36 | "This command takes a JSON schema (either a URI or a file) as the input and produces matching code for Kotlin data classes as the output." 37 | 38 | override fun run() { 39 | val config = CodegenConfigurator().apply { 40 | setInputSpec(schema) 41 | setOutputDir(outputDirectory.absolutePath) 42 | setGeneratorName("kotlin") 43 | setLibrary("jvm-retrofit2") 44 | addAdditionalProperty("useCoroutines", "true") 45 | addAdditionalProperty("serializationLibrary", "kotlinx_serialization") 46 | } 47 | 48 | val generator = DefaultGenerator().apply { 49 | opts(config.toClientOptInput()) 50 | } 51 | 52 | runCatching { 53 | generator.generate() 54 | }.onFailure { 55 | echo(Theme.Default.danger(it.message.orEmpty())) 56 | } 57 | } 58 | }.main(args) 59 | -------------------------------------------------------------------------------- /linux/watch_and_copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WATCH_DIR=$1 4 | COPY_DIR=$2 5 | 6 | inotifywait -m "$WATCH_DIR" -e create | while read DIRECTORY EVENT FILE; do 7 | cp "$DIRECTORY/$FILE" "$COPY_DIR" 8 | echo "Copied $FILE to $COPY_DIR". 9 | done 10 | -------------------------------------------------------------------------------- /maven/inject-maven-plugin-from-jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | POM_FILE=$1 4 | 5 | # Pretent that the plugin is only available locally. 6 | curl -o cyclonedx-maven-plugin.jar https://repo1.maven.org/maven2/org/cyclonedx/cyclonedx-maven-plugin/2.8.1/cyclonedx-maven-plugin-2.8.1.jar 7 | 8 | # Install the plugin JAR to the local Maven repository in order to be able to refer to it via GAV coordinates. 9 | mvn org.apache.maven.plugins:maven-install-plugin:3.1.3:install-file -Dfile=cyclonedx-maven-plugin.jar 10 | 11 | # Run the plugin's "makeAggregateBom" goal on the provided POM file. 12 | mvn org.cyclonedx:cyclonedx-maven-plugin:2.8.1:makeAggregateBom -f $POM_FILE 13 | 14 | # Remove the downloaded plugin JAR. 15 | rm cyclonedx-maven-plugin.jar 16 | -------------------------------------------------------------------------------- /maven/list_pom_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$#" -ne 3 ]; then 4 | echo "Usage: $(basename $0) " 5 | exit 1 6 | fi 7 | 8 | POM_DIR="$(echo "$1" | tr . /)/$2/$3" 9 | POM_PATH="$POM_DIR/$2-$3.pom" 10 | 11 | mkdir -p "$HOME/.m2/repository/$POM_DIR" 12 | 13 | if type -p wget > /dev/null; then 14 | wget -q -O "$HOME/.m2/repository/$POM_PATH" "http://repo.maven.apache.org/maven2/$POM_PATH" 15 | elif type -p curl > /dev/null; then 16 | curl -s -o "$HOME/.m2/repository/$POM_PATH" "http://repo.maven.apache.org/maven2/$POM_PATH" 17 | fi 18 | 19 | mvn -f "$HOME/.m2/repository/$POM_PATH" dependency:tree 20 | -------------------------------------------------------------------------------- /text/ensure_final_newline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | ed -s $1 <<< $'w' 9 | -------------------------------------------------------------------------------- /text/trim_trailing_whitespaces.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | sed -i 's/[ \t]*$//' $1 9 | --------------------------------------------------------------------------------