diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 000000000..9bc01b4c3 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,3 @@ +--- +BUNDLE_PATH: "vendor/bundle" +BUNDLE_DISABLE_SHARED_GEMS: "true" diff --git a/00_hello/hello.rb b/00_hello/hello.rb new file mode 100644 index 000000000..fa307a03f --- /dev/null +++ b/00_hello/hello.rb @@ -0,0 +1,7 @@ +def hello + "Hello!" +end + +def greet name + "Hello, #{name}!" +end \ No newline at end of file diff --git a/01_temperature/temperature.rb b/01_temperature/temperature.rb new file mode 100644 index 000000000..93bb4d704 --- /dev/null +++ b/01_temperature/temperature.rb @@ -0,0 +1,6 @@ +def ftoc farenheit + (5/9.0)*(farenheit-32) +end +def ctof celcius + (9/5.0)*celcius+32 +end \ No newline at end of file diff --git a/02_calculator/calculator.rb b/02_calculator/calculator.rb new file mode 100644 index 000000000..2db0ad7cd --- /dev/null +++ b/02_calculator/calculator.rb @@ -0,0 +1,26 @@ +def add num,mod + num + mod +end +def subtract num, mod + num - mod +end +def sum numbers + total = 0 + numbers.each{|num| total += num} + total +end +def multiply num, factor, *multiple + if multiple + multiple.each {|additional_factor| factor *= additional_factor} + end + num * factor +end +def power num, factor + num**factor +end +def factorial num + if num < 2 then return 1 end + total = 1 + num.downto(1) {|factorial| total *= factorial} + total +end \ No newline at end of file diff --git a/02_calculator/calculator_spec.rb b/02_calculator/calculator_spec.rb index fef7e9d00..65facc077 100644 --- a/02_calculator/calculator_spec.rb +++ b/02_calculator/calculator_spec.rb @@ -79,21 +79,38 @@ describe "#multiply" do - it "multiplies two numbers" + it "multiplies two numbers" do + expect(multiply(4,9)).to eq(36) + end - it "multiplies several numbers" + it "multiplies several numbers" do + expect(multiply(4,9,0)).to eq(0) + end end describe "#power" do - it "raises one number to the power of another number" + it "raises one number to the power of another number" do + expect(power(2,4)).to eq(16) + end end # http://en.wikipedia.org/wiki/Factorial describe "#factorial" do - it "computes the factorial of 0" - it "computes the factorial of 1" - it "computes the factorial of 2" - it "computes the factorial of 5" - it "computes the factorial of 10" + it "computes the factorial of 0" do + expect(factorial(0)).to eq(1) + end + it "computes the factorial of 1" do + expect(factorial(1)).to eq(1) + end + it "computes the factorial of 2" do + expect(factorial(2)).to eq(2) + end + + it "computes the factorial of 5" do + expect(factorial(5)).to eq(5*4*3*2*1) + end + it "computes the factorial of 10" do + expect(factorial(10)).to eq(10*9*8*7*6*5*4*3*2*1) + end end diff --git a/03_simon_says/simon_says.rb b/03_simon_says/simon_says.rb new file mode 100644 index 000000000..ce5ff060f --- /dev/null +++ b/03_simon_says/simon_says.rb @@ -0,0 +1,30 @@ +def echo words + words +end +def shout words + echo words.upcase +end +def repeat words, times=2 + echo words+(" "+words)*(times-1) +end +def start_of_word word, num + letters = word.split("") + start = letters[0...num] + start.join +end +def first_word sentence + words = sentence.split(" ") + words[0] +end +def titleize sentence + small = ["and", "or", "the", "over", "to", "the", "a", "but"] + i = 0 + words= sentence.split(" ").map! do |word| + i += 1 + if (small.include?(word) && i != 1) + word + else + word.capitalize + end + end.join(" ") +end \ No newline at end of file diff --git a/04_pig_latin/pig_latin.rb b/04_pig_latin/pig_latin.rb new file mode 100644 index 000000000..a685a8c6d --- /dev/null +++ b/04_pig_latin/pig_latin.rb @@ -0,0 +1,19 @@ +def vowel? letter + ["a", "e", "i", "o", "u"].include? letter.downcase +end +def qu? word, letter + (word.chars[letter].downcase == "q" && word.chars[letter+1].downcase == "u") +end +def translate sentence + words = sentence.split(" ").map do |word| + if vowel? word.chars.first then word+"ay" + else + letter = 0 + until vowel? word.chars[letter+1] do + letter += 1 + end + if qu? word, letter then letter += 1 end + word.chars[letter+1..-1].join+word.chars[0..letter].join+"ay" + end + end.join(" ") +end \ No newline at end of file diff --git a/05_silly_blocks/silly_blocks.rb b/05_silly_blocks/silly_blocks.rb new file mode 100644 index 000000000..17b0fa987 --- /dev/null +++ b/05_silly_blocks/silly_blocks.rb @@ -0,0 +1,9 @@ +def reverser + yield.split(" ").map {|word| word.reverse}.join(" ") +end +def adder num=1 + yield+num +end +def repeater num=1 + num.times {yield} +end \ No newline at end of file diff --git a/06_performance_monitor/performance_monitor.rb b/06_performance_monitor/performance_monitor.rb new file mode 100644 index 000000000..bc137daa9 --- /dev/null +++ b/06_performance_monitor/performance_monitor.rb @@ -0,0 +1,7 @@ +def measure num=1 + nt = Time.now + num.times do + yield + end + total = (Time.now - nt)/num +end \ No newline at end of file diff --git a/07_hello_friend/friend.rb b/07_hello_friend/friend.rb new file mode 100644 index 000000000..ca42655fb --- /dev/null +++ b/07_hello_friend/friend.rb @@ -0,0 +1,5 @@ +class Friend + def greeting who=nil + @greeting = "Hello #{(who ? ', ' + who : nil)}!" + end +end \ No newline at end of file diff --git a/08_book_titles/book.rb b/08_book_titles/book.rb new file mode 100644 index 000000000..438a2189d --- /dev/null +++ b/08_book_titles/book.rb @@ -0,0 +1,29 @@ +class Book + def conjunction? word + ["and", "but", "for", "nor", "or", "so", "yet"].include? word + end + def preposition? word + ["a", "an", "in", "of", "the"].include? word + + + end + def title=(title) + i=0 + @title = title.split(" ").map do |word| + if i == 0 + i = 1 + word.capitalize + elsif conjunction? word + word + elsif preposition? word + word + else + word.capitalize + end + + end.join(" ") + end + def title + @title + end +end \ No newline at end of file diff --git a/09_timer/timer.rb b/09_timer/timer.rb new file mode 100644 index 000000000..a61256b75 --- /dev/null +++ b/09_timer/timer.rb @@ -0,0 +1,22 @@ +class Timer + def initialize + self.seconds=(0) + end + def seconds=(seconds) + @seconds = seconds + @time_string = Time.at(seconds).utc.strftime("%H:%M:%S") + + #Manual Method + + #hours = seconds/3600 + #minutes = seconds % 3600 / 60 + #seconds = seconds % 3600 % 60 + #@time_string = "#{(hours<10 ? '0'+hours.to_s : hours)}:#{(minutes<10 ? '0'+minutes.to_s : minutes)}:#{(seconds<10 ? '0'+seconds.to_s : seconds)}" + end + def seconds + @seconds + end + def time_string + @time_string + end +end \ No newline at end of file diff --git a/10_temperature_object/temperature.rb b/10_temperature_object/temperature.rb new file mode 100644 index 000000000..ed3e78154 --- /dev/null +++ b/10_temperature_object/temperature.rb @@ -0,0 +1,49 @@ +class Temperature + attr_accessor :f, :c + + def Temperature.from_celsius temp + Temperature.new(:c => temp) + end + + def Temperature.from_fahrenheit temp + Temperature.new(:f => temp) + end + + def initialize args + @f = args[:f] + @c = args[:c] + if @f + @c = ftoc + else + @f = ctof + end + end + + def ftoc + (@f-32)*5/9.0 + end + + def ctof + (@c*9/5.0)+32 + end + + def in_fahrenheit + @f + end + + def in_celsius + @c + end +end + +class Celsius < Temperature + def Celsius.new args + Temperature.new(:c => 50) + end +end + +class Fahrenheit < Temperature + def Fahrenheit.new args + Temperature.new(:f => 50) + end +end \ No newline at end of file diff --git a/11_dictionary/dictionary.rb b/11_dictionary/dictionary.rb new file mode 100644 index 000000000..8fc1cf25a --- /dev/null +++ b/11_dictionary/dictionary.rb @@ -0,0 +1,38 @@ +class Dictionary + + attr_reader :entries + + def initialize + @entries = {} + end + + def add items + if items.is_a?(Hash) + items.each {|key, definition| @entries[key] = definition} + else + @entries[items] = nil + end + @entries = Hash[@entries.sort_by {|key, definition| key}] + end + + def find partial + @entries.select {|key, definition| key.include? partial} + end + + def include? key + @entries.has_key? key + end + + def keywords + @entries.keys + end + + def printable + output = "" + @entries.each do |key, definition| + output += "[#{key}] \"#{definition}\"\n" + end + output.chomp + end + +end \ No newline at end of file diff --git a/12_rpn_calculator/rpn_calculator.rb b/12_rpn_calculator/rpn_calculator.rb new file mode 100644 index 000000000..137c28906 --- /dev/null +++ b/12_rpn_calculator/rpn_calculator.rb @@ -0,0 +1,49 @@ +class RPNCalculator + + attr_reader :value + + def initialize + @value = 0 + @entered = [] + end + + def divide + operate &:/ + end + + def evaluate formula + formula = tokens formula + formula.each do |token| + (token.class == Symbol ? operate(&token) : push(token)) + end + return @value + end + + def minus + operate &:- + end + + def operate &operator + raise "calculator is empty" if @entered.length < 2 + @value = @entered.push(@entered.pop(2).reduce &operator)[-1] + end + + def plus + operate &:+ + end + + def push num + @entered << num.to_f + end + + def times + operate &:* + end + + def tokens token_list + token_list.split(" ").map do |token| + (token.to_i.to_s == token ? token.to_i : token.to_sym) + end + end + +end \ No newline at end of file diff --git a/13_xml_document/xml_document.rb b/13_xml_document/xml_document.rb new file mode 100644 index 000000000..d2b8367a2 --- /dev/null +++ b/13_xml_document/xml_document.rb @@ -0,0 +1,31 @@ +class XmlDocument + + attr_accessor :beautify, :nested_level + def initialize(beautify= false) + @beautify = beautify + @nested_level = 0 + end + def indent + (beautify ? (" " * nested_level) : "") + end + + def method_missing(tag_name, *args, &block) + attributes = args[0] || false + nl = (beautify ? "\n" : "" ) + tag = "" + tag << "<#{tag_name}" + attributes.each {|name, value| tag << " #{name}='#{value}'" } if attributes + if block_given? + tag << ">" + nl + @nested_level += 1 + tag << indent + yield + @nested_level -= 1 + tag << indent + "" + nl + else + tag << "/>" + nl + end + tag + end + +end + diff --git a/14_array_extensions/array_extensions.rb b/14_array_extensions/array_extensions.rb new file mode 100644 index 000000000..5bb93502b --- /dev/null +++ b/14_array_extensions/array_extensions.rb @@ -0,0 +1,23 @@ +class Array + + def commutative &operator + if self.length < 1 then 0 + elsif self.length < 2 then self[0] + else + self.reduce &operator + end + end + + def square + self.map {|num| num**2 } + end + + def square! + self.map! {|num| num**2 } + end + + def sum + commutative &:+ + end + +end \ No newline at end of file diff --git a/15_in_words/in_words.rb b/15_in_words/in_words.rb new file mode 100644 index 000000000..7794fe92d --- /dev/null +++ b/15_in_words/in_words.rb @@ -0,0 +1,62 @@ +class Fixnum + + def word_list + { + 1000000000000 => "trillion", + 1000000000 => "billion", + 1000000 => "million", + 1000 => "thousand", + 100 => "hundred", + 90 => "ninety", + 80 => "eighty", + 70 => "seventy", + 60 => "sixty", + 50 => "fifty", + 40 => "forty", + 30 => "thirty", + 20 => "twenty", + 19 =>"nineteen", + 18 =>"eighteen", + 17 =>"seventeen", + 16 =>"sixteen", + 15 =>"fifteen", + 14 =>"fourteen", + 13 =>"thirteen", + 12 =>"twelve", + 11 => "eleven", + 10 => "ten", + 9 => "nine", + 8 => "eight", + 7 => "seven", + 6 => "six", + 5 => "five", + 4 => "four", + 3 => "three", + 2 => "two", + 1 => "one" + } + end + def write_words(num) + word = "" + until num == 0 + word_list.each do |base, name| + if num < 10 && num/base > 0 + word << "#{name}" + num -= num + elsif num < 100 && num/base > 0 + word << "#{name} " + num %= base + elsif num/base > 0 + word << write_words(num/base) + " #{name} " + num %= base + end + end + end + word.strip + end + + def in_words + if self == 0 then return "zero" end + write_words(self) + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/2.3.0/bin/byebug b/vendor/bundle/ruby/2.3.0/bin/byebug new file mode 100755 index 000000000..da51c647b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/byebug @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'byebug' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'byebug', version +load Gem.bin_path('byebug', 'byebug', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/coderay b/vendor/bundle/ruby/2.3.0/bin/coderay new file mode 100755 index 000000000..c27fc0dae --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/coderay @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'coderay' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'coderay', version +load Gem.bin_path('coderay', 'coderay', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/htmldiff b/vendor/bundle/ruby/2.3.0/bin/htmldiff new file mode 100755 index 000000000..deec4fc59 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/htmldiff @@ -0,0 +1,25 @@ +#!/bin/sh +'exec' "ruby" '-x' "$0" "$@" +#!/usr/bin/ruby +# +# This file was generated by RubyGems. +# +# The application 'diff-lcs' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'diff-lcs', version +load Gem.bin_path('diff-lcs', 'htmldiff', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/ldiff b/vendor/bundle/ruby/2.3.0/bin/ldiff new file mode 100755 index 000000000..e106db644 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/ldiff @@ -0,0 +1,25 @@ +#!/bin/sh +'exec' "ruby" '-x' "$0" "$@" +#!/usr/bin/ruby +# +# This file was generated by RubyGems. +# +# The application 'diff-lcs' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'diff-lcs', version +load Gem.bin_path('diff-lcs', 'ldiff', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/pry b/vendor/bundle/ruby/2.3.0/bin/pry new file mode 100755 index 000000000..850853cb3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/pry @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'pry' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'pry', version +load Gem.bin_path('pry', 'pry', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/rake b/vendor/bundle/ruby/2.3.0/bin/rake new file mode 100755 index 000000000..d5fbaafc5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/rake @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'rake', version +load Gem.bin_path('rake', 'rake', version) diff --git a/vendor/bundle/ruby/2.3.0/bin/rspec b/vendor/bundle/ruby/2.3.0/bin/rspec new file mode 100755 index 000000000..3d6decc38 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/bin/rspec @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'rspec-core' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +if ARGV.first + str = ARGV.first + str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding + if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then + version = $1 + ARGV.shift + end +end + +gem 'rspec-core', version +load Gem.bin_path('rspec-core', 'rspec', version) diff --git a/vendor/bundle/ruby/2.3.0/cache/byebug-5.0.0.gem b/vendor/bundle/ruby/2.3.0/cache/byebug-5.0.0.gem new file mode 100644 index 000000000..e0cb57490 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/byebug-5.0.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/coderay-1.1.0.gem b/vendor/bundle/ruby/2.3.0/cache/coderay-1.1.0.gem new file mode 100644 index 000000000..20f291162 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/coderay-1.1.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/columnize-0.9.0.gem b/vendor/bundle/ruby/2.3.0/cache/columnize-0.9.0.gem new file mode 100644 index 000000000..0896d5ecf Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/columnize-0.9.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/diff-lcs-1.2.5.gem b/vendor/bundle/ruby/2.3.0/cache/diff-lcs-1.2.5.gem new file mode 100644 index 000000000..e4436ccc5 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/diff-lcs-1.2.5.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/method_source-0.8.2.gem b/vendor/bundle/ruby/2.3.0/cache/method_source-0.8.2.gem new file mode 100644 index 000000000..842453a33 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/method_source-0.8.2.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/pry-0.10.1.gem b/vendor/bundle/ruby/2.3.0/cache/pry-0.10.1.gem new file mode 100644 index 000000000..258687536 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/pry-0.10.1.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/pry-byebug-3.2.0.gem b/vendor/bundle/ruby/2.3.0/cache/pry-byebug-3.2.0.gem new file mode 100644 index 000000000..5d473e017 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/pry-byebug-3.2.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rake-10.4.2.gem b/vendor/bundle/ruby/2.3.0/cache/rake-10.4.2.gem new file mode 100644 index 000000000..0bea3c015 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rake-10.4.2.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rspec-3.1.0.gem b/vendor/bundle/ruby/2.3.0/cache/rspec-3.1.0.gem new file mode 100644 index 000000000..9f909adb4 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rspec-3.1.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rspec-core-3.1.7.gem b/vendor/bundle/ruby/2.3.0/cache/rspec-core-3.1.7.gem new file mode 100644 index 000000000..2b20659f2 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rspec-core-3.1.7.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rspec-expectations-3.1.2.gem b/vendor/bundle/ruby/2.3.0/cache/rspec-expectations-3.1.2.gem new file mode 100644 index 000000000..1b0f2258d Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rspec-expectations-3.1.2.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rspec-mocks-3.1.3.gem b/vendor/bundle/ruby/2.3.0/cache/rspec-mocks-3.1.3.gem new file mode 100644 index 000000000..1625553b9 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rspec-mocks-3.1.3.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/rspec-support-3.1.2.gem b/vendor/bundle/ruby/2.3.0/cache/rspec-support-3.1.2.gem new file mode 100644 index 000000000..0a230d618 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/rspec-support-3.1.2.gem differ diff --git a/vendor/bundle/ruby/2.3.0/cache/slop-3.6.0.gem b/vendor/bundle/ruby/2.3.0/cache/slop-3.6.0.gem new file mode 100644 index 000000000..153a673db Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/cache/slop-3.6.0.gem differ diff --git a/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/byebug/byebug.so b/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/byebug/byebug.so new file mode 100755 index 000000000..a44061684 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/byebug/byebug.so differ diff --git a/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/gem.build_complete b/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/gem.build_complete new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/gem_make.out b/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/gem_make.out new file mode 100644 index 000000000..a2eb78183 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-5.0.0/gem_make.out @@ -0,0 +1,19 @@ +current directory: /home/samps/sites/assignments/learn_ruby/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug +/usr/bin/ruby -r ./siteconf20161027-1433-fbqg38.rb extconf.rb +creating Makefile + +current directory: /home/samps/sites/assignments/learn_ruby/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug +make "DESTDIR=" clean + +current directory: /home/samps/sites/assignments/learn_ruby/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug +make "DESTDIR=" +compiling threads.c +compiling byebug.c +compiling context.c +compiling locker.c +compiling breakpoint.c +linking shared-object byebug/byebug.so + +current directory: /home/samps/sites/assignments/learn_ruby/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug +make "DESTDIR=" install +/usr/bin/install -c -m 0755 byebug.so ./.gem.20161027-1433-zgd52b/byebug diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CHANGELOG.md b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CHANGELOG.md new file mode 100644 index 000000000..893e704e1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CHANGELOG.md @@ -0,0 +1,450 @@ +## 5.0.0 +### Fixed +* [#136](https://github.com/deivid-rodriguez/byebug/issues/136). `frame` +command not working with negative numbers (thanks @ark6). + +### Added +* IDE support and a new command/subcommand API for plugins. +* Add a "savefile" setting holding the file where "save" command saves current +debugger's state. + +### Changed +* `disable` no longer disable all breakpoints, it just shows command's help +instead. To disable all breakpoints now you need to do `disable breakpoints` +(or `dis b`). Similarly, you can't no longer use `dis 1 2 3` but need to do +`dis b 1 2 3` to disable specific breakpoints. The same applies to the `enable` +command. + +### Removed +* `help set ` no longer works. `help set` includes that same output and +it's not verbose enough so that this is a problem. Same with `help show +`. + +## 4.0.5 - 2015-04-02 +### Fixed +* [#131](https://github.com/deivid-rodriguez/byebug/issues/131) +* Thread commands help format should be consistent with the rest of the help +system now. + +## 4.0.4 - 2015-03-27 +### Fixed +* [#127](https://github.com/deivid-rodriguez/byebug/issues/127) + +## 4.0.3 - 2015-03-19 +### Fixed +* Unused variable warning in context.c + +## 4.0.2 - 2015-03-16 +### Fixed +* [#118](https://github.com/deivid-rodriguez/byebug/issues/118). Remove +`rb-readline` as a dependency and show a help message whenever requiring +`readline` fails instead. + +## 4.0.1 - 2015-03-13 +### Fixed +* .yml files needed for printers support were missing from the release... :S +* [#118](https://github.com/deivid-rodriguez/byebug/issues/118). Add `readline` +as a dependency. + +## 4.0.0 - 2015-03-13 +### Added +- `untracevar` command that stops tracing a global variable. +- Window CI build through AppVeyor. +- OSX CI build through Travis. +- Style enforcement through RuboCop. +- C style enforment using the `indent` command line utility. +- Some remote debugging tests (thanks @eric-hu). +- Printer's support (thanks @astashov). + +### Changed +- A lot of internal refactoring. +- `tracevar` now requires the full global variable name (with "$"). +- [#92](https://github.com/deivid-rodriguez/byebug/issues/92). The `catch` +command is not allowed in post_mortem mode anymore. It was not working anyways. +- [#85](https://github.com/deivid-rodriguez/byebug/issues/85). `step` is now +more user friendly when used in combination with `up`. +- `var const` can now be called without an argument and will show constants in +the current scope. +- `break` with a class name now creates breakpoints regardless of class not +being yet defined. If that's the case, it gives a warning but the class is +created anyways. + +### Fixed +- Code reloading issues. +- `set fullpath` was not showing fullpaths. Now it is. +- `up`, `down` and `frame` commands now work in post_mortem mode (#93). +- rc file (`.byebugrc`) loading: invalid commands are just ignored instead of +aborting, global (home) rc file is now properly loaded before project's file. +- [#93](https://github.com/deivid-rodriguez/byebug/issues/93). Backtraces not +working in `post_mortem` mode. +- 'cmd1 ; cmd2 ; ...; cmdN' syntax which allows running several commands +sequentially. +- [#101](https://github.com/deivid-rodriguez/byebug/issues/101). `finish` +command not stopping at the correct line. +- [#106](https://github.com/deivid-rodriguez/byebug/issues/106). `break` with +namespaced class, like `break A::B#c` should now work. +- Command history is now persisted before exiting byebug. +- Setting breakpoint in a method would stop not only at the beginning of the +method but also at the beginning of every block inside the method. +- [#122](https://github.com/deivid-rodriguez/byebug/issues/122). Setting +breakpoints on module methods (@x-yuri). + +### Removed +- `autoreload` setting as it's not necessary anymore. Code should always be up +to date. +- `reload` command for the same reason. +- Gem dependency on `debugger-linecache`. +- `step+`, `step-`, `next+`, `next-`, `set/show linetrace_plus` and +`set/show forcestep` commands. These were all mechanisms to deal with TracePoint +API event dupplication, but this duplicated events have been completely removed +from the API since +[r48609](bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/48609), so +they are no longer necessary. +- `info file` subcommands: `info file breakpoints`, `info file mtime`, `info +file sha1`, `info file all`. Now all information is listed under `info file`. +- `testing` setting. It was just a hack to be able to test `byebug`. Nobody was +supposed to actually use it! +- `var class` command, just use Ruby (`self.class.class_variables`). +- `p` command, just use `eval`, or just type your expression and `byebug` will +autoevaluate it. +- `exit` alias for `quit`. + +## 3.5.1 - 2014-09-29 +### Fixed +- [#79](https://github.com/deivid-rodriguez/byebug/issues/79). Windows +installation. +- `condition` command not properly detecting invalid breakpoint ids. + +## 3.5.0 - 2014-09-28 +### Fixed +- [#81](https://github.com/deivid-rodriguez/byebug/issues/81). Byebug's history +messing up other programs using Readline. +- Readline's history not being properly saved and inmediately available. +- User not being notified when trying to debug a non existent script. + +### Changed +- Complete rewrite of byebug's history. +- Complete rewrite of list command. +- Docs about stacktrace related commands (up, down, frame, backtrace). + +## 3.4.2 - 2014-09-26 +### Fixed +- [#67](https://github.com/deivid-rodriguez/byebug/issues/67). Debugging +commands invoked by ruby executable, as in `byebug -- ruby -Itest a_test.rb +-n test_something`. + +## 3.4.1 - 2014-09-25 +### Fixed +- [#54](https://github.com/deivid-rodriguez/byebug/issues/54). Use of threads +inside `eval` command. +- `list` command not listing backwards after reaching the end of the file. + +## 3.4.0 - 2014-09-01 +### Fixed +- deivid-rodriguez/pry-byebug#32 in a better way. + + +## 3.3.0 - 2014-08-28 +### Fixed +- `set verbose` command. +- `set post_mortem false` command. +- Debugger stopping in `byebug`'s internal frames in some cases. +- `backtrace` crashing when `fullpath` setting disabled and calculated stack +size being smaller than the real one. + +## Changed +- The `-t` option for `bin/byebug` now turns tracing on whereas the `-x` option +tells byebug to run the initialization file (.byebugrc) on startup. This is the +default behaviour though. +- `bin/byebug` libified and tests added. + +### Removed +- `info locals` command. Use `var local` instead. +- `info instance_variables` command. Use `var instance` instead. +- `info global_variables` command. Use `var global` instead. +- `info variables` command. Use `var all` instead. +- `irb` command stepping capabilities, see +[8e226d0](https://github.com/deivid-rodriguez/byebug/commit/8e226d0). +- `script` and `restart-script` options for `bin/byebug`. + +## 3.2.0 - 2014-08-02 +### Fixed +- [#71](https://github.com/deivid-rodriguez/byebug/issues/71). Remote debugging +(thanks @shuky19). +- [#69](https://github.com/deivid-rodriguez/byebug/issues/69). `source` command +(thanks @Olgagr). + +### Removed +- `post_mortem` activation through `Byebug.post_mortem`. Use `set post_mortem` +instead. +- `info stack` command. Use `where` instead. +- `method iv` command. Use `var instance` instead. +- [#77](https://github.com/deivid-rodriguez/byebug/issues/77). Warning. + +## 3.1.2 - 2014-04-23 +### Fixed +- (Really) `post_mortem` mode in `bin/byebug`. +- Line tracing in `bin/byebug`. + +## 3.1.1 - 2014-04-23 +### Fixed +- `post_mortem` mode in bin/byebug. + +## 3.1.0 - 2014-04-23 +### Removed +- `show commands` command. Use `history` instead. +- Byebug.start accepting options. Any program settings you want applied from +the start should be set in `.byebugrc`. +- `trace` command. Use `set linetrace` for line tracing and `tracevar` for +global variable tracing. +- `show version` command. Use `byebug --version` to check byebug's version. +- `set arg` setting. Use the `restart` command instead. + +### Changed +- `linetrace_plus` setting renamed to `tracing_plus`. + +### Added +- `history` command to check byebug's history of previous commands. + +## 3.0.0 - 2014-04-17 +### Fixed +- Plain `byebug` not working when `pry-byebug` installed. +- `post_mortem` mode. +- Command history not being saved after regular program termination. +- [#54](https://github.com/deivid-rodriguez/byebug/issues/54). (Again) calling +`Byebug.start` with `Timeout.timeout` (thanks @zmoazeni). + +### Added +- Allow disabling `post_mortem` mode. + +### Changed +- `show commands` command for listing history of previous commands now behaves +like shell's `history` command. +- `show/set history filename` is now `show/set histfile` +- `show/set history size` is now `show/set histsize` +- `show/set history save` is now `show/set autosave` +- `finish` semantics, see +[61f9b4d](https://github.com/deivid-rodriguez/byebug/commit/61f9b4d). +- Use `per project` history file by default. + +## Removed +- The `init` option for `Byebug.start`. Information to make the `restart` +command work is always saved now. + +## 2.7.0 - 2014-02-24 +### Fixed +- [#52](https://github.com/deivid-rodriguez/byebug/issues/52). `IGNORED_FILES` +slowing down startup. +- [#53](https://github.com/deivid-rodriguez/byebug/issues/53) and +[#54](https://github.com/deivid-rodriguez/byebug/issues/54). Calling +`Byebug.start` with `Timeout.timeout`. + +## 2.6.0 - 2014-02-08 +### Fixed +- Circular dependency affecting `pry-byebug` (thanks @andreychernih). + +## 2.5.0 - 2013-12-14 +### Added +- Support for `sublime-debugger`. + +## 2.4.1 - 2013-12-05 +### Fixed +- [#40](https://github.com/deivid-rodriguez/byebug/issues/40). Installation +error in Mac OSX (thanks @luislavena). + +## 2.4.0 - 2013-12-02 +### Fixed +- `thread list` showing too many threads. +- Fix setting post mortem mode with `set post_mortem`. Now this is the only +post mortem functionality available as specifying `Byebug.post_mortem` with a +block has been removed in this version. + +### Added +- (Again) `debugger` as an alias to `byebug` (thanks @wallace). +- `-R` option for `bin/byebug` to specify server's hostname:port for remote +debugging (thanks @mrkn). + +### Changed +- Use `require` instead of `require_relative` for loading byebug's extension +library (thanks @nobu). +- `trace variable $foo` should be now `trace variable $foo`. + +## 2.3.1 - 2013-10-17 +### Fixed +- Breakpoint removal. +- Broken test suite. + +## 2.3.0 - 2013-10-09 +### Added +- Compatibility with Phusion Passenger Enterprise (thanks @FooBarWidget). + +### Changed +- More minimalist help system. + +## 2.2.2 - 2013-09-25 +### Fixed +- Compilation issue in 64 bit systems. + +## 2.2.1 - 2013-09-24 +### Fixed +- [#26](https://github.com/deivid-rodriguez/byebug/issues/26). Compilation issue +introduced in `2.2.0`. + +### Changed +- `show/set stack_trace_on_error` is now `show/set stack_on_error`. + +## 2.2.0 - 2013-09-22 +### Fixed +- Stack size calculations. +- Setting `post_mortem` mode. + +### Added +- `verbose` setting for TracePoint API event inspection. + +### Changed +- Warning free byebug. +- Allow `edit ` without a line number. + +## 2.1.1 - 2013-09-10 +### Fixed +- Debugging code inside `-e` Ruby flag. + +## 2.1.0 - 2013-09-08 +### Fixed +- Remote debugging display. +- `eval` crashing when inspecting raised an exception (reported by @iblue). + +### Changed +- `enable breakpoints` now enables every breakpoint. +- `disable breakpoints` now disables every breakpoint. + +## 2.0.0 - 2013-08-30 +### Added +- "Official" definition of a command API. +- Thread support. + +### Removed +- `jump` command. It had never worked. + +### Changed +- Several internal refactorings. + +## 1.8.2 - 2013-08-16 +### Fixed +- `save` command now saves the list of `displays`. +- Stack size calculation. + +### Changed +- More user friendly regexps for commands. +- Better help for some commands. + +## 1.8.1 - 2013-08-12 +### Fixed +- Major regression introduced in 1.8.0. + +## 1.8.0 - 2013-08-12 +### Added +- Remote debugging support. + +## 1.7.0 - 2013-08-03 +### Added +- List command automatically called after callstack navigation commands. +- C-frames specifically marked in the callstack. +- C-frames skipped when navigating the callstack. + +## 1.6.1 - 2013-07-10 +### Fixed +- Windows compatibiliy: compilation and terminal width issues. + +## 1.6.0 - 2013-07-10 +### Fixed +- `byebug` placed at the end of a block or method call not working as expected. +- `autolist` being applied when Ruby `-e` option used. + +### Changed +- Backtrace callstyles. Use `long` for detailed frames in callstack and `short` +for more concise frames. + +## 1.5.0 - 2013-06-21 +### Fixed +- Incomplete backtraces when the debugger was not started at program startup. + +## 1.4.2 - 2013-06-20 +### Fixed +- `help command subcommand` command. +- Interaction with Rails Console debugging flag. +- `post_mortem` mode when running byebug from the outset. +- `no-quit` flag when running byebug from the outset. + +## 1.4.1 - 2013-06-15 +### Fixed +- Crash when printing some filenames in backtraces. +- Allow byebug developers to easily use compilers different from gcc (thanks +@GarthSnyder!). + +## 1.4.0 - 2013-06-05 +### Fixed +- Memory leaks causing `byebug` to randomly crash. + +### Changed +- Use the Debug Inspector API for backtrace information. + +## 1.3.1 - 2013-06-02 +### Fixed +- Interaction with Rails debugging flag. +- Crash when trying to print lines of code containing the character '%'. +- `basename` and `linetrace` options not working together. + +## 1.3.0 - 2013-05-25 +### Added +- Support colon-delimited include paths in command-line front-end (@ender672). + +## 1.2.0 - 2013-05-20 +### Fixed +- Ctrl+C during command line editing (works like pry/irb). + +### Added +- `pry` command. + +## 1.1.1 - 2013-05-07 +### Added +- `pry-byebug` compatibility. + +### Changed +- Better help system. +- Code cleanup. + +## 1.1.0 - 2013-04-30 +### Added +- Post Mortem support. + +## 1.0.3 - 2013-04-23 +### Fixed +- Negative line numbers shown by list command at the beginning of file. +- `backtrace` command segfaulting when trying to show info on some frame args. +Don't know the reason yet, but the exception is handled now and command does +not segfault anymore. + +### Changed +- `autoreload` is set by default now. +- Try some thread support (not even close to usable). + +## 1.0.2 - 2013-04-09 +### Fixed +- backtraces messed up when using both `next`/`step` and backtrace navigation +commands. + +### Changed +- `autolist` and `autoeval` are default settings now. + +## 1.0.1 - 2013-04-06 +### Fixed +- Byebug not loading properly. + +## 1.0.0 - 2013-03-29 +### Fixed +- Green test suite. + +## 0.0.1 - 2013-03-18 +### Added +- Initial release. diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CONTRIBUTING.md b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CONTRIBUTING.md new file mode 100644 index 000000000..3605990d3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/CONTRIBUTING.md @@ -0,0 +1,36 @@ +## Getting started + +The following steps should help you getting started: + +* `Byebug` depends on the TracePoint API provided by `ruby-core`. This is a +young API and a lot of bugs have been recently corrected, so make sure you +always have the lastest patch level release installed. +* Get a local clone of `byebug`'s source code. +* Run `bundle install` to get development & test dependencies installed. +* Install the [overcommit][] hooks using `bundle exec overcommit --install`. +They will review your changes before they are committed, checking they are +consistent with the project's code style. If you're changing C files, make sure +you have the GNU indent utility installed in your system. `sudo apt-get install +indent` for linux or `brew install gnu-indent --with-default-names` should do +the job. +* Make sure you compile the C-extension using `bundle exec rake compile`. +Otherwise you won't be able to use `byebug`. +* Run the test suite using the default rake task (`bundle exec rake`). This +task is composed of 2 subtasks: `bundle exec rake compile` && `bundle exec rake +test`. + +After having done this, just read the code and improve it! Your contribution is +appreciated a lot! + +[overcommit]: https://github.com/brigade/overcommit/ + +## Byebug as a C-extension + +Byebug is a gem developed as a C-extension. The debugger internal's +functionality is implemented in C (the interaction with the TracePoint API). +The rest of the gem is implemented in Ruby. Normally you won't need to touch +the C-extension, but it will obviously depended on the bug you're trying to fix +or the feature you are willing to add. You can learn more about C-extensions +[here](http://tenderlovemaking.com/2009/12/18/writing-ruby-c-extensions-part-1.html) +or +[here](http://tenderlovemaking.com/2010/12/11/writing-ruby-c-extensions-part-2.html). diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/GUIDE.md b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/GUIDE.md new file mode 100644 index 000000000..59b28c8a3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/GUIDE.md @@ -0,0 +1,1850 @@ +### First Steps + +A handful of commands are enough to get started using `byebug`. The following +session illustrates these commands. Take the following sample file: + +```ruby +# +# The n'th triangle number: triangle(n) = n*(n+1)/2 = 1 + 2 + ... + n +# +def triangle(n) + tri = 0 + + 0.upto(n) { |i| tri += i } + + tri +end + +t = triangle(3) +puts t + +``` + +Let's debug it. + +```bash +$ byebug /path/to/triangle.rb + +[1, 10] in /path/to/triangle.rb + 1: # + 2: # The n'th triangle number: triangle(n) = n*(n+1)/2 = 1 + 2 + ... + n + 3: # +=> 4: def triangle(n) + 5: tri = 0 + 6: + 7: 0.upto(n) { |i| tri += i } + 8: + 9: tri + 10: end +(byebug) +``` + +We are currently stopped before the first executable line of the program: line 4 +of `triangle.rb`. If you are used to less dynamic languages and have used +debuggers for more statically compiled languages like C, C++, or Java, it may +seem odd to be stopped before a function definition but in Ruby line 4 is +executed. + +Byebug's prompt is `(byebug)`. If the program has died and you are in +post-mortem debugging, `(byebug:post-mortem)` is used instead. If the program +has terminated normally and the `--no-quit` option has been specified in the +command line, the prompt will be `(byebug:ctrl)` instead. The commands available +change depending on the program's state. + +Byebug automatically lists 10 lines of code centered around the current line +every time it is stopped. The current line is marked with `=>`. If the range +would overflow the beggining or the end of the file, byebug will move it +accordingly so that only actual real lines of code are displayed. + +Now let us step through the program. + +```bash +(byebug) step + +[5, 14] in /path/to/triangle.rb + 5: tri = 0 + 6: + 7: 0.upto(n) { |i| tri += i } + 9: end + 10: + 11: tri + 12: end + 13: +=> 14: triangle(3) +(byebug) # hit enter + +[1, 10] in /path/to/triangle.rb + 1: # + 2: # The n'th triangle number: triangle(n) = n*(n+1)/2 = 1 + 2 + ... + n + 3: # + 4: def triangle(n) +=> 5: tri = 0 + 6: + 7: 0.upto(n) { |i| tri += i } + 8: + 9: tri + 10: end +(byebug) p tri +nil +(byebug) step + +[2, 11] in /path/to/triangle.rb + 2: # The n'th triangle number: triangle(n) = n*(n+1)/2 = 1 + 2 + ... + n + 3: # + 4: def triangle(n) + 5: tri = 0 + 6: +=> 7: 0.upto(n) { |i| tri += i } + 8: + 9: tri + 10: end + 11: +(byebug) p tri +0 +``` + +The first `step` command runs the script one executable unit. The second command +we entered was just hitting the return key: `byebug` remembers the last command +you entered was `step` and runs it again. + +One way to print the values of variables is `p` (there are other ways). When we +look at the value of `tri` the first time, we see it is `nil`. Again we are +stopped _before_ the assignment on line 5, and this variable hadn't been set +previously. However after issuing another `step` command we see that the value +is 0 as expected. If every time we stop we want to see the value of `tri` to see +how things are going, there is a better way by setting a display expression: + +```bash +(byebug) display tri +1: tri = 0 +``` + +Now let us run the program until right before we return from the function. We'll +want to see which lines get run, so we turn on _line tracing_. If we don't want +whole paths to be displayed when tracing, we can turn on _basename_. + +```bash +(byebug) set linetrace +linetrace is on +(byebug) set basename +basename is on +(byebug) finish 0 +Tracing: triangle.rb:7 0.upto(n) { |i| tri += i } +1: tri = 0 +Tracing: triangle.rb:7 0.upto(n) { |i| tri += i } +1: tri = 0 +Tracing: triangle.rb:7 0.upto(n) { |i| tri += i } +1: tri = 1 +Tracing: triangle.rb:7 0.upto(n) { |i| tri += i } +1: tri = 3 +Tracing: triangle.rb:9 tri +1: tri = 6 +1: tri = 6 + +[4, 13] in /home/davidr/Proyectos/byebug/triangle.rb + 4: def triangle(n) + 5: tri = 0 + 6: + 7: 0.upto(n) { |i| tri += i } + 8: + 9: tri +=> 10: end + 11: + 12: t = triangle(3) + 13: puts t +(byebug) quit +Really quit? (y/n) +y +``` + +So far, so good. As you can see from the above to get out of `byebug`, one +can issue a `quit` command (`q` and `exit` are just as good). If you want to +quit without being prompted, suffix the command with an exclamation mark, e.g., +`q!`. + + +### Second Sample Session: Delving Deeper + +In this section we'll introduce breakpoints, the call stack and restarting. +Below we will debug a simple Ruby program to solve the classic Towers of Hanoi +puzzle. It is augmented by the bane of programming: some command-parameter +processing with error checking. + +```ruby +# +# Solves the classic Towers of Hanoi puzzle. +# +def hanoi(n, a, b, c) + hanoi(n - 1, a, c, b) if n - 1 > 0 + + puts "Move disk #{a} to #{b}" + + hanoi(n - 1, c, b, a) if n - 1 > 0 +end + +n_args = $ARGV.length + +fail('*** Need number of disks or no parameter') if n_args > 1 +``` + +Recall in the first section it was stated that before the `def` is run, the method it +names is undefined. Let's check that out. First let's see what private methods +we can call before running `def hanoi`. + + +```bash +$ byebug path/to/hanoi.rb + + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # + 4: def hanoi(n, a, b, c) + 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end +(byebug) private_methods +[:public, :private, :include, :using, :define_method, :default_src_encoding, ... +``` + +`private_methods` is not a byebug command but a Ruby feature. By default, when +`byebug` doesn't understand a command, it will evaluate it as if it was a Ruby +command. If you don't want this behaviour, you can use `set noautoeval` or +even drop it in your `.byebugrc` file if you want that behaviour permanently. +The output of `private_methods`, thought, is unwieldy for our purpose: check +whether `hanoi` method is in the list. Fortunately, byebug has nice formatting +features: we can sort the output and put it into columns list using the print +command `ps`. It also has a `width` setting that let's us adapt the width of +the output so that it nicely fits our screen. + +```bash +(byebug) set width 80 +Maximum width of byebug's output is 80 +(byebug) ps private_methods +Array default_src_encoding open sleep +Complex define_method p spawn +Digest eval pp sprintf +Float exec print srand +Hash exit printf syscall +Integer exit! private system +Pathname fail proc test +Rational fork public throw +String format putc timeout +URI gem_original_require puts trace_var +__callee__ gets raise trap +__dir__ global_variables rand untrace_var +__method__ include readline using +` initialize readlines warn +abort initialize_clone require y +at_exit initialize_copy require_relative +autoload initialize_dup respond_to_missing? +autoload? iterator? rubygems_require +binding lambda select +block_given? load set_trace_func +caller local_variables singleton_method_added +caller_locations loop singleton_method_removed +catch method_missing singleton_method_undefined +(byebug) +``` + +Now let's see what happens after stepping: + +```bash +(byebug) private_methods.member?(:hanoi) +false +(byebug) step + +[5, 14] in /path/to/hanoi.rb + 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end + 11: +=> 12: n_args = $ARGV.length + 13: + 14: fail('*** Need number of disks or no parameter') if n_args > 1 +(byebug) private_methods.member?(:hanoi) +true +(byebug) +``` + +Okay, lets go on and talk about program arguments. + +```bash +(byebug) $ARGV +[] +``` + +Oops. We forgot to specify any parameters to this program. Let's try again. We +can use the `restart` command here. + +```bash +(byebug) restart 3 +Re exec'ing: + /path/to/bin/byebug /path/to/hanoi.rb 3 + +[1, 10] in /path/to/hanoi.rb + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # +=> 4: def hanoi(n, a, b, c) + 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end +(byebug) break 5 +Created breakpoint 1 at /path/to/hanoi.rb:5 +(byebug) continue +Stopped by breakpoint 1 at /path/to/hanoi.rb:5 + +[1, 10] in /path/to/hanoi.rb + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # + 4: def hanoi(n, a, b, c) +=> 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end +(byebug) display n +1: n = 3 +(byebug) display a +2: a = :a +(byebug) display b +3: b = :b +(byebug) undisplay 3 +(byebug) continue +Stopped by breakpoint 1 at /path/to/hanoi.rb:5 +1: n = 2 +2: a = :a +[1, 10] in /path/to/hanoi.rb + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # + 4: def hanoi(n, a, b, c) +=> 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end + +(byebug) c +Stopped by breakpoint 1 at /path/to/hanoi.rb:5 +1: n = 1 +2: a = :a + +[1, 10] in /path/to/hanoi.rb + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # + 4: def hanoi(n, a, b, c) +=> 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end +(byebug) set nofullpath +fullpath is off +(byebug) where +--> #0 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at .../shortpath/to/hanoi.rb:5 + #1 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at .../shortpath/to/hanoi.rb:5 + #2 at .../Proyectos/byebug/hanoi.rb:28 +(byebug) +``` + +In the above we added new commands: `break` (see [breakpoints]()), which +indicates to stop just before that line of code is run, and `continue`, which +resumes execution. To remove a display expression `undisplay` is used. If we +give a display number, just that display expression is removed. + +We also used a new command `where`(see [backtrace]()) to show the callstack. In +the above situation, starting from the bottom line we see we called the `hanoi` +method from line 28 of the file `hanoi.rb` and the `hanoi` method called itself +two more times at line 5. + +In the callstack we show a _current frame_ mark, the frame number, the method +being called, the names of the parameters, the types those parameters +_currently_ have and the file-line position. Remember it's possible that when +the program was called the parameters had different types, since the types of +variables can change dynamically. You can alter the style of what to show in the +trace (see [callstyle]()). + +Now let's move around the callstack. + +```bash +(byebug) undisplay +Clear all expressions? (y/n) y +(byebug) n_args +NameError Exception: undefined local variable or method `n_args' for main:Object +(byebug) frame 2 + +[19, 28] in /path/to/hanoi.rb + 19: begin + 20: n = $ARGV[0].to_i + 21: rescue ValueError + 22: raise("** Expecting an integer, got: #{$ARGV[0]}") + 23: end + 24: end + 25: + 26: fail('*** Number of disks should be between 1 and 100') if n < 1 || n > 100 + 27: +=> 28: hanoi(n, :a, :b, :c) +(byebug) n_args +0 +(byebug) p n +3 +(byebug) down 2 + +[1, 10] in /path/to/hanoi.rb + 1: # + 2: # Solves the classic Towers of Hanoi puzzle. + 3: # + 4: def hanoi(n, a, b, c) +=> 5: hanoi(n - 1, a, c, b) if n - 1 > 0 + 6: + 7: puts "Move disk #{a} to #{b}" + 8: + 9: hanoi(n - 1, c, b, a) if n - 1 > 0 + 10: end +(byebug) p n +2 +``` + +Notice in the above to get the value of variable `n` we had to use a print +command like `p n`. If we entered just `n`, that would be taken to mean byebug +command `next`. In the current scope, variable `n_args` is not defined. However +I can change to the top-most frame by using the `frame 2` command. Notice that +inside frame #2, the value of `n_args` can be shown. Also note that the value of +variable `n` is different. + + +### Attaching to a running program with `byebug` + +In the previous sessions we've been calling byebug right at the outset, but +there is another mode of operation you might use. If there's a lot of code that +needs to be run before the part you want to inspect, it might not be efficient +or convenient to run byebug from the outset. + +In this section we'll show how to enter the code in the middle of your program, +while delving more into byebug's operation. We will also use unit testing. Using +unit tests will greatly reduce the amount of debugging needed, while at the same +time, will increase the quality of your program. + +What we'll do is take the `triangle` code from the first session and write a +unit test for that. In a sense we did write a tiny test for the program which +was basically the last line where we printed the value of `triangle(3)`. This +test however wasn't automated: the expectation is that someone would look at the +output and verify that what was printed is what was expected. + +Before we can turn that into something that can be `required`, we probably want +to remove that output. However I like to keep in that line so that when I +look at the file, I have an example of how to run it. Therefore we will +conditionally run this line if that file is invoked directly, but skip it if it +is not. _NOTE: `byebug` resets `$0` to try to make things like this work._ + +```ruby +if __FILE__ == $PROGRAM_NAME + t = triangle(3) + puts t +end +``` + +Okay, we're now ready to write our unit test and we'll use the `minitest` +framework for that. Here's the test code, it should be placed in the same +directory as `triangle.rb`. + +```ruby +require 'minitest/autorun' +require_relative 'triangle.rb' + +class TestTriangle < Minitest::Test + def test_basic + solutions = [] + + 0.upto(5) { |i| solutions << triangle(i) } + + assert_equal([0, 1, 3, 6, 10, 15], solutions, 'First 5 triangle numbers') + end +end +``` + +Let's say we want to stop before the first statement in our test method, we'll +add the following: + +```ruby +... +def test_basic + byebug + solutions = [] +... +``` + +Now we run the program, requiring `byebug` + +```bash +$ ruby -rbyebug test_triangle.rb +Run options: --seed 31679 + +# Running: + + +[2, 11] in test_triangle.rb + 2: require_relative 'triangle.rb' + 3: + 4: class TestTriangle < Minitest::Test + 5: def test_basic + 6: byebug +=> 7: solutions = [] + 8: + 9: 0.upto(5) { |i| solutions << triangle(i) } + 10: + 11: assert_equal([0, 1, 3, 6, 10, 15], solutions, 'First 5 triangle numbers') +(byebug) +``` + +and we see that we are stopped at line 7 just before the initialization of the +list `solutions`. + +Now let's see where we are... + +```bash +(byebug) set nofullpath +Displaying frame's full file names is off. +(byebug) bt +--> #0 TestTriangle.test_basic at .../Proyectos/byebug/test_triangle.rb:7 + #1 block (3 levels) in Minitest::Test.run at .../lib/minitest/test.rb:108 + #2 Minitest::Test.capture_exceptions at .../lib/minitest/test.rb:206 + #3 block (2 levels) in Minitest::Test.run at .../lib/minitest/test.rb:105 + #4 Minitest::Test.time_it at .../lib/minitest/test.rb:258 + #5 block in Minitest::Test.run at .../lib/minitest/test.rb:104 + #6 #.on_signal(name#String, action#Proc) at .../minitest-5.5.0/lib/minitest.rb:321 + #7 Minitest::Test.with_info_handler(&block#Proc) at .../lib/minitest/test.rb:278 + #8 Minitest::Test.run at .../lib/minitest/test.rb:103 + #9 #.run_one_method(klass#Class, method_name#String) at .../minitest-5.5.0/lib/minitest.rb:768 + #10 #.run_one_method(klass#Class, method_name#String, reporter#Minitest::CompositeReporter) at .../minitest-5.5.0/lib/minitest.rb:295 + #11 block (2 levels) in #.run(reporter#Minitest::CompositeReporter, options#Hash) at .../minitest-5.5.0/lib/minitest.rb:289 + ͱ-- #12 Array.each at .../minitest-5.5.0/lib/minitest.rb:288 + #13 block in #.run(reporter#Minitest::CompositeReporter, options#Hash) at .../minitest-5.5.0/lib/minitest.rb:288 + #14 #.on_signal(name#String, action#Proc) at .../minitest-5.5.0/lib/minitest.rb:321 + #15 #.with_info_handler(reporter#Minitest::CompositeReporter, &block#Proc) at .../minitest-5.5.0/lib/minitest.rb:308 + #16 #.run(reporter#Minitest::CompositeReporter, options#Hash) at .../minitest-5.5.0/lib/minitest.rb:287 + #17 block in #.__run(reporter#Minitest::CompositeReporter, options#Hash) at .../minitest-5.5.0/lib/minitest.rb:150 + ͱ-- #18 Array.map at .../minitest-5.5.0/lib/minitest.rb:150 + #19 #.__run(reporter#Minitest::CompositeReporter, options#Hash) at .../minitest-5.5.0/lib/minitest.rb:150 + #20 #.run(args#Array) at .../minitest-5.5.0/lib/minitest.rb:127 + #21 block in #.autorun at .../minitest-5.5.0/lib/minitest.rb:56 +(byebug) +``` + +We get the same result as if we had run byebug from the outset. + + +### Debugging Oddities: How debugging Ruby may be different from other languages + +If you are used to debugging in other languages like C, C++, Perl, Java or even +Bash (see [bashdb](http://bashdb.sf.net)), there may be a number of things that +seem or feel a little bit different and may confuse you. A number of these +things aren't oddities of the debugger per se but differences in how Ruby works +compared to those other languages. Because Ruby works a little differently from +those other languages, writing a debugger has to also be a little different as +well if it is to be useful. In this respect, using Byebug may help you +understand Ruby better. + +We've already seen one such difference: the fact that we stop on method +definitions or `def`'s and that is because these are in fact executable +statements. In other compiled languages this would not happen because that's +already been done when you compile the program (or in Perl when it scans in the +program). In this section we'll consider some other things that might throw off +new users to Ruby who are familiar with other languages and debugging in them. + +* Bouncing Around in Blocks (iterators) +* No Parameter Values in a Call Stack +* Lines You Can Stop At + +#### Bouncing Around in Blocks (iterators) + +When debugging languages with coroutines like Python and Ruby, a method call may +not necessarily go to the first statement after the method header. It's possible +that the call will continue after a `yield` statement from a prior call. + +```ruby +# +# Enumerator for primes +# +class SievePrime + def initialize + @odd_primes = [] + end + + def next_prime + candidate = 2 + yield candidate + not_prime = false + candidate += 1 + + loop do + @odd_primes.each do |p| + not_prime = (0 == (candidate % p)) + break if not_prime + end + + unless not_prime + @odd_primes << candidate + yield candidate + end + + candidate += 2 + end + end +end + +SievePrime.new.next_prime do |prime| + puts prime + break if prime > 10 +end +``` + +```bash +$ byebug primes.rb +[1, 10] in /path/to/primes.rb + 1: # + 2: # Enumerator for primes + 3: # +=> 4: class SievePrime + 5: def initialize + 6: @odd_primes = [] + 7: end + 8: + 9: def self.next_prime(&block) + 10: candidate = 2 +(byebug) set tracing +line tracing is on. +(byebug) set basename +basename in on. +(byebug) step 9 +Tracing: primes.rb:5 def initialize +Tracing: primes.rb:9 def next_prime +Tracing: primes.rb:31 SievePrime.new.next_prime do |prime| +Tracing: primes.rb:6 @odd_primes = [] +Tracing: primes.rb:10 candidate = 2 +Tracing: primes.rb:11 yield candidate +Tracing: primes.rb:32 puts prime +2 +Tracing: primes.rb:33 break if prime > 10 +Tracing: primes.rb:12 not_prime = false + +[7, 16] in /path/to/primes.rb + 7: end + 8: + 9: def next_prime + 10: candidate = 2 + 11: yield candidate +=> 12: not_prime = false + 13: candidate += 1 + 14: + 15: loop do + 16: @odd_primes.each do |p| + 17: not_prime = (0 == (candidate % p)) +(byebug) +``` + +The loop between lines 31-34 gets interleaved between those of +`SievePrime#next_prime`, lines 9-28 above. + + +#### No Parameter Values in a Call Stack + +In traditional debuggers, in a call stack you can generally see the names of the +parameters and the values that were passed in. + +Ruby is a very dynamic language and it tries to be efficient within the confines +of the language definition. Values generally aren't taken out of a variable or +expression and pushed onto a stack. Instead a new scope is created and the +parameters are given initial values. Parameter passing is by _reference_ not by +_value_ as it is say Algol, C, or Perl. During the execution of a method, +parameter values can change (and often do). In fact even the _class_ of the +object can change. + +So at present, the name of the parameter is shown. The call-style setting +([callstyle]()) can be used to set whether the name is shown or the name and the +_current_ class of the object. + + +#### Lines You Can Stop At + +Consider the following little Ruby program. + +```ruby +'Yes it does' =~ / +(Yes) \s+ +it \s+ +does +/ix +puts $1 +``` + +The stopping points that Ruby records are the last two lines, lines 5 and 6. + +Inside `byebug` you can get a list of stoppable lines for a file using the `info +file` command. + + +### Threading support + +Byebug supports debugging Ruby programs making use of multiple threads. + +Let's consider the following sample program: + +```ruby +class Company + def initialize(task) + @tasks, @results = Queue.new, Queue.new + + @tasks.push(task) + end + + def run + manager = Thread.new { manager_routine } + employee = Thread.new { employee_routine } + + sleep 6 + + go_home(manager) + go_home(employee) + end + + # + # An employee doing his thing + # + def employee_routine + loop do + if @tasks.empty? + have_a_break(0.1) + else + work_hard(@tasks.pop) + end + end + end + + # + # A manager doing his thing + # + def manager_routine + loop do + if @results.empty? + have_a_break(1) + else + show_off(@results.pop) + end + end + end + + private + + def show_off(result) + puts result + end + + def work_hard(task) + task ** task + end + + def have_a_break(amount) + sleep amount + end + + def go_home(person) + person.kill + end +end + +Company.new(10).run +``` + +The `Company` class simulates a real company. The company has a manager and an +employee represented by 2 threads: they work concurrently to achieve the +company's targets. + +* The employee looks for tasks to complete. If there are tasks, it works hard to +complete them. Otherwise he has a quick break. + +```ruby +# +# An employee doing his thing +# +def employee_routine + loop do + if @tasks.empty? + have_a_break(0.1) + else + work_hard(@tasks.pop) + end + end +end +``` + +* The manager, on the other hand, sits there all day and sporadically checks +whether there are any results to show off. + +```ruby +# +# A manager doing his thing +# +def manager_routine + loop do + if @results.empty? + have_a_break(1) + else + show_off(@results.pop) + end + end +end +``` + +We do some abstractions easily readable in the code. Our tasks are just a +`Queue` of numbers, so are our results. What our employer does when he works is +some calculation with those numbers and what the manager does with the results +is printing them to the screen. + +We instantiate a new company with an initial task and after running that +company we expect the result to be printed in the screen, but it is not. Lets +debug our sample program: + +```bash +[1, 10] in /path/to/company.rb +=> 1: class Company + 2: def initialize(task) + 3: @tasks, @results = Queue.new, Queue.new + 4: + 5: @tasks.push(task) + 6: end + 7: + 8: def run + 9: manager = Thread.new { manager_routine } + 10: employee = Thread.new { employee_routine } +(byebug) l + +[11, 20] in /path/to/company.rb + 11: + 12: sleep 6 + 13: + 14: go_home(manager) + 15: go_home(employee) + 16: end + 17: + 18: # + 19: # An employee doing his thing + 20: # + +(byebug) c 12 +Stopped by breakpoint 1 at /path/to/company.rb:12 + +[7, 16] in /path/to/company.rb + 7: + 8: def run + 9: manager = Thread.new { manager_routine } + 10: employee = Thread.new { employee_routine } + 11: +=> 12: sleep 6 + 13: + 14: go_home(manager) + 15: go_home(employee) + 16: end +(byebug) th l ++ 1 # /path/to/company.rb:12 + 2 # + 3 # +``` + +What we have done here is just start our program and advance to the point +inmediately after our `employee` and `manager` threads have been created. We +can then check that the threads are there using the `thread list` command. Now +we want to debug both of this threads to check what's happening and look for the +bug. + +```bash +(byebug) th switch 3 + +[5, 14] in /path/to/company.rb + 5: @tasks.push(task) + 6: end + 7: + 8: def run + 9: manager = Thread.new { manager_routine } +=> 10: employee = Thread.new { employee_routine } + 11: + 12: sleep 6 + 13: + 14: go_home(manager) +(byebug) th stop 1; th stop 2 +$ 1 # /path/to/company.rb:12 +$ 2 # /path/to/company.rb:9 +(byebug) th l +$ 1 # /path/to/company.rb:12 +$ 2 # /path/to/company.rb:55 ++ 3 # /path/to/company.rb:10 +``` + +We have started by debugging the `employee` thread. To do that, we switch to +that thread using the `thread switch 3` command. The thread number is the one +specified by `thread list`, we know this is our worker thread because `thread +list` specifies where the thread is defined in the file (and its current +position if the thread is currently running, although this is only available +since Ruby 2.2.1). + +After that we stopped the main thread and the worker thread, using the command +`thread stop`. We do this because we want to focus on the employee thread first +and don't want the program to finish while we are debugging. Notice that stopped +threads are marked with the "$" symbol whereas the current thread is marked with +the "+" symbol. + +```bash +(byebug) s + +[17, 26] in /path/to/company.rb + 17: + 18: # + 19: # An employee doing his thing + 20: # + 21: def employee_routine +=> 22: loop do + 23: if @tasks.empty? + 24: have_a_break(0.1) + 25: else + 26: work_hard(@tasks.pop) +(byebug) s + +[18, 27] in /path/to/company.rb + 18: # + 19: # An employee doing his thing + 20: # + 21: def employee_routine + 22: loop do +=> 23: if @tasks.empty? + 24: have_a_break(0.1) + 25: else + 26: work_hard(@tasks.pop) + 27: end +(byebug) n + +[21, 30] in /path/to/company.rb + 21: def employee_routine + 22: loop do + 23: if @tasks.empty? + 24: have_a_break(0.1) + 25: else +=> 26: work_hard(@tasks.pop) + 27: end + 28: end + 29: end + 30: +(byebug) s + +[49, 58] in /path/to/company.rb + 49: def show_off(result) + 50: puts result + 51: end + 52: + 53: def work_hard(task) +=> 54: task ** task + 55: end + 56: + 57: def have_a_break(amount) + 58: sleep amount +(byebug) s + +[21, 30] in /path/to/company.rb + 21: # + 22: # An employee doing his thing + 23: # + 24: def employee_routine + 25: loop do +=> 26: if @tasks.empty? + 27: have_a_break(0.1) + 28: else + 29: work_hard(@tasks.pop) + 30: end +(byebug) n + +[22, 31] in /path/to/company.rb + 22: # An employee doing his thing + 23: # + 24: def employee_routine + 25: loop do + 26: if @tasks.empty? +=> 27: have_a_break(0.1) + 28: else + 29: work_hard(@tasks.pop) + 30: end + 31: end +(byebug) n + +[21, 30] in /path/to/company.rb + 21: # + 22: # An employee doing his thing + 23: # + 24: def employee_routine + 25: loop do +=> 26: if @tasks.empty? + 27: have_a_break(0.1) + 28: else + 29: work_hard(@tasks.pop) + 30: end + 31: end +(byebug) +``` + +Everything seems fine in this thread. The first iteration the employee will do +his job, and after that it will just check for new tasks and sleep. Let's debug +the manager task now: + +```bash +(byebug) th resume 2 + 2 # /path/to/company.rb:12 +(byebug) th switch 2 + 2 # /path/to/company.rb:12 + +[7, 16] in /path/to/company.rb + 7: + 8: # + 9: # A CEO running his company + 10: # + 11: def run +=> 12: manager = Thread.new { manager_routine } + 13: employee = Thread.new { employee_routine } + 14: + 15: sleep 6 + 16: +(byebug) +``` + +We used the command `thread resume` to restart the manager's thread and then +switch to it using `thread switch`. It's important to resume the thread's +execution before switching to it, otherwise we'll get a hang because we cannot +run a sleeping thread. + +Now we can investigate the problem in the employer's side: + +```bash +(byebug) s +[30, 39] in /path/to/company.rb + 30: + 31: # + 32: # A manager doing his thing + 33: # + 34: def manager_routine +=> 35: loop do + 36: if @results.empty? + 37: have_a_break(1) + 38: else + 39: show_off(@results.pop) +(byebug) s + +[31, 40] in /path/to/company.rb + 31: # + 32: # A manager doing his thing + 33: # + 34: def manager_routine + 35: loop do +=> 36: if @results.empty? + 37: have_a_break(1) + 38: else + 39: show_off(@results.pop) + 40: end +(byebug) n + +[32, 41] in /path/to/company.rb + 32: # A manager doing his thing + 33: # + 34: def manager_routine + 35: loop do + 36: if @results.empty? +=> 37: have_a_break(1) + 38: else + 39: show_off(@results.pop) + 40: end + 41: end +(byebug) n + +[31, 40] in /path/to/company.rb + 31: # + 32: # A manager doing his thing + 33: # + 34: def manager_routine + 35: loop do +=> 36: if @results.empty? + 37: have_a_break(1) + 38: else + 39: show_off(@results.pop) + 40: end +(byebug) +``` + +Now we can see the problem, the `@results` variable is always empty! The +employee forgot to leave the results in his manager's deck. We fix it by +changing the line + +```ruby +work_hard(@tasks.pop) +``` + +in the `employee_routine` method with the line + +```ruby +@results << work_hard(@tasks.pop) +``` + +To be continued... +* More complex examples with objects, pretty printing and irb. +* Line tracing and non-interactive tracing. +* Post-mortem debugging. + + +## Getting in & out + +### Starting byebug + +There is a wrapper script called `byebug` which basically `require`'s the gem +then loads `byebug` before its argument (the program to be debugged) is started. +If you don't need to pass dash options to your program, which might be confused +with byebug options, then you don't need to add the `--`. To get a brief list of +options and descriptions, use the `--help` option. + +```bash +$ byebug --help + + byebug 3.5.1 + + Usage: byebug [options] -- + + -d, --debug Set $DEBUG=true + -I, --include list Add to paths to $LOAD_PATH + -m, --[no-]post-mortem Use post-mortem mode + -q, --[no-]quit Quit when script finishes + -x, --[no-]rc Run byebug initialization file + -s, --[no-]stop Stop when script is loaded + -r, --require file Require library before script + -R, --remote [host:]port Remote debug [host:]port + -t, --[no-]trace Turn on line tracing + -v, --version Print program version + -h, --help Display this message + +``` + +Many options appear as a long option name, such as `--help` and a short one +letter option name, such as `-h`. The list of options is detailed below: + +#### -h | --help + +It causes `byebug` to print some basic help and exit + + +#### -v | --version + +It causes `byebug` to print its version number and exit. + + +#### -d | --debug + +Sets `$DEBUG` to `true`. Compatible with Ruby's flag. + +#### -I | --include + +Adds `path` to load path. `path` can be a single path or a colon separated path +list. + +#### -m | --post-mortem + +If your program raises an exception that isn't caught you can enter byebug for +inspection of what went wrong. You may also want to use this option in +conjunction with `--no-stop`. See also [Post-Mortem Debugging](). + +#### --no-quit + +Keep inside `byebug` after your program terminates normally. + +#### --no-stop + +Normally `byebug` stops before executing the first statement. If instead you +want it to start running initially and perhaps break it later in the execution, +use this option. + +#### -r | --require + +Requires the library before executing the script. This option is compatible +with Ruby's. + +#### -t | --trace + +Turns on line tracing. Running `byebug --trace .rb` is pretty much +like running `ruby -rtracer .rb`. If all you want to do however is +get a line trace, `tracer` is most likely faster than `byebug`. + +```bash +$ time byebug --trace --no-stop hanoi.rb > /dev/null + +real 0m0.743s +user 0m0.668s +sys 0m0.068s +$ time ruby -rtracer hanoi.rb > /dev/null + +real 0m0.077s +user 0m0.072s +sys 0m0.004s +``` + +### Byebug default options + +Byebug has many command-line options,; it seems that some people want to set +them differently from the defaults. For example, some people may want +`--no-quit` to be the default behavior. One could write a wrapper script or set +a shell alias to handle this. + +### Command Files + +A command file is a file of lines that are `byebug` commands. Comments (lines +starting with `#`) may also be included. An empty line in a command file does +nothing; it does not mean to repeat the last command, as it would from the +terminal. + +When you start `byebug`, it automatically executes commands from its +_init file_, called `.byebugrc`. During startup, `byebug` does the following: + +* __Processes command line options and operands.__ Reads the init file in your +current directory, if any, and then checks your home directory. The home +directory is the directory named in the `$HOME` or `$HOMEPATH` environment +variable. Thus, you can have more than one init file, one generic in your home +directory, and another, specific to the program you are debugging, in the +directory where you invoke `byebug`. + +You can also request the execution of a command file with the `source` command +(see [Source]()). + + +### Quitting byebug + +To exit `byebug`, use the `quit` command (abbreviated `q` and aliased `exit`). +Normally if you are in an interactive session, this command will prompt to ask +if you really want to quit. If you don't want any questions asked, enter +`quit unconditionally` (abbreviated `q!`). Another way to terminate byebug is to +use the `kill` command. This does the more forceful `kill -9`. It can be used in +cases where `quit` doesn't work (I haven't seen those yet). + + +### Calling byebug from inside your program + +Running a program from byebug adds a bit of overhead and slows it down a little. +Furthermore, by necessity, debuggers change the operation of the program they +are debugging. And this can lead to unexpected and unwanted differences. It has +happened so often that the term +[Heisenbugs](http://en.wikipedia.org/wiki/Heisenbug) was coined to describe the +situation where using a debugger (among other possibilities) changes the +behavior of the program so that the bug doesn't manifest itself anymore. + +There is another way to get into byebug which adds no overhead or slowdown until +you reach the point at which you want to start debugging. However here you must +change the script and make an explicit call to byebug. Because byebug isn't +involved before the first call, there is no overhead and the script will run +at the same speed as if there were no byebug. + +To enter byebug this way, just drop `byebug` in whichever line you want to start +debugging at. You also have to require byebug somehow. If using bundler, it will +take care of that for you, otherwise you can use the ruby `-r` flag or add +`require 'byebug'` in the line previous to the `byebug` call. + +If speed is crucial, you may want to start and stop this around certain sections +of code, using `Byebug.start` and `Byebug.stop`. Alternatively, instead of +issuing an explicit `Byebug.stop` you can add a block to the `Byebug.start` and +debugging is turned on for that block. If the block of code raises an uncaught +exception that would cause the block to terminate, the `stop` will occur. See +[Byebug.start with a block](). + +When `byebug`is run, `.byebugrc` is read. + +You may want to enter byebug at several points in the program where there is a +problem you want to investigate. And since `byebug` is just a method call it's +possible to enclose it in a conditional expression, for example + +```ruby +byebug if 'bar' == foo and 20 == iter_count +``` + +### Restarting Byebug + +You can restart the program using `restart [program args]`. This is a re-exec - +all byebug state is lost. If command arguments are passed, those are used. +Otherwise program arguments from the last invocation are used. + +You won't be able to restart your program in all cases. First, the program +should have been invoked at the outset rather than having been called from +inside your program or invoked as a result of post-mortem handling. + +Also, since this relies on the OS `exec` call, this command is available only if +your OS supports `exec`. + + +## Debugging remote programs + +It is possible to set up debugging so that you can issue byebug commands from +outside the process running the Ruby code. In fact, you might even be on a +different computer than the one running the Ruby program. + +To setup remote debugging, drop the following somewhere before the point in the +program that you want to debug (In Rails, the +`config/environments/development.rb` could be a good candidate). + +```ruby + require 'byebug' + Byebug.wait_connection = true + Byebug.start_server('localhost', ) +``` + +Once this piece gets executed, you can connect to the remote debugger from your +local machine, by running: `byebug -R localhost:`. + +Next, at a place of program execution which gets run just before the code you +want to debug, add a call to `byebug` as was done without remote execution: + +```ruby + # work, work, work... + byebug + some ruby code # byebug will stop before this line is run +``` + + +## Byebug Command Reference + +### Command Syntax +Usually a command is put on a single line. There is no limit on how long it can +be. It starts with a command name, which is followed by arguments whose meaning +depends on the command name. For example, the command `step` accepts an +argument which is the number of times to step, as in `step 5`. You can also use +the `step` command with no arguments. Some commands do not allow any arguments. + +Multiple commands can be put on a line by separating each with a semicolon `;`. +You can disable the meaning of a semicolon to separate commands by escaping it +with a backslash. + +For example, if you have [autoeval]() set, which is the default, you might want +to enter the following code to compute the 5th Fibonacci number. + +```bash +(byebug) fib1=0; fib2=1; 5.times {|temp| temp=fib1; fib1=fib2; fib2 += temp } +0 +1 +SyntaxError Exception: /home/davidr/Proyectos/sample_app/trace.rb:1: syntax +error, unexpected end-of-input, expecting '}' + 5.times { |temp| temp=fib1 + ^ +nil +1 +SyntaxError Exception: /home/davidr/Proyectos/sample_app/trace.rb:1: syntax +error, unexpected tSTRING_DEND, expecting end-of-input + fib2 += temp } + ^ +nil +(byebug) fib1=0\; fib2=1\; 5.times {|temp| temp=fib1\; fib1=fib2\; fib2 += temp } +5 +(byebug) fib2 +8 +``` + +You might also consider using the [irb]() or [pry]() commands and then you +won't have to escape semicolons. + +A blank line as input (typing just ``) means to repeat the previous +command. + +Byebug uses readline, which handles line editing and retrieval of previous commands. +Up arrow, for example, moves to the previous byebug command; down arrow moves to the +next more recent command (provided you are not already at the last command). Command +history is saved in file `.byebug_hist`. A limit is put on the history size. You +can see this with the `show history size` command. See [history]() for history +parameters. + +### Command Output +In the command-line interface, when `byebug` is waiting for input it presents a +prompt of the form `(byebug)`. If the program has terminated normally the prompt will +be `(byebug:ctrl)` and in post-mortem debugging it will be +`(byebug:post-mortem)`. + +Whenever `byebug` gives an error message such as for an invalid command or an invalid +location position, it will generally preface the message with `***`. + +### Command Help + +Once inside `byebug` you can always ask it for information on its commands using the +`help` command. You can use `help` (abbreviated `h`) with no arguments to display a +short list of named classes of commands + +```bash +(byebug) help +Type "help " for help on a specific command + +Available commands: +backtrace delete enable help method ps save step where +break disable eval info next putl set trace catch +display exit irb p quit show undisplay condition down +finish kill pp skip up continue edit frame list +pry restart source var +``` + +With a command name as `help` argument, `byebug` displays short information on how to +use that command. + +```bash +(byebug) help list +l[ist] list forward +l[ist] - list backward +l[ist] = list current line +l[ist] nn-mm list given lines +* NOTE - to turn on autolist, use 'set autolist' +(byebug) +``` + +A number of commands, namely `info`, `set`, `show`, `enable` and `disable`, have many +sub-parameters or _subcommands_. When you ask for help for one of these commands, you +will get help for all of the subcommands that command offers. Sometimes you may want +help only on a subcommand and to do this just follow the command with its subcommand +name. For example, `help info breakpoints`will just give help about the `info +breakpoints` command. Furthermore it will give longer help than the summary +information that appears when you ask for help. You don't need to list the full +subcommand name, just enough of the letters to make that subcommand distinct from +others will do. For example, `help info b` is the same as `help info breakpoints`. + +Some examples follow. + +```bash +(byebug) help info +info[ subcommand] + +Generic command for showing things about the program being debugged. + +-- +List of "info" subcommands: +-- +info args -- Argument variables of current stack frame +info breakpoints -- Status of user-settable breakpoints +info catch -- Exceptions that can be caught in the current stack frame +info display -- Expressions to display when program stops +info file -- Info about a particular file read in +info files -- File names and timestamps of files read in +info line -- Line number and filename of current position in source file +info program -- Execution status of the program +``` + +```bash +(byebug) help info breakpoints +Status of user-settable breakpoints. +Without argument, list info about all breakpoints. +With an integer argument, list info on that breakpoint. +``` + +```bash +(byebug) help info b +Status of user-settable breakpoints. +Without argument, list info about all breakpoints. +With an integer argument, list info on that breakpoint. +``` + +### Control Commands: quit, restart, source + +#### Quit + +To exit `byebug`, type `quit` (abbreviated `q` and aliased `exit`). Normally if +you are in an interactive session, this command will prompt you to confirm you +really want to quit. If you don't want any questions asked, enter +`quit unconditionally` (abbreviated `q!`). + +#### Restart + +To restart the program, use the `restart|r` command. This is a re-exec - all +`byebug` state is lost. If command arguments are passed, those are used. +Otherwise program arguments from the last invocation are used. + +You won't be able to restart your program in all cases. First, the program +should have been invoked at the outset rather than having been called from +inside your program or invoked as a result of post-mortem handling. + +#### Source + +You can run `byebug` commands inside a file, using the command `source `. +The lines in a command file are executed sequentially. They are not printed as +they are executed. If there is an error, execution proceeds to the next command +in the file. For information about command files that get run automatically on +startup see [Command Files](). + + +### Display Commands: display, undisplay + +#### Display + +If you find that you want to print the value of an expression frequently (to see +how it changes), you might want to add it to the *automatic display list** so +that `byebug` evaluates it each time your program stops or after a line is +printed if line tracing is enabled. Each expression added to the list is given a +number to identify it; to remove an expression from the list, you specify that +number. The automatic display looks like this: + +```bash +(byebug) display n +1: n = 3 +``` + +This display shows item numbers, expressions and their current values. If the +expression is undefined or illegal the expression will be printed but no value +will appear. + +```bash +(byebug) display undefined_variable +2: undefined_variable = +(byebug) display 1/0 +3: 1/0 = +``` + +If you use `display` with no argument, `byebug` will display the current values +of the expressions in the list, just as it is done when your program stops. +Using `info display` has the same effect. + +#### Undisplay + +To remove an item from the list, use `undisplay` followed by the number +identifying the expression you want to remove. `undisplay` does not repeat if +you press ``after using it (otherwise you would just get the error _No +display number n_) + +You can also temporarily disable or enable display expressions, so that the will +not be printed but they won't be forgotten either, so you can toggle them again +later. To do that, use `disable display` or `enable display` followed by the +expression number. + + +### Print Commands + +One way to examine and change data in your script is with the `eval` command +(abbreviated `p`). `byebug` by default evaluates any input that is not +recognized as a command, so in most situations `eval` is not necessary and +`byebug` will work like a REPL. One case where it's necessary could be when +trying to print a variable called `n`. In this case, you have no choice because +typing just `n` will execute `byebug`'s command `next`. + +A similar command to `eval|p` is `pp` which tries to pretty print the result. + +If the value you want to print is an array, sometimes a columnized list looks +nicer. Use `putl` for that. Notice however that entries are sorted to run down +first rather than across. If the value is not an array `putl` will just call +pretty-print. + +Sometimes you may want to print the array not only columnized, but sorted as +well. The list of byebug help commands appears this way, and so does the output +of the `method` commands. Use `ps` for that. If the value is not an array `ps` +will just call pretty-print. + +```bash +(byebug) Kernel.instance_methods +[:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, +:dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, +:frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, +:private_methods, :public_methods, :instance_variables, :instance_variable_get, +:instance_variable_set, :instance_variable_defined?, :remove_instance_variable, +:instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, +:extend, :display, :method, :public_method, :define_singleton_method, +:object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug] +(byebug) p Kernel.instance_methods +[:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, +:dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, +:frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, +:private_methods, :public_methods, :instance_variables, :instance_variable_get, +:instance_variable_set, :instance_variable_defined?, :remove_instance_variable, +:instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, +:extend, :display, :method, :public_method, :define_singleton_method, +:object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug] +(byebug) pp Kernel.instance_methods +[:nil?, + :===, + :=~, + :!~, + :eql?, + :hash, + :<=>, + :class, + :singleton_class, + :clone, + :dup, + :taint, + :tainted?, + :untaint, + :untrust, + :untrusted?, + :trust, + :freeze, + :frozen?, + :to_s, + :inspect, + :methods, + :singleton_methods, + :protected_methods, + :private_methods, + :public_methods, + :instance_variables, + :instance_variable_get, + :instance_variable_set, + :instance_variable_defined?, + :remove_instance_variable, + :instance_of?, + :kind_of?, + :is_a?, + :tap, + :send, + :public_send, + :respond_to?, + :extend, + :display, + :method, + :public_method, + :define_singleton_method, + :object_id, + :to_enum, + :enum_for, + :gem, + :pretty_inspect, + :byebug] +(byebug) putl Kernel.instance_methods +nil? trust is_a? +=== freeze tap +=~ frozen? send +!~ to_s public_send +eql? inspect respond_to? +hash methods extend +<=> singleton_methods display +class protected_methods method +singleton_class private_methods public_method +clone public_methods singleton_method +dup instance_variables define_singleton_method +itself instance_variable_get object_id +taint instance_variable_set to_enum +tainted? instance_variable_defined? enum_for +untaint remove_instance_variable gem +untrust instance_of? pretty_inspect +untrusted? kind_of? +(byebug) ps Kernel.instance_methods +!~ instance_of? public_send +<=> instance_variable_defined? remove_instance_variable +=== instance_variable_get respond_to? +=~ instance_variable_set send +class instance_variables singleton_class +clone is_a? singleton_method +define_singleton_method itself singleton_methods +display kind_of? taint +dup method tainted? +enum_for methods tap +eql? nil? to_enum +extend object_id to_s +freeze pretty_inspect trust +frozen? private_methods untaint +gem protected_methods untrust +hash public_method untrusted? +``` + +Finally, if you need more advanced functionality from REPL's, you can enter +`irb` or `pry` using `irb` or `pry` commands. The bindings environment will be +set to the current state in the program. When you leave the repl and go back to +`byebug`'s command prompt we show the file, line and text position of the +program. If you issue a `list` without location information, the default +location used is the current line rather than the current position that may have +got updated via a prior `list` command. + +``` +$ byebug triangle.rb +[1, 10] in /path/to/triangle.rb + 1: # Compute the n'th triangle number, the hard way: triangle(n) == (n*(n+1))/2 +=> 2: def triangle(n) + 3: tri = 0 + 4: 0.upto(n) do |i| + 5: tri += i + 6: end + 7: tri + 8: end + 9: + 10: if __FILE__ == $0 +(byebug) irb +2.0.0-p247 :001 > (0..6).inject{|sum, i| sum +=i} + => 21 +2.0.0-p247 :002 > exit +/home/davidr/Proyectos/byebug/old_doc/triangle.rb @ 2 +def triangle(n) +(byebug) list # same line range as before going into irb +[1, 10] in /path/to/triangle.rb + 1: # Compute the n'th triangle number, the hard way: triangle(n) == (n*(n+1))/2 +=> 2: def triangle(n) + 3: tri = 0 + 4: 0.upto(n) do |i| + 5: tri += i + 6: end + 7: tri + 8: end + 9: + 10: if __FILE__ == $0 +(byebug) +``` + +### Printing variables + +Byebug can print many different information about variables. Such as +* `var const `. Show the constants of ``. This is basically +listing variables and their values in `.constant`. +* `var instance `. Show the instance variables of ``. This is +basically listing `.instance_variables`. +* `var instance`. Show instance_variables of `self`. +* `var local`. Show local variables. +* `var global`. Show global variables. +* `var all`. Show local, global and instance and class variables of `self`. +* `method instance `. Show methods of ``. Basically this is the +same as running `ps .instance_methods(false)`. +* `method `. Show methods of the class or module +``. Basically this is the same as running +`ps .methods`. + +### Examining Program Source Files: list + +`byebug` can print parts of your script's source. When your script stops, +`byebug` spontaneously lists the source code around the line where it stopped +that line. It does that when you change the current stack frame as well. +Implicitly there is a default line location. Each time a list command is run +that implicit location is updated, so that running several list commands in +succession shows a contiguous block of program text. + +If you don't need code context displayed every time, you can issue the `set +noautolist` command. Now whenever you want code listed, you can explicitly issue +the `list` command or its abbreviation `l`. Notice that when a second listing is +displayed, we continue listing from the place we last left off. When the +beginning or end of the file is reached, the line range to be shown is adjusted +so "it doesn't overflow". You can set the `noautolist` option by default by +dropping `set noautolist` in byebug's startup file `.byebugrc`. + +If you want to set how many lines to be printed by default rather than use the +initial number of lines, 10, use the `set listsize` command ([listsize()). To +see the entire program in one shot, give an explicit starting and ending line +number. You can print other portions of source files by giving explicit position +as a parameter to the list command. + +There are several ways to specify what part of the file you want to print. `list +nnn` prints lines centered around line number `nnn` in the current source file. +`l` prints more lines, following the last lines printed. `list -` prints lines +just before the lines last printed. `list nnn-mmm` prints lines between `nnn` +and `mmm` inclusive. `list =` prints lines centered around where the script is +stopped. Repeating a `list` command with `RET` discards the argument, so it is +equivalent to typing just `list`. This is more useful than listing the same +lines again. An exception is made for an argument of `-`: that argument is +preserved in repetition so that each repetition moves up in the source file. + +### Editing Source files: edit + +To edit a source file, use the `edit` command. The editor of your choice is invoked +with the current line set to the active line in the program. Alternatively, you can +give a line specification to specify what part of the file you want to edit. + +You can customize `byebug` to use any editor you want by using the `EDITOR` +environment variable. The only restriction is that your editor (say `ex`) recognizes +the following command-line syntax: +``` +ex +nnn file +``` + +The optional numeric value `+nnn` specifies the line number in the file where +you want to start editing. For example, to configure `byebug` to use the `vi` editor, +you could use these commands with the `sh` shell: + +```bash +EDITOR=/usr/bin/vi +export EDITOR +byebug ... +``` + +or in the `csh` shell, +```bash +setenv EDITOR /usr/bin/vi +byebug ... +``` + +### The stack trace + +When your script has stopped, one thing you'll probably want to know is where +it stopped and some idea of how it got there. + +Each time your script calls a method or enters a block, information about this +action is saved. This information is what we call a _stack frame_ or just a +_frame_. The set of all frames at a certain point in the program's execution is +called the _stack trace_ or just the _stack_. Each frame contains a line number +and the source-file name that the line refers to. If the frame is the beginning +of a method it also contains the method name. + +When your script is started, the stack has only one frame, that of the `main` +method. This is called the _initial frame_ or the _outermost frame_. Each time +a method is called, a new frame is added to the stack trace. Each time a method +returns, the frame for that method invocation is removed. If a method is +recursive, there can be many frames for the same method. The frame for the +method in which execution is actually occurring is called the _innermost +frame_. This is the most recently created of all the stack frames that still +exist. + +Every time the debugger stops, one entry in the stack is selected as the +current frame. Many byebug commands refer implicitly to the selected block. In +particular, whenever you ask Byebug to list lines without giving a line number +or location the value is found in the selected frame. There are special +commands to select whichever frame you're interested in, such as `up`, `down` +and `frame`. + +After switching frames, when you issue a `list` command without any position +information, the position used is the location in the frame that you just +switched between, rather than a location that got updated via a prior `list` +command. + +Byebug assigns numbers to all existing stack frames, starting with zero for the +_innermost frame_, one for the frame that called it, and so on upward. These +numbers do not really exist in your script, they are assigned by Byebug to give +you a way of designating stack frames in commands. + +### Printing the Stack: `where` command + +The command `where`, aliased to `bt` or `backtrace` prints the call stack., It +shows one line per frame, for many frames, starting with the place that you are +stopped at (frame zero), followed by its caller (frame one), and on up the +stack. Each frame is numbered and can be referred to in the `frame` command. +The position of the current frame is marked with `-->`. + +The are some special frames generated for methods that are implemented in C. +One such method is `each`. They are marked differently in the call stack to +indicate that we cannot switch to those frames. This is because they have no +source code in Ruby, so we can not debug them using Byebug. + +```bash +(byebug) where +--> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6 + #1 at line gcd.rb:19 +``` + +### Selecting a frame: `up`, `down` and `frame` commands + +* `up `: Move `n` frames up the stack, towards the outermost frame (higher +frame numbers, frames that have existed longer). `n` defaults to one. + +* `down `: Move `n` frames down the stack, towards the _innermost frame_ +(lower frame numbers, frames that were created more recently). `n` defaults to +one. + +* `frame `: Allows you to move to an arbitrary frame. `n` is the stack frame +number or 0 if no frame number is given. `frame 0` will show the current and +most recent stack frame. If a negative number is given, counting is from the +other end of the stack frame, so `frame -1` shows the least-recent, outermost +stack frame. Without an argument, `frame` prints the current stack frame. diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/LICENSE b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/LICENSE new file mode 100644 index 000000000..8987a5ead --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) David Rodríguez +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/README.md b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/README.md new file mode 100644 index 000000000..670b65fef --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/README.md @@ -0,0 +1,171 @@ +# Byebug + +[![Ver][gem]][gem_url] +[![Gpa][gpa]][gpa_url] +[![Dep][dep]][dep_url] +[![Cov][cov]][cov_url] +[![Git][tip]][tip_url] + +[gem]: https://img.shields.io/gem/v/byebug.svg +[gpa]: https://img.shields.io/codeclimate/github/deivid-rodriguez/byebug.svg +[dep]: https://img.shields.io/gemnasium/deivid-rodriguez/byebug.svg +[cov]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/byebug.svg +[tip]: https://img.shields.io/gittip/deivid-rodriguez.svg + +[gem_url]: https://rubygems.org/gems/byebug +[gpa_url]: https://codeclimate.com/github/deivid-rodriguez/byebug +[dep_url]: https://gemnasium.com/deivid-rodriguez/byebug +[cov_url]: https://codeclimate.com/github/deivid-rodriguez/byebug +[tip_url]: https://www.gittip.com/deivid-rodriguez + +_Debugging in Ruby 2_ + +Byebug is a simple to use, feature rich debugger for Ruby 2. It uses the new +TracePoint API for execution control and the new Debug Inspector API for call +stack navigation, so it doesn't depend on internal core sources. It's developed +as a C extension, so it's fast. And it has a full test suite so it's reliable. + +It allows you to see what is going on _inside_ a Ruby program while it executes +and offers many of the traditional debugging features such as: + +* Stepping: Running your program one line at a time. +* Breaking: Pausing the program at some event or specified instruction, to +examine the current state. +* Evaluating: Basic REPL functionality, although [pry][] does a better job at +that. +* Tracking: Keeping track of the different values of your variables or the +different lines executed by your program. + + +## Build Status + +Linux & OSX [![Tra][tra]][tra_url] + +Windows [![Vey][vey]][vey_url] + +[tra]: https://img.shields.io/travis/deivid-rodriguez/byebug.svg?branch=master +[vey]: https://ci.appveyor.com/api/projects/status/github/deivid-rodriguez/byebug?svg=true + +[tra_url]: https://travis-ci.org/deivid-rodriguez/byebug +[vey_url]: https://ci.appveyor.com/project/deivid-rodriguez/byebug + + +## Requirements + +* Required: MRI 2.0.0 or higher. For debugging ruby 1.9.3 or older, use +[debugger][]. + +* Recommended: + - MRI 2.0.0-p576 or higher. + - MRI 2.1.3 or higher. + - MRI 2.2.1 or higher. + + +## Install + + $ gem install byebug + + +## Usage + +Simply drop + + byebug + +wherever you want to start debugging and the execution will stop there. If you +are debugging rails, start the server and once the execution gets to your +`byebug` command you will get a debugging prompt. + + +## Byebug's commands + + Command | Aliases | Subcommands + ----------- |:------------ |:----------- + `backtrace` | `bt` `where` | + `break` | | + `catch` | | + `condition` | | + `continue` | | + `delete` | | + `disable` | | `breakpoints` `display` + `display` | | + `down` | | + `edit` | | + `enable` | | `breakpoints` `display` + `eval` | | + `finish` | | + `frame` | | + `help` | | + `history` | | + `info` | | `args` `breakpoints` `catch` `display` `file` `line` `program` + `irb` | | + `kill` | | + `list` | | + `method` | | `instance` + `next` | | + `pp` | | + `pry` | | + `ps` | | + `putl` | | + `quit` | `exit` | + `restart` | | + `save` | | + `set` | | `autoeval` `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `verbose` `width` + `show` | | `autoeval` `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `verbose` `width` + `source` | | + `step` | | + `thread` | | `current` `list` `resume` `stop` `switch` + `tracevar` | | + `undisplay` | | + `up` | | + `var` | | `all` `constant` `global` `instance` `local` + + +## Semantic Versioning + +Byebug tries to follow [semantic versioning](http://semver.org) and tries to +bump major version only when backwards incompatible changes are released. +Backwards compatibility is targeted to [pry-byebug][] and any other plugins +relying on `byebug`. + + +## Getting Started + +Read [byebug's markdown +guide](https://github.com/deivid-rodriguez/byebug/blob/master/GUIDE.md) to get +started. Proper documentation will be eventually written. + + +## Related projects + +* [pry-byebug][] adds `next`, `step`, `finish`, `continue` and `break` commands +to `pry` using `byebug`. +* [ruby-debug-passenger][] adds a rake task that restarts Passenger with Byebug +connected. +* [minitest-byebug][] starts a byebug session on minitest failures. +* [sublime_debugger][] provides a plugin for ruby debugging on Sublime Text. + + +## Contribute + +See [Getting Started with Development](CONTRIBUTING.md). + + +## Credits + +Everybody who has ever contributed to this forked and reforked piece of +software, specially: + +* @ko1, author of the awesome TracePoint API for Ruby. +* @cldwalker, [debugger][]'s mantainer. +* @denofevil, author of [debase][], the starting point of this. +* @kevjames3 for testing, bug reports and the interest in the project. +* @FooBarWidget for working and helping with remote debugging. + +[debugger]: https://github.com/cldwalker/debugger +[pry]: https://github.com/pry/pry +[debase]: https://github.com/denofevil/debase +[pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug +[ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger +[minitest-byebug]: https://github.com/kaspth/minitest-byebug +[sublime_debugger]: https://github.com/shuky19/sublime_debugger diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/bin/byebug b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/bin/byebug new file mode 100755 index 000000000..f884fd201 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/bin/byebug @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require 'byebug/runner' + +Byebug::Runner.new.run diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/.RUBYARCHDIR.-.byebug.time b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/.RUBYARCHDIR.-.byebug.time new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/Makefile b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/Makefile new file mode 100644 index 000000000..00b591c8c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/Makefile @@ -0,0 +1,260 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@:) +ECHO = $(ECHO1:0=@echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /usr/include/ruby-2.3.0 +hdrdir = $(topdir) +arch_hdrdir = /usr/include/ruby-2.3.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/usr +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(prefix) +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(DESTDIR)./.gem.20161027-1433-zgd52b +sitelibdir = $(DESTDIR)./.gem.20161027-1433-zgd52b +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(datarootdir)/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(datarootdir)/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(prefix)/include +localstatedir = $(DESTDIR)/var +sharedstatedir = $(DESTDIR)/var/lib +sysconfdir = $(DESTDIR)/etc +datadir = $(datarootdir) +datarootdir = $(prefix)/share +libexecdir = $(DESTDIR)/usr/lib/ruby +sbindir = $(exec_prefix)/sbin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC = gcc +CXX = g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = $(optflags) $(debugflags) $(warnflags) +optflags = -O3 -fno-fast-math +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fPIC -Wall -Werror $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -D_FORTIFY_SOURCE=2 $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong $(ARCH_FLAG) +ldflags = -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic +dldflags = +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 2.3.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = $(RUBY) -run -e rm -- -rf +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = + +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = /byebug +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc +ORIG_SRCS = threads.c byebug.c context.c locker.c breakpoint.c +SRCS = $(ORIG_SRCS) +OBJS = threads.o byebug.o context.o locker.o breakpoint.o +HDRS = $(srcdir)/byebug.h +TARGET = byebug +TARGET_NAME = byebug +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(rubyhdrdir)/ruby$(target_prefix) +ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix) + +TARGET_SO = $(DLLIB) +CLEANLIBS = $(TARGET).so +CLEANOBJS = *.o *.bak + +all: $(DLLIB) +static: $(STATIC_LIB) install-rb +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.byebug.time + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb install-rb-default +install-rb-default: pre-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +pre-install-rb-default: + @$(NULLCMD) +$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.byebug.time: + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $< + +$(DLLIB): $(OBJS) Makefile + $(ECHO) linking shared-object byebug/$(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +$(OBJS): $(HDRS) $(ruby_headers) diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.c b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.c new file mode 100644 index 000000000..c26557014 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.c @@ -0,0 +1,517 @@ +#include + +#ifdef _WIN32 +#include +#endif + +#if defined DOSISH +#define isdirsep(x) ((x) == '/' || (x) == '\\') +#else +#define isdirsep(x) ((x) == '/') +#endif + +static VALUE cBreakpoint; +static int breakpoint_max; + +static ID idEval; + +static VALUE +eval_expression(VALUE args) +{ + return rb_funcall2(rb_mKernel, idEval, 2, RARRAY_PTR(args)); +} + +/* + * call-seq: + * breakpoint.enabled? -> bool + * + * Returns +true+ if breakpoint is enabled, false otherwise. + */ +static VALUE +brkpt_enabled(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return breakpoint->enabled; +} + +/* + * call-seq: + * breakpoint.enabled = bool + * + * Enables or disables breakpoint. + */ +static VALUE +brkpt_set_enabled(VALUE self, VALUE bool) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return breakpoint->enabled = bool; +} + +/* + * call-seq: + * breakpoint.expr -> string + * + * Returns a conditional expression which indicates when this breakpoint should + * be activated. + */ +static VALUE +brkpt_expr(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return breakpoint->expr; +} + +/* + * call-seq: + * breakpoint.expr = string | nil + * + * Sets or unsets the conditional expression which indicates when this + * breakpoint should be activated. + */ +static VALUE +brkpt_set_expr(VALUE self, VALUE expr) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + breakpoint->expr = NIL_P(expr) ? expr : StringValue(expr); + return expr; +} + +/* + * call-seq: + * breakpoint.hit_condition -> symbol + * + * Returns the hit condition of the breakpoint: +nil+ if it is an + * unconditional breakpoint, or :greater_or_equal, :equal or :modulo otherwise + */ +static VALUE +brkpt_hit_condition(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + switch (breakpoint->hit_condition) + { + case HIT_COND_GE: + return ID2SYM(rb_intern("greater_or_equal")); + case HIT_COND_EQ: + return ID2SYM(rb_intern("equal")); + case HIT_COND_MOD: + return ID2SYM(rb_intern("modulo")); + case HIT_COND_NONE: + default: + return Qnil; + } +} + +/* + * call-seq: + * breakpoint.hit_condition = symbol + * + * Sets the hit condition of the breakpoint which must be one of the following + * values: + * + * +nil+ if it is an unconditional breakpoint, or + * :greater_or_equal(:ge), :equal(:eq), :modulo(:mod) + */ +static VALUE +brkpt_set_hit_condition(VALUE self, VALUE value) +{ + breakpoint_t *breakpoint; + ID id_value; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + id_value = rb_to_id(value); + + if (rb_intern("greater_or_equal") == id_value || rb_intern("ge") == id_value) + breakpoint->hit_condition = HIT_COND_GE; + else if (rb_intern("equal") == id_value || rb_intern("eq") == id_value) + breakpoint->hit_condition = HIT_COND_EQ; + else if (rb_intern("modulo") == id_value || rb_intern("mod") == id_value) + breakpoint->hit_condition = HIT_COND_MOD; + else + rb_raise(rb_eArgError, "Invalid condition parameter"); + return value; +} + +/* + * call-seq: + * breakpoint.hit_count -> int + * + * Returns the number of times this breakpoint has been hit. + */ +static VALUE +brkpt_hit_count(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return INT2FIX(breakpoint->hit_count); +} + +/* + * call-seq: + * breakpoint.hit_value -> int + * + * Returns the hit value of the breakpoint, namely, a value to build a + * condition on the number of hits of the breakpoint. + */ +static VALUE +brkpt_hit_value(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return INT2FIX(breakpoint->hit_value); +} + +/* + * call-seq: + * breakpoint.hit_value = int + * + * Sets the hit value of the breakpoint. This allows the user to set conditions + * on the number of hits to enable/disable the breakpoint. + */ +static VALUE +brkpt_set_hit_value(VALUE self, VALUE value) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + breakpoint->hit_value = FIX2INT(value); + return value; +} + +/* + * call-seq: + * breakpoint.id -> int + * + * Returns the id of the breakpoint. + */ +static VALUE +brkpt_id(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return INT2FIX(breakpoint->id); +} + +/* + * call-seq: + * breakpoint.pos -> string or int + * + * Returns the position of this breakpoint, either a method name or a line + * number. + */ +static VALUE +brkpt_pos(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + if (breakpoint->type == BP_METHOD_TYPE) + return rb_str_new2(rb_id2name(breakpoint->pos.mid)); + else + return INT2FIX(breakpoint->pos.line); +} + +/* + * call-seq: + * breakpoint.source -> string + * + * Returns the source file of the breakpoint. + */ +static VALUE +brkpt_source(VALUE self) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + return breakpoint->source; +} + +static void +mark_breakpoint(breakpoint_t * breakpoint) +{ + rb_gc_mark(breakpoint->source); + rb_gc_mark(breakpoint->expr); +} + +static VALUE +brkpt_create(VALUE klass) +{ + breakpoint_t *breakpoint = ALLOC(breakpoint_t); + + return Data_Wrap_Struct(klass, mark_breakpoint, xfree, breakpoint); +} + +static VALUE +brkpt_initialize(VALUE self, VALUE source, VALUE pos, VALUE expr) +{ + breakpoint_t *breakpoint; + + Data_Get_Struct(self, breakpoint_t, breakpoint); + + breakpoint->type = FIXNUM_P(pos) ? BP_POS_TYPE : BP_METHOD_TYPE; + if (breakpoint->type == BP_POS_TYPE) + breakpoint->pos.line = FIX2INT(pos); + else + breakpoint->pos.mid = SYM2ID(pos); + + breakpoint->id = ++breakpoint_max; + breakpoint->source = StringValue(source); + breakpoint->enabled = Qtrue; + breakpoint->expr = NIL_P(expr) ? expr : StringValue(expr); + breakpoint->hit_count = 0; + breakpoint->hit_value = 0; + breakpoint->hit_condition = HIT_COND_NONE; + + return Qnil; +} + +int +filename_cmp_impl(VALUE source, char *file) +{ + char *source_ptr, *file_ptr; + long s_len, f_len, min_len; + long s, f; + int dirsep_flag = 0; + + s_len = RSTRING_LEN(source); + f_len = strlen(file); + min_len = s_len < f_len ? s_len : f_len; + + source_ptr = RSTRING_PTR(source); + file_ptr = file; + + for (s = s_len - 1, f = f_len - 1; + s >= s_len - min_len && f >= f_len - min_len; s--, f--) + { + if ((source_ptr[s] == '.' || file_ptr[f] == '.') && dirsep_flag) + return 1; + if (isdirsep(source_ptr[s]) && isdirsep(file_ptr[f])) + dirsep_flag = 1; +#ifdef DOSISH_DRIVE_LETTER + else if (s == 0) + return (toupper(source_ptr[s]) == toupper(file_ptr[f])); +#endif + else if (source_ptr[s] != file_ptr[f]) + return 0; + } + return 1; +} + +int +filename_cmp(VALUE source, char *file) +{ +#ifdef _WIN32 + return filename_cmp_impl(source, file); +#else +#ifdef PATH_MAX + char path[PATH_MAX + 1]; + + path[PATH_MAX] = 0; + return filename_cmp_impl(source, realpath(file, path) != NULL ? path : file); +#else + char *path; + int result; + + path = realpath(file, NULL); + result = filename_cmp_impl(source, path == NULL ? file : path); + free(path); + return result; +#endif +#endif +} + +int +classname_cmp(VALUE name, VALUE klass) +{ + VALUE mod_name; + VALUE class_name = NIL_P(name) ? rb_str_new2("main") : name; + + if (NIL_P(klass)) + return 0; + + mod_name = rb_mod_name(klass); + return (mod_name != Qnil && rb_str_cmp(class_name, mod_name) == 0); +} + +static int +check_breakpoint_by_hit_condition(VALUE rb_breakpoint) +{ + breakpoint_t *breakpoint; + + if (NIL_P(rb_breakpoint)) + return 0; + + Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint); + breakpoint->hit_count++; + + if (Qtrue != breakpoint->enabled) + return 0; + + switch (breakpoint->hit_condition) + { + case HIT_COND_NONE: + return 1; + case HIT_COND_GE: + { + if (breakpoint->hit_count >= breakpoint->hit_value) + return 1; + break; + } + case HIT_COND_EQ: + { + if (breakpoint->hit_count == breakpoint->hit_value) + return 1; + break; + } + case HIT_COND_MOD: + { + if (breakpoint->hit_count % breakpoint->hit_value == 0) + return 1; + break; + } + } + return 0; +} + +static int +check_breakpoint_by_pos(VALUE rb_breakpoint, char *file, int line) +{ + breakpoint_t *breakpoint; + + if (NIL_P(rb_breakpoint)) + return 0; + + Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint); + + if (Qfalse == breakpoint->enabled || breakpoint->type != BP_POS_TYPE + || breakpoint->pos.line != line) + return 0; + + return filename_cmp(breakpoint->source, file); +} + +static int +check_breakpoint_by_method(VALUE rb_breakpoint, VALUE klass, ID mid, VALUE self) +{ + breakpoint_t *breakpoint; + + if (NIL_P(rb_breakpoint)) + return 0; + + Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint); + + if (Qfalse == breakpoint->enabled || breakpoint->type != BP_METHOD_TYPE + || breakpoint->pos.mid != mid) + return 0; + + if (classname_cmp(breakpoint->source, klass) + || ((rb_type(self) == T_CLASS || rb_type(self) == T_MODULE) + && classname_cmp(breakpoint->source, self))) + return 1; + + return 0; +} + +static int +check_breakpoint_by_expr(VALUE rb_breakpoint, VALUE bind) +{ + breakpoint_t *breakpoint; + VALUE args, expr_result; + + if (NIL_P(rb_breakpoint)) + return 0; + + Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint); + + if (Qfalse == breakpoint->enabled) + return 0; + + if (NIL_P(breakpoint->expr)) + return 1; + + args = rb_ary_new3(2, breakpoint->expr, bind); + expr_result = rb_protect(eval_expression, args, 0); + + return RTEST(expr_result); +} + +extern VALUE +find_breakpoint_by_pos(VALUE breakpoints, VALUE source, VALUE pos, VALUE bind) +{ + VALUE breakpoint; + char *file; + int line; + int i; + + file = RSTRING_PTR(source); + line = FIX2INT(pos); + for (i = 0; i < RARRAY_LENINT(breakpoints); i++) + { + breakpoint = rb_ary_entry(breakpoints, i); + if (check_breakpoint_by_pos(breakpoint, file, line) + && check_breakpoint_by_expr(breakpoint, bind) + && check_breakpoint_by_hit_condition(breakpoint)) + { + return breakpoint; + } + } + return Qnil; +} + +extern VALUE +find_breakpoint_by_method(VALUE breakpoints, VALUE klass, ID mid, VALUE bind, + VALUE self) +{ + VALUE breakpoint; + int i; + + for (i = 0; i < RARRAY_LENINT(breakpoints); i++) + { + breakpoint = rb_ary_entry(breakpoints, i); + if (check_breakpoint_by_method(breakpoint, klass, mid, self) + && check_breakpoint_by_expr(breakpoint, bind) + && check_breakpoint_by_hit_condition(breakpoint)) + { + return breakpoint; + } + } + return Qnil; +} + +void +Init_breakpoint(VALUE mByebug) +{ + breakpoint_max = 0; + + cBreakpoint = rb_define_class_under(mByebug, "Breakpoint", rb_cObject); + + rb_define_alloc_func(cBreakpoint, brkpt_create); + rb_define_method(cBreakpoint, "initialize", brkpt_initialize, 3); + + rb_define_method(cBreakpoint, "enabled?", brkpt_enabled, 0); + rb_define_method(cBreakpoint, "enabled=", brkpt_set_enabled, 1); + rb_define_method(cBreakpoint, "expr", brkpt_expr, 0); + rb_define_method(cBreakpoint, "expr=", brkpt_set_expr, 1); + rb_define_method(cBreakpoint, "hit_count", brkpt_hit_count, 0); + rb_define_method(cBreakpoint, "hit_condition", brkpt_hit_condition, 0); + rb_define_method(cBreakpoint, "hit_condition=", brkpt_set_hit_condition, 1); + rb_define_method(cBreakpoint, "hit_value", brkpt_hit_value, 0); + rb_define_method(cBreakpoint, "hit_value=", brkpt_set_hit_value, 1); + rb_define_method(cBreakpoint, "id", brkpt_id, 0); + rb_define_method(cBreakpoint, "pos", brkpt_pos, 0); + rb_define_method(cBreakpoint, "source", brkpt_source, 0); + + idEval = rb_intern("eval"); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.o b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.o new file mode 100644 index 000000000..4c2ecf7b7 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/breakpoint.o differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.c b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.c new file mode 100644 index 000000000..6714d2a56 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.c @@ -0,0 +1,806 @@ +#include + +static VALUE mByebug; /* Ruby Byebug Module object */ + +static VALUE tracing = Qfalse; +static VALUE post_mortem = Qfalse; +static VALUE verbose = Qfalse; + +static VALUE catchpoints = Qnil; +static VALUE breakpoints = Qnil; +static VALUE tracepoints = Qnil; + +static VALUE raised_exception = Qnil; + +static ID idPuts; + +/* Hash table with active threads and their associated contexts */ +VALUE threads = Qnil; + +/* + * call-seq: + * Byebug.breakpoints -> array + * + * Returns an array of breakpoints. + */ +static VALUE +Breakpoints(VALUE self) +{ + UNUSED(self); + + if (NIL_P(breakpoints)) + breakpoints = rb_ary_new(); + + return breakpoints; +} + +/* + * call-seq: + * Byebug.catchpoints -> array + * + * Returns an array of catchpoints. + */ +static VALUE +Catchpoints(VALUE self) +{ + UNUSED(self); + + return catchpoints; +} + +/* + * call-seq: + * Byebug.raised_exception -> exception + * + * Returns raised exception when in post_mortem mode. + */ +static VALUE +Raised_exception(VALUE self) +{ + UNUSED(self); + + return raised_exception; +} + +#define IS_STARTED (catchpoints != Qnil) +static void +check_started() +{ + if (!IS_STARTED) + { + rb_raise(rb_eRuntimeError, "Byebug is not started yet."); + } +} + +static void +trace_print(rb_trace_arg_t * trace_arg, debug_context_t * dc, + const char *file_filter, const char *debug_msg) +{ + char *fullpath = NULL; + const char *basename; + int filtered = 0; + const char *event = rb_id2name(SYM2ID(rb_tracearg_event(trace_arg))); + + VALUE rb_path = rb_tracearg_path(trace_arg); + const char *path = NIL_P(rb_path) ? "" : RSTRING_PTR(rb_path); + + int line = NUM2INT(rb_tracearg_lineno(trace_arg)); + + VALUE rb_mid = rb_tracearg_method_id(trace_arg); + const char *mid = NIL_P(rb_mid) ? "(top level)" : rb_id2name(SYM2ID(rb_mid)); + + VALUE rb_cl = rb_tracearg_defined_class(trace_arg); + VALUE rb_cl_name = NIL_P(rb_cl) ? rb_cl : rb_mod_name(rb_cl); + const char *defined_class = NIL_P(rb_cl_name) ? "" : RSTRING_PTR(rb_cl_name); + + if (!trace_arg) + return; + + if (file_filter) + { +#ifndef _WIN32 + fullpath = realpath(path, NULL); +#endif + basename = fullpath ? strrchr(fullpath, '/') : path; + + if (!basename || strncmp(basename + 1, file_filter, strlen(file_filter))) + filtered = 1; + +#ifndef _WIN32 + free(fullpath); +#endif + } + + if (!filtered) + { + if (debug_msg) + rb_funcall(mByebug, idPuts, 1, + rb_sprintf("[#%d] %s\n", dc->thnum, debug_msg)); + else + rb_funcall(mByebug, idPuts, 1, + rb_sprintf("%*s [#%d] %s@%s:%d %s#%s\n", dc->calced_stack_size, + "", dc->thnum, event, path, line, defined_class, + mid)); + } +} + +static void +cleanup(debug_context_t * dc) +{ + dc->stop_reason = CTX_STOP_NONE; + + release_lock(); +} + +#define EVENT_TEARDOWN cleanup(dc); + +#define EVENT_SETUP \ + debug_context_t *dc; \ + VALUE context; \ + rb_trace_arg_t *trace_arg; \ + \ + UNUSED(data); \ + \ + if (!is_living_thread(rb_thread_current())) \ + return; \ + \ + thread_context_lookup(rb_thread_current(), &context); \ + Data_Get_Struct(context, debug_context_t, dc); \ + \ + if (CTX_FL_TEST(dc, CTX_FL_IGNORE)) \ + return; \ + \ + acquire_lock(dc); \ + \ + trace_arg = rb_tracearg_from_tracepoint(trace_point); \ + if (verbose == Qtrue) \ + trace_print(trace_arg, dc, 0, 0); \ + + +/* Functions that return control to byebug after the different events */ + +static VALUE +call_at(VALUE context_obj, debug_context_t * dc, ID mid, int argc, VALUE a0, + VALUE a1) +{ + struct call_with_inspection_data cwi; + VALUE argv[2]; + + argv[0] = a0; + argv[1] = a1; + + cwi.dc = dc; + cwi.context_obj = context_obj; + cwi.id = mid; + cwi.argc = argc; + cwi.argv = &argv[0]; + + return call_with_debug_inspector(&cwi); +} + +static VALUE +call_at_line(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line) +{ + return call_at(context_obj, dc, rb_intern("at_line"), 2, file, line); +} + +static VALUE +call_at_tracing(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line) +{ + return call_at(context_obj, dc, rb_intern("at_tracing"), 2, file, line); +} + +static VALUE +call_at_breakpoint(VALUE context_obj, debug_context_t * dc, VALUE breakpoint) +{ + dc->stop_reason = CTX_STOP_BREAKPOINT; + return call_at(context_obj, dc, rb_intern("at_breakpoint"), 1, breakpoint, 0); +} + +static VALUE +call_at_catchpoint(VALUE context_obj, debug_context_t * dc, VALUE exp) +{ + dc->stop_reason = CTX_STOP_CATCHPOINT; + return call_at(context_obj, dc, rb_intern("at_catchpoint"), 1, exp, 0); +} + +static VALUE +call_at_return(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line) +{ + dc->stop_reason = CTX_STOP_BREAKPOINT; + return call_at(context_obj, dc, rb_intern("at_return"), 2, file, line); +} + +static void +call_at_line_check(VALUE context_obj, debug_context_t * dc, VALUE breakpoint, + VALUE file, VALUE line) +{ + dc->stop_reason = CTX_STOP_STEP; + + if (breakpoint != Qnil) + call_at_breakpoint(context_obj, dc, breakpoint); + + reset_stepping_stop_points(dc); + call_at_line(context_obj, dc, file, line); +} + + +/* TracePoint API event handlers */ + +static void +line_event(VALUE trace_point, void *data) +{ + VALUE brkpnt, file, line, binding; + + EVENT_SETUP; + + file = rb_tracearg_path(trace_arg); + line = rb_tracearg_lineno(trace_arg); + binding = rb_tracearg_binding(trace_arg); + + if (RTEST(tracing)) + call_at_tracing(context, dc, file, line); + + if (!CTX_FL_TEST(dc, CTX_FL_IGNORE_STEPS)) + dc->steps = dc->steps <= 0 ? -1 : dc->steps - 1; + + if (dc->calced_stack_size <= dc->dest_frame) + { + dc->dest_frame = dc->calced_stack_size; + CTX_FL_UNSET(dc, CTX_FL_IGNORE_STEPS); + + dc->lines = dc->lines <= 0 ? -1 : dc->lines - 1; + } + + if (dc->steps == 0 || dc->lines == 0) + call_at_line_check(context, dc, Qnil, file, line); + + brkpnt = Qnil; + + if (!NIL_P(breakpoints)) + brkpnt = find_breakpoint_by_pos(breakpoints, file, line, binding); + + if (!NIL_P(brkpnt)) + call_at_line_check(context, dc, brkpnt, file, line); + + EVENT_TEARDOWN; +} + +static void +call_event(VALUE trace_point, void *data) +{ + VALUE brkpnt, klass, msym, mid, binding, self, file, line; + + EVENT_SETUP; + + if (dc->calced_stack_size <= dc->dest_frame) + CTX_FL_UNSET(dc, CTX_FL_IGNORE_STEPS); + + dc->calced_stack_size++; + + dc->steps_out = dc->steps_out <= 0 ? -1 : dc->steps_out + 1; + + /* nil method_id means we are at top level so there can't be a method + * breakpoint here. Just leave then. */ + msym = rb_tracearg_method_id(trace_arg); + if (NIL_P(msym)) + { + EVENT_TEARDOWN; + return; + } + + mid = SYM2ID(msym); + klass = rb_tracearg_defined_class(trace_arg); + binding = rb_tracearg_binding(trace_arg); + self = rb_tracearg_self(trace_arg); + file = rb_tracearg_path(trace_arg); + line = rb_tracearg_lineno(trace_arg); + + brkpnt = Qnil; + + if (!NIL_P(breakpoints)) + brkpnt = find_breakpoint_by_method(breakpoints, klass, mid, binding, self); + + if (!NIL_P(brkpnt)) + { + call_at_breakpoint(context, dc, brkpnt); + call_at_line(context, dc, file, line); + } + + EVENT_TEARDOWN; +} + +static void +return_event(VALUE trace_point, void *data) +{ + EVENT_SETUP; + + dc->calced_stack_size--; + + if (dc->steps_out == 1) + dc->steps = 1; + else if ((dc->steps_out == 0) && (CTX_FL_TEST(dc, CTX_FL_STOP_ON_RET))) + { + VALUE file, line; + + reset_stepping_stop_points(dc); + file = rb_tracearg_path(trace_arg); + line = rb_tracearg_lineno(trace_arg); + call_at_return(context, dc, file, line); + } + + dc->steps_out = dc->steps_out <= 0 ? -1 : dc->steps_out - 1; + + EVENT_TEARDOWN; +} + +static void +raw_call_event(VALUE trace_point, void *data) +{ + EVENT_SETUP; + + dc->calced_stack_size++; + + EVENT_TEARDOWN; +} + +static void +raw_return_event(VALUE trace_point, void *data) +{ + EVENT_SETUP; + + dc->calced_stack_size--; + + EVENT_TEARDOWN; +} + +static void +raise_event(VALUE trace_point, void *data) +{ + VALUE expn_class, ancestors; + VALUE path, lineno, binding, post_mortem_context; + int i; + debug_context_t *new_dc; + + EVENT_SETUP; + + path = rb_tracearg_path(trace_arg); + lineno = rb_tracearg_lineno(trace_arg); + binding = rb_tracearg_binding(trace_arg); + raised_exception = rb_tracearg_raised_exception(trace_arg); + + if (post_mortem == Qtrue) + { + post_mortem_context = context_dup(dc); + rb_ivar_set(raised_exception, rb_intern("@__bb_file"), path); + rb_ivar_set(raised_exception, rb_intern("@__bb_line"), lineno); + rb_ivar_set(raised_exception, rb_intern("@__bb_binding"), binding); + rb_ivar_set(raised_exception, rb_intern("@__bb_context"), + post_mortem_context); + + Data_Get_Struct(post_mortem_context, debug_context_t, new_dc); + rb_debug_inspector_open(context_backtrace_set, (void *)new_dc); + } + + if (catchpoints == Qnil || dc->calced_stack_size == 0 + || RHASH_TBL(catchpoints)->num_entries == 0) + { + EVENT_TEARDOWN; + return; + } + + expn_class = rb_obj_class(raised_exception); + ancestors = rb_mod_ancestors(expn_class); + for (i = 0; i < RARRAY_LENINT(ancestors); i++) + { + VALUE ancestor_class, module_name, hit_count; + + ancestor_class = rb_ary_entry(ancestors, i); + module_name = rb_mod_name(ancestor_class); + hit_count = rb_hash_aref(catchpoints, module_name); + + /* increment exception */ + if (hit_count != Qnil) + { + rb_hash_aset(catchpoints, module_name, INT2FIX(FIX2INT(hit_count) + 1)); + call_at_catchpoint(context, dc, raised_exception); + call_at_line(context, dc, path, lineno); + break; + } + } + + EVENT_TEARDOWN; +} + + +/* Setup TracePoint functionality */ + +static void +register_tracepoints(VALUE self) +{ + int i; + VALUE traces = tracepoints; + + UNUSED(self); + + if (NIL_P(traces)) + { + int line_msk = RUBY_EVENT_LINE; + int call_msk = RUBY_EVENT_CALL; + int ret_msk = RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END; + int raw_call_msk = RUBY_EVENT_C_CALL | RUBY_EVENT_B_CALL | RUBY_EVENT_CLASS; + int raw_ret_msk = RUBY_EVENT_C_RETURN; + int raise_msk = RUBY_EVENT_RAISE; + + VALUE tpLine = rb_tracepoint_new(Qnil, line_msk, line_event, 0); + VALUE tpCall = rb_tracepoint_new(Qnil, call_msk, call_event, 0); + VALUE tpReturn = rb_tracepoint_new(Qnil, ret_msk, return_event, 0); + VALUE tpCCall = rb_tracepoint_new(Qnil, raw_call_msk, raw_call_event, 0); + VALUE tpCReturn = rb_tracepoint_new(Qnil, raw_ret_msk, raw_return_event, 0); + VALUE tpRaise = rb_tracepoint_new(Qnil, raise_msk, raise_event, 0); + + traces = rb_ary_new(); + rb_ary_push(traces, tpLine); + rb_ary_push(traces, tpCall); + rb_ary_push(traces, tpReturn); + rb_ary_push(traces, tpCCall); + rb_ary_push(traces, tpCReturn); + rb_ary_push(traces, tpRaise); + + tracepoints = traces; + } + + for (i = 0; i < RARRAY_LENINT(traces); i++) + rb_tracepoint_enable(rb_ary_entry(traces, i)); +} + +static void +clear_tracepoints(VALUE self) +{ + int i; + + UNUSED(self); + + for (i = RARRAY_LENINT(tracepoints) - 1; i >= 0; i--) + rb_tracepoint_disable(rb_ary_entry(tracepoints, i)); +} + + +/* Byebug's Public API */ + +/* + * call-seq: + * Byebug.contexts -> array + * + * Returns an array of all contexts. + */ +static VALUE +Contexts(VALUE self) +{ + volatile VALUE list; + volatile VALUE new_list; + VALUE context; + threads_table_t *t_tbl; + debug_context_t *dc; + int i; + + UNUSED(self); + + check_started(); + + new_list = rb_ary_new(); + list = rb_funcall(rb_cThread, rb_intern("list"), 0); + + for (i = 0; i < RARRAY_LENINT(list); i++) + { + VALUE thread = rb_ary_entry(list, i); + + thread_context_lookup(thread, &context); + rb_ary_push(new_list, context); + } + + Data_Get_Struct(threads, threads_table_t, t_tbl); + st_clear(t_tbl->tbl); + + for (i = 0; i < RARRAY_LENINT(new_list); i++) + { + context = rb_ary_entry(new_list, i); + Data_Get_Struct(context, debug_context_t, dc); + st_insert(t_tbl->tbl, dc->thread, context); + } + + return new_list; +} + +/* + * call-seq: + * Byebug.thread_context(thread) -> context + * + * Returns context of the thread passed as an argument. + */ +static VALUE +Thread_context(VALUE self, VALUE thread) +{ + VALUE context; + + UNUSED(self); + + check_started(); + + thread_context_lookup(thread, &context); + + return context; +} + +/* + * call-seq: + * Byebug.current_context -> context + * + * Returns the current context. + * Note: Byebug.current_context.thread == Thread.current + */ +static VALUE +Current_context(VALUE self) +{ + VALUE context; + + UNUSED(self); + + check_started(); + + thread_context_lookup(rb_thread_current(), &context); + + return context; +} + +/* + * call-seq: + * Byebug.started? -> bool + * + * Returns +true+ byebug is started. + */ +static VALUE +Started(VALUE self) +{ + UNUSED(self); + + return IS_STARTED; +} + +/* + * call-seq: + * Byebug.stop -> bool + * + * This method disables byebug. It returns +true+ if byebug was already + * disabled, otherwise it returns +false+. + */ +static VALUE +Stop(VALUE self) +{ + UNUSED(self); + + if (IS_STARTED) + { + clear_tracepoints(self); + + breakpoints = Qnil; + catchpoints = Qnil; + threads = Qnil; + + return Qfalse; + } + + return Qtrue; +} + +/* + * call-seq: + * Byebug.start -> bool + * + * The return value is the value of !Byebug.started? before issuing the + * +start+; That is, +true+ is returned, unless byebug was previously started. + */ +static VALUE +Start(VALUE self) +{ + if (IS_STARTED) + return Qfalse; + + catchpoints = rb_hash_new(); + + threads = create_threads_table(); + + register_tracepoints(self); + + return Qtrue; +} + +/* + * call-seq: + * Byebug.debug_load(file, stop = false) -> nil + * + * Same as Kernel#load but resets current context's frames. + * +stop+ parameter forces byebug to stop at the first line of code in +file+ + */ +static VALUE +Debug_load(int argc, VALUE * argv, VALUE self) +{ + VALUE file, stop, context; + debug_context_t *dc; + VALUE status = Qnil; + int state = 0; + + UNUSED(self); + + if (rb_scan_args(argc, argv, "11", &file, &stop) == 1) + stop = Qfalse; + + Start(self); + + context = Current_context(self); + Data_Get_Struct(context, debug_context_t, dc); + + dc->calced_stack_size = 1; + + if (RTEST(stop)) + dc->steps = 1; + + rb_load_protect(file, 0, &state); + if (0 != state) + { + status = rb_errinfo(); + reset_stepping_stop_points(dc); + } + + return status; +} + +/* + * call-seq: + * Byebug.verbose? -> bool + * + * Returns +true+ if verbose output of TracePoint API events is enabled. + */ +static VALUE +Verbose(VALUE self) +{ + UNUSED(self); + + return verbose; +} + +/* + * call-seq: + * Byebug.verbose = bool + * + * Enable verbose output of every TracePoint API events, useful for debugging + * byebug. + */ +static VALUE +Set_verbose(VALUE self, VALUE value) +{ + UNUSED(self); + + verbose = RTEST(value) ? Qtrue : Qfalse; + return value; +} + +/* + * call-seq: + * Byebug.tracing? -> bool + * + * Returns +true+ if global tracing is enabled. + */ +static VALUE +Tracing(VALUE self) +{ + UNUSED(self); + + return tracing; +} + +/* + * call-seq: + * Byebug.tracing = bool + * + * Sets the global tracing flag. + */ +static VALUE +Set_tracing(VALUE self, VALUE value) +{ + UNUSED(self); + + tracing = RTEST(value) ? Qtrue : Qfalse; + return value; +} + +/* + * call-seq: + * Byebug.post_mortem? -> bool + * + * Returns +true+ if post-mortem debugging is enabled. + */ +static VALUE +Post_mortem(VALUE self) +{ + UNUSED(self); + + return post_mortem; +} + +/* + * call-seq: + * Byebug.post_mortem = bool + * + * Sets post-moterm flag. + */ +static VALUE +Set_post_mortem(VALUE self, VALUE value) +{ + UNUSED(self); + + post_mortem = RTEST(value) ? Qtrue : Qfalse; + return value; +} + +/* + * call-seq: + * Byebug.add_catchpoint(exception) -> exception + * + * Adds a new exception to the catchpoints array. + */ +static VALUE +Add_catchpoint(VALUE self, VALUE value) +{ + UNUSED(self); + + if (TYPE(value) != T_STRING) + rb_raise(rb_eTypeError, "value of a catchpoint must be String"); + + rb_hash_aset(catchpoints, rb_str_dup(value), INT2FIX(0)); + return value; +} + +/* + * Document-class: Byebug + * + * == Summary + * + * This is a singleton class allows controlling byebug. Use it to start/stop + * byebug, set/remove breakpoints, etc. + */ +void +Init_byebug() +{ + mByebug = rb_define_module("Byebug"); + + rb_define_module_function(mByebug, "add_catchpoint", Add_catchpoint, 1); + rb_define_module_function(mByebug, "breakpoints", Breakpoints, 0); + rb_define_module_function(mByebug, "catchpoints", Catchpoints, 0); + rb_define_module_function(mByebug, "contexts", Contexts, 0); + rb_define_module_function(mByebug, "current_context", Current_context, 0); + rb_define_module_function(mByebug, "debug_load", Debug_load, -1); + rb_define_module_function(mByebug, "post_mortem?", Post_mortem, 0); + rb_define_module_function(mByebug, "post_mortem=", Set_post_mortem, 1); + rb_define_module_function(mByebug, "raised_exception", Raised_exception, 0); + rb_define_module_function(mByebug, "start", Start, 0); + rb_define_module_function(mByebug, "started?", Started, 0); + rb_define_module_function(mByebug, "stop", Stop, 0); + rb_define_module_function(mByebug, "thread_context", Thread_context, 1); + rb_define_module_function(mByebug, "tracing?", Tracing, 0); + rb_define_module_function(mByebug, "tracing=", Set_tracing, 1); + rb_define_module_function(mByebug, "verbose?", Verbose, 0); + rb_define_module_function(mByebug, "verbose=", Set_verbose, 1); + + Init_threads_table(mByebug); + Init_context(mByebug); + Init_breakpoint(mByebug); + + rb_global_variable(&breakpoints); + rb_global_variable(&catchpoints); + rb_global_variable(&tracepoints); + rb_global_variable(&raised_exception); + rb_global_variable(&threads); + + idPuts = rb_intern("puts"); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.h b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.h new file mode 100644 index 000000000..9a779c353 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.h @@ -0,0 +1,126 @@ +#ifndef BYEBUG +#define BYEBUG + +#include +#include + +/* To prevent unused parameter warnings */ +#define UNUSED(x) (void)(x) + +/* flags */ +#define CTX_FL_DEAD (1<<1) /* this context belonged to a dead thread */ +#define CTX_FL_IGNORE (1<<2) /* this context belongs to ignored thread */ +#define CTX_FL_SUSPEND (1<<3) /* thread currently suspended */ +#define CTX_FL_TRACING (1<<4) /* call at_tracing method */ +#define CTX_FL_WAS_RUNNING (1<<5) /* thread was previously running */ +#define CTX_FL_STOP_ON_RET (1<<6) /* can stop on method 'end' */ +#define CTX_FL_IGNORE_STEPS (1<<7) /* doesn't countdown steps to break */ + +/* macro functions */ +#define CTX_FL_TEST(c,f) ((c)->flags & (f)) +#define CTX_FL_SET(c,f) do { (c)->flags |= (f); } while (0) +#define CTX_FL_UNSET(c,f) do { (c)->flags &= ~(f); } while (0) + +/* types */ +typedef enum { + CTX_STOP_NONE, + CTX_STOP_STEP, + CTX_STOP_BREAKPOINT, + CTX_STOP_CATCHPOINT +} ctx_stop_reason; + +typedef struct { + int calced_stack_size; + int flags; + ctx_stop_reason stop_reason; + + VALUE thread; + int thnum; + + int dest_frame; /* next stop's frame if stopped by next */ + int lines; /* # of lines in dest_frame before stopping */ + int steps; /* # of steps before stopping */ + int steps_out; /* # of returns before stopping */ + + VALUE backtrace; /* [[loc, self, klass, binding], ...] */ +} debug_context_t; + +enum frame_component { LOCATION, SELF, CLASS, BINDING }; + +struct call_with_inspection_data { + debug_context_t *dc; + VALUE context_obj; + ID id; + int argc; + VALUE *argv; +}; + +typedef struct { + st_table *tbl; +} threads_table_t; + +enum bp_type { BP_POS_TYPE, BP_METHOD_TYPE }; + +enum hit_condition { HIT_COND_NONE, HIT_COND_GE, HIT_COND_EQ, HIT_COND_MOD }; + +typedef struct { + int id; + enum bp_type type; + VALUE source; + union + { + int line; + ID mid; + } pos; + VALUE expr; + VALUE enabled; + int hit_count; + int hit_value; + enum hit_condition hit_condition; +} breakpoint_t; + +/* functions from locker.c */ +extern int is_in_locked(VALUE thread_id); +extern void add_to_locked(VALUE thread); +extern VALUE pop_from_locked(); +extern void remove_from_locked(VALUE thread); + +/* functions from threads.c */ +extern void Init_threads_table(VALUE mByebug); +extern VALUE create_threads_table(void); +extern void thread_context_lookup(VALUE thread, VALUE *context); +extern int is_living_thread(VALUE thread); +extern void acquire_lock(debug_context_t *dc); +extern void release_lock(void); + +/* global variables */ +extern VALUE threads; +extern VALUE next_thread; + +/* functions from context.c */ +extern void Init_context(VALUE mByebug); +extern VALUE context_create(VALUE thread); +extern VALUE context_dup(debug_context_t *context); +extern void reset_stepping_stop_points(debug_context_t *context); +extern VALUE call_with_debug_inspector(struct call_with_inspection_data *data); +extern VALUE context_backtrace_set(const rb_debug_inspector_t *inspector, + void *data); + +/* functions from breakpoint.c */ +extern void Init_breakpoint(VALUE mByebug); +extern VALUE catchpoint_hit_count(VALUE catchpoints, + VALUE exception, + VALUE *exception_name); + +extern VALUE find_breakpoint_by_pos(VALUE breakpoints, + VALUE source, + VALUE pos, + VALUE bind); + +extern VALUE find_breakpoint_by_method(VALUE breakpoints, + VALUE klass, + VALUE mid, + VALUE bind, + VALUE self); + +#endif diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.o b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.o new file mode 100644 index 000000000..25aca322b Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.o differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.so b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.so new file mode 100755 index 000000000..a44061684 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/byebug.so differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.c b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.c new file mode 100644 index 000000000..e3fd9a050 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.c @@ -0,0 +1,674 @@ +#include + +static VALUE cContext; +static VALUE cDebugThread; +static int thnum_max = 0; + +/* "Step", "Next" and "Finish" do their work by saving information about where + * to stop next. reset_stepping_stop_points removes/resets this information. */ +extern void +reset_stepping_stop_points(debug_context_t * context) +{ + context->dest_frame = -1; + context->lines = -1; + context->steps = -1; + context->steps_out = -1; +} + +/* + * call-seq: + * context.dead? -> bool + * + * Returns +true+ if context doesn't represent a live context and is created + * during post-mortem exception handling. + */ +static inline VALUE +Context_dead(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + return CTX_FL_TEST(context, CTX_FL_DEAD) ? Qtrue : Qfalse; +} + +static void +context_mark(void *data) +{ + debug_context_t *context = (debug_context_t *) data; + + rb_gc_mark(context->backtrace); +} + +static VALUE +dc_backtrace(const debug_context_t * context) +{ + return context->backtrace; +} + +static int +dc_stack_size(debug_context_t * context) +{ + + if (NIL_P(dc_backtrace(context))) + return 0; + + return RARRAY_LENINT(dc_backtrace(context)); +} + +extern VALUE +context_create(VALUE thread) +{ + debug_context_t *context = ALLOC(debug_context_t); + + context->flags = 0; + context->thnum = ++thnum_max; + context->thread = thread; + reset_stepping_stop_points(context); + context->stop_reason = CTX_STOP_NONE; + + rb_debug_inspector_open(context_backtrace_set, (void *)context); + context->calced_stack_size = dc_stack_size(context) + 1; + + if (rb_obj_class(thread) == cDebugThread) + CTX_FL_SET(context, CTX_FL_IGNORE); + + return Data_Wrap_Struct(cContext, context_mark, 0, context); +} + +extern VALUE +context_dup(debug_context_t * context) +{ + debug_context_t *new_context = ALLOC(debug_context_t); + + memcpy(new_context, context, sizeof(debug_context_t)); + reset_stepping_stop_points(new_context); + new_context->backtrace = context->backtrace; + CTX_FL_SET(new_context, CTX_FL_DEAD); + + return Data_Wrap_Struct(cContext, context_mark, 0, new_context); +} + + +static VALUE +dc_frame_get(const debug_context_t * context, int frame_index, + enum frame_component type) +{ + VALUE frame; + + if (NIL_P(dc_backtrace(context))) + rb_raise(rb_eRuntimeError, "Backtrace information is not available"); + + if (frame_index >= RARRAY_LENINT(dc_backtrace(context))) + rb_raise(rb_eRuntimeError, "That frame doesn't exist!"); + + frame = rb_ary_entry(dc_backtrace(context), frame_index); + return rb_ary_entry(frame, type); +} + +static VALUE +dc_frame_location(const debug_context_t * context, int frame_index) +{ + return dc_frame_get(context, frame_index, LOCATION); +} + +static VALUE +dc_frame_self(const debug_context_t * context, int frame_index) +{ + return dc_frame_get(context, frame_index, SELF); +} + +static VALUE +dc_frame_class(const debug_context_t * context, int frame_index) +{ + return dc_frame_get(context, frame_index, CLASS); +} + +static VALUE +dc_frame_binding(const debug_context_t * context, int frame_index) +{ + return dc_frame_get(context, frame_index, BINDING); +} + +static VALUE +load_backtrace(const rb_debug_inspector_t * inspector) +{ + VALUE backtrace = rb_ary_new(); + VALUE locs = rb_debug_inspector_backtrace_locations(inspector); + int i; + + for (i = 0; i < RARRAY_LENINT(locs); i++) + { + VALUE frame = rb_ary_new(); + + rb_ary_push(frame, rb_ary_entry(locs, i)); + rb_ary_push(frame, rb_debug_inspector_frame_self_get(inspector, i)); + rb_ary_push(frame, rb_debug_inspector_frame_class_get(inspector, i)); + rb_ary_push(frame, rb_debug_inspector_frame_binding_get(inspector, i)); + + rb_ary_push(backtrace, frame); + } + + return backtrace; +} + +extern VALUE +context_backtrace_set(const rb_debug_inspector_t * inspector, void *data) +{ + debug_context_t *dc = (debug_context_t *) data; + + dc->backtrace = load_backtrace(inspector); + + return Qnil; +} + +static VALUE +open_debug_inspector_i(const rb_debug_inspector_t * inspector, void *data) +{ + struct call_with_inspection_data *cwi = + (struct call_with_inspection_data *)data; + + cwi->dc->backtrace = load_backtrace(inspector); + + return rb_funcall2(cwi->context_obj, cwi->id, cwi->argc, cwi->argv); +} + +static VALUE +open_debug_inspector(struct call_with_inspection_data *cwi) +{ + return rb_debug_inspector_open(open_debug_inspector_i, cwi); +} + +static VALUE +close_debug_inspector(struct call_with_inspection_data *cwi) +{ + cwi->dc->backtrace = Qnil; + return Qnil; +} + +extern VALUE +call_with_debug_inspector(struct call_with_inspection_data *data) +{ + return rb_ensure(open_debug_inspector, (VALUE) data, close_debug_inspector, + (VALUE) data); +} + +#define FRAME_SETUP \ + debug_context_t *context; \ + VALUE frame_no; \ + int frame_n; \ + Data_Get_Struct(self, debug_context_t, context); \ + if (!rb_scan_args(argc, argv, "01", &frame_no)) \ + frame_n = 0; \ + else \ + frame_n = FIX2INT(frame_no); + +/* + * call-seq: + * context.frame_binding(frame_position = 0) -> binding + * + * Returns frame's binding. + */ +static VALUE +Context_frame_binding(int argc, VALUE * argv, VALUE self) +{ + FRAME_SETUP; + + return dc_frame_binding(context, frame_n); +} + +/* + * call-seq: + * context.frame_class(frame_position = 0) -> binding + * + * Returns frame's defined class. + */ +static VALUE +Context_frame_class(int argc, VALUE * argv, VALUE self) +{ + FRAME_SETUP; + + return dc_frame_class(context, frame_n); +} + +/* + * call-seq: + * context.frame_file(frame_position = 0) -> string + * + * Returns the name of the file in the frame. + */ +static VALUE +Context_frame_file(int argc, VALUE * argv, VALUE self) +{ + VALUE loc, absolute_path; + + FRAME_SETUP; + + loc = dc_frame_location(context, frame_n); + + absolute_path = rb_funcall(loc, rb_intern("absolute_path"), 0); + + if (!NIL_P(absolute_path)) + return absolute_path; + + return rb_funcall(loc, rb_intern("path"), 0); +} + +/* + * call-seq: + * context.frame_line(frame_position = 0) -> int + * + * Returns the line number in the file. + */ +static VALUE +Context_frame_line(int argc, VALUE * argv, VALUE self) +{ + VALUE loc; + + FRAME_SETUP; + + loc = dc_frame_location(context, frame_n); + + return rb_funcall(loc, rb_intern("lineno"), 0); +} + +/* + * call-seq: + * context.frame_method(frame_position = 0) -> sym + * + * Returns the sym of the called method. + */ +static VALUE +Context_frame_method(int argc, VALUE * argv, VALUE self) +{ + VALUE loc; + + FRAME_SETUP; + + loc = dc_frame_location(context, frame_n); + + return rb_str_intern(rb_funcall(loc, rb_intern("label"), 0)); +} + +/* + * call-seq: + * context.frame_self(frame_postion = 0) -> obj + * + * Returns self object of the frame. + */ +static VALUE +Context_frame_self(int argc, VALUE * argv, VALUE self) +{ + FRAME_SETUP; + + return dc_frame_self(context, frame_n); +} + +/* + * call-seq: + * context.ignored? -> bool + * + * Returns the ignore flag for the context, which marks whether the associated + * thread is ignored while debugging. + */ +static inline VALUE +Context_ignored(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + return CTX_FL_TEST(context, CTX_FL_IGNORE) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * context.resume -> nil + * + * Resumes thread from the suspended mode. + */ +static VALUE +Context_resume(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + if (!CTX_FL_TEST(context, CTX_FL_SUSPEND)) + return Qnil; + + CTX_FL_UNSET(context, CTX_FL_SUSPEND); + + if (CTX_FL_TEST(context, CTX_FL_WAS_RUNNING)) + rb_thread_wakeup(context->thread); + + return Qnil; +} + +/* + * call-seq: + * context.backtrace-> int + * + * Returns the frame stack of a context. + */ +static inline VALUE +Context_backtrace(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + return dc_backtrace(context); +} + +static VALUE +Context_stop_reason(VALUE self) +{ + debug_context_t *context; + const char *symbol; + + Data_Get_Struct(self, debug_context_t, context); + + if (CTX_FL_TEST(context, CTX_FL_DEAD)) + symbol = "post-mortem"; + else + switch (context->stop_reason) + { + case CTX_STOP_STEP: + symbol = "step"; + break; + case CTX_STOP_BREAKPOINT: + symbol = "breakpoint"; + break; + case CTX_STOP_CATCHPOINT: + symbol = "catchpoint"; + break; + case CTX_STOP_NONE: + default: + symbol = "none"; + } + return ID2SYM(rb_intern(symbol)); +} + +/* + * call-seq: + * context.step_into(steps, frame = 0) + * + * Stops the current context after a number of +steps+ are made from frame + * +frame+ (by default the newest one). + */ +static VALUE +Context_step_into(int argc, VALUE * argv, VALUE self) +{ + VALUE steps, v_frame; + int n_args, from_frame; + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + if (context->calced_stack_size == 0) + rb_raise(rb_eRuntimeError, "No frames collected."); + + n_args = rb_scan_args(argc, argv, "11", &steps, &v_frame); + + if (FIX2INT(steps) <= 0) + rb_raise(rb_eRuntimeError, "Steps argument can't be negative."); + + from_frame = n_args == 1 ? 0 : FIX2INT(v_frame); + + if (from_frame < 0 || from_frame >= context->calced_stack_size) + rb_raise(rb_eRuntimeError, "Destination frame (%d) is out of range (%d)", + from_frame, context->calced_stack_size); + else if (from_frame > 0) + CTX_FL_SET(context, CTX_FL_IGNORE_STEPS); + + context->steps = FIX2INT(steps); + context->dest_frame = context->calced_stack_size - from_frame; + + return steps; +} + +/* + * call-seq: + * context.step_out(n_frames = 1, force = false) + * + * Stops after +n_frames+ frames are finished. +force+ parameter (if true) + * ensures that the execution will stop in the specified frame even when there + * are no more instructions to run. In that case, it will stop when the return + * event for that frame is triggered. + */ +static VALUE +Context_step_out(int argc, VALUE * argv, VALUE self) +{ + int n_args, n_frames; + VALUE v_frames, force; + debug_context_t *context; + + n_args = rb_scan_args(argc, argv, "02", &v_frames, &force); + n_frames = n_args == 0 ? 1 : FIX2INT(v_frames); + + Data_Get_Struct(self, debug_context_t, context); + + if (n_frames < 0 || n_frames > context->calced_stack_size) + rb_raise(rb_eRuntimeError, + "You want to finish %d frames, but stack size is only %d", + n_frames, context->calced_stack_size); + + context->steps_out = n_frames; + if (n_args == 2 && RTEST(force)) + CTX_FL_SET(context, CTX_FL_STOP_ON_RET); + else + CTX_FL_UNSET(context, CTX_FL_STOP_ON_RET); + + return Qnil; +} + +/* + * call-seq: + * context.step_over(lines, frame = 0) + * + * Steps over +lines+ lines in frame +frame+ (by default the newest one) or + * higher (if frame +frame+ finishes). + */ +static VALUE +Context_step_over(int argc, VALUE * argv, VALUE self) +{ + int n_args, frame; + VALUE lines, v_frame; + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + if (context->calced_stack_size == 0) + rb_raise(rb_eRuntimeError, "No frames collected."); + + n_args = rb_scan_args(argc, argv, "11", &lines, &v_frame); + frame = n_args == 1 ? 0 : FIX2INT(v_frame); + + if (frame < 0 || frame >= context->calced_stack_size) + rb_raise(rb_eRuntimeError, "Destination frame (%d) is out of range (%d)", + frame, context->calced_stack_size); + + context->lines = FIX2INT(lines); + context->dest_frame = context->calced_stack_size - frame; + + return Qnil; +} + +/* + * call-seq: + * context.suspend -> nil + * + * Suspends the thread when it is running. + */ +static VALUE +Context_suspend(VALUE self) +{ + VALUE status; + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + status = rb_funcall(context->thread, rb_intern("status"), 0); + + if (rb_str_cmp(status, rb_str_new2("run")) == 0) + CTX_FL_SET(context, CTX_FL_WAS_RUNNING); + else if (rb_str_cmp(status, rb_str_new2("sleep")) == 0) + CTX_FL_UNSET(context, CTX_FL_WAS_RUNNING); + else + return Qnil; + + CTX_FL_SET(context, CTX_FL_SUSPEND); + + return Qnil; +} + +/* + * call-seq: + * context.switch -> nil + * + * Switches execution to this context. + */ +static VALUE +Context_switch(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + next_thread = context->thread; + + context->steps = 1; + context->steps_out = 0; + CTX_FL_SET(context, CTX_FL_STOP_ON_RET); + + return Qnil; +} + +/* + * call-seq: + * context.suspended? -> bool + * + * Returns +true+ if the thread is suspended by debugger. + */ +static VALUE +Context_is_suspended(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + return CTX_FL_TEST(context, CTX_FL_SUSPEND) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * context.thnum -> int + * + * Returns the context's number. + */ +static inline VALUE +Context_thnum(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + return INT2FIX(context->thnum); +} + +/* + * call-seq: + * context.thread -> thread + * + * Returns the thread this context is associated with. + */ +static inline VALUE +Context_thread(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + return context->thread; +} + +/* + * call-seq: + * context.tracing -> bool + * + * Returns the tracing flag for the current context. + */ +static VALUE +Context_tracing(VALUE self) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + return CTX_FL_TEST(context, CTX_FL_TRACING) ? Qtrue : Qfalse; +} + +/* + * call-seq: + * context.tracing = bool + * + * Controls the tracing for this context. + */ +static VALUE +Context_set_tracing(VALUE self, VALUE value) +{ + debug_context_t *context; + + Data_Get_Struct(self, debug_context_t, context); + + if (RTEST(value)) + CTX_FL_SET(context, CTX_FL_TRACING); + else + CTX_FL_UNSET(context, CTX_FL_TRACING); + return value; +} + +/* :nodoc: */ +static VALUE +dt_inherited(VALUE klass) +{ + UNUSED(klass); + + rb_raise(rb_eRuntimeError, "Can't inherit Byebug::DebugThread class"); + + return Qnil; +} + +/* + * Document-class: Context + * + * == Summary + * + * Byebug keeps a single instance of this class. + */ +void +Init_context(VALUE mByebug) +{ + cContext = rb_define_class_under(mByebug, "Context", rb_cObject); + + rb_define_method(cContext, "backtrace", Context_backtrace, 0); + rb_define_method(cContext, "dead?", Context_dead, 0); + rb_define_method(cContext, "frame_binding", Context_frame_binding, -1); + rb_define_method(cContext, "frame_class", Context_frame_class, -1); + rb_define_method(cContext, "frame_file", Context_frame_file, -1); + rb_define_method(cContext, "frame_line", Context_frame_line, -1); + rb_define_method(cContext, "frame_method", Context_frame_method, -1); + rb_define_method(cContext, "frame_self", Context_frame_self, -1); + rb_define_method(cContext, "ignored?", Context_ignored, 0); + rb_define_method(cContext, "resume", Context_resume, 0); + rb_define_method(cContext, "step_into", Context_step_into, -1); + rb_define_method(cContext, "step_out", Context_step_out, -1); + rb_define_method(cContext, "step_over", Context_step_over, -1); + rb_define_method(cContext, "stop_reason", Context_stop_reason, 0); + rb_define_method(cContext, "suspend", Context_suspend, 0); + rb_define_method(cContext, "suspended?", Context_is_suspended, 0); + rb_define_method(cContext, "switch", Context_switch, 0); + rb_define_method(cContext, "thnum", Context_thnum, 0); + rb_define_method(cContext, "thread", Context_thread, 0); + rb_define_method(cContext, "tracing", Context_tracing, 0); + rb_define_method(cContext, "tracing=", Context_set_tracing, 1); + + cDebugThread = rb_define_class_under(mByebug, "DebugThread", rb_cThread); + rb_define_singleton_method(cDebugThread, "inherited", dt_inherited, 1); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.o b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.o new file mode 100644 index 000000000..3954df4b8 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/context.o differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/extconf.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/extconf.rb new file mode 100644 index 000000000..3a4a59066 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/extconf.rb @@ -0,0 +1,20 @@ +if RUBY_VERSION < '2.0' + STDERR.print("Ruby version is too old\n") + exit(1) +end + +require 'mkmf' + +makefile_config = RbConfig::MAKEFILE_CONFIG + +makefile_config['CC'] = ENV['CC'] if ENV['CC'] + +makefile_config['CFLAGS'] << ' -Wall -Werror' +makefile_config['CFLAGS'] << ' -gdwarf-2 -g3 -O0' if ENV['debug'] + +if makefile_config['CC'] =~ /clang/ + makefile_config['CFLAGS'] << ' -Wno-unknown-warning-option' +end + +dir_config('ruby') +with_cflags(makefile_config['CFLAGS']) { create_makefile('byebug/byebug') } diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.c b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.c new file mode 100644 index 000000000..2ef2be136 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.c @@ -0,0 +1,96 @@ +#include + +/** + * A simple linked list containing locked threads, FIFO style. + */ + +typedef struct locked_thread_t +{ + VALUE thread; + struct locked_thread_t *next; +} locked_thread_t; + +static locked_thread_t *locked_head = NULL; +static locked_thread_t *locked_tail = NULL; + +extern int +is_in_locked(VALUE thread) +{ + locked_thread_t *node; + + if (!locked_head) + return 0; + + for (node = locked_head; node != locked_tail; node = node->next) + if (node->thread == thread) + return 1; + + return 0; +} + +extern void +add_to_locked(VALUE thread) +{ + locked_thread_t *node; + + if (is_in_locked(thread)) + return; + + node = ALLOC(locked_thread_t); + node->thread = thread; + node->next = NULL; + + if (locked_tail) + locked_tail->next = node; + + locked_tail = node; + + if (!locked_head) + locked_head = node; +} + +extern VALUE +pop_from_locked() +{ + VALUE thread; + locked_thread_t *node; + + if (!locked_head) + return Qnil; + + node = locked_head; + locked_head = locked_head->next; + + if (locked_tail == node) + locked_tail = NULL; + + thread = node->thread; + xfree(node); + + return thread; +} + +extern void +remove_from_locked(VALUE thread) +{ + locked_thread_t *node; + locked_thread_t *next_node; + + if (NIL_P(thread) || !locked_head || !is_in_locked(thread)) + return; + + if (locked_head->thread == thread) + { + pop_from_locked(); + return; + } + + for (node = locked_head; node != locked_tail; node = node->next) + if (node->next && node->next->thread == thread) + { + next_node = node->next; + node->next = next_node->next; + xfree(next_node); + return; + } +} diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.o b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.o new file mode 100644 index 000000000..81264b4a2 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/locker.o differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.c b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.c new file mode 100644 index 000000000..b9d8b0ad6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.c @@ -0,0 +1,232 @@ +#include + +/* Threads table class */ +static VALUE cThreadsTable; + +/* If not Qnil, holds the next thread that must be run */ +VALUE next_thread = Qnil; + +/* To allow thread syncronization, we must stop threads when debugging */ +VALUE locker = Qnil; + +static int +t_tbl_mark_keyvalue(st_data_t key, st_data_t value, st_data_t tbl) +{ + UNUSED(tbl); + + rb_gc_mark((VALUE) key); + + if (!value) + return ST_CONTINUE; + + rb_gc_mark((VALUE) value); + + return ST_CONTINUE; +} + +static void +t_tbl_mark(void *data) +{ + threads_table_t *t_tbl = (threads_table_t *) data; + st_table *tbl = t_tbl->tbl; + + st_foreach(tbl, t_tbl_mark_keyvalue, (st_data_t) tbl); +} + +static void +t_tbl_free(void *data) +{ + threads_table_t *t_tbl = (threads_table_t *) data; + + st_free_table(t_tbl->tbl); + xfree(t_tbl); +} + +/* + * Creates a numeric hash whose keys are the currently active threads and + * whose values are their associated contexts. + */ +VALUE +create_threads_table(void) +{ + threads_table_t *t_tbl; + + t_tbl = ALLOC(threads_table_t); + t_tbl->tbl = st_init_numtable(); + return Data_Wrap_Struct(cThreadsTable, t_tbl_mark, t_tbl_free, t_tbl); +} + +/* + * Checks a single entry in the threads table. + * + * If it has no associated context or the key doesn't correspond to a living + * thread, the entry is removed from the thread's list. + */ +static int +check_thread_i(st_data_t key, st_data_t value, st_data_t data) +{ + UNUSED(data); + + if (!value) + return ST_DELETE; + + if (!is_living_thread((VALUE) key)) + return ST_DELETE; + + return ST_CONTINUE; +} + +/* + * Checks whether a thread is either in the running or sleeping state. + */ +int +is_living_thread(VALUE thread) +{ + VALUE status = rb_funcall(thread, rb_intern("status"), 0); + + if (NIL_P(status) || status == Qfalse) + return 0; + + if (rb_str_cmp(status, rb_str_new2("run")) == 0 + || rb_str_cmp(status, rb_str_new2("sleep")) == 0) + return 1; + + return 0; +} + +/* + * Checks threads table for dead/finished threads. + */ +void +cleanup_dead_threads(void) +{ + threads_table_t *t_tbl; + + Data_Get_Struct(threads, threads_table_t, t_tbl); + st_foreach(t_tbl->tbl, check_thread_i, 0); +} + +/* + * Looks up a context in the threads table. If not present, it creates it. + */ +void +thread_context_lookup(VALUE thread, VALUE * context) +{ + threads_table_t *t_tbl; + + Data_Get_Struct(threads, threads_table_t, t_tbl); + + if (!st_lookup(t_tbl->tbl, thread, context) || !*context) + { + *context = context_create(thread); + st_insert(t_tbl->tbl, thread, *context); + } +} + +/* + * Holds thread execution while another thread is active. + * + * Thanks to this, all threads are "frozen" while the user is typing commands. + */ +void +acquire_lock(debug_context_t * dc) +{ + while ((!NIL_P(locker) && locker != rb_thread_current()) + || CTX_FL_TEST(dc, CTX_FL_SUSPEND)) + { + add_to_locked(rb_thread_current()); + rb_thread_stop(); + + if (CTX_FL_TEST(dc, CTX_FL_SUSPEND)) + CTX_FL_SET(dc, CTX_FL_WAS_RUNNING); + } + + locker = rb_thread_current(); +} + +/* + * Releases our global lock and passes execution on to another thread, either + * the thread specified by +next_thread+ or any other thread if +next_thread+ + * is nil. + */ +void +release_lock(void) +{ + VALUE thread; + + cleanup_dead_threads(); + + locker = Qnil; + + if (NIL_P(next_thread)) + thread = pop_from_locked(); + else + { + remove_from_locked(next_thread); + thread = next_thread; + } + + if (thread == next_thread) + next_thread = Qnil; + + if (!NIL_P(thread) && is_living_thread(thread)) + rb_thread_run(thread); +} + +/* + * call-seq: + * Byebug.unlock -> nil + * + * Unlocks global switch so other threads can run. + */ +static VALUE +Unlock(VALUE self) +{ + UNUSED(self); + + release_lock(); + + return locker; +} + +/* + * call-seq: + * Byebug.lock -> Thread.current + * + * Locks global switch to reserve execution to current thread exclusively. + */ +static VALUE +Lock(VALUE self) +{ + debug_context_t *dc; + VALUE context; + + UNUSED(self); + + if (!is_living_thread(rb_thread_current())) + rb_raise(rb_eRuntimeError, "Current thread is dead!"); + + thread_context_lookup(rb_thread_current(), &context); + Data_Get_Struct(context, debug_context_t, dc); + + acquire_lock(dc); + + return locker; +} + +/* + * + * Document-class: ThreadsTable + * + * == Sumary + * + * Hash table holding currently active threads and their associated contexts + */ +void +Init_threads_table(VALUE mByebug) +{ + cThreadsTable = rb_define_class_under(mByebug, "ThreadsTable", rb_cObject); + + rb_define_module_function(mByebug, "unlock", Unlock, 0); + rb_define_module_function(mByebug, "lock", Lock, 0); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.o b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.o new file mode 100644 index 000000000..d4571506d Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/ext/byebug/threads.o differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug.rb new file mode 100644 index 000000000..075fdef60 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug.rb @@ -0,0 +1,2 @@ +require 'byebug/core' +require 'byebug/attacher' diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/attacher.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/attacher.rb new file mode 100644 index 000000000..99ab7c9f5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/attacher.rb @@ -0,0 +1,32 @@ +# +# Main Container for all of Byebug's code +# +module Byebug + # + # Enters byebug right before (or right after if _before_ is false) return + # events occur. Before entering byebug the init script is read. + # + def self.attach + unless started? + self.mode = :attached + + start + run_init_script + end + + current_context.step_out(2, true) + end +end + +# +# Adds a `byebug` method to the Kernel module. +# +# Dropping a `byebug` call anywhere in your code, you get a debug prompt. +# +module Kernel + def byebug + Byebug.attach + end + + alias_method :debugger, :byebug +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/breakpoint.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/breakpoint.rb new file mode 100644 index 000000000..7d8b019ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/breakpoint.rb @@ -0,0 +1,91 @@ +module Byebug + # + # Implements breakpoints + # + class Breakpoint + # + # First breakpoint, in order of creation + # + def self.first + Byebug.breakpoints.first + end + + # + # Last breakpoint, in order of creation + # + def self.last + Byebug.breakpoints.last + end + + # + # Adds a new breakpoint + # + # @param [String] file + # @param [Fixnum] line + # @param [String] expr + # + def self.add(file, line, expr = nil) + breakpoint = Breakpoint.new(file, line, expr) + Byebug.breakpoints << breakpoint + breakpoint + end + + # + # Removes a breakpoint + # + # @param [integer] breakpoint number + # + def self.remove(id) + Byebug.breakpoints.reject! { |b| b.id == id } + end + + # + # Returns an array of line numbers in file named +filename+ where + # breakpoints could be set. The list will contain an entry for each + # distinct line event call so it is possible (and possibly useful) for a + # line number appear more than once. + # + # @param filename [String] File name to inspect for possible breakpoints + # + def self.potential_lines(filename) + name = "#{Time.new.to_i}_#{rand(2**31)}" + lines = {} + iseq = RubyVM::InstructionSequence.compile(File.read(filename), name) + + iseq.disasm.each_line do |line| + res = /^\d+ (?\w+)\s+.+\(\s*(?\d+)\)$/.match(line) + next unless res && res[:insn] == 'trace' + + lines[res[:lineno].to_i] = true + end + + lines.keys + end + + # + # Returns true if a breakpoint could be set in line number +lineno+ in file + # name +filename. + # + def self.potential_line?(filename, lineno) + potential_lines(filename).member?(lineno) + end + + # + # True if there's no breakpoints + # + def self.none? + Byebug.breakpoints.empty? + end + + # + # Prints all information associated to the breakpoint + # + def inspect + meths = %w(id pos source expr hit_condition hit_count hit_value enabled?) + values = meths.map do |field| + "#{field}: #{send(field)}" + end.join(', ') + "#" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/byebug.so b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/byebug.so new file mode 100755 index 000000000..a44061684 Binary files /dev/null and b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/byebug.so differ diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/command.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/command.rb new file mode 100644 index 000000000..22ab061d9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/command.rb @@ -0,0 +1,105 @@ +require 'columnize' +require 'forwardable' +require 'byebug/helpers/string' + +module Byebug + # + # Parent class of all byebug commands. + # + # Subclasses need to implement a `regexp` method and an `execute` method. + # + class Command + extend Forwardable + + include Helpers::StringHelper + + def initialize(state) + @match = nil + @state = state + end + + def match(input) + @match = regexp.match(input) + end + + def_delegators :'self.class', :to_name, :description + + # + # Default help text for a command. + # + def help + prettify(description) + end + + def_delegator :"Byebug.printer", :print, :pr + def_delegator :"Byebug.printer", :print_collection, :prc + def_delegator :"Byebug.printer", :print_variables, :prv + + protected + + def_delegators :@state, :errmsg, :puts, :print, :confirm + + # + # Evaluates a string containing Ruby code, using binding +b+. In case of + # error full stack trace and error are printed. + # + def bb_eval(str, b = get_binding) + b.eval(str) + rescue StandardError, ScriptError => e + at = e.backtrace + locations = [] + locations << "#{at.shift}: #{e.class} Exception(#{e.message})" + locations += at.map { |path| "\tfrom #{path}" } + + errmsg(pr('eval.exception', text_message: locations.join("\n"))) + nil + end + + # + # Evaluates a string containing Ruby code, using binding +b+. In case of + # error, an error message with the exception is printed. + # + def bb_warning_eval(str, b = get_binding) + b.eval(str) + rescue StandardError, ScriptError => e + text_message = "#{e.class} Exception: #{e.message}" + errmsg(pr('eval.exception', text_message: text_message)) + nil + end + + def get_binding(pos = @state.frame) + @state.context ? @state.context.frame_binding(pos) : TOPLEVEL_BINDING + end + + class << self + attr_accessor :allow_in_control + attr_writer :allow_in_post_mortem, :always_run + + def allow_in_post_mortem + !defined?(@allow_in_post_mortem) ? true : false + end + + def always_run + @always_run ||= 0 + end + + # + # Name of the command, as executed by the user. + # + def to_name + name.gsub(/^Byebug::/, '').gsub(/Command$/, '').downcase + end + + # + # Available subcommands for the current command + # + # A subcommand is any class defined inside the parent's command class + # + def subcommands + const_list = constants(false).map { |const| const_get(const, false) } + + const_list.select { |c| c.is_a?(Class) } + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/break.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/break.rb new file mode 100644 index 000000000..4d2bea545 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/break.rb @@ -0,0 +1,89 @@ +require 'byebug/command' +require 'byebug/helpers/file' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements breakpoint functionality + # + class BreakCommand < Command + include Helpers::FileHelper + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + self.allow_in_control = true + + def regexp + /^\s* b(?:reak)? (?:\s+ (\S+))? (?:\s+ if \s+(.+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + b = line_breakpoint(@match[1]) || method_breakpoint(@match[1]) + + if syntax_valid?(@match[2]) + return puts(pr('break.created', id: b.id, file: b.source, line: b.pos)) + end + + errmsg(pr('break.errors.expression', expr: @match[2])) + b.enabled = false + rescue => e + errmsg(e.message) + end + + def short_description + 'Set breakpoint to some position, (optionally) if expr == true' + end + + def description + <<-EOD + b[reak] [file:]line [if expr] + b[reak] [module::...]class(.|#)method [if expr] + + #{short_description} + EOD + end + + private + + def line_breakpoint(loc) + line = loc.match(/^(\d+)$/) + file_line = loc.match(/^([^:]+):(\d+)$/) + return nil unless line || file_line + + f, l = line ? [@state.file, line[1]] : [file_line[1], file_line[2]] + + check_errors(f, l.to_i) + + Breakpoint.add(File.expand_path(f), l.to_i, @match[2]) + end + + def method_breakpoint(location) + location.match(/([^.#]+)[.#](.+)/) do |match| + k = bb_warning_eval(match[1]) + m = match[2] + + klass = k && k.is_a?(Module) ? k.name : match[1] + method = m.intern + + Breakpoint.add(klass, method, @match[2]) + end + end + + def check_errors(file, line) + path = File.expand_path(file) + deco_path = normalize(file) + + fail(pr('break.errors.source', file: deco_path)) unless File.exist?(path) + + if line > n_lines(file) + fail(pr('break.errors.far_line', lines: n_lines(file), file: deco_path)) + end + + return if Breakpoint.potential_line?(path, line) + + fail(pr('break.errors.line', file: deco_path, line: line)) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/catch.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/catch.rb new file mode 100644 index 000000000..d1522d923 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/catch.rb @@ -0,0 +1,56 @@ +require 'byebug/command' + +module Byebug + # + # Implements exception catching. + # + # Enables the user to catch unhandled assertion when they happen. + # + class CatchCommand < Command + def regexp + /^\s* cat(?:ch)? (?:\s+(\S+))? (?:\s+(off))? \s*$/x + end + + def execute + ex = @match[1] + return info_catch unless ex + + cmd = @match[2] + unless cmd + if 'off' == ex + Byebug.catchpoints.clear if + confirm(pr('catch.confirmations.delete_all')) + + return + end + + is_class = bb_eval("#{ex.is_a?(Class)}") + puts pr('catch.errors.not_class', class: ex) unless is_class + + Byebug.add_catchpoint(ex) + return puts pr('catch.catching', exception: ex) + end + + if cmd == 'off' + exists = Byebug.catchpoints.member?(ex) + return errmsg pr('catch.errors.not_found', exception: ex) unless exists + + Byebug.catchpoints.delete(ex) + return errmsg pr('catch.errors.removed', exception: ex) + end + + errmsg pr('catch.errors.off', off: cmd) + end + + def description + <<-EOD + cat[ch][ (off|[ off])] + + "catch" lists catchpoints. + "catch off" deletes all catchpoints. + "catch " enables handling . + "catch off" disables handling . + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/condition.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/condition.rb new file mode 100644 index 000000000..b228aa857 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/condition.rb @@ -0,0 +1,49 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements conditions on breakpoints. + # + # Adds the ability to stop on breakpoints only under certain conditions. + # + class ConditionCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + + def regexp + /^\s* cond(?:ition)? (?:\s+(\d+)(?:\s+(.*))?)? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + breakpoints = Byebug.breakpoints.sort_by(&:id) + return errmsg(pr('condition.errors.no_breakpoints')) if breakpoints.empty? + + pos, err = get_int(@match[1], 'Condition', 1) + return errmsg(err) if err + + breakpoint = breakpoints.find { |b| b.id == pos } + return errmsg(pr('break.errors.no_breakpoint')) unless breakpoint + + unless syntax_valid?(@match[2]) + return errmsg(pr('break.errors.not_changed', expr: @match[2])) + end + + breakpoint.expr = @match[2] + end + + def description + <<-EOD + cond[ition] [ expr] + + Specify breakpoint number to break only if is true. is + an integer and is an expression to be evaluated whenever + breakpoint is reached. If no expression is specified, the condition + is removed. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/continue.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/continue.rb new file mode 100644 index 000000000..587d5db30 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/continue.rb @@ -0,0 +1,42 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements the continue command. + # + # Allows the user to continue execution until the next stopping point, a + # specific line number or until program termination. + # + class ContinueCommand < Command + include Helpers::ParseHelper + + def regexp + /^\s* c(?:ont(?:inue)?)? (?:\s+(\S+))? \s*$/x + end + + def execute + if @match[1] + num, err = get_int(@match[1], 'Continue', 0, nil) + return errmsg(err) unless num + + filename = File.expand_path(@state.file) + unless Breakpoint.potential_line?(filename, num) + return errmsg(pr('continue.errors.unstopped_line', line: num)) + end + + Breakpoint.add(filename, num) + end + + @state.proceed + end + + def description + <<-EOD + c[ont[inue]][ ] + + Run until program ends, hits a breakpoint or reaches line . + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/delete.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/delete.rb new file mode 100644 index 000000000..431b404f1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/delete.rb @@ -0,0 +1,47 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements breakpoint deletion. + # + class DeleteCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + self.allow_in_control = true + + def regexp + /^\s* del(?:ete)? (?:\s+(.*))?$/x + end + + def execute + unless @match[1] + if confirm(pr('break.confirmations.delete_all')) + Byebug.breakpoints.clear + end + + return nil + end + + @match[1].split(/ +/).each do |number| + pos, err = get_int(number, 'Delete', 1) + + return errmsg(err) unless pos + + unless Breakpoint.remove(pos) + return errmsg(pr('break.errors.no_breakpoint_delete', pos: pos)) + end + end + end + + def description + <<-EOD + del[ete][ nnn...] + + Without and argument, deletes all breakpoints. With integer arguments, + it deletes specific breakpoints. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable.rb new file mode 100644 index 000000000..37429349b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable.rb @@ -0,0 +1,32 @@ +require 'byebug/subcommands' + +require 'byebug/commands/disable/breakpoints' +require 'byebug/commands/disable/display' + +module Byebug + # + # Disabling custom display expressions or breakpoints. + # + class DisableCommand < Command + include Subcommands + + def regexp + /^\s* dis(?:able)? (?:\s+ (.+))? \s*$/x + end + + def description + <<-EOD + dis[able][[ breakpoints| display)][ n1[ n2[ ...[ nn]]]]] + + Disables breakpoints or displays. + + "disable" by itself shows this help + "disable breakpoints" disables all breakpoints. + "disable displays" disables all displays. + + You can also specify a space separated list of breakpoint or display + numbers to disable only specific breakpoints or displays. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/breakpoints.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/breakpoints.rb new file mode 100644 index 000000000..8eab33e8f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/breakpoints.rb @@ -0,0 +1,38 @@ +require 'byebug/helpers/toggle' + +module Byebug + # + # Reopens the +disable+ command to define the +breakpoints+ subcommand + # + class DisableCommand < Command + # + # Disables all or specific breakpoints + # + class BreakpointsSubcommand < Command + include Helpers::ToggleHelper + + def regexp + /^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x + end + + def execute + enable_disable_breakpoints('disable', @match[1]) + end + + def short_description + 'Disable all or specific breakpoints.' + end + + def description + <<-EOD + dis[able] b[reakpoints][ .. ] + + #{short_description} + + Give breakpoint numbers (separated by spaces) as arguments or no + argument at all if you want to disable every breakpoint. + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/display.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/display.rb new file mode 100644 index 000000000..e3f55f74b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/disable/display.rb @@ -0,0 +1,39 @@ +require 'byebug/helpers/toggle' + +module Byebug + # + # Reopens the +disable+ command to define the +display+ subcommand + # + class DisableCommand < Command + # + # Enables all or specific displays + # + class DisplaySubcommand < Command + include Helpers::ToggleHelper + + def regexp + /^\s* d(?:isplay)? (?:\s+ (.+))? \s*$/x + end + + def execute + enable_disable_display('disable', @match[1]) + end + + def short_description + 'Disables expressions to be displayed when program stops.' + end + + def description + <<-EOD + dis[able] d[isplay][ .. ] + + #{short_description} + + Arguments are the code numbers of the expressions to disable. Do "info + display" to see the current list of code numbers. If no arguments are + specified, all displays are disabled. + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/display.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/display.rb new file mode 100644 index 000000000..322eaa2d9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/display.rb @@ -0,0 +1,56 @@ +require 'byebug/command' + +module Byebug + # + # Custom expressions to be displayed every time the debugger stops. + # + class DisplayCommand < Command + self.allow_in_post_mortem = false + + def self.always_run + 2 + end + + def regexp + /^\s* disp(?:lay)? (?:\s+ (.+))? \s*$/x + end + + def execute + return print_display_expressions unless @match && @match[1] + + @state.display.push [true, @match[1]] + display_expression(@match[1]) + end + + def description + <<-EOD + disp[lay][ ] + + If specified, adds into display expression + list. Otherwise, it lists all expressions. + EOD + end + + private + + def display_expression(exp) + print pr('display.result', + n: @state.display.size, + exp: exp, + result: bb_warning_eval(exp).inspect) + end + + def print_display_expressions + result = prc('display.result', @state.display) do |item, index| + is_active, expression = item + if is_active + { n: index + 1, + exp: expression, + result: bb_warning_eval(expression).inspect } + end + end + + print result + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/down.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/down.rb new file mode 100644 index 000000000..117acc3fa --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/down.rb @@ -0,0 +1,39 @@ +# encoding: utf-8 + +require 'pathname' +require 'byebug/command' +require 'byebug/helpers/frame' +require 'byebug/helpers/parse' + +module Byebug + # + # Move the current frame down in the backtrace. + # + class DownCommand < Command + include Helpers::FrameHelper + include Helpers::ParseHelper + + def regexp + /^\s* down (?:\s+(\S+))? \s*$/x + end + + def execute + pos, err = parse_steps(@match[1], 'Down') + return errmsg(err) unless pos + + adjust_frame(-pos, false) + + ListCommand.new(@state).execute if Setting[:autolist] + end + + def description + <<-EOD + down[ count] + + Move to a lower frame in the stack trace. + + Use the "bt" command to find out where you want to go. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/edit.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/edit.rb new file mode 100644 index 000000000..99c858360 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/edit.rb @@ -0,0 +1,50 @@ +require 'byebug/command' + +module Byebug + # + # Edit a file from byebug's prompt. + # + class EditCommand < Command + self.allow_in_control = true + + def regexp + /^\s* ed(?:it)? (?:\s+(\S+))? \s*$/x + end + + def execute + if !@match[1] + return errmsg(pr('edit.errors.state')) unless @state.file + file = @state.file + line = @state.line if @state.line + elsif (@pos_match = /([^:]+)[:]([0-9]+)/.match(@match[1])) + file, line = @pos_match.captures + else + file = @match[1] + end + + editor = ENV['EDITOR'] || 'vim' + file = File.expand_path(file) + + unless File.exist?(file) + return errmsg(pr('edit.errors.not_exist', file: file)) + end + unless File.readable?(file) + return errmsg(pr('edit.errors.not_readable', file: file)) + end + + cmd = line ? "#{editor} +#{line} #{file}" : "#{editor} #{file}" + + system(cmd) + end + + def description + <<-EOD + edit[ file:lineno] Edit specified files. + + With no argument, edits file containing most recent line listed. Editing + targets can also be specified to start editing at a specific line in a + specific file. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable.rb new file mode 100644 index 000000000..5819143a6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable.rb @@ -0,0 +1,25 @@ +require 'byebug/subcommands' + +require 'byebug/commands/enable/breakpoints' +require 'byebug/commands/enable/display' + +module Byebug + # + # Enabling custom display expressions or breakpoints. + # + class EnableCommand < Command + include Subcommands + + def regexp + /^\s* en(?:able)? (?:\s+ (.+))? \s*$/x + end + + def description + <<-EOD + en[able][[ b[reakpoints]| d[isplay])][ n1[ n2[ ...[ nn]]]]] + + Enables breakpoints or displays. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/breakpoints.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/breakpoints.rb new file mode 100644 index 000000000..c919d82f9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/breakpoints.rb @@ -0,0 +1,38 @@ +require 'byebug/helpers/toggle' + +module Byebug + # + # Reopens the +enable+ command to define the +breakpoints+ subcommand + # + class EnableCommand < Command + # + # Enables all or specific breakpoints + # + class BreakpointsSubcommand < Command + include Helpers::ToggleHelper + + def regexp + /^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x + end + + def execute + enable_disable_breakpoints('enable', @match[1]) + end + + def short_description + 'Disable all or specific breakpoints' + end + + def description + <<-EOD + en[able] b[reakpoints][ ] + + #{short_description} + + Give breakpoint numbers (separated by spaces) as arguments or no + argument at all if you want to enable every breakpoint. + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/display.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/display.rb new file mode 100644 index 000000000..6f8a4b308 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/enable/display.rb @@ -0,0 +1,39 @@ +require 'byebug/helpers/toggle' + +module Byebug + # + # Reopens the +enable+ command to define the +display+ subcommand + # + class EnableCommand < Command + # + # Enables all or specific displays + # + class DisplaySubcommand < Command + include Helpers::ToggleHelper + + def regexp + /^\s* d(?:isplay)? (?:\s+ (.+))? \s*$/x + end + + def execute + enable_disable_display('enable', @match[1]) + end + + def short_description + 'Enables expressions to be displayed when program stops.' + end + + def description + <<-EOD + en[able] d[isplay][ .. ] + + #{short_description} + + Arguments are the code numbers of the expressions to enable. Do "info + display" to see the current list of code numbers. If no arguments are + specified, all displays are enabled. + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/eval.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/eval.rb new file mode 100644 index 000000000..098c5741a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/eval.rb @@ -0,0 +1,43 @@ +require 'English' +require 'byebug/command' +require 'byebug/helpers/eval' + +module Byebug + # + # Evaluation of expressions from byebug's prompt. + # + class EvalCommand < Command + include Helpers::EvalHelper + + def match(input) + @input = input + super + end + + def regexp + /^\s* e(?:val)? \s+/x + end + + def execute + expr = @match ? @match.post_match : @input + run_with_binding do |b| + res = eval_with_setting(b, expr, Setting[:stack_on_error]) + + print pr('eval.result', expr: expr, result: res.inspect) + end + rescue + puts "#{$ERROR_INFO.class} Exception: #{$ERROR_INFO.message}" + end + + def description + <<-EOD + e[val] + + Evaluates and prints its value. + + * NOTE - unknown input is automatically evaluated, to turn this off use + 'set noautoeval'. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/finish.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/finish.rb new file mode 100644 index 000000000..2ae705079 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/finish.rb @@ -0,0 +1,46 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements the finish functionality. + # + # Allows the user to continue execution until certain frames are finished. + # + class FinishCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + + def regexp + /^\s* fin(?:ish)? (?:\s+(\S+))? \s*$/x + end + + def execute + max_frames = @state.context.stack_size - @state.frame + if @match[1] + n_frames, err = get_int(@match[1], 'finish', 0, max_frames - 1) + return errmsg(err) unless n_frames + else + n_frames = 1 + end + + force = n_frames == 0 ? true : false + @state.context.step_out(@state.frame + n_frames, force) + @state.frame = 0 + @state.proceed + end + + def description + <<-EOD + fin[ish][ n_frames] + + Execute until frame returns. + + If no number is given, we run until the current frame returns. If a + number of frames `n_frames` is given, then we run until `n_frames` + return from the current position. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/frame.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/frame.rb new file mode 100644 index 000000000..3941cc492 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/frame.rb @@ -0,0 +1,50 @@ +# encoding: utf-8 + +require 'pathname' +require 'byebug/command' +require 'byebug/helpers/frame' +require 'byebug/helpers/parse' + +module Byebug + # + # Move to specific frames in the backtrace. + # + class FrameCommand < Command + include Helpers::FrameHelper + include Helpers::ParseHelper + + def regexp + /^\s* f(?:rame)? (?:\s+(\S+))? \s*$/x + end + + def execute + unless @match[1] + print(pr('frame.line', get_pr_arguments(@state.frame))) + return + end + + pos, err = get_int(@match[1], 'Frame') + return errmsg(err) unless pos + + adjust_frame(pos, true) + end + + def description + <<-EOD + f[rame][ frame-number] + + Move the current frame to the specified frame number, or the 0 if no + frame-number has been given. + + A negative number indicates position from the other end, so "frame -1" + moves to the oldest frame, and "frame 0" moves to the newest frame. + + Without an argument, the command prints the current stack frame. Since + the current position is redisplayed, it may trigger a resyncronization + if there is a front end also watching over things. + + Use the "bt" command to find out where you want to go. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/help.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/help.rb new file mode 100644 index 000000000..3959b2bbc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/help.rb @@ -0,0 +1,39 @@ +require 'byebug/command' + +module Byebug + # + # Ask for help from byebug's prompt. + # + class HelpCommand < Command + self.allow_in_control = true + + def regexp + /^\s* h(?:elp)? (?:\s+(\S+))? (?:\s+(\S+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + cmd = Byebug.commands.find { |c| c.to_name == @match[1] } + return errmsg(pr('help.errors.undefined', cmd: @match[1])) unless cmd + + cmd = cmd.new(@state) + return puts(cmd.help) unless @match[2] + + subcmd = cmd.subcommands.find(@match[2]) + return errmsg(pr('help.errors.undefined', cmd: @match[2])) unless subcmd + + puts(subcmd.help) + end + + def description + <<-EOD + h[elp][ [ ]] + + help -- prints this help. + help -- prints help on command . + help -- prints help on 's subcommand . + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/history.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/history.rb new file mode 100644 index 000000000..f1d9a4e46 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/history.rb @@ -0,0 +1,34 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Show history of byebug commands. + # + class HistoryCommand < Command + include Helpers::ParseHelper + + def regexp + /^\s* hist(?:ory)? (?:\s+(?.+))? \s*$/x + end + + def execute + history = @state.interface.history + + if @match[:num_cmds] + size, = get_int(@match[:num_cmds], 'history', 1, history.size) + return errmsg(err) unless size + end + + puts history.to_s(size) + end + + def description + <<-EOD + hist[ory] [num_cmds] + + Show byebug's command history. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info.rb new file mode 100644 index 000000000..ff8501fec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info.rb @@ -0,0 +1,32 @@ +require 'byebug/subcommands' + +require 'byebug/commands/info/args' +require 'byebug/commands/info/breakpoints' +require 'byebug/commands/info/catch' +require 'byebug/commands/info/display' +require 'byebug/commands/info/file' +require 'byebug/commands/info/line' +require 'byebug/commands/info/program' + +module Byebug + # + # Shows info about different aspects of the debugger. + # + class InfoCommand < Command + include Subcommands + + self.allow_in_control = true + + def regexp + /^\s* i(?:nfo)? (?:\s+ (.+))? \s*$/x + end + + def description + <<-EOD + info[ subcommand] + + Generic command for showing things about the program being debugged. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/args.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/args.rb new file mode 100644 index 000000000..40f1c7956 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/args.rb @@ -0,0 +1,39 @@ +module Byebug + # + # Reopens the +info+ command to define the +args+ subcommand + # + class InfoCommand < Command + # + # Information about arguments of the current method/block + # + class ArgsSubcommand < Command + def regexp + /^\s* a(?:rgs)? \s*$/x + end + + def execute + locals = @state.context.frame_locals + args = @state.context.frame_args + return if args == [[:rest]] + + args.map do |_, name| + s = "#{name} = #{locals[name].inspect}" + s[Setting[:width] - 3..-1] = '...' if s.size > Setting[:width] + puts s + end + end + + def short_description + 'Information about arguments of the current method/block' + end + + def description + <<-EOD + inf[o] a[args] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/breakpoints.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/breakpoints.rb new file mode 100644 index 000000000..41acef3fc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/breakpoints.rb @@ -0,0 +1,59 @@ +module Byebug + # + # Reopens the +info+ command to define the +breakpoints+ subcommand + # + class InfoCommand < Command + # + # Information about current breakpoints + # + class BreakpointsSubcommand < Command + def regexp + /^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x + end + + def execute + return puts('No breakpoints.') if Byebug.breakpoints.empty? + + breakpoints = Byebug.breakpoints.sort_by(&:id) + + if @match[1] + indices = @match[1].split(/ +/).map(&:to_i) + breakpoints = breakpoints.select { |b| indices.member?(b.id) } + if breakpoints.empty? + return errmsg('No breakpoints found among list given') + end + end + + puts 'Num Enb What' + breakpoints.each { |b| info_breakpoint(b) } + end + + def short_description + 'Status of user settable breakpoints.' + end + + def description + <<-EOD + inf[o] b[reakpoints] + + #{short_description} + EOD + end + + private + + def info_breakpoint(brkpt) + expr = brkpt.expr.nil? ? '' : " if #{brkpt.expr}" + y_n = brkpt.enabled? ? 'y' : 'n' + interp = format('%-3d %-3s at %s:%s%s', + brkpt.id, y_n, brkpt.source, brkpt.pos, expr) + puts interp + hits = brkpt.hit_count + return unless hits > 0 + + s = (hits > 1) ? 's' : '' + puts "\tbreakpoint already hit #{hits} time#{s}" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/catch.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/catch.rb new file mode 100644 index 000000000..c3e890e71 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/catch.rb @@ -0,0 +1,39 @@ +module Byebug + # + # Reopens the +info+ command to define the +catch+ subcommand + # + class InfoCommand < Command + # + # Information on exceptions that can be caught by the debugger + # + class CatchSubcommand < Command + def regexp + /^\s* c(?:atch)? (?:\s+ (.+))? \s*$/x + end + + def execute + return puts('No frame selected.') unless @state.context + + if Byebug.catchpoints && !Byebug.catchpoints.empty? + Byebug.catchpoints.each do |exception, _hits| + puts("#{exception}: #{exception.is_a?(Class)}") + end + else + puts 'No exceptions set to be caught.' + end + end + + def short_description + 'Exceptions that can be caught in the current stack frame' + end + + def description + <<-EOD + inf[o] c[atch] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/display.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/display.rb new file mode 100644 index 000000000..8160698e9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/display.rb @@ -0,0 +1,42 @@ +module Byebug + # + # Reopens the +info+ command to define the +display+ subcommand + # + class InfoCommand < Command + # + # Information about display expressions + # + class DisplaySubcommand < Command + def regexp + /^\s* d(?:isplay)? \s*$/x + end + + def execute + display = @state.display + + unless display.find { |d| d[0] } + return puts('There are no auto-display expressions now.') + end + + puts 'Auto-display expressions now in effect:' + puts 'Num Enb Expression' + + display.each_with_index do |d, i| + puts(format('%3d: %s %s', i + 1, d[0] ? 'y' : 'n', d[1])) + end + end + + def short_description + 'List of expressions to display when program stops' + end + + def description + <<-EOD + inf[o] d[display] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/file.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/file.rb new file mode 100644 index 000000000..701374ab3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/file.rb @@ -0,0 +1,81 @@ +require 'byebug/helpers/file' + +module Byebug + # + # Reopens the +info+ command to define the +file+ subcommand + # + class InfoCommand < Command + # + # Information about a particular source file + # + class FileSubcommand < Command + include Helpers::FileHelper + + def regexp + /^\s* f(?:ile)? (?:\s+ (\S+))? \s*$/x + end + + def execute + file = @match[1] || @state.file + unless File.exist?(file) + return errmsg(pr('info.errors.undefined_file', file: file)) + end + + puts <<-EOC.gsub(/^ {6}/, '') + + File #{info_file_basic(file)} + + Breakpoint line numbers: + #{info_file_breakpoints(file)} + + Modification time: #{info_file_mtime(file)} + + Sha1 Signature: #{info_file_sha1(file)} + + EOC + end + + def short_description + 'Information about a particular source file.' + end + + def description + <<-EOD + inf[o] f[ile] + + #{short_description} + + It informs about file name, number of lines, possible breakpoints in + the file, last modification time and sha1 digest. + EOD + end + + private + + def info_file_basic(file) + path = File.expand_path(file) + return unless File.exist?(path) + + s = n_lines(path) == 1 ? '' : 's' + "#{path} (#{n_lines(path)} line#{s})" + end + + def info_file_breakpoints(file) + breakpoints = Breakpoint.potential_lines(file) + return unless breakpoints + + breakpoints.to_a.sort.columnize(line_prefix: ' ', + displaywidth: Setting[:width]) + end + + def info_file_mtime(file) + File.stat(file).mtime + end + + def info_file_sha1(file) + require 'digest/sha1' + Digest::SHA1.hexdigest(file) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/line.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/line.rb new file mode 100644 index 000000000..323188e25 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/line.rb @@ -0,0 +1,31 @@ +module Byebug + # + # Reopens the +info+ command to define the +line+ subcommand + # + class InfoCommand < Command + # + # Information about current location + # + class LineSubcommand < Command + def regexp + /^\s* l(?:ine)? \s*$/x + end + + def execute + puts "Line #{@state.line} of \"#{@state.file}\"" + end + + def short_description + 'Line number and file name of current position in source file.' + end + + def description + <<-EOD + inf[o] l[ine] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/program.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/program.rb new file mode 100644 index 000000000..7ae8a3955 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/info/program.rb @@ -0,0 +1,51 @@ +module Byebug + # + # Reopens the +info+ command to define the +args+ subcommand + # + class InfoCommand < Command + # + # Information about arguments of the current method/block + # + class ProgramSubcommand < Command + def regexp + /^\s* p(?:rogram)? \s*$/x + end + + def execute + if @state.context.dead? + puts 'The program crashed.' + excpt = Byebug.last_exception + return puts("Exception: #{excpt.inspect}") if excpt + end + + puts 'Program stopped. ' + format_stop_reason @state.context.stop_reason + end + + def short_description + 'Information about the current status of the debugged program.' + end + + def description + <<-EOD + inf[o] p[rogram] + + #{short_description} + EOD + end + + private + + def format_stop_reason(stop_reason) + case stop_reason + when :step + puts "It stopped after stepping, next'ing or initial start." + when :breakpoint + puts 'It stopped at a breakpoint.' + when :catchpoint + puts 'It stopped at a catchpoint.' + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/interrupt.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/interrupt.rb new file mode 100644 index 000000000..c797c9b67 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/interrupt.rb @@ -0,0 +1,28 @@ +require 'byebug/command' + +module Byebug + # + # Interrupting execution of current thread. + # + class InterruptCommand < Command + self.allow_in_control = true + self.allow_in_post_mortem = false + + def regexp + /^\s*i(?:nterrupt)?\s*$/ + end + + def execute + context = Byebug.thread_context(Thread.main) + context.interrupt + end + + def description + <<-EOD + i[nterrupt] + + Interrupts the program. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/irb.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/irb.rb new file mode 100644 index 000000000..0940dc4a2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/irb.rb @@ -0,0 +1,29 @@ +require 'byebug/command' +require 'irb' + +module Byebug + # + # Enter IRB from byebug's prompt + # + class IrbCommand < Command + def regexp + /^\s* irb \s*$/x + end + + def execute + unless @state.interface.is_a?(LocalInterface) + return errmsg(pr('base.errors.only_local')) + end + + IRB.start(__FILE__) + end + + def description + <<-EOD + irb + + Starts an Interactive Ruby (IRB) session. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/kill.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/kill.rb new file mode 100644 index 000000000..6cc0e3920 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/kill.rb @@ -0,0 +1,39 @@ +require 'byebug/command' + +module Byebug + # + # Send custom signals to the debugged program. + # + class KillCommand < Command + self.allow_in_control = true + + def regexp + /^\s* (?:kill) \s* (?:\s+(\S+))? \s*$/x + end + + def execute + if @match[1] + signame = @match[1] + unless Signal.list.member?(signame) + errmsg("signal name #{signame} is not a signal I know about\n") + return false + end + @state.interface.close if 'KILL' == signame + else + return unless confirm('Really kill? (y/n) ') + signame = 'KILL' + end + + Process.kill(signame, Process.pid) + end + + def description + <<-EOD + kill[ signal] + + Send [signal] to Process.pid + Equivalent of Process.kill(Process.pid) + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/list.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/list.rb new file mode 100644 index 000000000..e8ecc6b31 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/list.rb @@ -0,0 +1,155 @@ +require 'byebug/command' +require 'byebug/helpers/file' +require 'byebug/helpers/parse' + +module Byebug + # + # List parts of the source code. + # + class ListCommand < Command + include Helpers::FileHelper + include Helpers::ParseHelper + + def regexp + /^\s* l(?:ist)? (?:\s*([-=])|\s+(\S+))? \s*$/x + end + + def execute + exist = File.exist?(@state.file) + return errmsg "No sourcefile available for #{@state.file}\n" unless exist + + @match ||= match('list') + max_lines = n_lines(@state.file) + b, e = range(@match[2], max_lines) + return errmsg('Invalid line range') unless valid_range?(b, e, max_lines) + + display_lines(b, e) + + @state.prev_line = b + end + + def description + <<-EOD + l[ist][[-=]][ nn-mm] + + Lists lines of code forward from current line or from the place where + code was last listed. If "list-" is specified, lists backwards instead. + If "list=" is specified, lists from current line regardless of where + code was last listed. A line range can also be specified to list + specific sections of code. + EOD + end + + private + + # + # Line range to be printed by `list`. + # + # If is set, range is parsed from it. + # + # Otherwise it's automatically chosen. + # + def range(input, max_line) + size = [Setting[:listsize], max_line].min + + return set_range(size, max_line) unless input + + parse_range(input, size, max_line) + end + + def valid_range?(first, last, max) + first <= last && (1..max).include?(first) && (1..max).include?(last) + end + + # + # Set line range to be printed by list + # + # @param size - number of lines to be printed + # @param max_line - max line number that can be printed + # + # @return first line number to list + # @return last line number to list + # + def set_range(size, max_line) + first = amend(lower(size, @match[1] || '+'), max_line - size + 1) + + [first, move(first, size - 1)] + end + + def parse_range(input, size, max_line) + first, err = get_int(lower_bound(input), 'List', 1, max_line) + return [-1, -1] if err + + if upper_bound(input) + last, = get_int(upper_bound(input), 'List', 1, max_line) + return [-1, -1] unless last + + last = amend(last, max_line) + else + first -= (size / 2) + end + + [first, last || move(first, size - 1)] + end + + def amend(line, max_line) + return 1 if line < 1 + + [max_line, line].min + end + + def lower(size, direction = '+') + return @state.line - size / 2 if direction == '=' || !@state.prev_line + + move(@state.prev_line, size, direction) + end + + def move(line, size, direction = '+') + line.send(direction, size) + end + + # + # Show lines in @state.file from line number to line number . + # + def display_lines(min, max) + puts "\n[#{min}, #{max}] in #{@state.file}" + + File.foreach(@state.file).with_index do |line, lineno| + break if lineno + 1 > max + next unless (min..max).include?(lineno + 1) + + mark = lineno + 1 == @state.line ? '=> ' : ' ' + puts format("#{mark}%#{max.to_s.size}d: %s", lineno + 1, line) + end + end + + private + + # + # @param range [String] A string with an integer range format + # + # @return [String] The lower bound of the given range + # + def lower_bound(range) + split_range(range)[0] + end + + # + # @param range [String] A string with an integer range format + # + # @return [String] The upper bound of the given range + # + def upper_bound(range) + split_range(range)[1] + end + + # + # @param range [String] A string with an integer range format + # + # @return [Array] The upper & lower bounds of the given range + # + def split_range(str) + str.split(/[-,]/) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/method.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/method.rb new file mode 100644 index 000000000..af988a821 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/method.rb @@ -0,0 +1,41 @@ +require 'byebug/command' + +module Byebug + # + # Show methods of specific classes/modules/objects. + # + class MethodCommand < Command + include Columnize + + def regexp + /^\s* m(?:ethod)? \s+ (i(:?nstance)?\s+)?/x + end + + def execute + obj = bb_eval(@match.post_match) + result = + if @match[1] + prc('method.methods', obj.methods.sort) { |item, _| { name: item } } + elsif !obj.is_a?(Module) + pr('variable.errors.not_module', object: @match.post_match) + else + prc('method.methods', obj.instance_methods(false).sort) do |item, _| + { name: item } + end + end + puts result + end + + def description + <<-EOD + m[ethod] (i[nstance][ ]|) + + When invoked with "instance", shows instance methods of the object + specified as argument or of self no object was specified. + + When invoked only with a class or module, shows class methods of the + class or module specified as argument. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/next.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/next.rb new file mode 100644 index 000000000..8cfc799a7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/next.rb @@ -0,0 +1,36 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements the next functionality. + # + # Allows the user the continue execution until the next instruction in the + # current frame. + # + class NextCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + + def regexp + /^\s* n(?:ext)? (?:\s+(\S+))? \s*$/x + end + + def execute + steps, err = parse_steps(@match[1], 'Next') + return errmsg(err) unless steps + + @state.context.step_over(steps, @state.frame) + @state.proceed + end + + def description + <<-EOD + n[ext][ nnn] + + Steps over once or nnn times. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pp.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pp.rb new file mode 100644 index 000000000..1f1f25377 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pp.rb @@ -0,0 +1,41 @@ +require 'English' +require 'pp' +require 'byebug/command' +require 'byebug/helpers/eval' + +module Byebug + # + # Evaluation and pretty printing from byebug's prompt. + # + class PpCommand < Command + include Helpers::EvalHelper + + self.allow_in_control = true + + def regexp + /^\s* pp \s+/x + end + + def execute + out = StringIO.new + run_with_binding do |b| + if Setting[:stack_on_error] + PP.pp(bb_eval(@match.post_match, b), out) + else + PP.pp(bb_warning_eval(@match.post_match, b), out) + end + end + puts out.string + rescue + out.puts $ERROR_INFO.message + end + + def description + <<-EOD + pp + + Evaluates and pretty-prints its value. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pry.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pry.rb new file mode 100644 index 000000000..69e1aac14 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/pry.rb @@ -0,0 +1,34 @@ +require 'byebug/command' + +module Byebug + # + # Enter Pry from byebug's prompt + # + class PryCommand < Command + def regexp + /^\s* pry \s*$/x + end + + def execute + unless @state.interface.is_a?(LocalInterface) + return errmsg(pr('base.errors.only_local')) + end + + begin + require 'pry' + rescue LoadError + errmsg(pr('pry.errors.not_installed')) + end + + get_binding.pry + end + + def description + <<-EOD + pry + + Starts a Pry session. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/ps.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/ps.rb new file mode 100644 index 000000000..c91042e13 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/ps.rb @@ -0,0 +1,44 @@ +require 'English' +require 'pp' +require 'byebug/command' +require 'byebug/helpers/eval' + +module Byebug + # + # Evaluation, pretty printing, columnizing and sorting from byebug's prompt + # + class PsCommand < Command + include Helpers::EvalHelper + include Columnize + + self.allow_in_control = true + + def regexp + /^\s* ps \s+/x + end + + def execute + out = StringIO.new + run_with_binding do |b| + res = eval_with_setting(b, @match.post_match, Setting[:stack_on_error]) + + if res.is_a?(Array) + puts "#{columnize(res.map(&:to_s).sort!, Setting[:width])}" + else + PP.pp(res, out) + puts out.string + end + end + rescue + out.puts $ERROR_INFO.message + end + + def description + <<-EOD + ps + + Evaluates , an array, sort and columnize its value. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/putl.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/putl.rb new file mode 100644 index 000000000..cce7dd6dd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/putl.rb @@ -0,0 +1,43 @@ +require 'pp' +require 'byebug/command' +require 'byebug/helpers/eval' + +module Byebug + # + # Evaluation, pretty printing and columnizing from byebug's prompt. + # + class PutlCommand < Command + include Helpers::EvalHelper + include Columnize + + self.allow_in_control = true + + def regexp + /^\s* putl (?:\s+ (.+))? \s*$/x + end + + def execute + out = StringIO.new + run_with_binding do |b| + res = eval_with_setting(b, @match[1], Setting[:stack_on_error]) + + if res.is_a?(Array) + puts "#{columnize(res.map(&:to_s), Setting[:width])}" + else + PP.pp(res, out) + puts out.string + end + end + rescue + out.puts $ERROR_INFO.message + end + + def description + <<-EOD + putl + + Evaluates , an array, and columnize its value. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/quit.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/quit.rb new file mode 100644 index 000000000..ab054a254 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/quit.rb @@ -0,0 +1,34 @@ +require 'byebug/command' + +module Byebug + # + # Exit from byebug. + # + class QuitCommand < Command + self.allow_in_control = true + + def regexp + /^\s* q(?:uit)? \s* (?:(!|\s+unconditionally))? \s*$/x + end + + def execute + return unless @match[1] || confirm(pr('quit.confirmations.really')) + + @state.interface.autosave + @state.interface.close + exit! # exit -> exit!: No graceful way to stop... + end + + def description + <<-EOD + q[uit] [!|unconditionally] + + Exits from byebug. + + Normally we prompt before exiting. However if the parameter + "unconditionally" is given or command is suffixed with !, we exit + without asking further questions. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/restart.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/restart.rb new file mode 100644 index 000000000..824cb958e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/restart.rb @@ -0,0 +1,41 @@ +require 'byebug/command' + +module Byebug + # + # Restart debugged program from within byebug. + # + class RestartCommand < Command + self.allow_in_control = true + + def regexp + /^\s* (?:restart|R) (?:\s+(?.+))? \s*$/x + end + + def execute + if Byebug.mode == :standalone + cmd = "#{Gem.bin_path('byebug', 'byebug')} #{$PROGRAM_NAME}" + else + cmd = $PROGRAM_NAME + end + + if @match[:args] + cmd += " #{@match[:args]}" + else + require 'shellwords' + cmd += " #{$ARGV.compact.shelljoin}" + end + + puts pr('restart.success', cmd: cmd) + exec(cmd) + end + + def description + <<-EOD + restart|R [args] + + Restart the program. This is a re-exec - all byebug state + is lost. If command arguments are passed those are used. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/save.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/save.rb new file mode 100644 index 000000000..728adcac4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/save.rb @@ -0,0 +1,62 @@ +require 'byebug/command' + +module Byebug + # + # Save current settings to use them in another debug session. + # + class SaveCommand < Command + self.allow_in_control = true + + def regexp + /^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x + end + + def execute + file = File.open(@match[1] || Setting[:savefile], 'w') + + save_breakpoints(file) + save_catchpoints(file) + save_displays(file) + save_settings(file) + + print pr('save.messages.done', path: file.path) + file.close + end + + def description + <<-EOD + save[ FILE] + + Saves current byebug state to FILE as a script file. This includes + breakpoints, catchpoints, display expressions and some settings. If no + filename is given, we will fabricate one. + + Use the "source" command in another debug session to restore them. + EOD + end + + private + + def save_breakpoints(file) + Byebug.breakpoints.each do |b| + file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}" + end + end + + def save_catchpoints(file) + Byebug.catchpoints.keys.each do |c| + file.puts "catch #{c}" + end + end + + def save_displays(file) + @state.display.each { |d| file.puts "display #{d[1]}" if d[0] } + end + + def save_settings(file) + %w(autoeval autoirb autolist basename).each do |setting| + file.puts "set #{setting} #{Setting[setting.to_sym]}" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/set.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/set.rb new file mode 100644 index 000000000..4ed112194 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/set.rb @@ -0,0 +1,70 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Change byebug settings. + # + class SetCommand < Command + include Helpers::ParseHelper + + self.allow_in_control = true + + def regexp + /^\s* set (?:\s+(?\w+))? (?:\s+(?\S+))? \s*$/x + end + + def execute + key = @match[:setting] + value = @match[:value] + return puts(help) if key.nil? && value.nil? + + setting = Setting.find(key) + return errmsg(pr('set.errors.unknown_setting', key: key)) unless setting + + if !setting.boolean? && value.nil? + err = pr('set.errors.must_specify_value', key: key) + elsif setting.boolean? + value, err = get_onoff(value, key =~ /^no/ ? false : true) + elsif setting.integer? + value, err = get_int(value, setting.to_sym, 1) + end + return errmsg(err) if value.nil? + + setting.value = value + + puts setting.to_s + end + + def get_onoff(arg, default) + return default if arg.nil? + + case arg + when '1', 'on', 'true' + true + when '0', 'off', 'false' + false + else + [nil, pr('set.errors.on_off', arg: arg)] + end + end + + def help + description + Setting.help_all + end + + def description + <<-EOD + set + + Modifies parts of byebug environment. + + Boolean values take "on", "off", "true", "false", "1" or "0". If you + don't specify a value, the boolean setting will be enabled. Conversely, + you can use "set no" to disable them. + + You can see these environment settings with the "show" command. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/show.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/show.rb new file mode 100644 index 000000000..665bfd084 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/show.rb @@ -0,0 +1,37 @@ +require 'byebug/command' + +module Byebug + # + # Show byebug settings. + # + class ShowCommand < Command + self.allow_in_control = true + + def regexp + /^\s* show (?:\s+(?\w+))? \s*$/x + end + + def execute + key = @match[:setting] + return puts(help) unless key + + setting = Setting.find(key) + return errmsg(pr('show.errors.unknown_setting', key: key)) unless setting + + puts Setting.settings[setting.to_sym] + end + + def help + description + Setting.help_all + end + + def description + <<-EOD + show + + Generic command for showing byebug settings. You can change them with + the "set" command. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/source.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/source.rb new file mode 100644 index 000000000..5da00951b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/source.rb @@ -0,0 +1,39 @@ +require 'byebug/command' + +module Byebug + # + # Execute a file containing byebug commands. + # + # It can be used to restore a previously saved debugging session. + # + class SourceCommand < Command + self.allow_in_control = true + + def regexp + /^\s* so(?:urce)? (?:\s+(\S+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + unless @state && @state.interface + return errmsg(pr('source.errors.not_available')) + end + + file = File.expand_path(@match[1]).strip + unless File.exist?(file) + return errmsg(pr('source.errors.not_found', file: file)) + end + + @state.interface.read_file(file) + end + + def description + <<-EOD + source + + Executes file containing byebug commands. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/step.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/step.rb new file mode 100644 index 000000000..221451fbe --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/step.rb @@ -0,0 +1,36 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Implements the step functionality. + # + # Allows the user the continue execution until the next instruction, possibily + # in a different frame. Use step to step into method calls or blocks. + # + class StepCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + + def regexp + /^\s* s(?:tep)? (?:\s+(\S+))? \s*$/x + end + + def execute + steps, err = parse_steps(@match[1], 'Steps') + return errmsg(err) unless steps + + @state.context.step_into(steps, @state.frame) + @state.proceed + end + + def description + <<-EOD + s[tep][ nnn] + + Steps (into methods) once or nnn times. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread.rb new file mode 100644 index 000000000..3604534ed --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread.rb @@ -0,0 +1,28 @@ +require 'byebug/subcommands' + +require 'byebug/commands/thread/current' +require 'byebug/commands/thread/list' +require 'byebug/commands/thread/resume' +require 'byebug/commands/thread/stop' +require 'byebug/commands/thread/switch' + +module Byebug + # + # Manipulation of Ruby threads + # + class ThreadCommand < Command + include Subcommands + + def regexp + /^\s* th(?:read)? (?:\s+ (.+))? \s*$/x + end + + def description + <<-EOD + th]read + + Commands to manipulate threads. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/current.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/current.rb new file mode 100644 index 000000000..a6fa85af5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/current.rb @@ -0,0 +1,35 @@ +require 'byebug/helpers/thread' + +module Byebug + # + # Reopens the +thread+ command to define the +current+ subcommand + # + class ThreadCommand < Command + # + # Information about the current thread + # + class CurrentSubcommand < Command + include Helpers::ThreadHelper + + def regexp + /^\s* c(?:urrent)? \s*$/x + end + + def execute + display_context(@state.context) + end + + def short_description + 'Shows current thread information' + end + + def description + <<-EOD + th[read] c[urrent] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/list.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/list.rb new file mode 100644 index 000000000..a2faa73a3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/list.rb @@ -0,0 +1,41 @@ +require 'byebug/helpers/thread' + +module Byebug + # + # Reopens the +thread+ command to define the +list+ subcommand + # + class ThreadCommand < Command + # + # Information about threads + # + class ListSubcommand < Command + include Helpers::ThreadHelper + + def regexp + /^\s* l(?:ist)? \s*$/x + end + + def execute + contexts = Byebug.contexts.sort_by(&:thnum) + + thread_list = prc('thread.context', contexts) do |context, _| + thread_arguments(context) + end + + print(thread_list) + end + + def short_description + 'Lists all threads' + end + + def description + <<-EOD + th[read] l[ist] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/resume.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/resume.rb new file mode 100644 index 000000000..b736d6dec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/resume.rb @@ -0,0 +1,45 @@ +require 'byebug/helpers/thread' + +module Byebug + # + # Reopens the +thread+ command to define the +resume+ subcommand + # + class ThreadCommand < Command + # + # Resumes the specified thread + # + class ResumeSubcommand < Command + include Helpers::ThreadHelper + + def regexp + /^\s* r(?:esume)? (?: \s* (\d+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + context, err = context_from_thread(@match[1]) + return errmsg(err) if err + + unless context.suspended? + return errmsg(pr('thread.errors.already_running')) + end + + context.resume + display_context(context) + end + + def short_description + 'Resumes execution of the specified thread' + end + + def description + <<-EOD + th[read] r[esume] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/stop.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/stop.rb new file mode 100644 index 000000000..1f841e99c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/stop.rb @@ -0,0 +1,41 @@ +require 'byebug/helpers/thread' + +module Byebug + # + # Reopens the +thread+ command to define the +stop+ subcommand + # + class ThreadCommand < Command + # + # Stops the specified thread + # + class StopSubcommand < Command + include Helpers::ThreadHelper + + def regexp + /^\s* st(?:op)? (?: \s* (\d+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + context, err = context_from_thread(@match[1]) + return errmsg(err) if err + + context.suspend + display_context(context) + end + + def short_description + 'Stops the execution of the specified thread' + end + + def description + <<-EOD + th[read] st[op] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/switch.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/switch.rb new file mode 100644 index 000000000..e271e2e32 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/thread/switch.rb @@ -0,0 +1,43 @@ +require 'byebug/helpers/thread' + +module Byebug + # + # Reopens the +thread+ command to define the +switch+ subcommand + # + class ThreadCommand < Command + # + # Switches to the specified thread + # + class SwitchSubcommand < Command + include Helpers::ThreadHelper + + def regexp + /^\s* sw(?:itch)? (?: \s* (\d+))? \s*$/x + end + + def execute + return puts(help) unless @match[1] + + context, err = context_from_thread(@match[1]) + return errmsg(err) if err + + display_context(context) + + context.switch + @state.proceed + end + + def short_description + 'Switches execution to the specified thread' + end + + def description + <<-EOD + th[read] sw[itch] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/tracevar.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/tracevar.rb new file mode 100644 index 000000000..26332e10f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/tracevar.rb @@ -0,0 +1,51 @@ +require 'byebug/command' + +module Byebug + # + # Show (and possibily stop) at every line that changes a global variable. + # + class TracevarCommand < Command + self.allow_in_post_mortem = false + + def regexp + /^\s* tr(?:acevar)? (?: \s+ (\S+))? # (variable-name)? + (?: \s+ (stop|nostop))? + \s*$/x + end + + def execute + var = @match[1] + return errmsg(pr('trace.errors.needs_global_variable')) unless var + + unless global_variables.include?(:"#{var}") + return errmsg(pr('trace.errors.var_is_not_global', name: var)) + end + + stop = @match[2] && @match[2] !~ /nostop/ + + instance_eval do + trace_var(:"#{var}") { |val| on_change(var, val, stop) } + end + + puts pr('trace.messages.success', var: var) + end + + def on_change(name, value, stop) + puts pr('trace.messages.on_change', name: name, value: value) + + @state.context.step_out(1, false) if stop + end + + def description + <<-EOD + tr[acevar] [[no]stop] + + Start tracing variable . + + If "stop" is specified, execution will stop every time the variable + changes its value. If nothing or "nostop" is specified, execution won't + stop, changes will just be logged in byebug's output. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/undisplay.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/undisplay.rb new file mode 100644 index 000000000..de3145da6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/undisplay.rb @@ -0,0 +1,46 @@ +require 'byebug/command' +require 'byebug/helpers/parse' + +module Byebug + # + # Remove expressions from display list. + # + class UndisplayCommand < Command + include Helpers::ParseHelper + + self.allow_in_post_mortem = false + + def regexp + /^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x + end + + def execute + if @match[1] + pos, err = get_int(@match[1], 'Undisplay', 1, @state.display.size) + return errmsg(err) unless err.nil? + + unless @state.display[pos - 1] + return errmsg(pr('display.errors.undefined', expr: pos)) + end + + @state.display[pos - 1][0] = nil + else + return unless confirm(pr('display.confirmations.clear_all')) + + @state.display.each { |d| d[0] = false } + end + end + + def description + <<-EOD + undisp[lay][ nnn] + + Cancel some expressions to be displayed when program stops. Arguments + are the code numbers of the expressions to stop displaying. No argument + means cancel all automatic-display expressions. "delete display" has the + same effect as this command. Do "info display" to see the current list + of code numbers. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/untracevar.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/untracevar.rb new file mode 100644 index 000000000..9934205d5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/untracevar.rb @@ -0,0 +1,32 @@ +require 'byebug/command' + +module Byebug + # + # Stop tracing a global variable. + # + class UntracevarCommand < Command + self.allow_in_post_mortem = false + + def regexp + /^\s* untr(?:acevar)? (?:\s+ (\S+))? \s*$/x + end + + def execute + var = @match[1] + if global_variables.include?(:"#{var}") + untrace_var(:"#{var}") + puts pr('trace.messages.undo', var: var) + else + errmsg pr('trace.errors.not_global', var: var) + end + end + + def description + <<-EOD + untr[acevar] + + Stop tracing global variable . + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/up.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/up.rb new file mode 100644 index 000000000..d6c01c19f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/up.rb @@ -0,0 +1,39 @@ +# encoding: utf-8 + +require 'pathname' +require 'byebug/command' +require 'byebug/helpers/frame' +require 'byebug/helpers/parse' + +module Byebug + # + # Move the current frame up in the backtrace. + # + class UpCommand < Command + include Helpers::FrameHelper + include Helpers::ParseHelper + + def regexp + /^\s* u(?:p)? (?:\s+(\S+))? \s*$/x + end + + def execute + pos, err = parse_steps(@match[1], 'Up') + return errmsg(err) unless pos + + adjust_frame(pos, false) + + ListCommand.new(@state).execute if Setting[:autolist] + end + + def description + <<-EOD + up[ count] + + Move to a higher frame in the stack trace. + + Use the "bt" command to find out where you want to go. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var.rb new file mode 100644 index 000000000..73f71d25f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var.rb @@ -0,0 +1,28 @@ +require 'byebug/subcommands' + +require 'byebug/commands/var/all' +require 'byebug/commands/var/const' +require 'byebug/commands/var/instance' +require 'byebug/commands/var/local' +require 'byebug/commands/var/global' + +module Byebug + # + # Shows variables and its values + # + class VarCommand < Command + include Subcommands + + def regexp + /^\s* v(?:ar)? (?:\s+ (.+))? \s*$/x + end + + def description + <<-EOD + [v]ar + + Shows variables and its values. + EOD + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/all.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/all.rb new file mode 100644 index 000000000..c20f48391 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/all.rb @@ -0,0 +1,37 @@ +require 'byebug/helpers/var' + +module Byebug + # + # Reopens the +var+ command to define the +all+ subcommand + # + class VarCommand < Command + # + # Shows global, instance and local variables + # + class AllSubcommand < Command + include Helpers::VarHelper + + def regexp + /^\s* a(?:ll)? \s*$/x + end + + def execute + var_global + var_instance('self') + var_local + end + + def short_description + 'Shows local, global and instance variables of self.' + end + + def description + <<-EOD + v[ar] a[ll] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/const.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/const.rb new file mode 100644 index 000000000..dd7a62701 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/const.rb @@ -0,0 +1,38 @@ +module Byebug + # + # Reopens the +var+ command to define the +const+ subcommand + # + class VarCommand < Command + # + # Shows constants + # + class ConstSubcommand < Command + def regexp + /^\s* c(?:onst)? (?:\s+ (.+))? \s*$/x + end + + def execute + str_obj = @match[1] || 'self.class' + obj = bb_warning_eval(str_obj) + unless obj.is_a?(Module) + return errmsg(pr('variable.errors.not_module', object: str_obj)) + end + + constants = bb_eval("#{str_obj}.constants") + puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, 'constant') + end + + def short_description + 'Shows constants of an object.' + end + + def description + <<-EOD + v[ar] c[onstant] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/global.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/global.rb new file mode 100644 index 000000000..c486aecdd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/global.rb @@ -0,0 +1,33 @@ +module Byebug + # + # Reopens the +var+ command to define the +global+ subcommand + # + class VarCommand < Command + # + # Shows global variables + # + class GlobalSubcommand < Command + include Helpers::VarHelper + + def regexp + /^\s* g(?:lobal)? \s*$/x + end + + def execute + var_global + end + + def short_description + 'Shows global variables.' + end + + def description + <<-EOD + v[ar] g[lobal] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/instance.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/instance.rb new file mode 100644 index 000000000..61e2bebae --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/instance.rb @@ -0,0 +1,35 @@ +require 'byebug/helpers/var' + +module Byebug + # + # Reopens the +var+ command to define the +instance+ subcommand + # + class VarCommand < Command + # + # Shows instance variables + # + class InstanceSubcommand < Command + include Helpers::VarHelper + + def regexp + /^\s* i(?:nstance)? (?:\s+ (.+))? \s*$/x + end + + def execute + var_instance(@match[1]) + end + + def short_description + 'Shows instance variables of self or a specific object.' + end + + def description + <<-EOD + v[ar] i[nstance][ ] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/local.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/local.rb new file mode 100644 index 000000000..eae085380 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/var/local.rb @@ -0,0 +1,35 @@ +require 'byebug/helpers/var' + +module Byebug + # + # Reopens the +var+ command to define the +local+ subcommand + # + class VarCommand < Command + # + # Shows local variables in current scope + # + class LocalSubcommand < Command + include Helpers::VarHelper + + def regexp + /^\s* l(?:ocal)? \s*$/x + end + + def execute + var_local + end + + def short_description + 'Shows local variables in current scope.' + end + + def description + <<-EOD + v[ar] l[ocal] + + #{short_description} + EOD + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/where.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/where.rb new file mode 100644 index 000000000..2cec04651 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/commands/where.rb @@ -0,0 +1,47 @@ +# encoding: utf-8 + +require 'pathname' +require 'byebug/command' +require 'byebug/helpers/frame' + +module Byebug + # + # Show current backtrace. + # + class WhereCommand < Command + include Helpers::FrameHelper + + def regexp + /^\s* (?:w(?:here)?|bt|backtrace) \s*$/x + end + + def execute + print_backtrace + end + + def description + <<-EOD + w[here]|bt|backtrace + + Display stack frames. + + Print the entire stack frame. Each frame is numbered; the most recent + frame is 0. A frame number can be referred to in the "frame" command. + "up" and "down" add or subtract respectively to frame numbers shown. + The position of the current frame is marked with -->. C-frames hang + from their most immediate Ruby frame to indicate that they are not + navigable. + EOD + end + + private + + def print_backtrace + bt = prc('frame.line', (0...@state.context.stack_size)) do |_, index| + get_pr_arguments(index) + end + + print(bt) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/context.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/context.rb new file mode 100644 index 000000000..545fc4c3a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/context.rb @@ -0,0 +1,126 @@ +module Byebug + # + # Mantains context information for the debugger and it's the main + # communication point between the library and the C-extension through the + # at_breakpoint, at_catchpoint, at_tracing, at_line and at_return callbacks + # + class Context + # + # List of files byebug will ignore while debugging + # + def self.ignored_files + Byebug.mode == :standalone ? lib_files + [bin_file] : lib_files + end + + def self.bin_file + @bin_file ||= Gem.bin_path('byebug', 'byebug') + end + + def self.lib_files + @lib_files ||= Dir.glob(File.expand_path('../../**/*.rb', __FILE__)) + end + + # + # Tells whether a file is ignored by the debugger. + # + # @param path [String] filename to be checked. + # + def ignored_file?(path) + self.class.ignored_files.include?(path) + end + + # + # Context's stack size + # + def stack_size + return 0 unless backtrace + + backtrace.drop_while { |l| ignored_file?(l.first.path) } + .take_while { |l| !ignored_file?(l.first.path) } + .size + end + + def interrupt + step_into 1 + end + + # + # Gets local variables for a frame. + # + # @param frame_no Frame index in the backtrace. Defaults to 0. + # + # TODO: Use brand new local_variable_{get,set,defined?} for rubies >= 2.1 + # + def frame_locals(frame_no = 0) + bind = frame_binding(frame_no) + return [] unless bind + + bind.eval('local_variables.inject({}){|h, v| h[v] = eval(v.to_s); h}') + end + + # + # Gets current method arguments for a frame. + # + # @param frame_no Frame index in the backtrace. Defaults to 0. + # + def frame_args(frame_no = 0) + bind = frame_binding(frame_no) + return c_frame_args(frame_no) unless bind + + ruby_frame_args(bind) + end + + def handler + Byebug.handler || fail('No interface loaded') + end + + def at_breakpoint(brkpnt) + handler.at_breakpoint(self, brkpnt) + end + + def at_catchpoint(excpt) + handler.at_catchpoint(self, excpt) + end + + def at_tracing(file, line) + handler.at_tracing(self, file, line) unless ignored_file?(file) + end + + def at_line(file, line) + handler.at_line(self, file, line) unless ignored_file?(file) + end + + def at_return(file, line) + handler.at_return(self, file, line) unless ignored_file?(file) + end + + private + + # + # Gets method arguments for a c-frame. + # + # @param frame_no Frame index in the backtrace. + # + def c_frame_args(frame_no) + myself = frame_self(frame_no) + return [] unless myself.to_s != 'main' + + myself.method(frame_method(frame_no)).parameters + end + + # + # Gets method arguments for a ruby-frame. + # + # @param bind Binding for the ruby-frame. + # + def ruby_frame_args(bind) + return [] unless bind.eval('__method__') + + bind.eval('method(__method__).parameters') + rescue NameError => e + Byebug.errmsg \ + "Exception #{e.class} (#{e.message}) while retreving frame params" + [] + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/core.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/core.rb new file mode 100644 index 000000000..8208ad853 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/core.rb @@ -0,0 +1,86 @@ +require 'byebug/byebug' +require 'byebug/version' +require 'byebug/context' +require 'byebug/breakpoint' +require 'byebug/interface' +require 'byebug/processor' +require 'byebug/remote' +require 'byebug/printers/plain' + +module Byebug + extend self + + # + # Configuration file used for startup commands. Default value is .byebugrc + # + INIT_FILE = '.byebugrc' unless defined?(INIT_FILE) + + # + # Main debugger's processor + # + attr_accessor :handler + self.handler = CommandProcessor.new + + extend Forwardable + def_delegators :handler, :errmsg, :puts + + # + # Main debugger's printer + # + attr_accessor :printer + self.printer = Printers::Plain.new + + # + # Running mode of the debugger. Can be either: + # + # * :attached => Attached to a running program through the `byebug` method. + # * :standalone => Started through `bin/byebug` script. + # + attr_accessor :mode + + # + # Runs normal byebug initialization scripts. + # + # Reads and executes the commands from init file (if any) in the current + # working directory. This is only done if the current directory is different + # from your home directory. Thus, you can have more than one init file, one + # generic in your home directory, and another, specific to the program you + # are debugging, in the directory where you invoke byebug. + # + def run_init_script + home_rc = File.expand_path(File.join(ENV['HOME'].to_s, INIT_FILE)) + run_script(home_rc) if File.exist?(home_rc) + + cwd_rc = File.expand_path(File.join('.', INIT_FILE)) + run_script(cwd_rc) if File.exist?(cwd_rc) && cwd_rc != home_rc + end + + # + # A Byebug command is a class defined right under the Byebug module and + # named Command + # + def commands + const_list = constants.map { |const| const_get(const, false) } + + const_list.select { |c| c.is_a?(Class) && c.name =~ /[a-z]Command$/ } + end + + private + + # + # Runs a script file + # + def run_script(file, verbose = false) + interface = ScriptInterface.new(file, verbose) + processor = ControlCommandProcessor.new(interface) + processor.process_commands + end +end + +# +# Extends the extension class to be able to pass information about the +# debugging environment from the c-extension to the user. +# +class Exception + attr_reader :__bb_file, :__bb_line, :__bb_binding, :__bb_context +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/eval.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/eval.rb new file mode 100644 index 000000000..ecb369f58 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/eval.rb @@ -0,0 +1,47 @@ +module Byebug + module Helpers + # + # Utilities used by the eval command + # + module EvalHelper + # + # Run block temporarily ignoring all TracePoint events. + # + # Used to evaluate stuff within Byebug's prompt. Otherwise, any code + # creating new threads won't be properly evaluated because new threads + # will get blocked by byebug's main thread. + # + def allowing_other_threads + Byebug.unlock + res = yield + Byebug.lock + res + end + + # + # Get current binding and yield it to the given block + # + def run_with_binding + binding = get_binding + yield binding + end + + # + # Evaluate +expression+ using +binding+ + # + # @param binding [Binding] Context where to evaluate the expression + # @param expression [String] Expression to evaluation + # @param stack_on_error [Boolean] Whether to show a stack trace on error. + # + def eval_with_setting(binding, expression, stack_on_error) + allowing_other_threads do + if stack_on_error + bb_eval(expression, binding) + else + bb_warning_eval(expression, binding) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/file.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/file.rb new file mode 100644 index 000000000..e10182fe4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/file.rb @@ -0,0 +1,46 @@ +module Byebug + module Helpers + # + # Utilities for interaction with files + # + module FileHelper + # + # Reads lines of source file +filename+ into an array + # + def get_lines(filename) + File.foreach(filename).reduce([]) { |a, e| a << e.chomp } + end + + # + # Reads line number +lineno+ from file named +filename+ + # + def get_line(filename, lineno) + File.open(filename) do |f| + f.gets until f.lineno == lineno - 1 + f.gets + end + end + + # + # Returns the number of lines in file +filename+ in a portable, + # one-line-at-a-time way. + # + def n_lines(filename) + File.foreach(filename).reduce(0) { |a, _e| a + 1 } + end + + # + # Regularize file name. + # + def normalize(filename) + return filename if ['(irb)', '-e'].include?(filename) + + return File.basename(filename) if Setting[:basename] + + path = File.expand_path(filename) + + File.exist?(path) ? File.realpath(path) : filename + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/frame.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/frame.rb new file mode 100644 index 000000000..2c8f3c7a8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/frame.rb @@ -0,0 +1,76 @@ +module Byebug + module Helpers + # + # Utilities to assist frame navigation + # + module FrameHelper + def switch_to_frame(frame_no) + frame_no >= 0 ? frame_no : @state.context.stack_size + frame_no + end + + def navigate_to_frame(jump_no) + return if jump_no == 0 + + current_jumps = 0 + current_pos = @state.frame + + loop do + current_pos += direction(jump_no) + break if current_pos < 0 || current_pos >= @state.context.stack_size + + next if @state.c_frame?(current_pos) + + current_jumps += 1 + break if current_jumps == jump_no.abs + end + + current_pos + end + + def adjust_frame(frame, absolute) + if absolute + abs_frame = switch_to_frame(frame) + if @state.c_frame?(abs_frame) + return errmsg(pr('frame.errors.c_frame')) + end + else + abs_frame = navigate_to_frame(frame) + end + + if abs_frame >= @state.context.stack_size + return errmsg(pr('frame.errors.too_low')) + elsif abs_frame < 0 + return errmsg(pr('frame.errors.too_high')) + end + + @state.frame = abs_frame + @state.file = @state.context.frame_file(@state.frame) + @state.line = @state.context.frame_line(@state.frame) + @state.prev_line = nil + end + + def get_pr_arguments(frame_no) + file = @state.frame_file(frame_no) + full_path = File.expand_path(file) + line = @state.frame_line(frame_no) + call = @state.frame_call(frame_no) + mark = @state.frame_mark(frame_no) + pos = @state.frame_pos(frame_no) + + { mark: mark, pos: pos, call: call, file: file, line: line, + full_path: full_path } + end + + private + + # + # @param [Integer] A positive or negative integer + # + # @return [Integer] +1 if step is positive / -1 if negative + # + def direction(step) + step / step.abs + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/parse.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/parse.rb new file mode 100644 index 000000000..1cecfed40 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/parse.rb @@ -0,0 +1,74 @@ +module Byebug + module Helpers + # + # Utilities to assist command parsing + # + module ParseHelper + # + # Parses +str+ of command +cmd+ as an integer between +min+ and +max+. + # + # If either +min+ or +max+ is nil, that value has no bound. + # + # TODO: Remove the `cmd` parameter. It has nothing to do with the methods + # purpose. + # + def get_int(str, cmd, min = nil, max = nil) + if str !~ /\A-?[0-9]+\z/ + err = pr('parse.errors.int.not_number', cmd: cmd, str: str) + return nil, errmsg(err) + end + + int = str.to_i + if min && int < min + err = pr('parse.errors.int.too_low', cmd: cmd, str: str, min: min) + return min, errmsg(err) + elsif max && int > max + err = pr('parse.errors.int.too_high', cmd: cmd, str: str, max: max) + return max, errmsg(err) + end + + int + end + + # + # @return true if code is syntactically correct for Ruby, false otherwise + # + def syntax_valid?(code) + return true unless code + + without_stderr do + begin + RubyVM::InstructionSequence.compile(code) + true + rescue SyntaxError + false + end + end + end + + # + # Temporarily disable output to $stderr + # + def without_stderr + stderr = $stderr + $stderr.reopen(IO::NULL) + + yield + ensure + $stderr.reopen(stderr) + end + + # + # @return +str+ as an integer or 1 if +str+ is empty. + # + def parse_steps(str, cmd) + return 1 unless str + + steps, err = get_int(str, cmd, 1) + return nil, err unless steps + + steps + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/string.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/string.rb new file mode 100644 index 000000000..0700afbce --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/string.rb @@ -0,0 +1,24 @@ +module Byebug + module Helpers + # + # Utilities for interaction with strings + # + module StringHelper + # + # Converts +str+ from an_underscored-or-dasherized_string to + # ACamelizedString. + # + def camelize(str) + str.dup.split(/[_-]/).map(&:capitalize).join('') + end + + # + # Improves indentation and spacing in +str+ for readability in Byebug's + # command prompt. + # + def prettify(str) + "\n" + str.gsub(/^ {6}/, '') + "\n" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/thread.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/thread.rb new file mode 100644 index 000000000..0556b709c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/thread.rb @@ -0,0 +1,53 @@ +module Byebug + module Helpers + # + # Utilities for thread subcommands + # + module ThreadHelper + def display_context(context) + puts pr('thread.context', thread_arguments(context)) + end + + def thread_arguments(context) + status_flag = if context.suspended? + '$' + else + context.thread == Thread.current ? '+' : ' ' + end + debug_flag = context.ignored? ? '!' : ' ' + + if context == Byebug.current_context + file_line = "#{@state.file}:#{@state.line}" + else + backtrace = context.thread.backtrace_locations + if backtrace && backtrace[0] + file_line = "#{backtrace[0].path}:#{backtrace[0].lineno}" + end + end + + { + status_flag: status_flag, + debug_flag: debug_flag, + id: context.thnum, + thread: context.thread.inspect, + file_line: file_line || '', + pid: Process.pid, + status: context.thread.status, + current: (context.thread == Thread.current) + } + end + + def context_from_thread(thnum) + ctx = Byebug.contexts.find { |c| c.thnum.to_s == thnum } + + err = case + when ctx.nil? then pr('thread.errors.no_thread') + when ctx == @state.context then pr('thread.errors.current_thread') + when ctx.ignored? then pr('thread.errors.ignored', arg: thnum) + end + + [ctx, err] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/toggle.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/toggle.rb new file mode 100644 index 000000000..e33046dc1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/toggle.rb @@ -0,0 +1,56 @@ +require 'byebug/helpers/parse' + +module Byebug + module Helpers + # + # Utilities to assist breakpoint/display enabling/disabling. + # + module ToggleHelper + include ParseHelper + + def enable_disable_breakpoints(is_enable, args) + return errmsg(pr('toggle.errors.no_breakpoints')) if Breakpoint.none? + + all_breakpoints = Byebug.breakpoints.sort_by(&:id) + if args.nil? + selected_breakpoints = all_breakpoints + else + selected_ids = [] + args.split(/ +/).each do |pos| + last_id = all_breakpoints.last.id + pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id) + return errmsg(err) unless pos + + selected_ids << pos + end + selected_breakpoints = all_breakpoints.select do |b| + selected_ids.include?(b.id) + end + end + + selected_breakpoints.each do |b| + enabled = ('enable' == is_enable) + if enabled && !syntax_valid?(b.expr) + return errmsg(pr('toggle.errors.expression', expr: b.expr)) + end + + b.enabled = enabled + end + end + + def enable_disable_display(is_enable, args) + display = @state.display + return errmsg(pr('toggle.errors.no_display')) if 0 == display.size + + selected_displays = args.nil? ? [1..display.size + 1] : args.split(/ +/) + + selected_displays.each do |pos| + pos, err = get_int(pos, "#{is_enable} display", 1, display.size) + return errmsg(err) unless err.nil? + + display[pos - 1][0] = ('enable' == is_enable) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/var.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/var.rb new file mode 100644 index 000000000..1b303c4f7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/helpers/var.rb @@ -0,0 +1,45 @@ +module Byebug + module Helpers + # + # Utilities for variable subcommands + # + module VarHelper + def var_list(ary, b = get_binding) + vars = ary.sort.map do |v| + s = begin + b.eval(v.to_s).inspect + rescue + begin + b.eval(v.to_s).to_s + rescue + '*Error in evaluation*' + end + end + [v, s] + end + puts prv(vars, 'instance') + end + + def var_global + globals = global_variables.reject do |v| + [:$IGNORECASE, :$=, :$KCODE, :$-K, :$binding].include?(v) + end + + var_list(globals) + end + + def var_instance(str) + obj = bb_warning_eval(str || 'self') + + var_list(obj.instance_variables, obj.instance_eval { binding }) + end + + def var_local + locals = @state.context.frame_locals + cur_self = @state.context.frame_self(@state.frame) + locals[:self] = cur_self unless cur_self.to_s == 'main' + puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, 'instance') + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/history.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/history.rb new file mode 100644 index 000000000..d4e93c33d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/history.rb @@ -0,0 +1,121 @@ +begin + require 'readline' +rescue LoadError + warn <<-EOW + Sorry, you can't use byebug without Readline. To solve this, you need to + rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get + install libreadline-dev` and then reinstall your Ruby. + EOW + + raise +end + +module Byebug + # + # Handles byebug's history of commands. + # + class History + attr_accessor :size + + def initialize + self.size = 0 + end + + # + # Restores history from disk. + # + def restore + return unless File.exist?(Setting[:histfile]) + + File.readlines(Setting[:histfile]).reverse_each { |l| push(l.chomp) } + end + + # + # Saves history to disk. + # + def save + n_cmds = Setting[:histsize] > size ? size : Setting[:histsize] + + open(Setting[:histfile], 'w') do |file| + n_cmds.times { file.puts(pop) } + end + + clear + end + + # + # Discards history. + # + def clear + size.times { pop } + end + + # + # Adds a new command to Readline's history. + # + def push(cmd) + return if ignore?(cmd) + + self.size += 1 + Readline::HISTORY.push(cmd) + end + + # + # Removes a command from Readline's history. + # + def pop + self.size -= 1 + Readline::HISTORY.pop + end + + # + # Prints the requested numbers of history entries. + # + def to_s(n_cmds) + show_size = n_cmds ? specific_max_size(n_cmds) : default_max_size + + commands = Readline::HISTORY.to_a.last(show_size) + + last_ids(show_size).zip(commands).map do |l| + format('%5d %s', l[0], l[1]) + end.join("\n") + "\n" + end + + # + # Array of ids of the last n commands. + # + def last_ids(n) + (1 + size - n..size).to_a + end + + # + # Max number of commands to be displayed when no size has been specified. + # + # Never more than Setting[:histsize]. + # + def default_max_size + [Setting[:histsize], self.size].min + end + + # + # Max number of commands to be displayed when a size has been specified. + # + # The only bound here is not showing more items than available. + # + def specific_max_size(number) + [self.size, number].min + end + + # + # Whether a specific command should not be stored in history. + # + # For now, empty lines and consecutive duplicates. + # + def ignore?(buf) + return true if /^\s*$/ =~ buf + return false if Readline::HISTORY.length == 0 + + Readline::HISTORY[Readline::HISTORY.length - 1] == buf + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interface.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interface.rb new file mode 100644 index 000000000..5819be8c0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interface.rb @@ -0,0 +1,122 @@ +require 'byebug/history' +require 'byebug/helpers/file' + +# +# Namespace for all of byebug's code +# +module Byebug + # + # Main Interface class + # + # Contains common functionality to all implemented interfaces. + # + class Interface + include Helpers::FileHelper + + attr_accessor :command_queue, :history + attr_reader :input, :output, :error + + def initialize + @command_queue = [] + @history = History.new + end + + # + # Pops a command from the input stream. + # + def read_command(prompt) + return command_queue.shift unless command_queue.empty? + + cmds = read_input(prompt) + return unless cmds + + command_queue.concat(cmds) + command_queue.shift + end + + # + # Pushes lines in +filename+ to the command queue. + # + def read_file(filename) + command_queue.concat(get_lines(filename)) + end + + # + # Reads a new line from the interface's input stream. + # + def read_input(prompt, save_hist = true) + line = readline(prompt) + return unless line + + history.push(line) if save_hist + + split_commands(line) + end + + # + # Prints an error message to the error stream. + # + def errmsg(message) + error.print("*** #{message}\n") + end + + # + # Prints an output message to the output stream. + # + def puts(message) + output.puts(message) + end + + def print(message) + output.print(message) + end + + # + # Confirms user introduced an affirmative response to the input stream. + # + def confirm(prompt) + readline(prompt) == 'y' + end + + def close + end + + # + # Saves or clears history according to +autosave+ setting. + # + def autosave + Setting[:autosave] ? history.save : history.clear + end + + # + # Restores history according to +autosave+ setting. + # + def autorestore + history.restore if Setting[:autosave] + end + + private + + # + # Splits a command line of the form "cmd1 ; cmd2 ; ... ; cmdN" into an + # array of commands: [cmd1, cmd2, ..., cmdN] + # + def split_commands(cmd_line) + return [''] if cmd_line.empty? + + cmd_line.split(/;/).each_with_object([]) do |v, m| + if m.empty? || m.last[-1] != '\\' + m << v + next + end + + m.last[-1, 1] = '' + m.last << ';' << v + end + end + end +end + +require 'byebug/interfaces/local_interface' +require 'byebug/interfaces/script_interface' +require 'byebug/interfaces/remote_interface' diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/local_interface.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/local_interface.rb new file mode 100644 index 000000000..16212271d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/local_interface.rb @@ -0,0 +1,27 @@ +module Byebug + # + # Interface class for standard byebug use. + # + class LocalInterface < Interface + def initialize + super() + @input = STDIN + @output = STDOUT + @error = STDERR + end + + # + # Reads a single line of input using Readline. If Ctrl-C is pressed in the + # middle of input, the line is reset to only the prompt and we ask for input + # again. + # + # @param prompt Prompt to be displayed. + # + def readline(prompt) + Readline.readline(prompt, false) + rescue Interrupt + puts('^C') + retry + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/remote_interface.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/remote_interface.rb new file mode 100644 index 000000000..2a0dc8a1e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/remote_interface.rb @@ -0,0 +1,38 @@ +require 'byebug/history' + +module Byebug + # + # Interface class for remote use of byebug. + # + class RemoteInterface < Interface + def initialize(socket) + super() + @input = socket + @output = socket + @error = socket + end + + def read_command(prompt) + super("PROMPT #{prompt}") + end + + def confirm(prompt) + super("CONFIRM #{prompt}") + end + + def close + output.close + rescue IOError + errmsg('Error closing the interface...') + end + + def readline(prompt) + output.puts(prompt) + + result = input.gets + fail IOError unless result + + result.chomp + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/script_interface.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/script_interface.rb new file mode 100644 index 000000000..6aed91299 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/script_interface.rb @@ -0,0 +1,29 @@ +module Byebug + # + # Interface class for command execution from script files. + # + class ScriptInterface < Interface + def initialize(file, verbose = false) + super() + @input = File.open(file) + @output = verbose ? STDOUT : StringIO.new + @error = verbose ? STDERR : StringIO.new + end + + def read_command(prompt) + readline(prompt, false) + end + + def close + input.close + end + + def readline(*) + while (result = input.gets) + output.puts "+ #{result}" + next if result =~ /^\s*#/ + return result.chomp + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/test_interface.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/test_interface.rb new file mode 100644 index 000000000..0be8ed3ed --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/interfaces/test_interface.rb @@ -0,0 +1,58 @@ +module Byebug + # + # Custom interface for easier assertions + # + class TestInterface < Interface + attr_accessor :test_block + + def initialize + super() + @input = [] + @output = [] + @error = [] + end + + def errmsg(message) + error.concat(message.to_s.split("\n")) + end + + def print(message) + output.concat(message.to_s.split("\n")) + end + + def puts(message) + output.concat(message.to_s.split("\n")) + end + + def read_command(prompt) + cmd = super(prompt) + + return cmd unless cmd.nil? && test_block + + test_block.call + self.test_block = nil + end + + def clear + @input = [] + @output = [] + @error = [] + history.clear + end + + def inspect + [ + 'Input:', input.join("\n"), + 'Output:', output.join("\n"), + 'Error:', error.join("\n") + ].join("\n") + end + + def readline(prompt) + puts(prompt) + + cmd = input.shift + cmd.is_a?(Proc) ? cmd.call : cmd + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/base.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/base.rb new file mode 100644 index 000000000..818662200 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/base.rb @@ -0,0 +1,64 @@ +require 'yaml' + +module Byebug + module Printers + class Base + class MissedPath < StandardError; end + class MissedArgument < StandardError; end + + SEPARATOR = '.' + + def type + self.class.name.split('::').last.downcase + end + + private + + def locate(path) + result = nil + contents.each do |_, contents| + result = parts(path).reduce(contents) do |r, part| + r && r.key?(part) ? r[part] : nil + end + break if result + end + fail MissedPath, "Can't find part path '#{path}'" unless result + result + end + + def translate(string, args = {}) + # they may contain #{} string interpolation + string.gsub(/\|\w+$/, '').gsub(/([^#]?){([^}]*)}/) do + key = Regexp.last_match[2].to_s + unless args.key?(key.to_sym) + fail MissedArgument, "Missed argument #{key} for '#{string}'" + end + + "#{Regexp.last_match[1]}#{args[key.to_sym]}" + end + end + + def parts(path) + path.split(SEPARATOR) + end + + def contents + @contents ||= contents_files.each_with_object({}) do |filename, hash| + hash[filename] = YAML.load_file(filename) || {} + end + end + + def array_of_args(collection, &block) + collection_with_index = collection.each.with_index + collection_with_index.each_with_object([]) do |(item, index), array| + args = block.call(item, index) + array << args if args + end + end + + def contents_files + [File.expand_path(File.join('..', 'texts', 'base.yml'), __FILE__)] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/plain.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/plain.rb new file mode 100644 index 000000000..8e760ee10 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/plain.rb @@ -0,0 +1,53 @@ +require 'byebug/printers/base' + +module Byebug + module Printers + class Plain < Base + include Columnize + + def print(path, args = {}) + message = translate(locate(path), args) + tail = parts(path).include?('confirmations') ? ' (y/n) ' : "\n" + message << tail + end + + def print_collection(path, collection, &block) + modifier = get_modifier(path) + lines = array_of_args(collection, &block).map do |args| + print(path, args) + end + + if modifier == 'c' + columnize(lines.map { |l| l.gsub(/\n$/, '') }, Setting[:width]) + else + lines.join('') + end + end + + def print_variables(variables, *_) + print_collection('variable.variable', variables) do |(key, value), _| + value = value.nil? ? 'nil' : value.to_s + if "#{key} = #{value}".size > Setting[:width] + key_size = "#{key} = ".size + value = value[0..Setting[:width] - key_size - 4] + '...' + end + + { key: key, value: value } + end + end + + private + + def get_modifier(path) + modifier_regexp = /\|(\w+)$/ + modifier_match = locate(path).match(modifier_regexp) + modifier_match && modifier_match[1] + end + + def contents_files + [File.expand_path(File.join('..', 'texts', 'plain.yml'), __FILE__)] + + super + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/base.yml b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/base.yml new file mode 100644 index 000000000..a2b98354c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/base.yml @@ -0,0 +1,116 @@ +base: + errors: + only_local: 'Command is available only in local mode.' + +break: + errors: + line: "Line {line} is not a valid breakpoint in file {file}" + location: "Invalid breakpoint location" + state: "We are not in a state that has an associated file" + class: "Unknown class {klass}" + far_line: "There are only {lines} lines in file {file}" + source: "No file named {file}" + expression: "Incorrect expression \"{expr}\"; breakpoint disabled" + no_breakpoint: "Invalid breakpoint id. Use \"info breakpoint\" to find out the correct id" + no_breakpoint_delete: "No breakpoint number {pos}" + not_changed: "Incorrect expression \"{expr}\", breakpoint not changed" + confirmations: + delete_all: "Delete all breakpoints?" + +catch: + catching: "Catching exception {exception}." + errors: + off: "Off expected. Got {off}" + not_class: "Warning {class} is not known to be a Class" + removed: "Catch for exception {exception} removed" + not_found: "Catch for exception {exception} not found" + confirmations: + delete_all: "Delete all catchpoints? (y or n) " + +condition: + errors: + no_breakpoints: "No breakpoints have been set" + +continue: + errors: + unstopped_line: "Line {line} is not a valid stopping point in file" + +display: + confirmations: + clear_all: "Clear all expressions?" + errors: + undefined: "Display expression {expr} is not defined" + +edit: + errors: + state: "We are not in a state that has an associated file" + file_line: "Invalid file[:line] number specification: {file_line}" + not_readable: "File {file} is not readable." + not_exist: "File {file} does not exist." + +frame: + errors: + too_low: "Can't navigate beyond the oldest frame" + too_high: "Can't navigate beyond the newest frame" + c_frame: "Can't navigate to c-frame" + +help: + errors: + undefined: "Undefined command: {cmd}. Try: help" + +info: + errors: + undefined_file: "{file} is not a valid source file" + +pry: + errors: + not_installed: 'You need to install pry in order to run this command' + +quit: + confirmations: + really: "Really quit?" + +save: + messages: + done: "Saved to '{path}'" + +set: + errors: + unknown_setting: "Unknown setting :{key}" + must_specify_value: "You must specify a value for setting :{key}" + on_off: "Expecting 'on', 1, true, 'off', 0, false. Got: {arg}." + +show: + errors: + unknown_setting: "Unknown setting :{key}" + +source: + errors: + not_found: "File \"{file}\" not found" + not_available: "Source commmand not available at this time" + +thread: + errors: + no_thread: "No such thread" + current_thread: "It's the current thread" + wrong_action: "Can't {subcmd} thread {arg}" + already_running: "Already running" + +toggle: + errors: + no_breakpoints: "No breakpoints have been set" + no_display: "No display expressions have been set" + syntax: "\"{toggle}\" must be followed by \"display\", \"breakpoints\" or breakpoint ids" + expression: "Expression \"{expr}\" syntactically incorrect; breakpoint remains disabled." + +parse: + errors: + int: + too_low: "\"{cmd}\" argument \"{str}\" needs to be at least {min}" + too_high: "\"{cmd}\" argument \"{str}\" needs to be at most {max}" + not_number: "\"{cmd}\" argument \"{str}\" needs to be a number" + +variable: + errors: + not_module: "Should be Class/Module: {object}" + cant_get_class_vars: "can't get class variables here.\n" diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/plain.yml b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/plain.yml new file mode 100644 index 000000000..b7d7ab2ec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/printers/texts/plain.yml @@ -0,0 +1,33 @@ +break: + created: "Successfully created breakpoint with id {id}" + +display: + result: "{n}: {exp} = {result}" + +eval: + exception: "{text_message}" + result: "{result}" + +frame: + line: "{mark} #{pos} {call} at {file}:{line}" + +method: + methods: "{name}|c" + +restart: + success: "Re exec'ing:\n\t{cmd}" + +thread: + context: "{status_flag}{debug_flag}{id} {thread} {file_line}" + +trace: + messages: + success: "Tracing global variable \"{var}\"." + on_change: "traced global variable '{name}' has value '{value}'" + undo: "Not tracing global variable \"{var}\" anymore." + errors: + var_is_not_global: "'{name}' is not a global variable." + needs_global_variable: "tracevar needs a global variable name" + +variable: + variable: "{key} = {value}" diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processor.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processor.rb new file mode 100644 index 000000000..edb7fef7a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processor.rb @@ -0,0 +1,43 @@ +require 'forwardable' + +module Byebug + class Processor + attr_accessor :interface + + extend Forwardable + def_delegators :@interface, :errmsg, :puts + + def initialize(interface) + @interface = interface + end + + def without_exceptions + yield + rescue + nil + end + + def self.load_commands + Dir.glob(File.expand_path('../commands/*.rb', __FILE__)).each do |file| + require file + end + end + + def self.load_settings + Dir.glob(File.expand_path('../settings/*.rb', __FILE__)).each do |file| + require file + end + + Byebug.constants.grep(/[a-z]Setting/).map do |name| + setting = Byebug.const_get(name).new + Byebug::Setting.settings[setting.to_sym] = setting + end + end + end + + Processor.load_commands + Processor.load_settings +end + +require 'byebug/processors/command_processor' +require 'byebug/processors/control_command_processor' diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/command_processor.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/command_processor.rb new file mode 100644 index 000000000..c89dbde8e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/command_processor.rb @@ -0,0 +1,164 @@ +require 'byebug/states/regular_state' +require 'byebug/helpers/file' + +module Byebug + # + # Processes commands in regular mode + # + class CommandProcessor < Processor + include Helpers::FileHelper + + attr_reader :display, :state + + def initialize(interface = LocalInterface.new) + super(interface) + + @display = [] + @last_cmd = nil # To allow empty (just ) commands + @context_was_dead = false # Assume we haven't started. + end + + def interface=(interface) + @interface.close if @interface + @interface = interface + end + + def at_breakpoint(_context, breakpoint) + n = Byebug.breakpoints.index(breakpoint) + 1 + file = normalize(breakpoint.source) + line = breakpoint.pos + + puts "Stopped by breakpoint #{n} at #{file}:#{line}" + end + + def at_catchpoint(context, excpt) + file = normalize(context.frame_file(0)) + line = context.frame_line(0) + + puts "Catchpoint at #{file}:#{line}: `#{excpt}' (#{excpt.class})" + end + + def at_tracing(context, file, line) + puts "Tracing: #{normalize(file)}:#{line} #{get_line(file, line)}" + + always_run(context, file, line, 2) + end + + def at_line(context, file, line) + process_commands(context, file, line) + end + + def at_return(context, file, line) + process_commands(context, file, line) + end + + private + + # + # Prompt shown before reading a command. + # + def prompt(context) + "(byebug#{context.dead? ? ':post-mortem' : ''}) " + end + + # + # Run commands everytime. + # + # For example display commands or possibly the list or irb in an "autolist" + # or "autoirb". + # + # @return List of commands acceptable to run bound to the current state + # + def always_run(context, file, line, run_level) + @state = RegularState.new(context, @display, file, @interface, line) + + # Change default when in irb or code included in command line + Setting[:autolist] = false if ['(irb)', '-e'].include?(file) + + # Bind commands to the current state. + commands.each { |cmd| cmd.execute if cmd.class.always_run >= run_level } + end + + def commands + Byebug.commands.map { |cmd| cmd.new(state) } + end + + # + # Handle byebug commands. + # + def process_commands(context, file, line) + always_run(context, file, line, 1) + + puts 'The program finished.' if program_just_finished?(context) + puts(state.location) if Setting[:autolist] == 0 + + @interface.autorestore + + repl(context) + ensure + @interface.autosave + end + + # + # Main byebug's REPL + # + def repl(context) + until state.proceed? + cmd = @interface.read_command(prompt(context)) + return unless cmd + + next if cmd == '' && @last_cmd.nil? + + cmd.empty? ? cmd = @last_cmd : @last_cmd = cmd + + one_cmd(context, cmd) + end + end + + # + # Autoevals a single command + # + def one_unknown_cmd(input) + unless Setting[:autoeval] + return errmsg("Unknown command: \"#{input}\". Try \"help\"") + end + + eval_cmd = EvalCommand.new(state) + eval_cmd.match(input) + eval_cmd.execute + end + + # + # + # Executes a single byebug command + # + def one_cmd(context, input) + cmd = match_cmd(input) + + return one_unknown_cmd(input) unless cmd + + if context.dead? && !cmd.class.allow_in_post_mortem + return errmsg('Command unavailable in post mortem mode.') + end + + cmd.execute + end + + # + # Finds a matches the command matching the input + # + def match_cmd(input) + commands.find { |cmd| cmd.match(input) } + end + + # + # Returns true first time control is given to the user after program + # termination. + # + def program_just_finished?(context) + result = context.dead? && !@context_was_dead + @context_was_dead = false if result == true + result + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/control_command_processor.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/control_command_processor.rb new file mode 100644 index 000000000..9d201fbf0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/processors/control_command_processor.rb @@ -0,0 +1,48 @@ +require 'byebug/states/control_state' + +module Byebug + # + # Processes commands in 'control' mode, when there's no program running + # + class ControlCommandProcessor < Processor + attr_reader :state + + def initialize(interface = LocalInterface.new) + super(interface) + end + + def commands + Byebug.commands.select(&:allow_in_control).map { |cmd| cmd.new(state) } + end + + def process_commands + @state = ControlState.new(interface) + + while (input = @interface.read_command(prompt(nil))) + cmd = commands.find { |c| c.match(input) } + unless cmd + errmsg('Unknown command') + next + end + + cmd.execute + end + + @interface.close + rescue IOError, SystemCallError + @interface.close + rescue + without_exceptions do + puts "INTERNAL ERROR!!! #{$ERROR_INFO}" + puts $ERROR_INFO.backtrace.map { |l| "\t#{l}" }.join("\n") + end + end + + # + # Prompt shown before reading a command. + # + def prompt(_context) + '(byebug:ctrl) ' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/remote.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/remote.rb new file mode 100644 index 000000000..539047023 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/remote.rb @@ -0,0 +1,99 @@ +require 'socket' + +module Byebug + # Port number used for remote debugging + PORT = 8989 unless defined?(PORT) + + class << self + # If in remote mode, wait for the remote connection + attr_accessor :wait_connection + + # The actual port that the server is started at + attr_accessor :actual_port + attr_reader :actual_control_port + + # + # Interrupts the current thread + # + def interrupt + current_context.interrupt + end + + # + # Starts a remote byebug + # + def start_server(host = nil, port = PORT) + return if @thread + + handler.interface = nil + start + + start_control(host, port == 0 ? 0 : port + 1) + + yield if block_given? + + mutex = Mutex.new + proceed = ConditionVariable.new + + server = TCPServer.new(host, port) + self.actual_port = server.addr[1] + + @thread = DebugThread.new do + while (session = server.accept) + handler.interface = RemoteInterface.new(session) + mutex.synchronize { proceed.signal } if wait_connection + end + end + + mutex.synchronize { proceed.wait(mutex) } if wait_connection + end + + def start_control(host = nil, ctrl_port = PORT + 1) + return @actual_control_port if @control_thread + server = TCPServer.new(host, ctrl_port) + @actual_control_port = server.addr[1] + + @control_thread = DebugThread.new do + while (session = server.accept) + handler.interface = RemoteInterface.new(session) + ControlCommandProcessor.new(handler.interface).process_commands + end + end + + @actual_control_port + end + + # + # Connects to the remote byebug + # + def start_client(host = 'localhost', port = PORT) + handler.interface = LocalInterface.new + puts 'Connecting to byebug server...' + socket = TCPSocket.new(host, port) + puts 'Connected.' + + catch(:exit) do + while (line = socket.gets) + case line + when /^PROMPT (.*)$/ + input = handler.interface.read_command(Regexp.last_match[1]) + throw :exit unless input + socket.puts input + when /^CONFIRM (.*)$/ + input = handler.interface.confirm(Regexp.last_match[1]) + throw :exit unless input + socket.puts input + else + puts line + end + end + end + socket.close + end + + def parse_host_and_port(host_port_spec) + location = host_port_spec.split(':') + location[1] ? [location[0], location[1].to_i] : ['localhost', location[0]] + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/runner.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/runner.rb new file mode 100644 index 000000000..8ea2b0315 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/runner.rb @@ -0,0 +1,190 @@ +require 'optparse' +require 'English' +require 'byebug/core' +require 'byebug/helpers/parse' + +module Byebug + # + # Responsible for starting the debugger when started from the command line. + # + class Runner + include Helpers::ParseHelper + + # + # Error class signaling absence of a script to debug + # + class NoScript < StandardError; end + + # + # Error class signaling a non existent script to debug + # + class NonExistentScript < StandardError; end + + # + # Error class signaling a script with invalid Ruby syntax + # + class InvalidScript < StandardError; end + + # + # Special working modes that don't actually start the debugger. + # + attr_accessor :help, :version, :remote + + # + # @param stop [Boolean] Whether the runner should stop right before + # starting the program. + # + # @param quit [Boolean] Whether the runner should quit right after + # finishing the program. + # + def initialize(stop = true, quit = true) + @stop = stop + @quit = quit + end + + # + # Usage banner. + # + def banner + <<-EOB.gsub(/^ {8}/, '') + + byebug #{Byebug::VERSION} + + Usage: byebug [options] -- + + EOB + end + + # + # Starts byebug to debug a program + # + def run + prepare_options.order!($ARGV) + + if version + Byebug.puts("\n Running byebug #{version}\n") + return + end + + if help + Byebug.puts("#{help}\n") + return + end + + if remote + Byebug.start_client(*remote) + return + end + + setup_cmd_line_args + + loop do + debug_program + + break if @quit + + processor = Byebug::ControlCommandProcessor.new + processor.process_commands + end + end + + private + + # + # Processes options passed from the command line + # + def prepare_options + OptionParser.new(banner, 25) do |opts| + opts.banner = banner + + opts.on '-d', '--debug', 'Set $DEBUG=true' do + $DEBUG = true + end + + opts.on('-I', '--include list', 'Add to paths to $LOAD_PATH') do |list| + $LOAD_PATH.push(list.split(':')).flatten! + end + + opts.on '-m', '--[no-]post-mortem', 'Use post-mortem mode' do |v| + Setting[:post_mortem] = v + end + + opts.on '-q', '--[no-]quit', 'Quit when script finishes' do |v| + @quit = v + end + + opts.on '-x', '--[no-]rc', 'Run byebug initialization file' do |v| + Byebug.run_init_script if v + end + + opts.on '-s', '--[no-]stop', 'Stop when script is loaded' do |v| + @stop = v + end + + opts.on '-r', '--require file', 'Require library before script' do |lib| + require lib + end + + opts.on '-R', '--remote [host:]port', 'Remote debug [host:]port' do |p| + self.remote = Byebug.parse_host_and_port(p) + end + + opts.on '-t', '--[no-]trace', 'Turn on line tracing' do |v| + Setting[:linetrace] = v + end + + opts.on '-v', '--version', 'Print program version' do + self.version = VERSION + end + + opts.on('-h', '--help', 'Display this message') do + self.help = opts.help + end + end + end + + # + # Extracts debugged program from command line args + # + def setup_cmd_line_args + Byebug.mode = :standalone + + fail(NoScript, 'You must specify a program to debug...') if $ARGV.empty? + + program = which($ARGV.shift) + program = which($ARGV.shift) if program == which('ruby') + fail(NonExistentScript, "The script doesn't exist") unless program + + $PROGRAM_NAME = program + end + + # + # Debugs a script only if syntax checks okay. + # + def debug_program + ok = syntax_valid?(File.read($PROGRAM_NAME)) + fail(InvalidScript, 'The script has incorrect syntax') unless ok + + error = Byebug.debug_load($PROGRAM_NAME, @stop) + Byebug.puts "#{status}\n#{status.backtrace}" if error + end + + # + # Cross-platform way of finding an executable in the $PATH. + # Borrowed from: http://stackoverflow.com/questions/2108727 + # + def which(cmd) + return File.expand_path(cmd) if File.exist?(cmd) + + exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] + ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + exts.each do |ext| + exe = File.join(path, "#{cmd}#{ext}") + return exe if File.executable?(exe) && !File.directory?(exe) + end + end + + nil + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/setting.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/setting.rb new file mode 100644 index 000000000..55b041746 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/setting.rb @@ -0,0 +1,70 @@ +require 'byebug/helpers/string' + +module Byebug + # + # Parent class for all byebug settings. + # + class Setting + attr_accessor :value + + DEFAULT = false + + def initialize + @value = self.class::DEFAULT + end + + def boolean? + [true, false].include?(value) + end + + def integer? + Integer(value) ? true : false + rescue ArgumentError + false + end + + def help + prettify(banner) + end + + def to_sym + name = self.class.name.gsub(/^Byebug::/, '').gsub(/Setting$/, '') + name.gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym + end + + def to_s + "#{to_sym} is #{value ? 'on' : 'off'}\n" + end + + class << self + def settings + @settings ||= {} + end + + def [](name) + settings[name].value + end + + def []=(name, value) + settings[name].value = value + end + + def find(shortcut) + abbr = shortcut =~ /^no/ ? shortcut[2..-1] : shortcut + matches = settings.select do |key, value| + value.boolean? ? key =~ /#{abbr}/ : key =~ /#{shortcut}/ + end + matches.size == 1 ? matches.values.first : nil + end + + def help_all + output = " List of settings supported in byebug:\n --\n" + width = settings.keys.max_by(&:size).size + settings.values.each do |sett| + output << format(" %-#{width}s -- %s\n", sett.to_sym, sett.banner) + end + output + "\n" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoeval.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoeval.rb new file mode 100644 index 000000000..5592d721a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoeval.rb @@ -0,0 +1,14 @@ +require 'byebug/setting' + +module Byebug + # + # Setting for automatic evaluation of unknown commands. + # + class AutoevalSetting < Setting + DEFAULT = true + + def banner + 'Automatically evaluate unrecognized commands' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoirb.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoirb.rb new file mode 100644 index 000000000..a12de2a5c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autoirb.rb @@ -0,0 +1,27 @@ +require 'byebug/setting' +require 'byebug/commands/irb' + +module Byebug + # + # Setting for automatically invoking IRB on every stop. + # + class AutoirbSetting < Setting + DEFAULT = 0 + + def initialize + IrbCommand.always_run = DEFAULT + end + + def banner + 'Invoke IRB on every stop' + end + + def value=(v) + IrbCommand.always_run = v ? 1 : 0 + end + + def value + IrbCommand.always_run == 1 + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autolist.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autolist.rb new file mode 100644 index 000000000..6d403560d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autolist.rb @@ -0,0 +1,27 @@ +require 'byebug/setting' +require 'byebug/commands/list' + +module Byebug + # + # Setting for automatically listing source code on every stop. + # + class AutolistSetting < Setting + DEFAULT = 1 + + def initialize + ListCommand.always_run = DEFAULT + end + + def banner + 'Invoke list command on every stop' + end + + def value=(v) + ListCommand.always_run = v ? 1 : 0 + end + + def value + ListCommand.always_run == 1 + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autosave.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autosave.rb new file mode 100644 index 000000000..977256634 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/autosave.rb @@ -0,0 +1,15 @@ +require 'byebug/setting' + +module Byebug + # + # Setting for automatically saving previously entered commands to history + # when exiting the debugger. + # + class AutosaveSetting < Setting + DEFAULT = true + + def banner + 'Automatically save command history record on exit' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/basename.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/basename.rb new file mode 100644 index 000000000..3bb2f442a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/basename.rb @@ -0,0 +1,14 @@ +require 'byebug/setting' + +module Byebug + # + # Command to display short paths in file names. + # + # For example, when displaying source code information. + # + class BasenameSetting < Setting + def banner + ': information after every stop uses short paths' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/callstyle.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/callstyle.rb new file mode 100644 index 000000000..ca433ed4b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/callstyle.rb @@ -0,0 +1,18 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the verbosity level for stack frames. + # + class CallstyleSetting < Setting + DEFAULT = 'long' + + def banner + 'Set how you want method call parameters to be displayed' + end + + def to_s + "Frame display callstyle is '#{value}'" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/fullpath.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/fullpath.rb new file mode 100644 index 000000000..c99248be8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/fullpath.rb @@ -0,0 +1,14 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to display full paths in backtraces. + # + class FullpathSetting < Setting + DEFAULT = true + + def banner + 'Display full file names in backtraces' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histfile.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histfile.rb new file mode 100644 index 000000000..75927aa68 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histfile.rb @@ -0,0 +1,18 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the file where byebug's history is saved. + # + class HistfileSetting < Setting + DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_hist") + + def banner + 'File where cmd history is saved to. Default: ~/.byebug_hist' + end + + def to_s + "The command history file is #{value}\n" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histsize.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histsize.rb new file mode 100644 index 000000000..a6d931578 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/histsize.rb @@ -0,0 +1,18 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the number of byebug commands to be saved in history. + # + class HistsizeSetting < Setting + DEFAULT = 256 + + def banner + 'Maximum number of commands that can be stored in byebug history' + end + + def to_s + "Maximum size of byebug's command history is #{value}" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/linetrace.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/linetrace.rb new file mode 100644 index 000000000..e77207a92 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/linetrace.rb @@ -0,0 +1,20 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to enable/disable linetracing. + # + class LinetraceSetting < Setting + def banner + 'Enable line execution tracing' + end + + def value=(v) + Byebug.tracing = v + end + + def value + Byebug.tracing? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/listsize.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/listsize.rb new file mode 100644 index 000000000..178f3e5b5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/listsize.rb @@ -0,0 +1,19 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the number of source code lines to be displayed every + # time the "list" command is invoked. + # + class ListsizeSetting < Setting + DEFAULT = 10 + + def banner + 'Set number of source lines to list by default' + end + + def to_s + "Number of source lines to list is #{value}\n" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/post_mortem.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/post_mortem.rb new file mode 100644 index 000000000..1156a4306 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/post_mortem.rb @@ -0,0 +1,41 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to enable/disable post_mortem mode, i.e., a debugger prompt after + # program termination by unhandled exception. + # + class PostMortemSetting < Setting + def initialize + Byebug.post_mortem = DEFAULT + end + + def banner + 'Enable/disable post-mortem mode' + end + + def value=(v) + Byebug.post_mortem = v + end + + def value + Byebug.post_mortem? + end + end + + # + # Saves information about the unhandled exception and gives a byebug + # prompt back to the user before program termination. + # + def self.handle_post_mortem + return unless Byebug.raised_exception + + context = Byebug.raised_exception.__bb_context + file = Byebug.raised_exception.__bb_file + line = Byebug.raised_exception.__bb_line + + Byebug.handler.at_line(context, file, line) + end + + at_exit { Byebug.handle_post_mortem if Byebug.post_mortem? } +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/savefile.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/savefile.rb new file mode 100644 index 000000000..97a80b430 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/savefile.rb @@ -0,0 +1,21 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the file where byebug's history is saved. + # + class SavefileSetting < Setting + DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_save") + + def banner + <<-EOB + File where save commands saves current settings to. Default: + ~/.byebug_save + EOB + end + + def to_s + "The command history file is #{value}\n" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/stack_on_error.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/stack_on_error.rb new file mode 100644 index 000000000..f9de06e22 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/stack_on_error.rb @@ -0,0 +1,13 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to enable/disable the display of backtraces when evaluations raise + # errors. + # + class StackOnErrorSetting < Setting + def banner + 'Display stack trace when `eval` raises an exception' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/verbose.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/verbose.rb new file mode 100644 index 000000000..32d38a96b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/verbose.rb @@ -0,0 +1,20 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to show verbose output about TracePoint API events. + # + class VerboseSetting < Setting + def banner + 'Enable verbose output of TracePoint API events' + end + + def value=(v) + Byebug.verbose = v + end + + def value + Byebug.verbose? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/width.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/width.rb new file mode 100644 index 000000000..20bee9dad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/settings/width.rb @@ -0,0 +1,18 @@ +require 'byebug/setting' + +module Byebug + # + # Setting to customize the maximum width of byebug's output. + # + class WidthSetting < Setting + DEFAULT = 160 + + def banner + "Number of characters per line in byebug's output" + end + + def to_s + "Maximum width of byebug's output is #{value}" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/state.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/state.rb new file mode 100644 index 000000000..79c8ce550 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/state.rb @@ -0,0 +1,12 @@ +module Byebug + # + # Common parent class for all of Byebug's states + # + class State + attr_reader :interface + + def initialize(interface) + @interface = interface + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/control_state.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/control_state.rb new file mode 100644 index 000000000..c29c584e7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/control_state.rb @@ -0,0 +1,26 @@ +require 'byebug/state' + +module Byebug + # + # Controls state of Byebug's REPL when in control mode + # + class ControlState < State + def proceed + end + + extend Forwardable + def_delegators :@interface, :errmsg, :puts + + def confirm(*_args) + 'y' + end + + def context + nil + end + + def file + errmsg 'No filename given.' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/regular_state.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/regular_state.rb new file mode 100644 index 000000000..42625c6b4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/states/regular_state.rb @@ -0,0 +1,187 @@ +require 'byebug/state' +require 'byebug/helpers/file' + +module Byebug + # + # Controls state of Byebug's REPL when in normal mode + # + class RegularState < State + include Helpers::FileHelper + + attr_accessor :context, :frame, :display, :file, :line, :prev_line + attr_writer :interface + + def initialize(context, display, file, interface, line) + super(interface) + @context = context + @display = display + @file = file + @frame = 0 + @line = line + @prev_line = nil + @proceed = false + end + + extend Forwardable + def_delegators :@interface, :errmsg, :puts, :print, :confirm + + # + # Checks whether that execution can proceed + # + def proceed? + @proceed + end + + # + # Signals the REPL that the execution can proceed + # + def proceed + @proceed = true + end + + # + # Current (formatted) location + # + def location + l = "#{normalize(file)} @ #{line}\n" + l += "#{get_line(file, line)}\n" unless %w((irb) -e').include?(file) + l + end + + # + # Builds a string containing the class associated to frame number +pos+ + # or an empty string if the current +callstyle+ setting is 'short' + # + # @param pos [Integer] Frame position. + # + def frame_class(pos) + return '' if Setting[:callstyle] == 'short' + + klass = context.frame_class(pos) + return '' if klass.to_s.empty? + + "#{klass}." + end + + # + # Builds a formatted string containing information about block and method + # of the frame in position +pos+ + # + # @param pos [Integer] Frame position. + # + def frame_block_and_method(pos) + deco_regexp = /((?:block(?: \(\d+ levels\))?|rescue) in )?(.+)/ + deco_method = "#{context.frame_method(pos)}" + block_and_method = deco_regexp.match(deco_method)[1..2] + block_and_method.map { |x| x.nil? ? '' : x } + end + + # + # Builds a string containing all available args in frame number +pos+, in a + # verbose or non verbose way according to the value of the +callstyle+ + # setting + # + # @param pos [Integer] Frame position. + # + def frame_args(pos) + args = context.frame_args(pos) + return '' if args.empty? + + locals = context.frame_locals(pos) unless Setting[:callstyle] == 'short' + my_args = args.map do |arg| + prefix, default = prefix_and_default_from(arg[0]) + + kls = if Setting[:callstyle] == 'short' || arg[1].nil? || locals.empty? + '' + else + "##{locals[arg[1]].class}" + end + + "#{prefix}#{arg[1] || default}#{kls}" + end + + "(#{my_args.join(', ')})" + end + + # + # Builds a formatted string containing information about current method + # call in frame number +pos+. + # + # @param pos [Integer] Frame position. + # + def frame_call(pos) + block, method = frame_block_and_method(pos) + + block + frame_class(pos) + method + frame_args(pos) + end + + # + # Formatted filename in frame number +pos+ + # + # @param pos [Integer] Frame position. + # + def frame_file(pos) + fullpath = context.frame_file(pos) + Setting[:fullpath] ? fullpath : shortpath(fullpath) + end + + # + # Line number in frame number +pos+ + # + # @param pos [Integer] Frame position. + # + def frame_line(pos) + context.frame_line(pos) + end + + # + # Properly formatted frame number of frame in position +pos+ + # + # @param pos [Integer] Frame position. + # + def frame_pos(pos) + format('%-2d', pos) + end + + # + # Formatted mark for number of frame in position +pos+. The mark can + # contain the current frame symbo (-->), the c_frame symbol (ͱ--) or both + # + # @param pos [Integer] Frame position. + # + def frame_mark(pos) + mark = frame == pos ? '-->' : ' ' + + c_frame?(pos) ? mark + ' ͱ--' : mark + end + + # + # Checks whether the frame in position +pos+ is a c-frame or not + # + # @param pos [Integer] Frame position. + # + def c_frame?(pos) + context.frame_binding(pos).nil? + end + + private + + def shortpath(fullpath) + components = Pathname(fullpath).each_filename.to_a + return fullpath if components.size <= 2 + + File.join('...', components[-3..-1]) + end + + def prefix_and_default_from(arg_type) + case arg_type + when :block + return ['&', 'block'] + when :rest + return ['*', 'args'] + else + return ['', nil] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommand_list.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommand_list.rb new file mode 100644 index 000000000..ce96014c2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommand_list.rb @@ -0,0 +1,33 @@ +module Byebug + # + # Holds an array of subcommands for a command + # + class SubcommandList + def initialize(commands, parent) + @commands = commands + @parent = parent + end + + def find(name) + @commands.find { |cmd| cmd.match(name) } + end + + def help(name) + subcmd = find(name) + return errmsg("Unknown subcommand '#{name}'") unless subcmd + + subcmd.help + end + + def to_s + width = @commands.map(&:to_name).max_by(&:size).size + + formatted_cmds = @commands.map do |subcmd| + format("%s %-#{width}s -- %s\n", + @parent, subcmd.to_name, subcmd.short_description) + end + + formatted_cmds.join + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommands.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommands.rb new file mode 100644 index 000000000..abf63ce3a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/subcommands.rb @@ -0,0 +1,53 @@ +require 'byebug/command' +require 'byebug/subcommand_list' + +module Byebug + # + # Subcommand additions. + # + module Subcommands + # + # Summarized description of a subcommand + # + def short_description + fail(NotImplementedError, 'Your custom subcommand needs to define this') + end + + # + # Delegates to subcommands or prints help if no subcommand specified. + # + def execute + return puts(help) unless @match[1] + + subcmd = subcommands.find(@match[1]) + return errmsg("Unknown subcommand '#{@match[1]}'\n") unless subcmd + + subcmd.execute + end + + # + # Default help text for a command with subcommands + # + def help + prettify <<-EOH + #{description} + + List of "#{to_name}" subcommands: + + -- + #{subcommands} + EOH + end + + # + # Command's subcommands. + # + def subcommands + subcmd_klasses = self.class.subcommands + return nil unless subcmd_klasses.any? + + subcmd_list = subcmd_klasses.map { |cmd| cmd.new(@state) } + SubcommandList.new(subcmd_list, self.class.name) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/version.rb b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/version.rb new file mode 100644 index 000000000..8f76f8be6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/byebug-5.0.0/lib/byebug/version.rb @@ -0,0 +1,3 @@ +module Byebug + VERSION = '5.0.0' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/README_INDEX.rdoc b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/README_INDEX.rdoc new file mode 100644 index 000000000..7332653c6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/README_INDEX.rdoc @@ -0,0 +1,123 @@ += CodeRay + +Tired of blue'n'gray? Try the original version of this documentation on +coderay.rubychan.de[http://coderay.rubychan.de/doc/] :-) + +== About + +CodeRay is a Ruby library for syntax highlighting. + +You put your code in, and you get it back colored; Keywords, strings, +floats, comments - all in different colors. And with line numbers. + +*Syntax* *Highlighting*... +* makes code easier to read and maintain +* lets you detect syntax errors faster +* helps you to understand the syntax of a language +* looks nice +* is what everybody wants to have on their website +* solves all your problems and makes the girls run after you + + +== Installation + + % gem install coderay + + +=== Dependencies + +CodeRay needs Ruby 1.8.7+ or 1.9.2+. It also runs on Rubinius and JRuby. + + +== Example Usage + + require 'coderay' + + html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) + + +== Documentation + +See CodeRay. + + +== Credits + +=== Special Thanks to + +* licenser (Heinz N. Gies) for ending my QBasic career, inventing the Coder + project and the input/output plugin system. + CodeRay would not exist without him. +* bovi (Daniel Bovensiepen) for helping me out on various occasions. + +=== Thanks to + +* Caleb Clausen for writing RubyLexer (see + http://rubyforge.org/projects/rubylexer) and lots of very interesting mail + traffic +* birkenfeld (Georg Brandl) and mitsuhiku (Arnim Ronacher) for PyKleur, now pygments. + You guys rock! +* Jamis Buck for writing Syntax (see http://rubyforge.org/projects/syntax) + I got some useful ideas from it. +* Doug Kearns and everyone else who worked on ruby.vim - it not only helped me + coding CodeRay, but also gave me a wonderful target to reach for the Ruby + scanner. +* everyone who uses CodeBB on http://www.rubyforen.de and http://www.python-forum.de +* iGEL, magichisoka, manveru, WoNáDo and everyone I forgot from rubyforen.de +* Dethix from ruby-mine.de +* zickzackw +* Dookie (who is no longer with us...) and Leonidas from http://www.python-forum.de +* Andreas Schwarz for finding out that CaseIgnoringWordList was not case + ignoring! Such things really make you write tests. +* closure for the first version of the Scheme scanner. +* Stefan Walk for the first version of the JavaScript and PHP scanners. +* Josh Goebel for another version of the JavaScript scanner, a SQL and a Diff scanner. +* Jonathan Younger for pointing out the licence confusion caused by wrong LICENSE file. +* Jeremy Hinegardner for finding the shebang-on-empty-file bug in FileType. +* Charles Oliver Nutter and Yehuda Katz for helping me benchmark CodeRay on JRuby. +* Andreas Neuhaus for pointing out a markup bug in coderay/for_redcloth. +* 0xf30fc7 for the FileType patch concerning Delphi file extensions. +* The folks at redmine.org - thank you for using and fixing CodeRay! +* Keith Pitt for his SQL scanners +* Rob Aldred for the terminal encoder +* Trans for pointing out $DEBUG dependencies +* Flameeyes for finding that Term::ANSIColor was obsolete +* matz and all Ruby gods and gurus +* The inventors of: the computer, the internet, the true color display, HTML & + CSS, VIM, Ruby, pizza, microwaves, guitars, scouting, programming, anime, + manga, coke and green ice tea. + +Where would we be without all those people? + +=== Created using + +* Ruby[http://ruby-lang.org/] +* Chihiro (my Sony VAIO laptop); Henrietta (my old MacBook); + Triella, born Rico (my new MacBook); as well as + Seras and Hikari (my PCs) +* RDE[http://homepage2.nifty.com/sakazuki/rde_e.html], + VIM[http://vim.org] and TextMate[http://macromates.com] +* Subversion[http://subversion.tigris.org/] +* Redmine[http://redmine.org/] +* Firefox[http://www.mozilla.org/products/firefox/], + Firebug[http://getfirebug.com/], Safari[http://www.apple.com/safari/], and + Thunderbird[http://www.mozilla.org/products/thunderbird/] +* RubyGems[http://docs.rubygems.org/] and Rake[http://rake.rubyforge.org/] +* TortoiseSVN[http://tortoisesvn.tigris.org/] using Apache via + XAMPP[http://www.apachefriends.org/en/xampp.html] +* RDoc (though I'm quite unsatisfied with it) +* Microsoft Windows (yes, I confess!) and MacOS X +* GNUWin32, MinGW and some other tools to make the shell under windows a bit + less useless +* Term::ANSIColor[http://term-ansicolor.rubyforge.org/] +* PLEAC[http://pleac.sourceforge.net/] code examples +* Github +* Travis CI (http://travis-ci.org/rubychan/github) + +=== Free + +* As you can see, CodeRay was created under heavy use of *free* software. +* So CodeRay is also *free*. +* If you use CodeRay to create software, think about making this software + *free*, too. +* Thanks :) diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/Rakefile b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/Rakefile new file mode 100644 index 000000000..c9b1e8a35 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/Rakefile @@ -0,0 +1,37 @@ +require 'bundler/gem_tasks' + +$:.unshift File.dirname(__FILE__) unless $:.include? '.' + +ROOT = '.' +LIB_ROOT = File.join ROOT, 'lib' + +task :default => :test + +if File.directory? 'rake_tasks' + + # load rake tasks from subfolder + for task_file in Dir['rake_tasks/*.rake'].sort + load task_file + end + +else + + # fallback tasks when rake_tasks folder is not present (eg. in the distribution package) + desc 'Run CodeRay tests (basic)' + task :test do + ruby './test/functional/suite.rb' + ruby './test/functional/for_redcloth.rb' + end + + gem 'rdoc' if defined? gem + require 'rdoc/task' + desc 'Generate documentation for CodeRay' + Rake::RDocTask.new :doc do |rd| + rd.title = 'CodeRay Documentation' + rd.main = 'README_INDEX.rdoc' + rd.rdoc_files.add Dir['lib'] + rd.rdoc_files.add rd.main + rd.rdoc_dir = 'doc' + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/bin/coderay b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/bin/coderay new file mode 100755 index 000000000..889ae726c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/bin/coderay @@ -0,0 +1,215 @@ +#!/usr/bin/env ruby +require 'coderay' + +$options, args = ARGV.partition { |arg| arg[/^-[hv]$|--\w+/] } +subcommand = args.first if /^\w/ === args.first +subcommand = nil if subcommand && File.exist?(subcommand) +args.delete subcommand + +def option? *options + !($options & options).empty? +end + +def tty? + $stdout.tty? || option?('--tty') +end + +def version + puts <<-USAGE +CodeRay #{CodeRay::VERSION} + USAGE +end + +def help + puts <<-HELP +This is CodeRay #{CodeRay::VERSION}, a syntax highlighting tool for selected languages. + +usage: + coderay [-language] [input] [-format] [output] + +defaults: + language detect from input file name or shebang; fall back to plain text + input STDIN + format detect from output file name or use terminal; fall back to HTML + output STDOUT + +common: + coderay file.rb # highlight file to terminal + coderay file.rb > file.html # highlight file to HTML page + coderay file.rb -div > file.html # highlight file to HTML snippet + +configure output: + coderay file.py output.json # output tokens as JSON + coderay file.py -loc # count lines of code in Python file + +configure input: + coderay -python file # specify the input language + coderay -ruby # take input from STDIN + +more: + coderay stylesheet [style] # print CSS stylesheet + HELP +end + +def commands + puts <<-COMMANDS + general: + highlight code highlighting (default command, optional) + stylesheet print the CSS stylesheet with the given name (aliases: style, css) + + about: + list [of] list all available plugins (or just the scanners|encoders|styles|filetypes) + commands print this list + help show some help + version print CodeRay version + COMMANDS +end + +def print_list_of plugin_host + plugins = plugin_host.all_plugins.map do |plugin| + info = " #{plugin.plugin_id}: #{plugin.title}" + + aliases = (plugin.aliases - [:default]).map { |key| "-#{key}" }.sort_by { |key| key.size } + if plugin.respond_to?(:file_extension) || !aliases.empty? + additional_info = [] + additional_info << aliases.join(', ') unless aliases.empty? + info << " (#{additional_info.join('; ')})" + end + + info << ' <-- default' if plugin.aliases.include? :default + + info + end + puts plugins.sort +end + +if option? '-v', '--version' + version +end + +if option? '-h', '--help' + help +end + +case subcommand +when 'highlight', nil + if ARGV.empty? + version + help + else + signature = args.map { |arg| arg[/^-/] ? '-' : 'f' }.join + names = args.map { |arg| arg.sub(/^-/, '') } + case signature + when /^$/ + exit + when /^ff?$/ + input_file, output_file, = *names + when /^f-f?$/ + input_file, output_format, output_file, = *names + when /^-ff?$/ + input_lang, input_file, output_file, = *names + when /^-f-f?$/ + input_lang, input_file, output_format, output_file, = *names + when /^--?f?$/ + input_lang, output_format, output_file, = *names + else + $stdout = $stderr + help + puts + puts "Unknown parameter order: #{args.join ' '}, expected: [-language] [input] [-format] [output]" + exit 1 + end + + if input_file + input_lang ||= CodeRay::FileType.fetch input_file, :text, true + end + + if output_file + output_format ||= CodeRay::FileType[output_file] || :plain + else + output_format ||= :terminal + end + + output_format = :page if output_format.to_s == 'html' + + if input_file + input = File.read input_file + else + input = $stdin.read + end + + begin + file = + if output_file + File.open output_file, 'w' + else + $stdout + end + CodeRay.encode(input, input_lang, output_format, :out => file) + file.puts + rescue CodeRay::PluginHost::PluginNotFound => boom + $stdout = $stderr + if boom.message[/CodeRay::(\w+)s could not load plugin :?(.*?): /] + puts "I don't know the #$1 \"#$2\"." + else + puts boom.message + end + # puts "I don't know this plugin: #{boom.message[/Could not load plugin (.*?): /, 1]}." + rescue CodeRay::Scanners::Scanner::ScanError + # this is sometimes raised by pagers; ignore + # FIXME: rescue Errno::EPIPE + ensure + file.close if output_file + end + end +when 'li', 'list' + arg = args.first && args.first.downcase + if [nil, 's', 'sc', 'scanner', 'scanners'].include? arg + puts 'input languages (Scanners):' + print_list_of CodeRay::Scanners + end + + if [nil, 'e', 'en', 'enc', 'encoder', 'encoders'].include? arg + puts 'output formats (Encoders):' + print_list_of CodeRay::Encoders + end + + if [nil, 'st', 'style', 'styles'].include? arg + puts 'CSS themes for HTML output (Styles):' + print_list_of CodeRay::Styles + end + + if [nil, 'f', 'ft', 'file', 'filetype', 'filetypes'].include? arg + puts 'recognized file types:' + + filetypes = Hash.new { |h, k| h[k] = [] } + CodeRay::FileType::TypeFromExt.inject filetypes do |types, (ext, type)| + types[type.to_s] << ".#{ext}" + types + end + CodeRay::FileType::TypeFromName.inject filetypes do |types, (name, type)| + types[type.to_s] << name + types + end + + filetypes.sort.each do |type, exts| + puts " #{type}: #{exts.sort_by { |ext| ext.size }.join(', ')}" + end + end +when 'stylesheet', 'style', 'css' + puts CodeRay::Encoders[:html]::CSS.new(args.first || :default).stylesheet +when 'commands' + commands +when 'help' + help +else + $stdout = $stderr + help + puts + if subcommand[/\A\w+\z/] + puts "Unknown command: #{subcommand}" + else + puts "File not found: #{subcommand}" + end + exit 1 +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay.rb new file mode 100644 index 000000000..f759ed637 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay.rb @@ -0,0 +1,284 @@ +# encoding: utf-8 +# Encoding.default_internal = 'UTF-8' + +# = CodeRay Library +# +# CodeRay is a Ruby library for syntax highlighting. +# +# I try to make CodeRay easy to use and intuitive, but at the same time fully +# featured, complete, fast and efficient. +# +# See README. +# +# It consists mainly of +# * the main engine: CodeRay (Scanners::Scanner, Tokens, Encoders::Encoder) +# * the plugin system: PluginHost, Plugin +# * the scanners in CodeRay::Scanners +# * the encoders in CodeRay::Encoders +# * the styles in CodeRay::Styles +# +# Here's a fancy graphic to light up this gray docu: +# +# http://cycnus.de/raindark/coderay/scheme.png +# +# == Documentation +# +# See CodeRay, Encoders, Scanners, Tokens. +# +# == Usage +# +# Remember you need RubyGems to use CodeRay, unless you have it in your load +# path. Run Ruby with -rubygems option if required. +# +# === Highlight Ruby code in a string as html +# +# require 'coderay' +# print CodeRay.scan('puts "Hello, world!"', :ruby).html +# +# # prints something like this: +# puts "Hello, world!" +# +# +# === Highlight C code from a file in a html div +# +# require 'coderay' +# print CodeRay.scan(File.read('ruby.h'), :c).div +# print CodeRay.scan_file('ruby.h').html.div +# +# You can include this div in your page. The used CSS styles can be printed with +# +# % coderay_stylesheet +# +# === Highlight without typing too much +# +# If you are one of the hasty (or lazy, or extremely curious) people, just run this file: +# +# % ruby -rubygems /path/to/coderay/coderay.rb > example.html +# +# and look at the file it created in your browser. +# +# = CodeRay Module +# +# The CodeRay module provides convenience methods for the engine. +# +# * The +lang+ and +format+ arguments select Scanner and Encoder to use. These are +# simply lower-case symbols, like :python or :html. +# * All methods take an optional hash as last parameter, +options+, that is send to +# the Encoder / Scanner. +# * Input and language are always sorted in this order: +code+, +lang+. +# (This is in alphabetical order, if you need a mnemonic ;) +# +# You should be able to highlight everything you want just using these methods; +# so there is no need to dive into CodeRay's deep class hierarchy. +# +# The examples in the demo directory demonstrate common cases using this interface. +# +# = Basic Access Ways +# +# Read this to get a general view what CodeRay provides. +# +# == Scanning +# +# Scanning means analysing an input string, splitting it up into Tokens. +# Each Token knows about what type it is: string, comment, class name, etc. +# +# Each +lang+ (language) has its own Scanner; for example, :ruby code is +# handled by CodeRay::Scanners::Ruby. +# +# CodeRay.scan:: Scan a string in a given language into Tokens. +# This is the most common method to use. +# CodeRay.scan_file:: Scan a file and guess the language using FileType. +# +# The Tokens object you get from these methods can encode itself; see Tokens. +# +# == Encoding +# +# Encoding means compiling Tokens into an output. This can be colored HTML or +# LaTeX, a textual statistic or just the number of non-whitespace tokens. +# +# Each Encoder provides output in a specific +format+, so you select Encoders via +# formats like :html or :statistic. +# +# CodeRay.encode:: Scan and encode a string in a given language. +# CodeRay.encode_tokens:: Encode the given tokens. +# CodeRay.encode_file:: Scan a file, guess the language using FileType and encode it. +# +# == All-in-One Encoding +# +# CodeRay.encode:: Highlight a string with a given input and output format. +# +# == Instanciating +# +# You can use an Encoder instance to highlight multiple inputs. This way, the setup +# for this Encoder must only be done once. +# +# CodeRay.encoder:: Create an Encoder instance with format and options. +# CodeRay.scanner:: Create an Scanner instance for lang, with '' as default code. +# +# To make use of CodeRay.scanner, use CodeRay::Scanner::code=. +# +# The scanning methods provide more flexibility; we recommend to use these. +# +# == Reusing Scanners and Encoders +# +# If you want to re-use scanners and encoders (because that is faster), see +# CodeRay::Duo for the most convenient (and recommended) interface. +module CodeRay + + $CODERAY_DEBUG ||= false + + CODERAY_PATH = File.expand_path('../coderay', __FILE__) + + # Assuming the path is a subpath of lib/coderay/ + def self.coderay_path *path + File.join CODERAY_PATH, *path + end + + require 'coderay/version' + + # helpers + autoload :FileType, coderay_path('helpers', 'file_type') + + # Tokens + autoload :Tokens, coderay_path('tokens') + autoload :TokensProxy, coderay_path('tokens_proxy') + autoload :TokenKinds, coderay_path('token_kinds') + + # Plugin system + autoload :PluginHost, coderay_path('helpers', 'plugin') + autoload :Plugin, coderay_path('helpers', 'plugin') + + # Plugins + autoload :Scanners, coderay_path('scanner') + autoload :Encoders, coderay_path('encoder') + autoload :Styles, coderay_path('style') + + # convenience access and reusable Encoder/Scanner pair + autoload :Duo, coderay_path('duo') + + class << self + + # Scans the given +code+ (a String) with the Scanner for +lang+. + # + # This is a simple way to use CodeRay. Example: + # require 'coderay' + # page = CodeRay.scan("puts 'Hello, world!'", :ruby).html + # + # See also demo/demo_simple. + def scan code, lang, options = {}, &block + TokensProxy.new code, lang, options, block + end + + # Scans +filename+ (a path to a code file) with the Scanner for +lang+. + # + # If +lang+ is :auto or omitted, the CodeRay::FileType module is used to + # determine it. If it cannot find out what type it is, it uses + # CodeRay::Scanners::Text. + # + # Calls CodeRay.scan. + # + # Example: + # require 'coderay' + # page = CodeRay.scan_file('some_c_code.c').html + def scan_file filename, lang = :auto, options = {}, &block + lang = FileType.fetch filename, :text, true if lang == :auto + code = File.read filename + scan code, lang, options, &block + end + + # Encode a string. + # + # This scans +code+ with the the Scanner for +lang+ and then + # encodes it with the Encoder for +format+. + # +options+ will be passed to the Encoder. + # + # See CodeRay::Encoder.encode. + def encode code, lang, format, options = {} + encoder(format, options).encode code, lang, options + end + + # Encode pre-scanned Tokens. + # Use this together with CodeRay.scan: + # + # require 'coderay' + # + # # Highlight a short Ruby code example in a HTML span + # tokens = CodeRay.scan '1 + 2', :ruby + # puts CodeRay.encode_tokens(tokens, :span) + # + def encode_tokens tokens, format, options = {} + encoder(format, options).encode_tokens tokens, options + end + + # Encodes +filename+ (a path to a code file) with the Scanner for +lang+. + # + # See CodeRay.scan_file. + # Notice that the second argument is the output +format+, not the input language. + # + # Example: + # require 'coderay' + # page = CodeRay.encode_file 'some_c_code.c', :html + def encode_file filename, format, options = {} + tokens = scan_file filename, :auto, get_scanner_options(options) + encode_tokens tokens, format, options + end + + # Highlight a string into a HTML
. + # + # CSS styles use classes, so you have to include a stylesheet + # in your output. + # + # See encode. + def highlight code, lang, options = { :css => :class }, format = :div + encode code, lang, format, options + end + + # Highlight a file into a HTML
. + # + # CSS styles use classes, so you have to include a stylesheet + # in your output. + # + # See encode. + def highlight_file filename, options = { :css => :class }, format = :div + encode_file filename, format, options + end + + # Finds the Encoder class for +format+ and creates an instance, passing + # +options+ to it. + # + # Example: + # require 'coderay' + # + # stats = CodeRay.encoder(:statistic) + # stats.encode("puts 17 + 4\n", :ruby) + # + # puts '%d out of %d tokens have the kind :integer.' % [ + # stats.type_stats[:integer].count, + # stats.real_token_count + # ] + # #-> 2 out of 4 tokens have the kind :integer. + def encoder format, options = {} + Encoders[format].new options + end + + # Finds the Scanner class for +lang+ and creates an instance, passing + # +options+ to it. + # + # See Scanner.new. + def scanner lang, options = {}, &block + Scanners[lang].new '', options, &block + end + + # Extract the options for the scanner from the +options+ hash. + # + # Returns an empty Hash if :scanner_options is not set. + # + # This is used if a method like CodeRay.encode has to provide options + # for Encoder _and_ scanner. + def get_scanner_options options + options.fetch :scanner_options, {} + end + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/duo.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/duo.rb new file mode 100644 index 000000000..cb3f8ee82 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/duo.rb @@ -0,0 +1,81 @@ +module CodeRay + + # = Duo + # + # A Duo is a convenient way to use CodeRay. You just create a Duo, + # giving it a lang (language of the input code) and a format (desired + # output format), and call Duo#highlight with the code. + # + # Duo makes it easy to re-use both scanner and encoder for a repetitive + # task. It also provides a very easy interface syntax: + # + # require 'coderay' + # CodeRay::Duo[:python, :div].highlight 'import this' + # + # Until you want to do uncommon things with CodeRay, I recommend to use + # this method, since it takes care of everything. + class Duo + + attr_accessor :lang, :format, :options + + # Create a new Duo, holding a lang and a format to highlight code. + # + # simple: + # CodeRay::Duo[:ruby, :html].highlight 'bla 42' + # + # with options: + # CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??' + # + # alternative syntax without options: + # CodeRay::Duo[:ruby => :statistic].encode 'class << self; end' + # + # alternative syntax with options: + # CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc' + # + # The options are forwarded to scanner and encoder + # (see CodeRay.get_scanner_options). + def initialize lang = nil, format = nil, options = {} + if format.nil? && lang.is_a?(Hash) && lang.size == 1 + @lang = lang.keys.first + @format = lang[@lang] + else + @lang = lang + @format = format + end + @options = options + end + + class << self + # To allow calls like Duo[:ruby, :html].highlight. + alias [] new + end + + # The scanner of the duo. Only created once. + def scanner + @scanner ||= CodeRay.scanner @lang, CodeRay.get_scanner_options(@options) + end + + # The encoder of the duo. Only created once. + def encoder + @encoder ||= CodeRay.encoder @format, @options + end + + # Tokenize and highlight the code using +scanner+ and +encoder+. + def encode code, options = {} + options = @options.merge options + encoder.encode(code, @lang, options) + end + alias highlight encode + + # Allows to use Duo like a proc object: + # + # CodeRay::Duo[:python => :yaml].call(code) + # + # or, in Ruby 1.9 and later: + # + # CodeRay::Duo[:python => :yaml].(code) + alias call encode + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoder.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoder.rb new file mode 100644 index 000000000..d2d6c7e62 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoder.rb @@ -0,0 +1,201 @@ +module CodeRay + + # This module holds the Encoder class and its subclasses. + # For example, the HTML encoder is named CodeRay::Encoders::HTML + # can be found in coderay/encoders/html. + # + # Encoders also provides methods and constants for the register + # mechanism and the [] method that returns the Encoder class + # belonging to the given format. + module Encoders + + extend PluginHost + plugin_path File.dirname(__FILE__), 'encoders' + + # = Encoder + # + # The Encoder base class. Together with Scanner and + # Tokens, it forms the highlighting triad. + # + # Encoder instances take a Tokens object and do something with it. + # + # The most common Encoder is surely the HTML encoder + # (CodeRay::Encoders::HTML). It highlights the code in a colorful + # html page. + # If you want the highlighted code in a div or a span instead, + # use its subclasses Div and Span. + class Encoder + extend Plugin + plugin_host Encoders + + class << self + + # If FILE_EXTENSION isn't defined, this method returns the + # downcase class name instead. + def const_missing sym + if sym == :FILE_EXTENSION + (defined?(@plugin_id) && @plugin_id || name[/\w+$/].downcase).to_s + else + super + end + end + + # The default file extension for output file of this encoder class. + def file_extension + self::FILE_EXTENSION + end + + end + + # Subclasses are to store their default options in this constant. + DEFAULT_OPTIONS = { } + + # The options you gave the Encoder at creating. + attr_accessor :options, :scanner + + # Creates a new Encoder. + # +options+ is saved and used for all encode operations, as long + # as you don't overwrite it there by passing additional options. + # + # Encoder objects provide three encode methods: + # - encode simply takes a +code+ string and a +lang+ + # - encode_tokens expects a +tokens+ object instead + # + # Each method has an optional +options+ parameter. These are + # added to the options you passed at creation. + def initialize options = {} + @options = self.class::DEFAULT_OPTIONS.merge options + @@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN = false + end + + # Encode a Tokens object. + def encode_tokens tokens, options = {} + options = @options.merge options + @scanner = tokens.scanner if tokens.respond_to? :scanner + setup options + compile tokens, options + finish options + end + + # Encode the given +code+ using the Scanner for +lang+. + def encode code, lang, options = {} + options = @options.merge options + @scanner = Scanners[lang].new code, CodeRay.get_scanner_options(options).update(:tokens => self) + setup options + @scanner.tokenize + finish options + end + + # You can use highlight instead of encode, if that seems + # more clear to you. + alias highlight encode + + # The default file extension for this encoder. + def file_extension + self.class.file_extension + end + + def << token + unless @@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN + warn 'Using old Tokens#<< interface.' + @@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN = true + end + self.token(*token) + end + + # Called with +content+ and +kind+ of the currently scanned token. + # For simple scanners, it's enougth to implement this method. + # + # By default, it calls text_token, begin_group, end_group, begin_line, + # or end_line, depending on the +content+. + def token content, kind + case content + when String + text_token content, kind + when :begin_group + begin_group kind + when :end_group + end_group kind + when :begin_line + begin_line kind + when :end_line + end_line kind + else + raise ArgumentError, 'Unknown token content type: %p, kind = %p' % [content, kind] + end + end + + # Called for each text token ([text, kind]), where text is a String. + def text_token text, kind + @out << text + end + + # Starts a token group with the given +kind+. + def begin_group kind + end + + # Ends a token group with the given +kind+. + def end_group kind + end + + # Starts a new line token group with the given +kind+. + def begin_line kind + end + + # Ends a new line token group with the given +kind+. + def end_line kind + end + + protected + + # Called with merged options before encoding starts. + # Sets @out to an empty string. + # + # See the HTML Encoder for an example of option caching. + def setup options + @out = get_output(options) + end + + def get_output options + options[:out] || '' + end + + # Append data.to_s to the output. Returns the argument. + def output data + @out << data.to_s + data + end + + # Called with merged options after encoding starts. + # The return value is the result of encoding, typically @out. + def finish options + @out + end + + # Do the encoding. + # + # The already created +tokens+ object must be used; it must be a + # Tokens object. + def compile tokens, options = {} + content = nil + for item in tokens + if item.is_a? Array + raise ArgumentError, 'Two-element array tokens are no longer supported.' + end + if content + token content, item + content = nil + else + content = item + end + end + raise 'odd number list for Tokens' if content + end + + alias tokens compile + public :tokens + + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/_map.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/_map.rb new file mode 100644 index 000000000..4cca1963f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/_map.rb @@ -0,0 +1,17 @@ +module CodeRay +module Encoders + + map \ + :loc => :lines_of_code, + :plain => :text, + :plaintext => :text, + :remove_comments => :comment_filter, + :stats => :statistic, + :term => :terminal, + :tty => :terminal, + :yml => :yaml + + # No default because Tokens#nonsense should raise NoMethodError. + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/comment_filter.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/comment_filter.rb new file mode 100644 index 000000000..28336b3d4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/comment_filter.rb @@ -0,0 +1,25 @@ +module CodeRay +module Encoders + + load :token_kind_filter + + # A simple Filter that removes all tokens of the :comment kind. + # + # Alias: +remove_comments+ + # + # Usage: + # CodeRay.scan('print # foo', :ruby).comment_filter.text + # #-> "print " + # + # See also: TokenKindFilter, LinesOfCode + class CommentFilter < TokenKindFilter + + register_for :comment_filter + + DEFAULT_OPTIONS = superclass::DEFAULT_OPTIONS.merge \ + :exclude => [:comment, :docstring] + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/count.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/count.rb new file mode 100644 index 000000000..98a427e18 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/count.rb @@ -0,0 +1,39 @@ +module CodeRay +module Encoders + + # Returns the number of tokens. + # + # Text and block tokens are counted. + class Count < Encoder + + register_for :count + + protected + + def setup options + super + + @count = 0 + end + + def finish options + output @count + end + + public + + def text_token text, kind + @count += 1 + end + + def begin_group kind + @count += 1 + end + alias end_group begin_group + alias begin_line begin_group + alias end_line begin_group + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug.rb new file mode 100644 index 000000000..f4db33019 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug.rb @@ -0,0 +1,49 @@ +module CodeRay +module Encoders + + # = Debug Encoder + # + # Fast encoder producing simple debug output. + # + # It is readable and diff-able and is used for testing. + # + # You cannot fully restore the tokens information from the + # output, because consecutive :space tokens are merged. + # + # See also: Scanners::Debug + class Debug < Encoder + + register_for :debug + + FILE_EXTENSION = 'raydebug' + + def text_token text, kind + if kind == :space + @out << text + else + text = text.gsub('\\', '\\\\\\\\') if text.index('\\') + text = text.gsub(')', '\\\\)') if text.index(')') + @out << "#{kind}(#{text})" + end + end + + def begin_group kind + @out << "#{kind}<" + end + + def end_group kind + @out << '>' + end + + def begin_line kind + @out << "#{kind}[" + end + + def end_line kind + @out << ']' + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug_lint.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug_lint.rb new file mode 100644 index 000000000..a4eba2c74 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/debug_lint.rb @@ -0,0 +1,63 @@ +module CodeRay +module Encoders + + load :lint + + # = Debug Lint Encoder + # + # Debug encoder with additional checks for: + # + # - empty tokens + # - incorrect nesting + # + # It will raise an InvalidTokenStream exception when any of the above occurs. + # + # See also: Encoders::Debug + class DebugLint < Debug + + register_for :debug_lint + + def text_token text, kind + raise Lint::EmptyToken, 'empty token for %p' % [kind] if text.empty? + raise Lint::UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind + super + end + + def begin_group kind + @opened << kind + super + end + + def end_group kind + raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind + @opened.pop + super + end + + def begin_line kind + @opened << kind + super + end + + def end_line kind + raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind + @opened.pop + super + end + + protected + + def setup options + super + @opened = [] + end + + def finish options + raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty? + super + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/div.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/div.rb new file mode 100644 index 000000000..efd9435c2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/div.rb @@ -0,0 +1,23 @@ +module CodeRay +module Encoders + + load :html + + # Wraps HTML output into a DIV element, using inline styles by default. + # + # See Encoders::HTML for available options. + class Div < HTML + + FILE_EXTENSION = 'div.html' + + register_for :div + + DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ + :css => :style, + :wrap => :div, + :line_numbers => false + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/filter.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/filter.rb new file mode 100644 index 000000000..e7f34d6ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/filter.rb @@ -0,0 +1,58 @@ +module CodeRay +module Encoders + + # A Filter encoder has another Tokens instance as output. + # It can be subclass to select, remove, or modify tokens in the stream. + # + # Subclasses of Filter are called "Filters" and can be chained. + # + # == Options + # + # === :tokens + # + # The Tokens object which will receive the output. + # + # Default: Tokens.new + # + # See also: TokenKindFilter + class Filter < Encoder + + register_for :filter + + protected + def setup options + super + + @tokens = options[:tokens] || Tokens.new + end + + def finish options + output @tokens + end + + public + + def text_token text, kind # :nodoc: + @tokens.text_token text, kind + end + + def begin_group kind # :nodoc: + @tokens.begin_group kind + end + + def begin_line kind # :nodoc: + @tokens.begin_line kind + end + + def end_group kind # :nodoc: + @tokens.end_group kind + end + + def end_line kind # :nodoc: + @tokens.end_line kind + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html.rb new file mode 100644 index 000000000..d2ebb5afe --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html.rb @@ -0,0 +1,332 @@ +require 'set' + +module CodeRay +module Encoders + + # = HTML Encoder + # + # This is CodeRay's most important highlighter: + # It provides save, fast XHTML generation and CSS support. + # + # == Usage + # + # require 'coderay' + # puts CodeRay.scan('Some /code/', :ruby).html #-> a HTML page + # puts CodeRay.scan('Some /code/', :ruby).html(:wrap => :span) + # #-> Some /code/ + # puts CodeRay.scan('Some /code/', :ruby).span #-> the same + # + # puts CodeRay.scan('Some code', :ruby).html( + # :wrap => nil, + # :line_numbers => :inline, + # :css => :style + # ) + # + # == Options + # + # === :tab_width + # Convert \t characters to +n+ spaces (a number.) + # + # Default: 8 + # + # === :css + # How to include the styles; can be :class or :style. + # + # Default: :class + # + # === :wrap + # Wrap in :page, :div, :span or nil. + # + # You can also use Encoders::Div and Encoders::Span. + # + # Default: nil + # + # === :title + # + # The title of the HTML page (works only when :wrap is set to :page.) + # + # Default: 'CodeRay output' + # + # === :break_lines + # + # Split multiline blocks at line breaks. + # Forced to true if :line_numbers option is set to :inline. + # + # Default: false + # + # === :line_numbers + # Include line numbers in :table, :inline, or nil (no line numbers) + # + # Default: nil + # + # === :line_number_anchors + # Adds anchors and links to the line numbers. Can be false (off), true (on), + # or a prefix string that will be prepended to the anchor name. + # + # The prefix must consist only of letters, digits, and underscores. + # + # Default: true, default prefix name: "line" + # + # === :line_number_start + # Where to start with line number counting. + # + # Default: 1 + # + # === :bold_every + # Make every +n+-th number appear bold. + # + # Default: 10 + # + # === :highlight_lines + # + # Highlights certain line numbers. + # Can be any Enumerable, typically just an Array or Range, of numbers. + # + # Bolding is deactivated when :highlight_lines is set. It only makes sense + # in combination with :line_numbers. + # + # Default: nil + # + # === :hint + # Include some information into the output using the title attribute. + # Can be :info (show token kind on mouse-over), :info_long (with full path) + # or :debug (via inspect). + # + # Default: false + class HTML < Encoder + + register_for :html + + FILE_EXTENSION = 'snippet.html' + + DEFAULT_OPTIONS = { + :tab_width => 8, + + :css => :class, + :style => :alpha, + :wrap => nil, + :title => 'CodeRay output', + + :break_lines => false, + + :line_numbers => nil, + :line_number_anchors => 'n', + :line_number_start => 1, + :bold_every => 10, + :highlight_lines => nil, + + :hint => false, + } + + autoload :Output, CodeRay.coderay_path('encoders', 'html', 'output') + autoload :CSS, CodeRay.coderay_path('encoders', 'html', 'css') + autoload :Numbering, CodeRay.coderay_path('encoders', 'html', 'numbering') + + attr_reader :css + + protected + + def self.make_html_escape_hash + { + '&' => '&', + '"' => '"', + '>' => '>', + '<' => '<', + # "\t" => will be set to ' ' * options[:tab_width] during setup + }.tap do |hash| + # Escape ASCII control codes except \x9 == \t and \xA == \n. + (Array(0x00..0x8) + Array(0xB..0x1F)).each { |invalid| hash[invalid.chr] = ' ' } + end + end + + HTML_ESCAPE = make_html_escape_hash + HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1F]/ + + TOKEN_KIND_TO_INFO = Hash.new do |h, kind| + h[kind] = kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } + end + + TRANSPARENT_TOKEN_KINDS = Set[ + :delimiter, :modifier, :content, :escape, :inline_delimiter, + ] + + # Generate a hint about the given +kinds+ in a +hint+ style. + # + # +hint+ may be :info, :info_long or :debug. + def self.token_path_to_hint hint, kinds + kinds = Array kinds + title = + case hint + when :info + kinds = kinds[1..-1] if TRANSPARENT_TOKEN_KINDS.include? kinds.first + TOKEN_KIND_TO_INFO[kinds.first] + when :info_long + kinds.reverse.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/') + when :debug + kinds.inspect + end + title ? " title=\"#{title}\"" : '' + end + + def setup options + super + + check_options! options + + if options[:wrap] || options[:line_numbers] + @real_out = @out + @out = '' + end + + @break_lines = (options[:break_lines] == true) + + @HTML_ESCAPE = HTML_ESCAPE.merge("\t" => ' ' * options[:tab_width]) + + @opened = [] + @last_opened = nil + @css = CSS.new options[:style] + + @span_for_kinds = make_span_for_kinds(options[:css], options[:hint]) + + @set_last_opened = options[:hint] || options[:css] == :style + end + + def finish options + unless @opened.empty? + @out << '' while @opened.pop + @last_opened = nil + end + + if @out.respond_to? :to_str + @out.extend Output + @out.css = @css + if options[:line_numbers] + Numbering.number! @out, options[:line_numbers], options + end + @out.wrap! options[:wrap] + @out.apply_title! options[:title] + end + + if defined?(@real_out) && @real_out + @real_out << @out + @out = @real_out + end + + super + end + + public + + def text_token text, kind + style = @span_for_kinds[@last_opened ? [kind, *@opened] : kind] + + text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] } if text =~ /#{HTML_ESCAPE_PATTERN}/o + text = break_lines(text, style) if @break_lines && (style || @opened.size > 0) && text.index("\n") + + if style + @out << style << text << '' + else + @out << text + end + end + + # token groups, eg. strings + def begin_group kind + @out << (@span_for_kinds[@last_opened ? [kind, *@opened] : kind] || '') + @opened << kind + @last_opened = kind if @set_last_opened + end + + def end_group kind + check_group_nesting 'token group', kind if $CODERAY_DEBUG + close_span + end + + # whole lines to be highlighted, eg. a deleted line in a diff + def begin_line kind + if style = @span_for_kinds[@last_opened ? [kind, *@opened] : kind] + if style['class="'] + @out << style.sub('class="', 'class="line ') + else + @out << style.sub('>', ' class="line">') + end + else + @out << '' + end + @opened << kind + @last_opened = kind if @options[:css] == :style + end + + def end_line kind + check_group_nesting 'line', kind if $CODERAY_DEBUG + close_span + end + + protected + + def check_options! options + unless [false, nil, :debug, :info, :info_long].include? options[:hint] + raise ArgumentError, "Unknown value %p for :hint; expected :info, :info_long, :debug, false, or nil." % [options[:hint]] + end + + unless [:class, :style].include? options[:css] + raise ArgumentError, 'Unknown value %p for :css.' % [options[:css]] + end + + options[:break_lines] = true if options[:line_numbers] == :inline + end + + def css_class_for_kinds kinds + TokenKinds[kinds.is_a?(Symbol) ? kinds : kinds.first] + end + + def style_for_kinds kinds + css_classes = kinds.is_a?(Array) ? kinds.map { |c| TokenKinds[c] } : [TokenKinds[kinds]] + @css.get_style_for_css_classes css_classes + end + + def make_span_for_kinds method, hint + Hash.new do |h, kinds| + begin + css_class = css_class_for_kinds(kinds) + title = HTML.token_path_to_hint hint, kinds if hint + + if css_class || title + if method == :style + style = style_for_kinds(kinds) + "" + else + "" + end + end + end.tap do |span| + h.clear if h.size >= 100 + h[kinds] = span + end + end + end + + def check_group_nesting name, kind + if @opened.empty? || @opened.last != kind + warn "Malformed token stream: Trying to close a #{name} (%p) that is not open. Open are: %p." % [kind, @opened[1..-1]] + end + end + + def break_lines text, style + reopen = '' + @opened.each_with_index do |kind, index| + reopen << (@span_for_kinds[index > 0 ? [kind, *@opened[0...index]] : kind] || '') + end + text.gsub("\n", "#{'' * @opened.size}#{'' if style}\n#{reopen}#{style}") + end + + def close_span + if @opened.pop + @out << '' + @last_opened = @opened.last if @last_opened + end + end + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/css.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/css.rb new file mode 100644 index 000000000..164d7f852 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/css.rb @@ -0,0 +1,65 @@ +module CodeRay +module Encoders + + class HTML + class CSS # :nodoc: + + attr :stylesheet + + def CSS.load_stylesheet style = nil + CodeRay::Styles[style] + end + + def initialize style = :default + @styles = Hash.new + style = CSS.load_stylesheet style + @stylesheet = [ + style::CSS_MAIN_STYLES, + style::TOKEN_COLORS.gsub(/^(?!$)/, '.CodeRay ') + ].join("\n") + parse style::TOKEN_COLORS + end + + def get_style_for_css_classes css_classes + cl = @styles[css_classes.first] + return '' unless cl + style = '' + 1.upto css_classes.size do |offset| + break if style = cl[css_classes[offset .. -1]] + end + # warn 'Style not found: %p' % [styles] if style.empty? + return style + end + + private + + CSS_CLASS_PATTERN = / + ( # $1 = selectors + (?: + (?: \s* \. [-\w]+ )+ + \s* ,? + )+ + ) + \s* \{ \s* + ( [^\}]+ )? # $2 = style + \s* \} \s* + | + ( [^\n]+ ) # $3 = error + /mx + def parse stylesheet + stylesheet.scan CSS_CLASS_PATTERN do |selectors, style, error| + raise "CSS parse error: '#{error.inspect}' not recognized" if error + for selector in selectors.split(',') + classes = selector.scan(/[-\w]+/) + cl = classes.pop + @styles[cl] ||= Hash.new + @styles[cl][classes] = style.to_s.strip.delete(' ').chomp(';') + end + end + end + + end + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/numbering.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/numbering.rb new file mode 100644 index 000000000..a1b9c04a0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/numbering.rb @@ -0,0 +1,108 @@ +module CodeRay +module Encoders + + class HTML + + module Numbering # :nodoc: + + def self.number! output, mode = :table, options = {} + return self unless mode + + options = DEFAULT_OPTIONS.merge options + + start = options[:line_number_start] + unless start.is_a? Integer + raise ArgumentError, "Invalid value %p for :line_number_start; Integer expected." % start + end + + anchor_prefix = options[:line_number_anchors] + anchor_prefix = 'line' if anchor_prefix == true + anchor_prefix = anchor_prefix.to_s[/[\w-]+/] if anchor_prefix + anchoring = + if anchor_prefix + proc do |line| + line = line.to_s + anchor = anchor_prefix + line + "#{line}" + end + else + :to_s.to_proc + end + + bold_every = options[:bold_every] + highlight_lines = options[:highlight_lines] + bolding = + if bold_every == false && highlight_lines == nil + anchoring + elsif highlight_lines.is_a? Enumerable + highlight_lines = highlight_lines.to_set + proc do |line| + if highlight_lines.include? line + "#{anchoring[line]}" # highlighted line numbers in bold + else + anchoring[line] + end + end + elsif bold_every.is_a? Integer + raise ArgumentError, ":bolding can't be 0." if bold_every == 0 + proc do |line| + if line % bold_every == 0 + "#{anchoring[line]}" # every bold_every-th number in bold + else + anchoring[line] + end + end + else + raise ArgumentError, 'Invalid value %p for :bolding; false or Integer expected.' % bold_every + end + + if position_of_last_newline = output.rindex(RUBY_VERSION >= '1.9' ? /\n/ : ?\n) + after_last_newline = output[position_of_last_newline + 1 .. -1] + ends_with_newline = after_last_newline[/\A(?:<\/span>)*\z/] + + if ends_with_newline + line_count = output.count("\n") + else + line_count = output.count("\n") + 1 + end + else + line_count = 1 + end + + case mode + when :inline + max_width = (start + line_count).to_s.size + line_number = start + output.gsub!(/^.*$\n?/) do |line| + line_number_text = bolding.call line_number + indent = ' ' * (max_width - line_number.to_s.size) + line_number += 1 + "#{indent}#{line_number_text}#{line}" + end + + when :table + line_numbers = (start ... start + line_count).map(&bolding).join("\n") + line_numbers << "\n" + line_numbers_table_template = Output::TABLE.apply('LINE_NUMBERS', line_numbers) + + output.gsub!(/<\/div>\n/, '
') + output.wrap_in! line_numbers_table_template + output.wrapped_in = :div + + when :list + raise NotImplementedError, 'The :list option is no longer available. Use :table.' + + else + raise ArgumentError, 'Unknown value %p for mode: expected one of %p' % + [mode, [:table, :inline]] + end + + output + end + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/output.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/output.rb new file mode 100644 index 000000000..de6f6ea1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/html/output.rb @@ -0,0 +1,166 @@ +module CodeRay +module Encoders + + class HTML + + # This module is included in the output String of the HTML Encoder. + # + # It provides methods like wrap, div, page etc. + # + # Remember to use #clone instead of #dup to keep the modules the object was + # extended with. + # + # TODO: Rewrite this without monkey patching. + module Output + + attr_accessor :css + + class << self + + # Raises an exception if an object that doesn't respond to to_str is extended by Output, + # to prevent users from misuse. Use Module#remove_method to disable. + def extended o # :nodoc: + warn "The Output module is intended to extend instances of String, not #{o.class}." unless o.respond_to? :to_str + end + + def make_stylesheet css, in_tag = false # :nodoc: + sheet = css.stylesheet + sheet = <<-'CSS' if in_tag + + CSS + sheet + end + + def page_template_for_css css # :nodoc: + sheet = make_stylesheet css + PAGE.apply 'CSS', sheet + end + + end + + def wrapped_in? element + wrapped_in == element + end + + def wrapped_in + @wrapped_in ||= nil + end + attr_writer :wrapped_in + + def wrap_in! template + Template.wrap! self, template, 'CONTENT' + self + end + + def apply_title! title + self.sub!(/()(<\/title>)/) { $1 + title + $2 } + self + end + + def wrap! element, *args + return self if not element or element == wrapped_in + case element + when :div + raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil + wrap_in! DIV + when :span + raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil + wrap_in! SPAN + when :page + wrap! :div if wrapped_in? nil + raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? :div + wrap_in! Output.page_template_for_css(@css) + if args.first.is_a?(Hash) && title = args.first[:title] + apply_title! title + end + self + when nil + return self + else + raise "Unknown value %p for :wrap" % element + end + @wrapped_in = element + self + end + + def stylesheet in_tag = false + Output.make_stylesheet @css, in_tag + end + +#-- don't include the templates in docu + + class Template < String # :nodoc: + + def self.wrap! str, template, target + target = Regexp.new(Regexp.escape("<%#{target}%>")) + if template =~ target + str[0,0] = $` + str << $' + else + raise "Template target <%%%p%%> not found" % target + end + end + + def apply target, replacement + target = Regexp.new(Regexp.escape("<%#{target}%>")) + if self =~ target + Template.new($` + replacement + $') + else + raise "Template target <%%%p%%> not found" % target + end + end + + end + + SPAN = Template.new '<span class="CodeRay"><%CONTENT%></span>' + + DIV = Template.new <<-DIV +<div class="CodeRay"> + <div class="code"><pre><%CONTENT%></pre></div> +</div> + DIV + + TABLE = Template.new <<-TABLE +<table class="CodeRay"><tr> + <td class="line-numbers"><pre><%LINE_NUMBERS%></pre></td> + <td class="code"><pre><%CONTENT%></pre></td> +</tr></table> + TABLE + + PAGE = Template.new <<-PAGE +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title> + + + + +<%CONTENT%> + + + PAGE + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/json.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/json.rb new file mode 100644 index 000000000..a9e40dc60 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/json.rb @@ -0,0 +1,83 @@ +module CodeRay +module Encoders + + # A simple JSON Encoder. + # + # Example: + # CodeRay.scan('puts "Hello world!"', :ruby).json + # yields + # [ + # {"type"=>"text", "text"=>"puts", "kind"=>"ident"}, + # {"type"=>"text", "text"=>" ", "kind"=>"space"}, + # {"type"=>"block", "action"=>"open", "kind"=>"string"}, + # {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, + # {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"}, + # {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, + # {"type"=>"block", "action"=>"close", "kind"=>"string"}, + # ] + class JSON < Encoder + + begin + require 'json' + rescue LoadError + begin + require 'rubygems' unless defined? Gem + gem 'json' + require 'json' + rescue LoadError + $stderr.puts "The JSON encoder needs the JSON library.\n" \ + "Please gem install json." + raise + end + end + + register_for :json + FILE_EXTENSION = 'json' + + protected + def setup options + super + + @first = true + @out << '[' + end + + def finish options + @out << ']' + end + + def append data + if @first + @first = false + else + @out << ',' + end + + @out << data.to_json + end + + public + def text_token text, kind + append :type => 'text', :text => text, :kind => kind + end + + def begin_group kind + append :type => 'block', :action => 'open', :kind => kind + end + + def end_group kind + append :type => 'block', :action => 'close', :kind => kind + end + + def begin_line kind + append :type => 'block', :action => 'begin_line', :kind => kind + end + + def end_line kind + append :type => 'block', :action => 'end_line', :kind => kind + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lines_of_code.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lines_of_code.rb new file mode 100644 index 000000000..5f8422f3d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lines_of_code.rb @@ -0,0 +1,45 @@ +module CodeRay +module Encoders + + # Counts the LoC (Lines of Code). Returns an Integer >= 0. + # + # Alias: +loc+ + # + # Everything that is not comment, markup, doctype/shebang, or an empty line, + # is considered to be code. + # + # For example, + # * HTML files not containing JavaScript have 0 LoC + # * in a Java class without comments, LoC is the number of non-empty lines + # + # A Scanner class should define the token kinds that are not code in the + # KINDS_NOT_LOC constant, which defaults to [:comment, :doctype]. + class LinesOfCode < TokenKindFilter + + register_for :lines_of_code + + NON_EMPTY_LINE = /^\s*\S.*$/ + + protected + + def setup options + if scanner + kinds_not_loc = scanner.class::KINDS_NOT_LOC + else + warn "Tokens have no associated scanner, counting all nonempty lines." if $VERBOSE + kinds_not_loc = CodeRay::Scanners::Scanner::KINDS_NOT_LOC + end + + options[:exclude] = kinds_not_loc + + super options + end + + def finish options + output @tokens.text.scan(NON_EMPTY_LINE).size + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lint.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lint.rb new file mode 100644 index 000000000..88c8bd1d5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/lint.rb @@ -0,0 +1,59 @@ +module CodeRay +module Encoders + + # = Lint Encoder + # + # Checks for: + # + # - empty tokens + # - incorrect nesting + # + # It will raise an InvalidTokenStream exception when any of the above occurs. + # + # See also: Encoders::DebugLint + class Lint < Debug + + register_for :lint + + InvalidTokenStream = Class.new StandardError + EmptyToken = Class.new InvalidTokenStream + UnknownTokenKind = Class.new InvalidTokenStream + IncorrectTokenGroupNesting = Class.new InvalidTokenStream + + def text_token text, kind + raise EmptyToken, 'empty token for %p' % [kind] if text.empty? + raise UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind + end + + def begin_group kind + @opened << kind + end + + def end_group kind + raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind + @opened.pop + end + + def begin_line kind + @opened << kind + end + + def end_line kind + raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind + @opened.pop + end + + protected + + def setup options + @opened = [] + end + + def finish options + raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty? + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/null.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/null.rb new file mode 100644 index 000000000..73ba47d35 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/null.rb @@ -0,0 +1,18 @@ +module CodeRay +module Encoders + + # = Null Encoder + # + # Does nothing and returns an empty string. + class Null < Encoder + + register_for :null + + def text_token text, kind + # do nothing + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/page.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/page.rb new file mode 100644 index 000000000..800e73f32 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/page.rb @@ -0,0 +1,24 @@ +module CodeRay +module Encoders + + load :html + + # Wraps the output into a HTML page, using CSS classes and + # line numbers in the table format by default. + # + # See Encoders::HTML for available options. + class Page < HTML + + FILE_EXTENSION = 'html' + + register_for :page + + DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ + :css => :class, + :wrap => :page, + :line_numbers => :table + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/span.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/span.rb new file mode 100644 index 000000000..da705bdc0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/span.rb @@ -0,0 +1,23 @@ +module CodeRay +module Encoders + + load :html + + # Wraps HTML output into a SPAN element, using inline styles by default. + # + # See Encoders::HTML for available options. + class Span < HTML + + FILE_EXTENSION = 'span.html' + + register_for :span + + DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ + :css => :style, + :wrap => :span, + :line_numbers => false + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/statistic.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/statistic.rb new file mode 100644 index 000000000..b2f8b8306 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/statistic.rb @@ -0,0 +1,95 @@ +module CodeRay +module Encoders + + # Makes a statistic for the given tokens. + # + # Alias: +stats+ + class Statistic < Encoder + + register_for :statistic + + attr_reader :type_stats, :real_token_count # :nodoc: + + TypeStats = Struct.new :count, :size # :nodoc: + + protected + + def setup options + super + + @type_stats = Hash.new { |h, k| h[k] = TypeStats.new 0, 0 } + @real_token_count = 0 + end + + STATS = <<-STATS # :nodoc: + +Code Statistics + +Tokens %8d + Non-Whitespace %8d +Bytes Total %8d + +Token Types (%d): + type count ratio size (average) +------------------------------------------------------------- +%s + STATS + + TOKEN_TYPES_ROW = <<-TKR # :nodoc: + %-20s %8d %6.2f %% %5.1f + TKR + + def finish options + all = @type_stats['TOTAL'] + all_count, all_size = all.count, all.size + @type_stats.each do |type, stat| + stat.size /= stat.count.to_f + end + types_stats = @type_stats.sort_by { |k, v| [-v.count, k.to_s] }.map do |k, v| + TOKEN_TYPES_ROW % [k, v.count, 100.0 * v.count / all_count, v.size] + end.join + @out << STATS % [ + all_count, @real_token_count, all_size, + @type_stats.delete_if { |k, v| k.is_a? String }.size, + types_stats + ] + + super + end + + public + + def text_token text, kind + @real_token_count += 1 unless kind == :space + @type_stats[kind].count += 1 + @type_stats[kind].size += text.size + @type_stats['TOTAL'].size += text.size + @type_stats['TOTAL'].count += 1 + end + + def begin_group kind + block_token ':begin_group', kind + end + + def end_group kind + block_token ':end_group', kind + end + + def begin_line kind + block_token ':begin_line', kind + end + + def end_line kind + block_token ':end_line', kind + end + + def block_token action, kind + @type_stats['TOTAL'].count += 1 + @type_stats[action].count += 1 + @type_stats[kind].count += 1 + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/terminal.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/terminal.rb new file mode 100644 index 000000000..c7ae01464 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/terminal.rb @@ -0,0 +1,195 @@ +module CodeRay + module Encoders + + # Outputs code highlighted for a color terminal. + # + # Note: This encoder is in beta. It currently doesn't use the Styles. + # + # Alias: +term+ + # + # == Authors & License + # + # By Rob Aldred (http://robaldred.co.uk) + # + # Based on idea by Nathan Weizenbaum (http://nex-3.com) + # + # MIT License (http://www.opensource.org/licenses/mit-license.php) + class Terminal < Encoder + + register_for :terminal + + TOKEN_COLORS = { + :debug => "\e[1;37;44m", + + :annotation => "\e[34m", + :attribute_name => "\e[35m", + :attribute_value => "\e[31m", + :binary => { + :self => "\e[31m", + :char => "\e[1;31m", + :delimiter => "\e[1;31m", + }, + :char => { + :self => "\e[35m", + :delimiter => "\e[1;35m" + }, + :class => "\e[1;35;4m", + :class_variable => "\e[36m", + :color => "\e[32m", + :comment => { + :self => "\e[1;30m", + :char => "\e[37m", + :delimiter => "\e[37m", + }, + :constant => "\e[1;34;4m", + :decorator => "\e[35m", + :definition => "\e[1;33m", + :directive => "\e[33m", + :docstring => "\e[31m", + :doctype => "\e[1;34m", + :done => "\e[1;30;2m", + :entity => "\e[31m", + :error => "\e[1;37;41m", + :exception => "\e[1;31m", + :float => "\e[1;35m", + :function => "\e[1;34m", + :global_variable => "\e[1;32m", + :hex => "\e[1;36m", + :id => "\e[1;34m", + :include => "\e[31m", + :integer => "\e[1;34m", + :imaginary => "\e[1;34m", + :important => "\e[1;31m", + :key => { + :self => "\e[35m", + :char => "\e[1;35m", + :delimiter => "\e[1;35m", + }, + :keyword => "\e[32m", + :label => "\e[1;33m", + :local_variable => "\e[33m", + :namespace => "\e[1;35m", + :octal => "\e[1;34m", + :predefined => "\e[36m", + :predefined_constant => "\e[1;36m", + :predefined_type => "\e[1;32m", + :preprocessor => "\e[1;36m", + :pseudo_class => "\e[1;34m", + :regexp => { + :self => "\e[35m", + :delimiter => "\e[1;35m", + :modifier => "\e[35m", + :char => "\e[1;35m", + }, + :reserved => "\e[32m", + :shell => { + :self => "\e[33m", + :char => "\e[1;33m", + :delimiter => "\e[1;33m", + :escape => "\e[1;33m", + }, + :string => { + :self => "\e[31m", + :modifier => "\e[1;31m", + :char => "\e[1;35m", + :delimiter => "\e[1;31m", + :escape => "\e[1;31m", + }, + :symbol => { + :self => "\e[33m", + :delimiter => "\e[1;33m", + }, + :tag => "\e[32m", + :type => "\e[1;34m", + :value => "\e[36m", + :variable => "\e[34m", + + :insert => { + :self => "\e[42m", + :insert => "\e[1;32;42m", + :eyecatcher => "\e[102m", + }, + :delete => { + :self => "\e[41m", + :delete => "\e[1;31;41m", + :eyecatcher => "\e[101m", + }, + :change => { + :self => "\e[44m", + :change => "\e[37;44m", + }, + :head => { + :self => "\e[45m", + :filename => "\e[37;45m" + }, + } + + TOKEN_COLORS[:keyword] = TOKEN_COLORS[:reserved] + TOKEN_COLORS[:method] = TOKEN_COLORS[:function] + TOKEN_COLORS[:escape] = TOKEN_COLORS[:delimiter] + + protected + + def setup(options) + super + @opened = [] + @color_scopes = [TOKEN_COLORS] + end + + public + + def text_token text, kind + if color = @color_scopes.last[kind] + color = color[:self] if color.is_a? Hash + + @out << color + @out << (text.index("\n") ? text.gsub("\n", "\e[0m\n" + color) : text) + @out << "\e[0m" + if outer_color = @color_scopes.last[:self] + @out << outer_color + end + else + @out << text + end + end + + def begin_group kind + @opened << kind + @out << open_token(kind) + end + alias begin_line begin_group + + def end_group kind + if @opened.pop + @color_scopes.pop + @out << "\e[0m" + if outer_color = @color_scopes.last[:self] + @out << outer_color + end + end + end + + def end_line kind + @out << (@line_filler ||= "\t" * 100) + end_group kind + end + + private + + def open_token kind + if color = @color_scopes.last[kind] + if color.is_a? Hash + @color_scopes << color + color[:self] + else + @color_scopes << @color_scopes.last + color + end + else + @color_scopes << @color_scopes.last + '' + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/text.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/text.rb new file mode 100644 index 000000000..15c66f9c7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/text.rb @@ -0,0 +1,46 @@ +module CodeRay +module Encoders + + # Concats the tokens into a single string, resulting in the original + # code string if no tokens were removed. + # + # Alias: +plain+, +plaintext+ + # + # == Options + # + # === :separator + # A separator string to join the tokens. + # + # Default: empty String + class Text < Encoder + + register_for :text + + FILE_EXTENSION = 'txt' + + DEFAULT_OPTIONS = { + :separator => nil + } + + def text_token text, kind + super + + if @first + @first = false + else + @out << @sep + end if @sep + end + + protected + def setup options + super + + @first = true + @sep = options[:separator] + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/token_kind_filter.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/token_kind_filter.rb new file mode 100644 index 000000000..4773ea34e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/token_kind_filter.rb @@ -0,0 +1,111 @@ +module CodeRay +module Encoders + + load :filter + + # A Filter that selects tokens based on their token kind. + # + # == Options + # + # === :exclude + # + # One or many symbols (in an Array) which shall be excluded. + # + # Default: [] + # + # === :include + # + # One or many symbols (in an array) which shall be included. + # + # Default: :all, which means all tokens are included. + # + # Exclusion wins over inclusion. + # + # See also: CommentFilter + class TokenKindFilter < Filter + + register_for :token_kind_filter + + DEFAULT_OPTIONS = { + :exclude => [], + :include => :all + } + + protected + def setup options + super + + @group_excluded = false + @exclude = options[:exclude] + @exclude = Array(@exclude) unless @exclude == :all + @include = options[:include] + @include = Array(@include) unless @include == :all + end + + def include_text_token? text, kind + include_group? kind + end + + def include_group? kind + (@include == :all || @include.include?(kind)) && + !(@exclude == :all || @exclude.include?(kind)) + end + + public + + # Add the token to the output stream if +kind+ matches the conditions. + def text_token text, kind + super if !@group_excluded && include_text_token?(text, kind) + end + + # Add the token group to the output stream if +kind+ matches the + # conditions. + # + # If it does not, all tokens inside the group are excluded from the + # stream, even if their kinds match. + def begin_group kind + if @group_excluded + @group_excluded += 1 + elsif include_group? kind + super + else + @group_excluded = 1 + end + end + + # See +begin_group+. + def begin_line kind + if @group_excluded + @group_excluded += 1 + elsif include_group? kind + super + else + @group_excluded = 1 + end + end + + # Take care of re-enabling the delegation of tokens to the output stream + # if an exluded group has ended. + def end_group kind + if @group_excluded + @group_excluded -= 1 + @group_excluded = false if @group_excluded.zero? + else + super + end + end + + # See +end_group+. + def end_line kind + if @group_excluded + @group_excluded -= 1 + @group_excluded = false if @group_excluded.zero? + else + super + end + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/xml.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/xml.rb new file mode 100644 index 000000000..3d306a608 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/xml.rb @@ -0,0 +1,72 @@ +module CodeRay +module Encoders + + # = XML Encoder + # + # Uses REXML. Very slow. + class XML < Encoder + + register_for :xml + + FILE_EXTENSION = 'xml' + + autoload :REXML, 'rexml/document' + + DEFAULT_OPTIONS = { + :tab_width => 8, + :pretty => -1, + :transitive => false, + } + + protected + def setup options + super + + @doc = REXML::Document.new + @doc << REXML::XMLDecl.new + @tab_width = options[:tab_width] + @root = @node = @doc.add_element('coderay-tokens') + end + + def finish options + @doc.write @out, options[:pretty], options[:transitive], true + + super + end + + public + def text_token text, kind + if kind == :space + token = @node + else + token = @node.add_element kind.to_s + end + text.scan(/(\x20+)|(\t+)|(\n)|[^\x20\t\n]+/) do |space, tab, nl| + case + when space + token << REXML::Text.new(space, true) + when tab + token << REXML::Text.new(tab, true) + when nl + token << REXML::Text.new(nl, true) + else + token << REXML::Text.new($&) + end + end + end + + def begin_group kind + @node = @node.add_element kind.to_s + end + + def end_group kind + if @node == @root + raise 'no token to close!' + end + @node = @node.parent + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/yaml.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/yaml.rb new file mode 100644 index 000000000..ba6e71555 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/encoders/yaml.rb @@ -0,0 +1,50 @@ +autoload :YAML, 'yaml' + +module CodeRay +module Encoders + + # = YAML Encoder + # + # Slow. + class YAML < Encoder + + register_for :yaml + + FILE_EXTENSION = 'yaml' + + protected + def setup options + super + + @data = [] + end + + def finish options + output ::YAML.dump(@data) + end + + public + def text_token text, kind + @data << [text, kind] + end + + def begin_group kind + @data << [:begin_group, kind] + end + + def end_group kind + @data << [:end_group, kind] + end + + def begin_line kind + @data << [:begin_line, kind] + end + + def end_line kind + @data << [:end_line, kind] + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/for_redcloth.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/for_redcloth.rb new file mode 100644 index 000000000..f9df32be6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/for_redcloth.rb @@ -0,0 +1,95 @@ +module CodeRay + + # A little hack to enable CodeRay highlighting in RedCloth. + # + # Usage: + # require 'coderay' + # require 'coderay/for_redcloth' + # RedCloth.new('@[ruby]puts "Hello, World!"@').to_html + # + # Make sure you have RedCloth 4.0.3 activated, for example by calling + # require 'rubygems' + # before RedCloth is loaded and before calling CodeRay.for_redcloth. + module ForRedCloth + + def self.install + gem 'RedCloth', '>= 4.0.3' if defined? gem + require 'redcloth' + unless RedCloth::VERSION.to_s >= '4.0.3' + if defined? gem + raise 'CodeRay.for_redcloth needs RedCloth version 4.0.3 or later. ' + + "You have #{RedCloth::VERSION}. Please gem install RedCloth." + else + $".delete 'redcloth.rb' # sorry, but it works + require 'rubygems' + return install # retry + end + end + unless RedCloth::VERSION.to_s >= '4.2.2' + warn 'CodeRay.for_redcloth works best with RedCloth version 4.2.2 or later.' + end + RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc + RedCloth::Formatters::HTML.module_eval do + def unescape(html) # :nodoc: + replacements = { + '&' => '&', + '"' => '"', + '>' => '>', + '<' => '<', + } + html.gsub(/&(?:amp|quot|[gl]t);/) { |entity| replacements[entity] } + end + undef code, bc_open, bc_close, escape_pre + def code(opts) # :nodoc: + opts[:block] = true + if !opts[:lang] && RedCloth::VERSION.to_s >= '4.2.0' + # simulating pre-4.2 behavior + if opts[:text].sub!(/\A\[(\w+)\]/, '') + if CodeRay::Scanners[$1].lang == :text + opts[:text] = $& + opts[:text] + else + opts[:lang] = $1 + end + end + end + if opts[:lang] && !filter_coderay + require 'coderay' + @in_bc ||= nil + format = @in_bc ? :div : :span + opts[:text] = unescape(opts[:text]) unless @in_bc + highlighted_code = CodeRay.encode opts[:text], opts[:lang], format + highlighted_code.sub!(/\A<(span|div)/) { |m| m + pba(@in_bc || opts) } + highlighted_code + else + "#{opts[:text]}" + end + end + def bc_open(opts) # :nodoc: + opts[:block] = true + @in_bc = opts + opts[:lang] ? '' : "" + end + def bc_close(opts) # :nodoc: + opts = @in_bc + @in_bc = nil + opts[:lang] ? '' : "\n" + end + def escape_pre(text) # :nodoc: + if @in_bc ||= nil + text + else + html_esc(text, :html_escape_preformatted) + end + end + end + end + + module TextileDoc # :nodoc: + attr_accessor :filter_coderay + end + + end + +end + +CodeRay::ForRedCloth.install \ No newline at end of file diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/file_type.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/file_type.rb new file mode 100644 index 000000000..7de34d58e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/file_type.rb @@ -0,0 +1,151 @@ +module CodeRay + + # = FileType + # + # A simple filetype recognizer. + # + # == Usage + # + # # determine the type of the given + # lang = FileType[file_name] + # + # # return :text if the file type is unknown + # lang = FileType.fetch file_name, :text + # + # # try the shebang line, too + # lang = FileType.fetch file_name, :text, true + module FileType + + UnknownFileType = Class.new Exception + + class << self + + # Try to determine the file type of the file. + # + # +filename+ is a relative or absolute path to a file. + # + # The file itself is only accessed when +read_shebang+ is set to true. + # That means you can get filetypes from files that don't exist. + def [] filename, read_shebang = false + name = File.basename filename + ext = File.extname(name).sub(/^\./, '') # from last dot, delete the leading dot + ext2 = filename.to_s[/\.(.*)/, 1] # from first dot + + type = + TypeFromExt[ext] || + TypeFromExt[ext.downcase] || + (TypeFromExt[ext2] if ext2) || + (TypeFromExt[ext2.downcase] if ext2) || + TypeFromName[name] || + TypeFromName[name.downcase] + type ||= type_from_shebang(filename) if read_shebang + + type + end + + # This works like Hash#fetch. + # + # If the filetype cannot be found, the +default+ value + # is returned. + def fetch filename, default = nil, read_shebang = false + if default && block_given? + warn 'Block supersedes default value argument; use either.' + end + + if type = self[filename, read_shebang] + type + else + return yield if block_given? + return default if default + raise UnknownFileType, 'Could not determine type of %p.' % filename + end + end + + protected + + def type_from_shebang filename + return unless File.exist? filename + File.open filename, 'r' do |f| + if first_line = f.gets + if type = first_line[TypeFromShebang] + type.to_sym + end + end + end + end + + end + + TypeFromExt = { + 'c' => :c, + 'cfc' => :xml, + 'cfm' => :xml, + 'clj' => :clojure, + 'css' => :css, + 'diff' => :diff, + 'dpr' => :delphi, + 'erb' => :erb, + 'gemspec' => :ruby, + 'go' => :go, + 'groovy' => :groovy, + 'gvy' => :groovy, + 'h' => :c, + 'haml' => :haml, + 'htm' => :html, + 'html' => :html, + 'html.erb' => :erb, + 'java' => :java, + 'js' => :java_script, + 'json' => :json, + 'lua' => :lua, + 'mab' => :ruby, + 'pas' => :delphi, + 'patch' => :diff, + 'phtml' => :php, + 'php' => :php, + 'php3' => :php, + 'php4' => :php, + 'php5' => :php, + 'prawn' => :ruby, + 'py' => :python, + 'py3' => :python, + 'pyw' => :python, + 'rake' => :ruby, + 'raydebug' => :raydebug, + 'rb' => :ruby, + 'rbw' => :ruby, + 'rhtml' => :erb, + 'rjs' => :ruby, + 'rpdf' => :ruby, + 'ru' => :ruby, # config.ru + 'rxml' => :ruby, + 'sass' => :sass, + 'sql' => :sql, + 'taskpaper' => :taskpaper, + 'template' => :json, # AWS CloudFormation template + 'tmproj' => :xml, + 'xaml' => :xml, + 'xhtml' => :html, + 'xml' => :xml, + 'yaml' => :yaml, + 'yml' => :yaml, + } + for cpp_alias in %w[cc cpp cp cxx c++ C hh hpp h++ cu] + TypeFromExt[cpp_alias] = :cpp + end + + TypeFromShebang = /\b(?:ruby|perl|python|sh)\b/ + + TypeFromName = { + 'Capfile' => :ruby, + 'Rakefile' => :ruby, + 'Rantfile' => :ruby, + 'Gemfile' => :ruby, + 'Guardfile' => :ruby, + 'Vagrantfile' => :ruby, + 'Appraisals' => :ruby + } + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/plugin.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/plugin.rb new file mode 100644 index 000000000..9a724ffff --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/plugin.rb @@ -0,0 +1,274 @@ +module CodeRay + + # = PluginHost + # + # A simple subclass/subfolder plugin system. + # + # Example: + # class Generators + # extend PluginHost + # plugin_path 'app/generators' + # end + # + # class Generator + # extend Plugin + # PLUGIN_HOST = Generators + # end + # + # class FancyGenerator < Generator + # register_for :fancy + # end + # + # Generators[:fancy] #-> FancyGenerator + # # or + # CodeRay.require_plugin 'Generators/fancy' + # # or + # Generators::Fancy + module PluginHost + + # Raised if Encoders::[] fails because: + # * a file could not be found + # * the requested Plugin is not registered + PluginNotFound = Class.new LoadError + HostNotFound = Class.new LoadError + + PLUGIN_HOSTS = [] + PLUGIN_HOSTS_BY_ID = {} # dummy hash + + # Loads all plugins using list and load. + def load_all + for plugin in list + load plugin + end + end + + # Returns the Plugin for +id+. + # + # Example: + # yaml_plugin = MyPluginHost[:yaml] + def [] id, *args, &blk + plugin = validate_id(id) + begin + plugin = plugin_hash.[](plugin, *args, &blk) + end while plugin.is_a? String + plugin + end + + alias load [] + + # Tries to +load+ the missing plugin by translating +const+ to the + # underscore form (eg. LinesOfCode becomes lines_of_code). + def const_missing const + id = const.to_s. + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + downcase + load id + end + + class << self + + # Adds the module/class to the PLUGIN_HOSTS list. + def extended mod + PLUGIN_HOSTS << mod + end + + end + + # The path where the plugins can be found. + def plugin_path *args + unless args.empty? + @plugin_path = File.expand_path File.join(*args) + end + @plugin_path ||= '' + end + + # Map a plugin_id to another. + # + # Usage: Put this in a file plugin_path/_map.rb. + # + # class MyColorHost < PluginHost + # map :navy => :dark_blue, + # :maroon => :brown, + # :luna => :moon + # end + def map hash + for from, to in hash + from = validate_id from + to = validate_id to + plugin_hash[from] = to unless plugin_hash.has_key? from + end + end + + # Define the default plugin to use when no plugin is found + # for a given id, or return the default plugin. + # + # See also map. + # + # class MyColorHost < PluginHost + # map :navy => :dark_blue + # default :gray + # end + # + # MyColorHost.default # loads and returns the Gray plugin + def default id = nil + if id + id = validate_id id + raise "The default plugin can't be named \"default\"." if id == :default + plugin_hash[:default] = id + else + load :default + end + end + + # Every plugin must register itself for +id+ by calling register_for, + # which calls this method. + # + # See Plugin#register_for. + def register plugin, id + plugin_hash[validate_id(id)] = plugin + end + + # A Hash of plugion_id => Plugin pairs. + def plugin_hash + @plugin_hash ||= (@plugin_hash = make_plugin_hash).tap { load_plugin_map } + end + + # Returns an array of all .rb files in the plugin path. + # + # The extension .rb is not included. + def list + Dir[path_to('*')].select do |file| + File.basename(file)[/^(?!_)\w+\.rb$/] + end.map do |file| + File.basename(file, '.rb').to_sym + end + end + + # Returns an array of all Plugins. + # + # Note: This loads all plugins using load_all. + def all_plugins + load_all + plugin_hash.values.grep(Class) + end + + # Loads the map file (see map). + # + # This is done automatically when plugin_path is called. + def load_plugin_map + mapfile = path_to '_map' + if File.exist? mapfile + require mapfile + true + else + false + end + end + + protected + + # Return a plugin hash that automatically loads plugins. + def make_plugin_hash + Hash.new do |h, plugin_id| + id = validate_id(plugin_id) + path = path_to id + begin + require path + rescue LoadError => boom + if h.has_key?(:default) + h[:default] + else + raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom] + end + else + # Plugin should have registered by now + if h.has_key? id + h[id] + else + raise PluginNotFound, "No #{self.name} plugin for #{id.inspect} found in #{path}." + end + end + end + end + + # Returns the expected path to the plugin file for the given id. + def path_to plugin_id + File.join plugin_path, "#{plugin_id}.rb" + end + + # Converts +id+ to a valid plugin ID String, or returns +nil+. + # + # Raises +ArgumentError+ for all other objects, or if the + # given String includes non-alphanumeric characters (\W). + def validate_id id + case id + when Symbol + id.to_s + when String + if id[/\w+/] == id + id.downcase + else + raise ArgumentError, "Invalid id given: #{id}" + end + else + raise ArgumentError, "Symbol or String expected, but #{id.class} given." + end + end + + end + + + # = Plugin + # + # Plugins have to include this module. + # + # IMPORTANT: Use extend for this module. + # + # See CodeRay::PluginHost for examples. + module Plugin + + attr_reader :plugin_id + + # Register this class for the given +id+. + # + # Example: + # class MyPlugin < PluginHost::BaseClass + # register_for :my_id + # ... + # end + # + # See PluginHost.register. + def register_for id + @plugin_id = id + plugin_host.register self, id + end + + # Returns the title of the plugin, or sets it to the + # optional argument +title+. + def title title = nil + if title + @title = title.to_s + else + @title ||= name[/([^:]+)$/, 1] + end + end + + # The PluginHost for this Plugin class. + def plugin_host host = nil + if host.is_a? PluginHost + const_set :PLUGIN_HOST, host + end + self::PLUGIN_HOST + end + + def aliases + plugin_host.plugin_hash.inject [] do |aliases, (key, _)| + aliases << key if plugin_host[key] == self + aliases + end + end + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/word_list.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/word_list.rb new file mode 100644 index 000000000..4a42c4a73 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/helpers/word_list.rb @@ -0,0 +1,72 @@ +module CodeRay + + # = WordList + # + # A Hash subclass designed for mapping word lists to token types. + # + # A WordList is a Hash with some additional features. + # It is intended to be used for keyword recognition. + # + # WordList is optimized to be used in Scanners, + # typically to decide whether a given ident is a special token. + # + # For case insensitive words use WordList::CaseIgnoring. + # + # Example: + # + # # define word arrays + # RESERVED_WORDS = %w[ + # asm break case continue default do else + # ] + # + # PREDEFINED_TYPES = %w[ + # int long short char void + # ] + # + # # make a WordList + # IDENT_KIND = WordList.new(:ident). + # add(RESERVED_WORDS, :reserved). + # add(PREDEFINED_TYPES, :predefined_type) + # + # ... + # + # def scan_tokens tokens, options + # ... + # + # elsif scan(/[A-Za-z_][A-Za-z_0-9]*/) + # # use it + # kind = IDENT_KIND[match] + # ... + class WordList < Hash + + # Create a new WordList with +default+ as default value. + def initialize default = false + super default + end + + # Add words to the list and associate them with +value+. + # + # Returns +self+, so you can concat add calls. + def add words, value = true + words.each { |word| self[word] = value } + self + end + + end + + + # A CaseIgnoring WordList is like a WordList, only that + # keys are compared case-insensitively (normalizing keys using +downcase+). + class WordList::CaseIgnoring < WordList + + def [] key + super key.downcase + end + + def []= key, value + super key.downcase, value + end + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanner.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanner.rb new file mode 100644 index 000000000..b3f7e175c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanner.rb @@ -0,0 +1,355 @@ +# encoding: utf-8 +require 'strscan' + +module CodeRay + + autoload :WordList, coderay_path('helpers', 'word_list') + + # = Scanners + # + # This module holds the Scanner class and its subclasses. + # For example, the Ruby scanner is named CodeRay::Scanners::Ruby + # can be found in coderay/scanners/ruby. + # + # Scanner also provides methods and constants for the register + # mechanism and the [] method that returns the Scanner class + # belonging to the given lang. + # + # See PluginHost. + module Scanners + extend PluginHost + plugin_path File.dirname(__FILE__), 'scanners' + + + # = Scanner + # + # The base class for all Scanners. + # + # It is a subclass of Ruby's great +StringScanner+, which + # makes it easy to access the scanning methods inside. + # + # It is also +Enumerable+, so you can use it like an Array of + # Tokens: + # + # require 'coderay' + # + # c_scanner = CodeRay::Scanners[:c].new "if (*p == '{') nest++;" + # + # for text, kind in c_scanner + # puts text if kind == :operator + # end + # + # # prints: (*==)++; + # + # OK, this is a very simple example :) + # You can also use +map+, +any?+, +find+ and even +sort_by+, + # if you want. + class Scanner < StringScanner + + extend Plugin + plugin_host Scanners + + # Raised if a Scanner fails while scanning + ScanError = Class.new StandardError + + # The default options for all scanner classes. + # + # Define @default_options for subclasses. + DEFAULT_OPTIONS = { } + + KINDS_NOT_LOC = [:comment, :doctype, :docstring] + + attr_accessor :state + + class << self + + # Normalizes the given code into a string with UNIX newlines, in the + # scanner's internal encoding, with invalid and undefined charachters + # replaced by placeholders. Always returns a new object. + def normalize code + # original = code + code = code.to_s unless code.is_a? ::String + return code if code.empty? + + if code.respond_to? :encoding + code = encode_with_encoding code, self.encoding + else + code = to_unix code + end + # code = code.dup if code.eql? original + code + end + + # The typical filename suffix for this scanner's language. + def file_extension extension = lang + @file_extension ||= extension.to_s + end + + # The encoding used internally by this scanner. + def encoding name = 'UTF-8' + @encoding ||= defined?(Encoding.find) && Encoding.find(name) + end + + # The lang of this Scanner class, which is equal to its Plugin ID. + def lang + @plugin_id + end + + protected + + def encode_with_encoding code, target_encoding + if code.encoding == target_encoding + if code.valid_encoding? + return to_unix(code) + else + source_encoding = guess_encoding code + end + else + source_encoding = code.encoding + end + # print "encode_with_encoding from #{source_encoding} to #{target_encoding}" + code.encode target_encoding, source_encoding, :universal_newline => true, :undef => :replace, :invalid => :replace + end + + def to_unix code + code.index(?\r) ? code.gsub(/\r\n?/, "\n") : code + end + + def guess_encoding s + #:nocov: + IO.popen("file -b --mime -", "w+") do |file| + file.write s[0, 1024] + file.close_write + begin + Encoding.find file.gets[/charset=([-\w]+)/, 1] + rescue ArgumentError + Encoding::BINARY + end + end + #:nocov: + end + + end + + # Create a new Scanner. + # + # * +code+ is the input String and is handled by the superclass + # StringScanner. + # * +options+ is a Hash with Symbols as keys. + # It is merged with the default options of the class (you can + # overwrite default options here.) + # + # Else, a Tokens object is used. + def initialize code = '', options = {} + if self.class == Scanner + raise NotImplementedError, "I am only the basic Scanner class. I can't scan anything. :( Use my subclasses." + end + + @options = self.class::DEFAULT_OPTIONS.merge options + + super self.class.normalize(code) + + @tokens = options[:tokens] || Tokens.new + @tokens.scanner = self if @tokens.respond_to? :scanner= + + setup + end + + # Sets back the scanner. Subclasses should redefine the reset_instance + # method instead of this one. + def reset + super + reset_instance + end + + # Set a new string to be scanned. + def string= code + code = self.class.normalize(code) + super code + reset_instance + end + + # the Plugin ID for this scanner + def lang + self.class.lang + end + + # the default file extension for this scanner + def file_extension + self.class.file_extension + end + + # Scan the code and returns all tokens in a Tokens object. + def tokenize source = nil, options = {} + options = @options.merge(options) + + set_tokens_from_options options + set_string_from_source source + + begin + scan_tokens @tokens, options + rescue => e + message = "Error in %s#scan_tokens, initial state was: %p" % [self.class, defined?(state) && state] + raise_inspect e.message, @tokens, message, 30, e.backtrace + end + + @cached_tokens = @tokens + if source.is_a? Array + @tokens.split_into_parts(*source.map { |part| part.size }) + else + @tokens + end + end + + # Cache the result of tokenize. + def tokens + @cached_tokens ||= tokenize + end + + # Traverse the tokens. + def each &block + tokens.each(&block) + end + include Enumerable + + # The current line position of the scanner, starting with 1. + # See also: #column. + # + # Beware, this is implemented inefficiently. It should be used + # for debugging only. + def line pos = self.pos + return 1 if pos <= 0 + binary_string[0...pos].count("\n") + 1 + end + + # The current column position of the scanner, starting with 1. + # See also: #line. + def column pos = self.pos + return 1 if pos <= 0 + pos - (binary_string.rindex(?\n, pos - 1) || -1) + end + + # The string in binary encoding. + # + # To be used with #pos, which is the index of the byte the scanner + # will scan next. + def binary_string + @binary_string ||= + if string.respond_to?(:bytesize) && string.bytesize != string.size + #:nocov: + string.dup.force_encoding('binary') + #:nocov: + else + string + end + end + + protected + + # Can be implemented by subclasses to do some initialization + # that has to be done once per instance. + # + # Use reset for initialization that has to be done once per + # scan. + def setup # :doc: + end + + def set_string_from_source source + case source + when Array + self.string = self.class.normalize(source.join) + when nil + reset + else + self.string = self.class.normalize(source) + end + end + + def set_tokens_from_options options + @tokens = options[:tokens] || @tokens || Tokens.new + @tokens.scanner = self if @tokens.respond_to? :scanner= + end + + # This is the central method, and commonly the only one a + # subclass implements. + # + # Subclasses must implement this method; it must return +tokens+ + # and must only use Tokens#<< for storing scanned tokens! + def scan_tokens tokens, options # :doc: + raise NotImplementedError, "#{self.class}#scan_tokens not implemented." + end + + # Resets the scanner. + def reset_instance + @tokens.clear if @tokens.respond_to?(:clear) && !@options[:keep_tokens] + @cached_tokens = nil + @binary_string = nil if defined? @binary_string + end + + SCAN_ERROR_MESSAGE = <<-MESSAGE + + +***ERROR in %s: %s (after %s tokens) + +tokens: +%s + +%s + +surrounding code: +%p ~~ %p + + +***ERROR*** + + MESSAGE + + def raise_inspect_arguments message, tokens, state, ambit + return File.basename(caller[0]), + message, + tokens_size(tokens), + tokens_last(tokens, 10).map(&:inspect).join("\n"), + scanner_state_info(state), + binary_string[pos - ambit, ambit], + binary_string[pos, ambit] + end + + SCANNER_STATE_INFO = <<-INFO +current line: %d column: %d pos: %d +matched: %p state: %p +bol?: %p, eos?: %p + INFO + + def scanner_state_info state + SCANNER_STATE_INFO % [ + line, column, pos, + matched, state || 'No state given!', + bol?, eos?, + ] + end + + # Scanner error with additional status information + def raise_inspect message, tokens, state = self.state, ambit = 30, backtrace = caller + raise ScanError, SCAN_ERROR_MESSAGE % raise_inspect_arguments(message, tokens, state, ambit), backtrace + end + + def tokens_size tokens + tokens.size if tokens.respond_to?(:size) + end + + def tokens_last tokens, n + tokens.respond_to?(:last) ? tokens.last(n) : [] + end + + # Shorthand for scan_until(/\z/). + # This method also avoids a JRuby 1.9 mode bug. + def scan_rest + rest = self.rest + terminate + rest + end + + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/_map.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/_map.rb new file mode 100644 index 000000000..a240298d1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/_map.rb @@ -0,0 +1,24 @@ +module CodeRay +module Scanners + + map \ + :'c++' => :cpp, + :cplusplus => :cpp, + :ecmascript => :java_script, + :ecma_script => :java_script, + :rhtml => :erb, + :eruby => :erb, + :irb => :ruby, + :javascript => :java_script, + :js => :java_script, + :pascal => :delphi, + :patch => :diff, + :plain => :text, + :plaintext => :text, + :xhtml => :html, + :yml => :yaml + + default :text + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/c.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/c.rb new file mode 100644 index 000000000..84b6e8ec5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/c.rb @@ -0,0 +1,189 @@ +module CodeRay +module Scanners + + # Scanner for C. + class C < Scanner + + register_for :c + file_extension 'c' + + KEYWORDS = [ + 'asm', 'break', 'case', 'continue', 'default', 'do', + 'else', 'enum', 'for', 'goto', 'if', 'return', + 'sizeof', 'struct', 'switch', 'typedef', 'union', 'while', + 'restrict', # added in C99 + ] # :nodoc: + + PREDEFINED_TYPES = [ + 'int', 'long', 'short', 'char', + 'signed', 'unsigned', 'float', 'double', + 'bool', 'complex', # added in C99 + ] # :nodoc: + + PREDEFINED_CONSTANTS = [ + 'EOF', 'NULL', + 'true', 'false', # added in C99 + ] # :nodoc: + DIRECTIVES = [ + 'auto', 'extern', 'register', 'static', 'void', + 'const', 'volatile', # added in C89 + 'inline', # added in C99 + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(PREDEFINED_TYPES, :predefined_type). + add(DIRECTIVES, :directive). + add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc: + + ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + label_expected = true + case_expected = false + label_expected_before_preproc_line = nil + in_preproc_line = false + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + if in_preproc_line && match != "\\\n" && match.index(?\n) + in_preproc_line = false + label_expected = label_expected_before_preproc_line + end + encoder.text_token match, :space + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + encoder.text_token match, :comment + + elsif match = scan(/ [-+*=<>?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x) + label_expected = match =~ /[;\{\}]/ + if case_expected + label_expected = true if match == ':' + case_expected = false + end + encoder.text_token match, :operator + + elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) + kind = IDENT_KIND[match] + if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/) + kind = :label + match << matched + else + label_expected = false + if kind == :keyword + case match + when 'case', 'default' + case_expected = true + end + end + end + encoder.text_token match, kind + + elsif match = scan(/L?"/) + encoder.begin_group :string + if match[0] == ?L + encoder.text_token 'L', :modifier + match = '"' + end + encoder.text_token match, :delimiter + state = :string + + elsif match = scan(/ \# \s* if \s* 0 /x) + match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos? + encoder.text_token match, :comment + + elsif match = scan(/#[ \t]*(\w*)/) + encoder.text_token match, :preprocessor + in_preproc_line = true + label_expected_before_preproc_line = label_expected + state = :include_expected if self[1] == 'include' + + elsif match = scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox) + label_expected = false + encoder.text_token match, :char + + elsif match = scan(/\$/) + encoder.text_token match, :ident + + elsif match = scan(/0[xX][0-9A-Fa-f]+/) + label_expected = false + encoder.text_token match, :hex + + elsif match = scan(/(?:0[0-7]+)(?![89.eEfF])/) + label_expected = false + encoder.text_token match, :octal + + elsif match = scan(/(?:\d+)(?![.eEfF])L?L?/) + label_expected = false + encoder.text_token match, :integer + + elsif match = scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/) + label_expected = false + encoder.text_token match, :float + + else + encoder.text_token getch, :error + + end + + when :string + if match = scan(/[^\\\n"]+/) + encoder.text_token match, :content + elsif match = scan(/"/) + encoder.text_token match, :delimiter + encoder.end_group :string + state = :initial + label_expected = false + elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + elsif match = scan(/ \\ | $ /x) + encoder.end_group :string + encoder.text_token match, :error unless match.empty? + state = :initial + label_expected = false + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + end + + when :include_expected + if match = scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/) + encoder.text_token match, :include + state = :initial + + elsif match = scan(/\s+/) + encoder.text_token match, :space + state = :initial if match.index ?\n + + else + state = :initial + + end + + else + raise_inspect 'Unknown state', encoder + + end + + end + + if state == :string + encoder.end_group :string + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/clojure.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/clojure.rb new file mode 100644 index 000000000..f8fbf6506 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/clojure.rb @@ -0,0 +1,217 @@ +# encoding: utf-8 +module CodeRay + module Scanners + + # Clojure scanner by Licenser. + class Clojure < Scanner + + register_for :clojure + file_extension 'clj' + + SPECIAL_FORMS = %w[ + def if do let quote var fn loop recur throw try catch monitor-enter monitor-exit . + new + ] # :nodoc: + + CORE_FORMS = %w[ + + - -> ->> .. / * <= < = == >= > accessor aclone add-classpath add-watch + agent agent-error agent-errors aget alength alias all-ns alter alter-meta! + alter-var-root amap ancestors and apply areduce array-map aset aset-boolean + aset-byte aset-char aset-double aset-float aset-int aset-long aset-short + assert assoc assoc! assoc-in associative? atom await await-for bases bean + bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or + bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array + booleans bound-fn bound-fn* bound? butlast byte byte-array bytes case cast char + char-array char-escape-string char-name-string char? chars class class? + clear-agent-errors clojure-version coll? comment commute comp comparator + compare compare-and-set! compile complement concat cond condp conj conj! + cons constantly construct-proxy contains? count counted? create-ns + create-struct cycle dec decimal? declare definline defmacro defmethod defmulti + defn defn- defonce defprotocol defrecord defstruct deftype delay delay? + deliver denominator deref derive descendants disj disj! dissoc dissoc! + distinct distinct? doall doc dorun doseq dosync dotimes doto double + double-array doubles drop drop-last drop-while empty empty? ensure + enumeration-seq error-handler error-mode eval even? every? extend + extend-protocol extend-type extenders extends? false? ffirst file-seq + filter find find-doc find-ns find-var first float float-array float? + floats flush fn fn? fnext for force format future future-call future-cancel + future-cancelled? future-done? future? gen-class gen-interface gensym get + get-in get-method get-proxy-class get-thread-bindings get-validator hash + hash-map hash-set identical? identity if-let if-not ifn? import in-ns + inc init-proxy instance? int int-array integer? interleave intern + interpose into into-array ints io! isa? iterate iterator-seq juxt key + keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* + list? load load-file load-reader load-string loaded-libs locking long + long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy + map map? mapcat max max-key memfn memoize merge merge-with meta methods + min min-key mod name namespace neg? newline next nfirst nil? nnext not + not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns + ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth + nthnext num number? numerator object-array odd? or parents partial + partition pcalls peek persistent! pmap pop pop! pop-thread-bindings + pos? pr pr-str prefer-method prefers print print-namespace-doc + print-str printf println println-str prn prn-str promise proxy + proxy-mappings proxy-super push-thread-bindings pvalues quot rand + rand-int range ratio? rationalize re-find re-groups re-matcher + re-matches re-pattern re-seq read read-line read-string reduce ref + ref-history-count ref-max-history ref-min-history ref-set refer + refer-clojure reify release-pending-sends rem remove remove-all-methods + remove-method remove-ns remove-watch repeat repeatedly replace replicate + require reset! reset-meta! resolve rest restart-agent resultset-seq + reverse reversible? rseq rsubseq satisfies? second select-keys send + send-off seq seq? seque sequence sequential? set set-error-handler! + set-error-mode! set-validator! set? short short-array shorts + shutdown-agents slurp some sort sort-by sorted-map sorted-map-by + sorted-set sorted-set-by sorted? special-form-anchor special-symbol? + split-at split-with str string? struct struct-map subs subseq subvec + supers swap! symbol symbol? sync syntax-symbol-anchor take take-last + take-nth take-while test the-ns thread-bound? time to-array to-array-2d + trampoline transient tree-seq true? type unchecked-add unchecked-dec + unchecked-divide unchecked-inc unchecked-multiply unchecked-negate + unchecked-remainder unchecked-subtract underive update-in update-proxy + use val vals var-get var-set var? vary-meta vec vector vector-of vector? + when when-first when-let when-not while with-bindings with-bindings* + with-in-str with-local-vars with-meta with-open with-out-str + with-precision xml-seq zero? zipmap + ] # :nodoc: + + PREDEFINED_CONSTANTS = %w[ + true false nil *1 *2 *3 *agent* *clojure-version* *command-line-args* + *compile-files* *compile-path* *e *err* *file* *flush-on-newline* + *in* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* + *print-readably* *read-eval* *warn-on-reflection* + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(SPECIAL_FORMS, :keyword). + add(CORE_FORMS, :keyword). + add(PREDEFINED_CONSTANTS, :predefined_constant) + + KEYWORD_NEXT_TOKEN_KIND = WordList.new(nil). + add(%w[ def defn defn- definline defmacro defmulti defmethod defstruct defonce declare ], :function). + add(%w[ ns ], :namespace). + add(%w[ defprotocol defrecord ], :class) + + BASIC_IDENTIFIER = /[a-zA-Z$%*\/_+!?&<>\-=]=?[a-zA-Z0-9$&*+!\/_?<>\-\#]*/ + IDENTIFIER = /(?!-\d)(?:(?:#{BASIC_IDENTIFIER}\.)*#{BASIC_IDENTIFIER}(?:\/#{BASIC_IDENTIFIER})?\.?)|\.\.?/ + SYMBOL = /::?#{IDENTIFIER}/o + DIGIT = /\d/ + DIGIT10 = DIGIT + DIGIT16 = /[0-9a-f]/i + DIGIT8 = /[0-7]/ + DIGIT2 = /[01]/ + RADIX16 = /\#x/i + RADIX8 = /\#o/i + RADIX2 = /\#b/i + RADIX10 = /\#d/i + EXACTNESS = /#i|#e/i + SIGN = /[\+-]?/ + EXP_MARK = /[esfdl]/i + EXP = /#{EXP_MARK}#{SIGN}#{DIGIT}+/ + SUFFIX = /#{EXP}?/ + PREFIX10 = /#{RADIX10}?#{EXACTNESS}?|#{EXACTNESS}?#{RADIX10}?/ + PREFIX16 = /#{RADIX16}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX16}/ + PREFIX8 = /#{RADIX8}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX8}/ + PREFIX2 = /#{RADIX2}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX2}/ + UINT10 = /#{DIGIT10}+#*/ + UINT16 = /#{DIGIT16}+#*/ + UINT8 = /#{DIGIT8}+#*/ + UINT2 = /#{DIGIT2}+#*/ + DECIMAL = /#{DIGIT10}+#+\.#*#{SUFFIX}|#{DIGIT10}+\.#{DIGIT10}*#*#{SUFFIX}|\.#{DIGIT10}+#*#{SUFFIX}|#{UINT10}#{EXP}/ + UREAL10 = /#{UINT10}\/#{UINT10}|#{DECIMAL}|#{UINT10}/ + UREAL16 = /#{UINT16}\/#{UINT16}|#{UINT16}/ + UREAL8 = /#{UINT8}\/#{UINT8}|#{UINT8}/ + UREAL2 = /#{UINT2}\/#{UINT2}|#{UINT2}/ + REAL10 = /#{SIGN}#{UREAL10}/ + REAL16 = /#{SIGN}#{UREAL16}/ + REAL8 = /#{SIGN}#{UREAL8}/ + REAL2 = /#{SIGN}#{UREAL2}/ + IMAG10 = /i|#{UREAL10}i/ + IMAG16 = /i|#{UREAL16}i/ + IMAG8 = /i|#{UREAL8}i/ + IMAG2 = /i|#{UREAL2}i/ + COMPLEX10 = /#{REAL10}@#{REAL10}|#{REAL10}\+#{IMAG10}|#{REAL10}-#{IMAG10}|\+#{IMAG10}|-#{IMAG10}|#{REAL10}/ + COMPLEX16 = /#{REAL16}@#{REAL16}|#{REAL16}\+#{IMAG16}|#{REAL16}-#{IMAG16}|\+#{IMAG16}|-#{IMAG16}|#{REAL16}/ + COMPLEX8 = /#{REAL8}@#{REAL8}|#{REAL8}\+#{IMAG8}|#{REAL8}-#{IMAG8}|\+#{IMAG8}|-#{IMAG8}|#{REAL8}/ + COMPLEX2 = /#{REAL2}@#{REAL2}|#{REAL2}\+#{IMAG2}|#{REAL2}-#{IMAG2}|\+#{IMAG2}|-#{IMAG2}|#{REAL2}/ + NUM10 = /#{PREFIX10}?#{COMPLEX10}/ + NUM16 = /#{PREFIX16}#{COMPLEX16}/ + NUM8 = /#{PREFIX8}#{COMPLEX8}/ + NUM2 = /#{PREFIX2}#{COMPLEX2}/ + NUM = /#{NUM10}|#{NUM16}|#{NUM8}|#{NUM2}/ + + protected + + def scan_tokens encoder, options + + state = :initial + kind = nil + + until eos? + + case state + when :initial + if match = scan(/ \s+ | \\\n | , /x) + encoder.text_token match, :space + elsif match = scan(/['`\(\[\)\]\{\}]|\#[({]|~@?|[@\^]/) + encoder.text_token match, :operator + elsif match = scan(/;.*/) + encoder.text_token match, :comment # TODO: recognize (comment ...) too + elsif match = scan(/\#?\\(?:newline|space|.?)/) + encoder.text_token match, :char + elsif match = scan(/\#[ft]/) + encoder.text_token match, :predefined_constant + elsif match = scan(/#{IDENTIFIER}/o) + kind = IDENT_KIND[match] + encoder.text_token match, kind + if rest? && kind == :keyword + if kind = KEYWORD_NEXT_TOKEN_KIND[match] + encoder.text_token match, :space if match = scan(/\s+/o) + encoder.text_token match, kind if match = scan(/#{IDENTIFIER}/o) + end + end + elsif match = scan(/#{SYMBOL}/o) + encoder.text_token match, :symbol + elsif match = scan(/\./) + encoder.text_token match, :operator + elsif match = scan(/ \# \^ #{IDENTIFIER} /ox) + encoder.text_token match, :type + elsif match = scan(/ (\#)? " /x) + state = self[1] ? :regexp : :string + encoder.begin_group state + encoder.text_token match, :delimiter + elsif match = scan(/#{NUM}/o) and not matched.empty? + encoder.text_token match, match[/[.e\/]/i] ? :float : :integer + else + encoder.text_token getch, :error + end + + when :string, :regexp + if match = scan(/[^"\\]+|\\.?/) + encoder.text_token match, :content + elsif match = scan(/"/) + encoder.text_token match, :delimiter + encoder.end_group state + state = :initial + else + raise_inspect "else case \" reached; %p not handled." % peek(1), + encoder, state + end + + else + raise 'else case reached' + + end + + end + + if [:string, :regexp].include? state + encoder.end_group state + end + + encoder + + end + end + end +end \ No newline at end of file diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/cpp.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/cpp.rb new file mode 100644 index 000000000..e61f56f4e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/cpp.rb @@ -0,0 +1,215 @@ +module CodeRay +module Scanners + + # Scanner for C++. + # + # Aliases: +cplusplus+, c++ + class CPlusPlus < Scanner + + register_for :cpp + file_extension 'cpp' + title 'C++' + + #-- http://www.cppreference.com/wiki/keywords/start + KEYWORDS = [ + 'and', 'and_eq', 'asm', 'bitand', 'bitor', 'break', + 'case', 'catch', 'class', 'compl', 'const_cast', + 'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else', + 'enum', 'export', 'for', 'goto', 'if', 'namespace', 'new', + 'not', 'not_eq', 'or', 'or_eq', 'reinterpret_cast', 'return', + 'sizeof', 'static_cast', 'struct', 'switch', 'template', + 'throw', 'try', 'typedef', 'typeid', 'typename', 'union', + 'while', 'xor', 'xor_eq', + ] # :nodoc: + + PREDEFINED_TYPES = [ + 'bool', 'char', 'double', 'float', 'int', 'long', + 'short', 'signed', 'unsigned', 'wchar_t', 'string', + ] # :nodoc: + PREDEFINED_CONSTANTS = [ + 'false', 'true', + 'EOF', 'NULL', + ] # :nodoc: + PREDEFINED_VARIABLES = [ + 'this', + ] # :nodoc: + DIRECTIVES = [ + 'auto', 'const', 'explicit', 'extern', 'friend', 'inline', 'mutable', 'operator', + 'private', 'protected', 'public', 'register', 'static', 'using', 'virtual', 'void', + 'volatile', + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(PREDEFINED_TYPES, :predefined_type). + add(PREDEFINED_VARIABLES, :local_variable). + add(DIRECTIVES, :directive). + add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc: + + ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + label_expected = true + case_expected = false + label_expected_before_preproc_line = nil + in_preproc_line = false + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + if in_preproc_line && match != "\\\n" && match.index(?\n) + in_preproc_line = false + label_expected = label_expected_before_preproc_line + end + encoder.text_token match, :space + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + encoder.text_token match, :comment + + elsif match = scan(/ \# \s* if \s* 0 /x) + match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos? + encoder.text_token match, :comment + + elsif match = scan(/ [-+*=<>?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x) + label_expected = match =~ /[;\{\}]/ + if case_expected + label_expected = true if match == ':' + case_expected = false + end + encoder.text_token match, :operator + + elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) + kind = IDENT_KIND[match] + if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/) + kind = :label + match << matched + else + label_expected = false + if kind == :keyword + case match + when 'class' + state = :class_name_expected + when 'case', 'default' + case_expected = true + end + end + end + encoder.text_token match, kind + + elsif match = scan(/\$/) + encoder.text_token match, :ident + + elsif match = scan(/L?"/) + encoder.begin_group :string + if match[0] == ?L + encoder.text_token match, 'L', :modifier + match = '"' + end + state = :string + encoder.text_token match, :delimiter + + elsif match = scan(/#[ \t]*(\w*)/) + encoder.text_token match, :preprocessor + in_preproc_line = true + label_expected_before_preproc_line = label_expected + state = :include_expected if self[1] == 'include' + + elsif match = scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox) + label_expected = false + encoder.text_token match, :char + + elsif match = scan(/0[xX][0-9A-Fa-f]+/) + label_expected = false + encoder.text_token match, :hex + + elsif match = scan(/(?:0[0-7]+)(?![89.eEfF])/) + label_expected = false + encoder.text_token match, :octal + + elsif match = scan(/(?:\d+)(?![.eEfF])L?L?/) + label_expected = false + encoder.text_token match, :integer + + elsif match = scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/) + label_expected = false + encoder.text_token match, :float + + else + encoder.text_token getch, :error + + end + + when :string + if match = scan(/[^\\"]+/) + encoder.text_token match, :content + elsif match = scan(/"/) + encoder.text_token match, :delimiter + encoder.end_group :string + state = :initial + label_expected = false + elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + elsif match = scan(/ \\ | $ /x) + encoder.end_group :string + encoder.text_token match, :error unless match.empty? + state = :initial + label_expected = false + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + end + + when :include_expected + if match = scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/) + encoder.text_token match, :include + state = :initial + + elsif match = scan(/\s+/) + encoder.text_token match, :space + state = :initial if match.index ?\n + + else + state = :initial + + end + + when :class_name_expected + if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) + encoder.text_token match, :class + state = :initial + + elsif match = scan(/\s+/) + encoder.text_token match, :space + + else + encoder.text_token getch, :error + state = :initial + + end + + else + raise_inspect 'Unknown state', encoder + + end + + end + + if state == :string + encoder.end_group :string + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/css.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/css.rb new file mode 100644 index 000000000..55d523978 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/css.rb @@ -0,0 +1,196 @@ +module CodeRay +module Scanners + + class CSS < Scanner + + register_for :css + + KINDS_NOT_LOC = [ + :comment, + :class, :pseudo_class, :tag, + :id, :directive, + :key, :value, :operator, :color, :float, :string, + :error, :important, :type, + ] # :nodoc: + + module RE # :nodoc: + Hex = /[0-9a-fA-F]/ + Unicode = /\\#{Hex}{1,6}\b/ # differs from standard because it allows uppercase hex too + Escape = /#{Unicode}|\\[^\n0-9a-fA-F]/ + NMChar = /[-_a-zA-Z0-9]/ + NMStart = /[_a-zA-Z]/ + String1 = /"(?:[^\n\\"]+|\\\n|#{Escape})*"?/ # TODO: buggy regexp + String2 = /'(?:[^\n\\']+|\\\n|#{Escape})*'?/ # TODO: buggy regexp + String = /#{String1}|#{String2}/ + + HexColor = /#(?:#{Hex}{6}|#{Hex}{3})/ + + Num = /-?(?:[0-9]*\.[0-9]+|[0-9]+)n?/ + Name = /#{NMChar}+/ + Ident = /-?#{NMStart}#{NMChar}*/ + AtKeyword = /@#{Ident}/ + Percentage = /#{Num}%/ + + reldimensions = %w[em ex px] + absdimensions = %w[in cm mm pt pc] + Unit = Regexp.union(*(reldimensions + absdimensions + %w[s dpi dppx deg])) + + Dimension = /#{Num}#{Unit}/ + + Function = /(?:url|alpha|attr|counters?)\((?:[^)\n]|\\\))*\)?/ + + Id = /(?!#{HexColor}\b(?!-))##{Name}/ + Class = /\.#{Name}/ + PseudoClass = /::?#{Ident}/ + AttributeSelector = /\[[^\]]*\]?/ + end + + protected + + def setup + @state = :initial + @value_expected = false + end + + def scan_tokens encoder, options + states = Array(options[:state] || @state).dup + value_expected = @value_expected + + until eos? + + if match = scan(/\s+/) + encoder.text_token match, :space + + elsif case states.last + when :initial, :media + if match = scan(/(?>#{RE::Ident})(?!\()|\*/ox) + encoder.text_token match, :tag + next + elsif match = scan(RE::Class) + encoder.text_token match, :class + next + elsif match = scan(RE::Id) + encoder.text_token match, :id + next + elsif match = scan(RE::PseudoClass) + encoder.text_token match, :pseudo_class + next + elsif match = scan(RE::AttributeSelector) + # TODO: Improve highlighting inside of attribute selectors. + encoder.text_token match[0,1], :operator + encoder.text_token match[1..-2], :attribute_name if match.size > 2 + encoder.text_token match[-1,1], :operator if match[-1] == ?] + next + elsif match = scan(/@media/) + encoder.text_token match, :directive + states.push :media_before_name + next + end + + when :block + if match = scan(/(?>#{RE::Ident})(?!\()/ox) + if value_expected + encoder.text_token match, :value + else + encoder.text_token match, :key + end + next + end + + when :media_before_name + if match = scan(RE::Ident) + encoder.text_token match, :type + states[-1] = :media_after_name + next + end + + when :media_after_name + if match = scan(/\{/) + encoder.text_token match, :operator + states[-1] = :media + next + end + + else + #:nocov: + raise_inspect 'Unknown state', encoder + #:nocov: + + end + + elsif match = scan(/\/\*(?:.*?\*\/|\z)/m) + encoder.text_token match, :comment + + elsif match = scan(/\{/) + value_expected = false + encoder.text_token match, :operator + states.push :block + + elsif match = scan(/\}/) + value_expected = false + encoder.text_token match, :operator + if states.last == :block || states.last == :media + states.pop + end + + elsif match = scan(/#{RE::String}/o) + encoder.begin_group :string + encoder.text_token match[0, 1], :delimiter + encoder.text_token match[1..-2], :content if match.size > 2 + encoder.text_token match[-1, 1], :delimiter if match.size >= 2 + encoder.end_group :string + + elsif match = scan(/#{RE::Function}/o) + encoder.begin_group :function + start = match[/^\w+\(/] + encoder.text_token start, :delimiter + if match[-1] == ?) + encoder.text_token match[start.size..-2], :content if match.size > start.size + 1 + encoder.text_token ')', :delimiter + else + encoder.text_token match[start.size..-1], :content if match.size > start.size + end + encoder.end_group :function + + elsif match = scan(/(?: #{RE::Dimension} | #{RE::Percentage} | #{RE::Num} )/ox) + encoder.text_token match, :float + + elsif match = scan(/#{RE::HexColor}/o) + encoder.text_token match, :color + + elsif match = scan(/! *important/) + encoder.text_token match, :important + + elsif match = scan(/(?:rgb|hsl)a?\([^()\n]*\)?/) + encoder.text_token match, :color + + elsif match = scan(RE::AtKeyword) + encoder.text_token match, :directive + + elsif match = scan(/ [+>~:;,.=()\/] /x) + if match == ':' + value_expected = true + elsif match == ';' + value_expected = false + end + encoder.text_token match, :operator + + else + encoder.text_token getch, :error + + end + + end + + if options[:keep_state] + @state = states + @value_expected = value_expected + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/debug.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/debug.rb new file mode 100644 index 000000000..83ede9a58 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/debug.rb @@ -0,0 +1,75 @@ +require 'set' + +module CodeRay +module Scanners + + # = Debug Scanner + # + # Interprets the output of the Encoders::Debug encoder (basically the inverse function). + class Debug < Scanner + + register_for :debug + title 'CodeRay Token Dump Import' + + protected + + def setup + super + @known_token_kinds = TokenKinds.keys.map(&:to_s).to_set + end + + def scan_tokens encoder, options + + opened_tokens = [] + + until eos? + + if match = scan(/\s+/) + encoder.text_token match, :space + + elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /x) + if @known_token_kinds.include? self[1] + encoder.text_token self[2].gsub(/\\(.)/m, '\1'), self[1].to_sym + else + encoder.text_token matched, :unknown + end + + elsif match = scan(/ (\w+) ([<\[]) /x) + if @known_token_kinds.include? self[1] + kind = self[1].to_sym + else + kind = :unknown + end + + opened_tokens << kind + case self[2] + when '<' + encoder.begin_group kind + when '[' + encoder.begin_line kind + else + raise 'CodeRay bug: This case should not be reached.' + end + + elsif !opened_tokens.empty? && match = scan(/ > /x) + encoder.end_group opened_tokens.pop + + elsif !opened_tokens.empty? && match = scan(/ \] /x) + encoder.end_line opened_tokens.pop + + else + encoder.text_token getch, :space + + end + + end + + encoder.end_group opened_tokens.pop until opened_tokens.empty? + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/delphi.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/delphi.rb new file mode 100644 index 000000000..b328155ab --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/delphi.rb @@ -0,0 +1,144 @@ +module CodeRay +module Scanners + + # Scanner for the Delphi language (Object Pascal). + # + # Alias: +pascal+ + class Delphi < Scanner + + register_for :delphi + file_extension 'pas' + + KEYWORDS = [ + 'and', 'array', 'as', 'at', 'asm', 'at', 'begin', 'case', 'class', + 'const', 'constructor', 'destructor', 'dispinterface', 'div', 'do', + 'downto', 'else', 'end', 'except', 'exports', 'file', 'finalization', + 'finally', 'for', 'function', 'goto', 'if', 'implementation', 'in', + 'inherited', 'initialization', 'inline', 'interface', 'is', 'label', + 'library', 'mod', 'nil', 'not', 'object', 'of', 'or', 'out', 'packed', + 'procedure', 'program', 'property', 'raise', 'record', 'repeat', + 'resourcestring', 'set', 'shl', 'shr', 'string', 'then', 'threadvar', + 'to', 'try', 'type', 'unit', 'until', 'uses', 'var', 'while', 'with', + 'xor', 'on', + ] # :nodoc: + + DIRECTIVES = [ + 'absolute', 'abstract', 'assembler', 'at', 'automated', 'cdecl', + 'contains', 'deprecated', 'dispid', 'dynamic', 'export', + 'external', 'far', 'forward', 'implements', 'local', + 'near', 'nodefault', 'on', 'overload', 'override', + 'package', 'pascal', 'platform', 'private', 'protected', 'public', + 'published', 'read', 'readonly', 'register', 'reintroduce', + 'requires', 'resident', 'safecall', 'stdcall', 'stored', 'varargs', + 'virtual', 'write', 'writeonly', + ] # :nodoc: + + IDENT_KIND = WordList::CaseIgnoring.new(:ident). + add(KEYWORDS, :keyword). + add(DIRECTIVES, :directive) # :nodoc: + + NAME_FOLLOWS = WordList::CaseIgnoring.new(false). + add(%w(procedure function .)) # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + last_token = '' + + until eos? + + if state == :initial + + if match = scan(/ \s+ /x) + encoder.text_token match, :space + next + + elsif match = scan(%r! \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !mx) + encoder.text_token match, :preprocessor + next + + elsif match = scan(%r! // [^\n]* | \{ [^}]* \}? | \(\* (?: .*? \*\) | .* ) !mx) + encoder.text_token match, :comment + next + + elsif match = scan(/ <[>=]? | >=? | :=? | [-+=*\/;,@\^|\(\)\[\]] | \.\. /x) + encoder.text_token match, :operator + + elsif match = scan(/\./) + encoder.text_token match, :operator + next if last_token == 'end' + + elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) + encoder.text_token match, NAME_FOLLOWS[last_token] ? :ident : IDENT_KIND[match] + + elsif match = skip(/ ' ( [^\n']|'' ) (?:'|$) /x) + encoder.begin_group :char + encoder.text_token "'", :delimiter + encoder.text_token self[1], :content + encoder.text_token "'", :delimiter + encoder.end_group :char + next + + elsif match = scan(/ ' /x) + encoder.begin_group :string + encoder.text_token match, :delimiter + state = :string + + elsif match = scan(/ \# (?: \d+ | \$[0-9A-Fa-f]+ ) /x) + encoder.text_token match, :char + + elsif match = scan(/ \$ [0-9A-Fa-f]+ /x) + encoder.text_token match, :hex + + elsif match = scan(/ (?: \d+ ) (?![eE]|\.[^.]) /x) + encoder.text_token match, :integer + + elsif match = scan(/ \d+ (?: \.\d+ (?: [eE][+-]? \d+ )? | [eE][+-]? \d+ ) /x) + encoder.text_token match, :float + + else + encoder.text_token getch, :error + next + + end + + elsif state == :string + if match = scan(/[^\n']+/) + encoder.text_token match, :content + elsif match = scan(/''/) + encoder.text_token match, :char + elsif match = scan(/'/) + encoder.text_token match, :delimiter + encoder.end_group :string + state = :initial + next + elsif match = scan(/\n/) + encoder.end_group :string + encoder.text_token match, :space + state = :initial + else + raise "else case \' reached; %p not handled." % peek(1), encoder + end + + else + raise 'else-case reached', encoder + + end + + last_token = match + + end + + if state == :string + encoder.end_group state + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/diff.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/diff.rb new file mode 100644 index 000000000..fd1aed67a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/diff.rb @@ -0,0 +1,221 @@ +module CodeRay +module Scanners + + # Scanner for output of the diff command. + # + # Alias: +patch+ + class Diff < Scanner + + register_for :diff + title 'diff output' + + DEFAULT_OPTIONS = { + :highlight_code => true, + :inline_diff => true, + } + + protected + + def scan_tokens encoder, options + + line_kind = nil + state = :initial + deleted_lines_count = 0 + scanners = Hash.new do |h, lang| + h[lang] = Scanners[lang].new '', :keep_tokens => true, :keep_state => true + end + content_scanner = scanners[:plain] + content_scanner_entry_state = nil + + until eos? + + if match = scan(/\n/) + deleted_lines_count = 0 unless line_kind == :delete + if line_kind + encoder.end_line line_kind + line_kind = nil + end + encoder.text_token match, :space + next + end + + case state + + when :initial + if match = scan(/--- |\+\+\+ |=+|_+/) + encoder.begin_line line_kind = :head + encoder.text_token match, :head + if match = scan(/[^\x00\n]+?(?=$|[\t\n]| \(revision)/) + encoder.text_token match, :filename + if options[:highlight_code] && match != '/dev/null' + file_type = CodeRay::FileType.fetch(match, :text) + file_type = :text if file_type == :diff + content_scanner = scanners[file_type] + content_scanner_entry_state = nil + end + end + next unless match = scan(/.+/) + encoder.text_token match, :plain + elsif match = scan(/Index: |Property changes on: /) + encoder.begin_line line_kind = :head + encoder.text_token match, :head + next unless match = scan(/.+/) + encoder.text_token match, :plain + elsif match = scan(/Added: /) + encoder.begin_line line_kind = :head + encoder.text_token match, :head + next unless match = scan(/.+/) + encoder.text_token match, :plain + state = :added + elsif match = scan(/\\ .*/) + encoder.text_token match, :comment + elsif match = scan(/@@(?>[^@\n]+)@@/) + content_scanner.state = :initial unless match?(/\n\+/) + content_scanner_entry_state = nil + if check(/\n|$/) + encoder.begin_line line_kind = :change + else + encoder.begin_group :change + end + encoder.text_token match[0,2], :change + encoder.text_token match[2...-2], :plain + encoder.text_token match[-2,2], :change + encoder.end_group :change unless line_kind + next unless match = scan(/.+/) + if options[:highlight_code] + content_scanner.tokenize match, :tokens => encoder + else + encoder.text_token match, :plain + end + next + elsif match = scan(/\+/) + encoder.begin_line line_kind = :insert + encoder.text_token match, :insert + next unless match = scan(/.+/) + if options[:highlight_code] + content_scanner.tokenize match, :tokens => encoder + else + encoder.text_token match, :plain + end + next + elsif match = scan(/-/) + deleted_lines_count += 1 + if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/.*(?:\n\-.*)*/).count("\n")) && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/) + deleted_lines = Array.new(changed_lines_count) { |i| skip(/\n\-/) if i > 0; scan(/.*/) } + inserted_lines = Array.new(changed_lines_count) { |i| skip(/\n\+/) ; scan(/.*/) } + + deleted_lines_tokenized = [] + inserted_lines_tokenized = [] + for deleted_line, inserted_line in deleted_lines.zip(inserted_lines) + pre, deleted_part, inserted_part, post = diff deleted_line, inserted_line + content_scanner_entry_state = content_scanner.state + deleted_lines_tokenized << content_scanner.tokenize([pre, deleted_part, post], :tokens => Tokens.new) + content_scanner.state = content_scanner_entry_state || :initial + inserted_lines_tokenized << content_scanner.tokenize([pre, inserted_part, post], :tokens => Tokens.new) + end + + for pre, deleted_part, post in deleted_lines_tokenized + encoder.begin_line :delete + encoder.text_token '-', :delete + encoder.tokens pre + unless deleted_part.empty? + encoder.begin_group :eyecatcher + encoder.tokens deleted_part + encoder.end_group :eyecatcher + end + encoder.tokens post + encoder.end_line :delete + encoder.text_token "\n", :space + end + + for pre, inserted_part, post in inserted_lines_tokenized + encoder.begin_line :insert + encoder.text_token '+', :insert + encoder.tokens pre + unless inserted_part.empty? + encoder.begin_group :eyecatcher + encoder.tokens inserted_part + encoder.end_group :eyecatcher + end + encoder.tokens post + changed_lines_count -= 1 + if changed_lines_count > 0 + encoder.end_line :insert + encoder.text_token "\n", :space + end + end + + line_kind = :insert + + elsif match = scan(/.*/) + encoder.begin_line line_kind = :delete + encoder.text_token '-', :delete + if options[:highlight_code] + if deleted_lines_count == 1 + content_scanner_entry_state = content_scanner.state + end + content_scanner.tokenize match, :tokens => encoder unless match.empty? + if !match?(/\n-/) + if match?(/\n\+/) + content_scanner.state = content_scanner_entry_state || :initial + end + content_scanner_entry_state = nil + end + else + encoder.text_token match, :plain + end + end + next + elsif match = scan(/ .*/) + if options[:highlight_code] + content_scanner.tokenize match, :tokens => encoder + else + encoder.text_token match, :plain + end + next + elsif match = scan(/.+/) + encoder.begin_line line_kind = :comment + encoder.text_token match, :plain + else + raise_inspect 'else case rached' + end + + when :added + if match = scan(/ \+/) + encoder.begin_line line_kind = :insert + encoder.text_token match, :insert + next unless match = scan(/.+/) + encoder.text_token match, :plain + else + state = :initial + next + end + end + + end + + encoder.end_line line_kind if line_kind + + encoder + end + + private + + def diff a, b + # i will be the index of the leftmost difference from the left. + i_max = [a.size, b.size].min + i = 0 + i += 1 while i < i_max && a[i] == b[i] + # j_min will be the index of the leftmost difference from the right. + j_min = i - i_max + # j will be the index of the rightmost difference from the right which + # does not precede the leftmost one from the left. + j = -1 + j -= 1 while j >= j_min && a[j] == b[j] + return a[0...i], a[i..j], b[i..j], (j < -1) ? a[j+1..-1] : '' + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/erb.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/erb.rb new file mode 100644 index 000000000..727a993bf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/erb.rb @@ -0,0 +1,81 @@ +module CodeRay +module Scanners + + load :html + load :ruby + + # Scanner for HTML ERB templates. + class ERB < Scanner + + register_for :erb + title 'HTML ERB Template' + + KINDS_NOT_LOC = HTML::KINDS_NOT_LOC + + ERB_RUBY_BLOCK = / + (<%(?!%)[-=\#]?) + ((?> + [^\-%]* # normal* + (?> # special + (?: %(?!>) | -(?!%>) ) + [^\-%]* # normal* + )* + )) + ((?: -?%> )?) + /x # :nodoc: + + START_OF_ERB = / + <%(?!%) + /x # :nodoc: + + protected + + def setup + @ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true + @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true + end + + def reset_instance + super + @html_scanner.reset + end + + def scan_tokens encoder, options + + until eos? + + if (match = scan_until(/(?=#{START_OF_ERB})/o) || scan_rest) and not match.empty? + @html_scanner.tokenize match, :tokens => encoder + + elsif match = scan(/#{ERB_RUBY_BLOCK}/o) + start_tag = self[1] + code = self[2] + end_tag = self[3] + + encoder.begin_group :inline + encoder.text_token start_tag, :inline_delimiter + + if start_tag == '<%#' + encoder.text_token code, :comment + else + @ruby_scanner.tokenize code, :tokens => encoder + end unless code.empty? + + encoder.text_token end_tag, :inline_delimiter unless end_tag.empty? + encoder.end_group :inline + + else + raise_inspect 'else-case reached!', encoder + + end + + end + + encoder + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/go.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/go.rb new file mode 100644 index 000000000..99fdd638e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/go.rb @@ -0,0 +1,208 @@ +module CodeRay +module Scanners + + class Go < Scanner + + register_for :go + file_extension 'go' + + # http://golang.org/ref/spec#Keywords + KEYWORDS = [ + 'break', 'default', 'func', 'interface', 'select', + 'case', 'defer', 'go', 'map', 'struct', + 'chan', 'else', 'goto', 'package', 'switch', + 'const', 'fallthrough', 'if', 'range', 'type', + 'continue', 'for', 'import', 'return', 'var', + ] # :nodoc: + + # http://golang.org/ref/spec#Types + PREDEFINED_TYPES = [ + 'bool', + 'uint8', 'uint16', 'uint32', 'uint64', + 'int8', 'int16', 'int32', 'int64', + 'float32', 'float64', + 'complex64', 'complex128', + 'byte', 'rune', 'string', 'error', + 'uint', 'int', 'uintptr', + ] # :nodoc: + + PREDEFINED_CONSTANTS = [ + 'nil', 'iota', + 'true', 'false', + ] # :nodoc: + + PREDEFINED_FUNCTIONS = %w[ + append cap close complex copy delete imag len + make new panic print println real recover + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(PREDEFINED_TYPES, :predefined_type). + add(PREDEFINED_CONSTANTS, :predefined_constant). + add(PREDEFINED_FUNCTIONS, :predefined) # :nodoc: + + ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + label_expected = true + case_expected = false + label_expected_before_preproc_line = nil + in_preproc_line = false + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + if in_preproc_line && match != "\\\n" && match.index(?\n) + in_preproc_line = false + case_expected = false + label_expected = label_expected_before_preproc_line + end + encoder.text_token match, :space + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + encoder.text_token match, :comment + + elsif match = scan(/ ?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x) + if case_expected + label_expected = true if match == ':' + case_expected = false + end + encoder.text_token match, :operator + + elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) + kind = IDENT_KIND[match] + if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/) + kind = :label + label_expected = false + match << matched + else + label_expected = false + if kind == :keyword + case match + when 'case', 'default' + case_expected = true + end + end + end + encoder.text_token match, kind + + elsif match = scan(/L?"/) + encoder.begin_group :string + if match[0] == ?L + encoder.text_token 'L', :modifier + match = '"' + end + encoder.text_token match, :delimiter + state = :string + + elsif match = scan(/ ` ([^`]+)? (`)? /x) + encoder.begin_group :shell + encoder.text_token '`', :delimiter + encoder.text_token self[1], :content if self[1] + encoder.text_token self[2], :delimiter if self[2] + encoder.end_group :shell + + elsif match = scan(/ \# \s* if \s* 0 /x) + match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos? + encoder.text_token match, :comment + + elsif match = scan(/#[ \t]*(\w*)/) + encoder.text_token match, :preprocessor + in_preproc_line = true + label_expected_before_preproc_line = label_expected + state = :include_expected if self[1] == 'include' + + elsif match = scan(/ L?' (?: [^\'\n\\] | \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) )? '? /ox) + label_expected = false + encoder.text_token match, :char + + elsif match = scan(/\$/) + encoder.text_token match, :ident + + elsif match = scan(/-?\d*(\.\d*)?([eE][+-]?\d+)?i/) + label_expected = false + encoder.text_token match, :imaginary + + elsif match = scan(/-?0[xX][0-9A-Fa-f]+/) + label_expected = false + encoder.text_token match, :hex + + elsif match = scan(/-?(?:0[0-7]+)(?![89.eEfF])/) + label_expected = false + encoder.text_token match, :octal + + elsif match = scan(/-?(?:\d*\.\d+|\d+\.)(?:[eE][+-]?\d+)?|\d+[eE][+-]?\d+/) + label_expected = false + encoder.text_token match, :float + + elsif match = scan(/-?(?:\d+)(?![.eEfF])L?L?/) + label_expected = false + encoder.text_token match, :integer + + else + encoder.text_token getch, :error + + end + + when :string + if match = scan(/[^\\\n"]+/) + encoder.text_token match, :content + elsif match = scan(/"/) + encoder.text_token match, :delimiter + encoder.end_group :string + state = :initial + label_expected = false + elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + elsif match = scan(/ \\ /x) + encoder.text_token match, :error + elsif match = scan(/$/) + encoder.end_group :string + state = :initial + label_expected = false + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + end + + when :include_expected + if match = scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/) + encoder.text_token match, :include + state = :initial + + elsif match = scan(/\s+/) + encoder.text_token match, :space + state = :initial if match.index ?\n + + else + state = :initial + + end + + else + raise_inspect 'Unknown state', encoder + + end + + end + + if state == :string + encoder.end_group :string + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/groovy.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/groovy.rb new file mode 100644 index 000000000..c64454f0b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/groovy.rb @@ -0,0 +1,268 @@ +module CodeRay +module Scanners + + load :java + + # Scanner for Groovy. + class Groovy < Java + + register_for :groovy + + # TODO: check list of keywords + GROOVY_KEYWORDS = %w[ + as assert def in + ] # :nodoc: + KEYWORDS_EXPECTING_VALUE = WordList.new.add %w[ + case instanceof new return throw typeof while as assert in + ] # :nodoc: + GROOVY_MAGIC_VARIABLES = %w[ it ] # :nodoc: + + IDENT_KIND = Java::IDENT_KIND.dup. + add(GROOVY_KEYWORDS, :keyword). + add(GROOVY_MAGIC_VARIABLES, :local_variable) # :nodoc: + + ESCAPE = / [bfnrtv$\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc: no 4-byte unicode chars? U[a-fA-F0-9]{8} + REGEXP_ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} | \d | [bBdDsSwW\/] /x # :nodoc: + + # TODO: interpretation inside ', ", / + STRING_CONTENT_PATTERN = { + "'" => /(?>\\[^\\'\n]+|[^\\'\n]+)+/, + '"' => /[^\\$"\n]+/, + "'''" => /(?>[^\\']+|'(?!''))+/, + '"""' => /(?>[^\\$"]+|"(?!""))+/, + '/' => /[^\\$\/\n]+/, + } # :nodoc: + + protected + + def setup + @state = :initial + end + + def scan_tokens encoder, options + state = options[:state] || @state + inline_block_stack = [] + inline_block_paren_depth = nil + string_delimiter = nil + import_clause = class_name_follows = last_token = after_def = false + value_expected = true + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + encoder.text_token match, :space + if match.index ?\n + import_clause = after_def = false + value_expected = true unless value_expected + end + next + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + value_expected = true + after_def = false + encoder.text_token match, :comment + + elsif bol? && match = scan(/ \#!.* /x) + encoder.text_token match, :doctype + + elsif import_clause && match = scan(/ (?!as) #{IDENT} (?: \. #{IDENT} )* (?: \.\* )? /ox) + after_def = value_expected = false + encoder.text_token match, :include + + elsif match = scan(/ #{IDENT} | \[\] /ox) + kind = IDENT_KIND[match] + value_expected = (kind == :keyword) && KEYWORDS_EXPECTING_VALUE[match] + if last_token == '.' + kind = :ident + elsif class_name_follows + kind = :class + class_name_follows = false + elsif after_def && check(/\s*[({]/) + kind = :method + after_def = false + elsif kind == :ident && last_token != '?' && check(/:/) + kind = :key + else + class_name_follows = true if match == 'class' || (import_clause && match == 'as') + import_clause = match == 'import' + after_def = true if match == 'def' + end + encoder.text_token match, kind + + elsif match = scan(/;/) + import_clause = after_def = false + value_expected = true + encoder.text_token match, :operator + + elsif match = scan(/\{/) + class_name_follows = after_def = false + value_expected = true + encoder.text_token match, :operator + if !inline_block_stack.empty? + inline_block_paren_depth += 1 + end + + # TODO: ~'...', ~"..." and ~/.../ style regexps + elsif match = scan(/ \.\.] | \+\+ | + && | \|\| | \*\*=? | ==?~ | <=?>? | [-+*%^~&|>=!]=? | <<>>?=? /x) + value_expected = true + value_expected = :regexp if match == '~' + after_def = false + encoder.text_token match, :operator + + elsif match = scan(/ [)\]}] /x) + value_expected = after_def = false + if !inline_block_stack.empty? && match == '}' + inline_block_paren_depth -= 1 + if inline_block_paren_depth == 0 # closing brace of inline block reached + encoder.text_token match, :inline_delimiter + encoder.end_group :inline + state, string_delimiter, inline_block_paren_depth = inline_block_stack.pop + next + end + end + encoder.text_token match, :operator + + elsif check(/[\d.]/) + after_def = value_expected = false + if match = scan(/0[xX][0-9A-Fa-f]+/) + encoder.text_token match, :hex + elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/) + encoder.text_token match, :octal + elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/) + encoder.text_token match, :float + elsif match = scan(/\d+[lLgG]?/) + encoder.text_token match, :integer + end + + elsif match = scan(/'''|"""/) + after_def = value_expected = false + state = :multiline_string + encoder.begin_group :string + string_delimiter = match + encoder.text_token match, :delimiter + + # TODO: record.'name' syntax + elsif match = scan(/["']/) + after_def = value_expected = false + state = match == '/' ? :regexp : :string + encoder.begin_group state + string_delimiter = match + encoder.text_token match, :delimiter + + elsif value_expected && match = scan(/\//) + after_def = value_expected = false + encoder.begin_group :regexp + state = :regexp + string_delimiter = '/' + encoder.text_token match, :delimiter + + elsif match = scan(/ @ #{IDENT} /ox) + after_def = value_expected = false + encoder.text_token match, :annotation + + elsif match = scan(/\//) + after_def = false + value_expected = true + encoder.text_token match, :operator + + else + encoder.text_token getch, :error + + end + + when :string, :regexp, :multiline_string + if match = scan(STRING_CONTENT_PATTERN[string_delimiter]) + encoder.text_token match, :content + + elsif match = scan(state == :multiline_string ? /'''|"""/ : /["'\/]/) + encoder.text_token match, :delimiter + if state == :regexp + # TODO: regexp modifiers? s, m, x, i? + modifiers = scan(/[ix]+/) + encoder.text_token modifiers, :modifier if modifiers && !modifiers.empty? + end + state = :string if state == :multiline_string + encoder.end_group state + string_delimiter = nil + after_def = value_expected = false + state = :initial + next + + elsif (state == :string || state == :multiline_string) && + (match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)) + if string_delimiter[0] == ?' && !(match == "\\\\" || match == "\\'") + encoder.text_token match, :content + else + encoder.text_token match, :char + end + elsif state == :regexp && match = scan(/ \\ (?: #{REGEXP_ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + + elsif match = scan(/ \$ #{IDENT} /mox) + encoder.begin_group :inline + encoder.text_token '$', :inline_delimiter + match = match[1..-1] + encoder.text_token match, IDENT_KIND[match] + encoder.end_group :inline + next + elsif match = scan(/ \$ \{ /x) + encoder.begin_group :inline + encoder.text_token match, :inline_delimiter + inline_block_stack << [state, string_delimiter, inline_block_paren_depth] + inline_block_paren_depth = 1 + state = :initial + next + + elsif match = scan(/ \$ /mx) + encoder.text_token match, :content + + elsif match = scan(/ \\. /mx) + encoder.text_token match, :content # TODO: Shouldn't this be :error? + + elsif match = scan(/ \\ | \n /x) + encoder.end_group state == :regexp ? :regexp : :string + encoder.text_token match, :error + after_def = value_expected = false + state = :initial + + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + + end + + else + raise_inspect 'Unknown state', encoder + + end + + last_token = match unless [:space, :comment, :doctype].include? kind + + end + + if [:multiline_string, :string, :regexp].include? state + encoder.end_group state == :regexp ? :regexp : :string + end + + if options[:keep_state] + @state = state + end + + until inline_block_stack.empty? + state, = *inline_block_stack.pop + encoder.end_group :inline + encoder.end_group state == :regexp ? :regexp : :string + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/haml.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/haml.rb new file mode 100644 index 000000000..5433790a9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/haml.rb @@ -0,0 +1,168 @@ +module CodeRay +module Scanners + + load :ruby + load :html + load :java_script + + class HAML < Scanner + + register_for :haml + title 'HAML Template' + + KINDS_NOT_LOC = HTML::KINDS_NOT_LOC + + protected + + def setup + super + @ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true + @embedded_ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true, :state => @ruby_scanner.interpreted_string_state + @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true + end + + def scan_tokens encoder, options + + match = nil + code = '' + + until eos? + + if bol? + if match = scan(/!!!.*/) + encoder.text_token match, :doctype + next + end + + if match = scan(/(?>( *)(\/(?!\[if)|-\#|:javascript|:ruby|:\w+) *)(?=\n)/) + encoder.text_token match, :comment + + code = self[2] + if match = scan(/(?:\n+#{self[1]} .*)+/) + case code + when '/', '-#' + encoder.text_token match, :comment + when ':javascript' + # TODO: recognize #{...} snippets inside JavaScript + @java_script_scanner ||= CodeRay.scanner :java_script, :tokens => @tokens, :keep_tokens => true + @java_script_scanner.tokenize match, :tokens => encoder + when ':ruby' + @ruby_scanner.tokenize match, :tokens => encoder + when /:\w+/ + encoder.text_token match, :comment + else + raise 'else-case reached: %p' % [code] + end + end + end + + if match = scan(/ +/) + encoder.text_token match, :space + end + + if match = scan(/\/.*/) + encoder.text_token match, :comment + next + end + + if match = scan(/\\/) + encoder.text_token match, :plain + if match = scan(/.+/) + @html_scanner.tokenize match, :tokens => encoder + end + next + end + + tag = false + + if match = scan(/%[\w:]+\/?/) + encoder.text_token match, :tag + # if match = scan(/( +)(.+)/) + # encoder.text_token self[1], :space + # @embedded_ruby_scanner.tokenize self[2], :tokens => encoder + # end + tag = true + end + + while match = scan(/([.#])[-\w]*\w/) + encoder.text_token match, self[1] == '#' ? :constant : :class + tag = true + end + + if tag && match = scan(/(\()([^)]+)?(\))?/) + # TODO: recognize title=@title, class="widget_#{@widget.number}" + encoder.text_token self[1], :plain + @html_scanner.tokenize self[2], :tokens => encoder, :state => :attribute if self[2] + encoder.text_token self[3], :plain if self[3] + end + + if tag && match = scan(/\{/) + encoder.text_token match, :plain + + code = '' + level = 1 + while true + code << scan(/([^\{\},\n]|, *\n?)*/) + case match = getch + when '{' + level += 1 + code << match + when '}' + level -= 1 + if level > 0 + code << match + else + break + end + when "\n", ",", nil + break + end + end + @ruby_scanner.tokenize code, :tokens => encoder unless code.empty? + + encoder.text_token match, :plain if match + end + + if tag && match = scan(/(\[)([^\]\n]+)?(\])?/) + encoder.text_token self[1], :plain + @ruby_scanner.tokenize self[2], :tokens => encoder if self[2] + encoder.text_token self[3], :plain if self[3] + end + + if tag && match = scan(/\//) + encoder.text_token match, :tag + end + + if scan(/(>? encoder + else + @ruby_scanner.tokenize self[4], :tokens => encoder + end + end + elsif match = scan(/((?:<|> encoder if self[2] + end + + elsif match = scan(/.+/) + @html_scanner.tokenize match, :tokens => encoder + + end + + if match = scan(/\n/) + encoder.text_token match, :space + end + end + + encoder + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/html.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/html.rb new file mode 100644 index 000000000..ebe7b01d1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/html.rb @@ -0,0 +1,275 @@ +module CodeRay +module Scanners + + # HTML Scanner + # + # Alias: +xhtml+ + # + # See also: Scanners::XML + class HTML < Scanner + + register_for :html + + KINDS_NOT_LOC = [ + :comment, :doctype, :preprocessor, + :tag, :attribute_name, :operator, + :attribute_value, :string, + :plain, :entity, :error, + ] # :nodoc: + + EVENT_ATTRIBUTES = %w( + onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay + oncanplaythrough onchange onclick oncontextmenu oncuechange ondblclick + ondrag ondragdrop ondragend ondragenter ondragleave ondragover + ondragstart ondrop ondurationchange onemptied onended onerror onfocus + onformchange onforminput onhashchange oninput oninvalid onkeydown + onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart + onmessage onmousedown onmousemove onmouseout onmouseover onmouseup + onmousewheel onmove onoffline ononline onpagehide onpageshow onpause + onplay onplaying onpopstate onprogress onratechange onreadystatechange + onredo onreset onresize onscroll onseeked onseeking onselect onshow + onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload + onvolumechange onwaiting + ) + + IN_ATTRIBUTE = WordList::CaseIgnoring.new(nil). + add(EVENT_ATTRIBUTES, :script). + add(['style'], :style) + + ATTR_NAME = /[\w.:-]+/ # :nodoc: + TAG_END = /\/?>/ # :nodoc: + HEX = /[0-9a-fA-F]/ # :nodoc: + ENTITY = / + & + (?: + \w+ + | + \# + (?: + \d+ + | + x#{HEX}+ + ) + ) + ; + /ox # :nodoc: + + PLAIN_STRING_CONTENT = { + "'" => /[^&'>\n]+/, + '"' => /[^&">\n]+/, + } # :nodoc: + + def reset + super + @state = :initial + @plain_string_content = nil + end + + protected + + def setup + @state = :initial + @plain_string_content = nil + @in_tag = nil + end + + def scan_java_script encoder, code + if code && !code.empty? + @java_script_scanner ||= Scanners::JavaScript.new '', :keep_tokens => true + @java_script_scanner.tokenize code, :tokens => encoder + end + end + + def scan_css encoder, code, state = [:initial] + if code && !code.empty? + @css_scanner ||= Scanners::CSS.new '', :keep_tokens => true + @css_scanner.tokenize code, :tokens => encoder, :state => state + end + end + + def scan_tokens encoder, options + state = options[:state] || @state + plain_string_content = @plain_string_content + in_tag = @in_tag + in_attribute = nil + + encoder.begin_group :string if state == :attribute_value_string + + until eos? + + if state != :in_special_tag && match = scan(/\s+/m) + encoder.text_token match, :space + + else + + case state + + when :initial + if match = scan(//m) + encoder.text_token match[0..-4], :plain + encoder.text_token ']]>', :inline_delimiter + elsif match = scan(/.+/) + encoder.text_token match, :error + end + elsif match = scan(/|.*)/m) + encoder.text_token match, :comment + elsif match = scan(/|.*)|\]>/m) + encoder.text_token match, :doctype + elsif match = scan(/<\?xml(?:.*?\?>|.*)/m) + encoder.text_token match, :preprocessor + elsif match = scan(/<\?(?:.*?\?>|.*)/m) + encoder.text_token match, :comment + elsif match = scan(/<\/[-\w.:]*>?/m) + in_tag = nil + encoder.text_token match, :tag + elsif match = scan(/<(?:(script|style)|[-\w.:]+)(>)?/m) + encoder.text_token match, :tag + in_tag = self[1] + if self[2] + state = :in_special_tag if in_tag + else + state = :attribute + end + elsif match = scan(/[^<>&]+/) + encoder.text_token match, :plain + elsif match = scan(/#{ENTITY}/ox) + encoder.text_token match, :entity + elsif match = scan(/[<>&]/) + in_tag = nil + encoder.text_token match, :error + else + raise_inspect '[BUG] else-case reached with state %p' % [state], encoder + end + + when :attribute + if match = scan(/#{TAG_END}/o) + encoder.text_token match, :tag + in_attribute = nil + if in_tag + state = :in_special_tag + else + state = :initial + end + elsif match = scan(/#{ATTR_NAME}/o) + in_attribute = IN_ATTRIBUTE[match] + encoder.text_token match, :attribute_name + state = :attribute_equal + else + in_tag = nil + encoder.text_token getch, :error + end + + when :attribute_equal + if match = scan(/=/) #/ + encoder.text_token match, :operator + state = :attribute_value + else + state = :attribute + next + end + + when :attribute_value + if match = scan(/#{ATTR_NAME}/o) + encoder.text_token match, :attribute_value + state = :attribute + elsif match = scan(/["']/) + if in_attribute == :script || in_attribute == :style + encoder.begin_group :string + encoder.text_token match, :delimiter + if scan(/javascript:[ \t]*/) + encoder.text_token matched, :comment + end + code = scan_until(match == '"' ? /(?="|\z)/ : /(?='|\z)/) + if in_attribute == :script + scan_java_script encoder, code + else + scan_css encoder, code, [:block] + end + match = scan(/["']/) + encoder.text_token match, :delimiter if match + encoder.end_group :string + state = :attribute + in_attribute = nil + else + encoder.begin_group :string + state = :attribute_value_string + plain_string_content = PLAIN_STRING_CONTENT[match] + encoder.text_token match, :delimiter + end + elsif match = scan(/#{TAG_END}/o) + encoder.text_token match, :tag + state = :initial + else + encoder.text_token getch, :error + end + + when :attribute_value_string + if match = scan(plain_string_content) + encoder.text_token match, :content + elsif match = scan(/['"]/) + encoder.text_token match, :delimiter + encoder.end_group :string + state = :attribute + elsif match = scan(/#{ENTITY}/ox) + encoder.text_token match, :entity + elsif match = scan(/&/) + encoder.text_token match, :content + elsif match = scan(/[\n>]/) + encoder.end_group :string + state = :initial + encoder.text_token match, :error + end + + when :in_special_tag + case in_tag + when 'script', 'style' + encoder.text_token match, :space if match = scan(/[ \t]*\n/) + if scan(/(\s*)|(.*))/m) + code = self[2] || self[4] + closing = self[3] + encoder.text_token self[1], :comment + else + code = scan_until(/(?=(?:\n\s*)?<\/#{in_tag}>)|\z/) + closing = false + end + unless code.empty? + encoder.begin_group :inline + if in_tag == 'script' + scan_java_script encoder, code + else + scan_css encoder, code + end + encoder.end_group :inline + end + encoder.text_token closing, :comment if closing + state = :initial + else + raise 'unknown special tag: %p' % [in_tag] + end + + else + raise_inspect 'Unknown state: %p' % [state], encoder + + end + + end + + end + + if options[:keep_state] + @state = state + @plain_string_content = plain_string_content + @in_tag = in_tag + end + + encoder.end_group :string if state == :attribute_value_string + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java.rb new file mode 100644 index 000000000..b282864a4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java.rb @@ -0,0 +1,174 @@ +module CodeRay +module Scanners + + # Scanner for Java. + class Java < Scanner + + register_for :java + + autoload :BuiltinTypes, CodeRay.coderay_path('scanners', 'java', 'builtin_types') + + # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html + KEYWORDS = %w[ + assert break case catch continue default do else + finally for if instanceof import new package + return switch throw try typeof while + debugger export + ] # :nodoc: + RESERVED = %w[ const goto ] # :nodoc: + CONSTANTS = %w[ false null true ] # :nodoc: + MAGIC_VARIABLES = %w[ this super ] # :nodoc: + TYPES = %w[ + boolean byte char class double enum float int interface long + short void + ] << '[]' # :nodoc: because int[] should be highlighted as a type + DIRECTIVES = %w[ + abstract extends final implements native private protected public + static strictfp synchronized throws transient volatile + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(RESERVED, :reserved). + add(CONSTANTS, :predefined_constant). + add(MAGIC_VARIABLES, :local_variable). + add(TYPES, :type). + add(BuiltinTypes::List, :predefined_type). + add(BuiltinTypes::List.select { |builtin| builtin[/(Error|Exception)$/] }, :exception). + add(DIRECTIVES, :directive) # :nodoc: + + ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: + STRING_CONTENT_PATTERN = { + "'" => /[^\\']+/, + '"' => /[^\\"]+/, + '/' => /[^\\\/]+/, + } # :nodoc: + IDENT = /[a-zA-Z_][A-Za-z_0-9]*/ # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + string_delimiter = nil + package_name_expected = false + class_name_follows = false + last_token_dot = false + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + encoder.text_token match, :space + next + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + encoder.text_token match, :comment + next + + elsif package_name_expected && match = scan(/ #{IDENT} (?: \. #{IDENT} )* /ox) + encoder.text_token match, package_name_expected + + elsif match = scan(/ #{IDENT} | \[\] /ox) + kind = IDENT_KIND[match] + if last_token_dot + kind = :ident + elsif class_name_follows + kind = :class + class_name_follows = false + else + case match + when 'import' + package_name_expected = :include + when 'package' + package_name_expected = :namespace + when 'class', 'interface' + class_name_follows = true + end + end + encoder.text_token match, kind + + elsif match = scan(/ \.(?!\d) | [,?:()\[\]}] | -- | \+\+ | && | \|\| | \*\*=? | [-+*\/%^~&|<>=!]=? | <<>>?=? /x) + encoder.text_token match, :operator + + elsif match = scan(/;/) + package_name_expected = false + encoder.text_token match, :operator + + elsif match = scan(/\{/) + class_name_follows = false + encoder.text_token match, :operator + + elsif check(/[\d.]/) + if match = scan(/0[xX][0-9A-Fa-f]+/) + encoder.text_token match, :hex + elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/) + encoder.text_token match, :octal + elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/) + encoder.text_token match, :float + elsif match = scan(/\d+[lL]?/) + encoder.text_token match, :integer + end + + elsif match = scan(/["']/) + state = :string + encoder.begin_group state + string_delimiter = match + encoder.text_token match, :delimiter + + elsif match = scan(/ @ #{IDENT} /ox) + encoder.text_token match, :annotation + + else + encoder.text_token getch, :error + + end + + when :string + if match = scan(STRING_CONTENT_PATTERN[string_delimiter]) + encoder.text_token match, :content + elsif match = scan(/["'\/]/) + encoder.text_token match, :delimiter + encoder.end_group state + state = :initial + string_delimiter = nil + elsif state == :string && (match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)) + if string_delimiter == "'" && !(match == "\\\\" || match == "\\'") + encoder.text_token match, :content + else + encoder.text_token match, :char + end + elsif match = scan(/\\./m) + encoder.text_token match, :content + elsif match = scan(/ \\ | $ /x) + encoder.end_group state + state = :initial + encoder.text_token match, :error unless match.empty? + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + end + + else + raise_inspect 'Unknown state', encoder + + end + + last_token_dot = match == '.' + + end + + if state == :string + encoder.end_group state + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java/builtin_types.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java/builtin_types.rb new file mode 100644 index 000000000..d1b8b73be --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java/builtin_types.rb @@ -0,0 +1,421 @@ +module CodeRay +module Scanners + + module Java::BuiltinTypes # :nodoc: + + #:nocov: + List = %w[ + AbstractAction AbstractBorder AbstractButton AbstractCellEditor AbstractCollection + AbstractColorChooserPanel AbstractDocument AbstractExecutorService AbstractInterruptibleChannel + AbstractLayoutCache AbstractList AbstractListModel AbstractMap AbstractMethodError AbstractPreferences + AbstractQueue AbstractQueuedSynchronizer AbstractSelectableChannel AbstractSelectionKey AbstractSelector + AbstractSequentialList AbstractSet AbstractSpinnerModel AbstractTableModel AbstractUndoableEdit + AbstractWriter AccessControlContext AccessControlException AccessController AccessException Accessible + AccessibleAction AccessibleAttributeSequence AccessibleBundle AccessibleComponent AccessibleContext + AccessibleEditableText AccessibleExtendedComponent AccessibleExtendedTable AccessibleExtendedText + AccessibleHyperlink AccessibleHypertext AccessibleIcon AccessibleKeyBinding AccessibleObject + AccessibleRelation AccessibleRelationSet AccessibleResourceBundle AccessibleRole AccessibleSelection + AccessibleState AccessibleStateSet AccessibleStreamable AccessibleTable AccessibleTableModelChange + AccessibleText AccessibleTextSequence AccessibleValue AccountException AccountExpiredException + AccountLockedException AccountNotFoundException Acl AclEntry AclNotFoundException Action ActionEvent + ActionListener ActionMap ActionMapUIResource Activatable ActivateFailedException ActivationDesc + ActivationException ActivationGroup ActivationGroupDesc ActivationGroupID ActivationGroup_Stub + ActivationID ActivationInstantiator ActivationMonitor ActivationSystem Activator ActiveEvent + ActivityCompletedException ActivityRequiredException Adjustable AdjustmentEvent AdjustmentListener + Adler32 AffineTransform AffineTransformOp AlgorithmParameterGenerator AlgorithmParameterGeneratorSpi + AlgorithmParameters AlgorithmParameterSpec AlgorithmParametersSpi AllPermission AlphaComposite + AlreadyBoundException AlreadyConnectedException AncestorEvent AncestorListener AnnotatedElement + Annotation AnnotationFormatError AnnotationTypeMismatchException AppConfigurationEntry Appendable Applet + AppletContext AppletInitializer AppletStub Arc2D Area AreaAveragingScaleFilter ArithmeticException Array + ArrayBlockingQueue ArrayIndexOutOfBoundsException ArrayList Arrays ArrayStoreException ArrayType + AssertionError AsyncBoxView AsynchronousCloseException AtomicBoolean AtomicInteger AtomicIntegerArray + AtomicIntegerFieldUpdater AtomicLong AtomicLongArray AtomicLongFieldUpdater AtomicMarkableReference + AtomicReference AtomicReferenceArray AtomicReferenceFieldUpdater AtomicStampedReference Attribute + AttributeChangeNotification AttributeChangeNotificationFilter AttributedCharacterIterator + AttributedString AttributeException AttributeInUseException AttributeList AttributeModificationException + AttributeNotFoundException Attributes AttributeSet AttributeSetUtilities AttributeValueExp AudioClip + AudioFileFormat AudioFileReader AudioFileWriter AudioFormat AudioInputStream AudioPermission AudioSystem + AuthenticationException AuthenticationNotSupportedException Authenticator AuthorizeCallback + AuthPermission AuthProvider Autoscroll AWTError AWTEvent AWTEventListener AWTEventListenerProxy + AWTEventMulticaster AWTException AWTKeyStroke AWTPermission BackingStoreException + BadAttributeValueExpException BadBinaryOpValueExpException BadLocationException BadPaddingException + BadStringOperationException BandCombineOp BandedSampleModel BaseRowSet BasicArrowButton BasicAttribute + BasicAttributes BasicBorders BasicButtonListener BasicButtonUI BasicCheckBoxMenuItemUI BasicCheckBoxUI + BasicColorChooserUI BasicComboBoxEditor BasicComboBoxRenderer BasicComboBoxUI BasicComboPopup + BasicControl BasicDesktopIconUI BasicDesktopPaneUI BasicDirectoryModel BasicEditorPaneUI + BasicFileChooserUI BasicFormattedTextFieldUI BasicGraphicsUtils BasicHTML BasicIconFactory + BasicInternalFrameTitlePane BasicInternalFrameUI BasicLabelUI BasicListUI BasicLookAndFeel + BasicMenuBarUI BasicMenuItemUI BasicMenuUI BasicOptionPaneUI BasicPanelUI BasicPasswordFieldUI + BasicPermission BasicPopupMenuSeparatorUI BasicPopupMenuUI BasicProgressBarUI BasicRadioButtonMenuItemUI + BasicRadioButtonUI BasicRootPaneUI BasicScrollBarUI BasicScrollPaneUI BasicSeparatorUI BasicSliderUI + BasicSpinnerUI BasicSplitPaneDivider BasicSplitPaneUI BasicStroke BasicTabbedPaneUI BasicTableHeaderUI + BasicTableUI BasicTextAreaUI BasicTextFieldUI BasicTextPaneUI BasicTextUI BasicToggleButtonUI + BasicToolBarSeparatorUI BasicToolBarUI BasicToolTipUI BasicTreeUI BasicViewportUI BatchUpdateException + BeanContext BeanContextChild BeanContextChildComponentProxy BeanContextChildSupport + BeanContextContainerProxy BeanContextEvent BeanContextMembershipEvent BeanContextMembershipListener + BeanContextProxy BeanContextServiceAvailableEvent BeanContextServiceProvider + BeanContextServiceProviderBeanInfo BeanContextServiceRevokedEvent BeanContextServiceRevokedListener + BeanContextServices BeanContextServicesListener BeanContextServicesSupport BeanContextSupport + BeanDescriptor BeanInfo Beans BevelBorder Bidi BigDecimal BigInteger BinaryRefAddr BindException Binding + BitSet Blob BlockingQueue BlockView BMPImageWriteParam Book Boolean BooleanControl Border BorderFactory + BorderLayout BorderUIResource BoundedRangeModel Box BoxLayout BoxView BreakIterator + BrokenBarrierException Buffer BufferCapabilities BufferedImage BufferedImageFilter BufferedImageOp + BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter BufferOverflowException + BufferStrategy BufferUnderflowException Button ButtonGroup ButtonModel ButtonUI Byte + ByteArrayInputStream ByteArrayOutputStream ByteBuffer ByteChannel ByteLookupTable ByteOrder CachedRowSet + CacheRequest CacheResponse Calendar Callable CallableStatement Callback CallbackHandler + CancelablePrintJob CancellationException CancelledKeyException CannotProceedException + CannotRedoException CannotUndoException Canvas CardLayout Caret CaretEvent CaretListener CellEditor + CellEditorListener CellRendererPane Certificate CertificateEncodingException CertificateException + CertificateExpiredException CertificateFactory CertificateFactorySpi CertificateNotYetValidException + CertificateParsingException CertPath CertPathBuilder CertPathBuilderException CertPathBuilderResult + CertPathBuilderSpi CertPathParameters CertPathTrustManagerParameters CertPathValidator + CertPathValidatorException CertPathValidatorResult CertPathValidatorSpi CertSelector CertStore + CertStoreException CertStoreParameters CertStoreSpi ChangedCharSetException ChangeEvent ChangeListener + Channel Channels Character CharacterCodingException CharacterIterator CharArrayReader CharArrayWriter + CharBuffer CharConversionException CharSequence Charset CharsetDecoder CharsetEncoder CharsetProvider + Checkbox CheckboxGroup CheckboxMenuItem CheckedInputStream CheckedOutputStream Checksum Choice + ChoiceCallback ChoiceFormat Chromaticity Cipher CipherInputStream CipherOutputStream CipherSpi Class + ClassCastException ClassCircularityError ClassDefinition ClassDesc ClassFileTransformer ClassFormatError + ClassLoader ClassLoaderRepository ClassLoadingMXBean ClassNotFoundException Clip Clipboard + ClipboardOwner Clob Cloneable CloneNotSupportedException Closeable ClosedByInterruptException + ClosedChannelException ClosedSelectorException CMMException CoderMalfunctionError CoderResult CodeSigner + CodeSource CodingErrorAction CollationElementIterator CollationKey Collator Collection + CollectionCertStoreParameters Collections Color ColorChooserComponentFactory ColorChooserUI + ColorConvertOp ColorModel ColorSelectionModel ColorSpace ColorSupported ColorType ColorUIResource + ComboBoxEditor ComboBoxModel ComboBoxUI ComboPopup CommunicationException Comparable Comparator + CompilationMXBean Compiler CompletionService Component ComponentAdapter ComponentColorModel + ComponentEvent ComponentInputMap ComponentInputMapUIResource ComponentListener ComponentOrientation + ComponentSampleModel ComponentUI ComponentView Composite CompositeContext CompositeData + CompositeDataSupport CompositeName CompositeType CompositeView CompoundBorder CompoundControl + CompoundEdit CompoundName Compression ConcurrentHashMap ConcurrentLinkedQueue ConcurrentMap + ConcurrentModificationException Condition Configuration ConfigurationException ConfirmationCallback + ConnectException ConnectIOException Connection ConnectionEvent ConnectionEventListener + ConnectionPendingException ConnectionPoolDataSource ConsoleHandler Constructor Container + ContainerAdapter ContainerEvent ContainerListener ContainerOrderFocusTraversalPolicy ContentHandler + ContentHandlerFactory ContentModel Context ContextNotEmptyException ContextualRenderedImageFactory + Control ControlFactory ControllerEventListener ConvolveOp CookieHandler Copies CopiesSupported + CopyOnWriteArrayList CopyOnWriteArraySet CountDownLatch CounterMonitor CounterMonitorMBean CRC32 + CredentialException CredentialExpiredException CredentialNotFoundException CRL CRLException CRLSelector + CropImageFilter CSS CubicCurve2D Currency Cursor Customizer CyclicBarrier DatabaseMetaData DataBuffer + DataBufferByte DataBufferDouble DataBufferFloat DataBufferInt DataBufferShort DataBufferUShort + DataFlavor DataFormatException DatagramChannel DatagramPacket DatagramSocket DatagramSocketImpl + DatagramSocketImplFactory DataInput DataInputStream DataLine DataOutput DataOutputStream DataSource + DataTruncation DatatypeConfigurationException DatatypeConstants DatatypeFactory Date DateFormat + DateFormatSymbols DateFormatter DateTimeAtCompleted DateTimeAtCreation DateTimeAtProcessing + DateTimeSyntax DebugGraphics DecimalFormat DecimalFormatSymbols DefaultBoundedRangeModel + DefaultButtonModel DefaultCaret DefaultCellEditor DefaultColorSelectionModel DefaultComboBoxModel + DefaultDesktopManager DefaultEditorKit DefaultFocusManager DefaultFocusTraversalPolicy DefaultFormatter + DefaultFormatterFactory DefaultHighlighter DefaultKeyboardFocusManager DefaultListCellRenderer + DefaultListModel DefaultListSelectionModel DefaultLoaderRepository DefaultMenuLayout DefaultMetalTheme + DefaultMutableTreeNode DefaultPersistenceDelegate DefaultSingleSelectionModel DefaultStyledDocument + DefaultTableCellRenderer DefaultTableColumnModel DefaultTableModel DefaultTextUI DefaultTreeCellEditor + DefaultTreeCellRenderer DefaultTreeModel DefaultTreeSelectionModel Deflater DeflaterOutputStream Delayed + DelayQueue DelegationPermission Deprecated Descriptor DescriptorAccess DescriptorSupport DESedeKeySpec + DesignMode DESKeySpec DesktopIconUI DesktopManager DesktopPaneUI Destination Destroyable + DestroyFailedException DGC DHGenParameterSpec DHKey DHParameterSpec DHPrivateKey DHPrivateKeySpec + DHPublicKey DHPublicKeySpec Dialog Dictionary DigestException DigestInputStream DigestOutputStream + Dimension Dimension2D DimensionUIResource DirContext DirectColorModel DirectoryManager DirObjectFactory + DirStateFactory DisplayMode DnDConstants Doc DocAttribute DocAttributeSet DocFlavor DocPrintJob Document + DocumentBuilder DocumentBuilderFactory Documented DocumentEvent DocumentFilter DocumentListener + DocumentName DocumentParser DomainCombiner DOMLocator DOMResult DOMSource Double DoubleBuffer + DragGestureEvent DragGestureListener DragGestureRecognizer DragSource DragSourceAdapter + DragSourceContext DragSourceDragEvent DragSourceDropEvent DragSourceEvent DragSourceListener + DragSourceMotionListener Driver DriverManager DriverPropertyInfo DropTarget DropTargetAdapter + DropTargetContext DropTargetDragEvent DropTargetDropEvent DropTargetEvent DropTargetListener DSAKey + DSAKeyPairGenerator DSAParameterSpec DSAParams DSAPrivateKey DSAPrivateKeySpec DSAPublicKey + DSAPublicKeySpec DTD DTDConstants DuplicateFormatFlagsException Duration DynamicMBean ECField ECFieldF2m + ECFieldFp ECGenParameterSpec ECKey ECParameterSpec ECPoint ECPrivateKey ECPrivateKeySpec ECPublicKey + ECPublicKeySpec EditorKit Element ElementIterator ElementType Ellipse2D EllipticCurve EmptyBorder + EmptyStackException EncodedKeySpec Encoder EncryptedPrivateKeyInfo Entity Enum + EnumConstantNotPresentException EnumControl Enumeration EnumMap EnumSet EnumSyntax EOFException Error + ErrorListener ErrorManager EtchedBorder Event EventContext EventDirContext EventHandler EventListener + EventListenerList EventListenerProxy EventObject EventQueue EventSetDescriptor Exception + ExceptionInInitializerError ExceptionListener Exchanger ExecutionException Executor + ExecutorCompletionService Executors ExecutorService ExemptionMechanism ExemptionMechanismException + ExemptionMechanismSpi ExpandVetoException ExportException Expression ExtendedRequest ExtendedResponse + Externalizable FactoryConfigurationError FailedLoginException FeatureDescriptor Fidelity Field + FieldPosition FieldView File FileCacheImageInputStream FileCacheImageOutputStream FileChannel + FileChooserUI FileDescriptor FileDialog FileFilter FileHandler FileImageInputStream + FileImageOutputStream FileInputStream FileLock FileLockInterruptionException FilenameFilter FileNameMap + FileNotFoundException FileOutputStream FilePermission FileReader FileSystemView FileView FileWriter + Filter FilteredImageSource FilteredRowSet FilterInputStream FilterOutputStream FilterReader FilterWriter + Finishings FixedHeightLayoutCache FlatteningPathIterator FlavorEvent FlavorException FlavorListener + FlavorMap FlavorTable Float FloatBuffer FloatControl FlowLayout FlowView Flushable FocusAdapter + FocusEvent FocusListener FocusManager FocusTraversalPolicy Font FontFormatException FontMetrics + FontRenderContext FontUIResource Format FormatConversionProvider FormatFlagsConversionMismatchException + Formattable FormattableFlags Formatter FormatterClosedException FormSubmitEvent FormView Frame Future + FutureTask GapContent GarbageCollectorMXBean GatheringByteChannel GaugeMonitor GaugeMonitorMBean + GeneralPath GeneralSecurityException GenericArrayType GenericDeclaration GenericSignatureFormatError + GlyphJustificationInfo GlyphMetrics GlyphVector GlyphView GradientPaint GraphicAttribute Graphics + Graphics2D GraphicsConfigTemplate GraphicsConfiguration GraphicsDevice GraphicsEnvironment GrayFilter + GregorianCalendar GridBagConstraints GridBagLayout GridLayout Group Guard GuardedObject GZIPInputStream + GZIPOutputStream Handler HandshakeCompletedEvent HandshakeCompletedListener HasControls HashAttributeSet + HashDocAttributeSet HashMap HashPrintJobAttributeSet HashPrintRequestAttributeSet + HashPrintServiceAttributeSet HashSet Hashtable HeadlessException HierarchyBoundsAdapter + HierarchyBoundsListener HierarchyEvent HierarchyListener Highlighter HostnameVerifier HTML HTMLDocument + HTMLEditorKit HTMLFrameHyperlinkEvent HTMLWriter HttpRetryException HttpsURLConnection HttpURLConnection + HyperlinkEvent HyperlinkListener ICC_ColorSpace ICC_Profile ICC_ProfileGray ICC_ProfileRGB Icon + IconUIResource IconView Identity IdentityHashMap IdentityScope IIOByteBuffer IIOException IIOImage + IIOInvalidTreeException IIOMetadata IIOMetadataController IIOMetadataFormat IIOMetadataFormatImpl + IIOMetadataNode IIOParam IIOParamController IIOReadProgressListener IIOReadUpdateListener + IIOReadWarningListener IIORegistry IIOServiceProvider IIOWriteProgressListener IIOWriteWarningListener + IllegalAccessError IllegalAccessException IllegalArgumentException IllegalBlockingModeException + IllegalBlockSizeException IllegalCharsetNameException IllegalClassFormatException + IllegalComponentStateException IllegalFormatCodePointException IllegalFormatConversionException + IllegalFormatException IllegalFormatFlagsException IllegalFormatPrecisionException + IllegalFormatWidthException IllegalMonitorStateException IllegalPathStateException + IllegalSelectorException IllegalStateException IllegalThreadStateException Image ImageCapabilities + ImageConsumer ImageFilter ImageGraphicAttribute ImageIcon ImageInputStream ImageInputStreamImpl + ImageInputStreamSpi ImageIO ImageObserver ImageOutputStream ImageOutputStreamImpl ImageOutputStreamSpi + ImageProducer ImageReader ImageReaderSpi ImageReaderWriterSpi ImageReadParam ImageTranscoder + ImageTranscoderSpi ImageTypeSpecifier ImageView ImageWriteParam ImageWriter ImageWriterSpi + ImagingOpException IncompatibleClassChangeError IncompleteAnnotationException IndexColorModel + IndexedPropertyChangeEvent IndexedPropertyDescriptor IndexOutOfBoundsException Inet4Address Inet6Address + InetAddress InetSocketAddress Inflater InflaterInputStream InheritableThreadLocal Inherited + InitialContext InitialContextFactory InitialContextFactoryBuilder InitialDirContext InitialLdapContext + InlineView InputContext InputEvent InputMap InputMapUIResource InputMethod InputMethodContext + InputMethodDescriptor InputMethodEvent InputMethodHighlight InputMethodListener InputMethodRequests + InputMismatchException InputStream InputStreamReader InputSubset InputVerifier Insets InsetsUIResource + InstanceAlreadyExistsException InstanceNotFoundException InstantiationError InstantiationException + Instrument Instrumentation InsufficientResourcesException IntBuffer Integer IntegerSyntax InternalError + InternalFrameAdapter InternalFrameEvent InternalFrameFocusTraversalPolicy InternalFrameListener + InternalFrameUI InternationalFormatter InterruptedException InterruptedIOException + InterruptedNamingException InterruptibleChannel IntrospectionException Introspector + InvalidActivityException InvalidAlgorithmParameterException InvalidApplicationException + InvalidAttributeIdentifierException InvalidAttributesException InvalidAttributeValueException + InvalidClassException InvalidDnDOperationException InvalidKeyException InvalidKeySpecException + InvalidMarkException InvalidMidiDataException InvalidNameException InvalidObjectException + InvalidOpenTypeException InvalidParameterException InvalidParameterSpecException + InvalidPreferencesFormatException InvalidPropertiesFormatException InvalidRelationIdException + InvalidRelationServiceException InvalidRelationTypeException InvalidRoleInfoException + InvalidRoleValueException InvalidSearchControlsException InvalidSearchFilterException + InvalidTargetObjectTypeException InvalidTransactionException InvocationEvent InvocationHandler + InvocationTargetException IOException ItemEvent ItemListener ItemSelectable Iterable Iterator + IvParameterSpec JApplet JarEntry JarException JarFile JarInputStream JarOutputStream JarURLConnection + JButton JCheckBox JCheckBoxMenuItem JColorChooser JComboBox JComponent JdbcRowSet JDesktopPane JDialog + JEditorPane JFileChooser JFormattedTextField JFrame JInternalFrame JLabel JLayeredPane JList JMenu + JMenuBar JMenuItem JMException JMRuntimeException JMXAuthenticator JMXConnectionNotification + JMXConnector JMXConnectorFactory JMXConnectorProvider JMXConnectorServer JMXConnectorServerFactory + JMXConnectorServerMBean JMXConnectorServerProvider JMXPrincipal JMXProviderException + JMXServerErrorException JMXServiceURL JobAttributes JobHoldUntil JobImpressions JobImpressionsCompleted + JobImpressionsSupported JobKOctets JobKOctetsProcessed JobKOctetsSupported JobMediaSheets + JobMediaSheetsCompleted JobMediaSheetsSupported JobMessageFromOperator JobName JobOriginatingUserName + JobPriority JobPrioritySupported JobSheets JobState JobStateReason JobStateReasons Joinable JoinRowSet + JOptionPane JPanel JPasswordField JPEGHuffmanTable JPEGImageReadParam JPEGImageWriteParam JPEGQTable + JPopupMenu JProgressBar JRadioButton JRadioButtonMenuItem JRootPane JScrollBar JScrollPane JSeparator + JSlider JSpinner JSplitPane JTabbedPane JTable JTableHeader JTextArea JTextComponent JTextField + JTextPane JToggleButton JToolBar JToolTip JTree JViewport JWindow KerberosKey KerberosPrincipal + KerberosTicket Kernel Key KeyAdapter KeyAgreement KeyAgreementSpi KeyAlreadyExistsException + KeyboardFocusManager KeyEvent KeyEventDispatcher KeyEventPostProcessor KeyException KeyFactory + KeyFactorySpi KeyGenerator KeyGeneratorSpi KeyListener KeyManagementException KeyManager + KeyManagerFactory KeyManagerFactorySpi Keymap KeyPair KeyPairGenerator KeyPairGeneratorSpi KeyRep + KeySpec KeyStore KeyStoreBuilderParameters KeyStoreException KeyStoreSpi KeyStroke Label LabelUI + LabelView LanguageCallback LastOwnerException LayeredHighlighter LayoutFocusTraversalPolicy + LayoutManager LayoutManager2 LayoutQueue LDAPCertStoreParameters LdapContext LdapName + LdapReferralException Lease Level LimitExceededException Line Line2D LineBorder LineBreakMeasurer + LineEvent LineListener LineMetrics LineNumberInputStream LineNumberReader LineUnavailableException + LinkageError LinkedBlockingQueue LinkedHashMap LinkedHashSet LinkedList LinkException LinkLoopException + LinkRef List ListCellRenderer ListDataEvent ListDataListener ListenerNotFoundException ListIterator + ListModel ListResourceBundle ListSelectionEvent ListSelectionListener ListSelectionModel ListUI ListView + LoaderHandler Locale LocateRegistry Lock LockSupport Logger LoggingMXBean LoggingPermission LoginContext + LoginException LoginModule LogManager LogRecord LogStream Long LongBuffer LookAndFeel LookupOp + LookupTable Mac MacSpi MalformedInputException MalformedLinkException MalformedObjectNameException + MalformedParameterizedTypeException MalformedURLException ManagementFactory ManagementPermission + ManageReferralControl ManagerFactoryParameters Manifest Map MappedByteBuffer MarshalException + MarshalledObject MaskFormatter Matcher MatchResult Math MathContext MatteBorder MBeanAttributeInfo + MBeanConstructorInfo MBeanException MBeanFeatureInfo MBeanInfo MBeanNotificationInfo MBeanOperationInfo + MBeanParameterInfo MBeanPermission MBeanRegistration MBeanRegistrationException MBeanServer + MBeanServerBuilder MBeanServerConnection MBeanServerDelegate MBeanServerDelegateMBean MBeanServerFactory + MBeanServerForwarder MBeanServerInvocationHandler MBeanServerNotification MBeanServerNotificationFilter + MBeanServerPermission MBeanTrustPermission Media MediaName MediaPrintableArea MediaSize MediaSizeName + MediaTracker MediaTray Member MemoryCacheImageInputStream MemoryCacheImageOutputStream MemoryHandler + MemoryImageSource MemoryManagerMXBean MemoryMXBean MemoryNotificationInfo MemoryPoolMXBean MemoryType + MemoryUsage Menu MenuBar MenuBarUI MenuComponent MenuContainer MenuDragMouseEvent MenuDragMouseListener + MenuElement MenuEvent MenuItem MenuItemUI MenuKeyEvent MenuKeyListener MenuListener MenuSelectionManager + MenuShortcut MessageDigest MessageDigestSpi MessageFormat MetaEventListener MetalBorders MetalButtonUI + MetalCheckBoxIcon MetalCheckBoxUI MetalComboBoxButton MetalComboBoxEditor MetalComboBoxIcon + MetalComboBoxUI MetalDesktopIconUI MetalFileChooserUI MetalIconFactory MetalInternalFrameTitlePane + MetalInternalFrameUI MetalLabelUI MetalLookAndFeel MetalMenuBarUI MetalPopupMenuSeparatorUI + MetalProgressBarUI MetalRadioButtonUI MetalRootPaneUI MetalScrollBarUI MetalScrollButton + MetalScrollPaneUI MetalSeparatorUI MetalSliderUI MetalSplitPaneUI MetalTabbedPaneUI MetalTextFieldUI + MetalTheme MetalToggleButtonUI MetalToolBarUI MetalToolTipUI MetalTreeUI MetaMessage Method + MethodDescriptor MGF1ParameterSpec MidiChannel MidiDevice MidiDeviceProvider MidiEvent MidiFileFormat + MidiFileReader MidiFileWriter MidiMessage MidiSystem MidiUnavailableException MimeTypeParseException + MinimalHTMLWriter MissingFormatArgumentException MissingFormatWidthException MissingResourceException + Mixer MixerProvider MLet MLetMBean ModelMBean ModelMBeanAttributeInfo ModelMBeanConstructorInfo + ModelMBeanInfo ModelMBeanInfoSupport ModelMBeanNotificationBroadcaster ModelMBeanNotificationInfo + ModelMBeanOperationInfo ModificationItem Modifier Monitor MonitorMBean MonitorNotification + MonitorSettingException MouseAdapter MouseDragGestureRecognizer MouseEvent MouseInfo MouseInputAdapter + MouseInputListener MouseListener MouseMotionAdapter MouseMotionListener MouseWheelEvent + MouseWheelListener MultiButtonUI MulticastSocket MultiColorChooserUI MultiComboBoxUI MultiDesktopIconUI + MultiDesktopPaneUI MultiDoc MultiDocPrintJob MultiDocPrintService MultiFileChooserUI + MultiInternalFrameUI MultiLabelUI MultiListUI MultiLookAndFeel MultiMenuBarUI MultiMenuItemUI + MultiOptionPaneUI MultiPanelUI MultiPixelPackedSampleModel MultipleDocumentHandling MultipleMaster + MultiPopupMenuUI MultiProgressBarUI MultiRootPaneUI MultiScrollBarUI MultiScrollPaneUI MultiSeparatorUI + MultiSliderUI MultiSpinnerUI MultiSplitPaneUI MultiTabbedPaneUI MultiTableHeaderUI MultiTableUI + MultiTextUI MultiToolBarUI MultiToolTipUI MultiTreeUI MultiViewportUI MutableAttributeSet + MutableComboBoxModel MutableTreeNode Name NameAlreadyBoundException NameCallback NameClassPair + NameNotFoundException NameParser NamespaceChangeListener NamespaceContext Naming NamingEnumeration + NamingEvent NamingException NamingExceptionEvent NamingListener NamingManager NamingSecurityException + NavigationFilter NegativeArraySizeException NetPermission NetworkInterface NoClassDefFoundError + NoConnectionPendingException NodeChangeEvent NodeChangeListener NoInitialContextException + NoninvertibleTransformException NonReadableChannelException NonWritableChannelException + NoPermissionException NoRouteToHostException NoSuchAlgorithmException NoSuchAttributeException + NoSuchElementException NoSuchFieldError NoSuchFieldException NoSuchMethodError NoSuchMethodException + NoSuchObjectException NoSuchPaddingException NoSuchProviderException NotActiveException + NotBoundException NotCompliantMBeanException NotContextException Notification NotificationBroadcaster + NotificationBroadcasterSupport NotificationEmitter NotificationFilter NotificationFilterSupport + NotificationListener NotificationResult NotOwnerException NotSerializableException NotYetBoundException + NotYetConnectedException NullCipher NullPointerException Number NumberFormat NumberFormatException + NumberFormatter NumberOfDocuments NumberOfInterveningJobs NumberUp NumberUpSupported NumericShaper + OAEPParameterSpec Object ObjectChangeListener ObjectFactory ObjectFactoryBuilder ObjectInput + ObjectInputStream ObjectInputValidation ObjectInstance ObjectName ObjectOutput ObjectOutputStream + ObjectStreamClass ObjectStreamConstants ObjectStreamException ObjectStreamField ObjectView ObjID + Observable Observer OceanTheme OpenDataException OpenMBeanAttributeInfo OpenMBeanAttributeInfoSupport + OpenMBeanConstructorInfo OpenMBeanConstructorInfoSupport OpenMBeanInfo OpenMBeanInfoSupport + OpenMBeanOperationInfo OpenMBeanOperationInfoSupport OpenMBeanParameterInfo + OpenMBeanParameterInfoSupport OpenType OperatingSystemMXBean Operation OperationNotSupportedException + OperationsException Option OptionalDataException OptionPaneUI OrientationRequested OutOfMemoryError + OutputDeviceAssigned OutputKeys OutputStream OutputStreamWriter OverlappingFileLockException + OverlayLayout Override Owner Pack200 Package PackedColorModel Pageable PageAttributes + PagedResultsControl PagedResultsResponseControl PageFormat PageRanges PagesPerMinute PagesPerMinuteColor + Paint PaintContext PaintEvent Panel PanelUI Paper ParagraphView ParameterBlock ParameterDescriptor + ParameterizedType ParameterMetaData ParseException ParsePosition Parser ParserConfigurationException + ParserDelegator PartialResultException PasswordAuthentication PasswordCallback PasswordView Patch + PathIterator Pattern PatternSyntaxException PBEKey PBEKeySpec PBEParameterSpec PDLOverrideSupported + Permission PermissionCollection Permissions PersistenceDelegate PersistentMBean PhantomReference Pipe + PipedInputStream PipedOutputStream PipedReader PipedWriter PixelGrabber PixelInterleavedSampleModel + PKCS8EncodedKeySpec PKIXBuilderParameters PKIXCertPathBuilderResult PKIXCertPathChecker + PKIXCertPathValidatorResult PKIXParameters PlainDocument PlainView Point Point2D PointerInfo Policy + PolicyNode PolicyQualifierInfo Polygon PooledConnection Popup PopupFactory PopupMenu PopupMenuEvent + PopupMenuListener PopupMenuUI Port PortableRemoteObject PortableRemoteObjectDelegate + PortUnreachableException Position Predicate PreferenceChangeEvent PreferenceChangeListener Preferences + PreferencesFactory PreparedStatement PresentationDirection Principal Printable PrinterAbortException + PrinterException PrinterGraphics PrinterInfo PrinterIOException PrinterIsAcceptingJobs PrinterJob + PrinterLocation PrinterMakeAndModel PrinterMessageFromOperator PrinterMoreInfo + PrinterMoreInfoManufacturer PrinterName PrinterResolution PrinterState PrinterStateReason + PrinterStateReasons PrinterURI PrintEvent PrintException PrintGraphics PrintJob PrintJobAdapter + PrintJobAttribute PrintJobAttributeEvent PrintJobAttributeListener PrintJobAttributeSet PrintJobEvent + PrintJobListener PrintQuality PrintRequestAttribute PrintRequestAttributeSet PrintService + PrintServiceAttribute PrintServiceAttributeEvent PrintServiceAttributeListener PrintServiceAttributeSet + PrintServiceLookup PrintStream PrintWriter PriorityBlockingQueue PriorityQueue PrivateClassLoader + PrivateCredentialPermission PrivateKey PrivateMLet PrivilegedAction PrivilegedActionException + PrivilegedExceptionAction Process ProcessBuilder ProfileDataException ProgressBarUI ProgressMonitor + ProgressMonitorInputStream Properties PropertyChangeEvent PropertyChangeListener + PropertyChangeListenerProxy PropertyChangeSupport PropertyDescriptor PropertyEditor + PropertyEditorManager PropertyEditorSupport PropertyPermission PropertyResourceBundle + PropertyVetoException ProtectionDomain ProtocolException Provider ProviderException Proxy ProxySelector + PSource PSSParameterSpec PublicKey PushbackInputStream PushbackReader QName QuadCurve2D Query QueryEval + QueryExp Queue QueuedJobCount Random RandomAccess RandomAccessFile Raster RasterFormatException RasterOp + RC2ParameterSpec RC5ParameterSpec Rdn Readable ReadableByteChannel Reader ReadOnlyBufferException + ReadWriteLock RealmCallback RealmChoiceCallback Receiver Rectangle Rectangle2D RectangularShape + ReentrantLock ReentrantReadWriteLock Ref RefAddr Reference Referenceable ReferenceQueue + ReferenceUriSchemesSupported ReferralException ReflectionException ReflectPermission Refreshable + RefreshFailedException Region RegisterableService Registry RegistryHandler RejectedExecutionException + RejectedExecutionHandler Relation RelationException RelationNotFoundException RelationNotification + RelationService RelationServiceMBean RelationServiceNotRegisteredException RelationSupport + RelationSupportMBean RelationType RelationTypeNotFoundException RelationTypeSupport Remote RemoteCall + RemoteException RemoteObject RemoteObjectInvocationHandler RemoteRef RemoteServer RemoteStub + RenderableImage RenderableImageOp RenderableImageProducer RenderContext RenderedImage + RenderedImageFactory Renderer RenderingHints RepaintManager ReplicateScaleFilter RequestingUserName + RequiredModelMBean RescaleOp ResolutionSyntax Resolver ResolveResult ResourceBundle ResponseCache Result + ResultSet ResultSetMetaData Retention RetentionPolicy ReverbType RGBImageFilter RMIClassLoader + RMIClassLoaderSpi RMIClientSocketFactory RMIConnection RMIConnectionImpl RMIConnectionImpl_Stub + RMIConnector RMIConnectorServer RMIFailureHandler RMIIIOPServerImpl RMIJRMPServerImpl + RMISecurityException RMISecurityManager RMIServer RMIServerImpl RMIServerImpl_Stub + RMIServerSocketFactory RMISocketFactory Robot Role RoleInfo RoleInfoNotFoundException RoleList + RoleNotFoundException RoleResult RoleStatus RoleUnresolved RoleUnresolvedList RootPaneContainer + RootPaneUI RoundingMode RoundRectangle2D RowMapper RowSet RowSetEvent RowSetInternal RowSetListener + RowSetMetaData RowSetMetaDataImpl RowSetReader RowSetWarning RowSetWriter RSAKey RSAKeyGenParameterSpec + RSAMultiPrimePrivateCrtKey RSAMultiPrimePrivateCrtKeySpec RSAOtherPrimeInfo RSAPrivateCrtKey + RSAPrivateCrtKeySpec RSAPrivateKey RSAPrivateKeySpec RSAPublicKey RSAPublicKeySpec RTFEditorKit + RuleBasedCollator Runnable Runtime RuntimeErrorException RuntimeException RuntimeMBeanException + RuntimeMXBean RuntimeOperationsException RuntimePermission SampleModel Sasl SaslClient SaslClientFactory + SaslException SaslServer SaslServerFactory Savepoint SAXParser SAXParserFactory SAXResult SAXSource + SAXTransformerFactory Scanner ScatteringByteChannel ScheduledExecutorService ScheduledFuture + ScheduledThreadPoolExecutor Schema SchemaFactory SchemaFactoryLoader SchemaViolationException Scrollable + Scrollbar ScrollBarUI ScrollPane ScrollPaneAdjustable ScrollPaneConstants ScrollPaneLayout ScrollPaneUI + SealedObject SearchControls SearchResult SecretKey SecretKeyFactory SecretKeyFactorySpi SecretKeySpec + SecureCacheResponse SecureClassLoader SecureRandom SecureRandomSpi Security SecurityException + SecurityManager SecurityPermission Segment SelectableChannel SelectionKey Selector SelectorProvider + Semaphore SeparatorUI Sequence SequenceInputStream Sequencer SerialArray SerialBlob SerialClob + SerialDatalink SerialException Serializable SerializablePermission SerialJavaObject SerialRef + SerialStruct ServerCloneException ServerError ServerException ServerNotActiveException ServerRef + ServerRuntimeException ServerSocket ServerSocketChannel ServerSocketFactory ServiceNotFoundException + ServicePermission ServiceRegistry ServiceUI ServiceUIFactory ServiceUnavailableException Set + SetOfIntegerSyntax Severity Shape ShapeGraphicAttribute SheetCollate Short ShortBuffer + ShortBufferException ShortLookupTable ShortMessage Sides Signature SignatureException SignatureSpi + SignedObject Signer SimpleAttributeSet SimpleBeanInfo SimpleDateFormat SimpleDoc SimpleFormatter + SimpleTimeZone SimpleType SinglePixelPackedSampleModel SingleSelectionModel Size2DSyntax + SizeLimitExceededException SizeRequirements SizeSequence Skeleton SkeletonMismatchException + SkeletonNotFoundException SliderUI Socket SocketAddress SocketChannel SocketException SocketFactory + SocketHandler SocketImpl SocketImplFactory SocketOptions SocketPermission SocketSecurityException + SocketTimeoutException SoftBevelBorder SoftReference SortControl SortedMap SortedSet + SortingFocusTraversalPolicy SortKey SortResponseControl Soundbank SoundbankReader SoundbankResource + Source SourceDataLine SourceLocator SpinnerDateModel SpinnerListModel SpinnerModel SpinnerNumberModel + SpinnerUI SplitPaneUI Spring SpringLayout SQLData SQLException SQLInput SQLInputImpl SQLOutput + SQLOutputImpl SQLPermission SQLWarning SSLContext SSLContextSpi SSLEngine SSLEngineResult SSLException + SSLHandshakeException SSLKeyException SSLPeerUnverifiedException SSLPermission SSLProtocolException + SslRMIClientSocketFactory SslRMIServerSocketFactory SSLServerSocket SSLServerSocketFactory SSLSession + SSLSessionBindingEvent SSLSessionBindingListener SSLSessionContext SSLSocket SSLSocketFactory Stack + StackOverflowError StackTraceElement StandardMBean StartTlsRequest StartTlsResponse StateEdit + StateEditable StateFactory Statement StreamCorruptedException StreamHandler StreamPrintService + StreamPrintServiceFactory StreamResult StreamSource StreamTokenizer StrictMath String StringBuffer + StringBufferInputStream StringBuilder StringCharacterIterator StringContent + StringIndexOutOfBoundsException StringMonitor StringMonitorMBean StringReader StringRefAddr + StringSelection StringTokenizer StringValueExp StringWriter Stroke Struct Stub StubDelegate + StubNotFoundException Style StyleConstants StyleContext StyledDocument StyledEditorKit StyleSheet + Subject SubjectDelegationPermission SubjectDomainCombiner SupportedValuesAttribute SuppressWarnings + SwingConstants SwingPropertyChangeSupport SwingUtilities SyncFactory SyncFactoryException + SyncFailedException SynchronousQueue SyncProvider SyncProviderException SyncResolver SynthConstants + SynthContext Synthesizer SynthGraphicsUtils SynthLookAndFeel SynthPainter SynthStyle SynthStyleFactory + SysexMessage System SystemColor SystemFlavorMap TabableView TabbedPaneUI TabExpander TableCellEditor + TableCellRenderer TableColumn TableColumnModel TableColumnModelEvent TableColumnModelListener + TableHeaderUI TableModel TableModelEvent TableModelListener TableUI TableView TabSet TabStop TabularData + TabularDataSupport TabularType TagElement Target TargetDataLine TargetedNotification Templates + TemplatesHandler TextAction TextArea TextAttribute TextComponent TextEvent TextField TextHitInfo + TextInputCallback TextLayout TextListener TextMeasurer TextOutputCallback TextSyntax TextUI TexturePaint + Thread ThreadDeath ThreadFactory ThreadGroup ThreadInfo ThreadLocal ThreadMXBean ThreadPoolExecutor + Throwable Tie TileObserver Time TimeLimitExceededException TimeoutException Timer + TimerAlarmClockNotification TimerMBean TimerNotification TimerTask Timestamp TimeUnit TimeZone + TitledBorder ToolBarUI Toolkit ToolTipManager ToolTipUI TooManyListenersException Track + TransactionalWriter TransactionRequiredException TransactionRolledbackException Transferable + TransferHandler TransformAttribute Transformer TransformerConfigurationException TransformerException + TransformerFactory TransformerFactoryConfigurationError TransformerHandler Transmitter Transparency + TreeCellEditor TreeCellRenderer TreeExpansionEvent TreeExpansionListener TreeMap TreeModel + TreeModelEvent TreeModelListener TreeNode TreePath TreeSelectionEvent TreeSelectionListener + TreeSelectionModel TreeSet TreeUI TreeWillExpandListener TrustAnchor TrustManager TrustManagerFactory + TrustManagerFactorySpi Type TypeInfoProvider TypeNotPresentException Types TypeVariable UID UIDefaults + UIManager UIResource UndeclaredThrowableException UndoableEdit UndoableEditEvent UndoableEditListener + UndoableEditSupport UndoManager UnexpectedException UnicastRemoteObject UnknownError + UnknownFormatConversionException UnknownFormatFlagsException UnknownGroupException UnknownHostException + UnknownObjectException UnknownServiceException UnmappableCharacterException UnmarshalException + UnmodifiableClassException UnmodifiableSetException UnrecoverableEntryException + UnrecoverableKeyException Unreferenced UnresolvedAddressException UnresolvedPermission + UnsatisfiedLinkError UnsolicitedNotification UnsolicitedNotificationEvent + UnsolicitedNotificationListener UnsupportedAddressTypeException UnsupportedAudioFileException + UnsupportedCallbackException UnsupportedCharsetException UnsupportedClassVersionError + UnsupportedEncodingException UnsupportedFlavorException UnsupportedLookAndFeelException + UnsupportedOperationException URI URIException URIResolver URISyntax URISyntaxException URL + URLClassLoader URLConnection URLDecoder URLEncoder URLStreamHandler URLStreamHandlerFactory + UTFDataFormatException Util UtilDelegate Utilities UUID Validator ValidatorHandler ValueExp ValueHandler + ValueHandlerMultiFormat VariableHeightLayoutCache Vector VerifyError VetoableChangeListener + VetoableChangeListenerProxy VetoableChangeSupport View ViewFactory ViewportLayout ViewportUI + VirtualMachineError Visibility VMID VoiceStatus Void VolatileImage WeakHashMap WeakReference WebRowSet + WildcardType Window WindowAdapter WindowConstants WindowEvent WindowFocusListener WindowListener + WindowStateListener WrappedPlainView WritableByteChannel WritableRaster WritableRenderedImage + WriteAbortedException Writer X500Principal X500PrivateCredential X509Certificate X509CertSelector + X509CRL X509CRLEntry X509CRLSelector X509EncodedKeySpec X509ExtendedKeyManager X509Extension + X509KeyManager X509TrustManager XAConnection XADataSource XAException XAResource Xid XMLConstants + XMLDecoder XMLEncoder XMLFormatter XMLGregorianCalendar XMLParseException XmlReader XmlWriter XPath + XPathConstants XPathException XPathExpression XPathExpressionException XPathFactory + XPathFactoryConfigurationException XPathFunction XPathFunctionException XPathFunctionResolver + XPathVariableResolver ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream ZoneView + ] + #:nocov: + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java_script.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java_script.rb new file mode 100644 index 000000000..9eb0a0a14 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/java_script.rb @@ -0,0 +1,237 @@ +module CodeRay +module Scanners + + # Scanner for JavaScript. + # + # Aliases: +ecmascript+, +ecma_script+, +javascript+ + class JavaScript < Scanner + + register_for :java_script + file_extension 'js' + + # The actual JavaScript keywords. + KEYWORDS = %w[ + break case catch continue default delete do else + finally for function if in instanceof new + return switch throw try typeof var void while with + ] # :nodoc: + PREDEFINED_CONSTANTS = %w[ + false null true undefined NaN Infinity + ] # :nodoc: + + MAGIC_VARIABLES = %w[ this arguments ] # :nodoc: arguments was introduced in JavaScript 1.4 + + KEYWORDS_EXPECTING_VALUE = WordList.new.add %w[ + case delete in instanceof new return throw typeof with + ] # :nodoc: + + # Reserved for future use. + RESERVED_WORDS = %w[ + abstract boolean byte char class debugger double enum export extends + final float goto implements import int interface long native package + private protected public short static super synchronized throws transient + volatile + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(RESERVED_WORDS, :reserved). + add(PREDEFINED_CONSTANTS, :predefined_constant). + add(MAGIC_VARIABLES, :local_variable). + add(KEYWORDS, :keyword) # :nodoc: + + ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: + REGEXP_ESCAPE = / [bBdDsSwW] /x # :nodoc: + STRING_CONTENT_PATTERN = { + "'" => /[^\\']+/, + '"' => /[^\\"]+/, + '/' => /[^\\\/]+/, + } # :nodoc: + KEY_CHECK_PATTERN = { + "'" => / (?> [^\\']* (?: \\. [^\\']* )* ) ' \s* : /mx, + '"' => / (?> [^\\"]* (?: \\. [^\\"]* )* ) " \s* : /mx, + } # :nodoc: + + protected + + def setup + @state = :initial + end + + def scan_tokens encoder, options + + state, string_delimiter = options[:state] || @state + if string_delimiter + encoder.begin_group state + end + + value_expected = true + key_expected = false + function_expected = false + + until eos? + + case state + + when :initial + + if match = scan(/ \s+ | \\\n /x) + value_expected = true if !value_expected && match.index(?\n) + encoder.text_token match, :space + + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .*() ) !mx) + value_expected = true + encoder.text_token match, :comment + state = :open_multi_line_comment if self[1] + + elsif check(/\.?\d/) + key_expected = value_expected = false + if match = scan(/0[xX][0-9A-Fa-f]+/) + encoder.text_token match, :hex + elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/) + encoder.text_token match, :octal + elsif match = scan(/\d+[fF]|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/) + encoder.text_token match, :float + elsif match = scan(/\d+/) + encoder.text_token match, :integer + end + + elsif value_expected && match = scan(/<([[:alpha:]]\w*) (?: [^\/>]*\/> | .*?<\/\1>)/xim) + # TODO: scan over nested tags + xml_scanner.tokenize match, :tokens => encoder + value_expected = false + next + + elsif match = scan(/ [-+*=<>?:;,!&^|(\[{~%]+ | \.(?!\d) /x) + value_expected = true + last_operator = match[-1] + key_expected = (last_operator == ?{) || (last_operator == ?,) + function_expected = false + encoder.text_token match, :operator + + elsif match = scan(/ [)\]}]+ /x) + function_expected = key_expected = value_expected = false + encoder.text_token match, :operator + + elsif match = scan(/ [$a-zA-Z_][A-Za-z_0-9$]* /x) + kind = IDENT_KIND[match] + value_expected = (kind == :keyword) && KEYWORDS_EXPECTING_VALUE[match] + # TODO: labels + if kind == :ident + if match.index(?$) # $ allowed inside an identifier + kind = :predefined + elsif function_expected + kind = :function + elsif check(/\s*[=:]\s*function\b/) + kind = :function + elsif key_expected && check(/\s*:/) + kind = :key + end + end + function_expected = (kind == :keyword) && (match == 'function') + key_expected = false + encoder.text_token match, kind + + elsif match = scan(/["']/) + if key_expected && check(KEY_CHECK_PATTERN[match]) + state = :key + else + state = :string + end + encoder.begin_group state + string_delimiter = match + encoder.text_token match, :delimiter + + elsif value_expected && (match = scan(/\//)) + encoder.begin_group :regexp + state = :regexp + string_delimiter = '/' + encoder.text_token match, :delimiter + + elsif match = scan(/ \/ /x) + value_expected = true + key_expected = false + encoder.text_token match, :operator + + else + encoder.text_token getch, :error + + end + + when :string, :regexp, :key + if match = scan(STRING_CONTENT_PATTERN[string_delimiter]) + encoder.text_token match, :content + elsif match = scan(/["'\/]/) + encoder.text_token match, :delimiter + if state == :regexp + modifiers = scan(/[gim]+/) + encoder.text_token modifiers, :modifier if modifiers && !modifiers.empty? + end + encoder.end_group state + string_delimiter = nil + key_expected = value_expected = false + state = :initial + elsif state != :regexp && (match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)) + if string_delimiter == "'" && !(match == "\\\\" || match == "\\'") + encoder.text_token match, :content + else + encoder.text_token match, :char + end + elsif state == :regexp && match = scan(/ \\ (?: #{ESCAPE} | #{REGEXP_ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + elsif match = scan(/\\./m) + encoder.text_token match, :content + elsif match = scan(/ \\ | $ /x) + encoder.end_group state + encoder.text_token match, :error unless match.empty? + string_delimiter = nil + key_expected = value_expected = false + state = :initial + else + raise_inspect "else case #{string_delimiter} reached; %p not handled." % peek(1), encoder + end + + when :open_multi_line_comment + if match = scan(%r! .*? \*/ !mx) + state = :initial + else + match = scan(%r! .+ !mx) + end + value_expected = true + encoder.text_token match, :comment if match + + else + #:nocov: + raise_inspect 'Unknown state: %p' % [state], encoder + #:nocov: + + end + + end + + if options[:keep_state] + @state = state, string_delimiter + end + + if [:string, :regexp].include? state + encoder.end_group state + end + + encoder + end + + protected + + def reset_instance + super + @xml_scanner.reset if defined? @xml_scanner + end + + def xml_scanner + @xml_scanner ||= CodeRay.scanner :xml, :tokens => @tokens, :keep_tokens => true, :keep_state => false + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/json.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/json.rb new file mode 100644 index 000000000..b09970c23 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/json.rb @@ -0,0 +1,98 @@ +module CodeRay +module Scanners + + # Scanner for JSON (JavaScript Object Notation). + class JSON < Scanner + + register_for :json + file_extension 'json' + + KINDS_NOT_LOC = [ + :float, :char, :content, :delimiter, + :error, :integer, :operator, :value, + ] # :nodoc: + + ESCAPE = / [bfnrt\\"\/] /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc: + KEY = / (?> (?: [^\\"]+ | \\. )* ) " \s* : /x + + protected + + def setup + @state = :initial + end + + # See http://json.org/ for a definition of the JSON lexic/grammar. + def scan_tokens encoder, options + state = options[:state] || @state + + if [:string, :key].include? state + encoder.begin_group state + end + + until eos? + + case state + + when :initial + if match = scan(/ \s+ /x) + encoder.text_token match, :space + elsif match = scan(/"/) + state = check(/#{KEY}/o) ? :key : :string + encoder.begin_group state + encoder.text_token match, :delimiter + elsif match = scan(/ [:,\[{\]}] /x) + encoder.text_token match, :operator + elsif match = scan(/ true | false | null /x) + encoder.text_token match, :value + elsif match = scan(/ -? (?: 0 | [1-9]\d* ) /x) + if scan(/ \.\d+ (?:[eE][-+]?\d+)? | [eE][-+]? \d+ /x) + match << matched + encoder.text_token match, :float + else + encoder.text_token match, :integer + end + else + encoder.text_token getch, :error + end + + when :string, :key + if match = scan(/[^\\"]+/) + encoder.text_token match, :content + elsif match = scan(/"/) + encoder.text_token match, :delimiter + encoder.end_group state + state = :initial + elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + encoder.text_token match, :char + elsif match = scan(/\\./m) + encoder.text_token match, :content + elsif match = scan(/ \\ | $ /x) + encoder.end_group state + encoder.text_token match, :error unless match.empty? + state = :initial + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder + end + + else + raise_inspect 'Unknown state: %p' % [state], encoder + + end + end + + if options[:keep_state] + @state = state + end + + if [:string, :key].include? state + encoder.end_group state + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/lua.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/lua.rb new file mode 100644 index 000000000..fb1e45a7e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/lua.rb @@ -0,0 +1,280 @@ +# encoding: utf-8 + +module CodeRay +module Scanners + + # Scanner for the Lua[http://lua.org] programming lanuage. + # + # The language’s complete syntax is defined in + # {the Lua manual}[http://www.lua.org/manual/5.2/manual.html], + # which is what this scanner tries to conform to. + class Lua < Scanner + + register_for :lua + file_extension 'lua' + title 'Lua' + + # Keywords used in Lua. + KEYWORDS = %w[and break do else elseif end + for function goto if in + local not or repeat return + then until while + ] + + # Constants set by the Lua core. + PREDEFINED_CONSTANTS = %w[false true nil] + + # The expressions contained in this array are parts of Lua’s `basic' + # library. Although it’s not entirely necessary to load that library, + # it is highly recommended and one would have to provide own implementations + # of some of these expressions if one does not do so. They however aren’t + # keywords, neither are they constants, but nearly predefined, so they + # get tagged as `predefined' rather than anything else. + # + # This list excludes values of form `_UPPERCASE' because the Lua manual + # requires such identifiers to be reserved by Lua anyway and they are + # highlighted directly accordingly, without the need for specific + # identifiers to be listed here. + PREDEFINED_EXPRESSIONS = %w[ + assert collectgarbage dofile error getmetatable + ipairs load loadfile next pairs pcall print + rawequal rawget rawlen rawset select setmetatable + tonumber tostring type xpcall + ] + + # Automatic token kind selection for normal words. + IDENT_KIND = CodeRay::WordList.new(:ident). + add(KEYWORDS, :keyword). + add(PREDEFINED_CONSTANTS, :predefined_constant). + add(PREDEFINED_EXPRESSIONS, :predefined) + + protected + + # Scanner initialization. + def setup + @state = :initial + @brace_depth = 0 + end + + # CodeRay entry hook. Starts parsing. + def scan_tokens(encoder, options) + state = options[:state] || @state + brace_depth = @brace_depth + num_equals = nil + + until eos? + case state + + when :initial + if match = scan(/\-\-\[\=*\[/) #--[[ long (possibly multiline) comment ]] + num_equals = match.count("=") # Number must match for comment end + encoder.begin_group(:comment) + encoder.text_token(match, :delimiter) + state = :long_comment + + elsif match = scan(/--.*$/) # --Lua comment + encoder.text_token(match, :comment) + + elsif match = scan(/\[=*\[/) # [[ long (possibly multiline) string ]] + num_equals = match.count("=") # Number must match for comment end + encoder.begin_group(:string) + encoder.text_token(match, :delimiter) + state = :long_string + + elsif match = scan(/::\s*[a-zA-Z_][a-zA-Z0-9_]+\s*::/) # ::goto_label:: + encoder.text_token(match, :label) + + elsif match = scan(/_[A-Z]+/) # _UPPERCASE are names reserved for Lua + encoder.text_token(match, :predefined) + + elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) # Normal letters (or letters followed by digits) + kind = IDENT_KIND[match] + + # Extra highlighting for entities following certain keywords + if kind == :keyword and match == "function" + state = :function_expected + elsif kind == :keyword and match == "goto" + state = :goto_label_expected + elsif kind == :keyword and match == "local" + state = :local_var_expected + end + + encoder.text_token(match, kind) + + elsif match = scan(/\{/) # Opening table brace { + encoder.begin_group(:map) + encoder.text_token(match, brace_depth >= 1 ? :inline_delimiter : :delimiter) + brace_depth += 1 + state = :map + + elsif match = scan(/\}/) # Closing table brace } + if brace_depth == 1 + brace_depth = 0 + encoder.text_token(match, :delimiter) + encoder.end_group(:map) + elsif brace_depth == 0 # Mismatched brace + encoder.text_token(match, :error) + else + brace_depth -= 1 + encoder.text_token(match, :inline_delimiter) + encoder.end_group(:map) + state = :map + end + + elsif match = scan(/["']/) # String delimiters " and ' + encoder.begin_group(:string) + encoder.text_token(match, :delimiter) + start_delim = match + state = :string + + # ↓Prefix hex number ←|→ decimal number + elsif match = scan(/-? (?:0x\h* \. \h+ (?:p[+\-]?\d+)? | \d*\.\d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power + encoder.text_token(match, :float) + + # ↓Prefix hex number ←|→ decimal number + elsif match = scan(/-? (?:0x\h+ (?:p[+\-]?\d+)? | \d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power + encoder.text_token(match, :integer) + + elsif match = scan(/[\+\-\*\/%^\#=~<>\(\)\[\]:;,] | \.(?!\d)/x) # Operators + encoder.text_token(match, :operator) + + elsif match = scan(/\s+/) # Space + encoder.text_token(match, :space) + + else # Invalid stuff. Note that Lua doesn’t accept multibyte chars outside of strings, hence these are also errors. + encoder.text_token(getch, :error) + end + + # It may be that we’re scanning a full-blown subexpression of a table + # (tables can contain full expressions in parts). + # If this is the case, return to :map scanning state. + state = :map if state == :initial && brace_depth >= 1 + + when :function_expected + if match = scan(/\(.*?\)/m) # x = function() # "Anonymous" function without explicit name + encoder.text_token(match, :operator) + state = :initial + elsif match = scan(/[a-zA-Z_] (?:[a-zA-Z0-9_\.] (?!\.\d))* [\.\:]/x) # function tbl.subtbl.foo() | function tbl:foo() # Colon only allowed as last separator + encoder.text_token(match, :ident) + elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) # function foo() + encoder.text_token(match, :function) + state = :initial + elsif match = scan(/\s+/) # Between the `function' keyword and the ident may be any amount of whitespace + encoder.text_token(match, :space) + else + encoder.text_token(getch, :error) + state = :initial + end + + when :goto_label_expected + if match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) + encoder.text_token(match, :label) + state = :initial + elsif match = scan(/\s+/) # Between the `goto' keyword and the label may be any amount of whitespace + encoder.text_token(match, :space) + else + encoder.text_token(getch, :error) + end + + when :local_var_expected + if match = scan(/function/) # local function ... + encoder.text_token(match, :keyword) + state = :function_expected + elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) + encoder.text_token(match, :local_variable) + elsif match = scan(/,/) + encoder.text_token(match, :operator) + elsif match = scan(/\=/) + encoder.text_token(match, :operator) + # After encountering the equal sign, arbitrary expressions are + # allowed again, so just return to the main state for further + # parsing. + state = :initial + elsif match = scan(/\n/) + encoder.text_token(match, :space) + state = :initial + elsif match = scan(/\s+/) + encoder.text_token(match, :space) + else + encoder.text_token(getch, :error) + end + + when :long_comment + if match = scan(/.*?(?=\]={#{num_equals}}\])/m) + encoder.text_token(match, :content) + + delim = scan(/\]={#{num_equals}}\]/) + encoder.text_token(delim, :delimiter) + else # No terminator found till EOF + encoder.text_token(rest, :error) + terminate + end + encoder.end_group(:comment) + state = :initial + + when :long_string + if match = scan(/.*?(?=\]={#{num_equals}}\])/m) # Long strings do not interpret any escape sequences + encoder.text_token(match, :content) + + delim = scan(/\]={#{num_equals}}\]/) + encoder.text_token(delim, :delimiter) + else # No terminator found till EOF + encoder.text_token(rest, :error) + terminate + end + encoder.end_group(:string) + state = :initial + + when :string + if match = scan(/[^\\#{start_delim}\n]+/) # Everything except \ and the start delimiter character is string content (newlines are only allowed if preceeded by \ or \z) + encoder.text_token(match, :content) + elsif match = scan(/\\(?:['"abfnrtv\\]|z\s*|x\h\h|\d{1,3}|\n)/m) + encoder.text_token(match, :char) + elsif match = scan(Regexp.compile(start_delim)) + encoder.text_token(match, :delimiter) + encoder.end_group(:string) + state = :initial + elsif match = scan(/\n/) # Lua forbids unescaped newlines in normal non-long strings + encoder.text_token("\\n\n", :error) # Visually appealing error indicator--otherwise users may wonder whether the highlighter cannot highlight multine strings + encoder.end_group(:string) + state = :initial + else + encoder.text_token(getch, :error) + end + + when :map + if match = scan(/[,;]/) + encoder.text_token(match, :operator) + elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]* (?=\s*=)/x) + encoder.text_token(match, :key) + encoder.text_token(scan(/\s+/), :space) if check(/\s+/) + encoder.text_token(scan(/\=/), :operator) + state = :initial + elsif match = scan(/\s+/m) + encoder.text_token(match, :space) + else + # Note this clause doesn’t advance the scan pointer, it’s a kind of + # "retry with other options" (the :initial state then of course + # advances the pointer). + state = :initial + end + else + raise + end + + end + + if options[:keep_state] + @state = state + end + + encoder.end_group :string if [:string].include? state + brace_depth.times { encoder.end_group :map } + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/php.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/php.rb new file mode 100644 index 000000000..7a8d75d9c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/php.rb @@ -0,0 +1,527 @@ +# encoding: utf-8 +module CodeRay +module Scanners + + load :html + + # Scanner for PHP. + # + # Original by Stefan Walk. + class PHP < Scanner + + register_for :php + file_extension 'php' + + KINDS_NOT_LOC = HTML::KINDS_NOT_LOC + + protected + + def setup + @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true + end + + def reset_instance + super + @html_scanner.reset + end + + module Words # :nodoc: + + # according to http://www.php.net/manual/en/reserved.keywords.php + KEYWORDS = %w[ + abstract and array as break case catch class clone const continue declare default do else elseif + enddeclare endfor endforeach endif endswitch endwhile extends final for foreach function global + goto if implements interface instanceof namespace new or private protected public static switch + throw try use var while xor + cfunction old_function + ] + + TYPES = %w[ int integer float double bool boolean string array object resource ] + + LANGUAGE_CONSTRUCTS = %w[ + die echo empty exit eval include include_once isset list + require require_once return print unset + ] + + CLASSES = %w[ Directory stdClass __PHP_Incomplete_Class exception php_user_filter Closure ] + + # according to http://php.net/quickref.php on 2009-04-21; + # all functions with _ excluded (module functions) and selected additional functions + BUILTIN_FUNCTIONS = %w[ + abs acos acosh addcslashes addslashes aggregate array arsort ascii2ebcdic asin asinh asort assert atan atan2 + atanh basename bcadd bccomp bcdiv bcmod bcmul bcpow bcpowmod bcscale bcsqrt bcsub bin2hex bindec + bindtextdomain bzclose bzcompress bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite + calculhmac ceil chdir checkdate checkdnsrr chgrp chmod chop chown chr chroot clearstatcache closedir closelog + compact constant copy cos cosh count crc32 crypt current date dcgettext dcngettext deaggregate decbin dechex + decoct define defined deg2rad delete dgettext die dirname diskfreespace dl dngettext doubleval each + ebcdic2ascii echo empty end ereg eregi escapeshellarg escapeshellcmd eval exec exit exp explode expm1 extract + fclose feof fflush fgetc fgetcsv fgets fgetss file fileatime filectime filegroup fileinode filemtime fileowner + fileperms filepro filesize filetype floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv + fputs fread frenchtojd fscanf fseek fsockopen fstat ftell ftok ftruncate fwrite getallheaders getcwd getdate + getenv gethostbyaddr gethostbyname gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid + getmyuid getopt getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext + gettimeofday gettype glob gmdate gmmktime gmstrftime gregoriantojd gzclose gzcompress gzdecode gzdeflate + gzencode gzeof gzfile gzgetc gzgets gzgetss gzinflate gzopen gzpassthru gzputs gzread gzrewind gzseek gztell + gzuncompress gzwrite hash header hebrev hebrevc hexdec htmlentities htmlspecialchars hypot iconv idate + implode include intval ip2long iptcembed iptcparse isset + jddayofweek jdmonthname jdtofrench jdtogregorian jdtojewish jdtojulian jdtounix jewishtojd join jpeg2wbmp + juliantojd key krsort ksort lcfirst lchgrp lchown levenshtein link linkinfo list localeconv localtime log + log10 log1p long2ip lstat ltrim mail main max md5 metaphone mhash microtime min mkdir mktime msql natcasesort + natsort next ngettext nl2br nthmac octdec opendir openlog + ord overload pack passthru pathinfo pclose pfsockopen phpcredits phpinfo phpversion pi png2wbmp popen pos pow + prev print printf putenv quotemeta rad2deg rand range rawurldecode rawurlencode readdir readfile readgzfile + readline readlink realpath recode rename require reset rewind rewinddir rmdir round rsort rtrim scandir + serialize setcookie setlocale setrawcookie settype sha1 shuffle signeurlpaiement sin sinh sizeof sleep snmpget + snmpgetnext snmprealwalk snmpset snmpwalk snmpwalkoid sort soundex split spliti sprintf sqrt srand sscanf stat + strcasecmp strchr strcmp strcoll strcspn strftime stripcslashes stripos stripslashes stristr strlen + strnatcasecmp strnatcmp strncasecmp strncmp strpbrk strpos strptime strrchr strrev strripos strrpos strspn + strstr strtok strtolower strtotime strtoupper strtr strval substr symlink syslog system tan tanh tempnam + textdomain time tmpfile touch trim uasort ucfirst ucwords uksort umask uniqid unixtojd unlink unpack + unserialize unset urldecode urlencode usleep usort vfprintf virtual vprintf vsprintf wordwrap + array_change_key_case array_chunk array_combine array_count_values array_diff array_diff_assoc + array_diff_key array_diff_uassoc array_diff_ukey array_fill array_fill_keys array_filter array_flip + array_intersect array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey + array_key_exists array_keys array_map array_merge array_merge_recursive array_multisort array_pad + array_pop array_product array_push array_rand array_reduce array_reverse array_search array_shift + array_slice array_splice array_sum array_udiff array_udiff_assoc array_udiff_uassoc array_uintersect + array_uintersect_assoc array_uintersect_uassoc array_unique array_unshift array_values array_walk + array_walk_recursive + assert_options base_convert base64_decode base64_encode + chunk_split class_exists class_implements class_parents + count_chars debug_backtrace debug_print_backtrace debug_zval_dump + error_get_last error_log error_reporting extension_loaded + file_exists file_get_contents file_put_contents load_file + func_get_arg func_get_args func_num_args function_exists + get_browser get_called_class get_cfg_var get_class get_class_methods get_class_vars + get_current_user get_declared_classes get_declared_interfaces get_defined_constants + get_defined_functions get_defined_vars get_extension_funcs get_headers get_html_translation_table + get_include_path get_included_files get_loaded_extensions get_magic_quotes_gpc get_magic_quotes_runtime + get_meta_tags get_object_vars get_parent_class get_required_filesget_resource_type + gc_collect_cycles gc_disable gc_enable gc_enabled + halt_compiler headers_list headers_sent highlight_file highlight_string + html_entity_decode htmlspecialchars_decode + in_array include_once inclued_get_data + is_a is_array is_binary is_bool is_buffer is_callable is_dir is_double is_executable is_file is_finite + is_float is_infinite is_int is_integer is_link is_long is_nan is_null is_numeric is_object is_readable + is_real is_resource is_scalar is_soap_fault is_string is_subclass_of is_unicode is_uploaded_file + is_writable is_writeable + locale_get_default locale_set_default + number_format override_function parse_str parse_url + php_check_syntax php_ini_loaded_file php_ini_scanned_files php_logo_guid php_sapi_name + php_strip_whitespace php_uname + preg_filter preg_grep preg_last_error preg_match preg_match_all preg_quote preg_replace + preg_replace_callback preg_split print_r + require_once register_shutdown_function register_tick_function + set_error_handler set_exception_handler set_file_buffer set_include_path + set_magic_quotes_runtime set_time_limit shell_exec + str_getcsv str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split str_word_count + strip_tags substr_compare substr_count substr_replace + time_nanosleep time_sleep_until + token_get_all token_name trigger_error + unregister_tick_function use_soap_error_handler user_error + utf8_decode utf8_encode var_dump var_export + version_compare + zend_logo_guid zend_thread_id zend_version + create_function call_user_func_array + posix_access posix_ctermid posix_get_last_error posix_getcwd posix_getegid + posix_geteuid posix_getgid posix_getgrgid posix_getgrnam posix_getgroups + posix_getlogin posix_getpgid posix_getpgrp posix_getpid posix_getppid + posix_getpwnam posix_getpwuid posix_getrlimit posix_getsid posix_getuid + posix_initgroups posix_isatty posix_kill posix_mkfifo posix_mknod + posix_setegid posix_seteuid posix_setgid posix_setpgid posix_setsid + posix_setuid posix_strerror posix_times posix_ttyname posix_uname + pcntl_alarm pcntl_exec pcntl_fork pcntl_getpriority pcntl_setpriority + pcntl_signal pcntl_signal_dispatch pcntl_sigprocmask pcntl_sigtimedwait + pcntl_sigwaitinfo pcntl_wait pcntl_waitpid pcntl_wexitstatus pcntl_wifexited + pcntl_wifsignaled pcntl_wifstopped pcntl_wstopsig pcntl_wtermsig + ] + # TODO: more built-in PHP functions? + + EXCEPTIONS = %w[ + E_ERROR E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING + E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_DEPRECATED E_USER_DEPRECATED E_ALL E_STRICT + ] + + CONSTANTS = %w[ + null true false self parent + __LINE__ __DIR__ __FILE__ __LINE__ + __CLASS__ __NAMESPACE__ __METHOD__ __FUNCTION__ + PHP_VERSION PHP_MAJOR_VERSION PHP_MINOR_VERSION PHP_RELEASE_VERSION PHP_VERSION_ID PHP_EXTRA_VERSION PHP_ZTS + PHP_DEBUG PHP_MAXPATHLEN PHP_OS PHP_SAPI PHP_EOL PHP_INT_MAX PHP_INT_SIZE DEFAULT_INCLUDE_PATH + PEAR_INSTALL_DIR PEAR_EXTENSION_DIR PHP_EXTENSION_DIR PHP_PREFIX PHP_BINDIR PHP_LIBDIR PHP_DATADIR + PHP_SYSCONFDIR PHP_LOCALSTATEDIR PHP_CONFIG_FILE_PATH PHP_CONFIG_FILE_SCAN_DIR PHP_SHLIB_SUFFIX + PHP_OUTPUT_HANDLER_START PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END + __COMPILER_HALT_OFFSET__ + EXTR_OVERWRITE EXTR_SKIP EXTR_PREFIX_SAME EXTR_PREFIX_ALL EXTR_PREFIX_INVALID EXTR_PREFIX_IF_EXISTS + EXTR_IF_EXISTS SORT_ASC SORT_DESC SORT_REGULAR SORT_NUMERIC SORT_STRING CASE_LOWER CASE_UPPER COUNT_NORMAL + COUNT_RECURSIVE ASSERT_ACTIVE ASSERT_CALLBACK ASSERT_BAIL ASSERT_WARNING ASSERT_QUIET_EVAL CONNECTION_ABORTED + CONNECTION_NORMAL CONNECTION_TIMEOUT INI_USER INI_PERDIR INI_SYSTEM INI_ALL M_E M_LOG2E M_LOG10E M_LN2 M_LN10 + M_PI M_PI_2 M_PI_4 M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2 CRYPT_SALT_LENGTH CRYPT_STD_DES CRYPT_EXT_DES + CRYPT_MD5 CRYPT_BLOWFISH DIRECTORY_SEPARATOR SEEK_SET SEEK_CUR SEEK_END LOCK_SH LOCK_EX LOCK_UN LOCK_NB + HTML_SPECIALCHARS HTML_ENTITIES ENT_COMPAT ENT_QUOTES ENT_NOQUOTES INFO_GENERAL INFO_CREDITS + INFO_CONFIGURATION INFO_MODULES INFO_ENVIRONMENT INFO_VARIABLES INFO_LICENSE INFO_ALL CREDITS_GROUP + CREDITS_GENERAL CREDITS_SAPI CREDITS_MODULES CREDITS_DOCS CREDITS_FULLPAGE CREDITS_QA CREDITS_ALL STR_PAD_LEFT + STR_PAD_RIGHT STR_PAD_BOTH PATHINFO_DIRNAME PATHINFO_BASENAME PATHINFO_EXTENSION PATH_SEPARATOR CHAR_MAX + LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_ALL LC_MESSAGES ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 + ABDAY_6 ABDAY_7 DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7 ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6 + ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12 MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 + MON_10 MON_11 MON_12 AM_STR PM_STR D_T_FMT D_FMT T_FMT T_FMT_AMPM ERA ERA_YEAR ERA_D_T_FMT ERA_D_FMT ERA_T_FMT + ALT_DIGITS INT_CURR_SYMBOL CURRENCY_SYMBOL CRNCYSTR MON_DECIMAL_POINT MON_THOUSANDS_SEP MON_GROUPING + POSITIVE_SIGN NEGATIVE_SIGN INT_FRAC_DIGITS FRAC_DIGITS P_CS_PRECEDES P_SEP_BY_SPACE N_CS_PRECEDES + N_SEP_BY_SPACE P_SIGN_POSN N_SIGN_POSN DECIMAL_POINT RADIXCHAR THOUSANDS_SEP THOUSEP GROUPING YESEXPR NOEXPR + YESSTR NOSTR CODESET LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG LOG_KERN + LOG_USER LOG_MAIL LOG_DAEMON LOG_AUTH LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON LOG_AUTHPRIV LOG_LOCAL0 + LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_PID LOG_CONS LOG_ODELAY + LOG_NDELAY LOG_NOWAIT LOG_PERROR + ] + + PREDEFINED = %w[ + $GLOBALS $_SERVER $_GET $_POST $_FILES $_REQUEST $_SESSION $_ENV + $_COOKIE $php_errormsg $HTTP_RAW_POST_DATA $http_response_header + $argc $argv + ] + + IDENT_KIND = WordList::CaseIgnoring.new(:ident). + add(KEYWORDS, :keyword). + add(TYPES, :predefined_type). + add(LANGUAGE_CONSTRUCTS, :keyword). + add(BUILTIN_FUNCTIONS, :predefined). + add(CLASSES, :predefined_constant). + add(EXCEPTIONS, :exception). + add(CONSTANTS, :predefined_constant) + + VARIABLE_KIND = WordList.new(:local_variable). + add(PREDEFINED, :predefined) + end + + module RE # :nodoc: + + PHP_START = / + ]*?language\s*=\s*"php"[^>]*?> | + ]*?language\s*=\s*'php'[^>]*?> | + <\?php\d? | + <\?(?!xml) + /xi + + PHP_END = %r! + | + \?> + !xi + + HTML_INDICATOR = / ]/i + + IDENTIFIER = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : Regexp.new('[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]*', true) + VARIABLE = /\$#{IDENTIFIER}/ + + OPERATOR = / + \.(?!\d)=? | # dot that is not decimal point, string concatenation + && | \|\| | # logic + :: | -> | => | # scope, member, dictionary + \\(?!\n) | # namespace + \+\+ | -- | # increment, decrement + [,;?:()\[\]{}] | # simple delimiters + [-+*\/%&|^]=? | # ordinary math, binary logic, assignment shortcuts + [~$] | # whatever + =& | # reference assignment + [=!]=?=? | <> | # comparison and assignment + <<=? | >>=? | [<>]=? # comparison and shift + /x + + end + + protected + + def scan_tokens encoder, options + + if check(RE::PHP_START) || # starts with #{RE::IDENTIFIER}/o) + encoder.begin_group :inline + encoder.text_token match, :local_variable + encoder.text_token scan(/->/), :operator + encoder.text_token scan(/#{RE::IDENTIFIER}/o), :ident + encoder.end_group :inline + elsif check(/->/) + match << scan(/->/) + encoder.text_token match, :error + else + encoder.text_token match, :local_variable + end + elsif match = scan(/\{/) + if check(/\$/) + encoder.begin_group :inline + states[-1] = [states.last, delimiter] + delimiter = nil + states.push :php_inline + encoder.text_token match, :delimiter + else + encoder.text_token match, :content + end + elsif match = scan(/\$\{#{RE::IDENTIFIER}\}/o) + encoder.text_token match, :local_variable + elsif match = scan(/\$/) + encoder.text_token match, :content + else + encoder.end_group :string + states.pop + end + + when :class_expected + if match = scan(/\s+/) + encoder.text_token match, :space + elsif match = scan(/#{RE::IDENTIFIER}/o) + encoder.text_token match, :class + states.pop + else + states.pop + end + + when :function_expected + if match = scan(/\s+/) + encoder.text_token match, :space + elsif match = scan(/&/) + encoder.text_token match, :operator + elsif match = scan(/#{RE::IDENTIFIER}/o) + encoder.text_token match, :function + states.pop + else + states.pop + end + + else + raise_inspect 'Unknown state!', encoder, states + end + + end + + while state = states.pop + encoder.end_group :string if [:sqstring, :dqstring].include? state + if state.is_a? Array + encoder.end_group :inline + encoder.end_group :string if [:sqstring, :dqstring].include? state.first + end + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/python.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/python.rb new file mode 100644 index 000000000..09c8b6e70 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/python.rb @@ -0,0 +1,287 @@ +module CodeRay +module Scanners + + # Scanner for Python. Supports Python 3. + # + # Based on pygments' PythonLexer, see + # http://dev.pocoo.org/projects/pygments/browser/pygments/lexers/agile.py. + class Python < Scanner + + register_for :python + file_extension 'py' + + KEYWORDS = [ + 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', + 'del', 'elif', 'else', 'except', 'finally', 'for', + 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', + 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield', + 'nonlocal', # new in Python 3 + ] # :nodoc: + + OLD_KEYWORDS = [ + 'exec', 'print', # gone in Python 3 + ] # :nodoc: + + PREDEFINED_METHODS_AND_TYPES = %w[ + __import__ abs all any apply basestring bin bool buffer + bytearray bytes callable chr classmethod cmp coerce compile + complex delattr dict dir divmod enumerate eval execfile exit + file filter float frozenset getattr globals hasattr hash hex id + input int intern isinstance issubclass iter len list locals + long map max min next object oct open ord pow property range + raw_input reduce reload repr reversed round set setattr slice + sorted staticmethod str sum super tuple type unichr unicode + vars xrange zip + ] # :nodoc: + + PREDEFINED_EXCEPTIONS = %w[ + ArithmeticError AssertionError AttributeError + BaseException DeprecationWarning EOFError EnvironmentError + Exception FloatingPointError FutureWarning GeneratorExit IOError + ImportError ImportWarning IndentationError IndexError KeyError + KeyboardInterrupt LookupError MemoryError NameError + NotImplemented NotImplementedError OSError OverflowError + OverflowWarning PendingDeprecationWarning ReferenceError + RuntimeError RuntimeWarning StandardError StopIteration + SyntaxError SyntaxWarning SystemError SystemExit TabError + TypeError UnboundLocalError UnicodeDecodeError + UnicodeEncodeError UnicodeError UnicodeTranslateError + UnicodeWarning UserWarning ValueError Warning ZeroDivisionError + ] # :nodoc: + + PREDEFINED_VARIABLES_AND_CONSTANTS = [ + 'False', 'True', 'None', # "keywords" since Python 3 + 'self', 'Ellipsis', 'NotImplemented', + ] # :nodoc: + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(OLD_KEYWORDS, :old_keyword). + add(PREDEFINED_METHODS_AND_TYPES, :predefined). + add(PREDEFINED_VARIABLES_AND_CONSTANTS, :predefined_constant). + add(PREDEFINED_EXCEPTIONS, :exception) # :nodoc: + + NAME = / [[:alpha:]_] \w* /x # :nodoc: + ESCAPE = / [abfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} | N\{[-\w ]+\} /x # :nodoc: + + OPERATOR = / + \.\.\. | # ellipsis + \.(?!\d) | # dot but not decimal point + [,;:()\[\]{}] | # simple delimiters + \/\/=? | \*\*=? | # special math + [-+*\/%&|^]=? | # ordinary math and binary logic + [~`] | # binary complement and inspection + <<=? | >>=? | [<>=]=? | != # comparison and assignment + /x # :nodoc: + + STRING_DELIMITER_REGEXP = Hash.new { |h, delimiter| + h[delimiter] = Regexp.union delimiter # :nodoc: + } + + STRING_CONTENT_REGEXP = Hash.new { |h, delimiter| + h[delimiter] = / [^\\\n]+? (?= \\ | $ | #{Regexp.escape(delimiter)} ) /x # :nodoc: + } + + DEF_NEW_STATE = WordList.new(:initial). + add(%w(def), :def_expected). + add(%w(import from), :include_expected). + add(%w(class), :class_expected) # :nodoc: + + DESCRIPTOR = / + #{NAME} + (?: \. #{NAME} )* + | \* + /x # :nodoc: + + DOCSTRING_COMING = / + [ \t]* u?r? ("""|''') + /x # :nodoc: + + protected + + def scan_tokens encoder, options + + state = :initial + string_delimiter = nil + string_raw = false + string_type = nil + docstring_coming = match?(/#{DOCSTRING_COMING}/o) + last_token_dot = false + unicode = string.respond_to?(:encoding) && string.encoding.name == 'UTF-8' + from_import_state = [] + + until eos? + + if state == :string + if match = scan(STRING_DELIMITER_REGEXP[string_delimiter]) + encoder.text_token match, :delimiter + encoder.end_group string_type + string_type = nil + state = :initial + next + elsif string_delimiter.size == 3 && match = scan(/\n/) + encoder.text_token match, :content + elsif match = scan(STRING_CONTENT_REGEXP[string_delimiter]) + encoder.text_token match, :content + elsif !string_raw && match = scan(/ \\ #{ESCAPE} /ox) + encoder.text_token match, :char + elsif match = scan(/ \\ #{UNICODE_ESCAPE} /ox) + encoder.text_token match, :char + elsif match = scan(/ \\ . /x) + encoder.text_token match, :content + elsif match = scan(/ \\ | $ /x) + encoder.end_group string_type + string_type = nil + encoder.text_token match, :error unless match.empty? + state = :initial + else + raise_inspect "else case \" reached; %p not handled." % peek(1), encoder, state + end + + elsif match = scan(/ [ \t]+ | \\?\n /x) + encoder.text_token match, :space + if match == "\n" + state = :initial if state == :include_expected + docstring_coming = true if match?(/#{DOCSTRING_COMING}/o) + end + next + + elsif match = scan(/ \# [^\n]* /mx) + encoder.text_token match, :comment + next + + elsif state == :initial + + if match = scan(/#{OPERATOR}/o) + encoder.text_token match, :operator + + elsif match = scan(/(u?r?|b)?("""|"|'''|')/i) + modifiers = self[1] + string_delimiter = self[2] + string_type = docstring_coming ? :docstring : (modifiers == 'b' ? :binary : :string) + docstring_coming = false if docstring_coming + encoder.begin_group string_type + string_raw = false + unless modifiers.empty? + string_raw = !!modifiers.index(?r) + encoder.text_token modifiers, :modifier + match = string_delimiter + end + state = :string + encoder.text_token match, :delimiter + + # TODO: backticks + + elsif match = scan(unicode ? /#{NAME}/uo : /#{NAME}/o) + kind = IDENT_KIND[match] + # TODO: keyword arguments + kind = :ident if last_token_dot + if kind == :old_keyword + kind = check(/\(/) ? :ident : :keyword + elsif kind == :predefined && check(/ *=/) + kind = :ident + elsif kind == :keyword + state = DEF_NEW_STATE[match] + from_import_state << match.to_sym if state == :include_expected + end + encoder.text_token match, kind + + elsif match = scan(/@[a-zA-Z0-9_.]+[lL]?/) + encoder.text_token match, :decorator + + elsif match = scan(/0[xX][0-9A-Fa-f]+[lL]?/) + encoder.text_token match, :hex + + elsif match = scan(/0[bB][01]+[lL]?/) + encoder.text_token match, :binary + + elsif match = scan(/(?:\d*\.\d+|\d+\.\d*)(?:[eE][+-]?\d+)?|\d+[eE][+-]?\d+/) + if scan(/[jJ]/) + match << matched + encoder.text_token match, :imaginary + else + encoder.text_token match, :float + end + + elsif match = scan(/0[oO][0-7]+|0[0-7]+(?![89.eE])[lL]?/) + encoder.text_token match, :octal + + elsif match = scan(/\d+([lL])?/) + if self[1] == nil && scan(/[jJ]/) + match << matched + encoder.text_token match, :imaginary + else + encoder.text_token match, :integer + end + + else + encoder.text_token getch, :error + + end + + elsif state == :def_expected + state = :initial + if match = scan(unicode ? /#{NAME}/uo : /#{NAME}/o) + encoder.text_token match, :method + else + next + end + + elsif state == :class_expected + state = :initial + if match = scan(unicode ? /#{NAME}/uo : /#{NAME}/o) + encoder.text_token match, :class + else + next + end + + elsif state == :include_expected + if match = scan(unicode ? /#{DESCRIPTOR}/uo : /#{DESCRIPTOR}/o) + if match == 'as' + encoder.text_token match, :keyword + from_import_state << :as + elsif from_import_state.first == :from && match == 'import' + encoder.text_token match, :keyword + from_import_state << :import + elsif from_import_state.last == :as + # encoder.text_token match, match[0,1][unicode ? /[[:upper:]]/u : /[[:upper:]]/] ? :class : :method + encoder.text_token match, :ident + from_import_state.pop + elsif IDENT_KIND[match] == :keyword + unscan + match = nil + state = :initial + next + else + encoder.text_token match, :include + end + elsif match = scan(/,/) + from_import_state.pop if from_import_state.last == :as + encoder.text_token match, :operator + else + from_import_state = [] + state = :initial + next + end + + else + raise_inspect 'Unknown state', encoder, state + + end + + last_token_dot = match == '.' + + end + + if state == :string + encoder.end_group string_type + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/raydebug.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/raydebug.rb new file mode 100644 index 000000000..1effdc851 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/raydebug.rb @@ -0,0 +1,75 @@ +require 'set' + +module CodeRay +module Scanners + + # = Raydebug Scanner + # + # Highlights the output of the Encoders::Debug encoder. + class Raydebug < Scanner + + register_for :raydebug + file_extension 'raydebug' + title 'CodeRay Token Dump' + + protected + + def setup + super + @known_token_kinds = TokenKinds.keys.map(&:to_s).to_set + end + + def scan_tokens encoder, options + + opened_tokens = [] + + until eos? + + if match = scan(/\s+/) + encoder.text_token match, :space + + elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) /x) + kind = self[1] + encoder.text_token kind, :class + encoder.text_token '(', :operator + match = self[2] + unless match.empty? + if @known_token_kinds.include? kind + encoder.text_token match, kind.to_sym + else + encoder.text_token match, :plain + end + end + encoder.text_token match, :operator if match = scan(/\)/) + + elsif match = scan(/ (\w+) ([<\[]) /x) + encoder.text_token self[1], :class + if @known_token_kinds.include? self[1] + kind = self[1].to_sym + else + kind = :unknown + end + opened_tokens << kind + encoder.begin_group kind + encoder.text_token self[2], :operator + + elsif !opened_tokens.empty? && match = scan(/ [>\]] /x) + encoder.text_token match, :operator + encoder.end_group opened_tokens.pop + + else + encoder.text_token getch, :space + + end + + end + + encoder.end_group opened_tokens.pop until opened_tokens.empty? + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby.rb new file mode 100644 index 000000000..80165cae7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby.rb @@ -0,0 +1,470 @@ +module CodeRay +module Scanners + + # This scanner is really complex, since Ruby _is_ a complex language! + # + # It tries to highlight 100% of all common code, + # and 90% of strange codes. + # + # It is optimized for HTML highlighting, and is not very useful for + # parsing or pretty printing. + class Ruby < Scanner + + register_for :ruby + file_extension 'rb' + + autoload :Patterns, CodeRay.coderay_path('scanners', 'ruby', 'patterns') + autoload :StringState, CodeRay.coderay_path('scanners', 'ruby', 'string_state') + + def interpreted_string_state + StringState.new :string, true, '"' + end + + protected + + def setup + @state = :initial + end + + def scan_tokens encoder, options + state, heredocs = options[:state] || @state + heredocs = heredocs.dup if heredocs.is_a?(Array) + + if state && state.instance_of?(StringState) + encoder.begin_group state.type + end + + last_state = nil + + method_call_expected = false + value_expected = true + + inline_block_stack = nil + inline_block_curly_depth = 0 + + if heredocs + state = heredocs.shift + encoder.begin_group state.type + heredocs = nil if heredocs.empty? + end + + # def_object_stack = nil + # def_object_paren_depth = 0 + + patterns = Patterns # avoid constant lookup + + unicode = string.respond_to?(:encoding) && string.encoding.name == 'UTF-8' + + until eos? + + if state.instance_of? ::Symbol + + if match = scan(/[ \t\f\v]+/) + encoder.text_token match, :space + + elsif match = scan(/\n/) + if heredocs + unscan # heredoc scanning needs \n at start + state = heredocs.shift + encoder.begin_group state.type + heredocs = nil if heredocs.empty? + else + state = :initial if state == :undef_comma_expected + encoder.text_token match, :space + value_expected = true + end + + elsif match = scan(bol? ? / \#(!)?.* | #{patterns::RUBYDOC_OR_DATA} /ox : /\#.*/) + encoder.text_token match, self[1] ? :doctype : :comment + + elsif match = scan(/\\\n/) + if heredocs + unscan # heredoc scanning needs \n at start + encoder.text_token scan(/\\/), :space + state = heredocs.shift + encoder.begin_group state.type + heredocs = nil if heredocs.empty? + else + encoder.text_token match, :space + end + + elsif state == :initial + + # IDENTS # + if !method_call_expected && + match = scan(unicode ? /#{patterns::METHOD_NAME}/uo : + /#{patterns::METHOD_NAME}/o) + + kind = patterns::IDENT_KIND[match] + if value_expected != :colon_expected && scan(/:(?!:)/) + value_expected = true + encoder.text_token match, :key + encoder.text_token ':', :operator + else + value_expected = false + if kind == :ident + if match[/\A[A-Z]/] && !(match[/[!?]$/] || match?(/\(/)) + kind = :constant + end + elsif kind == :keyword + state = patterns::KEYWORD_NEW_STATE[match] + if patterns::KEYWORDS_EXPECTING_VALUE[match] + value_expected = match == 'when' ? :colon_expected : true + end + end + value_expected = true if !value_expected && check(/#{patterns::VALUE_FOLLOWS}/o) + encoder.text_token match, kind + end + + elsif method_call_expected && + match = scan(unicode ? /#{patterns::METHOD_AFTER_DOT}/uo : + /#{patterns::METHOD_AFTER_DOT}/o) + if method_call_expected == '::' && match[/\A[A-Z]/] && !match?(/\(/) + encoder.text_token match, :constant + else + encoder.text_token match, :ident + end + method_call_expected = false + value_expected = check(/#{patterns::VALUE_FOLLOWS}/o) + + # OPERATORS # + elsif !method_call_expected && match = scan(/ (\.(?!\.)|::) | ( \.\.\.? | ==?=? | [,\(\[\{] ) | [\)\]\}] /x) + method_call_expected = self[1] + value_expected = !method_call_expected && !!self[2] + if inline_block_stack + case match + when '{' + inline_block_curly_depth += 1 + when '}' + inline_block_curly_depth -= 1 + if inline_block_curly_depth == 0 # closing brace of inline block reached + state, inline_block_curly_depth, heredocs = inline_block_stack.pop + inline_block_stack = nil if inline_block_stack.empty? + heredocs = nil if heredocs && heredocs.empty? + encoder.text_token match, :inline_delimiter + encoder.end_group :inline + next + end + end + end + encoder.text_token match, :operator + + elsif match = scan(unicode ? /#{patterns::SYMBOL}/uo : + /#{patterns::SYMBOL}/o) + case delim = match[1] + when ?', ?" + encoder.begin_group :symbol + encoder.text_token ':', :symbol + match = delim.chr + encoder.text_token match, :delimiter + state = self.class::StringState.new :symbol, delim == ?", match + else + encoder.text_token match, :symbol + value_expected = false + end + + elsif match = scan(/ ' (?:(?>[^'\\]*) ')? | " (?:(?>[^"\\\#]*) ")? /mx) + encoder.begin_group :string + if match.size == 1 + encoder.text_token match, :delimiter + state = self.class::StringState.new :string, match == '"', match # important for streaming + else + encoder.text_token match[0,1], :delimiter + encoder.text_token match[1..-2], :content if match.size > 2 + encoder.text_token match[-1,1], :delimiter + encoder.end_group :string + value_expected = false + end + + elsif match = scan(unicode ? /#{patterns::INSTANCE_VARIABLE}/uo : + /#{patterns::INSTANCE_VARIABLE}/o) + value_expected = false + encoder.text_token match, :instance_variable + + elsif value_expected && match = scan(/\//) + encoder.begin_group :regexp + encoder.text_token match, :delimiter + state = self.class::StringState.new :regexp, true, '/' + + elsif match = scan(value_expected ? /[-+]?#{patterns::NUMERIC}/o : /#{patterns::NUMERIC}/o) + if method_call_expected + encoder.text_token match, :error + method_call_expected = false + else + encoder.text_token match, self[1] ? :float : :integer # TODO: send :hex/:octal/:binary + end + value_expected = false + + elsif match = scan(/ [-+!~^\/]=? | [:;] | [*|&]{1,2}=? | >>? /x) + value_expected = true + encoder.text_token match, :operator + + elsif value_expected && match = scan(/#{patterns::HEREDOC_OPEN}/o) + quote = self[3] + delim = self[quote ? 4 : 2] + kind = patterns::QUOTE_TO_TYPE[quote] + encoder.begin_group kind + encoder.text_token match, :delimiter + encoder.end_group kind + heredocs ||= [] # create heredocs if empty + heredocs << self.class::StringState.new(kind, quote != "'", delim, + self[1] == '-' ? :indented : :linestart) + value_expected = false + + elsif value_expected && match = scan(/#{patterns::FANCY_STRING_START}/o) + kind = patterns::FANCY_STRING_KIND[self[1]] + encoder.begin_group kind + state = self.class::StringState.new kind, patterns::FANCY_STRING_INTERPRETED[self[1]], self[2] + encoder.text_token match, :delimiter + + elsif value_expected && match = scan(/#{patterns::CHARACTER}/o) + value_expected = false + encoder.text_token match, :integer + + elsif match = scan(/ %=? | <(?:<|=>?)? | \? /x) + value_expected = match == '?' ? :colon_expected : true + encoder.text_token match, :operator + + elsif match = scan(/`/) + encoder.begin_group :shell + encoder.text_token match, :delimiter + state = self.class::StringState.new :shell, true, match + + elsif match = scan(unicode ? /#{patterns::GLOBAL_VARIABLE}/uo : + /#{patterns::GLOBAL_VARIABLE}/o) + encoder.text_token match, :global_variable + value_expected = false + + elsif match = scan(unicode ? /#{patterns::CLASS_VARIABLE}/uo : + /#{patterns::CLASS_VARIABLE}/o) + encoder.text_token match, :class_variable + value_expected = false + + elsif match = scan(/\\\z/) + encoder.text_token match, :space + + else + if method_call_expected + method_call_expected = false + next + end + unless unicode + # check for unicode + $DEBUG_BEFORE, $DEBUG = $DEBUG, false + begin + if check(/./mu).size > 1 + # seems like we should try again with unicode + unicode = true + end + rescue + # bad unicode char; use getch + ensure + $DEBUG = $DEBUG_BEFORE + end + next if unicode + end + + encoder.text_token getch, :error + + end + + if last_state + state = last_state unless state.is_a?(StringState) # otherwise, a simple 'def"' results in unclosed tokens + last_state = nil + end + + elsif state == :def_expected + if match = scan(unicode ? /(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/uo : + /(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/o) + encoder.text_token match, :method + state = :initial + else + last_state = :dot_expected + state = :initial + end + + elsif state == :dot_expected + if match = scan(/\.|::/) + # invalid definition + state = :def_expected + encoder.text_token match, :operator + else + state = :initial + end + + elsif state == :module_expected + if match = scan(/<#{patterns::METHOD_NAME_EX})(?!\.|::)/uo : + /(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/o) + encoder.text_token match, :method + elsif match = scan(/#{patterns::SYMBOL}/o) + case delim = match[1] + when ?', ?" + encoder.begin_group :symbol + encoder.text_token ':', :symbol + match = delim.chr + encoder.text_token match, :delimiter + state = self.class::StringState.new :symbol, delim == ?", match + state.next_state = :undef_comma_expected + else + encoder.text_token match, :symbol + end + else + state = :initial + end + + elsif state == :undef_comma_expected + if match = scan(/,/) + encoder.text_token match, :operator + state = :undef_expected + else + state = :initial + end + + elsif state == :alias_expected + match = scan(unicode ? /(#{patterns::METHOD_NAME_OR_SYMBOL})([ \t]+)(#{patterns::METHOD_NAME_OR_SYMBOL})/uo : + /(#{patterns::METHOD_NAME_OR_SYMBOL})([ \t]+)(#{patterns::METHOD_NAME_OR_SYMBOL})/o) + + if match + encoder.text_token self[1], (self[1][0] == ?: ? :symbol : :method) + encoder.text_token self[2], :space + encoder.text_token self[3], (self[3][0] == ?: ? :symbol : :method) + end + state = :initial + + else + #:nocov: + raise_inspect 'Unknown state: %p' % [state], encoder + #:nocov: + end + + else # StringState + + match = scan_until(state.pattern) || scan_rest + unless match.empty? + encoder.text_token match, :content + break if eos? + end + + if state.heredoc && self[1] # end of heredoc + match = getch + match << scan_until(/$/) unless eos? + encoder.text_token match, :delimiter unless match.empty? + encoder.end_group state.type + state = state.next_state + next + end + + case match = getch + + when state.delim + if state.paren_depth + state.paren_depth -= 1 + if state.paren_depth > 0 + encoder.text_token match, :content + next + end + end + encoder.text_token match, :delimiter + if state.type == :regexp && !eos? + match = scan(/#{patterns::REGEXP_MODIFIERS}/o) + encoder.text_token match, :modifier unless match.empty? + end + encoder.end_group state.type + value_expected = false + state = state.next_state + + when '\\' + if state.interpreted + if esc = scan(/#{patterns::ESCAPE}/o) + encoder.text_token match + esc, :char + else + encoder.text_token match, :error + end + else + case esc = getch + when nil + encoder.text_token match, :content + when state.delim, '\\' + encoder.text_token match + esc, :char + else + encoder.text_token match + esc, :content + end + end + + when '#' + case peek(1) + when '{' + inline_block_stack ||= [] + inline_block_stack << [state, inline_block_curly_depth, heredocs] + value_expected = true + state = :initial + inline_block_curly_depth = 1 + encoder.begin_group :inline + encoder.text_token match + getch, :inline_delimiter + when '$', '@' + encoder.text_token match, :escape + last_state = state + state = :initial + else + #:nocov: + raise_inspect 'else-case # reached; #%p not handled' % [peek(1)], encoder + #:nocov: + end + + when state.opening_paren + state.paren_depth += 1 + encoder.text_token match, :content + + else + #:nocov + raise_inspect 'else-case " reached; %p not handled, state = %p' % [match, state], encoder + #:nocov: + + end + + end + + end + + # cleaning up + if state.is_a? StringState + encoder.end_group state.type + end + + if options[:keep_state] + if state.is_a?(StringState) && state.heredoc + (heredocs ||= []).unshift state + state = :initial + elsif heredocs && heredocs.empty? + heredocs = nil + end + @state = state, heredocs + end + + if inline_block_stack + until inline_block_stack.empty? + state, = *inline_block_stack.pop + encoder.end_group :inline + encoder.end_group state.type + end + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/patterns.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/patterns.rb new file mode 100644 index 000000000..0b36e13bd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/patterns.rb @@ -0,0 +1,178 @@ +# encoding: utf-8 +module CodeRay +module Scanners + + module Ruby::Patterns # :nodoc: all + + KEYWORDS = %w[ + and def end in or unless begin + defined? ensure module redo super until + BEGIN break do next rescue then + when END case else for retry + while alias class elsif if not return + undef yield + ] + + # See http://murfy.de/ruby-constants. + PREDEFINED_CONSTANTS = %w[ + nil true false self + DATA ARGV ARGF ENV + FALSE TRUE NIL + STDERR STDIN STDOUT + TOPLEVEL_BINDING + RUBY_COPYRIGHT RUBY_DESCRIPTION RUBY_ENGINE RUBY_PATCHLEVEL + RUBY_PLATFORM RUBY_RELEASE_DATE RUBY_REVISION RUBY_VERSION + __FILE__ __LINE__ __ENCODING__ + ] + + IDENT_KIND = WordList.new(:ident). + add(KEYWORDS, :keyword). + add(PREDEFINED_CONSTANTS, :predefined_constant) + + KEYWORD_NEW_STATE = WordList.new(:initial). + add(%w[ def ], :def_expected). + add(%w[ undef ], :undef_expected). + add(%w[ alias ], :alias_expected). + add(%w[ class module ], :module_expected) + + IDENT = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : /[^\W\d]\w*/ + + METHOD_NAME = / #{IDENT} [?!]? /ox + METHOD_NAME_OPERATOR = / + \*\*? # multiplication and power + | [-+~]@? # plus, minus, tilde with and without at sign + | [\/%&|^`] # division, modulo or format strings, and, or, xor, system + | \[\]=? # array getter and setter + | << | >> # append or shift left, shift right + | <=?>? | >=? # comparison, rocket operator + | ===? | =~ # simple equality, case equality, match + | ![~=@]? # negation with and without at sign, not-equal and not-match + /ox + METHOD_SUFFIX = / (?: [?!] | = (?![~>]|=(?!>)) ) /x + METHOD_NAME_EX = / #{IDENT} #{METHOD_SUFFIX}? | #{METHOD_NAME_OPERATOR} /ox + METHOD_AFTER_DOT = / #{IDENT} [?!]? | #{METHOD_NAME_OPERATOR} /ox + INSTANCE_VARIABLE = / @ #{IDENT} /ox + CLASS_VARIABLE = / @@ #{IDENT} /ox + OBJECT_VARIABLE = / @@? #{IDENT} /ox + GLOBAL_VARIABLE = / \$ (?: #{IDENT} | [1-9]\d* | 0\w* | [~&+`'=\/,;_.<>!@$?*":\\] | -[a-zA-Z_0-9] ) /ox + PREFIX_VARIABLE = / #{GLOBAL_VARIABLE} | #{OBJECT_VARIABLE} /ox + VARIABLE = / @?@? #{IDENT} | #{GLOBAL_VARIABLE} /ox + + QUOTE_TO_TYPE = { + '`' => :shell, + '/'=> :regexp, + } + QUOTE_TO_TYPE.default = :string + + REGEXP_MODIFIERS = /[mousenix]*/ + + DECIMAL = /\d+(?:_\d+)*/ + OCTAL = /0_?[0-7]+(?:_[0-7]+)*/ + HEXADECIMAL = /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/ + BINARY = /0b[01]+(?:_[01]+)*/ + + EXPONENT = / [eE] [+-]? #{DECIMAL} /ox + FLOAT_SUFFIX = / #{EXPONENT} | \. #{DECIMAL} #{EXPONENT}? /ox + FLOAT_OR_INT = / #{DECIMAL} (?: #{FLOAT_SUFFIX} () )? /ox + NUMERIC = / (?: (?=0) (?: #{OCTAL} | #{HEXADECIMAL} | #{BINARY} ) | #{FLOAT_OR_INT} ) /ox + + SYMBOL = / + : + (?: + #{METHOD_NAME_EX} + | #{PREFIX_VARIABLE} + | ['"] + ) + /ox + METHOD_NAME_OR_SYMBOL = / #{METHOD_NAME_EX} | #{SYMBOL} /ox + + SIMPLE_ESCAPE = / + [abefnrstv] + | [0-7]{1,3} + | x[0-9A-Fa-f]{1,2} + | . + /mx + + CONTROL_META_ESCAPE = / + (?: M-|C-|c ) + (?: \\ (?: M-|C-|c ) )* + (?: [^\\] | \\ #{SIMPLE_ESCAPE} )? + /mox + + ESCAPE = / + #{CONTROL_META_ESCAPE} | #{SIMPLE_ESCAPE} + /mox + + CHARACTER = / + \? + (?: + [^\s\\] + | \\ #{ESCAPE} + ) + /mox + + # NOTE: This is not completely correct, but + # nobody needs heredoc delimiters ending with \n. + HEREDOC_OPEN = / + << (-)? # $1 = float + (?: + ( [A-Za-z_0-9]+ ) # $2 = delim + | + ( ["'`\/] ) # $3 = quote, type + ( [^\n]*? ) \3 # $4 = delim + ) + /mx + + RUBYDOC = / + =begin (?!\S) + .*? + (?: \Z | ^=end (?!\S) [^\n]* ) + /mx + + DATA = / + __END__$ + .*? + (?: \Z | (?=^\#CODE) ) + /mx + + RUBYDOC_OR_DATA = / #{RUBYDOC} | #{DATA} /xo + + # Checks for a valid value to follow. This enables + # value_expected in method calls without parentheses. + VALUE_FOLLOWS = / + (?>[ \t\f\v]+) + (?: + [%\/][^\s=] + | <<-?\S + | [-+] \d + | #{CHARACTER} + ) + /ox + KEYWORDS_EXPECTING_VALUE = WordList.new.add(%w[ + and end in or unless begin + defined? ensure redo super until + break do next rescue then + when case else for retry + while elsif if not return + yield + ]) + + FANCY_STRING_START = / % ( [iIqQrswWx] | (?![a-zA-Z0-9]) ) ([^a-zA-Z0-9]) /x + FANCY_STRING_KIND = Hash.new(:string).merge({ + 'i' => :symbol, + 'I' => :symbol, + 'r' => :regexp, + 's' => :symbol, + 'x' => :shell, + }) + FANCY_STRING_INTERPRETED = Hash.new(true).merge({ + 'i' => false, + 'q' => false, + 's' => false, + 'w' => false, + }) + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/string_state.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/string_state.rb new file mode 100644 index 000000000..28ddd6c64 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/ruby/string_state.rb @@ -0,0 +1,71 @@ +# encoding: utf-8 +module CodeRay +module Scanners + + class Ruby + + class StringState < Struct.new :type, :interpreted, :delim, :heredoc, + :opening_paren, :paren_depth, :pattern, :next_state # :nodoc: all + + CLOSING_PAREN = Hash[ *%w[ + ( ) + [ ] + < > + { } + ] ].each { |k,v| k.freeze; v.freeze } # debug, if I try to change it with << + + STRING_PATTERN = Hash.new do |h, k| + delim, interpreted = *k + delim_pattern = Regexp.escape(delim) + if closing_paren = CLOSING_PAREN[delim] + delim_pattern << Regexp.escape(closing_paren) + end + delim_pattern << '\\\\' unless delim == '\\' + + # special_escapes = + # case interpreted + # when :regexp_symbols + # '| [|?*+(){}\[\].^$]' + # end + + if interpreted && delim != '#' + / (?= [#{delim_pattern}] | \# [{$@] ) /mx + else + / (?= [#{delim_pattern}] ) /mx + end.tap do |pattern| + h[k] = pattern if (delim.respond_to?(:ord) ? delim.ord : delim[0]) < 256 + end + end + + def initialize kind, interpreted, delim, heredoc = false + if heredoc + pattern = heredoc_pattern delim, interpreted, heredoc == :indented + delim = nil + else + pattern = STRING_PATTERN[ [delim, interpreted] ] + if closing_paren = CLOSING_PAREN[delim] + opening_paren = delim + delim = closing_paren + paren_depth = 1 + end + end + super kind, interpreted, delim, heredoc, opening_paren, paren_depth, pattern, :initial + end + + def heredoc_pattern delim, interpreted, indented + # delim = delim.dup # workaround for old Ruby + delim_pattern = Regexp.escape(delim) + delim_pattern = / (?:\A|\n) #{ '(?>[ \t]*)' if indented } #{ Regexp.new delim_pattern } $ /x + if interpreted + / (?= #{delim_pattern}() | \\ | \# [{$@] ) /mx # $1 set == end of heredoc + else + / (?= #{delim_pattern}() | \\ ) /mx + end + end + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sass.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sass.rb new file mode 100644 index 000000000..e3296b90e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sass.rb @@ -0,0 +1,232 @@ +module CodeRay +module Scanners + + # A scanner for Sass. + class Sass < CSS + + register_for :sass + file_extension 'sass' + + protected + + def setup + @state = :initial + end + + def scan_tokens encoder, options + states = Array(options[:state] || @state).dup + + encoder.begin_group :string if states.last == :sqstring || states.last == :dqstring + + until eos? + + if bol? && (match = scan(/(?>( +)?(\/[\*\/])(.+)?)(?=\n)/)) + encoder.text_token self[1], :space if self[1] + encoder.begin_group :comment + encoder.text_token self[2], :delimiter + encoder.text_token self[3], :content if self[3] + if match = scan(/(?:\n+#{self[1]} .*)+/) + encoder.text_token match, :content + end + encoder.end_group :comment + elsif match = scan(/\n|[^\n\S]+\n?/) + encoder.text_token match, :space + if match.index(/\n/) + value_expected = false + states.pop if states.last == :include + end + + elsif states.last == :sass_inline && (match = scan(/\}/)) + encoder.text_token match, :inline_delimiter + encoder.end_group :inline + states.pop + + elsif case states.last + when :initial, :media, :sass_inline + if match = scan(/(?>#{RE::Ident})(?!\()/ox) + encoder.text_token match, value_expected ? :value : (check(/.*:(?![a-z])/) ? :key : :tag) + next + elsif !value_expected && (match = scan(/\*/)) + encoder.text_token match, :tag + next + elsif match = scan(RE::Class) + encoder.text_token match, :class + next + elsif match = scan(RE::Id) + encoder.text_token match, :id + next + elsif match = scan(RE::PseudoClass) + encoder.text_token match, :pseudo_class + next + elsif match = scan(RE::AttributeSelector) + # TODO: Improve highlighting inside of attribute selectors. + encoder.text_token match[0,1], :operator + encoder.text_token match[1..-2], :attribute_name if match.size > 2 + encoder.text_token match[-1,1], :operator if match[-1] == ?] + next + elsif match = scan(/(\=|@mixin +)#{RE::Ident}/o) + encoder.text_token match, :function + next + elsif match = scan(/@import\b/) + encoder.text_token match, :directive + states << :include + next + elsif match = scan(/@media\b/) + encoder.text_token match, :directive + # states.push :media_before_name + next + end + + when :block + if match = scan(/(?>#{RE::Ident})(?!\()/ox) + if value_expected + encoder.text_token match, :value + else + encoder.text_token match, :key + end + next + end + + when :sqstring, :dqstring + if match = scan(states.last == :sqstring ? /(?:[^\n\'\#]+|\\\n|#{RE::Escape}|#(?!\{))+/o : /(?:[^\n\"\#]+|\\\n|#{RE::Escape}|#(?!\{))+/o) + encoder.text_token match, :content + elsif match = scan(/['"]/) + encoder.text_token match, :delimiter + encoder.end_group :string + states.pop + elsif match = scan(/#\{/) + encoder.begin_group :inline + encoder.text_token match, :inline_delimiter + states.push :sass_inline + elsif match = scan(/ \\ | $ /x) + encoder.end_group states.last + encoder.text_token match, :error unless match.empty? + states.pop + else + raise_inspect "else case #{states.last} reached; %p not handled." % peek(1), encoder + end + + when :include + if match = scan(/[^\s'",]+/) + encoder.text_token match, :include + next + end + + else + #:nocov: + raise_inspect 'Unknown state: %p' % [states.last], encoder + #:nocov: + + end + + elsif match = scan(/\$#{RE::Ident}/o) + encoder.text_token match, :variable + next + + elsif match = scan(/&/) + encoder.text_token match, :local_variable + + elsif match = scan(/\+#{RE::Ident}/o) + encoder.text_token match, :include + value_expected = true + + elsif match = scan(/\/\*(?:.*?\*\/|.*)|\/\/.*/) + encoder.text_token match, :comment + + elsif match = scan(/#\{/) + encoder.begin_group :inline + encoder.text_token match, :inline_delimiter + states.push :sass_inline + + elsif match = scan(/\{/) + value_expected = false + encoder.text_token match, :operator + states.push :block + + elsif match = scan(/\}/) + value_expected = false + encoder.text_token match, :operator + if states.last == :block || states.last == :media + states.pop + end + + elsif match = scan(/['"]/) + encoder.begin_group :string + encoder.text_token match, :delimiter + if states.include? :sass_inline + # no nesting, just scan the string until delimiter + content = scan_until(/(?=#{match}|\}|\z)/) + encoder.text_token content, :content unless content.empty? + encoder.text_token match, :delimiter if scan(/#{match}/) + encoder.end_group :string + else + states.push match == "'" ? :sqstring : :dqstring + end + + elsif match = scan(/#{RE::Function}/o) + encoder.begin_group :function + start = match[/^[-\w]+\(/] + encoder.text_token start, :delimiter + if match[-1] == ?) + encoder.text_token match[start.size..-2], :content + encoder.text_token ')', :delimiter + else + encoder.text_token match[start.size..-1], :content if start.size < match.size + end + encoder.end_group :function + + elsif match = scan(/[a-z][-a-z_]*(?=\()/o) + encoder.text_token match, :predefined + + elsif match = scan(/(?: #{RE::Dimension} | #{RE::Percentage} | #{RE::Num} )/ox) + encoder.text_token match, :float + + elsif match = scan(/#{RE::HexColor}/o) + encoder.text_token match, :color + + elsif match = scan(/! *(?:important|optional)/) + encoder.text_token match, :important + + elsif match = scan(/(?:rgb|hsl)a?\([^()\n]*\)?/) + encoder.text_token match, :color + + elsif match = scan(/@else if\b|#{RE::AtKeyword}/o) + encoder.text_token match, :directive + value_expected = true + + elsif match = scan(/ == | != | [-+*\/>~:;,.=()] /x) + if match == ':' + value_expected = true + elsif match == ';' + value_expected = false + end + encoder.text_token match, :operator + + else + encoder.text_token getch, :error + + end + + end + + states.pop if states.last == :include + + if options[:keep_state] + @state = states.dup + end + + while state = states.pop + if state == :sass_inline + encoder.end_group :inline + elsif state == :sqstring || state == :dqstring + encoder.end_group :string + end + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sql.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sql.rb new file mode 100644 index 000000000..93aeaf39e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/sql.rb @@ -0,0 +1,177 @@ +module CodeRay +module Scanners + + # by Josh Goebel + class SQL < Scanner + + register_for :sql + + KEYWORDS = %w( + all and any as before begin between by case check collate + each else end exists + for foreign from full group having if in inner is join + like not of on or order outer over references + then to union using values when where + left right distinct + ) + + OBJECTS = %w( + database databases table tables column columns fields index constraint + constraints transaction function procedure row key view trigger + ) + + COMMANDS = %w( + add alter comment create delete drop grant insert into select update set + show prompt begin commit rollback replace truncate + ) + + PREDEFINED_TYPES = %w( + char varchar varchar2 enum binary text tinytext mediumtext + longtext blob tinyblob mediumblob longblob timestamp + date time datetime year double decimal float int + integer tinyint mediumint bigint smallint unsigned bit + bool boolean hex bin oct + ) + + PREDEFINED_FUNCTIONS = %w( sum cast substring abs pi count min max avg now ) + + DIRECTIVES = %w( + auto_increment unique default charset initially deferred + deferrable cascade immediate read write asc desc after + primary foreign return engine + ) + + PREDEFINED_CONSTANTS = %w( null true false ) + + IDENT_KIND = WordList::CaseIgnoring.new(:ident). + add(KEYWORDS, :keyword). + add(OBJECTS, :type). + add(COMMANDS, :class). + add(PREDEFINED_TYPES, :predefined_type). + add(PREDEFINED_CONSTANTS, :predefined_constant). + add(PREDEFINED_FUNCTIONS, :predefined). + add(DIRECTIVES, :directive) + + ESCAPE = / [rbfntv\n\\\/'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} | . /mx + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x + + STRING_PREFIXES = /[xnb]|_\w+/i + + def scan_tokens encoder, options + + state = :initial + string_type = nil + string_content = '' + name_expected = false + + until eos? + + if state == :initial + + if match = scan(/ \s+ | \\\n /x) + encoder.text_token match, :space + + elsif match = scan(/(?:--\s?|#).*/) + encoder.text_token match, :comment + + elsif match = scan(%r( /\* (!)? (?: .*? \*/ | .* ) )mx) + encoder.text_token match, self[1] ? :directive : :comment + + elsif match = scan(/ [*\/=<>:;,!&^|()\[\]{}~%] | [-+\.](?!\d) /x) + name_expected = true if match == '.' && check(/[A-Za-z_]/) + encoder.text_token match, :operator + + elsif match = scan(/(#{STRING_PREFIXES})?([`"'])/o) + prefix = self[1] + string_type = self[2] + encoder.begin_group :string + encoder.text_token prefix, :modifier if prefix + match = string_type + state = :string + encoder.text_token match, :delimiter + + elsif match = scan(/ @? [A-Za-z_][A-Za-z_0-9]* /x) + encoder.text_token match, name_expected ? :ident : (match[0] == ?@ ? :variable : IDENT_KIND[match]) + name_expected = false + + elsif match = scan(/0[xX][0-9A-Fa-f]+/) + encoder.text_token match, :hex + + elsif match = scan(/0[0-7]+(?![89.eEfF])/) + encoder.text_token match, :octal + + elsif match = scan(/[-+]?(?>\d+)(?![.eEfF])/) + encoder.text_token match, :integer + + elsif match = scan(/[-+]?(?:\d[fF]|\d*\.\d+(?:[eE][+-]?\d+)?|\d+[eE][+-]?\d+)/) + encoder.text_token match, :float + + elsif match = scan(/\\N/) + encoder.text_token match, :predefined_constant + + else + encoder.text_token getch, :error + + end + + elsif state == :string + if match = scan(/[^\\"'`]+/) + string_content << match + next + elsif match = scan(/["'`]/) + if string_type == match + if peek(1) == string_type # doubling means escape + string_content << string_type << getch + next + end + unless string_content.empty? + encoder.text_token string_content, :content + string_content = '' + end + encoder.text_token match, :delimiter + encoder.end_group :string + state = :initial + string_type = nil + else + string_content << match + end + elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox) + unless string_content.empty? + encoder.text_token string_content, :content + string_content = '' + end + encoder.text_token match, :char + elsif match = scan(/ \\ . /mox) + string_content << match + next + elsif match = scan(/ \\ | $ /x) + unless string_content.empty? + encoder.text_token string_content, :content + string_content = '' + end + encoder.text_token match, :error unless match.empty? + encoder.end_group :string + state = :initial + else + raise "else case \" reached; %p not handled." % peek(1), encoder + end + + else + raise 'else-case reached', encoder + + end + + end + + if state == :string + encoder.end_group state + end + + encoder + + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/taskpaper.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/taskpaper.rb new file mode 100644 index 000000000..42670bcce --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/taskpaper.rb @@ -0,0 +1,36 @@ +module CodeRay +module Scanners + + class Taskpaper < Scanner + + register_for :taskpaper + file_extension 'taskpaper' + + protected + + def scan_tokens encoder, options + until eos? + if match = scan(/\S.*:.*$/) # project + encoder.text_token(match, :namespace) + elsif match = scan(/-.+@done.*/) # completed task + encoder.text_token(match, :done) + elsif match = scan(/-(?:[^@\n]+|@(?!due))*/) # task + encoder.text_token(match, :plain) + elsif match = scan(/@due.*/) # comment + encoder.text_token(match, :important) + elsif match = scan(/.+/) # comment + encoder.text_token(match, :comment) + elsif match = scan(/\s+/) # space + encoder.text_token(match, :space) + else # other + encoder.text_token getch, :error + end + end + + encoder + end + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/text.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/text.rb new file mode 100644 index 000000000..bde902978 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/text.rb @@ -0,0 +1,26 @@ +module CodeRay + module Scanners + + # Scanner for plain text. + # + # Yields just one token of the kind :plain. + # + # Alias: +plaintext+, +plain+ + class Text < Scanner + + register_for :text + title 'Plain text' + + KINDS_NOT_LOC = [:plain] # :nodoc: + + protected + + def scan_tokens encoder, options + encoder.text_token string, :plain + encoder + end + + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/xml.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/xml.rb new file mode 100644 index 000000000..947f16ee1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/xml.rb @@ -0,0 +1,17 @@ +module CodeRay +module Scanners + + load :html + + # Scanner for XML. + # + # Currently this is the same scanner as Scanners::HTML. + class XML < HTML + + register_for :xml + file_extension 'xml' + + end + +end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/yaml.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/yaml.rb new file mode 100644 index 000000000..32c8e2cb9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/scanners/yaml.rb @@ -0,0 +1,140 @@ +module CodeRay +module Scanners + + # Scanner for YAML. + # + # Based on the YAML scanner from Syntax by Jamis Buck. + class YAML < Scanner + + register_for :yaml + file_extension 'yml' + + KINDS_NOT_LOC = :all + + protected + + def scan_tokens encoder, options + + state = :initial + key_indent = string_indent = 0 + + until eos? + + key_indent = nil if bol? + + if match = scan(/ +[\t ]*/) + encoder.text_token match, :space + + elsif match = scan(/\n+/) + encoder.text_token match, :space + state = :initial if match.index(?\n) + + elsif match = scan(/#.*/) + encoder.text_token match, :comment + + elsif bol? and case + when match = scan(/---|\.\.\./) + encoder.begin_group :head + encoder.text_token match, :head + encoder.end_group :head + next + when match = scan(/%.*/) + encoder.text_token match, :doctype + next + end + + elsif state == :value and case + when !check(/(?:"[^"]*")(?=: |:$)/) && match = scan(/"/) + encoder.begin_group :string + encoder.text_token match, :delimiter + encoder.text_token match, :content if (match = scan(/ [^"\\]* (?: \\. [^"\\]* )* /mx)) && !match.empty? + encoder.text_token match, :delimiter if match = scan(/"/) + encoder.end_group :string + next + when match = scan(/[|>][-+]?/) + encoder.begin_group :string + encoder.text_token match, :delimiter + string_indent = key_indent || column(pos - match.size) - 1 + encoder.text_token matched, :content if scan(/(?:\n+ {#{string_indent + 1}}.*)+/) + encoder.end_group :string + next + when match = scan(/(?![!"*&]).+?(?=$|\s+#)/) + encoder.begin_group :string + encoder.text_token match, :content + string_indent = key_indent || column(pos - match.size) - 1 + encoder.text_token matched, :content if scan(/(?:\n+ {#{string_indent + 1}}.*)+/) + encoder.end_group :string + next + end + + elsif case + when match = scan(/[-:](?= |$)/) + state = :value if state == :colon && (match == ':' || match == '-') + state = :value if state == :initial && match == '-' + encoder.text_token match, :operator + next + when match = scan(/[,{}\[\]]/) + encoder.text_token match, :operator + next + when state == :initial && match = scan(/[-\w.()\/ ]*\S(?= *:(?: |$))/) + encoder.text_token match, :key + key_indent = column(pos - match.size) - 1 + state = :colon + next + when match = scan(/(?:"[^"\n]*"|'[^'\n]*')(?= *:(?: |$))/) + encoder.begin_group :key + encoder.text_token match[0,1], :delimiter + encoder.text_token match[1..-2], :content if match.size > 2 + encoder.text_token match[-1,1], :delimiter + encoder.end_group :key + key_indent = column(pos - match.size) - 1 + state = :colon + next + when match = scan(/(![\w\/]+)(:([\w:]+))?/) + encoder.text_token self[1], :type + if self[2] + encoder.text_token ':', :operator + encoder.text_token self[3], :class + end + next + when match = scan(/&\S+/) + encoder.text_token match, :variable + next + when match = scan(/\*\w+/) + encoder.text_token match, :global_variable + next + when match = scan(/< 'debug', # highlight for debugging (white on blue background) + + :annotation => 'annotation', # Groovy, Java + :attribute_name => 'attribute-name', # HTML, CSS + :attribute_value => 'attribute-value', # HTML + :binary => 'binary', # Python, Ruby + :char => 'char', # most scanners, also inside of strings + :class => 'class', # lots of scanners, for different purposes also in CSS + :class_variable => 'class-variable', # Ruby, YAML + :color => 'color', # CSS + :comment => 'comment', # most scanners + :constant => 'constant', # PHP, Ruby + :content => 'content', # inside of strings, most scanners + :decorator => 'decorator', # Python + :definition => 'definition', # CSS + :delimiter => 'delimiter', # inside strings, comments and other types + :directive => 'directive', # lots of scanners + :doctype => 'doctype', # Goorvy, HTML, Ruby, YAML + :docstring => 'docstring', # Python + :done => 'done', # Taskpaper + :entity => 'entity', # HTML + :error => 'error', # invalid token, most scanners + :escape => 'escape', # Ruby (string inline variables like #$foo, #@bar) + :exception => 'exception', # Java, PHP, Python + :filename => 'filename', # Diff + :float => 'float', # most scanners + :function => 'function', # CSS, JavaScript, PHP + :global_variable => 'global-variable', # Ruby, YAML + :hex => 'hex', # hexadecimal number; lots of scanners + :id => 'id', # CSS + :imaginary => 'imaginary', # Python + :important => 'important', # CSS, Taskpaper + :include => 'include', # C, Groovy, Java, Python, Sass + :inline => 'inline', # nested code, eg. inline string evaluation; lots of scanners + :inline_delimiter => 'inline-delimiter', # used instead of :inline > :delimiter FIXME: Why use inline_delimiter? + :instance_variable => 'instance-variable', # Ruby + :integer => 'integer', # most scanners + :key => 'key', # lots of scanners, used together with :value + :keyword => 'keyword', # reserved word that's actually implemented; most scanners + :label => 'label', # C, PHP + :local_variable => 'local-variable', # local and magic variables; some scanners + :map => 'map', # Lua tables + :modifier => 'modifier', # used inside on strings; lots of scanners + :namespace => 'namespace', # Clojure, Java, Taskpaper + :octal => 'octal', # lots of scanners + :predefined => 'predefined', # predefined function: lots of scanners + :predefined_constant => 'predefined-constant',# lots of scanners + :predefined_type => 'predefined-type', # C, Java, PHP + :preprocessor => 'preprocessor', # C, Delphi, HTML + :pseudo_class => 'pseudo-class', # CSS + :regexp => 'regexp', # Groovy, JavaScript, Ruby + :reserved => 'reserved', # most scanners + :shell => 'shell', # Ruby + :string => 'string', # most scanners + :symbol => 'symbol', # Clojure, Ruby, YAML + :tag => 'tag', # CSS, HTML + :type => 'type', # CSS, Java, SQL, YAML + :value => 'value', # used together with :key; CSS, JSON, YAML + :variable => 'variable', # Sass, SQL, YAML + + :change => 'change', # Diff + :delete => 'delete', # Diff + :head => 'head', # Diff, YAML + :insert => 'insert', # Diff + :eyecatcher => 'eyecatcher', # Diff + + :ident => false, # almost all scanners + :operator => false, # almost all scanners + + :space => false, # almost all scanners + :plain => false # almost all scanners + ) + + TokenKinds[:method] = TokenKinds[:function] + TokenKinds[:unknown] = TokenKinds[:plain] +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens.rb new file mode 100644 index 000000000..e7bffce2a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens.rb @@ -0,0 +1,161 @@ +module CodeRay + + # The Tokens class represents a list of tokens returned from + # a Scanner. It's actually just an Array with a few helper methods. + # + # A token itself is not a special object, just two elements in an Array: + # * the _token_ _text_ (the original source of the token in a String) or + # a _token_ _action_ (begin_group, end_group, begin_line, end_line) + # * the _token_ _kind_ (a Symbol representing the type of the token) + # + # It looks like this: + # + # ..., '# It looks like this', :comment, ... + # ..., '3.1415926', :float, ... + # ..., '$^', :error, ... + # + # Some scanners also yield sub-tokens, represented by special + # token actions, for example :begin_group and :end_group. + # + # The Ruby scanner, for example, splits "a string" into: + # + # [ + # :begin_group, :string, + # '"', :delimiter, + # 'a string', :content, + # '"', :delimiter, + # :end_group, :string + # ] + # + # Tokens can be used to save the output of a Scanners in a simple + # Ruby object that can be send to an Encoder later: + # + # tokens = CodeRay.scan('price = 2.59', :ruby).tokens + # tokens.encode(:html) + # tokens.html + # CodeRay.encoder(:html).encode_tokens(tokens) + # + # Tokens gives you the power to handle pre-scanned code very easily: + # You can serialize it to a JSON string and store it in a database, pass it + # around to encode it more than once, send it to other algorithms... + class Tokens < Array + + # The Scanner instance that created the tokens. + attr_accessor :scanner + + # Encode the tokens using encoder. + # + # encoder can be + # * a plugin name like :html oder 'statistic' + # * an Encoder object + # + # options are passed to the encoder. + def encode encoder, options = {} + encoder = Encoders[encoder].new options if encoder.respond_to? :to_sym + encoder.encode_tokens self, options + end + + # Turn tokens into a string by concatenating them. + def to_s + encode CodeRay::Encoders::Encoder.new + end + + # Redirects unknown methods to encoder calls. + # + # For example, if you call +tokens.html+, the HTML encoder + # is used to highlight the tokens. + def method_missing meth, options = {} + encode meth, options + rescue PluginHost::PluginNotFound + super + end + + # Split the tokens into parts of the given +sizes+. + # + # The result will be an Array of Tokens objects. The parts have + # the text size specified by the parameter. In addition, each + # part closes all opened tokens. This is useful to insert tokens + # betweem them. + # + # This method is used by @Scanner#tokenize@ when called with an Array + # of source strings. The Diff encoder uses it for inline highlighting. + def split_into_parts *sizes + return Array.new(sizes.size) { Tokens.new } if size == 2 && first == '' + parts = [] + opened = [] + content = nil + part = Tokens.new + part_size = 0 + size = sizes.first + i = 0 + for item in self + case content + when nil + content = item + when String + if size && part_size + content.size > size # token must be cut + if part_size < size # some part of the token goes into this part + content = content.dup # content may no be safe to change + part << content.slice!(0, size - part_size) << item + end + # close all open groups and lines... + closing = opened.reverse.flatten.map do |content_or_kind| + case content_or_kind + when :begin_group + :end_group + when :begin_line + :end_line + else + content_or_kind + end + end + part.concat closing + begin + parts << part + part = Tokens.new + size = sizes[i += 1] + end until size.nil? || size > 0 + # ...and open them again. + part.concat opened.flatten + part_size = 0 + redo unless content.empty? + else + part << content << item + part_size += content.size + end + content = nil + when Symbol + case content + when :begin_group, :begin_line + opened << [content, item] + when :end_group, :end_line + opened.pop + else + raise ArgumentError, 'Unknown token action: %p, kind = %p' % [content, item] + end + part << content << item + content = nil + else + raise ArgumentError, 'Token input junk: %p, kind = %p' % [content, item] + end + end + parts << part + parts << Tokens.new while parts.size < sizes.size + parts + end + + # Return the actual number of tokens. + def count + size / 2 + end + + alias text_token push + def begin_group kind; push :begin_group, kind end + def end_group kind; push :end_group, kind end + def begin_line kind; push :begin_line, kind end + def end_line kind; push :end_line, kind end + alias tokens concat + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens_proxy.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens_proxy.rb new file mode 100644 index 000000000..31ff39be9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/tokens_proxy.rb @@ -0,0 +1,55 @@ +module CodeRay + + # The result of a scan operation is a TokensProxy, but should act like Tokens. + # + # This proxy makes it possible to use the classic CodeRay.scan.encode API + # while still providing the benefits of direct streaming. + class TokensProxy + + attr_accessor :input, :lang, :options, :block + + # Create a new TokensProxy with the arguments of CodeRay.scan. + def initialize input, lang, options = {}, block = nil + @input = input + @lang = lang + @options = options + @block = block + end + + # Call CodeRay.encode if +encoder+ is a Symbol; + # otherwise, convert the receiver to tokens and call encoder.encode_tokens. + def encode encoder, options = {} + if encoder.respond_to? :to_sym + CodeRay.encode(input, lang, encoder, options) + else + encoder.encode_tokens tokens, options + end + end + + # Tries to call encode; + # delegates to tokens otherwise. + def method_missing method, *args, &blk + encode method.to_sym, *args + rescue PluginHost::PluginNotFound + tokens.send(method, *args, &blk) + end + + # The (cached) result of the tokenized input; a Tokens instance. + def tokens + @tokens ||= scanner.tokenize(input) + end + + # A (cached) scanner instance to use for the scan task. + def scanner + @scanner ||= CodeRay.scanner(lang, options, &block) + end + + # Overwrite Struct#each. + def each *args, &blk + tokens.each(*args, &blk) + self + end + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/version.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/version.rb new file mode 100644 index 000000000..4b4f0850d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/lib/coderay/version.rb @@ -0,0 +1,3 @@ +module CodeRay + VERSION = '1.1.0' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/basic.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/basic.rb new file mode 100755 index 000000000..752d4ba0d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/basic.rb @@ -0,0 +1,318 @@ +# encoding: utf-8 +require 'test/unit' +require File.expand_path('../../lib/assert_warning', __FILE__) + +$:.unshift File.expand_path('../../../lib', __FILE__) +require 'coderay' + +class BasicTest < Test::Unit::TestCase + + def test_version + assert_nothing_raised do + assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION) + end + end + + def with_empty_load_path + old_load_path = $:.dup + $:.clear + yield + ensure + $:.replace old_load_path + end + + def test_autoload + with_empty_load_path do + assert_nothing_raised do + CodeRay::Scanners::Java::BuiltinTypes + end + end + end + + RUBY_TEST_CODE = 'puts "Hello, World!"' + + RUBY_TEST_TOKENS = [ + ['puts', :ident], + [' ', :space], + [:begin_group, :string], + ['"', :delimiter], + ['Hello, World!', :content], + ['"', :delimiter], + [:end_group, :string] + ].flatten + def test_simple_scan + assert_nothing_raised do + assert_equal RUBY_TEST_TOKENS, CodeRay.scan(RUBY_TEST_CODE, :ruby).tokens + end + end + + RUBY_TEST_HTML = 'puts "' + + 'Hello, World!"' + def test_simple_highlight + assert_nothing_raised do + assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html + end + end + + def test_scan_file + CodeRay.scan_file __FILE__ + end + + def test_encode + assert_equal 1, CodeRay.encode('test', :python, :count) + end + + def test_encode_tokens + assert_equal 1, CodeRay.encode_tokens(CodeRay::Tokens['test', :string], :count) + end + + def test_encode_file + assert_equal File.read(__FILE__), CodeRay.encode_file(__FILE__, :text) + end + + def test_highlight + assert_match '
test
', CodeRay.highlight('test', :python) + end + + def test_highlight_file + assert_match "require 'test/unit'\n", CodeRay.highlight_file(__FILE__) + end + + def test_duo + assert_equal(RUBY_TEST_CODE, + CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE)) + assert_equal(RUBY_TEST_CODE, + CodeRay::Duo[:plain => :text].highlight(RUBY_TEST_CODE)) + end + + def test_duo_stream + assert_equal(RUBY_TEST_CODE, + CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE, :stream => true)) + end + + def test_comment_filter + assert_equal <<-EXPECTED, CodeRay.scan(<<-INPUT, :ruby).comment_filter.text +#!/usr/bin/env ruby + +code + +more code + EXPECTED +#!/usr/bin/env ruby +=begin +A multi-line comment. +=end +code +# A single-line comment. +more code # and another comment, in-line. + INPUT + end + + def test_lines_of_code + assert_equal 2, CodeRay.scan(<<-INPUT, :ruby).lines_of_code +#!/usr/bin/env ruby +=begin +A multi-line comment. +=end +code +# A single-line comment. +more code # and another comment, in-line. + INPUT + rHTML = <<-RHTML + + + + + + <%= controller.controller_name.titleize %>: <%= controller.action_name %> + <%= stylesheet_link_tag 'scaffold' %> + + + +

<%= flash[:notice] %>

+ +
+ <%= yield %> +
+ + + + RHTML + assert_equal 0, CodeRay.scan(rHTML, :html).lines_of_code + assert_equal 0, CodeRay.scan(rHTML, :php).lines_of_code + assert_equal 0, CodeRay.scan(rHTML, :yaml).lines_of_code + assert_equal 4, CodeRay.scan(rHTML, :erb).lines_of_code + end + + def test_list_of_encoders + assert_kind_of(Array, CodeRay::Encoders.list) + assert CodeRay::Encoders.list.include?(:count) + end + + def test_list_of_scanners + assert_kind_of(Array, CodeRay::Scanners.list) + assert CodeRay::Scanners.list.include?(:text) + end + + def test_token_kinds + assert_kind_of Hash, CodeRay::TokenKinds + for kind, css_class in CodeRay::TokenKinds + assert_kind_of Symbol, kind + if css_class != false + assert_kind_of String, css_class, "TokenKinds[%p] == %p" % [kind, css_class] + end + end + assert_equal 'reserved', CodeRay::TokenKinds[:reserved] + assert_equal false, CodeRay::TokenKinds[:shibboleet] + end + + class Milk < CodeRay::Encoders::Encoder + FILE_EXTENSION = 'cocoa' + end + + class HoneyBee < CodeRay::Encoders::Encoder + end + + def test_encoder_file_extension + assert_nothing_raised do + assert_equal 'html', CodeRay::Encoders::Page::FILE_EXTENSION + assert_equal 'cocoa', Milk::FILE_EXTENSION + assert_equal 'cocoa', Milk.new.file_extension + assert_equal 'honeybee', HoneyBee::FILE_EXTENSION + assert_equal 'honeybee', HoneyBee.new.file_extension + end + assert_raise NameError do + HoneyBee::MISSING_CONSTANT + end + end + + def test_encoder_tokens + encoder = CodeRay::Encoders::Encoder.new + encoder.send :setup, {} + assert_raise(ArgumentError) { encoder.token :strange, '' } + encoder.token 'test', :debug + end + + def test_encoder_deprecated_interface + encoder = CodeRay::Encoders::Encoder.new + encoder.send :setup, {} + assert_warning 'Using old Tokens#<< interface.' do + encoder << ['test', :content] + end + assert_raise ArgumentError do + encoder << [:strange, :input] + end + assert_raise ArgumentError do + encoder.encode_tokens [['test', :token]] + end + end + + def encoder_token_interface_deprecation_warning_given + CodeRay::Encoders::Encoder.send :class_variable_get, :@@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN + end + + def test_scanner_file_extension + assert_equal 'rb', CodeRay::Scanners::Ruby.file_extension + assert_equal 'rb', CodeRay::Scanners::Ruby.new.file_extension + assert_equal 'java', CodeRay::Scanners::Java.file_extension + assert_equal 'java', CodeRay::Scanners::Java.new.file_extension + end + + def test_scanner_lang + assert_equal :ruby, CodeRay::Scanners::Ruby.lang + assert_equal :ruby, CodeRay::Scanners::Ruby.new.lang + assert_equal :java, CodeRay::Scanners::Java.lang + assert_equal :java, CodeRay::Scanners::Java.new.lang + end + + def test_scanner_tokenize + assert_equal ['foo', :plain], CodeRay::Scanners::Plain.new.tokenize('foo') + assert_equal [['foo', :plain], ['bar', :plain]], CodeRay::Scanners::Plain.new.tokenize(['foo', 'bar']) + CodeRay::Scanners::Plain.new.tokenize 42 + end + + def test_scanner_tokens + scanner = CodeRay::Scanners::Plain.new + scanner.tokenize('foo') + assert_equal ['foo', :plain], scanner.tokens + scanner.string = '' + assert_equal ['', :plain], scanner.tokens + end + + def test_scanner_line_and_column + scanner = CodeRay::Scanners::Plain.new "foo\nbär+quux" + assert_equal 0, scanner.pos + assert_equal 1, scanner.line + assert_equal 1, scanner.column + scanner.scan(/foo/) + assert_equal 3, scanner.pos + assert_equal 1, scanner.line + assert_equal 4, scanner.column + scanner.scan(/\n/) + assert_equal 4, scanner.pos + assert_equal 2, scanner.line + assert_equal 1, scanner.column + scanner.scan(/b/) + assert_equal 5, scanner.pos + assert_equal 2, scanner.line + assert_equal 2, scanner.column + scanner.scan(/a/) + assert_equal 5, scanner.pos + assert_equal 2, scanner.line + assert_equal 2, scanner.column + scanner.scan(/ä/) + assert_equal 7, scanner.pos + assert_equal 2, scanner.line + assert_equal 4, scanner.column + scanner.scan(/r/) + assert_equal 8, scanner.pos + assert_equal 2, scanner.line + assert_equal 5, scanner.column + end + + def test_scanner_use_subclasses + assert_raise NotImplementedError do + CodeRay::Scanners::Scanner.new + end + end + + class InvalidScanner < CodeRay::Scanners::Scanner + end + + def test_scanner_scan_tokens + assert_raise NotImplementedError do + InvalidScanner.new.tokenize '' + end + end + + class RaisingScanner < CodeRay::Scanners::Scanner + def scan_tokens encoder, options + raise_inspect 'message', [], :initial + end + end + + def test_scanner_raise_inspect + assert_raise CodeRay::Scanners::Scanner::ScanError do + RaisingScanner.new.tokenize '' + end + end + + def test_scan_a_frozen_string + assert_nothing_raised do + CodeRay.scan RUBY_VERSION, :ruby + CodeRay.scan RUBY_VERSION, :plain + end + end + + def test_scan_a_non_string + assert_nothing_raised do + CodeRay.scan 42, :ruby + CodeRay.scan nil, :ruby + CodeRay.scan self, :ruby + CodeRay.encode ENV.to_hash, :ruby, :page + CodeRay.highlight CodeRay, :plain + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/examples.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/examples.rb new file mode 100755 index 000000000..985ef8714 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/examples.rb @@ -0,0 +1,129 @@ +require 'test/unit' + +$:.unshift File.expand_path('../../../lib', __FILE__) +require 'coderay' + +class ExamplesTest < Test::Unit::TestCase + + def test_examples + # output as HTML div (using inline CSS styles) + div = CodeRay.scan('puts "Hello, world!"', :ruby).div + assert_equal <<-DIV, div +
+
puts "Hello, world!"
+
+ DIV + + # ...with line numbers + div = CodeRay.scan(<<-CODE.chomp, :ruby).div(:line_numbers => :table) +5.times do + puts 'Hello, world!' +end + CODE + assert_equal <<-DIV, div + + + +
1
+2
+3
+
5.times do
+  puts 'Hello, world!'
+end
+ DIV + + # output as standalone HTML page (using CSS classes) + page = CodeRay.scan('puts "Hello, world!"', :ruby).page + assert_match <<-PAGE, page + + + + + +
1
+
puts "Hello, world!"
+ + + PAGE + + # keep scanned tokens for later use + tokens = CodeRay.scan('{ "just": "an", "example": 42 }', :json) + assert_kind_of CodeRay::TokensProxy, tokens + + assert_equal ["{", :operator, " ", :space, :begin_group, :key, + "\"", :delimiter, "just", :content, "\"", :delimiter, + :end_group, :key, ":", :operator, " ", :space, + :begin_group, :string, "\"", :delimiter, "an", :content, + "\"", :delimiter, :end_group, :string, ",", :operator, + " ", :space, :begin_group, :key, "\"", :delimiter, + "example", :content, "\"", :delimiter, :end_group, :key, + ":", :operator, " ", :space, "42", :integer, + " ", :space, "}", :operator], tokens.tokens + + # produce a token statistic + assert_equal <<-STATISTIC, tokens.statistic + +Code Statistics + +Tokens 26 + Non-Whitespace 15 +Bytes Total 31 + +Token Types (7): + type count ratio size (average) +------------------------------------------------------------- + TOTAL 26 100.00 % 1.2 + delimiter 6 23.08 % 1.0 + operator 5 19.23 % 1.0 + space 5 19.23 % 1.0 + key 4 15.38 % 0.0 + :begin_group 3 11.54 % 0.0 + :end_group 3 11.54 % 0.0 + content 3 11.54 % 4.3 + string 2 7.69 % 0.0 + integer 1 3.85 % 2.0 + + STATISTIC + + # count the tokens + assert_equal 26, tokens.count + + # produce a HTML div, but with CSS classes + div = tokens.div(:css => :class) + assert_equal <<-DIV, div +
+
{ "just": "an", "example": 42 }
+
+ DIV + + # highlight a file (HTML div); guess the file type base on the extension + assert_equal :ruby, CodeRay::FileType[__FILE__] + + # get a new scanner for Python + python_scanner = CodeRay.scanner :python + assert_kind_of CodeRay::Scanners::Python, python_scanner + + # get a new encoder for terminal + terminal_encoder = CodeRay.encoder :term + assert_kind_of CodeRay::Encoders::Terminal, terminal_encoder + + # scanning into tokens + tokens = python_scanner.tokenize 'import this; # The Zen of Python' + assert_equal ["import", :keyword, " ", :space, "this", :include, + ";", :operator, " ", :space, "# The Zen of Python", :comment], tokens + + # format the tokens + term = terminal_encoder.encode_tokens(tokens) + assert_equal "\e[32mimport\e[0m \e[31mthis\e[0m; \e[1;30m# The Zen of Python\e[0m", term + + # re-using scanner and encoder + ruby_highlighter = CodeRay::Duo[:ruby, :div] + div = ruby_highlighter.encode('puts "Hello, world!"') + assert_equal <<-DIV, div +
+
puts "Hello, world!"
+
+ DIV + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/for_redcloth.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/for_redcloth.rb new file mode 100644 index 000000000..9fd244edf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/for_redcloth.rb @@ -0,0 +1,78 @@ +require 'test/unit' + +$:.unshift File.expand_path('../../../lib', __FILE__) +require 'coderay' + +begin + require 'rubygems' unless defined? Gem + gem 'RedCloth', '>= 4.0.3' rescue nil + require 'redcloth' +rescue LoadError + warn 'RedCloth not found - skipping for_redcloth tests.' + undef RedCloth if defined? RedCloth +end + +class BasicTest < Test::Unit::TestCase + + def test_for_redcloth + require 'coderay/for_redcloth' + assert_equal "

puts "Hello, World!"

", + RedCloth.new('@[ruby]puts "Hello, World!"@').to_html + assert_equal <<-BLOCKCODE.chomp, +
+
puts "Hello, World!"
+
+ BLOCKCODE + RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html + end + + def test_for_redcloth_no_lang + require 'coderay/for_redcloth' + assert_equal "

puts \"Hello, World!\"

", + RedCloth.new('@puts "Hello, World!"@').to_html + assert_equal <<-BLOCKCODE.chomp, +
puts \"Hello, World!\"
+ BLOCKCODE + RedCloth.new('bc. puts "Hello, World!"').to_html + end + + def test_for_redcloth_style + require 'coderay/for_redcloth' + assert_equal <<-BLOCKCODE.chomp, +
puts \"Hello, World!\"
+ BLOCKCODE + RedCloth.new('bc{color: red}. puts "Hello, World!"').to_html + end + + def test_for_redcloth_escapes + require 'coderay/for_redcloth' + assert_equal '

>

', + RedCloth.new('@[ruby]>@').to_html + assert_equal <<-BLOCKCODE.chomp, +
+
&
+
+ BLOCKCODE + RedCloth.new('bc[ruby]. &').to_html + end + + def test_for_redcloth_escapes2 + require 'coderay/for_redcloth' + assert_equal "

#include <test.h>

", + RedCloth.new('@[c]#include @').to_html + end + + # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets. + def test_for_redcloth_false_positive + require 'coderay/for_redcloth' + assert_equal '

[project]_dff.skjd

', + RedCloth.new('@[project]_dff.skjd@').to_html + # false positive, but expected behavior / known issue + assert_equal "

_dff.skjd

", + RedCloth.new('@[ruby]_dff.skjd@').to_html + assert_equal <<-BLOCKCODE.chomp, RedCloth.new('bc. [project]_dff.skjd').to_html +
[project]_dff.skjd
+ BLOCKCODE + end + +end if defined? RedCloth \ No newline at end of file diff --git a/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/suite.rb b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/suite.rb new file mode 100755 index 000000000..ec23eec08 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/coderay-1.1.0/test/functional/suite.rb @@ -0,0 +1,15 @@ +require 'test/unit' + +$VERBOSE = $CODERAY_DEBUG = true +$:.unshift File.expand_path('../../../lib', __FILE__) +require 'coderay' + +mydir = File.dirname(__FILE__) +suite = Dir[File.join(mydir, '*.rb')]. + map { |tc| File.basename(tc).sub(/\.rb$/, '') } - %w'suite for_redcloth' + +puts "Running basic CodeRay #{CodeRay::VERSION} tests: #{suite.join(', ')}" + +for test_case in suite + load File.join(mydir, test_case + '.rb') +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.gitignore b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.gitignore new file mode 100644 index 000000000..73f35cf67 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.gitignore @@ -0,0 +1,3 @@ +*~ +/doc +/pkg diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.travis.yml b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.travis.yml new file mode 100644 index 000000000..644377471 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/.travis.yml @@ -0,0 +1,9 @@ +language: ruby +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 + - 2.1.5 +matrix: + allow_failures: + - rvm: ruby-head diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/AUTHORS b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/AUTHORS new file mode 100644 index 000000000..463be9b5b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/AUTHORS @@ -0,0 +1,2 @@ +R. Bernstein (rockyb@rubyforge.net) +M. Davis (waslogic@gmail.com) diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/COPYING b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/COPYING new file mode 100644 index 000000000..32e46acec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/COPYING @@ -0,0 +1,57 @@ +Columnize is copyrighted free software by Rocky Bernstein . + +You can redistribute it and/or modify it under either the terms of the GPL +version 2, or the conditions below: + + 1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + + 2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b) use the modified software only within your corporation or + organization. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a) distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b) accompany the distribution with the machine-readable source of + the software. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + + 5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + + 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/ChangeLog b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/ChangeLog new file mode 100644 index 000000000..becafe2e0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/ChangeLog @@ -0,0 +1,282 @@ +2011-06-09 rocky + + * ChangeLog, NEWS, Rakefile: Get ready for new release. + +2011-04-27 r + + * README.md: Fix code example. + +2011-04-27 r + + * .gemspec, README, README.md, Rakefile: README->README.md + +2011-04-27 r + + * .gemspec, AUTHORS, COPYING, ChangeLog, Makefile, NEWS, README, + Rakefile, lib/Makefile, lib/columnize.rb, lib/version.rb, + tags/release-0.2.1/AUTHORS, tags/release-0.2.1/COPYING, + tags/release-0.2.1/ChangeLog, tags/release-0.2.1/NEWS, + tags/release-0.2.1/README, tags/release-0.2.1/Rakefile, + tags/release-0.2.1/VERSION, tags/release-0.2.1/lib/columnize.rb, + tags/release-0.2.1/test/test-columnize.rb, + tags/release-0.3.0/AUTHORS, tags/release-0.3.0/COPYING, + tags/release-0.3.0/ChangeLog, tags/release-0.3.0/NEWS, + tags/release-0.3.0/README, tags/release-0.3.0/Rakefile, + tags/release-0.3.0/VERSION, tags/release-0.3.0/lib/columnize.rb, + tags/release-0.3.0/test/test-columnize.rb, + tags/release-0.3.1/AUTHORS, tags/release-0.3.1/COPYING, + tags/release-0.3.1/ChangeLog, tags/release-0.3.1/NEWS, + tags/release-0.3.1/README, tags/release-0.3.1/Rakefile, + tags/release-0.3.1/VERSION, tags/release-0.3.1/lib/columnize.rb, + tags/release-0.3.1/test/test-columnize.rb, test/test-columnize.rb, + test/test-hashparm.rb, trunk/.gemspec, trunk/AUTHORS, + trunk/COPYING, trunk/ChangeLog, trunk/Makefile, trunk/NEWS, + trunk/README, trunk/Rakefile, trunk/lib/Makefile, + trunk/lib/columnize.rb, trunk/lib/version.rb, + trunk/test/test-columnize.rb, trunk/test/test-hashparm.rb: Remove + trunk and tags. + +2011-04-27 rockyb + + * trunk/ChangeLog, trunk/lib/columnize.rb, trunk/lib/version.rb, + trunk/test/test-columnize.rb, trunk/test/test-hashparm.rb: Redo + columnize options processing to allow for a single hash of options + instead of the numerous optional arguments. This make future + expansion easier. + +2010-09-22 rockyb + + * trunk/Makefile, trunk/Rakefile: Rakefile: Remove bad test task + Makefile: simplify. + +2010-09-21 rockyb + + * trunk/Makefile, trunk/Rakefile: Makefile was a little off + +2010-09-21 rockyb + + * trunk/.gemspec, trunk/Rakefile, trunk/lib/columnize.rb: Small + changes to Rakefile and rdoc and so on. + +2010-09-20 rockyb + + * trunk/.gemspec, trunk/Rakefile: Forgot to add .gemspec + +2010-09-20 rockyb + + * trunk/ChangeLog, trunk/Makefile, trunk/NEWS, trunk/README, + trunk/Rakefile, trunk/VERSION, trunk/lib/Makefile, + trunk/lib/columnize.rb, trunk/lib/version.rb: Add .gemspec, correct + description field and add a summary. Add Columnize::VERSION Simplify + Rakefile Add stub Makefiles + +2010-03-01 rockyb + + * trunk/README: Better README description + +2010-03-01 rockyb + + * trunk/README: Update README + +2010-02-22 rockyb + + * trunk/ChangeLog, trunk/VERSION, trunk/lib/columnize.rb: Remove + shadow variable warnings. Bump version number + +2009-07-26 rockyb + + * tags/release-0.3.1/AUTHORS, tags/release-0.3.1/COPYING, + tags/release-0.3.1/ChangeLog, tags/release-0.3.1/NEWS, + tags/release-0.3.1/README, tags/release-0.3.1/Rakefile, + tags/release-0.3.1/VERSION, tags/release-0.3.1/lib/columnize.rb, + tags/release-0.3.1/test/test-columnize.rb: Release 0.3.1 + +2009-07-26 rockyb + + * trunk/lib/columnize.rb: Small comment spelling typo. + +2009-07-26 rockyb + + * trunk/ChangeLog: Get ready for 0.3.1 release + +2009-07-26 rockyb + + * trunk/NEWS, trunk/lib/columnize.rb, trunk/test/test-columnize.rb: + Add lineprefix. Get ready for release. + +2009-07-26 mark-moseley + + * trunk/ChangeLog, trunk/lib/columnize.rb: Ruby 1.9 updates + +2009-03-30 rockyb + + * trunk/Rakefile: Revise for 1.9 version of rake + +2009-01-16 rockyb + + * trunk/ChangeLog, trunk/Rakefile, trunk/VERSION: package readme was + wonky. Looks like no one reads this stuff. + +2009-01-10 rockyb + + * tags/release-0.3.0/AUTHORS, tags/release-0.3.0/COPYING, + tags/release-0.3.0/ChangeLog, tags/release-0.3.0/NEWS, + tags/release-0.3.0/README, tags/release-0.3.0/Rakefile, + tags/release-0.3.0/VERSION, tags/release-0.3.0/lib/columnize.rb, + tags/release-0.3.0/test/test-columnize.rb: Release 0.3.0 + +2009-01-10 rockyb + + * trunk/ChangeLog, trunk/NEWS: Get ready for release + +2009-01-08 rockyb + + * trunk/ChangeLog, trunk/NEWS, trunk/VERSION, + trunk/lib/columnize.rb, trunk/test/test-columnize.rb: Fix bad bug in + arranging horizontally + +2009-01-01 rockyb + + * columnize/trunk/AUTHORS, columnize/trunk/COPYING, + columnize/trunk/ChangeLog, columnize/trunk/NEWS, + columnize/trunk/README, columnize/trunk/Rakefile, + columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb, + columnize/trunk/test/test-columnize.rb: Remove hacky + columnize/columnize + +2009-01-01 rockyb + + * tags/columnize-0.2/AUTHORS, tags/columnize-0.2/COPYING, + tags/columnize-0.2/ChangeLog, tags/columnize-0.2/NEWS, + tags/columnize-0.2/README, tags/columnize-0.2/Rakefile, + tags/columnize-0.2/VERSION, tags/columnize-0.2/lib/columnize.rb, + tags/columnize-0.2/test/test-columnize.rb: Regularize tags names + better + +2009-01-01 rockyb + + * tags/release-0.2.1/AUTHORS, tags/release-0.2.1/COPYING, + tags/release-0.2.1/ChangeLog, tags/release-0.2.1/NEWS, + tags/release-0.2.1/README, tags/release-0.2.1/Rakefile, + tags/release-0.2.1/VERSION, tags/release-0.2.1/lib/columnize.rb, + tags/release-0.2.1/test/test-columnize.rb: Release 0.2.1 + +2009-01-01 rockyb + + * trunk/NEWS: Merge NEWS + +2009-01-01 rockyb + + * columnize/tags/columnize-0.2/AUTHORS, + columnize/tags/columnize-0.2/COPYING, + columnize/tags/columnize-0.2/ChangeLog, + columnize/tags/columnize-0.2/NEWS, + columnize/tags/columnize-0.2/README, + columnize/tags/columnize-0.2/Rakefile, + columnize/tags/columnize-0.2/VERSION, + columnize/tags/columnize-0.2/lib/columnize.rb, + columnize/tags/columnize-0.2/test/test-columnize.rb, + tags/columnize-0.2/AUTHORS, tags/columnize-0.2/COPYING, + tags/columnize-0.2/ChangeLog, tags/columnize-0.2/NEWS, + tags/columnize-0.2/README, tags/columnize-0.2/Rakefile, + tags/columnize-0.2/VERSION, tags/columnize-0.2/lib/columnize.rb, + tags/columnize-0.2/test/test-columnize.rb: Cleanup of + columnize/columnize crap + +2009-01-01 rockyb + + * : Add directory for releases + +2009-01-01 rockyb + + * trunk/NEWS, trunk/VERSION: Ooops 0.2 release done. Go for 0.2.1 + +2009-01-01 rockyb + + * trunk/ChangeLog: Get ready for release 0.2 + +2009-01-01 rockyb + + * trunk/ChangeLog, trunk/NEWS, trunk/VERSION, + trunk/lib/columnize.rb, trunk/test/test-columnize.rb: Get ready for + release 0.2 + +2008-09-22 rockyb + + * columnize/tags/columnize-0.2/AUTHORS, + columnize/tags/columnize-0.2/COPYING, + columnize/tags/columnize-0.2/ChangeLog, + columnize/tags/columnize-0.2/NEWS, + columnize/tags/columnize-0.2/README, + columnize/tags/columnize-0.2/Rakefile, + columnize/tags/columnize-0.2/VERSION, + columnize/tags/columnize-0.2/lib/columnize.rb, + columnize/tags/columnize-0.2/test/test-columnize.rb: Tag 0.2 + release. + +2008-09-22 rockyb + + * : Add tags directory for release + +2008-09-22 rockyb + + * columnize/trunk/ChangeLog, columnize/trunk/NEWS: Add directory for + tagging releases. Other Administrivia. + +2008-09-22 rockyb + + * columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb: Get rid + of hacky $0 test. + +2008-03-16 rockyb + + * trunk/lib/columnize.rb: [no log message] + +2008-03-16 rockyb + + * trunk/lib/columnize.rb: Simplify __FILE__ == $0. (rdebug now + changes $0 and rcov has an option) + +2008-02-11 rockyb + + * trunk/lib/columnize.rb: Remove 1.9's shadow warning + +2007-12-10 rockyb + + * columnize/trunk/AUTHORS, columnize/trunk/COPYING, + columnize/trunk/ChangeLog, columnize/trunk/NEWS, + columnize/trunk/README, columnize/trunk/Rakefile, + columnize/trunk/VERSION, columnize/trunk/lib/columnize.rb, + columnize/trunk/test/test-columnize.rb: release 0.1 + +2007-12-09 rockyb + + * trunk/README, trunk/Rakefile: Fix up doc a little. Make the + default rake task "test". + +2007-12-09 rockyb + + * trunk/lib/columnize.rb: Doc fix. + +2007-12-09 rockyb + + * trunk/ChangeLog, trunk/lib/columnize.rb, + trunk/test/test-columnize.rb: columnize.rb: Allow one to specify a + separator string. Remove restriction that all entries in the array + have to be a string. test-columnize.rb: more tests - invalid list, + empty list, with separator string parameter. + +2007-12-09 rockyb + + * trunk/test/test-columnize.rb: Typo. + +2007-12-09 rockyb + + * : Property changes for Id lines and to make test-columnize.rb + executable. + +2007-12-09 rockyb + + * Initial release of Columnize, a module to print an Array in + column-sorted order. + diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile new file mode 100644 index 000000000..fa75df156 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile.lock b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile.lock new file mode 100644 index 000000000..bc9a50751 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Gemfile.lock @@ -0,0 +1,20 @@ +PATH + remote: . + specs: + columnize (0.8.9) + +GEM + remote: https://rubygems.org/ + specs: + json (1.8.0) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + +PLATFORMS + ruby + +DEPENDENCIES + columnize! + rake (~> 10.1.0) + rdoc diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Makefile b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Makefile new file mode 100644 index 000000000..7f690e9c5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Makefile @@ -0,0 +1,15 @@ +# I'll admit it -- I'm an absent-minded old-timer who has trouble +# learning new tricks. + +RUBY ?= ruby +RAKE ?= rake + +test: check + +#: Default target; same as "make check" +all: check + true + +#: Same as corresponding rake task +%: + $(RAKE) $@ diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/NEWS b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/NEWS new file mode 100644 index 000000000..c4a9d4fe1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/NEWS @@ -0,0 +1,60 @@ +0.9.0 Dec 5, 2014 - Early gecko + +0.8.9 Apr 19, 2014 +- Add columnize method to Array class and a place to set its default options +- Add option :colfmt to allow a format specifier to use (e.g. '%02d') in stringifying + list items +- Add option linesuffix (default is "\n") +- When using arrange_array each line now has trailing "," + +0.3.6 Dec 17, 2011 +- rename version.rb columnize/version.rb so as not to conflict with + another package called version +- Administrivia - shorten gemcutter description + +0.3.5 Nov 24, 2011 +- Handle situation where an array element is larger than the display width. + +0.3.4 July 4, 2011 + +- Change to Ruby License +- Add option 'term_adjust' to ignore terminal sequences in text +- Add :ljust => :auto to decide whether or not to automatically + left or right justify. When passing a hash parameter, the default + is :auto. + +0.3.3 June 12, 2011 Fleetwood release + +- More general but simpler inteface using an options + hash. Compatibility is maintaind though. + +0.3.2 + +- Mostly Administrivia. + * Add .gemspec, correct description field and add a summary. + * Add Columnize::VERSION + * Simplify Rakefile + * Add stub Makefiles + +0.3.1 (01-07-26) + +- Correct for Ruby 1.9 (Mark Moseley) + +- add optional lineprefix parameter + +0.3.0 (01-10-09) - Sam Woodward Release + +- Fix bad bug in arranging horizontally + +0.2.1 (12-31-08) + +- Add ability to run columns horizontally + +0.2 + +- Minor - get rid of hacky $0 test + +0.1 + +- Initial release of Columnize, a module to print an Array in + column-sorted order diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/README.md b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/README.md new file mode 100644 index 000000000..212004167 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/README.md @@ -0,0 +1,108 @@ +[![Build Status](https://travis-ci.org/rocky/columnize.png)](https://travis-ci.org/rocky/columnize) [![Gem Version](https://badge.fury.io/rb/columnize.svg)](http://badge.fury.io/rb/columnize) + +Columnize - Format an Array as a Column-aligned String +============================================================================ + +In showing a long lists, sometimes one would prefer to see the value +arranged aligned in columns. Some examples include listing methods of +an object, listing debugger commands, or showing a numeric array with data +aligned. + +Setup +----- + + $ irb + >> require 'columnize' + => true + +With numeric data +----------------- + + >> a = (1..10).to_a + => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + + >> a.columnize + => "1 2 3 4 5 6 7 8 9 10" + + >> puts a.columnize :arrange_array => true, :displaywidth => 10 + [1, 2, 3, + 4, 5, 6, + 7, 8, 9, + 10] + => nil + + >> puts a.columnize :arrange_array => true, :displaywidth => 20 + [1, 2, 3, 4, 5, 6, + 7, 8, 9, 10] + => nil + +With String data +---------------- + + >> g = %w(bibrons golden madascar leopard mourning suras tokay) + => ["bibrons", "golden", "madascar", "leopard", "mourning", "suras", "tokay"] + + >> puts g.columnize :displaywidth => 15 + bibrons suras + golden tokay + madascar + leopard + mourning + => nil + + >> puts g.columnize :displaywidth => 19, :colsep => ' | ' + bibrons | suras + golden | tokay + madascar + leopard + mourning + => nil + + >> puts g.columnize :displaywidth => 18, :colsep => ' | ', :ljust => false + bibrons | mourning + golden | suras + madascar | tokay + leopard + => nil + +Using Columnize.columnize +------------------------- + + >> Columnize.columnize(a) + => "1 2 3 4 5 6 7 8 9 10" + + >> puts Columnize.columnize(a, :displaywidth => 10) + 1 5 9 + 2 6 10 + 3 7 + 4 8 + => nil + + >> Columnize.columnize(g) + => "bibrons golden madascar leopard mourning suras tokay" + + >> puts Columnize.columnize(g, :displaywidth => 19, :colsep => ' | ') + bibrons | mourning + golden | suras + madascar | tokay + leopard + => nil + + +Credits +------- + +This is adapted from a method of the same name from Python's cmd module. + +Other stuff +----------- + +Authors: Rocky Bernstein [![endorse](https://api.coderwall.com/rocky/endorsecount.png)](https://coderwall.com/rocky) and [Martin Davis](https://github.com/waslogic) + +License: Copyright (c) 2011,2013 Rocky Bernstein + +Warranty +-------- + +You can redistribute it and/or modify it under either the terms of the GPL +version 2 or the conditions listed in COPYING diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Rakefile b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Rakefile new file mode 100644 index 000000000..f3f55dea5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/Rakefile @@ -0,0 +1,105 @@ +#!/usr/bin/env rake +# -*- Ruby -*- +require 'rubygems' +require 'fileutils' + +ROOT_DIR = File.dirname(__FILE__) +Gemspec_filename = 'columnize.gemspec' +require File.join %W(#{ROOT_DIR} lib columnize version) + +def gemspec + @gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename) +end + +require 'rubygems/package_task' +desc "Build the gem" +task :package=>:gem +task :gem=>:gemspec do + Dir.chdir(ROOT_DIR) do + sh "gem build columnize.gemspec" + FileUtils.mkdir_p 'pkg' + FileUtils.mv gemspec.file_name, 'pkg' + end +end + +desc "Install the gem locally" +task :install => :gem do + Dir.chdir(ROOT_DIR) do + sh %{gem install --local pkg/#{gemspec.file_name}} + end +end + +require 'rake/testtask' +desc "Test everything." +Rake::TestTask.new(:test) do |t| + t.libs << './lib' + t.test_files = FileList['test/test-*.rb'] + t.verbose = true +end +task :test => :lib + +desc "same as test" +task :check => :test + +desc "same as test" +task :columnize => :test + +desc 'Create a GNU-style ChangeLog via git2cl' +task :ChangeLog do + system('git log --pretty --numstat --summary | git2cl > ChangeLog') +end + +task :default => [:test] + +desc 'Create a GNU-style ChangeLog via git2cl' +task :ChangeLog do + system('git log --pretty --numstat --summary | git2cl > ChangeLog') +end + +desc "Generate the gemspec" +task :generate do + puts gemspec.to_ruby +end + +desc "Validate the gemspec" +task :gemspec do + gemspec.validate +end + +# --------- RDoc Documentation ------ +require 'rdoc/task' +desc "Generate rdoc documentation" +Rake::RDocTask.new("rdoc") do |rdoc| + rdoc.rdoc_dir = 'doc' + rdoc.title = "Columnize #{Columnize::VERSION} Documentation" + + # Make the README file the start page for the generated html + rdoc.options += %w(--main README.md) + + rdoc.rdoc_files.include('lib/*.rb', 'README.md', 'COPYING') +end + +desc "Same as rdoc" +task :doc => :rdoc + +task :clobber_package do + FileUtils.rm_rf File.join(ROOT_DIR, 'pkg') +end + +task :clobber_rdoc do + FileUtils.rm_rf File.join(ROOT_DIR, 'doc') +end + +desc 'Remove residue from running patch' +task :rm_patch_residue do + FileUtils.rm_rf Dir.glob('**/*.{rej,orig}'), :verbose => true +end + +desc 'Remove ~ backup files' +task :rm_tilde_backups do + FileUtils.rm_rf Dir.glob('**/*~'), :verbose => true +end + +desc 'Remove built files' +task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue, + :rm_tilde_backups] diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/THANKS b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/THANKS new file mode 100644 index 000000000..56e07f81c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/THANKS @@ -0,0 +1,8 @@ +I am indebted to: + +Mark Moseley: + the initial port from 1.8 to 1.9 +Martin Davis: + how to extend into Array classes and set options from there +David Rodríguez de Dios: + Miscellaneous portability fixes and doggedness to get out a new release diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/columnize.gemspec b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/columnize.gemspec new file mode 100644 index 000000000..9dd2d920f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/columnize.gemspec @@ -0,0 +1,35 @@ +# -*- Ruby -*- +# -*- encoding: utf-8 -*- +require File.dirname(__FILE__) + "/lib/columnize/version" unless + Object.const_defined?(:'Columnize') + +Gem::Specification.new do |spec| + spec.authors = ['Rocky Bernstein'] + spec.date = Time.now + spec.description = ' +In showing a long lists, sometimes one would prefer to see the value +arranged aligned in columns. Some examples include listing methods +of an object or debugger commands. +See Examples in the rdoc documentation for examples. +' + spec.email = 'rockyb@rubyforge.net' + spec.files = `git ls-files`.split("\n") + spec.homepage = 'https://github.com/rocky/columnize' + spec.name = 'columnize' + spec.licenses = ['Ruby', 'GPL2'] + spec.platform = Gem::Platform::RUBY + spec.require_path = 'lib' + spec.required_ruby_version = '>= 1.8.2' + spec.rubyforge_project = 'columnize' + spec.summary = 'Module to format an Array as an Array of String aligned in columns' + spec.version = Columnize::VERSION + spec.has_rdoc = true + spec.extra_rdoc_files = %w(README.md lib/columnize.rb COPYING THANKS) + + # Make the readme file the start page for the generated html + spec.rdoc_options += %w(--main README) + spec.rdoc_options += ['--title', "Columnize #{Columnize::VERSION} Documentation"] + + spec.add_development_dependency 'rdoc' + spec.add_development_dependency 'rake', '~> 10.1.0' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/Makefile b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/Makefile new file mode 100644 index 000000000..b1a10e533 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/Makefile @@ -0,0 +1,10 @@ +# Whatever it is you want to do, it should be handled by the main +# (parent) Makefile. So reissue make from there. +PHONY=check all + +#: Default target - the parent's testing or "check" target +all: check + +#: Whatever it is you want to do, it should be handled by the parent +%: + $(MAKE) -C .. $@ diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize.rb new file mode 100644 index 000000000..3469ae409 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize.rb @@ -0,0 +1,137 @@ +# Module to format an Array into a single string with embedded +# newlines, On printing the string, the columns are aligned. +# +# == Summary +# +# Return a string from an array with embedded newlines formatted so +# that when printed the columns are aligned. +# See below for examples and options to the main method +columnize+. +# +# +# == License +# +# Columnize is copyright (C) 2007-2011, 2013 Rocky Bernstein +# +# +# All rights reserved. You can redistribute and/or modify it under +# the same terms as Ruby. +# +# Also available in Python (columnize), and Perl (Array::Columnize) + +module Columnize + # Pull in the rest of my pieces + ROOT_DIR = File.dirname(__FILE__) + %w(opts columnize version).each do |submod| + require File.join %W(#{ROOT_DIR} columnize #{submod}) + end + + # Add +columnize_opts+ instance variable to classes that mix in this module. The type should be a kind of hash in file +columnize/opts+. + attr_accessor :columnize_opts + + # Columnize.columize([args]) => String + # + # Return a string from an array with embedded newlines formatted so + # that when printed the columns are aligned. + # + # For example, for a line width of 4 characters (arranged vertically): + # a = (1..4).to_a + # Columnize.columnize(a) => '1 3\n2 4\n' + # + # Alternatively: + # a.columnize => '1 3\n2 4\n' + # + # Arranged horizontally: + # a.columnize(:arrange_vertical => false) => + # ['1', '2,', '3', '4'] => '1 2\n3 4\n' + # + # Formatted as an array using format specifier '%02d': + # puts (1..10).to_a.columnize(:arrange_array => true, :colfmt => '%02d', + # :displaywidth => 10) => + # [01, 02, + # 03, 04, + # 05, 06, + # 07, 08, + # 09, 10, + # ] + # + # Each column is only as wide as necessary. By default, columns are + # separated by two spaces. Options are available for setting + # * the line display width + # * a column separator + # * a line prefix + # * a line suffix + # * A format specify for formatting each item each array item to a string + # * whether to ignore terminal codes in text size calculation + # * whether to left justify text instead of right justify + # * whether to format as an array - with surrounding [] and + # separating ', ' + def self.columnize(*args) + list = args.shift + opts = parse_columnize_options(args) + Columnizer.new(list, opts).columnize + end + + # Adds columnize_opts to the singleton level of included class + def self.included(base) + # screw class variables, we'll use an instance variable on the class singleton + class << base + attr_accessor :columnize_opts + end + base.columnize_opts = DEFAULT_OPTS.dup + end + + def columnize(*args) + return Columnize.columnize(*args) if args.length > 1 + opts = args.empty? ? {} : args.pop + @columnize_opts ||= self.class.columnize_opts.dup + @columnizer ||= Columnizer.new(self, @columnize_opts) + # make sure that any changes to list or opts get passed to columnizer + @columnizer.list = self unless @columnizer.list == self + @columnizer.opts = @columnize_opts.merge(opts) unless @columnizer.opts == @columnize_opts and opts.empty? + @columnizer.columnize + end +end + +# Mix Columnize into Array +Array.send :include, Columnize + +# Demo this sucker +if __FILE__ == $0 + # include Columnize + + a = (1..80).to_a + puts a.columnize :arrange_array => true + puts '=' * 50 + + b = (1..10).to_a + puts b.columnize(:displaywidth => 10) + + puts '-' * 50 + puts b.columnize(:arrange_array => true, :colfmt => '%02d', :displaywidth => 10) + + [[4, 4], [4, 7], [100, 80]].each do |width, num| + data = (1..num).map{|i| i } + [[false, 'horizontal'], [true, 'vertical']].each do |bool, dir| + puts "Width: #{width}, direction: #{dir}" + print Columnize.columnize(data, :displaywidth => width, :colsep => ' ', :arrange_vertical => bool, :ljust => :auto) + end + end + + puts Columnize.columnize(5) + puts Columnize.columnize([]) + puts Columnize.columnize(["a", 2, "c"], :displaywidth =>10, :colsep => ', ') + puts Columnize.columnize(["oneitem"]) + puts Columnize.columnize(["one", "two", "three"]) + data = ["one", "two", "three", + "for", "five", "six", + "seven", "eight", "nine", + "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eightteen", + "nineteen", "twenty", "twentyone", + "twentytwo", "twentythree", "twentyfour", + "twentyfive","twentysix", "twentyseven"] + + puts Columnize.columnize(data) + puts Columnize.columnize(data, 80, ' ', false) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/Makefile b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/Makefile new file mode 100644 index 000000000..aa4f7842e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/Makefile @@ -0,0 +1,11 @@ +# Whatever it is you want to do, it should be handled by the main +# (parent) Makefile. So reissue make from there. +PHONY=check all + +#: Default target - the parent's testing or "check" target +all: check + true + +#: Whatever it is you want to do, it should be handled by the parent +%: + $(MAKE) -C ../.. $@ diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/columnize.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/columnize.rb new file mode 100644 index 000000000..77743c8cf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/columnize.rb @@ -0,0 +1,159 @@ +# Copyright (C) 2007-2011, 2013 Rocky Bernstein +# +# +# Part of Columnize to format in either direction +module Columnize + class Columnizer + ARRANGE_ARRAY_OPTS = {:array_prefix => '[', :line_prefix => ' ', :line_suffix => ',', :array_suffix => ']', :colsep => ', ', :arrange_vertical => false} + OLD_AND_NEW_KEYS = {:lineprefix => :line_prefix, :linesuffix => :line_suffix} + # TODO: change colfmt to cell_format; change colsep to something else + ATTRS = [:arrange_vertical, :array_prefix, :array_suffix, :line_prefix, :line_suffix, :colfmt, :colsep, :displaywidth, :ljust] + + attr_reader :list, :opts + + def initialize(list=[], opts={}) + self.list = list + self.opts = DEFAULT_OPTS.merge(opts) + end + + def list=(list) + @list = list + if @list.is_a? Array + @short_circuit = @list.empty? ? "\n" : nil + else + @short_circuit = '' + @list = [] + end + end + + # TODO: freeze @opts + def opts=(opts) + @opts = opts + OLD_AND_NEW_KEYS.each {|old, new| @opts[new] = @opts.delete(old) if @opts.keys.include?(old) and !@opts.keys.include?(new) } + @opts.merge!(ARRANGE_ARRAY_OPTS) if @opts[:arrange_array] + set_attrs_from_opts + end + + def update_opts(opts) + self.opts = @opts.merge(opts) + end + + def columnize + return @short_circuit if @short_circuit + + rows, colwidths = min_rows_and_colwidths + ncols = colwidths.length + justify = lambda {|t, c| + @ljust ? t.ljust(colwidths[c]) : t.rjust(colwidths[c]) + } + textify = lambda do |row| + row.map!.with_index(&justify) unless ncols == 1 && @ljust + "#{@line_prefix}#{row.join(@colsep)}#{@line_suffix}" + end + + text = rows.map(&textify) + text.first.sub!(/^#{@line_prefix}/, @array_prefix) unless @array_prefix.empty? + text.last.sub!(/#{@line_suffix}$/, @array_suffix) unless @array_suffix.empty? + text.join("\n") # + "\n" # if we want extra separation + end + + # TODO: make this a method, rather than a function (?) + # compute the smallest number of rows and the max widths for each column + def min_rows_and_colwidths + list = @list.map(&@stringify) + cell_widths = list.map(&@term_adjuster).map(&:size) + + # Set default arrangement: one atom per row + cell_width_max = cell_widths.max + result = [arrange_by_row(list, list.size, 1), [cell_width_max]] + + # If any atom > @displaywidth, stop and use one atom per row. + return result if cell_width_max > @displaywidth + + # For horizontal arrangement, we want to *maximize* the number + # of columns. Thus the candidate number of rows (+sizes+) starts + # at the minumum number of rows, 1, and increases. + + # For vertical arrangement, we want to *minimize* the number of + # rows. So here the candidate number of columns (+sizes+) starts + # at the maximum number of columns, list.length, and + # decreases. Also the roles of columns and rows are reversed + # from horizontal arrangement. + + # Loop from most compact arrangement to least compact, stopping + # at the first successful packing. The below code is tricky, + # but very cool. + # + # FIXME: In the below code could be DRY'd. (The duplication got + # introduced when I revised the code - rocky) + if @arrange_vertical + (1..list.length).each do |size| + other_size = (list.size + size - 1) / size + colwidths = arrange_by_row(cell_widths, other_size, size).map(&:max) + totwidth = colwidths.inject(&:+) + ((colwidths.length-1) * @colsep.length) + return [arrange_by_column(list, other_size, size), colwidths] if + totwidth <= @displaywidth + end + else + list.length.downto(1).each do |size| + other_size = (list.size + size - 1) / size + colwidths = arrange_by_column(cell_widths, other_size, size).map(&:max) + totwidth = colwidths.inject(&:+) + ((colwidths.length-1) * @colsep.length) + return [arrange_by_row(list, other_size, size), colwidths] if + totwidth <= @displaywidth + end + end + result + end + + # Given +list+, +ncols+, +nrows+, arrange the one-dimensional + # array into a 2-dimensional lists of lists organized by rows. + # + # In either horizontal or vertical arrangement, we will need to + # access this for the list data or for the width + # information. + # + # Here is an example: + # arrange_by_row((1..5).to_a, 3, 2) => + # [[1,2], [3,4], [5]], + def arrange_by_row(list, nrows, ncols) + (0...nrows).map {|r| list[r*ncols, ncols] }.compact + end + + # Given +list+, +ncols+, +nrows+, arrange the one-dimensional + # array into a 2-dimensional lists of lists organized by columns. + # + # In either horizontal or vertical arrangement, we will need to + # access this for the list data or for the width + # information. + # + # Here is an example: + # arrange_by_column((1..5).to_a, 2, 3) => + # [[1,3,5], [2,4]] + def arrange_by_column(list, nrows, ncols) + (0...ncols).map do |i| + (0..nrows-1).inject([]) do |row, j| + k = i + (j * ncols) + k < list.length ? row << list[k] : row + end + end + end + + def set_attrs_from_opts + ATTRS.each {|attr| self.instance_variable_set "@#{attr}", @opts[attr] } + + @ljust = !@list.all? {|datum| datum.kind_of?(Numeric)} if @ljust == :auto + @displaywidth -= @line_prefix.length + @displaywidth = @line_prefix.length + 4 if @displaywidth < 4 + @stringify = @colfmt ? lambda {|li| @colfmt % li } : lambda {|li| li.to_s } + @term_adjuster = @opts[:term_adjust] ? lambda {|c| c.gsub(/\e\[.*?m/, '') } : lambda {|c| c } + end + end +end + +# Demo +if __FILE__ == $0 + Columnize::DEFAULT_OPTS = {:line_prefix => '', :displaywidth => 80} + puts Columnize::Columnizer.new.arrange_by_row((1..5).to_a, 2, 3).inspect + puts Columnize::Columnizer.new.arrange_by_column((1..5).to_a, 2, 3).inspect +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/opts.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/opts.rb new file mode 100644 index 000000000..81e4c20d0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/opts.rb @@ -0,0 +1,35 @@ +module Columnize + computed_displaywidth = (ENV['COLUMNS'] || '80').to_i + computed_displaywidth = 80 unless computed_displaywidth >= 10 + + # When an option is not specified for the below keys, these are the defaults. + DEFAULT_OPTS = { + :arrange_array => false, + :arrange_vertical => true, + :array_prefix => '', + :array_suffix => '', + :colfmt => nil, + :colsep => ' ', + :displaywidth => computed_displaywidth, + :line_prefix => '', + :line_suffix => '', + :ljust => :auto, + :term_adjust => false + } + + # Options parsing routine for Columnize::columnize. In the preferred + # newer style, +args+ is a hash where each key is one of the option names. + # + # In the older style positional arguments are used and the positions + # are in the order: +displaywidth+, +colsep+, +arrange_vertical+, + # +ljust+, and +line_prefix+. + def self.parse_columnize_options(args) + if 1 == args.size && args[0].kind_of?(Hash) # explicitly passed as a hash + args[0] + elsif !args.empty? # passed as ugly positional parameters. + Hash[args.zip([:displaywidth, :colsep, :arrange_vertical, :ljust, :line_prefix]).map(&:reverse)] + else + {} + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/version.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/version.rb new file mode 100644 index 000000000..d98955305 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/lib/columnize/version.rb @@ -0,0 +1,7 @@ +# Sets constant Columnize::VERSION, the version number of +# this package. It is used in Gem creation but can also be consulted after +# require'ing 'columnize'. +module Columnize + # The current version of this package + VERSION = '0.9.0' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize-array.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize-array.rb new file mode 100755 index 000000000..2231fba6d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize-array.rb @@ -0,0 +1,48 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnize module +class TestColumnizeArray < Test::Unit::TestCase + # Ruby 1.8 form of require_relative + TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + ENV['COLUMNS'] = '80' + require File.join(TOP_SRC_DIR, 'columnize.rb') + + # test columnize + def test_arrange_array + data = (1..80).to_a + expect = "[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n" + + " 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,\n" + + " 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,\n" + + " 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]" + assert_equal(expect, + data.columnize(:arrange_array => true, :displaywidth => 80), + "columnize_opts -> arrange_array") + end + + def test_displaywidth + expect = "1 5 9\n" + + "2 6 10\n" + + "3 7\n" + + "4 8" + data = (1..10).to_a + assert_equal(expect, data.columnize(:displaywidth => 10), "displaywidth") + end + + def test_colfmt + expect = "[01, 02,\n" + + " 03, 04,\n" + + " 05, 06,\n" + + " 07, 08,\n" + + " 09, 10]" + data = (1..10).to_a + assert_equal(expect, data.columnize(:arrange_array => true, :colfmt => '%02d', :displaywidth => 10), "arrange_array, colfmt, displaywidth") + end + + def test_backwards_compatiblity + foo = [] + data = (1..11).to_a + expect = " 1 2 3\n 4 5 6\n 7 8 9\n10 11" + assert_equal expect, foo.columnize(data, :displaywidth => 10, :arrange_vertical => false) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize.rb new file mode 100755 index 000000000..7963b427f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnize.rb @@ -0,0 +1,74 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnize module +class TestColumnize < Test::Unit::TestCase + # Ruby 1.8 form of require_relative + TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + require File.join(TOP_SRC_DIR, 'columnize.rb') + + # test columnize + def test_basic + assert_equal("1, 2, 3", Columnize::columnize([1, 2, 3], 10, ', ')) + assert_equal("", Columnize::columnize(5)) + assert_equal("1 3\n2 4", Columnize::columnize(['1', '2', '3', '4'], 4)) + assert_equal("1 2\n3 4", Columnize::columnize(['1', '2', '3', '4'], 4, ' ', false)) + assert_equal("\n", Columnize::columnize([])) + + assert_equal("oneitem", Columnize::columnize(["oneitem"])) + + data = (0..54).map{|i| i.to_s} + assert_equal( + "0, 6, 12, 18, 24, 30, 36, 42, 48, 54\n" + + "1, 7, 13, 19, 25, 31, 37, 43, 49\n" + + "2, 8, 14, 20, 26, 32, 38, 44, 50\n" + + "3, 9, 15, 21, 27, 33, 39, 45, 51\n" + + "4, 10, 16, 22, 28, 34, 40, 46, 52\n" + + "5, 11, 17, 23, 29, 35, 41, 47, 53", + Columnize::columnize(data, 39, ', ', true, false)) + + assert_equal( + " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n" + + "10, 11, 12, 13, 14, 15, 16, 17, 18, 19\n" + + "20, 21, 22, 23, 24, 25, 26, 27, 28, 29\n" + + "30, 31, 32, 33, 34, 35, 36, 37, 38, 39\n" + + "40, 41, 42, 43, 44, 45, 46, 47, 48, 49\n" + + "50, 51, 52, 53, 54", + Columnize::columnize(data, 39, ', ', false, false)) + + + assert_equal( + " 0, 1, 2, 3, 4, 5, 6, 7, 8\n" + + " 9, 10, 11, 12, 13, 14, 15, 16, 17\n" + + " 18, 19, 20, 21, 22, 23, 24, 25, 26\n" + + " 27, 28, 29, 30, 31, 32, 33, 34, 35\n" + + " 36, 37, 38, 39, 40, 41, 42, 43, 44\n" + + " 45, 46, 47, 48, 49, 50, 51, 52, 53\n" + + " 54", + Columnize::columnize(data, 39, ', ', false, false, ' ')) + + + data = ["one", "two", "three", + "for", "five", "six", + "seven", "eight", "nine", + "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eightteen", + "nineteen", "twenty", "twentyone", + "twentytwo", "twentythree", "twentyfour", + "twentyfive","twentysix", "twentyseven"] + + assert_equal( +"one two three for five six \n" + +"seven eight nine ten eleven twelve \n" + +"thirteen fourteen fifteen sixteen seventeen eightteen \n" + +"nineteen twenty twentyone twentytwo twentythree twentyfour\n" + +"twentyfive twentysix twentyseven", Columnize::columnize(data, 80, ' ', false)) + + assert_equal( +"one five nine thirteen seventeen twentyone twentyfive \n" + +"two six ten fourteen eightteen twentytwo twentysix \n" + +"three seven eleven fifteen nineteen twentythree twentyseven\n" + +"for eight twelve sixteen twenty twentyfour ", Columnize::columnize(data, 80)) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnizer.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnizer.rb new file mode 100755 index 000000000..fe27f737c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-columnizer.rb @@ -0,0 +1,112 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnizer class +class TestColumnizer < Test::Unit::TestCase + TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + require File.join(TOP_SRC_DIR, 'columnize.rb') + + Columnize::Columnizer.class_eval 'attr_reader :stringify, :short_circuit, :term_adjuster' + Columnize::Columnizer.class_eval 'attr_reader *ATTRS' + + # SETTING OPTS IN INITIALIZE + def test_passed_in_opts + # passed in opts should be merged with DEFAULT_OPTS + c = Columnize::Columnizer.new([], :displaywidth => 15) + assert_equal false, c.opts[:term_adjust], 'term_adjust comes from DEFAULT_OPTS' + assert_equal 15, c.opts[:displaywidth], 'displaywidth should override DEFAULT_OPTS' + end + + def test_ljust_attr + c = Columnize::Columnizer.new([1,2,3], {:ljust => :auto}) + assert_equal false, c.ljust, 'ljust: :auto should transform to false when all values are numeric' + c = Columnize::Columnizer.new(['1', 2, 3], {:ljust => :auto}) + assert_equal true, c.ljust, 'ljust: :auto should transform to true when not all values are numeric' + c = Columnize::Columnizer.new([], {:ljust => false}) + assert_equal false, c.ljust, 'ljust: false should stay false' + c = Columnize::Columnizer.new([], {:ljust => true}) + assert_equal true, c.ljust, 'ljust: true should stay true' + end + + def test_stringify_attr + c = Columnize::Columnizer.new + assert_equal '1.0', c.stringify[1.0], 'without colfmt, should be to_s' + c.update_opts :colfmt => '%02d' + assert_equal '01', c.stringify[1.0], 'without colfmt, should be to_s' + end + + def test_short_circuit_attr + c = Columnize::Columnizer.new + assert_equal "\n", c.short_circuit, 'should explicitly state when empty' + c.list = 1 + assert_equal '', c.short_circuit, 'should be an empty string when not an array' + c.list = [1] + assert_equal nil, c.short_circuit, 'should be nil when list is good' + end + + def test_term_adjuster_attr + c = Columnize::Columnizer.new + assert_equal 'abc', c.term_adjuster['abc'] + assert_equal "\e[0;31mObject\e[0;4m", c.term_adjuster["\e[0;31mObject\e[0;4m"] + c.update_opts :term_adjust => true + assert_equal 'abc', c.term_adjuster['abc'] + assert_equal 'Object', c.term_adjuster["\e[0;31mObject\e[0;4m"] + end + + def test_displaywidth_attr + c = Columnize::Columnizer.new [], :displaywidth => 10, :line_prefix => ' ' + assert_equal 12, c.displaywidth, 'displaywidth within 4 of line_prefix.length' + c.update_opts :line_prefix => ' ' + assert_equal 8, c.displaywidth, 'displaywidth not within 4 of line_prefix.length' + end + + # COLUMNIZE + def test_columnize_with_short_circuit + msg = 'Johnny 5 is alive!' + c = Columnize::Columnizer.new + c.instance_variable_set(:@short_circuit, msg) + assert_equal msg, c.columnize, 'columnize should return short_circuit message if set' + end + + def test_columnize_applies_ljust + c = Columnize::Columnizer.new [1,2,3,10,20,30], :displaywidth => 10, :ljust => false, :arrange_vertical => false + assert_equal " 1 2 3\n10 20 30", c.columnize, "ljust: #{c.ljust}" + c.update_opts :ljust => true + assert_equal "1 2 3 \n10 20 30", c.columnize, "ljust: #{c.ljust}" + end + + def no_test_columnize_applies_colsep_and_prefix_and_suffix + c = Columnize::Columnizer.new [1,2,3] + assert_equal "1 2 3", c.columnize + c.update_opts :line_prefix => '>', :colsep => '-', :line_suffix => '<' + assert_equal ">1-2-3<", c.columnize + end + + def test_columnize_applies_array_prefix_and_suffix + c = Columnize::Columnizer.new [1,2,3] + assert_equal "1 2 3", c.columnize + c.update_opts :array_prefix => '>', :array_suffix => '<' + assert_equal ">1 2 3<", c.columnize + end + + # NOTE: min_rows_and_colwidths tested in test-min_rows_and_colwidths.rb + + # arrange_rows_and_cols + def test_arrange_rows_and_cols + rows = Columnize::Columnizer.new.arrange_by_row((1..9).to_a, 3, 3) + assert_equal [[1,2,3],[4,5,6],[7,8,9]], rows, 'rows for (1..9), 3, 3' + + cols = Columnize::Columnizer.new.arrange_by_column((1..9).to_a, 3, 3) + assert_equal [[1,4,7],[2,5,8],[3,6,9]], cols, 'cols for (1..9), 3, 3' + + rows = Columnize::Columnizer.new.arrange_by_row((1..5).to_a, 3, 2) + assert_equal [[1,2],[3,4],[5]], rows, 'rows for (1..5, 2, 3)' + + cols = Columnize::Columnizer.new.arrange_by_column((1..5).to_a, 3, 2) + assert_equal [[1,3,5],[2,4]], cols, 'cols for (1..5, 2, 3)' + end + + def test_set_attrs_from_opts + assert(true, 'test set_attrs_from_opts') + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-hashparm.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-hashparm.rb new file mode 100755 index 000000000..f2a8f4070 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-hashparm.rb @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnize module +class TestHashFormat < Test::Unit::TestCase + TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + require File.join(TOP_SRC_DIR, 'columnize.rb') + + def test_parse_columnize_options + assert Columnize.parse_columnize_options([{}]).kind_of?(Hash) + assert_equal 90, Columnize.parse_columnize_options([90])[:displaywidth] + opts = Columnize.parse_columnize_options([70, '|']) + assert_equal 70, opts[:displaywidth] + assert_equal '|', opts[:colsep] + end + + def test_new_hash + hash = {:displaywidth => 40, :colsep => ', ', :term_adjust => true,} + assert_equal(hash, Columnize.parse_columnize_options([hash]), "parse_columnize_options returns same hash it was passed") + end + + def test_array + data = (0..54).to_a + expected = "[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" + + " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n" + + " 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n" + + " 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\n" + + " 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,\n" + + " 50, 51, 52, 53, 54]" + assert_equal(expected, Columnize.columnize(data, :arrange_array => true, :ljust => false, :displaywidth => 39)) + end + + def test_justify + data = (0..54).to_a + expected = "[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" + + " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n" + + " 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n" + + " 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\n" + + " 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,\n" + + " 50, 51, 52, 53, 54]" + assert_equal(expected, Columnize.columnize(data, :arrange_array => true, :displaywidth => 39)) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-issue3.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-issue3.rb new file mode 100755 index 000000000..11034d59c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-issue3.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnize module for github issue #3 +class TestIssue3 < Test::Unit::TestCase + @@TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + require File.join(@@TOP_SRC_DIR, 'columnize.rb') + + # test columnize + def test_long_column + data = ["what's", "upppppppppppppppppp"] + data.columnize_opts = Columnize::DEFAULT_OPTS.merge :displaywidth => 7, :arrange_vertical => false + assert_equal("what's\nupppppppppppppppppp", data.columnize) + assert_equal("what's\nupppppppppppppppppp", data.columnize(:arrange_vertical => true)) + end + + def test_long_column_with_ljust + data = ["whaaaaaat's", "up"] + data.columnize_opts = Columnize::DEFAULT_OPTS.merge :displaywidth => 7, :arrange_vertical => false, :ljust => true + assert_equal("whaaaaaat's\nup", data.columnize) + assert_equal("whaaaaaat's\n up", data.columnize(:ljust => false)) + assert_equal("whaaaaaat's\nup", data.columnize(:arrange_vertical => true)) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-min_rows_and_colwidths.rb b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-min_rows_and_colwidths.rb new file mode 100755 index 000000000..cf2b57dee --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/columnize-0.9.0/test/test-min_rows_and_colwidths.rb @@ -0,0 +1,65 @@ +#!/usr/bin/env ruby +require 'test/unit' + +# Test of Columnize#min_rows_and_colwidths +class TestComputeRowsAndColwidths < Test::Unit::TestCase + # Ruby 1.8 form of require_relative + TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib') + require File.join(TOP_SRC_DIR, 'columnize.rb') + + VOPTS = Columnize::DEFAULT_OPTS.merge(:displaywidth => 80) + HOPTS = VOPTS.merge(:arrange_vertical => false) + + def min_rows_and_colwidths(list, opts) + Columnize::Columnizer.new(list, opts).min_rows_and_colwidths + end + + def test_colwidths + data = ["one", "two", "three", + "four", "five", "six", + "seven", "eight", "nine", + "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eightteen", + "nineteen", "twenty", "twentyone", + "twentytwo", "twentythree", "twentyfour", + "twentyfive","twentysix", "twentyseven"] + + [['horizontal', HOPTS, [10, 9, 11, 9, 11, 10], 5, 6], + ['vertical' , VOPTS, [5, 5, 6, 8, 9, 11, 11], 4, 7]].each do + |direction, opts, expect_colwidths, expect_rows, expect_cols| + rows, colwidths = min_rows_and_colwidths(data, opts) + assert_equal(expect_colwidths, colwidths, "colwidths - #{direction}") + assert_equal(expect_rows, rows.length, + "number of rows - #{direction}") + assert_equal(expect_cols, rows.first.length, + "number of cols - #{direction}") + end + end + + def test_horizontal_vs_vertical + data = (0..54).map{|i| i.to_s} + + [['horizontal', HOPTS.merge(:displaywidth => 39), [2,2,2,2,2,2,2,2,2,2]], + ['vertical' , VOPTS.merge(:displaywidth => 39), [1,2,2,2,2,2,2,2,2,2]]].each do + |direction, opts, expect| + rows, colwidths = min_rows_and_colwidths(data, opts) + assert_equal(expect, colwidths, "colwidths #{direction}") + assert_equal(6, rows.length, "number of rows - #{direction}") + assert_equal(10, rows.first.length, "number of cols - #{direction}") + end + end + + def test_displaywidth_smaller_than_largest_atom + data = ['a' * 100, 'b', 'c', 'd', 'e'] + + [['horizontal', HOPTS], + ['vertical' , VOPTS]].each do + |direction, opts| + rows, colwidths = min_rows_and_colwidths(data, opts) + assert_equal([100], colwidths, "colwidths #{direction}") + assert_equal(5, rows.length, "number of rows - #{direction}") + assert_equal(1, rows.first.length, "number of cols - #{direction}") + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.autotest b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.autotest new file mode 100644 index 000000000..1236395b2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.autotest @@ -0,0 +1,3 @@ +require 'rubygems' + +# vim: syntax=ruby diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.gemtest b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.gemtest new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.hoerc b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.hoerc new file mode 100644 index 000000000..0a135436b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.hoerc @@ -0,0 +1,2 @@ +--- +exclude: !ruby/regexp /(tmp|swp)$|CVS|TAGS|\.(svn|git|hg|DS_Store|idea)|Gemfile\.lock|research\/|\.gemspec$/ diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.rspec b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.rspec new file mode 100644 index 000000000..7438fbe51 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.rspec @@ -0,0 +1,2 @@ +--colour +--format documentation diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.travis.yml b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.travis.yml new file mode 100644 index 000000000..903cddfbd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/.travis.yml @@ -0,0 +1,22 @@ +--- +after_script: +- rake travis:after -t +before_script: +- gem install hoe-travis --no-rdoc --no-ri +- rake travis:before -t +language: ruby +notifications: + email: true +rvm: + - 2.0.0 + - 1.9.3 + - 1.9.2 + - ruby-head + - 1.8.7 + - jruby-19mode + - jruby-head + - jruby-18mode + - rbx-19mode + - rbx-18mode + - ree +script: rake travis diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Contributing.rdoc b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Contributing.rdoc new file mode 100644 index 000000000..a0f37defd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Contributing.rdoc @@ -0,0 +1,64 @@ +== Contributing + +I value any contribution to Diff::LCS you can provide: a bug report, a feature +request, or code contributions. + +Code contributions to Diff::LCS are especially welcomeencouraged. +Because Diff::LCS is a complex codebase, there are a few guidelines: + +* Changes will not be accepted without tests. +* The test suite is written with RSpec.‡ +* Match my coding style. +* Use a thoughtfully-named topic branch that contains your change. Rebase your + commits into logical chunks as necessary. +* Use {quality commit messages}[http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html]. +* Do not change the version number; when your patch is accepted and a release + is made, the version will be updated at that point. +* Submit a GitHub pull request with your changes. +* New features require new documentation. + +=== Test Dependencies + +To run the test suite, you will need to install the development dependencies +for Diff::LCS. If you have Bundler, you can accomplish this easily: + + $ bundle install + +Diff::LCS uses Ryan Davis’s excellent {Hoe}[https://github.com/seattlerb/hoe] +to manage the release process, and it adds a number of rake tasks. You will +mostly be interested in: + + $ rake + +which runs the tests the same way that: + + $ rake spec + $ rake test + $ rake travis + +will do. + +=== Workflow + +Here's the most direct way to get your work merged into the project: + +* Fork the project. +* Clone down your fork (+git clone git://github.com//diff-lcs.git+). +* Create a topic branch to contain your change (+git checkout -b my\_awesome\_feature+). +* Hack away, add tests. Not necessarily in that order. +* Make sure everything still passes by running `rake`. +* If necessary, rebase your commits into logical chunks, without errors. +* Push the branch up (+git push origin my\_awesome\_feature+). +* Create a pull request against halostatue/diff-lcs and describe what your + change does and the why you think it should be merged. + +=== Contributors + +* Austin Ziegler created Diff::LCS. + +Thanks to everyone else who has contributed to Diff::LCS: + +* Kenichi Kamiya +* Michael Granger +* Vít Ondruch +* Jon Rowe diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Gemfile b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Gemfile new file mode 100644 index 000000000..174f15f6c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Gemfile @@ -0,0 +1,20 @@ +# -*- ruby -*- + +# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`. + +source "https://rubygems.org/" + + +gem "rubyforge", ">=2.0.4", :group => [:development, :test] +gem "rdoc", "~>4.0", :group => [:development, :test] +gem "hoe-bundler", "~>1.2", :group => [:development, :test] +gem "hoe-doofus", "~>1.0", :group => [:development, :test] +gem "hoe-gemspec2", "~>1.1", :group => [:development, :test] +gem "hoe-git", "~>1.5", :group => [:development, :test] +gem "hoe-rubygems", "~>1.0", :group => [:development, :test] +gem "hoe-travis", "~>1.2", :group => [:development, :test] +gem "rake", "~>10.0", :group => [:development, :test] +gem "rspec", "~>2.0", :group => [:development, :test] +gem "hoe", "~>3.7", :group => [:development, :test] + +# vim: syntax=ruby diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/History.rdoc b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/History.rdoc new file mode 100644 index 000000000..69e5ddc4e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/History.rdoc @@ -0,0 +1,152 @@ +== 1.2.5 / 2013-11-08 + +* Bugs fixed: + * Comparing arrays flattened them too far, especially with Diff::LCS.sdiff. + https://github.com/halostatue/diff-lcs/pull/23 + +== 1.2.4 / 2013-04-20 + +* Bugs fixed: + * A bug was introduced after 1.1.3 when pruning common sequences at the start + of comparison. Paul Kunysch (@pck) fixed this in pull request 18. Thanks! + https://github.com/halostatue/diff-lcs/pull/18 +* The Rubinius (1.9 mode) bug in rubinius/rubinius#2268 has been fixed by the + Rubinius team two days after it was filed. Thanks for fixing this so quickly! + https://github.com/rubinius/rubinius/issues/2268 +* Switching to Raggi's hoe-gemspec2 for gemspec generation. + +== 1.2.3 / 2013-04-11 + +* Bugs Fixed: + * The new encoding detection for diff output generation (added in 1.2.2) + introduced a bug if the left side of the comparison was the empty set. + Originally found in rspec/rspec-expectations#238 and + rspec/rspec-expectations#239. Jon Rowe developed a reasonable heuristic + (left side, right side, empty string literal) to avoid this bug. + https://github.com/rspec/rspec-expectations/pull/238 + https://github.com/rspec/rspec-expectations/pull/239 +* There is a known issue with Rubinius in 1.9 mode reported in + rubinius/rubinius#2268 and demonstrated in the Travis CI builds. For all + other tested platforms, diff-lcs is considered stable. As soon as a suitably + small test-case can be created for the Rubinius team to examine, this will be + added to the Rubinius issue around this. + https://github.com/rubinius/rubinius/issues/2268 + https://travis-ci.org/halostatue/diff-lcs/jobs/6241195 + +== 1.2.2 / 2013-03-30 + +* Bugs Fixed: + * Diff::LCS::Hunk could not properly generate a difference for comparison + sets that are not US-ASCII-compatible because of the use of literal regular + expressions and strings. Jon Rowe (JonRowe) found this in + rspec/rspec-expectations#219 and provided a first pass implementation in + diff-lcs#15. I've reworked it because of test failures in Rubinius when + running in Ruby 1.9 mode. This coerces the added values to the encoding of + the old dataset (as determined by the first piece of the old dataset). + https://github.com/rspec/rspec-expectations/issues/219 + https://github.com/halostatue/diff-lcs/pull/15 +* Adding Travis CI testing for Ruby 2.0. + +== 1.2.1 / 2013-02-09 + +* Bugs Fixed: + * As seen in https://github.com/rspec/rspec-expectations/pull/200, the + release of Diff::LCS 1.2 introduced an unnecessary public API change to + Diff::LCS::Hunk (see the change at + https://github.com/rspec/rspec-expectations/commit/3d6fc82c for details). + The new method name (and behaviour) is more correct, but I should not have + renamed the function or should have at least provided an alias. This + release restores Diff::LCS::Hunk#unshift as an alias to + #merge. Note that the old #unshift behaviour was incorrect and will not be + restored. + +== 1.2.0 / 2013-01-21 +* Minor Enhancements: + * Added special case handling for Diff::LCS.patch so that it handles patches + that are empty or contain no changes. + * Added two new methods (#patch\_me and #unpatch\_me) to the includable + module. +* Bugs Fixed: + * Fixed issue #1 patch direction detection. + https://github.com/halostatue/diff-lcs/issues/1 + * Resolved issue #2 by handling string[string.size, 1] properly (it returns + "" not nil). https://github.com/halostatue/diff-lcs/issues/2 + * Michael Granger (ged) fixed an implementation error in Diff::LCS::Change + and added specs in pull request #8. Thanks! + https://github.com/halostatue/diff-lcs/issues/8 + * Made the code auto-testable. + * Vít Ondruch (voxik) provided the latest version of the GPL2 license file in + pull request #10. Thanks! https://github.com/halostatue/diff-lcs/issues/10 + * Fixed a documentation issue with the includable versions of #patch! and + #unpatch! where they implied that they would replace the original value. + Given that Diff::LCS.patch always returns a copy, the documentation was + incorrect and has been corrected. To provide the behaviour that was + originally documented, two new methods were added to provide this + behaviour. Found by scooter-dangle in issue #12. Thanks! + https://github.com/halostatue/diff-lcs/issues/12 +* Code Style Changes: + * Removed trailing spaces. + * Calling class methods using '.' instead of '::'. + * Vít Ondruch (voxik) removed unnecessary shebangs in pull request #9. + Thanks! https://github.com/halostatue/diff-lcs/issues/9 + * Kenichi Kamiya (kachick) removed some warnings of an unused variable in + lucky pull request #13. https://github.com/halostatue/diff-lcs/issues/13 + Thanks! + * Embarked on a major refactoring to make the files a little more manageable + and understand the code on a deeper level. + * Adding to http://travis-ci.org. + +== 1.1.3 / 2011-08-27 +* Converted to 'hoe' for release. +* Converted tests to RSpec 2. +* Extracted the body of htmldiff into a class available from + diff/lcs/htmldiff. +* Migrated development and issue tracking to GitHub. +* Bugs fixed: + - Eliminated the explicit use of RubyGems in both bin/htmldiff and bin/ldiff. + Resolves issue 4 (https://github.com/halostatue/diff-lcs/issues/4). + - Eliminated Ruby warnings. Resolves issue 3 + (https://github.com/halostatue/diff-lcs/issues/3). + +== 1.1.2 / 2004-10-20 +* Fixed a problem reported by Mauricio Fernandez in htmldiff. + +== 1.1.1 / 2004-09-25 +* Fixed bug #891: + http://rubyforge.org/tracker/?func=detail&atid=407&aid=891&group_id=84 +* Fixed a problem with callback initialisation code (it assumed that all + callbacks passed as classes can be initialised; now, it rescues + NoMethodError in the event of private :new being called). +* Modified the non-initialisable callbacks to have a private #new method. +* Moved ldiff core code to Diff::LCS::Ldiff (diff/lcs/ldiff.rb). + +== 1.1.0 / - +* Eliminated the need for Diff::LCS::Event and removed it. +* Added a contextual diff callback, Diff::LCS::ContextDiffCallback. +* Implemented patching/unpatching for standard Diff callback output formats + with both #diff and #sdiff. +* Extensive documentation changes. + +== 1.0.4 / - +* Fixed a problem with bin/ldiff output, especially for unified format. + Newlines that should have been present weren't. +* Changed the .tar.gz installer to generate Windows batch files if ones do not + exist already. Removed the existing batch files as they didn't work. + +== 1.0.3 / - +* Fixed a problem with #traverse\_sequences where the first difference from the + left sequence might not be appropriately captured. + +== 1.0.2 / - +* Fixed an issue with ldiff not working because actions were changed from + symbols to strings. + +== 1.0.1 / - +* Minor modifications to the gemspec, the README. +* Renamed the diff program to ldiff (as well as the companion batch file) so as + to not collide with the standard diff program. +* Fixed issues with RubyGems. Requires RubyGems > 0.6.1 or >= 0.6.1 with the + latest CVS version. + +== 1.0 / - +* Initial release based mostly on Perl's Algorithm::Diff. diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/License.rdoc b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/License.rdoc new file mode 100644 index 000000000..63b763dda --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/License.rdoc @@ -0,0 +1,39 @@ +== License + +This software is available under three licenses: the GNU GPL version 2 (or at +your option, a later version), the Perl Artistic license, or the MIT license. +Note that my preference for licensing is the MIT license, but Algorithm::Diff +was dually originally licensed with the Perl Artistic and the GNU GPL ("the +same terms as Perl itself") and given that the Ruby implementation originally +hewed pretty closely to the Perl version, I must maintain the additional +licensing terms. + +* Copyright 2004–2013 Austin Ziegler. +* Adapted from Algorithm::Diff (Perl) by Ned Konz and a Smalltalk version by + Mario I. Wolczko. + +=== MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +=== Perl Artistic License (version 2) +See the file docs/artistic.txt in the main distribution. + +=== GNU GPL version 2 +See the file docs/COPYING.txt in the main distribution. diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Manifest.txt b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Manifest.txt new file mode 100644 index 000000000..d078734a0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Manifest.txt @@ -0,0 +1,38 @@ +.autotest +.gemtest +.hoerc +.rspec +.travis.yml +Contributing.rdoc +Gemfile +History.rdoc +License.rdoc +Manifest.txt +README.rdoc +Rakefile +autotest/discover.rb +bin/htmldiff +bin/ldiff +docs/COPYING.txt +docs/artistic.txt +lib/diff-lcs.rb +lib/diff/lcs.rb +lib/diff/lcs/array.rb +lib/diff/lcs/block.rb +lib/diff/lcs/callbacks.rb +lib/diff/lcs/change.rb +lib/diff/lcs/htmldiff.rb +lib/diff/lcs/hunk.rb +lib/diff/lcs/internals.rb +lib/diff/lcs/ldiff.rb +lib/diff/lcs/string.rb +spec/change_spec.rb +spec/diff_spec.rb +spec/hunk_spec.rb +spec/issues_spec.rb +spec/lcs_spec.rb +spec/patch_spec.rb +spec/sdiff_spec.rb +spec/spec_helper.rb +spec/traverse_balanced_spec.rb +spec/traverse_sequences_spec.rb diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/README.rdoc b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/README.rdoc new file mode 100644 index 000000000..fd6964e1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/README.rdoc @@ -0,0 +1,85 @@ += Diff::LCS + +home :: http://diff-lcs.rubyforge.org/ +code :: https://github.com/halostatue/diff-lcs +bugs :: https://github.com/halostatue/diff-lcs/issues +rdoc :: http://rubydoc.info/github/halostatue/diff-lcs + +== Description + +Diff::LCS computes the difference between two Enumerable sequences using the +McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities +to create a simple HTML diff output format and a standard diff-like tool. + +This is release 1.2.4, fixing a bug introduced after diff-lcs 1.1.3 that did +not properly prune common sequences at the beginning of a comparison set. +Thanks to Paul Kunysch for fixing this issue. + +Coincident with the release of diff-lcs 1.2.3, we reported an issue with +Rubinius in 1.9 mode +({rubinius/rubinius#2268}[https://github.com/rubinius/rubinius/issues/2268]). +We are happy to report that this issue has been resolved. + +== Synopsis + +Using this module is quite simple. By default, Diff::LCS does not extend +objects with the Diff::LCS interface, but will be called as if it were a +function: + + require 'diff/lcs' + + seq1 = %w(a b c e h j l m n p) + seq2 = %w(b c d e f j k l m r s t) + + lcs = Diff::LCS.LCS(seq1, seq2) + diffs = Diff::LCS.diff(seq1, seq2) + sdiff = Diff::LCS.sdiff(seq1, seq2) + seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj) + bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj) + seq2 == Diff::LCS.patch!(seq1, diffs) + seq1 == Diff::LCS.unpatch!(seq2, diffs) + seq2 == Diff::LCS.patch!(seq1, sdiff) + seq1 == Diff::LCS.unpatch!(seq2, sdiff) + +Objects can be extended with Diff::LCS: + + seq1.extend(Diff::LCS) + lcs = seq1.lcs(seq2) + diffs = seq1.diff(seq2) + sdiff = seq1.sdiff(seq2) + seq = seq1.traverse_sequences(seq2, callback_obj) + bal = seq1.traverse_balanced(seq2, callback_obj) + seq2 == seq1.patch!(diffs) + seq1 == seq2.unpatch!(diffs) + seq2 == seq1.patch!(sdiff) + seq1 == seq2.unpatch!(sdiff) + +By requiring 'diff/lcs/array' or 'diff/lcs/string', Array or String will be +extended for use this way. + +Note that Diff::LCS requires a sequenced enumerable container, which means that +the order of enumeration is both predictable and consistent for the same set of +data. While it is theoretically possible to generate a diff for an unordered +hash, it will only be meaningful if the enumeration of the hashes is +consistent. In general, this will mean that containers that behave like String +or Array will perform best. + +== History + +Diff::LCS is a port of Perl's Algorithm::Diff that uses the McIlroy-Hunt +longest common subsequence (LCS) algorithm to compute intelligent differences +between two sequenced enumerable containers. The implementation is based on +Mario I. Wolczko's {Smalltalk version 1.2}[ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st] +(1993) and Ned Konz's Perl version +{Algorithm::Diff 1.15}[http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15/]. + +This library is called Diff::LCS because of an early version of Algorithm::Diff +which was restrictively licensed. + +== Continuous Integration Status + +{}[https://travis-ci.org/halostatue/diff-lcs] + +:include: Contributing.rdoc + +:include: License.rdoc diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Rakefile b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Rakefile new file mode 100644 index 000000000..51868002c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/Rakefile @@ -0,0 +1,41 @@ +# -*- ruby encoding: utf-8 -*- + +require 'rubygems' +require 'rspec' +require 'hoe' + +Hoe.plugin :bundler +Hoe.plugin :doofus +Hoe.plugin :email +Hoe.plugin :gemspec2 +Hoe.plugin :git +Hoe.plugin :rubyforge +Hoe.plugin :travis + +Hoe.spec 'diff-lcs' do + developer('Austin Ziegler', 'austin@rubyforge.org') + + self.remote_rdoc_dir = '.' + self.rsync_args << ' --exclude=statsvn/' + + self.history_file = 'History.rdoc' + self.readme_file = 'README.rdoc' + self.extra_rdoc_files = FileList["*.rdoc"].to_a + + %w(MIT Perl\ Artistic\ v2 GNU\ GPL\ v2).each { |l| self.license l } + + self.extra_dev_deps << ['hoe-bundler', '~> 1.2'] + self.extra_dev_deps << ['hoe-doofus', '~> 1.0'] + self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1'] + self.extra_dev_deps << ['hoe-git', '~> 1.5'] + self.extra_dev_deps << ['hoe-rubygems', '~> 1.0'] + self.extra_dev_deps << ['hoe-travis', '~> 1.2'] + self.extra_dev_deps << ['rake', '~> 10.0'] + self.extra_dev_deps << ['rspec', '~> 2.0'] +end + +unless Rake::Task.task_defined? :test + task :test => :spec +end + +# vim: syntax=ruby diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/autotest/discover.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/autotest/discover.rb new file mode 100644 index 000000000..cd6892ccb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/autotest/discover.rb @@ -0,0 +1 @@ +Autotest.add_discovery { "rspec2" } diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/htmldiff b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/htmldiff new file mode 100755 index 000000000..1e4efe716 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/htmldiff @@ -0,0 +1,32 @@ +#!ruby -w + +require 'diff/lcs' +require 'diff/lcs/htmldiff' + +begin + require 'text/format' +rescue LoadError + Diff::LCS::HTMLDiff.can_expand_tabs = false +end + +if ARGV.size < 2 or ARGV.size > 3 + $stderr.puts "usage: #{File.basename($0)} old new [output.html]" + $stderr.puts " #{File.basename($0)} old new > output.html" + exit 127 +end + +left = IO.read(ARGV[0]).split($/) +right = IO.read(ARGV[1]).split($/) + +options = { :title => "diff #{ARGV[0]} #{ARGV[1]}" } + +htmldiff = Diff::LCS::HTMLDiff.new(left, right, options) + +if ARGV[2] + File.open(ARGV[2], "w") do |f| + htmldiff.options[:output] = f + htmldiff.run + end +else + htmldiff.run +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/ldiff b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/ldiff new file mode 100755 index 000000000..a9b876fe7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/bin/ldiff @@ -0,0 +1,6 @@ +#!ruby -w + +require 'diff/lcs' +require 'diff/lcs/ldiff' + +exit Diff::LCS::Ldiff.run(ARGV) diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/COPYING.txt b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/COPYING.txt new file mode 100644 index 000000000..d159169d1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/COPYING.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/artistic.txt b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/artistic.txt new file mode 100644 index 000000000..c04639a83 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/docs/artistic.txt @@ -0,0 +1,127 @@ +The "Artistic License" + + Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to make +reasonable modifications. + +Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and +when you changed that file, and provided that you do at least ONE of the +following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this +Package. You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) software +distribution provided that you do not advertise this Package as a +product of your own. You may embed this Package's interpreter within +an executable of yours (by linking); this shall be construed as a mere +form of aggregation, provided that the complete Standard Version of the +interpreter is so embedded. + +6. The scripts and library files supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whoever generated +them, and may be sold commercially, and may be aggregated with this +Package. If such scripts or library files are aggregated with this +Package via the so-called "undump" or "unexec" methods of producing a +binary executable image, then distribution of such an image shall +neither be construed as a distribution of this Package nor shall it +fall under the restrictions of Paragraphs 3 and 4, provided that you do +not represent such an executable image as a Standard Version of this +Package. + +7. C subroutines (or comparably compiled subroutines in other +languages) supplied by you and linked into this Package in order to +emulate subroutines and variables of the language defined by this +Package shall not be considered part of this Package, but are the +equivalent of input as in Paragraph 6, provided these subroutines do +not change the language in any way that would cause it to fail the +regression tests for the language. + +8. Aggregation of this Package with a commercial distribution is always +permitted provided that the use of this Package is embedded; that is, +when no overt attempt is made to make this Package's interfaces visible +to the end user of the commercial distribution. Such use shall not be +construed as a distribution of this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff-lcs.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff-lcs.rb new file mode 100644 index 000000000..10d6e8a8a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff-lcs.rb @@ -0,0 +1,3 @@ +# -*- ruby encoding: utf-8 -*- + +require 'diff/lcs' diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs.rb new file mode 100644 index 000000000..555961512 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs.rb @@ -0,0 +1,805 @@ +# -*- ruby encoding: utf-8 -*- + +module Diff; end unless defined? Diff +# = Diff::LCS 1.2.5 +# +# Computes "intelligent" differences between two sequenced Enumerables. This +# is an implementation of the McIlroy-Hunt "diff" algorithm for Enumerable +# objects that include Diffable. +# +# Based on Mario I. Wolczko's Smalltalk version (1.2, 1993) and Ned Konz's +# Perl version (Algorithm::Diff 1.15). +# +# == Synopsis +# require 'diff/lcs' +# +# seq1 = %w(a b c e h j l m n p) +# seq2 = %w(b c d e f j k l m r s t) +# +# lcs = Diff::LCS.lcs(seq1, seq2) +# diffs = Diff::LCS.diff(seq1, seq2) +# sdiff = Diff::LCS.sdiff(seq1, seq2) +# seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj) +# bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj) +# seq2 == Diff::LCS.patch(seq1, diffs) +# seq2 == Diff::LCS.patch!(seq1, diffs) +# seq1 == Diff::LCS.unpatch(seq2, diffs) +# seq1 == Diff::LCS.unpatch!(seq2, diffs) +# seq2 == Diff::LCS.patch(seq1, sdiff) +# seq2 == Diff::LCS.patch!(seq1, sdiff) +# seq1 == Diff::LCS.unpatch(seq2, sdiff) +# seq1 == Diff::LCS.unpatch!(seq2, sdiff) +# +# Alternatively, objects can be extended with Diff::LCS: +# +# seq1.extend(Diff::LCS) +# lcs = seq1.lcs(seq2) +# diffs = seq1.diff(seq2) +# sdiff = seq1.sdiff(seq2) +# seq = seq1.traverse_sequences(seq2, callback_obj) +# bal = seq1.traverse_balanced(seq2, callback_obj) +# seq2 == seq1.patch(diffs) +# seq2 == seq1.patch!(diffs) +# seq1 == seq2.unpatch(diffs) +# seq1 == seq2.unpatch!(diffs) +# seq2 == seq1.patch(sdiff) +# seq2 == seq1.patch!(sdiff) +# seq1 == seq2.unpatch(sdiff) +# seq1 == seq2.unpatch!(sdiff) +# +# Default extensions are provided for Array and String objects through the +# use of 'diff/lcs/array' and 'diff/lcs/string'. +# +# == Introduction (by Mark-Jason Dominus) +# +# The following text is from the Perl documentation. The only changes +# have been to make the text appear better in Rdoc. +# +# I once read an article written by the authors of +diff+; they said that +# they hard worked very hard on the algorithm until they found the right +# one. +# +# I think what they ended up using (and I hope someone will correct me, +# because I am not very confident about this) was the `longest common +# subsequence' method. In the LCS problem, you have two sequences of items: +# +# a b c d f g h j q z +# a b c d e f g i j k r x y z +# +# and you want to find the longest sequence of items that is present in both +# original sequences in the same order. That is, you want to find a new +# sequence *S* which can be obtained from the first sequence by deleting +# some items, and from the second sequence by deleting other items. You also +# want *S* to be as long as possible. In this case *S* is: +# +# a b c d f g j z +# +# From there it's only a small step to get diff-like output: +# +# e h i k q r x y +# + - + + - + + + +# +# This module solves the LCS problem. It also includes a canned function to +# generate +diff+-like output. +# +# It might seem from the example above that the LCS of two sequences is +# always pretty obvious, but that's not always the case, especially when the +# two sequences have many repeated elements. For example, consider +# +# a x b y c z p d q +# a b c a x b y c z +# +# A naive approach might start by matching up the +a+ and +b+ that appear at +# the beginning of each sequence, like this: +# +# a x b y c z p d q +# a b c a b y c z +# +# This finds the common subsequence +a b c z+. But actually, the LCS is +a x +# b y c z+: +# +# a x b y c z p d q +# a b c a x b y c z +# +# == Author +# This version is by Austin Ziegler . +# +# It is based on the Perl Algorithm::Diff (1.15) by Ned Konz , copyright +# © 2000–2002 and the Smalltalk diff version by Mario I. +# Wolczko, copyright © 1993. Documentation includes work by +# Mark-Jason Dominus. +# +# == Licence +# Copyright © 2004–2013 Austin Ziegler +# This program is free software; you can redistribute it and/or modify it +# under the same terms as Ruby, or alternatively under the Perl Artistic +# licence. +# +# == Credits +# Much of the documentation is taken directly from the Perl Algorithm::Diff +# implementation and was written originally by Mark-Jason Dominus and later +# by Ned Konz. The basic Ruby implementation was re-ported from the +# Smalltalk implementation, available at +# ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st +# +# #sdiff and #traverse_balanced were written for the Perl version by Mike +# Schilli . +# +# "The algorithm is described in A Fast Algorithm for Computing Longest +# Common Subsequences, CACM, vol.20, no.5, pp.350-353, May +# 1977, with a few minor improvements to improve the speed." +module Diff::LCS + VERSION = '1.2.5' +end + +require 'diff/lcs/callbacks' +require 'diff/lcs/internals' + +module Diff::LCS + # Returns an Array containing the longest common subsequence(s) between + # +self+ and +other+. See Diff::LCS#LCS. + # + # lcs = seq1.lcs(seq2) + def lcs(other, &block) #:yields self[i] if there are matched subsequences: + Diff::LCS.lcs(self, other, &block) + end + + # Returns the difference set between +self+ and +other+. See + # Diff::LCS#diff. + def diff(other, callbacks = nil, &block) + Diff::LCS.diff(self, other, callbacks, &block) + end + + # Returns the balanced ("side-by-side") difference set between +self+ and + # +other+. See Diff::LCS#sdiff. + def sdiff(other, callbacks = nil, &block) + Diff::LCS.sdiff(self, other, callbacks, &block) + end + + # Traverses the discovered longest common subsequences between +self+ and + # +other+. See Diff::LCS#traverse_sequences. + def traverse_sequences(other, callbacks = nil, &block) + traverse_sequences(self, other, callbacks || + Diff::LCS.YieldingCallbacks, &block) + end + + # Traverses the discovered longest common subsequences between +self+ and + # +other+ using the alternate, balanced algorithm. See + # Diff::LCS#traverse_balanced. + def traverse_balanced(other, callbacks = nil, &block) + traverse_balanced(self, other, callbacks || + Diff::LCS.YieldingCallbacks, &block) + end + + # Attempts to patch +self+ with the provided +patchset+. A new sequence + # based on +self+ and the +patchset+ will be created. See Diff::LCS#patch. + # Attempts to autodiscover the direction of the patch. + def patch(patchset) + Diff::LCS.patch(self, patchset) + end + alias_method :unpatch, :patch + + # Attempts to patch +self+ with the provided +patchset+. A new sequence + # based on +self+ and the +patchset+ will be created. See Diff::LCS#patch. + # Does no patch direction autodiscovery. + def patch!(patchset) + Diff::LCS.patch!(self, patchset) + end + + # Attempts to unpatch +self+ with the provided +patchset+. A new sequence + # based on +self+ and the +patchset+ will be created. See Diff::LCS#unpatch. + # Does no patch direction autodiscovery. + def unpatch!(patchset) + Diff::LCS.unpatch!(self, patchset) + end + + # Attempts to patch +self+ with the provided +patchset+, using #patch!. If + # the sequence this is used on supports #replace, the value of +self+ will + # be replaced. See Diff::LCS#patch. Does no patch direction autodiscovery. + def patch_me(patchset) + if respond_to? :replace + replace(patch!(patchset)) + else + patch!(patchset) + end + end + + # Attempts to unpatch +self+ with the provided +patchset+, using + # #unpatch!. If the sequence this is used on supports #replace, the value + # of +self+ will be replaced. See Diff::LCS#unpatch. Does no patch direction + # autodiscovery. + def unpatch_me(patchset) + if respond_to? :replace + replace(unpatch!(patchset)) + else + unpatch!(patchset) + end + end +end + +class << Diff::LCS + def lcs(seq1, seq2, &block) #:yields seq1[i] for each matched: + matches = Diff::LCS::Internals.lcs(seq1, seq2) + ret = [] + string = seq1.kind_of? String + matches.each_with_index do |e, i| + unless matches[i].nil? + v = string ? seq1[i, 1] : seq1[i] + v = block[v] if block + ret << v + end + end + ret + end + alias_method :LCS, :lcs + + # #diff computes the smallest set of additions and deletions necessary to + # turn the first sequence into the second, and returns a description of + # these changes. + # + # See Diff::LCS::DiffCallbacks for the default behaviour. An alternate + # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a + # Class argument is provided for +callbacks+, #diff will attempt to + # initialise it. If the +callbacks+ object (possibly initialised) responds + # to #finish, it will be called. + def diff(seq1, seq2, callbacks = nil, &block) # :yields diff changes: + diff_traversal(:diff, seq1, seq2, callbacks || Diff::LCS::DiffCallbacks, + &block) + end + + # #sdiff computes all necessary components to show two sequences and their + # minimized differences side by side, just like the Unix utility + # sdiff does: + # + # old < - + # same same + # before | after + # - > new + # + # See Diff::LCS::SDiffCallbacks for the default behaviour. An alternate + # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a + # Class argument is provided for +callbacks+, #diff will attempt to + # initialise it. If the +callbacks+ object (possibly initialised) responds + # to #finish, it will be called. + def sdiff(seq1, seq2, callbacks = nil, &block) #:yields diff changes: + diff_traversal(:sdiff, seq1, seq2, callbacks || Diff::LCS::SDiffCallbacks, + &block) + end + + # #traverse_sequences is the most general facility provided by this + # module; #diff and #lcs are implemented as calls to it. + # + # The arguments to #traverse_sequences are the two sequences to traverse, + # and a callback object, like this: + # + # traverse_sequences(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new) + # + # == Callback Methods + # + # Optional callback methods are emphasized. + # + # callbacks#match:: Called when +a+ and +b+ are pointing to + # common elements in +A+ and +B+. + # callbacks#discard_a:: Called when +a+ is pointing to an + # element not in +B+. + # callbacks#discard_b:: Called when +b+ is pointing to an + # element not in +A+. + # callbacks#finished_a:: Called when +a+ has reached the end of + # sequence +A+. + # callbacks#finished_b:: Called when +b+ has reached the end of + # sequence +B+. + # + # == Algorithm + # + # a---+ + # v + # A = a b c e h j l m n p + # B = b c d e f j k l m r s t + # ^ + # b---+ + # + # If there are two arrows (+a+ and +b+) pointing to elements of sequences + # +A+ and +B+, the arrows will initially point to the first elements of + # their respective sequences. #traverse_sequences will advance the arrows + # through the sequences one element at a time, calling a method on the + # user-specified callback object before each advance. It will advance the + # arrows in such a way that if there are elements A[i] and + # B[j] which are both equal and part of the longest common + # subsequence, there will be some moment during the execution of + # #traverse_sequences when arrow +a+ is pointing to A[i] and + # arrow +b+ is pointing to B[j]. When this happens, + # #traverse_sequences will call callbacks#match and then it will + # advance both arrows. + # + # Otherwise, one of the arrows is pointing to an element of its sequence + # that is not part of the longest common subsequence. #traverse_sequences + # will advance that arrow and will call callbacks#discard_a or + # callbacks#discard_b, depending on which arrow it advanced. If + # both arrows point to elements that are not part of the longest common + # subsequence, then #traverse_sequences will advance one of them and call + # the appropriate callback, but it is not specified which it will call. + # + # The methods for callbacks#match, callbacks#discard_a, + # and callbacks#discard_b are invoked with an event comprising + # the action ("=", "+", or "-", respectively), the indicies +i+ and +j+, + # and the elements A[i] and B[j]. Return values are + # discarded by #traverse_sequences. + # + # === End of Sequences + # + # If arrow +a+ reaches the end of its sequence before arrow +b+ does, + # #traverse_sequence will try to call callbacks#finished_a with + # the last index and element of +A+ (A[-1]) and the current index + # and element of +B+ (B[j]). If callbacks#finished_a + # does not exist, then callbacks#discard_b will be called on each + # element of +B+ until the end of the sequence is reached (the call will + # be done with A[-1] and B[j] for each element). + # + # If +b+ reaches the end of +B+ before +a+ reaches the end of +A+, + # callbacks#finished_b will be called with the current index and + # element of +A+ (A[i]) and the last index and element of +B+ + # (A[-1]). Again, if callbacks#finished_b does not exist + # on the callback object, then callbacks#discard_a will be called + # on each element of +A+ until the end of the sequence is reached + # (A[i] and B[-1]). + # + # There is a chance that one additional callbacks#discard_a or + # callbacks#discard_b will be called after the end of the + # sequence is reached, if +a+ has not yet reached the end of +A+ or +b+ + # has not yet reached the end of +B+. + def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks, &block) #:yields change events: + callbacks ||= Diff::LCS::SequenceCallbacks + matches = Diff::LCS::Internals.lcs(seq1, seq2) + + run_finished_a = run_finished_b = false + string = seq1.kind_of?(String) + + a_size = seq1.size + b_size = seq2.size + ai = bj = 0 + + (0..matches.size).each do |i| + b_line = matches[i] + + ax = string ? seq1[i, 1] : seq1[i] + bx = string ? seq2[bj, 1] : seq2[bj] + + if b_line.nil? + unless ax.nil? or (string and ax.empty?) + event = Diff::LCS::ContextChange.new('-', i, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + end + else + loop do + break unless bj < b_line + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('+', i, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('=', i, ax, bj, bx) + event = yield event if block_given? + callbacks.match(event) + bj += 1 + end + ai = i + end + ai += 1 + + # The last entry (if any) processed was a match. +ai+ and +bj+ point + # just past the last matching lines in their sequences. + while (ai < a_size) or (bj < b_size) + # last A? + if ai == a_size and bj < b_size + if callbacks.respond_to?(:finished_a) and not run_finished_a + ax = string ? seq1[-1, 1] : seq1[-1] + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('>', (a_size - 1), ax, bj, bx) + event = yield event if block_given? + callbacks.finished_a(event) + run_finished_a = true + else + ax = string ? seq1[ai, 1] : seq1[ai] + loop do + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + break unless bj < b_size + end + end + end + + # last B? + if bj == b_size and ai < a_size + if callbacks.respond_to?(:finished_b) and not run_finished_b + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[-1, 1] : seq2[-1] + event = Diff::LCS::ContextChange.new('<', ai, ax, (b_size - 1), bx) + event = yield event if block_given? + callbacks.finished_b(event) + run_finished_b = true + else + bx = string ? seq2[bj, 1] : seq2[bj] + loop do + ax = string ? seq1[ai, 1] : seq1[ai] + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + break unless bj < b_size + end + end + end + + if ai < a_size + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + end + + if bj < b_size + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + end + end + + # #traverse_balanced is an alternative to #traverse_sequences. It uses a + # different algorithm to iterate through the entries in the computed + # longest common subsequence. Instead of viewing the changes as insertions + # or deletions from one of the sequences, #traverse_balanced will report + # changes between the sequences. + # + # The arguments to #traverse_balanced are the two sequences to traverse + # and a callback object, like this: + # + # traverse_balanced(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new) + # + # #sdiff is implemented with #traverse_balanced. + # + # == Callback Methods + # + # Optional callback methods are emphasized. + # + # callbacks#match:: Called when +a+ and +b+ are pointing to + # common elements in +A+ and +B+. + # callbacks#discard_a:: Called when +a+ is pointing to an + # element not in +B+. + # callbacks#discard_b:: Called when +b+ is pointing to an + # element not in +A+. + # callbacks#change:: Called when +a+ and +b+ are pointing to + # the same relative position, but + # A[a] and B[b] are not + # the same; a change has + # occurred. + # + # #traverse_balanced might be a bit slower than #traverse_sequences, + # noticable only while processing huge amounts of data. + # + # == Algorithm + # + # a---+ + # v + # A = a b c e h j l m n p + # B = b c d e f j k l m r s t + # ^ + # b---+ + # + # === Matches + # + # If there are two arrows (+a+ and +b+) pointing to elements of sequences + # +A+ and +B+, the arrows will initially point to the first elements of + # their respective sequences. #traverse_sequences will advance the arrows + # through the sequences one element at a time, calling a method on the + # user-specified callback object before each advance. It will advance the + # arrows in such a way that if there are elements A[i] and + # B[j] which are both equal and part of the longest common + # subsequence, there will be some moment during the execution of + # #traverse_sequences when arrow +a+ is pointing to A[i] and + # arrow +b+ is pointing to B[j]. When this happens, + # #traverse_sequences will call callbacks#match and then it will + # advance both arrows. + # + # === Discards + # + # Otherwise, one of the arrows is pointing to an element of its sequence + # that is not part of the longest common subsequence. #traverse_sequences + # will advance that arrow and will call callbacks#discard_a or + # callbacks#discard_b, depending on which arrow it advanced. + # + # === Changes + # + # If both +a+ and +b+ point to elements that are not part of the longest + # common subsequence, then #traverse_sequences will try to call + # callbacks#change and advance both arrows. If + # callbacks#change is not implemented, then + # callbacks#discard_a and callbacks#discard_b will be + # called in turn. + # + # The methods for callbacks#match, callbacks#discard_a, + # callbacks#discard_b, and callbacks#change are invoked + # with an event comprising the action ("=", "+", "-", or "!", + # respectively), the indicies +i+ and +j+, and the elements + # A[i] and B[j]. Return values are discarded by + # #traverse_balanced. + # + # === Context + # Note that +i+ and +j+ may not be the same index position, even if +a+ + # and +b+ are considered to be pointing to matching or changed elements. + def traverse_balanced(seq1, seq2, callbacks = Diff::LCS::BalancedCallbacks) + matches = Diff::LCS::Internals.lcs(seq1, seq2) + a_size = seq1.size + b_size = seq2.size + ai = bj = mb = 0 + ma = -1 + string = seq1.kind_of?(String) + + # Process all the lines in the match vector. + loop do + # Find next match indices +ma+ and +mb+ + loop do + ma += 1 + break unless ma < matches.size and matches[ma].nil? + end + + break if ma >= matches.size # end of matches? + mb = matches[ma] + + # Change(seq2) + while (ai < ma) or (bj < mb) + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[bj, 1] : seq2[bj] + + case [(ai < ma), (bj < mb)] + when [true, true] + if callbacks.respond_to?(:change) + event = Diff::LCS::ContextChange.new('!', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.change(event) + ai += 1 + bj += 1 + else + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + ax = string ? seq1[ai, 1] : seq1[ai] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + when [true, false] + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + when [false, true] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + end + + # Match + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[bj, 1] : seq2[bj] + event = Diff::LCS::ContextChange.new('=', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.match(event) + ai += 1 + bj += 1 + end + + while (ai < a_size) or (bj < b_size) + ax = string ? seq1[ai, 1] : seq1[ai] + bx = string ? seq2[bj, 1] : seq2[bj] + + case [(ai < a_size), (bj < b_size)] + when [true, true] + if callbacks.respond_to?(:change) + event = Diff::LCS::ContextChange.new('!', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.change(event) + ai += 1 + bj += 1 + else + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + ax = string ? seq1[ai, 1] : seq1[ai] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + when [true, false] + event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_a(event) + ai += 1 + when [false, true] + event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx) + event = yield event if block_given? + callbacks.discard_b(event) + bj += 1 + end + end + end + + PATCH_MAP = { #:nodoc: + :patch => { '+' => '+', '-' => '-', '!' => '!', '=' => '=' }, + :unpatch => { '+' => '-', '-' => '+', '!' => '!', '=' => '=' } + } + + # Applies a +patchset+ to the sequence +src+ according to the +direction+ + # (:patch or :unpatch), producing a new sequence. + # + # If the +direction+ is not specified, Diff::LCS::patch will attempt to + # discover the direction of the +patchset+. + # + # A +patchset+ can be considered to apply forward (:patch) if the + # following expression is true: + # + # patch(s1, diff(s1, s2)) -> s2 + # + # A +patchset+ can be considered to apply backward (:unpatch) if + # the following expression is true: + # + # patch(s2, diff(s1, s2)) -> s1 + # + # If the +patchset+ contains no changes, the +src+ value will be returned + # as either src.dup or +src+. A +patchset+ can be deemed as + # having no changes if the following predicate returns true: + # + # patchset.empty? or + # patchset.flatten.all? { |change| change.unchanged? } + # + # === Patchsets + # + # A +patchset+ is always an enumerable sequence of changes, hunks of + # changes, or a mix of the two. A hunk of changes is an enumerable + # sequence of changes: + # + # [ # patchset + # # change + # [ # hunk + # # change + # ] + # ] + # + # The +patch+ method accepts patchsets that are enumerable + # sequences containing either Diff::LCS::Change objects (or a subclass) or + # the array representations of those objects. Prior to application, array + # representations of Diff::LCS::Change objects will be reified. + def patch(src, patchset, direction = nil) + # Normalize the patchset. + has_changes, patchset = Diff::LCS::Internals.analyze_patchset(patchset) + + if not has_changes + return src.dup if src.respond_to? :dup + return src + end + + string = src.kind_of?(String) + # Start with a new empty type of the source's class + res = src.class.new + + direction ||= Diff::LCS::Internals.intuit_diff_direction(src, patchset) + + ai = bj = 0 + + patch_map = PATCH_MAP[direction] + + patchset.flatten.each do |change| + # Both Change and ContextChange support #action + action = patch_map[change.action] + + case change + when Diff::LCS::ContextChange + case direction + when :patch + el = change.new_element + op = change.old_position + np = change.new_position + when :unpatch + el = change.old_element + op = change.new_position + np = change.old_position + end + + case action + when '-' # Remove details from the old string + while ai < op + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + ai += 1 + when '+' + while bj < np + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + + res << el + bj += 1 + when '=' + # This only appears in sdiff output with the SDiff callback. + # Therefore, we only need to worry about dealing with a single + # element. + res << el + + ai += 1 + bj += 1 + when '!' + while ai < op + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + + bj += 1 + ai += 1 + + res << el + end + when Diff::LCS::Change + case action + when '-' + while ai < change.position + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + ai += 1 + when '+' + while bj < change.position + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + + bj += 1 + + res << change.element + end + end + end + + while ai < src.size + res << (string ? src[ai, 1] : src[ai]) + ai += 1 + bj += 1 + end + + res + end + + # Given a set of patchset, convert the current version to the prior + # version. Does no auto-discovery. + def unpatch!(src, patchset) + patch(src, patchset, :unpatch) + end + + # Given a set of patchset, convert the current version to the next + # version. Does no auto-discovery. + def patch!(src, patchset) + patch(src, patchset, :patch) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb new file mode 100644 index 000000000..1acd8c9b7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb @@ -0,0 +1,7 @@ +# -*- ruby encoding: utf-8 -*- + +require 'diff/lcs' + +class Array + include Diff::LCS +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb new file mode 100644 index 000000000..851872704 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb @@ -0,0 +1,37 @@ +# -*- ruby encoding: utf-8 -*- + +# A block is an operation removing, adding, or changing a group of items. +# Basically, this is just a list of changes, where each change adds or +# deletes a single item. Used by bin/ldiff. +class Diff::LCS::Block + attr_reader :changes, :insert, :remove + + def initialize(chunk) + @changes = [] + @insert = [] + @remove = [] + + chunk.each do |item| + @changes << item + @remove << item if item.deleting? + @insert << item if item.adding? + end + end + + def diff_size + @insert.size - @remove.size + end + + def op + case [@remove.empty?, @insert.empty?] + when [false, false] + '!' + when [false, true] + '-' + when [true, false] + '+' + else # [true, true] + '^' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb new file mode 100644 index 000000000..8eec5fc43 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb @@ -0,0 +1,322 @@ +# -*- ruby encoding: utf-8 -*- + +require 'diff/lcs/change' + +module Diff::LCS + # This callback object implements the default set of callback events, + # which only returns the event itself. Note that #finished_a and + # #finished_b are not implemented -- I haven't yet figured out where they + # would be useful. + # + # Note that this is intended to be called as is, e.g., + # + # Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks) + class DefaultCallbacks + class << self + # Called when two items match. + def match(event) + event + end + # Called when the old value is discarded in favour of the new value. + def discard_a(event) + event + end + # Called when the new value is discarded in favour of the old value. + def discard_b(event) + event + end + # Called when both the old and new values have changed. + def change(event) + event + end + + private :new + end + end + + # An alias for DefaultCallbacks that is used in + # Diff::LCS#traverse_sequences. + # + # Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks) + SequenceCallbacks = DefaultCallbacks + + # An alias for DefaultCallbacks that is used in + # Diff::LCS#traverse_balanced. + # + # Diff::LCS.LCS(seq1, seq2, Diff::LCS::BalancedCallbacks) + BalancedCallbacks = DefaultCallbacks + + def self.callbacks_for(callbacks) + callbacks.new rescue callbacks + end +end + +# This will produce a compound array of simple diff change objects. Each +# element in the #diffs array is a +hunk+ or +hunk+ array, where each +# element in each +hunk+ array is a single Change object representing the +# addition or removal of a single element from one of the two tested +# sequences. The +hunk+ provides the full context for the changes. +# +# diffs = Diff::LCS.diff(seq1, seq2) +# # This example shows a simplified array format. +# # [ [ [ '-', 0, 'a' ] ], # 1 +# # [ [ '+', 2, 'd' ] ], # 2 +# # [ [ '-', 4, 'h' ], # 3 +# # [ '+', 4, 'f' ] ], +# # [ [ '+', 6, 'k' ] ], # 4 +# # [ [ '-', 8, 'n' ], # 5 +# # [ '-', 9, 'p' ], +# # [ '+', 9, 'r' ], +# # [ '+', 10, 's' ], +# # [ '+', 11, 't' ] ] ] +# +# There are five hunks here. The first hunk says that the +a+ at position 0 +# of the first sequence should be deleted ('-'). The second hunk +# says that the +d+ at position 2 of the second sequence should be inserted +# ('+'). The third hunk says that the +h+ at position 4 of the +# first sequence should be removed and replaced with the +f+ from position 4 +# of the second sequence. The other two hunks are described similarly. +# +# === Use +# +# This callback object must be initialised and is used by the Diff::LCS#diff +# method. +# +# cbo = Diff::LCS::DiffCallbacks.new +# Diff::LCS.LCS(seq1, seq2, cbo) +# cbo.finish +# +# Note that the call to #finish is absolutely necessary, or the last set of +# changes will not be visible. Alternatively, can be used as: +# +# cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) } +# +# The necessary #finish call will be made. +# +# === Simplified Array Format +# +# The simplified array format used in the example above can be obtained +# with: +# +# require 'pp' +# pp diffs.map { |e| e.map { |f| f.to_a } } +class Diff::LCS::DiffCallbacks + # Returns the difference set collected during the diff process. + attr_reader :diffs + + def initialize # :yields self: + @hunk = [] + @diffs = [] + + if block_given? + begin + yield self + ensure + self.finish + end + end + end + + # Finalizes the diff process. If an unprocessed hunk still exists, then it + # is appended to the diff list. + def finish + finish_hunk + end + + def match(event) + finish_hunk + end + + def discard_a(event) + @hunk << Diff::LCS::Change.new('-', event.old_position, event.old_element) + end + + def discard_b(event) + @hunk << Diff::LCS::Change.new('+', event.new_position, event.new_element) + end + + def finish_hunk + @diffs << @hunk unless @hunk.empty? + @hunk = [] + end + private :finish_hunk +end + +# This will produce a compound array of contextual diff change objects. Each +# element in the #diffs array is a "hunk" array, where each element in each +# "hunk" array is a single change. Each change is a Diff::LCS::ContextChange +# that contains both the old index and new index values for the change. The +# "hunk" provides the full context for the changes. Both old and new objects +# will be presented for changed objects. +nil+ will be substituted for a +# discarded object. +# +# seq1 = %w(a b c e h j l m n p) +# seq2 = %w(b c d e f j k l m r s t) +# +# diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks) +# # This example shows a simplified array format. +# # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1 +# # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2 +# # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3 +# # [ '+', [ 5, nil ], [ 4, 'f' ] ] ], +# # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4 +# # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5 +# # [ '+', [ 9, nil ], [ 9, 'r' ] ], +# # [ '-', [ 9, 'p' ], [ 10, nil ] ], +# # [ '+', [ 10, nil ], [ 10, 's' ] ], +# # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ] +# +# The five hunks shown are comprised of individual changes; if there is a +# related set of changes, they are still shown individually. +# +# This callback can also be used with Diff::LCS#sdiff, which will produce +# results like: +# +# diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks) +# # This example shows a simplified array format. +# # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1 +# # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2 +# # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3 +# # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4 +# # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5 +# # [ "!", [ 9, "p" ], [ 10, "s" ] ], +# # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ] +# +# The five hunks are still present, but are significantly shorter in total +# presentation, because changed items are shown as changes ("!") instead of +# potentially "mismatched" pairs of additions and deletions. +# +# The result of this operation is similar to that of +# Diff::LCS::SDiffCallbacks. They may be compared as: +# +# s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" } +# c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten +# +# s == c # -> true +# +# === Use +# +# This callback object must be initialised and can be used by the +# Diff::LCS#diff or Diff::LCS#sdiff methods. +# +# cbo = Diff::LCS::ContextDiffCallbacks.new +# Diff::LCS.LCS(seq1, seq2, cbo) +# cbo.finish +# +# Note that the call to #finish is absolutely necessary, or the last set of +# changes will not be visible. Alternatively, can be used as: +# +# cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) } +# +# The necessary #finish call will be made. +# +# === Simplified Array Format +# +# The simplified array format used in the example above can be obtained +# with: +# +# require 'pp' +# pp diffs.map { |e| e.map { |f| f.to_a } } +class Diff::LCS::ContextDiffCallbacks < Diff::LCS::DiffCallbacks + def discard_a(event) + @hunk << Diff::LCS::ContextChange.simplify(event) + end + + def discard_b(event) + @hunk << Diff::LCS::ContextChange.simplify(event) + end + + def change(event) + @hunk << Diff::LCS::ContextChange.simplify(event) + end +end + +# This will produce a simple array of diff change objects. Each element in +# the #diffs array is a single ContextChange. In the set of #diffs provided +# by SDiffCallbacks, both old and new objects will be presented for both +# changed and unchanged objects. +nil+ will be substituted +# for a discarded object. +# +# The diffset produced by this callback, when provided to Diff::LCS#sdiff, +# will compute and display the necessary components to show two sequences +# and their minimized differences side by side, just like the Unix utility +# +sdiff+. +# +# same same +# before | after +# old < - +# - > new +# +# seq1 = %w(a b c e h j l m n p) +# seq2 = %w(b c d e f j k l m r s t) +# +# diffs = Diff::LCS.sdiff(seq1, seq2) +# # This example shows a simplified array format. +# # [ [ "-", [ 0, "a"], [ 0, nil ] ], +# # [ "=", [ 1, "b"], [ 0, "b" ] ], +# # [ "=", [ 2, "c"], [ 1, "c" ] ], +# # [ "+", [ 3, nil], [ 2, "d" ] ], +# # [ "=", [ 3, "e"], [ 3, "e" ] ], +# # [ "!", [ 4, "h"], [ 4, "f" ] ], +# # [ "=", [ 5, "j"], [ 5, "j" ] ], +# # [ "+", [ 6, nil], [ 6, "k" ] ], +# # [ "=", [ 6, "l"], [ 7, "l" ] ], +# # [ "=", [ 7, "m"], [ 8, "m" ] ], +# # [ "!", [ 8, "n"], [ 9, "r" ] ], +# # [ "!", [ 9, "p"], [ 10, "s" ] ], +# # [ "+", [ 10, nil], [ 11, "t" ] ] ] +# +# The result of this operation is similar to that of +# Diff::LCS::ContextDiffCallbacks. They may be compared as: +# +# s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" } +# c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten +# +# s == c # -> true +# +# === Use +# +# This callback object must be initialised and is used by the Diff::LCS#sdiff +# method. +# +# cbo = Diff::LCS::SDiffCallbacks.new +# Diff::LCS.LCS(seq1, seq2, cbo) +# +# As with the other initialisable callback objects, +# Diff::LCS::SDiffCallbacks can be initialised with a block. As there is no +# "fininishing" to be done, this has no effect on the state of the object. +# +# cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) } +# +# === Simplified Array Format +# +# The simplified array format used in the example above can be obtained +# with: +# +# require 'pp' +# pp diffs.map { |e| e.to_a } +class Diff::LCS::SDiffCallbacks + # Returns the difference set collected during the diff process. + attr_reader :diffs + + def initialize #:yields self: + @diffs = [] + yield self if block_given? + end + + def match(event) + @diffs << Diff::LCS::ContextChange.simplify(event) + end + + def discard_a(event) + @diffs << Diff::LCS::ContextChange.simplify(event) + end + + def discard_b(event) + @diffs << Diff::LCS::ContextChange.simplify(event) + end + + def change(event) + @diffs << Diff::LCS::ContextChange.simplify(event) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb new file mode 100644 index 000000000..4077095c2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb @@ -0,0 +1,177 @@ +# -*- ruby encoding: utf-8 -*- + +# Represents a simplistic (non-contextual) change. Represents the removal or +# addition of an element from either the old or the new sequenced +# enumerable. +class Diff::LCS::Change + # The only actions valid for changes are '+' (add), '-' (delete), '=' + # (no change), '!' (changed), '<' (tail changes from first sequence), or + # '>' (tail changes from second sequence). The last two ('<>') are only + # found with Diff::LCS::diff and Diff::LCS::sdiff. + VALID_ACTIONS = %W(+ - = ! > <) + + def self.valid_action?(action) + VALID_ACTIONS.include? action + end + + # Returns the action this Change represents. + attr_reader :action + + # Returns the position of the Change. + attr_reader :position + # Returns the sequence element of the Change. + attr_reader :element + + def initialize(*args) + @action, @position, @element = *args + + unless Diff::LCS::Change.valid_action?(@action) + raise "Invalid Change Action '#{@action}'" + end + raise "Invalid Position Type" unless @position.kind_of? Fixnum + end + + def inspect + to_a.inspect + end + + def to_a + [ @action, @position, @element ] + end + + def self.from_a(arr) + arr = arr.flatten(1) + case arr.size + when 5 + Diff::LCS::ContextChange.new(*(arr[0...5])) + when 3 + Diff::LCS::Change.new(*(arr[0...3])) + else + raise "Invalid change array format provided." + end + end + + include Comparable + + def ==(other) + (self.action == other.action) and + (self.position == other.position) and + (self.element == other.element) + end + + def <=>(other) + r = self.action <=> other.action + r = self.position <=> other.position if r.zero? + r = self.element <=> other.element if r.zero? + r + end + + def adding? + @action == '+' + end + + def deleting? + @action == '-' + end + + def unchanged? + @action == '=' + end + + def changed? + @action == '!' + end + + def finished_a? + @action == '>' + end + + def finished_b? + @action == '<' + end +end + +# Represents a contextual change. Contains the position and values of the +# elements in the old and the new sequenced enumerables as well as the action +# taken. +class Diff::LCS::ContextChange < Diff::LCS::Change + # We don't need these two values. + undef :position + undef :element + + # Returns the old position being changed. + attr_reader :old_position + # Returns the new position being changed. + attr_reader :new_position + # Returns the old element being changed. + attr_reader :old_element + # Returns the new element being changed. + attr_reader :new_element + + def initialize(*args) + @action, @old_position, @old_element, @new_position, @new_element = *args + + unless Diff::LCS::Change.valid_action?(@action) + raise "Invalid Change Action '#{@action}'" + end + unless @old_position.nil? or @old_position.kind_of? Fixnum + raise "Invalid (Old) Position Type" + end + unless @new_position.nil? or @new_position.kind_of? Fixnum + raise "Invalid (New) Position Type" + end + end + + def to_a + [ @action, + [ @old_position, @old_element ], + [ @new_position, @new_element ] + ] + end + + def inspect(*args) + to_a.inspect + end + + def self.from_a(arr) + Diff::LCS::Change.from_a(arr) + end + + # Simplifies a context change for use in some diff callbacks. '<' actions + # are converted to '-' and '>' actions are converted to '+'. + def self.simplify(event) + ea = event.to_a + + case ea[0] + when '-' + ea[2][1] = nil + when '<' + ea[0] = '-' + ea[2][1] = nil + when '+' + ea[1][1] = nil + when '>' + ea[0] = '+' + ea[1][1] = nil + end + + Diff::LCS::ContextChange.from_a(ea) + end + + def ==(other) + (@action == other.action) and + (@old_position == other.old_position) and + (@new_position == other.new_position) and + (@old_element == other.old_element) and + (@new_element == other.new_element) + end + + def <=>(other) + r = @action <=> other.action + r = @old_position <=> other.old_position if r.zero? + r = @new_position <=> other.new_position if r.zero? + r = @old_element <=> other.old_element if r.zero? + r = @new_element <=> other.new_element if r.zero? + r + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb new file mode 100644 index 000000000..56b972ccf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb @@ -0,0 +1,149 @@ +# -*- ruby encoding: utf-8 -*- + +require 'cgi' + +class Diff::LCS::HTMLDiff + class << self + attr_accessor :can_expand_tabs #:nodoc: + end + self.can_expand_tabs = true + + class Callbacks + attr_accessor :output + attr_accessor :match_class + attr_accessor :only_a_class + attr_accessor :only_b_class + + def initialize(output, options = {}) + @output = output + options ||= {} + + @match_class = options[:match_class] || "match" + @only_a_class = options[:only_a_class] || "only_a" + @only_b_class = options[:only_b_class] || "only_b" + end + + def htmlize(element, css_class) + element = " " if element.empty? + %Q|
#{element}
\n| + end + private :htmlize + + # This will be called with both lines are the same + def match(event) + @output << htmlize(event.old_element, :match_class) + end + + # This will be called when there is a line in A that isn't in B + def discard_a(event) + @output << htmlize(event.old_element, :only_a_class) + end + + # This will be called when there is a line in B that isn't in A + def discard_b(event) + @output << htmlize(event.new_element, :only_b_class) + end + end + + DEFAULT_OPTIONS = { + :expand_tabs => nil, + :output => nil, + :css => nil, + :title => nil, + } + + DEFAULT_CSS = <<-CSS +body { margin: 0; } +.diff +{ + border: 1px solid black; + margin: 1em 2em; +} +p +{ + margin-left: 2em; +} +pre +{ + padding-left: 1em; + margin: 0; + font-family: Inconsolata, Consolas, Lucida, Courier, monospaced; + white-space: pre; +} +.match { } +.only_a +{ + background-color: #fdd; + color: red; + text-decoration: line-through; +} +.only_b +{ + background-color: #ddf; + color: blue; + border-left: 3px solid blue +} +h1 { margin-left: 2em; } + CSS + + def initialize(left, right, options = nil) + @left = left + @right = right + @options = options + + @options = DEFAULT_OPTIONS.dup if @options.nil? + end + + def verify_options + @options[:expand_tabs] ||= 4 + @options[:expand_tabs] = 4 if @options[:expand_tabs] < 0 + + @options[:output] ||= $stdout + + @options[:css] ||= DEFAULT_CSS.dup + + @options[:title] ||= "diff" + end + private :verify_options + + attr_reader :options + + def run + verify_options + + if @options[:expand_tabs] > 0 && self.class.can_expand_tabs + formatter = Text::Format.new + formatter.tabstop = @options[:expand_tabs] + + @left = left.map { |line| formatter.expand(line.chomp) } + @right = right.map { |line| formatter.expand(line.chomp) } + end + + @left.map! { |line| CGI.escapeHTML(line.chomp) } + @right.map! { |line| CGI.escapeHTML(line.chomp) } + + @options[:output] << <<-OUTPUT + + + #{@options[:title]} + + + +

#{@options[:title]}

+

Legend: Only in Old  + Only in New

+
+ OUTPUT + + callbacks = Callbacks.new(@options[:output]) + Diff::LCS.traverse_sequences(@left, @right, callbacks) + + @options[:output] << <<-OUTPUT +
+ + + OUTPUT + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb new file mode 100644 index 000000000..05c3fb6bd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb @@ -0,0 +1,276 @@ +# -*- ruby encoding: utf-8 -*- + +require 'diff/lcs/block' + +# A Hunk is a group of Blocks which overlap because of the context +# surrounding each block. (So if we're not using context, every hunk will +# contain one block.) Used in the diff program (bin/diff). +class Diff::LCS::Hunk + # Create a hunk using references to both the old and new data, as well as + # the piece of data. + def initialize(data_old, data_new, piece, flag_context, file_length_difference) + # At first, a hunk will have just one Block in it + @blocks = [ Diff::LCS::Block.new(piece) ] + if String.method_defined?(:encoding) + @preferred_data_encoding = data_old.fetch(0, data_new.fetch(0,'') ).encoding + end + @data_old = data_old + @data_new = data_new + + before = after = file_length_difference + after += @blocks[0].diff_size + @file_length_difference = after # The caller must get this manually + + # Save the start & end of each array. If the array doesn't exist (e.g., + # we're only adding items in this block), then figure out the line + # number based on the line number of the other file and the current + # difference in file lengths. + if @blocks[0].remove.empty? + a1 = a2 = nil + else + a1 = @blocks[0].remove[0].position + a2 = @blocks[0].remove[-1].position + end + + if @blocks[0].insert.empty? + b1 = b2 = nil + else + b1 = @blocks[0].insert[0].position + b2 = @blocks[0].insert[-1].position + end + + @start_old = a1 || (b1 - before) + @start_new = b1 || (a1 + before) + @end_old = a2 || (b2 - after) + @end_new = b2 || (a2 + after) + + self.flag_context = flag_context + end + + attr_reader :blocks + attr_reader :start_old, :start_new + attr_reader :end_old, :end_new + attr_reader :file_length_difference + + # Change the "start" and "end" fields to note that context should be added + # to this hunk. + attr_accessor :flag_context + undef :flag_context=; + def flag_context=(context) #:nodoc: + return if context.nil? or context.zero? + + add_start = (context > @start_old) ? @start_old : context + @start_old -= add_start + @start_new -= add_start + + if (@end_old + context) > @data_old.size + add_end = @data_old.size - @end_old + else + add_end = context + end + @end_old += add_end + @end_new += add_end + end + + # Merges this hunk and the provided hunk together if they overlap. Returns + # a truthy value so that if there is no overlap, you can know the merge + # was skipped. + def merge(hunk) + if overlaps?(hunk) + @start_old = hunk.start_old + @start_new = hunk.start_new + blocks.unshift(*hunk.blocks) + else + nil + end + end + alias_method :unshift, :merge + + # Determines whether there is an overlap between this hunk and the + # provided hunk. This will be true if the difference between the two hunks + # start or end positions is within one position of each other. + def overlaps?(hunk) + hunk and (((@start_old - hunk.end_old) <= 1) or + ((@start_new - hunk.end_new) <= 1)) + end + + # Returns a diff string based on a format. + def diff(format) + case format + when :old + old_diff + when :unified + unified_diff + when :context + context_diff + when :ed + self + when :reverse_ed, :ed_finish + ed_diff(format) + else + raise "Unknown diff format #{format}." + end + end + + # Note that an old diff can't have any context. Therefore, we know that + # there's only one block in the hunk. + def old_diff + warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1 + op_act = { "+" => 'a', "-" => 'd', "!" => "c" } + + block = @blocks[0] + + # Calculate item number range. Old diff range is just like a context + # diff range, except the ranges are on one line with the action between + # them. + s = encode("#{context_range(:old)}#{op_act[block.op]}#{context_range(:new)}\n") + # If removing anything, just print out all the remove lines in the hunk + # which is just all the remove lines in the block. + @data_old[@start_old .. @end_old].each { |e| s << encode("< ") + e + encode("\n") } unless block.remove.empty? + s << encode("---\n") if block.op == "!" + @data_new[@start_new .. @end_new].each { |e| s << encode("> ") + e + encode("\n") } unless block.insert.empty? + s + end + private :old_diff + + def unified_diff + # Calculate item number range. + s = encode("@@ -#{unified_range(:old)} +#{unified_range(:new)} @@\n") + + # Outlist starts containing the hunk of the old file. Removing an item + # just means putting a '-' in front of it. Inserting an item requires + # getting it from the new file and splicing it in. We splice in + # +num_added+ items. Remove blocks use +num_added+ because splicing + # changed the length of outlist. + # + # We remove +num_removed+ items. Insert blocks use +num_removed+ + # because their item numbers -- corresponding to positions in the NEW + # file -- don't take removed items into account. + lo, hi, num_added, num_removed = @start_old, @end_old, 0, 0 + + outlist = @data_old[lo .. hi].map { |e| e.insert(0, encode(' ')) } + + @blocks.each do |block| + block.remove.each do |item| + op = item.action.to_s # - + offset = item.position - lo + num_added + outlist[offset][0, 1] = encode(op) + num_removed += 1 + end + block.insert.each do |item| + op = item.action.to_s # + + offset = item.position - @start_new + num_removed + outlist[offset, 0] = encode(op) + @data_new[item.position] + num_added += 1 + end + end + + s << outlist.join(encode("\n")) + end + private :unified_diff + + def context_diff + s = encode("***************\n") + s << encode("*** #{context_range(:old)} ****\n") + r = context_range(:new) + + # Print out file 1 part for each block in context diff format if there + # are any blocks that remove items + lo, hi = @start_old, @end_old + removes = @blocks.select { |e| not e.remove.empty? } + if removes + outlist = @data_old[lo .. hi].map { |e| e.insert(0, encode(' ')) } + + removes.each do |block| + block.remove.each do |item| + outlist[item.position - lo][0, 1] = encode(block.op) # - or ! + end + end + s << outlist.join("\n") + end + + s << encode("\n--- #{r} ----\n") + lo, hi = @start_new, @end_new + inserts = @blocks.select { |e| not e.insert.empty? } + if inserts + outlist = @data_new[lo .. hi].collect { |e| e.insert(0, encode(' ')) } + inserts.each do |block| + block.insert.each do |item| + outlist[item.position - lo][0, 1] = encode(block.op) # + or ! + end + end + s << outlist.join("\n") + end + s + end + private :context_diff + + def ed_diff(format) + op_act = { "+" => 'a', "-" => 'd', "!" => "c" } + warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1 + + if format == :reverse_ed + s = encode("#{op_act[@blocks[0].op]}#{context_range(:old)}\n") + else + s = encode("#{context_range(:old, ' ')}#{op_act[@blocks[0].op]}\n") + end + + unless @blocks[0].insert.empty? + @data_new[@start_new .. @end_new].each { |e| s << e + encode("\n") } + s << encode(".\n") + end + s + end + private :ed_diff + + # Generate a range of item numbers to print. Only print 1 number if the + # range has only one item in it. Otherwise, it's 'start,end' + def context_range(mode, op = ',') + case mode + when :old + s, e = (@start_old + 1), (@end_old + 1) + when :new + s, e = (@start_new + 1), (@end_new + 1) + end + + (s < e) ? "#{s}#{op}#{e}" : "#{e}" + end + private :context_range + + # Generate a range of item numbers to print for unified diff. Print number + # where block starts, followed by number of lines in the block + # (don't print number of lines if it's 1) + def unified_range(mode) + case mode + when :old + s, e = (@start_old + 1), (@end_old + 1) + when :new + s, e = (@start_new + 1), (@end_new + 1) + end + + length = e - s + 1 + first = (length < 2) ? e : s # "strange, but correct" + (length == 1) ? "#{first}" : "#{first},#{length}" + end + private :unified_range + + if String.method_defined?(:encoding) + def encode(literal, target_encoding = @preferred_data_encoding) + literal.encode target_encoding + end + + def encode_as(string, *args) + args.map { |arg| arg.encode(string.encoding) } + end + else + def encode(literal, target_encoding = nil) + literal + end + def encode_as(string, *args) + args + end + end + + private :encode + private :encode_as +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb new file mode 100644 index 000000000..9d9e3f341 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb @@ -0,0 +1,301 @@ +# -*- ruby encoding: utf-8 -*- + +class << Diff::LCS + def diff_traversal(method, seq1, seq2, callbacks, &block) + callbacks = callbacks_for(callbacks) + case method + when :diff + traverse_sequences(seq1, seq2, callbacks) + when :sdiff + traverse_balanced(seq1, seq2, callbacks) + end + callbacks.finish if callbacks.respond_to? :finish + + if block + callbacks.diffs.map do |hunk| + if hunk.kind_of? Array + hunk.map { |hunk_block| block[hunk_block] } + else + block[hunk] + end + end + else + callbacks.diffs + end + end + private :diff_traversal +end + +module Diff::LCS::Internals # :nodoc: +end + +class << Diff::LCS::Internals + # Compute the longest common subsequence between the sequenced + # Enumerables +a+ and +b+. The result is an array whose contents is such + # that + # + # result = Diff::LCS::Internals.lcs(a, b) + # result.each_with_index do |e, i| + # assert_equal(a[i], b[e]) unless e.nil? + # end + def lcs(a, b) + a_start = b_start = 0 + a_finish = a.size - 1 + b_finish = b.size - 1 + vector = [] + + # Prune off any common elements at the beginning... + while ((a_start <= a_finish) and (b_start <= b_finish) and + (a[a_start] == b[b_start])) + vector[a_start] = b_start + a_start += 1 + b_start += 1 + end + b_start = a_start + + # Now the end... + while ((a_start <= a_finish) and (b_start <= b_finish) and + (a[a_finish] == b[b_finish])) + vector[a_finish] = b_finish + a_finish -= 1 + b_finish -= 1 + end + + # Now, compute the equivalence classes of positions of elements. + b_matches = position_hash(b, b_start..b_finish) + + thresh = [] + links = [] + string = a.kind_of?(String) + + (a_start .. a_finish).each do |i| + ai = string ? a[i, 1] : a[i] + bm = b_matches[ai] + k = nil + bm.reverse_each do |j| + if k and (thresh[k] > j) and (thresh[k - 1] < j) + thresh[k] = j + else + k = replace_next_larger(thresh, j, k) + end + links[k] = [ (k > 0) ? links[k - 1] : nil, i, j ] unless k.nil? + end + end + + unless thresh.empty? + link = links[thresh.size - 1] + while not link.nil? + vector[link[1]] = link[2] + link = link[0] + end + end + + vector + end + + # This method will analyze the provided patchset to provide a + # single-pass normalization (conversion of the array form of + # Diff::LCS::Change objects to the object form of same) and detection of + # whether the patchset represents changes to be made. + def analyze_patchset(patchset, depth = 0) + raise "Patchset too complex" if depth > 1 + + has_changes = false + + # Format: + # [ # patchset + # # hunk (change) + # [ # hunk + # # change + # ] + # ] + + patchset = patchset.map do |hunk| + case hunk + when Diff::LCS::Change + has_changes ||= !hunk.unchanged? + hunk + when Array + # Detect if the 'hunk' is actually an array-format + # Change object. + if Diff::LCS::Change.valid_action? hunk[0] + hunk = Diff::LCS::Change.from_a(hunk) + has_changes ||= !hunk.unchanged? + hunk + else + with_changes, hunk = analyze_patchset(hunk, depth + 1) + has_changes ||= with_changes + hunk.flatten + end + else + raise ArgumentError, "Cannot normalise a hunk of class #{hunk.class}." + end + end + + [ has_changes, patchset.flatten(1) ] + end + + # Examine the patchset and the source to see in which direction the + # patch should be applied. + # + # WARNING: By default, this examines the whole patch, so this could take + # some time. This also works better with Diff::LCS::ContextChange or + # Diff::LCS::Change as its source, as an array will cause the creation + # of one of the above. + # + # Note: This will be deprecated as a public function in a future release. + def intuit_diff_direction(src, patchset, limit = nil) + string = src.kind_of?(String) + count = left_match = left_miss = right_match = right_miss = 0 + + patchset.each do |change| + count += 1 + + case change + when Diff::LCS::ContextChange + le = string ? src[change.old_position, 1] : src[change.old_position] + re = string ? src[change.new_position, 1] : src[change.new_position] + + case change.action + when '-' # Remove details from the old string + if le == change.old_element + left_match += 1 + else + left_miss += 1 + end + when '+' + if re == change.new_element + right_match += 1 + else + right_miss += 1 + end + when '=' + left_miss += 1 if le != change.old_element + right_miss += 1 if re != change.new_element + when '!' + if le == change.old_element + left_match += 1 + else + if re == change.new_element + right_match += 1 + else + left_miss += 1 + right_miss += 1 + end + end + end + when Diff::LCS::Change + # With a simplistic change, we can't tell the difference between + # the left and right on '!' actions, so we ignore those. On '=' + # actions, if there's a miss, we miss both left and right. + element = string ? src[change.position, 1] : src[change.position] + + case change.action + when '-' + if element == change.element + left_match += 1 + else + left_miss += 1 + end + when '+' + if element == change.element + right_match += 1 + else + right_miss += 1 + end + when '=' + if element != change.element + left_miss += 1 + right_miss += 1 + end + end + end + + break if (not limit.nil?) && (count > limit) + end + + no_left = (left_match == 0) && (left_miss > 0) + no_right = (right_match == 0) && (right_miss > 0) + + case [no_left, no_right] + when [false, true] + :patch + when [true, false] + :unpatch + else + case left_match <=> right_match + when 1 + :patch + when -1 + :unpatch + else + raise "The provided patchset does not appear to apply to the provided value as either source or destination value." + end + end + end + + # Find the place at which +value+ would normally be inserted into the + # Enumerable. If that place is already occupied by +value+, do nothing + # and return +nil+. If the place does not exist (i.e., it is off the end + # of the Enumerable), add it to the end. Otherwise, replace the element + # at that point with +value+. It is assumed that the Enumerable's values + # are numeric. + # + # This operation preserves the sort order. + def replace_next_larger(enum, value, last_index = nil) + # Off the end? + if enum.empty? or (value > enum[-1]) + enum << value + return enum.size - 1 + end + + # Binary search for the insertion point + last_index ||= enum.size + first_index = 0 + while (first_index <= last_index) + i = (first_index + last_index) >> 1 + + found = enum[i] + + if value == found + return nil + elsif value > found + first_index = i + 1 + else + last_index = i - 1 + end + end + + # The insertion point is in first_index; overwrite the next larger + # value. + enum[first_index] = value + return first_index + end + private :replace_next_larger + + # If +vector+ maps the matching elements of another collection onto this + # Enumerable, compute the inverse of +vector+ that maps this Enumerable + # onto the collection. (Currently unused.) + def inverse_vector(a, vector) + inverse = a.dup + (0...vector.size).each do |i| + inverse[vector[i]] = i unless vector[i].nil? + end + inverse + end + private :inverse_vector + + # Returns a hash mapping each element of an Enumerable to the set of + # positions it occupies in the Enumerable, optionally restricted to the + # elements specified in the range of indexes specified by +interval+. + def position_hash(enum, interval) + string = enum.kind_of?(String) + hash = Hash.new { |h, k| h[k] = [] } + interval.each do |i| + k = string ? enum[i, 1] : enum[i] + hash[k] << i + end + hash + end + private :position_hash +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb new file mode 100644 index 000000000..fff325a5b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb @@ -0,0 +1,195 @@ +# -*- ruby encoding: utf-8 -*- + +require 'optparse' +require 'ostruct' +require 'diff/lcs/hunk' + +# == ldiff Usage +# ldiff [options] oldfile newfile +# +# -c:: Displays a context diff with 3 lines of context. +# -C [LINES], --context [LINES]:: Displays a context diff with LINES lines of context. Default 3 lines. +# -u:: Displays a unified diff with 3 lines of context. +# -U [LINES], --unified [LINES]:: Displays a unified diff with LINES lines of context. Default 3 lines. +# -e:: Creates an 'ed' script to change oldfile to newfile. +# -f:: Creates an 'ed' script to change oldfile to newfile in reverse order. +# -a, --text:: Treats the files as text and compares them line-by-line, even if they do not seem to be text. +# --binary:: Treats the files as binary. +# -q, --brief:: Reports only whether or not the files differ, not the details. +# --help:: Shows the command-line help. +# --version:: Shows the version of Diff::LCS. +# +# By default, runs produces an "old-style" diff, with output like UNIX diff. +# +# == Copyright +# Copyright © 2004 Austin Ziegler +# +# Part of Diff::LCS +# Austin Ziegler +# +# This program is free software. It may be redistributed and/or modified under +# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the +# Ruby licence. +module Diff::LCS::Ldiff + BANNER = <<-COPYRIGHT +ldiff #{Diff::LCS::VERSION} + Copyright 2004-2013 Austin Ziegler + + Part of Diff::LCS. + http://rubyforge.org/projects/ruwiki/ + + Austin Ziegler + + This program is free software. It may be redistributed and/or modified under + the terms of the GPL version 2 (or later), the Perl Artistic licence, or the + MIT licence. + COPYRIGHT +end + +class << Diff::LCS::Ldiff + attr_reader :format, :lines #:nodoc: + attr_reader :file_old, :file_new #:nodoc: + attr_reader :data_old, :data_new #:nodoc: + + def run(args, input = $stdin, output = $stdout, error = $stderr) #:nodoc: + @binary = nil + + args.options do |o| + o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile" + o.separator "" + o.on('-c', '-C', '--context [LINES]', Numeric, 'Displays a context diff with LINES lines', 'of context. Default 3 lines.') do |ctx| + @format = :context + @lines = ctx || 3 + end + o.on('-u', '-U', '--unified [LINES]', Numeric, 'Displays a unified diff with LINES lines', 'of context. Default 3 lines.') do |ctx| + @format = :unified + @lines = ctx || 3 + end + o.on('-e', 'Creates an \'ed\' script to change', 'oldfile to newfile.') do |ctx| + @format = :ed + end + o.on('-f', 'Creates an \'ed\' script to change', 'oldfile to newfile in reverse order.') do |ctx| + @format = :reverse_ed + end + o.on('-a', '--text', 'Treat the files as text and compare them', 'line-by-line, even if they do not seem', 'to be text.') do |txt| + @binary = false + end + o.on('--binary', 'Treats the files as binary.') do |bin| + @binary = true + end + o.on('-q', '--brief', 'Report only whether or not the files', 'differ, not the details.') do |ctx| + @format = :report + end + o.on_tail('--help', 'Shows this text.') do + error << o + return 0 + end + o.on_tail('--version', 'Shows the version of Diff::LCS.') do + error << BANNER + return 0 + end + o.on_tail "" + o.on_tail 'By default, runs produces an "old-style" diff, with output like UNIX diff.' + o.parse! + end + + unless args.size == 2 + error << args.options + return 127 + end + + # Defaults are for old-style diff + @format ||= :old + @lines ||= 0 + + file_old, file_new = *ARGV + + case @format + when :context + char_old = '*' * 3 + char_new = '-' * 3 + when :unified + char_old = '-' * 3 + char_new = '+' * 3 + end + + # After we've read up to a certain point in each file, the number of + # items we've read from each file will differ by FLD (could be 0). + file_length_difference = 0 + + if @binary.nil? or @binary + data_old = IO::read(file_old) + data_new = IO::read(file_new) + + # Test binary status + if @binary.nil? + old_txt = data_old[0...4096].scan(/\0/).empty? + new_txt = data_new[0...4096].scan(/\0/).empty? + @binary = (not old_txt) or (not new_txt) + old_txt = new_txt = nil + end + + unless @binary + data_old = data_old.split($/).map { |e| e.chomp } + data_new = data_new.split($/).map { |e| e.chomp } + end + else + data_old = IO::readlines(file_old).map { |e| e.chomp } + data_new = IO::readlines(file_new).map { |e| e.chomp } + end + + # diff yields lots of pieces, each of which is basically a Block object + if @binary + diffs = (data_old == data_new) + else + diffs = Diff::LCS.diff(data_old, data_new) + diffs = nil if diffs.empty? + end + + return 0 unless diffs + + if @format == :report + output << "Files #{file_old} and #{file_new} differ\n" + return 1 + end + + if (@format == :unified) or (@format == :context) + ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z') + puts "#{char_old} #{file_old}\t#{ft}" + ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z') + puts "#{char_new} #{file_new}\t#{ft}" + end + + # Loop over hunks. If a hunk overlaps with the last hunk, join them. + # Otherwise, print out the old one. + oldhunk = hunk = nil + + if @format == :ed + real_output = output + output = [] + end + + diffs.each do |piece| + begin + hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, @lines, + file_length_difference) + file_length_difference = hunk.file_length_difference + + next unless oldhunk + next if (@lines > 0) and hunk.merge(oldhunk) + + output << oldhunk.diff(@format) << "\n" + ensure + oldhunk = hunk + end + end + + output << oldhunk.diff(@format) << "\n" + + if @format == :ed + output.reverse_each { |e| real_output << e.diff(:ed_finish) } + end + + return 1 + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb new file mode 100644 index 000000000..8545bcf9d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb @@ -0,0 +1,5 @@ +# -*- ruby encoding: utf-8 -*- + +class String + include Diff::LCS +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/change_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/change_spec.rb new file mode 100644 index 000000000..dfe385fc7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/change_spec.rb @@ -0,0 +1,65 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe Diff::LCS::Change do + describe "an add" do + subject { described_class.new('+', 0, 'element') } + it { should_not be_deleting } + it { should be_adding } + it { should_not be_unchanged } + it { should_not be_changed } + it { should_not be_finished_a } + it { should_not be_finished_b } + end + + describe "a delete" do + subject { described_class.new('-', 0, 'element') } + it { should be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } + it { should_not be_finished_a } + it { should_not be_finished_b } + end + + describe "an unchanged" do + subject { described_class.new('=', 0, 'element') } + it { should_not be_deleting } + it { should_not be_adding } + it { should be_unchanged } + it { should_not be_changed } + it { should_not be_finished_a } + it { should_not be_finished_b } + end + + describe "a changed" do + subject { described_class.new('!', 0, 'element') } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should be_changed } + it { should_not be_finished_a } + it { should_not be_finished_b } + end + + describe "a finished_a" do + subject { described_class.new('>', 0, 'element') } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } + it { should be_finished_a } + it { should_not be_finished_b } + end + + describe "a finished_b" do + subject { described_class.new('<', 0, 'element') } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } + it { should_not be_finished_a } + it { should be_finished_b } + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb new file mode 100644 index 000000000..95d7b40f4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb @@ -0,0 +1,47 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.diff" do + include Diff::LCS::SpecHelper::Matchers + + it "should correctly diff seq1 to seq2" do + diff_s1_s2 = Diff::LCS.diff(seq1, seq2) + change_diff(correct_forward_diff).should == diff_s1_s2 + end + + it "should correctly diff seq2 to seq1" do + diff_s2_s1 = Diff::LCS.diff(seq2, seq1) + change_diff(correct_backward_diff).should == diff_s2_s1 + end + + it "should correctly diff against an empty sequence" do + diff = Diff::LCS.diff(word_sequence, []) + correct_diff = [ + [ [ '-', 0, 'abcd' ], + [ '-', 1, 'efgh' ], + [ '-', 2, 'ijkl' ], + [ '-', 3, 'mnopqrstuvwxyz' ] ] + ] + + change_diff(correct_diff).should == diff + + diff = Diff::LCS.diff([], word_sequence) + correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } } + change_diff(correct_diff).should == diff + end + + it "should correctly diff 'xx' and 'xaxb'" do + left = 'xx' + right = 'xaxb' + Diff::LCS.patch(left, Diff::LCS.diff(left, right)).should == right + end + + it "should return an empty diff with (hello, hello)" do + Diff::LCS.diff(hello, hello).should == [] + end + + it "should return an empty diff with (hello_ary, hello_ary)" do + Diff::LCS.diff(hello_ary, hello_ary).should == [] + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/hunk_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/hunk_spec.rb new file mode 100644 index 000000000..dc6f5327c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/hunk_spec.rb @@ -0,0 +1,72 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +def h(v) + v.to_s.bytes.to_a.map { |e| "%02x" % e }.join +end + +describe "Diff::LCS::Hunk" do + if String.method_defined?(:encoding) + + let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] } + let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] } + let(:pieces) { Diff::LCS.diff old_data, new_data } + let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) } + + it 'should be able to produce a unified diff from the two pieces' do + expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp) + @@ -1,2 +1,2 @@ + -Tu avec carté {count} itém has + +Tu avec carte {count} item has + EOD + expect(hunk.diff(:unified).to_s == expected).to eql true + end + + it 'should be able to produce a context diff from the two pieces' do + expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp) + *************** + *** 1,2 **** + !Tu avec carté {count} itém has + --- 1,2 ---- + !Tu avec carte {count} item has + EOD + + expect(hunk.diff(:context).to_s == expected).to eql true + end + + it 'should be able to produce an old diff from the two pieces' do + expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp) + 1,2c1,2 + < Tu avec carté {count} itém has + --- + > Tu avec carte {count} item has + + EOD + expect(hunk.diff(:old).to_s == expected).to eql true + end + + it 'should be able to produce a reverse ed diff from the two pieces' do + expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp) + c1,2 + Tu avec carte {count} item has + . + + EOD + expect(hunk.diff(:reverse_ed).to_s == expected).to eql true + end + + context 'with empty first data set' do + let(:old_data) { [] } + + it 'should be able to produce a unified diff' do + expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp) + @@ -1 +1,2 @@ + +Tu avec carte {count} item has + EOD + expect(hunk.diff(:unified).to_s == expected).to eql true + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/issues_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/issues_spec.rb new file mode 100644 index 000000000..c3d8f873b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/issues_spec.rb @@ -0,0 +1,24 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS Issues" do + include Diff::LCS::SpecHelper::Matchers + + it "should not fail to provide a simple patchset (issue 1)" do + s1, s2 = *%W(aX bXaX) + correct_forward_diff = [ + [ [ '+', 0, 'b' ], + [ '+', 1, 'X' ] ], + ] + + diff_s1_s2 = Diff::LCS.diff(s1, s2) + change_diff(correct_forward_diff).should == diff_s1_s2 + expect do + Diff::LCS.patch(s1, diff_s1_s2).should == s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + expect do + Diff::LCS.patch(s2, diff_s1_s2).should == s1 + end.to_not raise_error(RuntimeError, /provided patchset/) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/lcs_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/lcs_spec.rb new file mode 100644 index 000000000..205d5635b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/lcs_spec.rb @@ -0,0 +1,54 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS::Internals.lcs" do + include Diff::LCS::SpecHelper::Matchers + + it "should return a meaningful LCS array with (seq1, seq2)" do + res = Diff::LCS::Internals.lcs(seq1, seq2) + # The result of the LCS (less the +nil+ values) must be as long as the + # correct result. + res.compact.size.should == correct_lcs.size + res.should correctly_map_sequence(seq1).to_other_sequence(seq2) + + # Compact these transformations and they should be the correct LCS. + x_seq1 = (0...res.size).map { |ix| res[ix] ? seq1[ix] : nil }.compact + x_seq2 = (0...res.size).map { |ix| res[ix] ? seq2[res[ix]] : nil }.compact + + x_seq1.should == correct_lcs + x_seq2.should == correct_lcs + end + + it "should return all indexes with (hello, hello)" do + Diff::LCS::Internals.lcs(hello, hello).should == (0...hello.size).to_a + end + + it "should return all indexes with (hello_ary, hello_ary)" do + Diff::LCS::Internals.lcs(hello_ary, hello_ary).should == (0...hello_ary.size).to_a + end +end + +describe "Diff::LCS.LCS" do + include Diff::LCS::SpecHelper::Matchers + + it "should return the correct compacted values from Diff::LCS.LCS" do + res = Diff::LCS.LCS(seq1, seq2) + res.should == correct_lcs + res.compact.should == res + end + + it "should be transitive" do + res = Diff::LCS.LCS(seq2, seq1) + res.should == correct_lcs + res.compact.should == res + end + + it "should return %W(h e l l o) with (hello, hello)" do + Diff::LCS.LCS(hello, hello).should == hello.split(//) + end + + it "should return hello_ary with (hello_ary, hello_ary)" do + Diff::LCS.LCS(hello_ary, hello_ary).should == hello_ary + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/patch_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/patch_spec.rb new file mode 100644 index 000000000..0fc9160fd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/patch_spec.rb @@ -0,0 +1,414 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.patch" do + include Diff::LCS::SpecHelper::Matchers + + shared_examples "patch sequences correctly" do + it "should correctly patch left-to-right (patch autodiscovery)" do + Diff::LCS.patch(s1, patch_set).should == s2 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(s1, patch_set, :patch).should == s2 + Diff::LCS.patch!(s1, patch_set).should == s2 + end + + it "should correctly patch right-to-left (unpatch autodiscovery)" do + Diff::LCS.patch(s2, patch_set).should == s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(s2, patch_set, :unpatch).should == s1 + Diff::LCS.unpatch!(s2, patch_set).should == s1 + end + end + + describe "using a Diff::LCS.diff patchset" do + describe "an empty patchset returns the source" do + it "works on a string (hello)" do + Diff::LCS::patch(hello, Diff::LCS.diff(hello, hello)).should == hello + end + + it "works on an array %W(h e l l o)" do + Diff::LCS::patch(hello_ary, Diff::LCS.diff(hello_ary, hello_ary)).should == hello_ary + end + end + + describe "with default diff callbacks (DiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { Diff::LCS.diff(seq1, seq2) } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { Diff::LCS.diff(seq2, seq1) } + end + end + end + + describe "with context diff callbacks (ContextDiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { + Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks) + } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { + Diff::LCS.diff(seq2, seq1, Diff::LCS::ContextDiffCallbacks) + } + end + end + end + + describe "with sdiff callbacks (SDiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { + Diff::LCS.diff(seq1, seq2, Diff::LCS::SDiffCallbacks) + } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { + Diff::LCS.diff(seq2, seq1, Diff::LCS::SDiffCallbacks) + } + end + end + end + end + + describe "using a Diff::LCS.sdiff patchset" do + describe "an empty patchset returns the source" do + it "works on a string (hello)" do + Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello)).should == hello + end + + it "works on an array %W(h e l l o)" do + Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary)).should == hello_ary + end + end + + describe "with default diff callbacks (DiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { + Diff::LCS.sdiff(seq1, seq2, Diff::LCS::DiffCallbacks) + } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { + Diff::LCS.sdiff(seq2, seq1, Diff::LCS::DiffCallbacks) + } + end + end + end + + describe "with context diff callbacks (DiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { + Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks) + } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { + Diff::LCS.sdiff(seq2, seq1, Diff::LCS::ContextDiffCallbacks) + } + end + end + end + + describe "with sdiff callbacks (SDiffCallbacks)" do + describe "forward (s1 -> s2)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) } + end + end + + describe "reverse (s2 -> s1)" do + it_has_behavior "patch sequences correctly" do + let(:s1) { seq2 } + let(:s2) { seq1 } + let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) } + end + end + end + end + + # Note: because of the error in autodiscovery ("does not autodiscover s1 + # to s2 patches"), this cannot use the "patch sequences correctly" shared + # set. Once the bug in autodiscovery is fixed, this can be converted as + # above. + describe "fix bug 891: patchsets do not contain the last equal part" do + before(:each) do + @s1 = %w(a b c d e f g h i j k) + @s2 = %w(a b c d D e f g h i j k) + end + + describe "using Diff::LCS.diff with default diff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2) + @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + + describe "using Diff::LCS.diff with context diff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks) + @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + + describe "using Diff::LCS.diff with sdiff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks) + @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + + describe "using Diff::LCS.sdiff with default sdiff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2) + @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)", :only => true do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + + describe "using Diff::LCS.sdiff with context diff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks) + @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + + describe "using Diff::LCS.sdiff with default diff callbacks" do + before(:each) do + @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks) + @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks) + end + + it "should autodiscover s1 to s2 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 patches" do + expect do + Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2 + end.to_not raise_error(RuntimeError, /provided patchset/) + end + + it "should autodiscover s2 to s1 the left-to-right patches" do + Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1 + Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1 + end + + it "should correctly patch left-to-right (explicit patch)" do + Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2 + Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1 + Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2 + Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1 + end + + it "should correctly patch right-to-left (explicit unpatch)" do + Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1 + Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2 + Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1 + Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2 + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb new file mode 100644 index 000000000..7ab3bb61b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb @@ -0,0 +1,214 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.sdiff" do + include Diff::LCS::SpecHelper::Matchers + + shared_examples "compare sequences correctly" do + it "should compare s1 -> s2 correctly" do + Diff::LCS.sdiff(s1, s2).should == context_diff(result) + end + + it "should compare s2 -> s1 correctly" do + Diff::LCS.sdiff(s2, s1).should == context_diff(reverse_sdiff(result)) + end + end + + describe "using seq1 & seq2" do + let(:s1) { seq1 } + let(:s2) { seq2 } + let(:result) { correct_forward_sdiff } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)" do + let(:s1) { %w(abc def yyy xxx ghi jkl) } + let(:s2) { %w(abc dxf xxx ghi jkl) } + let(:result) { + [ + [ '=', [ 0, 'abc' ], [ 0, 'abc' ] ], + [ '!', [ 1, 'def' ], [ 1, 'dxf' ] ], + [ '-', [ 2, 'yyy' ], [ 2, nil ] ], + [ '=', [ 3, 'xxx' ], [ 2, 'xxx' ] ], + [ '=', [ 4, 'ghi' ], [ 3, 'ghi' ] ], + [ '=', [ 5, 'jkl' ], [ 4, 'jkl' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a b c d e) & %w(a e)" do + let(:s1) { %w(a b c d e) } + let(:s2) { %w(a e) } + let(:result) { + [ + [ '=', [ 0, 'a' ], [ 0, 'a' ] ], + [ '-', [ 1, 'b' ], [ 1, nil ] ], + [ '-', [ 2, 'c' ], [ 1, nil ] ], + [ '-', [ 3, 'd' ], [ 1, nil ] ], + [ '=', [ 4, 'e' ], [ 1, 'e' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a e) & %w(a b c d e)" do + let(:s1) { %w(a e) } + let(:s2) { %w(a b c d e) } + let(:result) { + [ + [ '=', [ 0, 'a' ], [ 0, 'a' ] ], + [ '+', [ 1, nil ], [ 1, 'b' ] ], + [ '+', [ 1, nil ], [ 2, 'c' ] ], + [ '+', [ 1, nil ], [ 3, 'd' ] ], + [ '=', [ 1, 'e' ], [ 4, 'e' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(v x a e) & %w(w y a b c d e)" do + let(:s1) { %w(v x a e) } + let(:s2) { %w(w y a b c d e) } + let(:result) { + [ + [ '!', [ 0, 'v' ], [ 0, 'w' ] ], + [ '!', [ 1, 'x' ], [ 1, 'y' ] ], + [ '=', [ 2, 'a' ], [ 2, 'a' ] ], + [ '+', [ 3, nil ], [ 3, 'b' ] ], + [ '+', [ 3, nil ], [ 4, 'c' ] ], + [ '+', [ 3, nil ], [ 5, 'd' ] ], + [ '=', [ 3, 'e' ], [ 6, 'e' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(x a e) & %w(a b c d e)" do + let(:s1) { %w(x a e) } + let(:s2) { %w(a b c d e) } + let(:result) { + [ + [ '-', [ 0, 'x' ], [ 0, nil ] ], + [ '=', [ 1, 'a' ], [ 0, 'a' ] ], + [ '+', [ 2, nil ], [ 1, 'b' ] ], + [ '+', [ 2, nil ], [ 2, 'c' ] ], + [ '+', [ 2, nil ], [ 3, 'd' ] ], + [ '=', [ 2, 'e' ], [ 4, 'e' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a e) & %w(x a b c d e)" do + let(:s1) { %w(a e) } + let(:s2) { %w(x a b c d e) } + let(:result) { + [ + [ '+', [ 0, nil ], [ 0, 'x' ] ], + [ '=', [ 0, 'a' ], [ 1, 'a' ] ], + [ '+', [ 1, nil ], [ 2, 'b' ] ], + [ '+', [ 1, nil ], [ 3, 'c' ] ], + [ '+', [ 1, nil ], [ 4, 'd' ] ], + [ '=', [ 1, 'e' ], [ 5, 'e' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a e v) & %w(x a b c d e w x)" do + let(:s1) { %w(a e v) } + let(:s2) { %w(x a b c d e w x) } + let(:result) { + [ + [ '+', [ 0, nil ], [ 0, 'x' ] ], + [ '=', [ 0, 'a' ], [ 1, 'a' ] ], + [ '+', [ 1, nil ], [ 2, 'b' ] ], + [ '+', [ 1, nil ], [ 3, 'c' ] ], + [ '+', [ 1, nil ], [ 4, 'd' ] ], + [ '=', [ 1, 'e' ], [ 5, 'e' ] ], + [ '!', [ 2, 'v' ], [ 6, 'w' ] ], + [ '+', [ 3, nil ], [ 7, 'x' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w() & %w(a b c)" do + let(:s1) { %w() } + let(:s2) { %w(a b c) } + let(:result) { + [ + [ '+', [ 0, nil ], [ 0, 'a' ] ], + [ '+', [ 0, nil ], [ 1, 'b' ] ], + [ '+', [ 0, nil ], [ 2, 'c' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a b c) & %w(1)" do + let(:s1) { %w(a b c) } + let(:s2) { %w(1) } + let(:result) { + [ + [ '!', [ 0, 'a' ], [ 0, '1' ] ], + [ '-', [ 1, 'b' ], [ 1, nil ] ], + [ '-', [ 2, 'c' ], [ 1, nil ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(a b c) & %w(c)" do + let(:s1) { %w(a b c) } + let(:s2) { %w(c) } + let(:result) { + [ + [ '-', [ 0, 'a' ], [ 0, nil ] ], + [ '-', [ 1, 'b' ], [ 0, nil ] ], + [ '=', [ 2, 'c' ], [ 0, 'c' ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using %w(abcd efgh ijkl mnop) & []" do + let(:s1) { %w(abcd efgh ijkl mnop) } + let(:s2) { [] } + let(:result) { + [ + [ '-', [ 0, 'abcd' ], [ 0, nil ] ], + [ '-', [ 1, 'efgh' ], [ 0, nil ] ], + [ '-', [ 2, 'ijkl' ], [ 0, nil ] ], + [ '-', [ 3, 'mnop' ], [ 0, nil ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end + + describe "using [[1,2]] & []" do + let(:s1) { [ [ 1, 2 ] ] } + let(:s2) { [] } + let(:result) { + [ + [ '-', [ 0, [ 1, 2 ] ], [ 0, nil ] ] + ] + } + + it_has_behavior "compare sequences correctly" + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/spec_helper.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/spec_helper.rb new file mode 100644 index 000000000..a5ca00d3f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/spec_helper.rb @@ -0,0 +1,290 @@ +# -*- ruby encoding: utf-8 -*- + +require 'rubygems' +require 'pathname' + +file = Pathname.new(__FILE__).expand_path +path = file.parent +parent = path.parent + +$:.unshift parent.join('lib') + +require 'diff-lcs' + +module Diff::LCS::SpecHelper + def hello + "hello" + end + + def hello_ary + %W(h e l l o) + end + + def seq1 + %w(a b c e h j l m n p) + end + + def skipped_seq1 + %w(a h n p) + end + + def seq2 + %w(b c d e f j k l m r s t) + end + + def skipped_seq2 + %w(d f k r s t) + end + + def word_sequence + %w(abcd efgh ijkl mnopqrstuvwxyz) + end + + def correct_lcs + %w(b c e j l m) + end + + def correct_forward_diff + [ + [ [ '-', 0, 'a' ] ], + [ [ '+', 2, 'd' ] ], + [ [ '-', 4, 'h' ], + [ '+', 4, 'f' ] ], + [ [ '+', 6, 'k' ] ], + [ [ '-', 8, 'n' ], + [ '-', 9, 'p' ], + [ '+', 9, 'r' ], + [ '+', 10, 's' ], + [ '+', 11, 't' ] ] + ] + end + + def correct_backward_diff + [ + [ [ '+', 0, 'a' ] ], + [ [ '-', 2, 'd' ] ], + [ [ '-', 4, 'f' ], + [ '+', 4, 'h' ] ], + [ [ '-', 6, 'k' ] ], + [ + [ '-', 9, 'r' ], + [ '-', 10, 's' ], + [ '+', 8, 'n' ], + [ '-', 11, 't' ], + [ '+', 9, 'p' ] ] + ] + end + + def correct_forward_sdiff + [ + [ '-', [ 0, 'a' ], [ 0, nil ] ], + [ '=', [ 1, 'b' ], [ 0, 'b' ] ], + [ '=', [ 2, 'c' ], [ 1, 'c' ] ], + [ '+', [ 3, nil ], [ 2, 'd' ] ], + [ '=', [ 3, 'e' ], [ 3, 'e' ] ], + [ '!', [ 4, 'h' ], [ 4, 'f' ] ], + [ '=', [ 5, 'j' ], [ 5, 'j' ] ], + [ '+', [ 6, nil ], [ 6, 'k' ] ], + [ '=', [ 6, 'l' ], [ 7, 'l' ] ], + [ '=', [ 7, 'm' ], [ 8, 'm' ] ], + [ '!', [ 8, 'n' ], [ 9, 'r' ] ], + [ '!', [ 9, 'p' ], [ 10, 's' ] ], + [ '+', [ 10, nil ], [ 11, 't' ] ] + ] + end + + def reverse_sdiff(forward_sdiff) + forward_sdiff.map { |line| + line[1], line[2] = line[2], line[1] + case line[0] + when '-' then line[0] = '+' + when '+' then line[0] = '-' + end + line + } + end + + def change_diff(diff) + map_diffs(diff, Diff::LCS::Change) + end + + def context_diff(diff) + map_diffs(diff, Diff::LCS::ContextChange) + end + + def format_diffs(diffs) + diffs.map do |e| + if e.kind_of?(Array) + e.map { |f| f.to_a.join }.join(", ") + else + e.to_a.join + end + end.join("\n") + end + + def map_diffs(diffs, klass = Diff::LCS::ContextChange) + diffs.map do |chunks| + if klass == Diff::LCS::ContextChange + klass.from_a(chunks) + else + chunks.map { |changes| klass.from_a(changes) } + end + end + end + + def balanced_traversal(s1, s2, callback_type) + callback = __send__(callback_type) + Diff::LCS.traverse_balanced(s1, s2, callback) + callback + end + + def balanced_reverse(change_result) + new_result = [] + change_result.each { |line| + line = [ line[0], line[2], line[1] ] + case line[0] + when '<' + line[0] = '>' + when '>' + line[0] = '<' + end + new_result << line + } + new_result.sort_by { |line| [ line[1], line[2] ] } + end + + def map_to_no_change(change_result) + new_result = [] + change_result.each { |line| + case line[0] + when '!' + new_result << [ '<', line[1], line[2] ] + new_result << [ '>', line[1] + 1, line[2] ] + else + new_result << line + end + } + new_result + end + + def simple_callback + callbacks = Object.new + class << callbacks + attr_reader :matched_a + attr_reader :matched_b + attr_reader :discards_a + attr_reader :discards_b + attr_reader :done_a + attr_reader :done_b + + def reset + @matched_a = [] + @matched_b = [] + @discards_a = [] + @discards_b = [] + @done_a = [] + @done_b = [] + end + + def match(event) + @matched_a << event.old_element + @matched_b << event.new_element + end + + def discard_b(event) + @discards_b << event.new_element + end + + def discard_a(event) + @discards_a << event.old_element + end + + def finished_a(event) + @done_a << [event.old_element, event.old_position, + event.new_element, event.new_position] + end + + def finished_b(event) + p "called #finished_b" + @done_b << [event.old_element, event.old_position, + event.new_element, event.new_position] + end + end + callbacks.reset + callbacks + end + + def simple_callback_no_finishers + simple = simple_callback + class << simple + undef :finished_a + undef :finished_b + end + simple + end + + def balanced_callback + cb = Object.new + class << cb + attr_reader :result + + def reset + @result = [] + end + + def match(event) + @result << [ "=", event.old_position, event.new_position ] + end + + def discard_a(event) + @result << [ "<", event.old_position, event.new_position ] + end + + def discard_b(event) + @result << [ ">", event.old_position, event.new_position ] + end + + def change(event) + @result << [ "!", event.old_position, event.new_position ] + end + end + cb.reset + cb + end + + def balanced_callback_no_change + balanced = balanced_callback + class << balanced + undef :change + end + balanced + end + + module Matchers + extend RSpec::Matchers::DSL + + matcher :be_nil_or_match_values do |ii, s1, s2| + match do |ee| + ee.should satisfy { |vee| vee.nil? || s1[ii] == s2[ee] } + end + end + + matcher :correctly_map_sequence do |s1| + match do |actual| + actual.each_with_index { |ee, ii| + ee.should be_nil_or_match_values(ii, s1, @s2) + } + end + + chain :to_other_sequence do |s2| + @s2 = s2 + end + end + end +end + +RSpec.configure do |conf| + conf.include Diff::LCS::SpecHelper + conf.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:' + conf.filter_run_excluding :broken => true +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb new file mode 100644 index 000000000..63fe1eb6f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb @@ -0,0 +1,310 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.traverse_balanced" do + include Diff::LCS::SpecHelper::Matchers + + shared_examples "with a #change callback" do |s1, s2, result| + it "should traverse s1 -> s2 correctly" do + traversal = balanced_traversal(s1, s2, :balanced_callback) + traversal.result.should == result + end + + it "should traverse s2 -> s1 correctly" do + traversal = balanced_traversal(s2, s1, :balanced_callback) + traversal.result.should == balanced_reverse(result) + end + end + + shared_examples "without a #change callback" do |s1, s2, result| + it "should traverse s1 -> s2 correctly" do + traversal = balanced_traversal(s1, s2, :balanced_callback_no_change) + traversal.result.should == map_to_no_change(result) + end + + it "should traverse s2 -> s1 correctly" do + traversal = balanced_traversal(s2, s1, :balanced_callback_no_change) + traversal.result.should == map_to_no_change(balanced_reverse(result)) + end + end + + describe "identical string sequences ('abc')" do + s1 = s2 = "abc" + + result = [ + [ '=', 0, 0 ], + [ '=', 1, 1 ], + [ '=', 2, 2 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "identical array sequences %w(a b c)" do + s1 = s2 = %w(a b c) + + result = [ + [ '=', 0, 0 ], + [ '=', 1, 1 ], + [ '=', 2, 2 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(a b c) & %w(a x c)" do + s1 = %w(a b c) + s2 = %w(a x c) + + result = [ + [ '=', 0, 0 ], + [ '!', 1, 1 ], + [ '=', 2, 2 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(a x y c) & %w(a v w c)" do + s1 = %w(a x y c) + s2 = %w(a v w c) + + result = [ + [ '=', 0, 0 ], + [ '!', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(x y c) & %w(v w c)" do + s1 = %w(x y c) + s2 = %w(v w c) + result = [ + [ '!', 0, 0 ], + [ '!', 1, 1 ], + [ '=', 2, 2 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(a x y z) & %w(b v w)" do + s1 = %w(a x y z) + s2 = %w(b v w) + result = [ + [ '!', 0, 0 ], + [ '!', 1, 1 ], + [ '!', 2, 2 ], + [ '<', 3, 3 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(a z) & %w(a)" do + s1 = %w(a z) + s2 = %w(a) + result = [ + [ '=', 0, 0 ], + [ '<', 1, 1 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(z a) & %w(a)" do + s1 = %w(z a) + s2 = %w(a) + result = [ + [ '<', 0, 0 ], + [ '=', 1, 0 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(a b c) & %w(x y z)" do + s1 = %w(a b c) + s2 = %w(x y z) + result = [ + [ '!', 0, 0 ], + [ '!', 1, 1 ], + [ '!', 2, 2 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "sequences %w(abcd efgh ijkl mnoopqrstuvwxyz) & []" do + s1 = %w(abcd efgh ijkl mnopqrstuvwxyz) + s2 = [] + result = [ + [ '<', 0, 0 ], + [ '<', 1, 0 ], + [ '<', 2, 0 ], + [ '<', 3, 0 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(a b c) & %Q(a x c)" do + s1 = %Q(a b c) + s2 = %Q(a x c) + + result = [ + [ '=', 0, 0 ], + [ '=', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ], + [ '=', 4, 4 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(a x y c) & %Q(a v w c)" do + s1 = %Q(a x y c) + s2 = %Q(a v w c) + + result = [ + [ '=', 0, 0 ], + [ '=', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ], + [ '!', 4, 4 ], + [ '=', 5, 5 ], + [ '=', 6, 6 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(x y c) & %Q(v w c)" do + s1 = %Q(x y c) + s2 = %Q(v w c) + result = [ + [ '!', 0, 0 ], + [ '=', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ], + [ '=', 4, 4 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(a x y z) & %Q(b v w)" do + s1 = %Q(a x y z) + s2 = %Q(b v w) + result = [ + [ '!', 0, 0 ], + [ '=', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ], + [ '!', 4, 4 ], + [ '<', 5, 5 ], + [ '<', 6, 5 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(a z) & %Q(a)" do + s1 = %Q(a z) + s2 = %Q(a) + result = [ + [ '=', 0, 0 ], + [ '<', 1, 1 ], + [ '<', 2, 1 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(z a) & %Q(a)" do + s1 = %Q(z a) + s2 = %Q(a) + result = [ + [ '<', 0, 0 ], + [ '<', 1, 0 ], + [ '=', 2, 0 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(a b c) & %Q(x y z)" do + s1 = %Q(a b c) + s2 = %Q(x y z) + result = [ + [ '!', 0, 0 ], + [ '=', 1, 1 ], + [ '!', 2, 2 ], + [ '=', 3, 3 ], + [ '!', 4, 4 ] + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end + + describe "strings %Q(abcd efgh ijkl mnopqrstuvwxyz) & %Q()" do + s1 = %Q(abcd efgh ijkl mnopqrstuvwxyz) + s2 = "" + result = [ + [ '<', 0, 0 ], + [ '<', 1, 0 ], + [ '<', 2, 0 ], + [ '<', 3, 0 ], + [ '<', 4, 0 ], + [ '<', 5, 0 ], + [ '<', 6, 0 ], + [ '<', 7, 0 ], + [ '<', 8, 0 ], + [ '<', 9, 0 ], + [ '<', 10, 0 ], + [ '<', 11, 0 ], + [ '<', 12, 0 ], + [ '<', 13, 0 ], + [ '<', 14, 0 ], + [ '<', 15, 0 ], + [ '<', 16, 0 ], + [ '<', 17, 0 ], + [ '<', 18, 0 ], + [ '<', 19, 0 ], + [ '<', 20, 0 ], + [ '<', 21, 0 ], + [ '<', 22, 0 ], + [ '<', 23, 0 ], + [ '<', 24, 0 ], + [ '<', 25, 0 ], + [ '<', 26, 0 ], + [ '<', 27, 0 ], + [ '<', 28, 0 ], + ] + + it_has_behavior "with a #change callback", s1, s2, result + it_has_behavior "without a #change callback", s1, s2, result + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb new file mode 100644 index 000000000..f4480dfc5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb @@ -0,0 +1,139 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS.traverse_sequences" do + describe "callback with no finishers" do + describe "over (seq1, seq2)" do + before(:each) do + @callback_s1_s2 = simple_callback_no_finishers + Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2) + + @callback_s2_s1 = simple_callback_no_finishers + Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1) + end + + it "should have the correct LCS result on left-matches" do + @callback_s1_s2.matched_a.should == correct_lcs + @callback_s2_s1.matched_a.should == correct_lcs + end + + it "should have the correct LCS result on right-matches" do + @callback_s1_s2.matched_b.should == correct_lcs + @callback_s2_s1.matched_b.should == correct_lcs + end + + it "should have the correct skipped sequences with the left sequence" do + @callback_s1_s2.discards_a.should == skipped_seq1 + @callback_s2_s1.discards_a.should == skipped_seq2 + end + + it "should have the correct skipped sequences with the right sequence" do + @callback_s1_s2.discards_b.should == skipped_seq2 + @callback_s2_s1.discards_b.should == skipped_seq1 + end + + it "should not have anything done markers from the left or right sequences" do + @callback_s1_s2.done_a.should be_empty + @callback_s1_s2.done_b.should be_empty + @callback_s2_s1.done_a.should be_empty + @callback_s2_s1.done_b.should be_empty + end + end + + describe "over (hello, hello)" do + before(:each) do + @callback = simple_callback_no_finishers + Diff::LCS.traverse_sequences(hello, hello, @callback) + end + + it "should have the correct LCS result on left-matches" do + @callback.matched_a.should == hello.split(//) + end + + it "should have the correct LCS result on right-matches" do + @callback.matched_b.should == hello.split(//) + end + + it "should have the correct skipped sequences with the left sequence", :only => true do + @callback.discards_a.should be_empty + end + + it "should have the correct skipped sequences with the right sequence" do + @callback.discards_b.should be_empty + end + + it "should not have anything done markers from the left or right sequences" do + @callback.done_a.should be_empty + @callback.done_b.should be_empty + end + end + + describe "over (hello_ary, hello_ary)" do + before(:each) do + @callback = simple_callback_no_finishers + Diff::LCS.traverse_sequences(hello_ary, hello_ary, @callback) + end + + it "should have the correct LCS result on left-matches" do + @callback.matched_a.should == hello_ary + end + + it "should have the correct LCS result on right-matches" do + @callback.matched_b.should == hello_ary + end + + it "should have the correct skipped sequences with the left sequence" do + @callback.discards_a.should be_empty + end + + it "should have the correct skipped sequences with the right sequence" do + @callback.discards_b.should be_empty + end + + it "should not have anything done markers from the left or right sequences" do + @callback.done_a.should be_empty + @callback.done_b.should be_empty + end + end + end + + describe "callback with finisher" do + before(:each) do + @callback_s1_s2 = simple_callback + Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2) + @callback_s2_s1 = simple_callback + Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1) + end + + it "should have the correct LCS result on left-matches" do + @callback_s1_s2.matched_a.should == correct_lcs + @callback_s2_s1.matched_a.should == correct_lcs + end + + it "should have the correct LCS result on right-matches" do + @callback_s1_s2.matched_b.should == correct_lcs + @callback_s2_s1.matched_b.should == correct_lcs + end + + it "should have the correct skipped sequences for the left sequence" do + @callback_s1_s2.discards_a.should == skipped_seq1 + @callback_s2_s1.discards_a.should == skipped_seq2 + end + + it "should have the correct skipped sequences for the right sequence" do + @callback_s1_s2.discards_b.should == skipped_seq2 + @callback_s2_s1.discards_b.should == skipped_seq1 + end + + it "should have done markers differently-sized sequences" do + @callback_s1_s2.done_a.should == [[ "p", 9, "s", 10 ]] + @callback_s1_s2.done_b.should be_empty + + # 20110731 I don't yet understand why this particular behaviour + # isn't transitive. + @callback_s2_s1.done_a.should be_empty + @callback_s2_s1.done_b.should be_empty + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.gemtest b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.gemtest new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.travis.yml b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.travis.yml new file mode 100644 index 000000000..2349f0677 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.travis.yml @@ -0,0 +1,13 @@ +rvm: + - 1.8.7 + - 1.9.2 + - 1.9.3 + - ree + - rbx-18mode + - rbx-19mode + - jruby + +notifications: + irc: "irc.freenode.org#pry" + recipients: + - jrmair@gmail.com diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.yardopts b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.yardopts new file mode 100644 index 000000000..a4e783801 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/.yardopts @@ -0,0 +1 @@ +-m markdown diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Gemfile b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Gemfile new file mode 100644 index 000000000..e45e65f87 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Gemfile @@ -0,0 +1,2 @@ +source :rubygems +gemspec diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/LICENSE b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/LICENSE new file mode 100644 index 000000000..d1a50d62d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/LICENSE @@ -0,0 +1,25 @@ +License +------- + +(The MIT License) + +Copyright (c) 2011 John Mair (banisterfiend) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/README.markdown b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/README.markdown new file mode 100644 index 000000000..d91b810a3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/README.markdown @@ -0,0 +1,91 @@ +method_source +============= + +(C) John Mair (banisterfiend) 2011 + +_retrieve the sourcecode for a method_ + +*NOTE:* This simply utilizes `Method#source_location`; it + does not access the live AST. + +`method_source` is a utility to return a method's sourcecode as a +Ruby string. Also returns `Proc` and `Lambda` sourcecode. + +Method comments can also be extracted using the `comment` method. + +It is written in pure Ruby (no C). + +* Some Ruby 1.8 support now available. +* Support for MRI, RBX, JRuby, REE + +`method_source` provides the `source` and `comment` methods to the `Method` and +`UnboundMethod` and `Proc` classes. + +* Install the [gem](https://rubygems.org/gems/method_source): `gem install method_source` +* Read the [documentation](http://rdoc.info/github/banister/method_source/master/file/README.markdown) +* See the [source code](http://github.com/banister/method_source) + +Example: display method source +------------------------------ + + Set.instance_method(:merge).source.display + # => + def merge(enum) + if enum.instance_of?(self.class) + @hash.update(enum.instance_variable_get(:@hash)) + else + do_with_enum(enum) { |o| add(o) } + end + + self + end + +Example: display method comments +-------------------------------- + + Set.instance_method(:merge).comment.display + # => + # Merges the elements of the given enumerable object to the set and + # returns self. + +Limitations: +------------ + +* Occasional strange behaviour in Ruby 1.8 +* Cannot return source for C methods. +* Cannot return source for dynamically defined methods. + +Special Thanks +-------------- + +[Adam Sanderson](https://github.com/adamsanderson) for `comment` functionality. + +[Dmitry Elastic](https://github.com/dmitryelastic) for the brilliant Ruby 1.8 `source_location` hack. + +[Samuel Kadolph](https://github.com/samuelkadolph) for the JRuby 1.8 `source_location`. + +License +------- + +(The MIT License) + +Copyright (c) 2011 John Mair (banisterfiend) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Rakefile b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Rakefile new file mode 100644 index 000000000..7dad800e6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/Rakefile @@ -0,0 +1,79 @@ +dlext = RbConfig::CONFIG['DLEXT'] +direc = File.dirname(__FILE__) + +require 'rake/clean' +require 'rubygems/package_task' +require "#{direc}/lib/method_source/version" + +CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o") +CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o", + "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*.rbc", + "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake") + +def apply_spec_defaults(s) + s.name = "method_source" + s.summary = "retrieve the sourcecode for a method" + s.version = MethodSource::VERSION + s.date = Time.now.strftime '%Y-%m-%d' + s.author = "John Mair (banisterfiend)" + s.email = 'jrmair@gmail.com' + s.description = s.summary + s.require_path = 'lib' + + s.add_development_dependency("bacon","~>1.1.0") + s.add_development_dependency("rake", "~>0.9") + s.homepage = "http://banisterfiend.wordpress.com" + s.has_rdoc = 'yard' + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- test/*`.split("\n") +end + +task :test do + sh "bacon -q #{direc}/test/test.rb #{direc}/test/test_code_helpers.rb" +end + +desc "reinstall gem" +task :reinstall => :gems do + sh "gem uninstall method_source" rescue nil + sh "gem install #{direc}/pkg/method_source-#{MethodSource::VERSION}.gem" +end + +desc "Set up and run tests" +task :default => [:test] + +desc "Build the gemspec file" +task :gemspec => "ruby:gemspec" + +namespace :ruby do + spec = Gem::Specification.new do |s| + apply_spec_defaults(s) + s.platform = Gem::Platform::RUBY + end + + Gem::PackageTask.new(spec) do |pkg| + pkg.need_zip = false + pkg.need_tar = false + end + + desc "Generate gemspec file" + task :gemspec do + File.open("#{spec.name}.gemspec", "w") do |f| + f << spec.to_ruby + end + end +end + +desc "build all platform gems at once" +task :gems => [:rmgems, "ruby:gem"] + +desc "remove all platform gems" +task :rmgems => ["ruby:clobber_package"] + +desc "build and push latest gems" +task :pushgems => :gems do + chdir("#{direc}/pkg") do + Dir["*.gem"].each do |gemfile| + sh "gem push #{gemfile}" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source.rb new file mode 100644 index 000000000..7d16c3b5b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source.rb @@ -0,0 +1,141 @@ +# (C) John Mair (banisterfiend) 2011 +# MIT License + +direc = File.dirname(__FILE__) + +require "#{direc}/method_source/version" +require "#{direc}/method_source/source_location" +require "#{direc}/method_source/code_helpers" + +module MethodSource + extend MethodSource::CodeHelpers + + # An Exception to mark errors that were raised trying to find the source from + # a given source_location. + # + class SourceNotFoundError < StandardError; end + + # Helper method responsible for extracting method body. + # Defined here to avoid polluting `Method` class. + # @param [Array] source_location The array returned by Method#source_location + # @param [String] method_name + # @return [String] The method body + def self.source_helper(source_location, name=nil) + raise SourceNotFoundError, "Could not locate source for #{name}!" unless source_location + file, line = *source_location + + expression_at(lines_for(file), line) + rescue SyntaxError => e + raise SourceNotFoundError, "Could not parse source for #{name}: #{e.message}" + end + + # Helper method responsible for opening source file and buffering up + # the comments for a specified method. Defined here to avoid polluting + # `Method` class. + # @param [Array] source_location The array returned by Method#source_location + # @param [String] method_name + # @return [String] The comments up to the point of the method. + def self.comment_helper(source_location, name=nil) + raise SourceNotFoundError, "Could not locate source for #{name}!" unless source_location + file, line = *source_location + + comment_describing(lines_for(file), line) + end + + # Load a memoized copy of the lines in a file. + # + # @param [String] file_name + # @param [String] method_name + # @return [Array] the contents of the file + # @raise [SourceNotFoundError] + def self.lines_for(file_name, name=nil) + @lines_for_file ||= {} + @lines_for_file[file_name] ||= File.readlines(file_name) + rescue Errno::ENOENT => e + raise SourceNotFoundError, "Could not load source for #{name}: #{e.message}" + end + + # @deprecated — use MethodSource::CodeHelpers#complete_expression? + def self.valid_expression?(str) + complete_expression?(str) + rescue SyntaxError + false + end + + # @deprecated — use MethodSource::CodeHelpers#expression_at + def self.extract_code(source_location) + source_helper(source_location) + end + + # This module is to be included by `Method` and `UnboundMethod` and + # provides the `#source` functionality + module MethodExtensions + + # We use the included hook to patch Method#source on rubinius. + # We need to use the included hook as Rubinius defines a `source` + # on Method so including a module will have no effect (as it's + # higher up the MRO). + # @param [Class] klass The class that includes the module. + def self.included(klass) + if klass.method_defined?(:source) && Object.const_defined?(:RUBY_ENGINE) && + RUBY_ENGINE =~ /rbx/ + + klass.class_eval do + orig_source = instance_method(:source) + + define_method(:source) do + begin + super + rescue + orig_source.bind(self).call + end + end + + end + end + end + + # Return the sourcecode for the method as a string + # @return [String] The method sourcecode as a string + # @raise SourceNotFoundException + # + # @example + # Set.instance_method(:clear).source.display + # => + # def clear + # @hash.clear + # self + # end + def source + MethodSource.source_helper(source_location, defined?(name) ? name : inspect) + end + + # Return the comments associated with the method as a string. + # @return [String] The method's comments as a string + # @raise SourceNotFoundException + # + # @example + # Set.instance_method(:clear).comment.display + # => + # # Removes all elements and returns self. + def comment + MethodSource.comment_helper(source_location, defined?(name) ? name : inspect) + end + end +end + +class Method + include MethodSource::SourceLocation::MethodExtensions + include MethodSource::MethodExtensions +end + +class UnboundMethod + include MethodSource::SourceLocation::UnboundMethodExtensions + include MethodSource::MethodExtensions +end + +class Proc + include MethodSource::SourceLocation::ProcExtensions + include MethodSource::MethodExtensions +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/code_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/code_helpers.rb new file mode 100644 index 000000000..6c1d53e8f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/code_helpers.rb @@ -0,0 +1,154 @@ +module MethodSource + + module CodeHelpers + # Retrieve the first expression starting on the given line of the given file. + # + # This is useful to get module or method source code. + # + # @param [Array, File, String] file The file to parse, either as a File or as + # @param [Fixnum] line_number The line number at which to look. + # NOTE: The first line in a file is + # line 1! + # @param [Hash] options The optional configuration parameters. + # @option options [Boolean] :strict If set to true, then only completely + # valid expressions are returned. Otherwise heuristics are used to extract + # expressions that may have been valid inside an eval. + # @option options [Fixnum] :consume A number of lines to automatically + # consume (add to the expression buffer) without checking for validity. + # @return [String] The first complete expression + # @raise [SyntaxError] If the first complete expression can't be identified + def expression_at(file, line_number, options={}) + options = { + :strict => false, + :consume => 0 + }.merge!(options) + + lines = file.is_a?(Array) ? file : file.each_line.to_a + + relevant_lines = lines[(line_number - 1)..-1] || [] + + extract_first_expression(relevant_lines, options[:consume]) + rescue SyntaxError => e + raise if options[:strict] + + begin + extract_first_expression(relevant_lines) do |code| + code.gsub(/\#\{.*?\}/, "temp") + end + rescue SyntaxError + raise e + end + end + + # Retrieve the comment describing the expression on the given line of the given file. + # + # This is useful to get module or method documentation. + # + # @param [Array, File, String] file The file to parse, either as a File or as + # a String or an Array of lines. + # @param [Fixnum] line_number The line number at which to look. + # NOTE: The first line in a file is line 1! + # @return [String] The comment + def comment_describing(file, line_number) + lines = file.is_a?(Array) ? file : file.each_line.to_a + + extract_last_comment(lines[0..(line_number - 2)]) + end + + # Determine if a string of code is a complete Ruby expression. + # @param [String] code The code to validate. + # @return [Boolean] Whether or not the code is a complete Ruby expression. + # @raise [SyntaxError] Any SyntaxError that does not represent incompleteness. + # @example + # complete_expression?("class Hello") #=> false + # complete_expression?("class Hello; end") #=> true + # complete_expression?("class 123") #=> SyntaxError: unexpected tINTEGER + def complete_expression?(str) + old_verbose = $VERBOSE + $VERBOSE = nil + + catch(:valid) do + eval("BEGIN{throw :valid}\n#{str}") + end + + # Assert that a line which ends with a , or \ is incomplete. + str !~ /[,\\]\s*\z/ + rescue IncompleteExpression + false + ensure + $VERBOSE = old_verbose + end + + private + + # Get the first expression from the input. + # + # @param [Array] lines + # @param [Fixnum] consume A number of lines to automatically + # consume (add to the expression buffer) without checking for validity. + # @yield a clean-up function to run before checking for complete_expression + # @return [String] a valid ruby expression + # @raise [SyntaxError] + def extract_first_expression(lines, consume=0, &block) + code = consume.zero? ? "" : lines.slice!(0..(consume - 1)).join + + lines.each do |v| + code << v + return code if complete_expression?(block ? block.call(code) : code) + end + raise SyntaxError, "unexpected $end" + end + + # Get the last comment from the input. + # + # @param [Array] lines + # @return [String] + def extract_last_comment(lines) + buffer = "" + + lines.each do |line| + # Add any line that is a valid ruby comment, + # but clear as soon as we hit a non comment line. + if (line =~ /^\s*#/) || (line =~ /^\s*$/) + buffer << line.lstrip + else + buffer.replace("") + end + end + + buffer + end + + # An exception matcher that matches only subsets of SyntaxErrors that can be + # fixed by adding more input to the buffer. + module IncompleteExpression + GENERIC_REGEXPS = [ + /unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby + /embedded document meets end of file/, # =begin + /unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby + /can't find string ".*" anywhere before EOF/, # rbx and jruby + /missing 'end' for/, /expecting kWHEN/ # rbx + ] + + RBX_ONLY_REGEXPS = [ + /expecting '[})\]]'(?:$|:)/, /expecting keyword_end/ + ] + + def self.===(ex) + return false unless SyntaxError === ex + case ex.message + when *GENERIC_REGEXPS + true + when *RBX_ONLY_REGEXPS + rbx? + else + false + end + end + + def self.rbx? + RbConfig::CONFIG['ruby_install_name'] == 'rbx' + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/source_location.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/source_location.rb new file mode 100644 index 000000000..1e2a22a1d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/source_location.rb @@ -0,0 +1,138 @@ +module MethodSource + module ReeSourceLocation + # Ruby enterprise edition provides all the information that's + # needed, in a slightly different way. + def source_location + [__file__, __line__] rescue nil + end + end + + module SourceLocation + module MethodExtensions + if Proc.method_defined? :__file__ + include ReeSourceLocation + + elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/ + require 'java' + + # JRuby version source_location hack + # @return [Array] A two element array containing the source location of the method + def source_location + to_java.source_location(Thread.current.to_java.getContext()) + end + else + + + def trace_func(event, file, line, id, binding, classname) + return unless event == 'call' + set_trace_func nil + + @file, @line = file, line + raise :found + end + + private :trace_func + + # Return the source location of a method for Ruby 1.8. + # @return [Array] A two element array. First element is the + # file, second element is the line in the file where the + # method definition is found. + def source_location + if @file.nil? + args =[*(1..(arity<-1 ? -arity-1 : arity ))] + + set_trace_func method(:trace_func).to_proc + call(*args) rescue nil + set_trace_func nil + @file = File.expand_path(@file) if @file && File.exist?(File.expand_path(@file)) + end + [@file, @line] if @file + end + end + end + + module ProcExtensions + if Proc.method_defined? :__file__ + include ReeSourceLocation + + elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ + + # Return the source location for a Proc (Rubinius only) + # @return [Array] A two element array. First element is the + # file, second element is the line in the file where the + # proc definition is found. + def source_location + [block.file.to_s, block.line] + end + else + + # Return the source location for a Proc (in implementations + # without Proc#source_location) + # @return [Array] A two element array. First element is the + # file, second element is the line in the file where the + # proc definition is found. + def source_location + self.to_s =~ /@(.*):(\d+)/ + [$1, $2.to_i] + end + end + end + + module UnboundMethodExtensions + if Proc.method_defined? :__file__ + include ReeSourceLocation + + elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/ + require 'java' + + # JRuby version source_location hack + # @return [Array] A two element array containing the source location of the method + def source_location + to_java.source_location(Thread.current.to_java.getContext()) + end + + else + + + # Return the source location of an instance method for Ruby 1.8. + # @return [Array] A two element array. First element is the + # file, second element is the line in the file where the + # method definition is found. + def source_location + klass = case owner + when Class + owner + when Module + method_owner = owner + Class.new { include(method_owner) } + end + + # deal with immediate values + case + when klass == Symbol + return :a.method(name).source_location + when klass == Fixnum + return 0.method(name).source_location + when klass == TrueClass + return true.method(name).source_location + when klass == FalseClass + return false.method(name).source_location + when klass == NilClass + return nil.method(name).source_location + end + + begin + Object.instance_method(:method).bind(klass.allocate).call(name).source_location + rescue TypeError + + # Assume we are dealing with a Singleton Class: + # 1. Get the instance object + # 2. Forward the source_location lookup to the instance + instance ||= ObjectSpace.each_object(owner).first + Object.instance_method(:method).bind(instance).call(name).source_location + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/version.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/version.rb new file mode 100644 index 000000000..7a91c7d60 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/lib/method_source/version.rb @@ -0,0 +1,3 @@ +module MethodSource + VERSION = "0.8.2" +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/method_source.gemspec b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/method_source.gemspec new file mode 100644 index 000000000..d24b3d9ff --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/method_source.gemspec @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = "method_source" + s.version = "0.8.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["John Mair (banisterfiend)"] + s.date = "2012-10-17" + s.description = "retrieve the sourcecode for a method" + s.email = "jrmair@gmail.com" + s.files = [".gemtest", ".travis.yml", ".yardopts", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "lib/method_source.rb", "lib/method_source/code_helpers.rb", "lib/method_source/source_location.rb", "lib/method_source/version.rb", "method_source.gemspec", "test/test.rb", "test/test_code_helpers.rb", "test/test_helper.rb"] + s.homepage = "http://banisterfiend.wordpress.com" + s.require_paths = ["lib"] + s.rubygems_version = "1.8.23" + s.summary = "retrieve the sourcecode for a method" + s.test_files = ["test/test.rb", "test/test_code_helpers.rb", "test/test_helper.rb"] + + if s.respond_to? :specification_version then + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, ["~> 1.1.0"]) + s.add_development_dependency(%q, ["~> 0.9"]) + else + s.add_dependency(%q, ["~> 1.1.0"]) + s.add_dependency(%q, ["~> 0.9"]) + end + else + s.add_dependency(%q, ["~> 1.1.0"]) + s.add_dependency(%q, ["~> 0.9"]) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test.rb new file mode 100644 index 000000000..4743a5033 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test.rb @@ -0,0 +1,138 @@ +direc = File.expand_path(File.dirname(__FILE__)) + +require 'rubygems' +require 'bacon' +require "#{direc}/../lib/method_source" +require "#{direc}/test_helper" + +describe MethodSource do + + describe "source_location (testing 1.8 implementation)" do + it 'should return correct source_location for a method' do + method(:hello).source_location.first.should =~ /test_helper/ + end + + it 'should not raise for immediate instance methods' do + [Symbol, Fixnum, TrueClass, FalseClass, NilClass].each do |immediate_class| + lambda { immediate_class.instance_method(:to_s).source_location }.should.not.raise + end + end + + it 'should not raise for immediate methods' do + [:a, 1, true, false, nil].each do |immediate| + lambda { immediate.method(:to_s).source_location }.should.not.raise + end + end + end + + before do + @hello_module_source = " def hello; :hello_module; end\n" + @hello_singleton_source = "def $o.hello; :hello_singleton; end\n" + @hello_source = "def hello; :hello; end\n" + @hello_comment = "# A comment for hello\n# It spans two lines and is indented by 2 spaces\n" + @lambda_comment = "# This is a comment for MyLambda\n" + @lambda_source = "MyLambda = lambda { :lambda }\n" + @proc_source = "MyProc = Proc.new { :proc }\n" + @hello_instance_evaled_source = " def hello_\#{name}(*args)\n send_mesg(:\#{name}, *args)\n end\n" + @hello_instance_evaled_source_2 = " def \#{name}_two()\n if 44\n 45\n end\n end\n" + @hello_class_evaled_source = " def hello_\#{name}(*args)\n send_mesg(:\#{name}, *args)\n end\n" + @hi_module_evaled_source = " def hi_\#{name}\n @var = \#{name}\n end\n" + end + + it 'should define methods on Method and UnboundMethod and Proc' do + Method.method_defined?(:source).should == true + UnboundMethod.method_defined?(:source).should == true + Proc.method_defined?(:source).should == true + end + + describe "Methods" do + it 'should return source for method' do + method(:hello).source.should == @hello_source + end + + it 'should return source for a method defined in a module' do + M.instance_method(:hello).source.should == @hello_module_source + end + + it 'should return source for a singleton method as an instance method' do + class << $o; self; end.instance_method(:hello).source.should == @hello_singleton_source + end + + it 'should return source for a singleton method' do + $o.method(:hello).source.should == @hello_singleton_source + end + + it 'should return a comment for method' do + method(:hello).comment.should == @hello_comment + end + + # These tests fail because of http://jira.codehaus.org/browse/JRUBY-4576 + unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" + it 'should return source for an *_evaled method' do + M.method(:hello_name).source.should == @hello_instance_evaled_source + M.method(:name_two).source.should == @hello_instance_evaled_source_2 + M.instance_method(:hello_name).source.should == @hello_class_evaled_source + M.instance_method(:hi_name).source.should == @hi_module_evaled_source + end + end + + it "should raise error for evaled methods that do not pass __FILE__ and __LINE__ + 1 as its arguments" do + lambda { M.instance_method(:name_three).source }.should.raise MethodSource::SourceNotFoundError + end + + if !is_rbx? + it 'should raise for C methods' do + lambda { method(:puts).source }.should.raise MethodSource::SourceNotFoundError + end + end + end + + # if RUBY_VERSION =~ /1.9/ || is_rbx? + describe "Lambdas and Procs" do + it 'should return source for proc' do + MyProc.source.should == @proc_source + end + + it 'should return an empty string if there is no comment' do + MyProc.comment.should == '' + end + + it 'should return source for lambda' do + MyLambda.source.should == @lambda_source + end + + it 'should return comment for lambda' do + MyLambda.comment.should == @lambda_comment + end + end + # end + describe "Comment tests" do + before do + @comment1 = "# a\n# b\n" + @comment2 = "# a\n# b\n" + @comment3 = "# a\n#\n# b\n" + @comment4 = "# a\n# b\n" + @comment5 = "# a\n# b\n# c\n# d\n" + end + + it "should correctly extract multi-line comments" do + method(:comment_test1).comment.should == @comment1 + end + + it "should correctly strip leading whitespace before comments" do + method(:comment_test2).comment.should == @comment2 + end + + it "should keep empty comment lines" do + method(:comment_test3).comment.should == @comment3 + end + + it "should ignore blank lines between comments" do + method(:comment_test4).comment.should == @comment4 + end + + it "should align all comments to same indent level" do + method(:comment_test5).comment.should == @comment5 + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test_code_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test_code_helpers.rb new file mode 100644 index 000000000..ba83a6382 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/method_source-0.8.2/test/test_code_helpers.rb @@ -0,0 +1,41 @@ +describe MethodSource::CodeHelpers do + before do + @tester = Object.new.extend(MethodSource::CodeHelpers) + end + + [ + ["p = '", "'"], + ["def", "a", "(); end"], + ["p = < 1.1.0` +* Remove deprecated hooks API ([#1209](https://github.com/pry/pry/pull/1209)) +* Add 64-bit windows support. + +#### Bug fixes, etc. +* The `gem-install` command can require gems like `net-ssh` thanks to better + logic for guessing what path to require. (#1188) +* `toggle-color` command toggles the local `_pry_.color` setting instead of the + global `Pry.color`. +* Update `Pry::CLIPPED_PRINT` to include a hex representation of object ID when + printing a return value. (#1162) +* Wrap exceptions in a proxy instead of adding singleton methods. (#1145) + * `Pry#last_exception=` now supports exception objects that have been frozen. +* `binding.pry` inside `.pryrc` file now works, with some limitations (@richo / #1118) +* Add support for BasicObjects to `ls` (#984) +* Allow `ls -c ` (#891) +* Fix indentation not working if the `mathn` stdlib was loaded (#872) +* Fix `hist`'s `--exclude-pry` switch (#874) +* Fix `gem-install` on JRuby (#870) +* Fix source lookup for instrumented classes (#923) +* Improved thread safety when multiple instances are running (#944) +* Make `edit` ignore `-n`/`--no-reload` flag and `disable_auto_reload` config + in cases where the user was editing a tempfile +* Make `gem-cd` use the most recent gem, not the oldest +* Make `install-command` honor `.gemrc` switches (#666) +* Make `hist` with no parameters show just the current session's history (#205) + * `hist --all` shows older history +* Make `-s`/`--super` flag of `show-source`/`show-doc` work when method name is + being inferred from context (#877) +* Rename `--installed-plugins` flag to `--plugins` +* Strip ANSI codes from prompt before measuring length for indentation (#493) +* Fix bug in `edit` regarding recognition of file names without suffix. +* Reduced download size by removing tests etc. from distributed gem. + +#### Dev-facing changes +* `CommandSet#commands`, sometimes referenced through `Pry.commands.commands`, + renamed to `CommandSet#to_hash`. It returns a duplicate of the internal hash + a CommandSet uses. +* `CommandSet#keys` is now an alias of `CommandSet#list_commands`. +* All commands should now reference configuration values via `_pry_.config` + (local) and not `Pry.config` (global). (#1096) + * This change improves support for concurrent environments and + context-specific Pry sessions. `_pry_.config` inherits default values from + `Pry.config` but can override them locally. +* `rake pry` now accepts switches prefixed with `_` (e.g., `rake pry _v`) +* Pagers now act like `IO`s and accept streaming output + * See `_pry_.pager.page` and `_pry_.pager.open`. +* The `Pry` class has been broken up into two smaller classes. + * `Pry` represents non-UI-specific session state, including the eval string + * `Pry::REPL` controls the user-facing interface + * This should make it easier to drive Pry from alternative interfaces + * `Pry.start` now has a `:driver` option that defaults to `Pry::REPL` + * This involved a lot of refactoring and may break plugins that depend on + the old layout +* Add `ColorPrinter` subclass of `PP` for colorized object inspection +* Add `[]` and `[]=` methods to `CommandSet`, which find and replace commands + * Example: `Pry.commands["help"] = MyHelpCommand` +* The completion API has been refactored (see fdb703a8de4ef3) +* `Pry.config.input_stack` (and the input stack concept in general) no longer + exists +* There's a new `Pry::Terminal` class that implements a number of different + methods of determining the terminal's dimensions +* Add `ReplTester` class for high-level simulation of Pry sessions in tests +* Add `Pry.main`. Returns the special instance of Object referenced by self of + `TOPLEVEL_BINDING`: "main". +* Changed second argument of `Pry.view_clip()` from Fixnum to Hash to support + returning a string with or without a hex representation of object ID. (#1162) +* The `output` and `pager` objects will now strip color-codes, so commands should + always print in color. +* Commands now have a `state` hash that is persistent across invocations of the command + in the same pry session. + +### 0.9.12.6 (2014/01/28) +* Don't fail if Bond is not installed (#1106) + +### 0.9.12.5 (2014/01/27) +* Fix early readline errors by deferring require of readline (#1081, #1095) + +### 0.9.12.4 (2013/11/23) +* Fix issue with Coderay colors being black, even when on a black background (#1016) + +### 0.9.12.3 (2013/09/11) +* Bump Coderay dependency (#987) +* Fix consecutive newlines in heredocs being collapsed (#962) +* Fix pager not working in JRuby > 1.7.5 (#992) + +### 0.9.12.2 (2013/05/10) +* Make `reload-code` with no args reload "current" file (#920) + +### 0.9.12.1 (2013/04/21) +* Add workaround for JRuby crashing bug (#890) + * Related to http://jira.codehaus.org/browse/JRUBY-7114 + +### 0.9.12 (2013/02/12) +#### Features +* `pry --gem` (see 19bfc13aa) +* `show-source` now works on commands created with `create_command` +* `whereami` now has `-m` (method), `-c` (class), and `-f` (file) options +* `show-source` now falls back to superclass (and displays warning) if it + can't find class code +* `show-source`/`show-doc` now indicate when `-a` option is available + +#### Bug fixes, etc. +* Fix commands breaking due to Slop looking at `ARGV` instead of command + parameters (#828) +* Fix pager breaking in some situations (#845) +* Fix broken rendering of some docs (#795) +* Silence warnings during failed tab-completion attempts +* Fix broken prompt when prompt is colored (#822 / #823) +* Added `reload-method` as alias for `reload-code` (for backwards + compatibility) +* Reopen `Readline.output` if it is not a tty (see 1538bc0990) + +### 0.9.11.4 (2013/01/20) +* Fix pager not rendering color codes in some circumstances +* Add `Pry.last_internal_error`, useful for devs debugging commands + +### 0.9.11.3 (2013/01/17) +* Fix `Pry.run_command` +* Improve `ls` output +* Add `:requires_gem => "jist"` to `gist` command (so dependencies can be + installed via `install-command`) +* Improve help for `edit` command + +### 0.9.11.2 (2013/01/16) +* Fix minor bug in `gist` on Windows: rescue `Jist::ClipboardError` rather + than letting the scary error spill out to users and potentially having them + think the gist didn't post. + +### 0.9.11.1 (2013/01/16) +* Fix minor bug in `gist` command where I neglected to remove + a call to a non-existent method (`no_arg`) which was called when + `gist` is invoked with no parameters + +### 0.9.11 (2013/01/16) +#### Dependency changes +* Upgrade `slop` to `~> 3.4` +* New optional dependency: `bond` + * You'll need to perform `gem install bond` + * It improves autocompletion if you use Readline + * Does not work for libedit + (More info: https://github.com/pry/pry/wiki/FAQ#wiki-readline) + * Big thanks to cldwalker + +#### Features +* Basic Ruby 2.0 support (#738) +* JRuby 1.7.0+ support (#732) +* New `reload-code` command + * Reload code for methods, classes, commands, objects and so on + * Examples: `reload-code MyClass`, `reload-code my_method`, + `reload-code my_obj` +* Bond tab completion (see "Dependency changes") +* Consolidate "show" commands into `show-source` + * `show-source` can now extract source for: + * Classes + * Methods + * Procs + * Pry commands + * Arbitrary objects (it shows the source for the class of the object) + * As a result, `show-command` is now removed +* `gist`, `play`, and `save-file` now infer object type without requiring flags + * Examples: `play MyClass`, `play my_file.rb`, `play my_method` +* Consolidate editing commands into `edit` + * `edit` can now edit: + * Files + * Methods + * Classes + * Pry commands + * As a result, `edit-method` is now removed + * Examples: `edit MyClass`, `edit my_file.rb`, `edit my_method` +* `amend-line` and `play` now properly indent code added to input buffer +* Support for multiple require switches (`pry -rubygems -r./a.rb`) (#674) +* Support for multiple exec switches (`pry -e ':one' -e ':two'`) +* Ability to customize the name displayed in the prompt (#695) +* `--patch` switch for `edit --ex` command (#716) +* Respect the `$PAGER` environment variable (#736) +* `disable-pry` command (#497) +* Two new hooks, `before_eval` and `after_eval` +* Tab completion for `Array#` in `show-source` and `show-doc` +* `gem-install` immediately requires gems +* `-l` switch for `ls` command (displays local variables) +* `gem-open` command +* `fix-indent` command +* Subcommands API +* Public test API for plugin writers (see d1489a) +* Tabular `ls` output +* `--no-line-numbers` switch for `whereami` command +* `--lines` switch for `play` command + +#### Bug fixes, etc. +* Use single escape instead of double in `find-method` (#652) +* Fix blank string delimiters (#657) +* Fix unwanted `binding_impl_method` local in scratch bindings (#622) +* Fix `edit-method -p` changing constant lookup (#645) +* Fix `.pryrc` loading twice when invoked from `$HOME` directory (#682) +* Fix Pry not remembering initial `pwd` (#675) +* Fix multiline object coloring (#717) +* Fix `show-method` not supporting `String::new` notation (#719) +* Fix `whereami` command not showing correct line numbers (#754) +* Fix buggy Cucumber AST output (#751) +* Fix `while/until do` loops indentation (#787) +* Fix `--no-plugins` switch (#526) +* Ensure all errors go to the error handler (#774) +* Fix `.pryrc` loading with wrong `__FILE__` +* Fix pager not working if `less` is not available +* Fix `^D` in nested REPL +* Many small improvements to error message clarity and documentation formatting + +### 0.9.10 (2012/07/04) +#### Dependency changes +* Upgrade `slop` to version 3 (#561) +* Switch from `gist` gem to `jist` (#590) +* Upgrade `method_source` to 0.8 + +#### Features +* Add `--hist`, `-o` and `-k` flags to `gist` command (#572) +* Support `show-source`/`show-doc` on methods defined in `class_eval` (#584) +* Support `show-source`/`show-doc` on gem methods defined in C (#585) +* Add `--disable-plugin` and `--select-plugin` options (#596) +* Allow `cd -` to switch between bindings (#597) +* Add `Pry.config.should_load_local_rc` to turn off `./.pryrc` (#612) +* Allow running a file of Pry input with `pry ` +* Support colours in `ri` command +* Add `before_eval` hook +* The prompt proc now gets a lot more data when its arity is 1 + +#### Bug fixes, etc. +* Removed the `req` command (#554) +* Fix rendering bugs when starting Pry (#567) +* Fix `Array#pretty_print` on Jruby (#568) +* Fix `edit` on Windows (#575) +* Fix `find-method` in the presence of badly behaved objects (#576) +* Fix `whereami` in ERb files on Rails (#580) +* Raise fewer exceptions while tab completing (#632) +* Don't immediately quit Pry when an error happens in Readline (#605) +* Support for `ansicon` to give JRuby Windows users colour (#606) +* Massive speed improvements to `show-source` for modules (#613) +* Improve `whereami` command when not in a `binding.pry` (#620) +* Support embedded documents (`=begin` ... `=end`) (#622) +* Support editing files with spaces in the name (#627) +* Renamed `__binding_impl__` to `__pry__` +* Support for absolute paths in `$EDITOR` +* Fix `cat` command on files with unknown extensions +* Many, many internal refactorings and tidyings + +### 0.9.9.6 (2012/05/09) +* Fix `ZeroDivisionError` in `correct_indentation` (#558) + +### 0.9.9.5 (2012/05/09) +* Fix `ZeroDivisionError` in `correct_indentation` (#558) +* Fix double highlighting in RDoc (#562) +* Automatically create configuration for plugins (#548) + +### 0.9.9.4 (2012/04/26) +* Fix `NoMethodError: undefined method `winsize' for #>` (#549) +* Fixes for JRuby +* Fix syntax error on `exit` (550) +* Heredoc content no longer auto-indented + +### 0.9.9.3 (2012/04/19) +* Fix `show-doc` failing on some core classes, like `Bignum` + +### 0.9.9.2 (2012/04/18) +* Make `correct_indentation`'s auto-colorization respect `Pry.color` + +### 0.9.9.1 (2012/04/18) +* Clear up confusion in `show-source`/`show-doc` docs + * `-a` switch applies to classes as well as modules + +### 0.9.9 (2012/04/18) +#### New features +* Lines of input are syntax highlighted upon Enter keypress +* `show-source` command can now show class/module source code + * Use `-a` to see all monkeypatches + * Hard dependency on `ruby18_source_location` gem in MRI 1.8 +* `show-doc` command can now show class/module docs + * Use `-a` to see docs for all monkeypatches + * Hard dependency on `ruby18_source_location` gem in MRI 1.8 +* New `find-method` command + * Performs a recursive search in a namespace for the existence of methods + * Can find methods whose names match a regex or methods which contain + provided code + * This command is like a ruby-aware `grep`, very cool (thanks swarley) +* [`pry-coolline`](https://github.com/pry/pry-coolline) now works properly +* `alias_command` method now much more powerful + * Example: `alias_command "lM", "ls -M"` +* `whereami` is now more intelligent + * Automatically shows entire source code of current method if current + context is a method (thanks robgleeson) +* New `raise-up` command + * Allows you to raise an exception that will bubble out of pry (ending the + session) and escape into enclosing program + +#### Bug fixes, etc. +* Fixed crash when paging under Windows +* Lines ending with `\` are incomplete (kudos to fowl) +* `edit-method -n` no longer blocks (thanks misfo) +* Show instance methods of modules by default in `ls` +* Docs for REPL-defined methods can now be displayed using `show-doc` +* Autoload `ruby18_source_location` on MRI 1.8, when available + * See https://github.com/conradirwin/ruby18_source_location +* Tab completion should work on first line now (historic bug fixed) +* `:quiet => true` option added to `Pry.start`, turns off `whereami` +* Another easter egg added +* Show unloaded constants in yellow for `ls` +* Improved documentation for `Pry.config` options +* Improved auto-indentation +* JRuby: heuristics used to clean up `ls` output + * Fewer internal methods polluting output + +### 0.9.8.4 (2012/6/3) +* ~/.pry_history wasnt being created (if it did not exist)! FIXED +* `hist --save` saved colors! FIXED +* added Pry#add_sticky_local API for adding sticky locals to individual pry instances + +### 0.9.8.3 (2012/3/2) +* various tweaks to improve rbx support +* commands now support optional block arguments +* much improved help command +* updated method_source dependencya +* added wtf command +* jruby should now work in windows (though without color) + +### 0.9.8.2 (2012/2/9) +* fixed bugs related to --super +* upgraded slop dependency +* added edit -c (edit current line) +* edit now respects Pry.config.disable_autoreload option + +### 0.9.8.1 (2012/1/30) +* fixed broken --no-plugins option +* Ensure ARGV is not mutated during option parsing. +* Use a more rbx-friendly test for unicodeness +* Use rbx-{18,19}mode as indicated http://about.travis-ci.org/docs/user/languages/ruby/ +* Don't explode in gem-list [Fixes #453, #454] +* Check for command-name collision on assignment [Fixes #450] + +### 0.9.8 (2012/1/25) + +MAJOR NEW FEATURES +- upgraded command api, https://github.com/pry/pry/wiki/Custom-commands +- added a system of hooks for customizing pry behaviour +- changed syntax checking to use eval() for improved accuracy +- added save-file command +- added gist command (removed gist-method, new gist command is more general) + +complete CHANGELOG: +* CommandError's no longer cause the current input to be disgarded +* Better syntax highlighting for rbx code code +* added cat --in to show pry input history +* prefixed temporary file names with 'pry' +* show-doc now supports -l and -b options (line numbers) +* play now supports -i and -d options +* moved UserCommandAPI command-set to pry-developer_tools plugin +* added :when_started event for hooks, called in Pry.start +* added a man page +* added rename method to Pry::CommandSet (commands can be renamed) +* added CommandSet#{before_command,after_command} for enhancing builtin commands +* added checking for namespace collisions with pry commands, set Pry.config.collision_warning +* work around namespace collisions by ensuring lines starting with a space are executed as +* ruby.work around namespace collisions by prensuring lines starting with a space are executed as ruby +* added handlers for Ctrl+C (SIGINT) on jruby, these are now caught as in other ruby versions +* removed dependency on ruby_parser +* prevented colours leaking across the pry prompt +* fixed edge cases in Pry::Method, for methods with crazy names and methods that have been 'undef'd +* refactored history handling code for clarity and correctness +* added Pry::WrappedModule as a counterpart to Pry::Method +* made a trailing , cause pry to wait for further input +* removed gist-method command, added gist command +* added pry-backtrace command to show history of current session +* fixed whereami within 'super' methods +* replaced inline version guards by Pry::Helpers::BaseHelpers.{rbx?,jruby?,windows?} etc. +* removed the CommandProcessor, its functionality is part of the new Command class +* changed cd .. at the top level so it doesn't quit pry. +* changed edit-command to no-longer need a command set argument +* fixed empty lines so that they don't replace _ by nil +* fixed SyntaxErrors at the REPL level so they don't replace _ex_. + +### 0.9.7.4 (2011/11/5) +* ls -M now works in modules (bugfix) +* added exception msg for bad cd object/path +* no longer die when encounter exceptions in .pryrc +* baked in CoolLine support +* Pry.config.input in .pryrc now respected + +### 0.9.7.3 (2011/10/28) +* really fixed indentation for 'super if' and friends +* Fixed indentation for tmux +* added Pry.config.correct_indent option (to toggle whether indentation +* corrected optional param behaviour for method signatures: e.g Signature meth(param1=?, param2=?) + +### 0.9.7.2 (2011/10/27) +* fixed indentation for 'super if' and 'ensure', 'next if', etc +* refactored Pry#run_command so it can accept an eval_string parameter (so amend-line and so on can work with it) +* changed ^D so it no longer resets indent level automatically + +### 0.9.7.1 (2011/10/26) +* fixed gem dependecy issues + +### 0.9.7 (2011/10/25) + +MAJOR NEW FEATURES: +- upgraded ls command to have a more intuitive interface +- added automatic indentation (thanks YorickPeterse!) +- added Pry::Method wrapper class to encapsulate method-related functionality + +complete CHANGELOG: +* fixed syntax highlighting for object literals +* fixed ActiveSupport method-naming conflict with "in?" +* added --super option to edit-method, show-method, and friends - making it easier to operate on superclass methods +* officially added edit --in to open previous expressions in an editor +* whereami now works for REPL-defined code +* started using JRuby parser for input validation in JRuby (thanks pangloss!) +* fixed bug where ~/.pryrc could be loaded more than once (thanks kelseyjudson!) +* added parse_options! helper to pull option parsing out of commands +* Pry now respects the terminal's input encoding +* moved some requires out of the startup process for improved speed +* added input_array info to DEFAULT_PROMPT, e.g [1] pry(main)> +* added --no-history option to pry binary (prevent history being LOADED, history will still be saved) + +### 0.9.6.2 (2011/9/27) +* downgrading to CodeRay 0.9.8 due to problems with 1.0 and rails (autoloading problem) see #280 on pry and #6 on CodeRay +* also added (as a minor feature) cirwin's implementation of edit --in +* added early break/exit for objectpath errors (the 'cd 34/@hello/bad_path/23') + +### 0.9.6 (2011/9/19) +* restored previous behavior of command-line switches (allowing "-rfilename") +* removed -p option (--play) from edit command +* `edit` with no arguments now edits the current or most recent expression +* `edit` auto-reloads .rb files (need to specify -n to suppress) +* added -p option (--patch) to edit-method command, which allows + monkeypatching methods without touching the original file +* edit-method can now edit REPL-defined methods +* cat --ex now works on exceptions in REPL-defined code +* play -m now uses eval_string.replace() +* play -m --open uses show-input to show play'd code +* added "unindent" helper to make adding help to commands easier +* local ./.pryrc now loaded after ~/.pryrc if it exists +* cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves throuh successive levels of the backtrace automatically with state stored on the exceptino object itself +* new option Pry.config.exception_window_size determines window size for cat --ex +* input_stack now implemented - pushing objects onto a pry instance's input_stack causes the instance to read from those objects in turn as it encounters EOF on the previous object. On finishing the input_stack the input object for the pry instance is set back to Pry.config.input, if this fails, pry breaks out of the REPL (throw(:breakout)) with an error message +* Pry.config.system() defines how pry runs system commands +* now injecting target_self method into command scope +* play now performs 'show-input' always unless eval_string contains a valid expression (i.e it's about to be eval'd) +* play and hist --replay now push the current input object onto the input_stack before redirecting input to a StringIO (works much better with pry-remote now) + +### 0.9.5 (2011/9/8) + +MAJOR NEW FEATURES: +- JRuby support, including show-method/edit-method and editor integration on both 1.8 and 1.9 versions +- extended cd syntax: cd ../@x/y +- play command now works much better with _in_ array (this is a very powerful feature, esp with Pry::NAV_PROMPT) +- history saving/loading is now lightning fast +- 'edit' (entered by itself) now opens current lines in input buffer in an editor, and evals on exit +- 'edit' command is also, in general more intelligent +- ls output no longer in array format, and colors can be configured, e.g: Pry.config.ls.ivar_color = :bright_blue +- new switch-to command for moving around the binding stack without exiting out of sessions +- more sophisticated prompts, Pry::NAV_PROMPT to ease deep spelunking of code +- major bug fix for windows systems +- much better support for huge objects, should no longer hang pry (see #245) +- cat --ex and edit --ex now work better + +complete CHANGELOG: +* tempfile should end in .rb (for edit -t) +* ls output should not be in array format +* fix history saving (should not save all of Readline::HISTORY, but only what changed) +* prevent blank lines going to Readline::HISTORY (thanks cirwin!) +* ensure that cat --ex emulates the `whereami` format - includes line numbers and formatted the same, etc +* fixed bug #200 ( https://github.com/pry/pry/issues/200 )- string interpolation bug (thanks to ryanf) +* show-doc and stat now display method visibility (update WIKI) +* got rid of warnings caused by stricter ruby 1.9.3 rules +* remove interpolation of command names and fix interpolation error messag (update WIKI) (thanks ryanf!) +* 'nested sessions' now use binding stacks (so each instance manages its own collection of bindings without spawning other instances) +* 'cd ..' just pops a binding off the binding_stack with special behaviour when only one binding in stack - it breaks out of the repl loop +* added switch-to command (like jump-to but doesnt unwind the stack) +* show-method and show-doc now accept multiple method names +* control_d hook added (Pry.config.control_d_handler) +* behaviour of ^d is now to break out of current expr if in multi-line expr, or break out of current context if nested, or break out of pry repl loop if at top-level +* can no longer interpolate command name itself e.g #{x}-#{y} where x = "show" and y = "doc" +* ^C no longer captured +* got rid of Pry.active_instance, Pry.last_exception and friends. +* also special locals now shared among bindings in a pry instance (i.e _ex_ (and friends) re-injected into new binding entered with 'cd') +* renamed inp and out to _in_ and _out_ (to avoid collisions with actual locals in debugging scope) +* added third parameter to prompts, the pry instance itself (_pry) see https://github.com/pry/pry/issues/233 for why it's important +* cd behaviour when no args performs the same as `cd /` +* commands with keep_retval can now return nil (to suppress output now return 'void' instead) +* Pry::CommandProcessor::Result introduced +* Pry.view_clip() modified to be more robust and properly display Class#name +* edit command when invoked with no args now works like edit -t +* when edit is invoked (with no args or with -t) inside a multi-line expression input buffer, it dumps that buffer into a temp file and takes you to it +* got rid of Pry#null_input? since all that was needed was eval_string.empty? +* cd command now supports complex syntax: cd ../@y/y/../z +* JRuby is no longer a 2nd class citizen, almost full JRuby support, passing 100% tests +* added Pry::NAV_PROMPT (great new navigation prompt, per robgleeson) and Pry::SIMPLE_PRINT for simple (IRB-style) print output (just using inspect) +* _pry_ now passed as 3rd parameter to :before_session hook +* ls colors now configurable via Pry.config.ls.local_var_color = :bright_red etc +* ls separator configurable via, e.g Pry.config.ls.separator = " " +* Pry.view_clip() now only calls inspect on a few immediates, otherwise uses the #<> syntax, which has been truncated further to exclude teh mem address, again related to #245 + +### 0.9.3 (2011/7/27) +* cat --ex (cats 5 lines above and below line in file where exception was raised) +* edit --ex (edits line in file where exception was raised) +* edit -t (opens a temporary file and evals it in current context when closed) +* `pry -r` requires now happen after plugin loading (so as not to interfere with +* new Pry.config.disable_auto_reload option, for turning off auto reloading by edit-method and related (thanks ryanf) +* add better error messages for `cd` command +* fixed exotic object regression - BasicObject.new etc now return "=> unknown" +* added reload-method command (reloads the associated file of a method) +* converted: import => import-set, version => pry-version, install => install-command +* Pry.config.command_prefix support (thanks ryanf!) +* fixed indentation for simple-prompt +* hist command now excludes last line of input (the command invocation itself) +* hist now has `history` alias +* missing plugins no longer raise exception, just print a warning to $stderr +* fixed jedit editor support + +### 0.9.2 (2011/6/21) +* fixed string interpolation bug (caused valid ruby code not to execute, sorry!) +* fixed `ls` command, so it can properly display members of Object and classes, and BasicObject, etc +* added a few git related commands to experimental command set, blame and diff + +### 0.9.0 (2011/6/17) +* plugin system +* regex commands +* show-method works on methods defined in REPL +* new command system/API +* rubinius core support +* more backports to ruby 1.8 +* inp/out special locals +* _ex_ backtrace navigation object (_ex_.line, _ex_.file) +* readline history saving/loading +* prompt stack +* more hooks +* amend-line +* play +* show-input +* edit +* much more comprehensive test suite +* support for new and old rubygems API +* changed -s behaviour of ls (now excludes Object methods) +* removed eval-file, lls, lcd, and a few other commands + + +### 0.7.6.1 (2011/3/26) +* added slightly better support for YARD +* now @param and @return tags are colored green and markdown `code` is syntax highlighted using coderay + +### 0.7.6 (2011/3/26) +* `whereami` command now accepts parameter AROUND, to display AROUND lines on eitherside of invocation line. +* made it so `whereami` is invoked even if no method exists in current context (i.e in rspec tests) +* added rubinius support for `whereami` invocation in HOOKS by checking for __unknown__.rb rather than just
+ +### 0.7.0 (2011/3/15) +* add pry-doc support with syntax highlighting for docs +* add 'mj' option to ls (restrict to singleton methods) +* add _ex_ local to hold last exception raised in an exception + +### 0.6.8 (2011/3/6) +* add whereami command, a la the `ir_b` gem +* make whereami run at the start of every session +* make .pryrc be loaded by run-time pry sessions + +### 0.6.7 (2011/3/4) +* color support +* --simple-prompt for pry commandline +* -I mode for pry commandline +* --color mode for pry commandline +* clean up requires (put them all in one place) +* simple-prompt command and toggle-color commandd. + +### 0.6.3 (2011/2/28) +* Using MethodSource 0.3.4 so 1.8 show-method support provided +* `Set` class added to list of classes that are inspected + +### 0.6.1 (2011/2/26) +* !@ command alias for exit_all +* `cd /` for breaking out to pry top level (jump-to 0) +* made `-e` option work in a more effective way for `pry` command line invocation +* exit and exit-all commands now accept a parameter, this parameter becomes the return value of repl() +* `command` method from CommandBase now accepts a :keep_retval arg that determines if command value is returned to pry session or just `nil` (`nil` was old behaviour) +* tests for new :keep_retval and exit-all/exit behaviour; :keep_retval will remain undocumented. + +### 0.5.8 (2011/2/22) +* Added -c (context) option to show-doc, show-methods and eval-file +* Fixed up ordering issue of -c and -r parameters to command line pry + +### 0.5.7 (2011/2/21) +* Added pry executable, auto-loads .pryrc in user's home directory, if it + exists. + +### 0.5.5 (2011/2/19) +* Added Pry.run_command +* More useful error messages +* Easter eggs (game and cohen-poem) + +### 0.5.0 (2011/2/17) +* Use clipped version of Pry.view() for large objects +* Exit Pry session on ^d +* Use Shellwords for breaking up parameters to pry commands +* Use OptionParser to parse options for default pry commands +* Add version command +* Refactor 'status' command: add current method info +* Add meth_name_from_binding utility lambda to commands.rb +* Add -M, -m, -v(erbose), -a(ll), -s(uper), -l(ocals), -i(ivars), -k(klass + vars), etc options to ls +* add -M(instance method) options to show-method and show-doc +* add --help option to most commands +* Get rid of ls_method and ls_imethods (subsumed by more powerful ls) +* Get rid of show_idoc and show_imethod +* Add special eval-file command that evals target file in current context + +### 0.4.5 (2011/1/27) +* fixed show_method (though fragile as it references __binding_impl__ + directly, making a name change to that method difficult + +### 0.4.4 (2011/1/27) +* oops, added examples/ directory + +### 0.4.3 (2011/1/26) +* added alias_command and desc methods to Pry::CommandBase +* changed behaviour of ls_methods and ls_imethods to return sorted lists + of methods + +### 0.4.1 (2011/1/23) +* made it so a 'def meth;end' in an object Pry session defines singleton + methods, not methods on the class (except in the case of + immediates) +* reorganized documentation, moving customization to a separate wiki file +* storing wiki in a nested git repo, as github wiki pages have their own + repo +* added more tests for new method definition behaviour + +### 0.4.0 (2011/1/21) +* added command API +* added many new commands, i.e ls_methods and friends +* modified other commands +* now accepts greater customization, can modify: input, output, hooks, + prompt, print object +* added tab completion (even completes commands) +* added extensive tests +* added examples +* many more changes + +### 0.1.3 (2010/12/9) +* Got rid of rubygems dependency, refactored some code. + +### 0.1.2 (2010/12/8) +* now rescuing SyntaxError as well as Racc::Parser error in valid_expression? + +### 0.1.0 (2010/12/8) +* release! diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/LICENSE b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/LICENSE new file mode 100644 index 000000000..125800408 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/LICENSE @@ -0,0 +1,25 @@ +License +------- + +(The MIT License) + +Copyright (c) 2013 John Mair (banisterfiend) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/README.md b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/README.md new file mode 100644 index 000000000..b42c87a8e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/README.md @@ -0,0 +1,406 @@ +[![Build Status](https://img.shields.io/travis/pry/pry.svg)](https://travis-ci.org/pry/pry) +[![Code Climate](https://img.shields.io/codeclimate/github/pry/pry.svg)](https://codeclimate.com/github/pry/pry) +[![Inline docs](http://inch-ci.org/github/pry/pry.svg)](http://inch-ci.org/github/pry/pry) + +
+![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png) + +© John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2013
+ +**Please** [DONATE](http://www.pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development! + +**Sponsors** + +[Tealeaf Academy](http://www.gotealeaf.com)
+[Atomic Object](http://www.atomicobject.com/)
+[Hashrocket](http://hashrocket.com/)
+[Intridea](http://intridea.com/)
+[Gaslight](http://gaslight.co/home)
+ +**Other Resources** + +[Skip to the website (recommended)](http://pry.github.com)
+[Skip to the wiki](https://github.com/pry/pry/wiki) +
+ +Pry is a powerful alternative to the standard IRB shell for Ruby. It is +written from scratch to provide a number of advanced features, +including: + +* Source code browsing (including core C source with the pry-doc gem) +* Documentation browsing +* Live help system +* Open methods in editors (`edit Class#method`) +* Syntax highlighting +* Command shell integration (start editors, run git, and rake from within Pry) +* Gist integration +* Navigation around state (`cd`, `ls` and friends) +* Runtime invocation (use Pry as a developer console or debugger) +* Exotic object support (BasicObject instances, IClasses, ...) +* A Powerful and flexible command system +* Ability to view and replay history +* Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs +* A wide-range number of [plugins](https://github.com/pry/pry/wiki/Available-plugins) that provide remote sessions, full debugging functionality, and more. + +Pry also aims to be more than an IRB replacement; it is an +attempt to bring REPL driven programming to the Ruby language. It is +currently not as powerful as tools like [SLIME](http://en.wikipedia.org/wiki/SLIME) for lisp, but that is the +general direction Pry is heading. + +Pry is also fairly flexible and allows significant user +[customization](https://github.com/pry/pry/wiki/Customization-and-configuration) +is trivial to set it to read from any object that has a `readline` method and write to any object that has a +`puts` method - many other aspects of Pry are also configurable making +it a good choice for implementing custom shells. + +Pry comes with an executable so it can be invoked at the command line. +Just enter `pry` to start. A `.pryrc` file in the user's home directory will +be loaded if it exists. Type `pry --help` at the command line for more +information. + +Try `gem install pry-doc` for additional documentation on Ruby Core +methods. The additional docs are accessed through the `show-doc` and +`show-method` commands. + +* Install the [gem](https://rubygems.org/gems/pry): `gem install pry` +* Browse the comprehensive [documentation at the official Pry wiki](https://github.com/pry/pry/wiki) +* Read the [YARD API documentation](http://rdoc.info/github/pry/pry/master/file/README.markdown) +* See the [source code](http://github.com/pry/pry) + +### Commands + +Nearly every piece of functionality in a Pry session is implemented as +a command. Commands are not methods and must start at the beginning of a line, with no +whitespace in between. Commands support a flexible syntax and allow +'options' in the same way as shell commands, for example the following +Pry command will show a list of all private instance methods (in +scope) that begin with 'pa' + + pry(YARD::Parser::SourceParser):5> ls -Mp --grep ^pa + YARD::Parser::SourceParser#methods: parse parser_class parser_type parser_type= parser_type_for_filename + +### Navigating around state + +Pry allows us to pop in and out of different scopes (objects) using +the `cd` command. This enables us to explore the run-time view of a +program or library. To view which variables and methods are available +within a particular scope we use the versatile [ls command.](https://gist.github.com/c0fc686ef923c8b87715) + +Here we will begin Pry at top-level, then Pry on a class and then on +an instance variable inside that class: + + pry(main)> class Hello + pry(main)* @x = 20 + pry(main)* end + => 20 + pry(main)> cd Hello + pry(Hello):1> ls -i + instance variables: @x + pry(Hello):1> cd @x + pry(20):2> self + 10 + => 30 + pry(20):2> cd .. + pry(Hello):1> cd .. + pry(main)> cd .. + +The number after the `:` in the pry prompt indicates the nesting +level. To display more information about nesting, use the `nesting` +command. E.g + + pry("friend"):3> nesting + Nesting status: + 0. main (Pry top level) + 1. Hello + 2. 100 + 3. "friend" + => nil + +We can then jump back to any of the previous nesting levels by using +the `jump-to` command: + + pry("friend"):3> jump-to 1 + => 100 + pry(Hello):1> + +### Runtime invocation + +Pry can be invoked in the middle of a running program. It opens a Pry +session at the point it's called and makes all program state at that +point available. It can be invoked on any object using the +`my_object.pry` syntax or on the current binding (or any binding) +using `binding.pry`. The Pry session will then begin within the scope +of the object (or binding). When the session ends the program continues with any +modifications you made to it. + +This functionality can be used for such things as: debugging, +implementing developer consoles and applying hot patches. + +code: + + # test.rb + require 'pry' + + class A + def hello() puts "hello world!" end + end + + a = A.new + + # start a REPL session + binding.pry + + # program resumes here (after pry session) + puts "program resumes here." + +Pry session: + + pry(main)> a.hello + hello world! + => nil + pry(main)> def a.goodbye + pry(main)* puts "goodbye cruel world!" + pry(main)* end + => nil + pry(main)> a.goodbye + goodbye cruel world! + => nil + pry(main)> exit + + program resumes here. + +### Command Shell Integration + +A line of input that begins with a '.' will be forwarded to the +command shell. This enables us to navigate the file system, spawn +editors, and run git and rake directly from within Pry. + +Further, we can use the `shell-mode` command to incorporate the +present working directory into the Pry prompt and bring in (limited at this stage, sorry) file name completion. +We can also interpolate Ruby code directly into the shell by +using the normal `#{}` string interpolation syntax. + +In the code below we're going to switch to `shell-mode` and edit the +`.pryrc` file in the home directory. We'll then cat its contents and +reload the file. + + pry(main)> shell-mode + pry main:/home/john/ruby/projects/pry $ .cd ~ + pry main:/home/john $ .emacsclient .pryrc + pry main:/home/john $ .cat .pryrc + def hello_world + puts "hello world!" + end + pry main:/home/john $ load ".pryrc" + => true + pry main:/home/john $ hello_world + hello world! + +We can also interpolate Ruby code into the shell. In the +example below we use the shell command `cat` on a random file from the +current directory and count the number of lines in that file with +`wc`: + + pry main:/home/john $ .cat #{Dir['*.*'].sample} | wc -l + 44 + +### Code Browsing + +You can browse method source code with the `show-method` command. Nearly all Ruby methods (and some C methods, with the pry-doc +gem) can have their source viewed. Code that is longer than a page is +sent through a pager (such as less), and all code is properly syntax +highlighted (even C code). + +The `show-method` command accepts two syntaxes, the typical ri +`Class#method` syntax and also simply the name of a method that's in +scope. You can optionally pass the `-l` option to show-method to +include line numbers in the output. + +In the following example we will enter the `Pry` class, list the +instance methods beginning with 're' and display the source code for the `rep` method: + + pry(main)> cd Pry + pry(Pry):1> ls -M --grep re + Pry#methods: re readline refresh rep repl repl_epilogue repl_prologue retrieve_line + pry(Pry):1> show-method rep -l + + From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb @ line 143: + Number of lines: 6 + + 143: def rep(target=TOPLEVEL_BINDING) + 144: target = Pry.binding_for(target) + 145: result = re(target) + 146: + 147: show_result(result) if should_print? + 148: end + +Note that we can also view C methods (from Ruby Core) using the +`pry-doc` plugin; we also show off the alternate syntax for +`show-method`: + + pry(main)> show-method Array#select + + From: array.c in Ruby Core (C Method): + Number of lines: 15 + + static VALUE + rb_ary_select(VALUE ary) + { + VALUE result; + long i; + + RETURN_ENUMERATOR(ary, 0, 0); + result = rb_ary_new2(RARRAY_LEN(ary)); + for (i = 0; i < RARRAY_LEN(ary); i++) { + if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + rb_ary_push(result, rb_ary_elt(ary, i)); + } + } + return result; + } + +### Documentation Browsing + +One use-case for Pry is to explore a program at run-time by `cd`-ing +in and out of objects and viewing and invoking methods. In the course +of exploring it may be useful to read the documentation for a +specific method that you come across. Like `show-method` the `show-doc` command supports +two syntaxes - the normal `ri` syntax as well as accepting the name of +any method that is currently in scope. + +The Pry documentation system does not rely on pre-generated `rdoc` or +`ri`, instead it grabs the comments directly above the method on +demand. This results in speedier documentation retrieval and allows +the Pry system to retrieve documentation for methods that would not be +picked up by `rdoc`. Pry also has a basic understanding of both the +rdoc and yard formats and will attempt to syntax highlight the +documentation appropriately. + +Nonetheless, the `ri` functionality is very good and +has an advantage over Pry's system in that it allows documentation +lookup for classes as well as methods. Pry therefore has good +integration with `ri` through the `ri` command. The syntax +for the command is exactly as it would be in command-line - +so it is not necessary to quote strings. + +In our example we will enter the `Gem` class and view the +documentation for the `try_activate` method: + + pry(main)> cd Gem + pry(Gem):1> show-doc try_activate + + From: /Users/john/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb @ line 201: + Number of lines: 3 + + Try to activate a gem containing path. Returns true if + activation succeeded or wasn't needed because it was already + activated. Returns false if it can't find the path in a gem. + pry(Gem):1> + +We can also use `ri` in the normal way: + + pry(main) ri Array#each + ----------------------------------------------------------- Array#each + array.each {|item| block } -> array + ------------------------------------------------------------------------ + Calls _block_ once for each element in _self_, passing that element + as a parameter. + + a = [ "a", "b", "c" ] + a.each {|x| print x, " -- " } + + produces: + + a -- b -- c -- + +### Gist integration + +If the `gist` gem is installed then method source or documentation can be gisted to github with the +`gist` command. The `gist` command is capable of gisting [almost any REPL content](https://gist.github.com/cae143e4533416529726), including methods, documentation, +input expressions, command source, and so on. In the example below we will gist the C source +code for the `Symbol#to_proc` method to github: + + pry(main)> gist -m Symbol#to_proc + Gist created at https://gist.github.com/5332c38afc46d902ce46 and added to clipboard. + pry(main)> + +You can see the actual gist generated here: [https://gist.github.com/5332c38afc46d902ce46](https://gist.github.com/5332c38afc46d902ce46) + +### Edit methods + +You can use `edit Class#method` or `edit my_method` +(if the method is in scope) to open a method for editing directly in +your favorite editor. Pry has knowledge of a few different editors and +will attempt to open the file at the line the method is defined. + +You can set the editor to use by assigning to the `Pry.editor` +accessor. `Pry.editor` will default to `$EDITOR` or failing that will +use `nano` as the backup default. The file that is edited will be +automatically reloaded after exiting the editor - reloading can be +suppressed by passing the `--no-reload` option to `edit` + +In the example below we will set our default editor to "emacsclient" +and open the `Pry#repl` method for editing: + + pry(main)> Pry.editor = "emacsclient" + pry(main)> edit Pry#repl + +### Live Help System + +Many other commands are available in Pry; to see the full list type +`help` at the prompt. A short description of each command is provided +with basic instructions for use; some commands have a more extensive +help that can be accessed via typing `command_name --help`. A command +will typically say in its description if the `--help` option is +avaiable. + +### Use Pry as your Rails Console + +The recommended way to use Pry as your Rails console is to add +[the `pry-rails` gem](https://github.com/rweng/pry-rails) to +your Gemfile. This replaces the default console with Pry, in +addition to loading the Rails console helpers and adding some +useful Rails-specific commands. + +If you don't want to change your Gemfile, you can still run a Pry +console in your app's environment using Pry's `-r` flag: + + pry -r ./config/environment + +Also check out the [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry) +for more information about integrating Pry with Rails. + +### Limitations: + +* Tab completion is currently a bit broken/limited this will have a + major overhaul in a future version. + +### Syntax Highlighting + +Syntax highlighting is on by default in Pry. If you want to change +the colors, check out the [pry-theme](https://github.com/kyrylo/pry-theme) +gem. + +You can toggle the syntax highlighting on and off in a session by +using the `toggle-color` command. Alternatively, you can turn it off +permanently by putting the line `Pry.color = false` in your `~/.pryrc` +file. + +### Future Directions + +Many new features are planned such as: + +* Increase modularity (rely more on plugin system) +* Much improved documentation system, better support for YARD +* Better support for code and method reloading and saving code +* Extended and more sophisticated command system, allowing piping +between commands and running commands in background + +### Contact + +Problems or questions? file an issue at [github](https://github.com/pry/pry/issues) + +### Contributors + +Pry is primarily the work of [John Mair (banisterfiend)](http://github.com/banister), for full list +of contributors see the +[CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file. diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/bin/pry b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/bin/pry new file mode 100755 index 000000000..3904fe96d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/bin/pry @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +# (C) John Mair (banisterfiend) +# MIT license + +$0 = 'pry' + +begin + require 'pry' +rescue LoadError + require 'rubygems' + require 'pry' +end + +# Process command line options and run Pry +Pry::CLI.parse_options diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry.rb new file mode 100644 index 000000000..a8e81c09f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry.rb @@ -0,0 +1,161 @@ +# (C) John Mair (banisterfiend) 2013 +# MIT License +# +require 'pp' + +require 'pry/input_lock' +require 'pry/exceptions' +require 'pry/helpers/base_helpers' +require 'pry/hooks' +require 'forwardable' + +class Pry + # The default hooks - display messages when beginning and ending Pry sessions. + DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_| + next if _pry_.quiet? + _pry_.run_command("whereami --quiet") + end + + # The default print + DEFAULT_PRINT = proc do |output, value, _pry_| + _pry_.pager.open do |pager| + pager.print _pry_.config.output_prefix + Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1) + end + end + + # may be convenient when working with enormous objects and + # pretty_print is too slow + SIMPLE_PRINT = proc do |output, value| + begin + output.puts value.inspect + rescue RescuableException + output.puts "unknown" + end + end + + # useful when playing with truly enormous objects + CLIPPED_PRINT = proc do |output, value| + output.puts Pry.view_clip(value, id: true) + end + + # Will only show the first line of the backtrace + DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _| + if UserError === exception && SyntaxError === exception + output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}" + else + output.puts "#{exception.class}: #{exception.message}" + output.puts "from #{exception.backtrace.first}" + end + end + + DEFAULT_PROMPT_NAME = 'pry' + + # The default prompt; includes the target and nesting level + DEFAULT_PROMPT = [ + proc { |target_self, nest_level, pry| + "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> " + }, + + proc { |target_self, nest_level, pry| + "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* " + } + ] + + DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false] + + # A simple prompt - doesn't display target or nesting level + SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }] + + NO_PROMPT = [proc { '' }, proc { '' }] + + SHELL_PROMPT = [ + proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " }, + proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} * " } + ] + + # A prompt that includes the full object path as well as + # input/output (_in_ and _out_) information. Good for navigation. + NAV_PROMPT = [ + proc do |_, _, _pry_| + tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / " + "[#{_pry_.input_array.count}] (#{_pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}> " + end, + proc do |_, _, _pry_| + tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / " + "[#{_pry_.input_array.count}] (#{ _pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}* " + end, + ] + + # Deal with the ^D key being pressed. Different behaviour in different cases: + # 1. In an expression behave like `!` command. + # 2. At top-level session behave like `exit` command. + # 3. In a nested session behave like `cd ..`. + DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_| + if !eval_string.empty? + eval_string.replace('') # Clear input buffer. + elsif _pry_.binding_stack.one? + _pry_.binding_stack.clear + throw(:breakout) + else + # Otherwise, saves current binding stack as old stack and pops last + # binding out of binding stack (the old stack still has that binding). + _pry_.command_state["cd"] ||= Pry::Config.from_hash({}) # FIXME + _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup + _pry_.binding_stack.pop + end + end + + DEFAULT_SYSTEM = proc do |output, cmd, _| + if !system(cmd) + output.puts "Error: there was a problem executing system command: #{cmd}" + end + end + + # Store the current working directory. This allows show-source etc. to work if + # your process has changed directory since boot. [Issue #675] + INITIAL_PWD = Dir.pwd + + # This is to keep from breaking under Rails 3.2 for people who are doing that + # IRB = Pry thing. + module ExtendCommandBundle; end +end + +require 'method_source' +require 'shellwords' +require 'stringio' +require 'coderay' +require 'slop' +require 'rbconfig' +require 'tempfile' +require 'pathname' + +require 'pry/version' +require 'pry/repl' +require 'pry/rbx_path' +require 'pry/code' +require 'pry/history_array' +require 'pry/helpers' +require 'pry/code_object' +require 'pry/method' +require 'pry/wrapped_module' +require 'pry/history' +require 'pry/command' +require 'pry/command_set' +require 'pry/commands' +require 'pry/plugins' +require 'pry/core_extensions' +require 'pry/pry_class' +require 'pry/pry_instance' +require 'pry/cli' +require 'pry/color_printer' +require 'pry/pager' +require 'pry/terminal' +require 'pry/editor' +require 'pry/rubygem' +require "pry/indent" +require "pry/last_exception" +require "pry/prompt" +require "pry/inspector" +require 'pry/object_path' +require 'pry/output' diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/cli.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/cli.rb new file mode 100644 index 000000000..ef7386946 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/cli.rb @@ -0,0 +1,220 @@ +class Pry + + # Manage the processing of command line options + class CLI + + NoOptionsError = Class.new(StandardError) + + class << self + + # @return [Proc] The Proc defining the valid command line options. + attr_accessor :options + + # @return [Array] The Procs that process the parsed options. Plugins can + # utilize this facility in order to add and process their own Pry + # options. + attr_accessor :option_processors + + # @return [Array] The input array of strings to process + # as CLI options. + attr_accessor :input_args + + # Add another set of CLI options (a Slop block) + def add_options(&block) + if options + old_options = options + self.options = proc do + instance_exec(&old_options) + instance_exec(&block) + end + else + self.options = block + end + + self + end + + # Bring in options defined in plugins + def add_plugin_options + Pry.plugins.values.each do |plugin| + plugin.load_cli_options + end + + self + end + + # Add a block responsible for processing parsed options. + def add_option_processor(&block) + self.option_processors ||= [] + option_processors << block + + self + end + + # Clear `options` and `option_processors` + def reset + self.options = nil + self.option_processors = nil + end + + def parse_options(args=ARGV) + unless options + raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." + end + + self.input_args = args + + begin + opts = Slop.parse!( + args, + :help => true, + :multiple_switches => false, + :strict => true, + &options + ) + rescue Slop::InvalidOptionError + # Display help message on unknown switches and exit. + puts Slop.new(&options) + exit + end + + # Option processors are optional. + if option_processors + option_processors.each { |processor| processor.call(opts) } + end + + self + end + + end + + reset + end +end + + +# String that is built to be executed on start (created by -e and -exec switches) +exec_string = "" + +# Bring in options defined by plugins +Slop.new do + on "no-plugins" do + Pry.config.should_load_plugins = false + end +end.parse(ARGV.dup) + +if Pry.config.should_load_plugins + Pry::CLI.add_plugin_options +end + +# The default Pry command line options (before plugin options are included) +Pry::CLI.add_options do + banner %{Usage: pry [OPTIONS] +Start a Pry session. +See http://pryrepl.org/ for more information. +Copyright (c) 2013 John Mair (banisterfiend) +-- +} + on :e, :exec=, "A line of code to execute in context before the session starts" do |input| + exec_string << input << "\n" + end + + on "no-pager", "Disable pager for long output" do + Pry.config.pager = false + end + + on "no-history", "Disable history loading" do + Pry.config.history.should_load = false + end + + on "no-color", "Disable syntax highlighting for session" do + Pry.config.color = false + end + + on :f, "Suppress loading of ~/.pryrc and ./.pryrc" do + Pry.config.should_load_rc = false + Pry.config.should_load_local_rc = false + end + + on :s, "select-plugin=", "Only load specified plugin (and no others)." do |plugin_name| + Pry.config.should_load_plugins = false + Pry.plugins[plugin_name].activate! + end + + on :d, "disable-plugin=", "Disable a specific plugin." do |plugin_name| + Pry.plugins[plugin_name].disable! + end + + on "no-plugins", "Suppress loading of plugins." do + Pry.config.should_load_plugins = false + end + + on "plugins", "List installed plugins." do + puts "Installed Plugins:" + puts "--" + Pry.locate_plugins.each do |plugin| + puts "#{plugin.name}".ljust(18) << plugin.spec.summary + end + exit + end + + on "simple-prompt", "Enable simple prompt mode" do + Pry.config.prompt = Pry::SIMPLE_PROMPT + end + + on "noprompt", "No prompt mode" do + Pry.config.prompt = Pry::NO_PROMPT + end + + on :r, :require=, "`require` a Ruby script at startup" do |file| + Pry.config.requires << file + end + + on :I=, "Add a path to the $LOAD_PATH", :as => Array, :delimiter => ":" do |load_path| + load_path.map! do |path| + /\A\.\// =~ path ? path : File.expand_path(path) + end + + $LOAD_PATH.unshift(*load_path) + end + + on "gem", "Shorthand for -I./lib -rgemname" do |load_path| + $LOAD_PATH.unshift("./lib") + Dir["./lib/*.rb"].each do |file| + Pry.config.requires << file + end + end + + on :v, :version, "Display the Pry version" do + puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}" + exit + end + + on(:c, :context=, + "Start the session in the specified context. Equivalent to `context.pry` in a session.", + :default => "Pry.toplevel_binding" + ) +end.add_option_processor do |opts| + + exit if opts.help? + + # invoked via cli + Pry.cli = true + + # create the actual context + if opts[:context] + Pry.initial_session_setup + context = Pry.binding_for(eval(opts[:context])) + else + context = Pry.toplevel_binding + end + + if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"] + full_name = File.expand_path(Pry::CLI.input_args.first) + Pry.load_file_through_repl(full_name) + exit + end + + # Start the session (running any code passed with -e, if there is any) + Pry.start(context, :input => StringIO.new(exec_string)) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code.rb new file mode 100644 index 000000000..f58189ebc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code.rb @@ -0,0 +1,346 @@ +require 'pry/code/loc' +require 'pry/code/code_range' +require 'pry/code/code_file' + +class Pry + class << self + # Convert the given object into an instance of `Pry::Code`, if it isn't + # already one. + # + # @param [Code, Method, UnboundMethod, Proc, Pry::Method, String, Array, + # IO] obj + def Code(obj) + case obj + when Code + obj + when ::Method, UnboundMethod, Proc, Pry::Method + Code.from_method(obj) + else + Code.new(obj) + end + end + end + + # `Pry::Code` is a class that encapsulates lines of source code and their + # line numbers and formats them for terminal output. It can read from a file + # or method definition or be instantiated with a `String` or an `Array`. + # + # In general, the formatting methods in `Code` return a new `Code` object + # which will format the text as specified when `#to_s` is called. This allows + # arbitrary chaining of formatting methods without mutating the original + # object. + class Code + class << self + include MethodSource::CodeHelpers + + # Instantiate a `Code` object containing code loaded from a file or + # Pry's line buffer. + # + # @param [String] filename The name of a file, or "(pry)". + # @param [Symbol] code_type The type of code the file contains. + # @return [Code] + def from_file(filename, code_type = nil) + code_file = CodeFile.new(filename, code_type) + new(code_file.code, 1, code_file.code_type) + end + + # Instantiate a `Code` object containing code extracted from a + # `::Method`, `UnboundMethod`, `Proc`, or `Pry::Method` object. + # + # @param [::Method, UnboundMethod, Proc, Pry::Method] meth The method + # object. + # @param [Integer, nil] start_line The line number to start on, or nil to + # use the method's original line numbers. + # @return [Code] + def from_method(meth, start_line = nil) + meth = Pry::Method(meth) + start_line ||= meth.source_line || 1 + new(meth.source, start_line, meth.source_type) + end + + # Attempt to extract the source code for module (or class) `mod`. + # + # @param [Module, Class] mod The module (or class) of interest. + # @param [Integer] candidate_rank The module candidate (by rank) + # to use (see `Pry::WrappedModule::Candidate` for more information). + # @param [Integer, nil] start_line The line number to start on, or nil to + # use the method's original line numbers. + # @return [Code] + def from_module(mod, candidate_rank = 0, start_line=nil) + candidate = Pry::WrappedModule(mod).candidate(candidate_rank) + start_line ||= candidate.line + new(candidate.source, start_line, :ruby) + end + end + + # @return [Symbol] The type of code stored in this wrapper. + attr_accessor :code_type + + # Instantiate a `Code` object containing code from the given `Array`, + # `String`, or `IO`. The first line will be line 1 unless specified + # otherwise. If you need non-contiguous line numbers, you can create an + # empty `Code` object and then use `#push` to insert the lines. + # + # @param [Array, String, IO] lines + # @param [Integer?] start_line + # @param [Symbol?] code_type + def initialize(lines = [], start_line = 1, code_type = :ruby) + if lines.is_a? String + lines = lines.lines + end + @lines = lines.each_with_index.map { |line, lineno| + LOC.new(line, lineno + start_line.to_i) } + @code_type = code_type + end + + # Append the given line. +lineno+ is one more than the last existing + # line, unless specified otherwise. + # + # @param [String] line + # @param [Integer?] lineno + # @return [String] The inserted line. + def push(line, lineno = nil) + if lineno.nil? + lineno = @lines.last.lineno + 1 + end + @lines.push(LOC.new(line, lineno)) + line + end + alias << push + + # Filter the lines using the given block. + # + # @yield [LOC] + # @return [Code] + def select(&block) + alter do + @lines = @lines.select(&block) + end + end + + # Remove all lines that aren't in the given range, expressed either as a + # `Range` object or a first and last line number (inclusive). Negative + # indices count from the end of the array of lines. + # + # @param [Range, Integer] start_line + # @param [Integer?] end_line + # @return [Code] + def between(start_line, end_line = nil) + return self unless start_line + + code_range = CodeRange.new(start_line, end_line) + + alter do + @lines = @lines[code_range.indices_range(@lines)] || [] + end + end + + # Take `num_lines` from `start_line`, forward or backwards. + # + # @param [Integer] start_line + # @param [Integer] num_lines + # @return [Code] + def take_lines(start_line, num_lines) + start_idx = + if start_line >= 0 + @lines.index { |loc| loc.lineno >= start_line } || @lines.length + else + [@lines.length + start_line, 0].max + end + + alter do + @lines = @lines.slice(start_idx, num_lines) + end + end + + # Remove all lines except for the +lines+ up to and excluding +lineno+. + # + # @param [Integer] lineno + # @param [Integer] lines + # @return [Code] + def before(lineno, lines = 1) + return self unless lineno + + select do |loc| + loc.lineno >= lineno - lines && loc.lineno < lineno + end + end + + # Remove all lines except for the +lines+ on either side of and including + # +lineno+. + # + # @param [Integer] lineno + # @param [Integer] lines + # @return [Code] + def around(lineno, lines = 1) + return self unless lineno + + select do |loc| + loc.lineno >= lineno - lines && loc.lineno <= lineno + lines + end + end + + # Remove all lines except for the +lines+ after and excluding +lineno+. + # + # @param [Integer] lineno + # @param [Integer] lines + # @return [Code] + def after(lineno, lines = 1) + return self unless lineno + + select do |loc| + loc.lineno > lineno && loc.lineno <= lineno + lines + end + end + + # Remove all lines that don't match the given `pattern`. + # + # @param [Regexp] pattern + # @return [Code] + def grep(pattern) + return self unless pattern + pattern = Regexp.new(pattern) + + select do |loc| + loc.line =~ pattern + end + end + + # Format output with line numbers next to it, unless `y_n` is falsy. + # + # @param [Boolean?] y_n + # @return [Code] + def with_line_numbers(y_n = true) + alter do + @with_line_numbers = y_n + end + end + + # Format output with a marker next to the given +lineno+, unless +lineno+ is + # falsy. + # + # @param [Integer?] lineno + # @return [Code] + def with_marker(lineno = 1) + alter do + @with_marker = !!lineno + @marker_lineno = lineno + end + end + + # Format output with the specified number of spaces in front of every line, + # unless `spaces` is falsy. + # + # @param [Integer?] spaces + # @return [Code] + def with_indentation(spaces = 0) + alter do + @with_indentation = !!spaces + @indentation_num = spaces + end + end + + # @return [String] + def inspect + Object.instance_method(:to_s).bind(self).call + end + + # @return [Integer] the number of digits in the last line. + def max_lineno_width + @lines.length > 0 ? @lines.last.lineno.to_s.length : 0 + end + + # @return [String] a formatted representation (based on the configuration of + # the object). + def to_s + print_to_output("", false) + end + + # @return [String] a (possibly highlighted) copy of the source code. + def highlighted + print_to_output("", true) + end + + # Writes a formatted representation (based on the configuration of the + # object) to the given output, which must respond to `#<<`. + def print_to_output(output, color=false) + @lines.each do |loc| + loc = loc.dup + loc.colorize(@code_type) if color + loc.add_line_number(max_lineno_width, color) if @with_line_numbers + loc.add_marker(@marker_lineno) if @with_marker + loc.indent(@indentation_num) if @with_indentation + output << loc.line + output << "\n" + end + output + end + + # Get the comment that describes the expression on the given line number. + # + # @param [Integer] line_number (1-based) + # @return [String] the code. + def comment_describing(line_number) + self.class.comment_describing(raw, line_number) + end + + # Get the multiline expression that starts on the given line number. + # + # @param [Integer] line_number (1-based) + # @return [String] the code. + def expression_at(line_number, consume = 0) + self.class.expression_at(raw, line_number, :consume => consume) + end + + # Get the (approximate) Module.nesting at the give line number. + # + # @param [Integer] line_number line number starting from 1 + # @param [Module] top_module the module in which this code exists + # @return [Array] a list of open modules. + def nesting_at(line_number, top_module = Object) + Pry::Indent.nesting_at(raw, line_number) + end + + # Return an unformatted String of the code. + # + # @return [String] + def raw + @lines.map(&:line).join("\n") << "\n" + end + + # Return the number of lines stored. + # + # @return [Integer] + def length + @lines ? @lines.length : 0 + end + + # Two `Code` objects are equal if they contain the same lines with the same + # numbers. Otherwise, call `to_s` and `chomp` and compare as Strings. + # + # @param [Code, Object] other + # @return [Boolean] + def ==(other) + if other.is_a?(Code) + other_lines = other.instance_variable_get(:@lines) + @lines.each_with_index.all? { |loc, i| loc == other_lines[i] } + else + to_s.chomp == other.to_s.chomp + end + end + + # Forward any missing methods to the output of `#to_s`. + def method_missing(name, *args, &block) + to_s.send(name, *args, &block) + end + undef =~ + + protected + + # An abstraction of the `dup.instance_eval` pattern used throughout this + # class. + def alter(&block) + dup.tap { |o| o.instance_eval(&block) } + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_file.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_file.rb new file mode 100644 index 000000000..9ccb23b1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_file.rb @@ -0,0 +1,103 @@ +class Pry + class CodeFile + DEFAULT_EXT = '.rb' + + # List of all supported languages. + # @return [Hash] + EXTENSIONS = { + %w(.py) => :python, + %w(.js) => :javascript, + %w(.css) => :css, + %w(.xml) => :xml, + %w(.php) => :php, + %w(.html) => :html, + %w(.diff) => :diff, + %w(.java) => :java, + %w(.json) => :json, + %w(.c .h) => :c, + %w(.rhtml) => :rhtml, + %w(.yaml .yml) => :yaml, + %w(.cpp .hpp .cc .h cxx) => :cpp, + %w(.rb .ru .irbrc .gemspec .pryrc) => :ruby, + } + + # @return [Symbol] The type of code stored in this wrapper. + attr_reader :code_type + + # @param [String] filename The name of a file with code to be detected + # @param [Symbol] code_type The type of code the `filename` contains + def initialize(filename, code_type = type_from_filename(filename)) + @filename = filename + @code_type = code_type + end + + # @return [String] The code contained in the current `@filename`. + def code + if @filename == Pry.eval_path + Pry.line_buffer.drop(1) + elsif Pry::Method::Patcher.code_for(@filename) + Pry::Method::Patcher.code_for(@filename) + elsif RbxPath.is_core_path?(@filename) + File.read(RbxPath.convert_path_to_full(@filename)) + else + path = abs_path + @code_type = type_from_filename(path) + File.read(path) + end + end + + private + + # @raise [MethodSource::SourceNotFoundError] if the `filename` is not + # readable for some reason. + # @return [String] absolute path for the given `filename`. + def abs_path + code_path.detect { |path| readable?(path) } or + raise MethodSource::SourceNotFoundError, + "Cannot open #{ @filename.inspect } for reading." + end + + # @param [String] path + # @return [Boolean] if the path, with or without the default ext, + # is a readable file then `true`, otherwise `false`. + def readable?(path) + File.readable?(path) && !File.directory?(path) or + File.readable?(path << DEFAULT_EXT) + end + + # @return [Array] All the paths that contain code that Pry can use for its + # API's. Skips directories. + def code_path + [from_pwd, from_pry_init_pwd, *from_load_path] + end + + # @param [String] filename + # @param [Symbol] default (:unknown) the file type to assume if none could be + # detected. + # @return [Symbol, nil] The CodeRay type of a file from its extension, or + # `nil` if `:unknown`. + def type_from_filename(filename, default = :unknown) + _, @code_type = EXTENSIONS.find do |k, _| + k.any? { |ext| ext == File.extname(filename) } + end + + code_type || default + end + + # @return [String] + def from_pwd + File.expand_path(@filename, Dir.pwd) + end + + # @return [String] + def from_pry_init_pwd + File.expand_path(@filename, Pry::INITIAL_PWD) + end + + # @return [String] + def from_load_path + $LOAD_PATH.map { |path| File.expand_path(@filename, path) } + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_range.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_range.rb new file mode 100644 index 000000000..043be02ec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/code_range.rb @@ -0,0 +1,71 @@ +class Pry + class Code + + # Represents a range of lines in a code listing. + # + # @api private + class CodeRange + + # @param [Integer] start_line + # @param [Integer?] end_line + def initialize(start_line, end_line = nil) + @start_line = start_line + @end_line = end_line + force_set_end_line + end + + # @param [Array] lines + # @return [Range] + def indices_range(lines) + Range.new(*indices(lines)) + end + + private + + def start_line; @start_line; end + def end_line; @end_line; end + + # If `end_line` is equal to `nil`, then calculate it from the first + # parameter, `start_line`. Otherwise, leave it as it is. + # @return [void] + def force_set_end_line + if start_line.is_a?(Range) + set_end_line_from_range + else + @end_line ||= start_line + end + end + + # Finds indices of `start_line` and `end_line` in the given Array of + # +lines+. + # + # @param [Array] lines + # @return [Array] + def indices(lines) + [find_start_index(lines), find_end_index(lines)] + end + + # @return [Integer] + def find_start_index(lines) + return start_line if start_line < 0 + lines.index { |loc| loc.lineno >= start_line } || lines.length + end + + # @return [Integer] + def find_end_index(lines) + return end_line if end_line < 0 + (lines.index { |loc| loc.lineno > end_line } || 0) - 1 + end + + # For example, if the range is 4..10, then `start_line` would be equal to + # 4 and `end_line` to 10. + # @return [void] + def set_end_line_from_range + @end_line = start_line.last + @end_line -= 1 if start_line.exclude_end? + @start_line = start_line.first + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/loc.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/loc.rb new file mode 100644 index 000000000..905c7040c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code/loc.rb @@ -0,0 +1,92 @@ +class Pry + class Code + + # Represents a line of code. A line of code is a tuple, which consists of a + # line and a line number. A `LOC` object's state (namely, the line + # parameter) can be changed via instance methods. `Pry::Code` heavily uses + # this class. + # + # @api private + # @example + # loc = LOC.new("def example\n :example\nend", 1) + # puts loc.line + # def example + # :example + # end + # #=> nil + # + # loc.indent(3) + # loc.line #=> " def example\n :example\nend" + class LOC + + # @return [Array] + attr_reader :tuple + + # @param [String] line The line of code. + # @param [Integer] lineno The position of the +line+. + def initialize(line, lineno) + @tuple = [line.chomp, lineno.to_i] + end + + # @return [Boolean] + def ==(other) + other.tuple == tuple + end + + def dup + self.class.new(line, lineno) + end + + # @return [String] + def line + tuple.first + end + + # @return [Integer] + def lineno + tuple.last + end + + # Paints the `line` of code. + # + # @param [Symbol] code_type + # @return [void] + def colorize(code_type) + tuple[0] = CodeRay.scan(line, code_type).term + end + + # Prepends the line number `lineno` to the `line`. + # + # @param [Integer] max_width + # @return [void] + def add_line_number(max_width = 0, color = false) + padded = lineno.to_s.rjust(max_width) + colorized_lineno = color ? Pry::Helpers::BaseHelpers.colorize_code(padded) : padded + tuple[0] = "#{ colorized_lineno }: #{ line }" + end + + # Prepends a marker "=>" or an empty marker to the +line+. + # + # @param [Integer] marker_lineno If it is equal to the `lineno`, then + # prepend a hashrocket. Otherwise, an empty marker. + # @return [void] + def add_marker(marker_lineno) + tuple[0] = + if lineno == marker_lineno + " => #{ line }" + else + " #{ line }" + end + end + + # Indents the `line` with +distance+ spaces. + # + # @param [Integer] distance + # @return [void] + def indent(distance) + tuple[0] = "#{ ' ' * distance }#{ line }" + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code_object.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code_object.rb new file mode 100644 index 000000000..11a3aa6ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/code_object.rb @@ -0,0 +1,172 @@ +class Pry + + # This class is responsible for taking a string (identifying a + # command/class/method/etc) and returning the relevant type of object. + # For example, if the user looks up "show-source" then a + # `Pry::Command` will be returned. Alternatively, if the user passes in "Pry#repl" then + # a `Pry::Method` object will be returned. + # + # The `CodeObject.lookup` method is responsible for 1. figuring out what kind of + # object the user wants (applying precedence rules in doing so -- i.e methods + # get precedence over commands with the same name) and 2. Returning + # the appropriate object. If the user fails to provide a string + # identifer for the object (i.e they pass in `nil` or "") then the + # object looked up will be the 'current method' or 'current class' + # associated with the Binding. + # + # TODO: This class is a clusterfuck. We need a much more robust + # concept of what a "Code Object" really is. Currently + # commands/classes/candidates/methods and so on just share a very + # ill-defined interface. + class CodeObject + module Helpers + # we need this helper as some Pry::Method objects can wrap Procs + # @return [Boolean] + def real_method_object? + is_a?(::Method) || is_a?(::UnboundMethod) + end + + def c_method? + real_method_object? && source_type == :c + end + + def module_with_yard_docs? + is_a?(WrappedModule) && yard_docs? + end + + def command? + is_a?(Module) && self <= Pry::Command + end + end + + include Pry::Helpers::CommandHelpers + + class << self + def lookup(str, _pry_, options={}) + co = new(str, _pry_, options) + + co.default_lookup || co.method_or_class_lookup || + co.command_lookup || co.empty_lookup + end + end + + attr_accessor :str + attr_accessor :target + attr_accessor :_pry_ + attr_accessor :super_level + + def initialize(str, _pry_, options={}) + options = { + :super => 0, + }.merge!(options) + + @str = str + @_pry_ = _pry_ + @target = _pry_.current_context + @super_level = options[:super] + end + + def command_lookup + # TODO: just make it so find_command_by_match_or_listing doesn't + # raise? + _pry_.commands.find_command_by_match_or_listing(str) rescue nil + end + + # when no paramter is given (i.e CodeObject.lookup(nil)), then we + # lookup the 'current object' from the binding. + def empty_lookup + return nil if str && !str.empty? + + obj = if internal_binding?(target) + mod = target_self.is_a?(Module) ? target_self : target_self.class + Pry::WrappedModule(mod) + else + Pry::Method.from_binding(target) + end + + # respect the super level (i.e user might have specified a + # --super flag to show-source) + lookup_super(obj, super_level) + end + + # lookup variables and constants and `self` that are not modules + def default_lookup + + # we skip instance methods as we want those to fall through to method_or_class_lookup() + if safe_to_evaluate?(str) && !looks_like_an_instance_method?(str) + obj = target.eval(str) + + # restrict to only objects we KNOW for sure support the full API + # Do NOT support just any object that responds to source_location + if sourcable_object?(obj) + Pry::Method(obj) + elsif !obj.is_a?(Module) + Pry::WrappedModule(obj.class) + else + nil + end + end + + rescue Pry::RescuableException + nil + end + + def method_or_class_lookup + obj = case str + when /\S+\(\)\z/ + Pry::Method.from_str(str.sub(/\(\)\z/, ''),target) || Pry::WrappedModule.from_str(str, target) + else + Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target) + end + + lookup_super(obj, super_level) + end + + private + + def sourcable_object?(obj) + [::Proc, ::Method, ::UnboundMethod].any? { |o| obj.is_a?(o) } + end + + # Returns true if `str` looks like a method, i.e Klass#method + # We need to consider this case because method lookups should fall + # through to the `method_or_class_lookup()` method but a + # defined?() on a "Klass#method` string will see the `#` as a + # comment and only evaluate the `Klass` part. + # @param [String] str + # @return [Boolean] Whether the string looks like an instance method. + def looks_like_an_instance_method?(str) + str =~ /\S#\S/ + end + + # We use this method to decide whether code is safe to eval. Method's are + # generally not, but everything else is. + # TODO: is just checking != "method" enough?? + # TODO: see duplication of this method in Pry::WrappedModule + # @param [String] str The string to lookup + # @return [Boolean] + def safe_to_evaluate?(str) + return true if str.strip == "self" + kind = target.eval("defined?(#{str})") + kind =~ /variable|constant/ + end + + def target_self + target.eval('self') + end + + # grab the nth (`super_level`) super of `obj + # @param [Object] obj + # @param [Fixnum] super_level How far up the super chain to ascend. + def lookup_super(obj, super_level) + return nil if !obj + + sup = obj.super(super_level) + if !sup + raise Pry::CommandError, "No superclass found for #{obj.wrapped}" + else + sup + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/color_printer.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/color_printer.rb new file mode 100644 index 000000000..218a82142 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/color_printer.rb @@ -0,0 +1,55 @@ +# PP subclass for streaming inspect output in color. +class Pry + class ColorPrinter < ::PP + OBJ_COLOR = begin + code = CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword] + if code.start_with? "\e" + code + else + "\e[0m\e[0;#{code}m" + end + end + + CodeRay::Encoders::Terminal::TOKEN_COLORS[:comment][:self] = "\e[1;34m" + + def self.pp(obj, out = $>, width = 79) + q = ColorPrinter.new(out, width) + q.guard_inspect_key { q.pp obj } + q.flush + out << "\n" + end + + def text(str, width = str.length) + # Don't recolorize output with color [Issue #751] + if str.include?("\e[") + super "#{str}\e[0m", width + elsif str.start_with?('#<') || str == '=' || str == '>' + super highlight_object_literal(str), width + else + super CodeRay.scan(str, :ruby).term, width + end + end + + def pp(obj) + super + rescue => e + raise if e.is_a? Pry::Pager::StopPaging + + # Read the class name off of the singleton class to provide a default + # inspect. + singleton = class << obj; self; end + ancestors = Pry::Method.safe_send(singleton, :ancestors) + klass = ancestors.reject { |k| k == singleton }.first + obj_id = obj.__id__.to_s(16) rescue 0 + str = "#<#{klass}:0x#{obj_id}>" + + text highlight_object_literal(str) + end + + private + + def highlight_object_literal(object_literal) + "#{OBJ_COLOR}#{object_literal}\e[0m" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command.rb new file mode 100644 index 000000000..0cf334f72 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command.rb @@ -0,0 +1,692 @@ +require 'delegate' +require 'pry/helpers/documentation_helpers' + +class Pry + + # The super-class of all commands, new commands should be created by calling + # {Pry::CommandSet#command} which creates a BlockCommand or {Pry::CommandSet#create_command} + # which creates a ClassCommand. Please don't use this class directly. + class Command + extend Helpers::DocumentationHelpers + extend CodeObject::Helpers + + # represents a void return value for a command + VOID_VALUE = Object.new + + # give it a nice inspect + def VOID_VALUE.inspect() "void" end + + # Properties of the command itself (as passed as arguments to + # {CommandSet#command} or {CommandSet#create_command}). + class << self + attr_writer :block + attr_writer :description + attr_writer :command_options + attr_writer :match + + def match(arg=nil) + if arg + @command_options ||= default_options(arg) + @command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect + @match = arg + end + @match ||= nil + end + + # Define or get the command's description + def description(arg=nil) + @description = arg if arg + @description ||= nil + end + + # Define or get the command's options + def command_options(arg=nil) + @command_options ||= default_options(match) + @command_options.merge!(arg) if arg + @command_options + end + # backward compatibility + alias_method :options, :command_options + alias_method :options=, :command_options= + + # Define or get the command's banner + def banner(arg=nil) + @banner = arg if arg + @banner || description + end + + def block + @block || instance_method(:process) + end + + def source + file, line = block.source_location + strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line)) + end + + def doc + new.help + end + + def source_location + block.source_location + end + + def source_file + Array(block.source_location).first + end + alias_method :file, :source_file + + def source_line + Array(block.source_location).last + end + alias_method :line, :source_line + + def default_options(match) + { + :requires_gem => [], + :keep_retval => false, + :argument_required => false, + :interpolate => true, + :shellwords => true, + :listing => (String === match ? match : match.inspect), + :use_prefix => true, + :takes_block => false + } + end + end + + # Make those properties accessible to instances + def name; self.class.name; end + def match; self.class.match; end + def description; self.class.description; end + def block; self.class.block; end + def command_options; self.class.options; end + def command_name; self.class.command_name; end + def source; self.class.source; end + def source_location; self.class.source_location; end + + class << self + def name + super.to_s == "" ? "#" : super + end + + def inspect + name + end + + def command_name + self.options[:listing] + end + + # Create a new command with the given properties. + # @param [String, Regex] match The thing that triggers this command + # @param [String] description The description to appear in `help` + # @param [Hash] options Behavioral options (see {Pry::CommandSet#command}) + # @param [Module] helpers A module of helper functions to be included. + # @yield optional, used for BlockCommands + # @return [Class] (a subclass of {Pry::Command}) + def subclass(match, description, options, helpers, &block) + klass = Class.new(self) + klass.send(:include, helpers) + klass.match = match + klass.description = description + klass.command_options = options + klass.block = block + klass + end + + # Should this command be called for the given line? + # @param [String] val A line input at the REPL + # @return [Boolean] + def matches?(val) + command_regex =~ val + end + + # How well does this command match the given line? + # + # Higher scores are better because they imply that this command matches + # the line more closely. + # + # The score is calculated by taking the number of characters at the start + # of the string that are used only to identify the command, not as part of + # the arguments. + # + # @example + # /\.(.*)/.match_score(".foo") #=> 1 + # /\.*(.*)/.match_score("...foo") #=> 3 + # 'hi'.match_score("hi there") #=> 2 + # + # @param [String] val A line input at the REPL + # @return [Fixnum] + def match_score(val) + if command_regex =~ val + Regexp.last_match.size > 1 ? Regexp.last_match.begin(1) : Regexp.last_match.end(0) + else + -1 + end + end + + # Store hooks to be run before or after the command body. + # @see {Pry::CommandSet#before_command} + # @see {Pry::CommandSet#after_command} + def hooks + @hooks ||= {:before => [], :after => []} + end + + def command_regex + pr = Pry.respond_to?(:config) ? Pry.config.command_prefix : "" + prefix = convert_to_regex(pr) + prefix = "(?:#{prefix})?" unless options[:use_prefix] + + /^#{prefix}#{convert_to_regex(match)}(?!\S)/ + end + + def convert_to_regex(obj) + case obj + when String + Regexp.escape(obj) + else + obj + end + end + + # The group in which the command should be displayed in "help" output. + # This is usually auto-generated from directory naming, but it can be + # manually overridden if necessary. + # Group should not be changed once it is initialized. + def group(name=nil) + @group ||= if name + name + else + case Pry::Method(block).source_file + when %r{/pry/.*_commands/(.*).rb} + $1.capitalize.gsub(/_/, " ") + when %r{(pry-\w+)-([\d\.]+([\w\.]+)?)} + name, version = $1, $2 + "#{name.to_s} (v#{version.to_s})" + when /pryrc/ + "~/.pryrc" + else + "(other)" + end + end + end + end + + # Properties of one execution of a command (passed by {Pry#run_command} as a hash of + # context and expanded in `#initialize` + attr_accessor :output + attr_accessor :target + attr_accessor :captures + attr_accessor :eval_string + attr_accessor :arg_string + attr_accessor :context + attr_accessor :command_set + attr_accessor :_pry_ + + # The block we pass *into* a command so long as `:takes_block` is + # not equal to `false` + # @example + # my-command | do + # puts "block content" + # end + attr_accessor :command_block + + # Run a command from another command. + # @param [String] command_string The string that invokes the command + # @param [Array] args Further arguments to pass to the command + # @example + # run "show-input" + # @example + # run ".ls" + # @example + # run "amend-line", "5", 'puts "hello world"' + def run(command_string, *args) + command_string = _pry_.config.command_prefix.to_s + command_string + complete_string = "#{command_string} #{args.join(" ")}".rstrip + command_set.process_line(complete_string, context) + end + + def commands + command_set.to_hash + end + + def text + Pry::Helpers::Text + end + + def void + VOID_VALUE + end + + include Pry::Helpers::BaseHelpers + include Pry::Helpers::CommandHelpers + + # Instantiate a command, in preparation for calling it. + # @param [Hash] context The runtime context to use with this command. + def initialize(context={}) + self.context = context + self.target = context[:target] + self.output = context[:output] + self.eval_string = context[:eval_string] + self.command_set = context[:command_set] + self._pry_ = context[:pry_instance] + end + + # @return [Object] The value of `self` inside the `target` binding. + def target_self; target.eval('self'); end + + # @return [Hash] Pry commands can store arbitrary state + # here. This state persists between subsequent command invocations. + # All state saved here is unique to the command, it does not + # need to be namespaced. + # @example + # state.my_state = "my state" # this will not conflict with any + # # `state.my_state` used in another command. + def state + _pry_.command_state[match] ||= Pry::Config.from_hash({}) + end + + # Revaluate the string (str) and perform interpolation. + # @param [String] str The string to reevaluate with interpolation. + # + # @return [String] The reevaluated string with interpolations + # applied (if any). + def interpolate_string(str) + dumped_str = str.dump + if dumped_str.gsub!(/\\\#\{/, '#{') + target.eval(dumped_str) + else + str + end + end + + # Display a warning if a command collides with a local/method in + # the current scope. + def check_for_command_collision(command_match, arg_string) + collision_type = target.eval("defined?(#{command_match})") + collision_type ||= 'local-variable' if arg_string.match(%r{\A\s*[-+*/%&|^]*=}) + + if collision_type + output.puts "#{text.bold('WARNING:')} Calling Pry command '#{command_match}', which conflicts with a #{collision_type}.\n\n" + end + rescue Pry::RescuableException + end + + # Extract necessary information from a line that Command.matches? this + # command. + # + # Returns an array of four elements: + # + # ``` + # [String] the portion of the line that matched with the Command match + # [String] a string of all the arguments (i.e. everything but the match) + # [Array] the captures caught by the command_regex + # [Array] the arguments obtained by splitting the arg_string + # ``` + # + # @param [String] val The line of input + # @return [Array] + def tokenize(val) + val.replace(interpolate_string(val)) if command_options[:interpolate] + + self.class.command_regex =~ val + + # please call Command.matches? before Command#call_safely + raise CommandError, "fatal: called a command which didn't match?!" unless Regexp.last_match + captures = Regexp.last_match.captures + pos = Regexp.last_match.end(0) + + arg_string = val[pos..-1] + + # remove the one leading space if it exists + arg_string.slice!(0) if arg_string.start_with?(" ") + + # process and pass a block if one is found + pass_block(arg_string) if command_options[:takes_block] + + if arg_string + args = command_options[:shellwords] ? Shellwords.shellwords(arg_string) : arg_string.split(" ") + else + args = [] + end + + [val[0..pos].rstrip, arg_string, captures, args] + end + + # Process a line that Command.matches? this command. + # @param [String] line The line to process + # @return [Object, Command::VOID_VALUE] + def process_line(line) + command_match, arg_string, captures, args = tokenize(line) + + check_for_command_collision(command_match, arg_string) if Pry.config.collision_warning + + self.arg_string = arg_string + self.captures = captures + + call_safely(*(captures + args)) + end + + # Pass a block argument to a command. + # @param [String] arg_string The arguments (as a string) passed to the command. + # We inspect these for a '| do' or a '| {' and if we find it we use it + # to start a block input sequence. Once we have a complete + # block, we save it to an accessor that can be retrieved from the command context. + # Note that if we find the '| do' or '| {' we delete this and the + # elements following it from `arg_string`. + def pass_block(arg_string) + # Workaround for weird JRuby bug where rindex in this case can return nil + # even when there's a match. + arg_string.scan(/\| *(?:do|\{)/) + block_index = $~ && $~.offset(0)[0] + + return if !block_index + + block_init_string = arg_string.slice!(block_index..-1)[1..-1] + prime_string = "proc #{block_init_string}\n" + + if !Pry::Code.complete_expression?(prime_string) + block_string = _pry_.r(target, prime_string) + else + block_string = prime_string + end + + begin + self.command_block = target.eval(block_string) + rescue Pry::RescuableException + raise CommandError, "Incomplete block definition." + end + end + + private :pass_block + + # Run the command with the given `args`. + # + # This is a public wrapper around `#call` which ensures all preconditions + # are met. + # + # @param [Array] args The arguments to pass to this command. + # @return [Object] The return value of the `#call` method, or + # {Command::VOID_VALUE}. + def call_safely(*args) + unless dependencies_met? + gems_needed = Array(command_options[:requires_gem]) + gems_not_installed = gems_needed.select { |g| !Rubygem.installed?(g) } + output.puts "\nThe command '#{command_name}' is #{text.bold("unavailable")} because it requires the following gems to be installed: #{(gems_not_installed.join(", "))}" + output.puts "-" + output.puts "Type `install-command #{command_name}` to install the required gems and activate this command." + return void + end + + if command_options[:argument_required] && args.empty? + raise CommandError, "The command '#{command_name}' requires an argument." + end + + ret = call_with_hooks(*args) + command_options[:keep_retval] ? ret : void + end + + # Are all the gems required to use this command installed? + # + # @return Boolean + def dependencies_met? + @dependencies_met ||= command_dependencies_met?(command_options) + end + + # Generate completions for this command + # + # @param [String] search The line typed so far + # @return [Array] Completion words + def complete(search) + [] + end + + private + + # Run the `#call` method and all the registered hooks. + # @param [Array] args The arguments to `#call` + # @return [Object] The return value from `#call` + def call_with_hooks(*args) + self.class.hooks[:before].each do |block| + instance_exec(*args, &block) + end + + ret = call(*args) + + self.class.hooks[:after].each do |block| + ret = instance_exec(*args, &block) + end + + ret + end + + # Fix the number of arguments we pass to a block to avoid arity warnings. + # @param [Fixnum] arity The arity of the block + # @param [Array] args The arguments to pass + # @return [Array] A (possibly shorter) array of the arguments to pass + def correct_arg_arity(arity, args) + case + when arity < 0 + args + when arity == 0 + [] + when arity > 0 + args.values_at(*(0..(arity - 1)).to_a) + end + end + end + + # A super-class for Commands that are created with a single block. + # + # This class ensures that the block is called with the correct number of arguments + # and the right context. + # + # Create subclasses using {Pry::CommandSet#command}. + class BlockCommand < Command + # backwards compatibility + alias_method :opts, :context + + # Call the block that was registered with this command. + # @param [Array] args The arguments passed + # @return [Object] The return value of the block + def call(*args) + instance_exec(*correct_arg_arity(block.arity, args), &block) + end + + def help + "#{command_options[:listing].to_s.ljust(18)} #{description}" + end + end + + # A super-class of Commands with structure. + # + # This class implements the bare-minimum functionality that a command should + # have, namely a --help switch, and then delegates actual processing to its + # subclasses. + # + # Create subclasses using {Pry::CommandSet#create_command}, and override the + # `options(opt)` method to set up an instance of Slop, and the `process` + # method to actually run the command. If necessary, you can also override + # `setup` which will be called before `options`, for example to require any + # gems your command needs to run, or to set up state. + class ClassCommand < Command + class << self + + # Ensure that subclasses inherit the options, description and + # match from a ClassCommand super class. + def inherited(klass) + klass.match match + klass.description description + klass.command_options options + end + + def source + source_object.source + end + + def doc + new.help + end + + def source_location + source_object.source_location + end + + def source_file + source_object.source_file + end + alias_method :file, :source_file + + def source_line + source_object.source_line + end + alias_method :line, :source_line + + private + + # The object used to extract the source for the command. + # + # This should be a `Pry::Method(block)` for a command made with `create_command` + # and a `Pry::WrappedModule(self)` for a command that's a standard class. + # @return [Pry::WrappedModule, Pry::Method] + def source_object + @source_object ||= if name =~ /^[A-Z]/ + Pry::WrappedModule(self) + else + Pry::Method(block) + end + end + end + + attr_accessor :opts + attr_accessor :args + + # Set up `opts` and `args`, and then call `process`. + # + # This method will display help if necessary. + # + # @param [Array] args The arguments passed + # @return [Object] The return value of `process` or VOID_VALUE + def call(*args) + setup + + self.opts = slop + self.args = self.opts.parse!(args) + + if opts.present?(:help) + output.puts slop.help + void + else + process(*correct_arg_arity(method(:process).arity, args)) + end + end + + # Return the help generated by Slop for this command. + def help + slop.help + end + + # Return an instance of Slop that can parse either subcommands or the + # options that this command accepts. + def slop + Slop.new do |opt| + opt.banner(unindent(self.class.banner)) + subcommands(opt) + options(opt) + opt.on :h, :help, 'Show this message.' + end + end + + # Generate shell completions + # @param [String] search The line typed so far + # @return [Array] the words to complete + def complete(search) + slop.map do |opt| + [opt.long && "--#{opt.long} " || opt.short && "-#{opt.short}"] + end.flatten(1).compact + super + end + + # A method called just before `options(opt)` as part of `call`. + # + # This method can be used to set up any context your command needs to run, + # for example requiring gems, or setting default values for options. + # + # @example + # def setup + # require 'gist' + # @action = :method + # end + def setup; end + + # A method to setup Slop commands so it can parse the subcommands your + # command expects. If you need to set up default values, use `setup` + # instead. + # + # @example A minimal example + # def subcommands(cmd) + # cmd.command :download do |opt| + # description 'Downloads a content from a server' + # + # opt.on :verbose, 'Use verbose output' + # + # run do |options, arguments| + # ContentDownloader.download(options, arguments) + # end + # end + # end + # + # @example Define the invokation block anywhere you want + # def subcommands(cmd) + # cmd.command :download do |opt| + # description 'Downloads a content from a server' + # + # opt.on :verbose, 'Use verbose output' + # end + # end + # + # def process + # # Perform calculations... + # opts.fetch_command(:download).run do |options, arguments| + # ContentDownloader.download(options, arguments) + # end + # # More calculations... + # end + def subcommands(cmd); end + + # A method to setup Slop so it can parse the options your command expects. + # + # @note Please don't do anything side-effecty in the main part of this + # method, as it may be called by Pry at any time for introspection reasons. + # If you need to set up default values, use `setup` instead. + # + # @example + # def options(opt) + # opt.banner "Gists methods or classes" + # opt.on(:c, :class, "gist a class") do + # @action = :class + # end + # end + def options(opt); end + + # The actual body of your command should go here. + # + # The `opts` mehod can be called to get the options that Slop has passed, + # and `args` gives the remaining, unparsed arguments. + # + # The return value of this method is discarded unless the command was + # created with `:keep_retval => true`, in which case it is returned to the + # repl. + # + # @example + # def process + # if opts.present?(:class) + # gist_class + # else + # gist_method + # end + # end + def process; raise CommandError, "command '#{command_name}' not implemented" end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command_set.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command_set.rb new file mode 100644 index 000000000..9483ab0f2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/command_set.rb @@ -0,0 +1,443 @@ +class Pry + class NoCommandError < StandardError + def initialize(match, owner) + super "Command '#{match}' not found in command set #{owner}" + end + end + + # This class is used to create sets of commands. Commands can be imported from + # different sets, aliased, removed, etc. + class CommandSet + include Enumerable + include Pry::Helpers::BaseHelpers + attr_reader :helper_module + + # @param [Array] imported_sets + # Sets which will be imported automatically + # @yield Optional block run to define commands + def initialize(*imported_sets, &block) + @commands = {} + @helper_module = Module.new + import(*imported_sets) + instance_eval(&block) if block + end + + # Defines a new Pry command. + # @param [String, Regexp] match The start of invocations of this command. + # @param [String] description A description of the command. + # @param [Hash] options The optional configuration parameters. + # @option options [Boolean] :keep_retval Whether or not to use return value + # of the block for return of `command` or just to return `nil` + # (the default). + # @option options [Array] :requires_gem Whether the command has + # any gem dependencies, if it does and dependencies not met then + # command is disabled and a stub proc giving instructions to + # install command is provided. + # @option options [Boolean] :interpolate Whether string #{} based + # interpolation is applied to the command arguments before + # executing the command. Defaults to true. + # @option options [String] :listing The listing name of the + # command. That is the name by which the command is looked up by + # help and by show-command. Necessary for commands with regex matches. + # @option options [Boolean] :use_prefix Whether the command uses + # `Pry.config.command_prefix` prefix (if one is defined). Defaults + # to true. + # @option options [Boolean] :shellwords Whether the command's arguments + # should be split using Shellwords instead of just split on spaces. + # Defaults to true. + # @yield The action to perform. The parameters in the block + # determines the parameters the command will receive. All + # parameters passed into the block will be strings. Successive + # command parameters are separated by whitespace at the Pry prompt. + # @example + # MyCommands = Pry::CommandSet.new do + # command "greet", "Greet somebody" do |name| + # puts "Good afternoon #{name.capitalize}!" + # end + # end + # + # # From pry: + # # pry(main)> _pry_.commands = MyCommands + # # pry(main)> greet john + # # Good afternoon John! + # # pry(main)> help greet + # # Greet somebody + # @example Regexp command + # MyCommands = Pry::CommandSet.new do + # command /number-(\d+)/, "number-N regex command", :listing => "number" do |num, name| + # puts "hello #{name}, nice number: #{num}" + # end + # end + # + # # From pry: + # # pry(main)> _pry_.commands = MyCommands + # # pry(main)> number-10 john + # # hello john, nice number: 10 + # # pry(main)> help number + # # number-N regex command + def block_command(match, description="No description.", options={}, &block) + description, options = ["No description.", description] if description.is_a?(Hash) + options = Pry::Command.default_options(match).merge!(options) + + @commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block) + end + alias_method :command, :block_command + + # Defines a new Pry command class. + # + # @param [String, Regexp] match The start of invocations of this command. + # @param [String] description A description of the command. + # @param [Hash] options The optional configuration parameters, see {#command} + # @yield The class body's definition. + # + # @example + # Pry::Commands.create_command "echo", "echo's the input", :shellwords => false do + # def options(opt) + # opt.banner "Usage: echo [-u | -d] " + # opt.on :u, :upcase, "ensure the output is all upper-case" + # opt.on :d, :downcase, "ensure the output is all lower-case" + # end + # + # def process + # raise Pry::CommandError, "-u and -d makes no sense" if opts.present?(:u) && opts.present?(:d) + # result = args.join(" ") + # result.downcase! if opts.present?(:downcase) + # result.upcase! if opts.present?(:upcase) + # output.puts result + # end + # end + # + def create_command(match, description="No description.", options={}, &block) + description, options = ["No description.", description] if description.is_a?(Hash) + options = Pry::Command.default_options(match).merge!(options) + + @commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block) + @commands[match].class_eval(&block) + @commands[match] + end + + # Execute a block of code before a command is invoked. The block also + # gets access to parameters that will be passed to the command and + # is evaluated in the same context. + # @param [String, Regexp] search The match or listing of the command. + # @yield The block to be run before the command. + # @example Display parameter before invoking command + # Pry.config.commands.before_command("whereami") do |n| + # output.puts "parameter passed was #{n}" + # end + def before_command(search, &block) + cmd = find_command_by_match_or_listing(search) + cmd.hooks[:before].unshift block + end + + # Execute a block of code after a command is invoked. The block also + # gets access to parameters that will be passed to the command and + # is evaluated in the same context. + # @param [String, Regexp] search The match or listing of the command. + # @yield The block to be run after the command. + # @example Display text 'command complete' after invoking command + # Pry.config.commands.after_command("whereami") do |n| + # output.puts "command complete!" + # end + def after_command(search, &block) + cmd = find_command_by_match_or_listing(search) + cmd.hooks[:after] << block + end + + def each(&block) + @commands.each(&block) + end + + # Removes some commands from the set + # @param [Array] searches the matches or listings of the commands to remove + def delete(*searches) + searches.each do |search| + cmd = find_command_by_match_or_listing(search) + @commands.delete cmd.match + end + end + + # Imports all the commands from one or more sets. + # @param [Array] sets Command sets, all of the commands of which + # will be imported. + # @return [Pry::CommandSet] Returns the reciever (a command set). + def import(*sets) + sets.each do |set| + @commands.merge! set.to_hash + helper_module.send :include, set.helper_module + end + self + end + + # Imports some commands from a set + # @param [CommandSet] set Set to import commands from + # @param [Array] matches Commands to import + # @return [Pry::CommandSet] Returns the reciever (a command set). + def import_from(set, *matches) + helper_module.send :include, set.helper_module + matches.each do |match| + cmd = set.find_command_by_match_or_listing(match) + @commands[cmd.match] = cmd + end + self + end + + # @param [String, Regexp] match_or_listing The match or listing of a command. + # of the command to retrieve. + # @return [Command] The command object matched. + def find_command_by_match_or_listing(match_or_listing) + cmd = (@commands[match_or_listing] || + Pry::Helpers::BaseHelpers.find_command(match_or_listing, @commands)) + cmd or raise ArgumentError, "Cannot find a command: '#{match_or_listing}'!" + end + + # Aliases a command + # @param [String, Regex] match The match of the alias (can be a regex). + # @param [String] action The action to be performed (typically + # another command). + # @param [Hash] options The optional configuration parameters, + # accepts the same as the `command` method, but also allows the + # command description to be passed this way too as `:desc` + # @example Creating an alias for `ls -M` + # Pry.config.commands.alias_command "lM", "ls -M" + # @example Pass explicit description (overriding default). + # Pry.config.commands.alias_command "lM", "ls -M", :desc => "cutiepie" + def alias_command(match, action, options={}) + cmd = find_command(action) or fail "Command: `#{action}` not found" + original_options = cmd.options.dup + + options = original_options.merge!({ + :desc => "Alias for `#{action}`", + :listing => match + }).merge!(options) + + # ensure default description is used if desc is nil + desc = options.delete(:desc).to_s + + c = block_command match, desc, options do |*args| + run action, *args + end + + c.class_eval do + define_method(:complete) do |input| + cmd.new(context).complete(input) + end + end + + c.group "Aliases" + + c + end + + # Rename a command. Accepts either match or listing for the search. + # + # @param [String, Regexp] new_match The new match for the command. + # @param [String, Regexp] search The command's current match or listing. + # @param [Hash] options The optional configuration parameters, + # accepts the same as the `command` method, but also allows the + # command description to be passed this way too. + # @example Renaming the `ls` command and changing its description. + # Pry.config.commands.rename "dir", "ls", :description => "DOS friendly ls" + def rename_command(new_match, search, options={}) + cmd = find_command_by_match_or_listing(search) + + options = { + :listing => new_match, + :description => cmd.description + }.merge!(options) + + @commands[new_match] = cmd.dup + @commands[new_match].match = new_match + @commands[new_match].description = options.delete(:description) + @commands[new_match].options.merge!(options) + @commands.delete(cmd.match) + end + + def disabled_command(name_of_disabled_command, message, matcher=name_of_disabled_command) + create_command name_of_disabled_command do + match matcher + description "" + + define_method(:process) do + output.puts "DISABLED: #{message}" + end + end + end + + # Sets or gets the description for a command (replacing the old + # description). Returns current description if no description + # parameter provided. + # @param [String, Regexp] search The command match. + # @param [String?] description (nil) The command description. + # @example Setting + # MyCommands = Pry::CommandSet.new do + # desc "help", "help description" + # end + # @example Getting + # Pry.config.commands.desc "amend-line" + def desc(search, description=nil) + cmd = find_command_by_match_or_listing(search) + return cmd.description if !description + + cmd.description = description + end + + # Defines helpers methods for this command sets. + # Those helpers are only defined in this command set. + # + # @yield A block defining helper methods + # @example + # helpers do + # def hello + # puts "Hello!" + # end + # + # include OtherModule + # end + def helpers(&block) + helper_module.class_eval(&block) + end + + + # @return [Array] + # The list of commands provided by the command set. + def list_commands + @commands.keys + end + alias_method :keys, :list_commands + + def to_hash + @commands.dup + end + alias_method :to_h, :to_hash + + # Find a command that matches the given line + # @param [String] pattern The line that might be a command invocation + # @return [Pry::Command, nil] + def [](pattern) + @commands.values.select do |command| + command.matches?(pattern) + end.sort_by do |command| + command.match_score(pattern) + end.last + end + alias_method :find_command, :[] + + # + # Re-assign the command found at _pattern_ with _command_. + # + # @param [Regexp, String] pattern + # The command to add or replace(found at _pattern_). + # + # @param [Pry::Command] command + # The command to add. + # + # @return [Pry::Command] + # Returns the new command (matched with "pattern".) + # + # @example + # Pry.config.commands["help"] = MyHelpCommand + # + def []=(pattern, command) + if command.equal?(nil) + return @commands.delete(pattern) + end + unless Class === command && command < Pry::Command + raise TypeError, "command is not a subclass of Pry::Command" + end + bind_command_to_pattern = pattern != command.match + if bind_command_to_pattern + command_copy = command.dup + command_copy.match = pattern + @commands[pattern] = command_copy + else + @commands[pattern] = command + end + end + + # + # Add a command to set. + # + # @param [Command] command + # a subclass of Pry::Command. + # + def add_command(command) + self[command.match] = command + end + + # Find the command that the user might be trying to refer to. + # @param [String] search The user's search. + # @return [Pry::Command?] + def find_command_for_help(search) + find_command(search) || (begin + find_command_by_match_or_listing(search) + rescue ArgumentError + nil + end) + end + + # Is the given line a command invocation? + # @param [String] val + # @return [Boolean] + def valid_command?(val) + !!find_command(val) + end + + # Process the given line to see whether it needs executing as a command. + # @param [String] val The line to execute + # @param [Hash] context The context to execute the commands with + # @return [CommandSet::Result] + def process_line(val, context={}) + if command = find_command(val) + context = context.merge(:command_set => self) + retval = command.new(context).process_line(val) + Result.new(true, retval) + else + Result.new(false) + end + end + + # @private (used for testing) + def run_command(context, match, *args) + command = @commands[match] or raise NoCommandError.new(match, self) + command.new(context).call_safely(*args) + end + + # Generate completions for the user's search. + # @param [String] search The line to search for + # @param [Hash] context The context to create the command with + # @return [Array] + def complete(search, context={}) + if command = find_command(search) + command.new(context).complete(search) + else + @commands.keys.select do |key| + String === key && key.start_with?(search) + end.map{ |key| key + " " } + end + end + end + + # Wraps the return result of process_commands, indicates if the + # result IS a command and what kind of command (e.g void) + class Result + attr_reader :retval + + def initialize(is_command, retval = nil) + @is_command, @retval = is_command, retval + end + + # Is the result a command? + # @return [Boolean] + def command? + @is_command + end + + # Is the result a command and if it is, is it a void command? + # (one that does not return a value) + # @return [Boolean] + def void_command? + retval == Command::VOID_VALUE + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands.rb new file mode 100644 index 000000000..4b85ada1b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands.rb @@ -0,0 +1,6 @@ +# Default commands used by Pry. +Pry::Commands = Pry::CommandSet.new + +Dir[File.expand_path('../commands', __FILE__) << '/*.rb'].each do |file| + require file +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/amend_line.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/amend_line.rb new file mode 100644 index 000000000..d30c9a0f2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/amend_line.rb @@ -0,0 +1,99 @@ +class Pry + class Command::AmendLine < Pry::ClassCommand + match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/) + group 'Editing' + description 'Amend a line of input in multi-line mode.' + command_options :interpolate => false, :listing => 'amend-line' + + banner <<-'BANNER' + Amend a line of input in multi-line mode. `amend-line N`, where the N represents + line to replace. Can also specify a range of lines using `amend-line N..M` + syntax. Passing "!" as replacement content deletes the line(s) instead. + + amend-line 1 puts 'new' # replace line 1 + amend-line 1..4 ! # delete lines 1..4 + amend-line 3 >puts 'bye' # insert before line 3 + amend-line puts 'appended' # no line number modifies immediately preceding line + BANNER + + def process + raise CommandError, "No input to amend." if eval_string.empty? + + eval_string.replace amended_input(eval_string) + run "fix-indent" + run "show-input" + end + + private + + # @param [String] string The string to amend. + # @return [String] A new string with the amendments applied to it. + def amended_input(string) + input_array = eval_string.each_line.to_a + + if arg_string == "!" + delete_from_array(input_array, line_range) + elsif arg_string.start_with?(">") + insert_into_array(input_array, line_range) + else + replace_in_array(input_array, line_range) + end + + input_array.join + end + + def delete_from_array(array, range) + array.slice!(range) + end + + def insert_into_array(array, range) + insert_slot = Array(range).first + array.insert(insert_slot, arg_string[1..-1] << "\n") + end + + def replace_in_array(array, range) + array[range] = arg_string + "\n" + end + + # @return [Fixnum] The number of lines currently in `eval_string` (the input buffer). + def line_count + eval_string.lines.count + end + + # Returns the (one-indexed) start and end lines given by the user. + # The lines in this range will be affected by the `amend-line`. + # Returns `nil` if no lines were specified by the user. + # @return [Array, nil] + def start_and_end_line_number + start_line_number, end_line_number = args + end_line_number ||= start_line_number.to_i + + [start_line_number.to_i, end_line_number.to_i] if start_line_number + end + + # Takes two numbers that are 1-indexed, and returns a range (or + # number) that is 0-indexed. 1-indexed means the first element is + # indentified by 1 rather than by 0 (as is the case for Ruby arrays). + # @param [Fixnum] start_line_number One-indexed number. + # @param [Fixnum] end_line_number One-indexed number. + # @return [Range] The zero-indexed range. + def zero_indexed_range_from_one_indexed_numbers(start_line_number, end_line_number) + # FIXME: one_index_number is a horrible name for this method + one_index_number(start_line_number)..one_index_number(end_line_number) + end + + # The lines (or line) that will be modified by the `amend-line`. + # @return [Range, Fixnum] The lines or line. + def line_range + start_line_number, end_line_number = start_and_end_line_number + if start_line_number + zero_indexed_range_from_one_indexed_numbers(start_line_number, + end_line_number) + else + line_count - 1 + end + end + end + + Pry::Commands.add_command(Pry::Command::AmendLine) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang.rb new file mode 100644 index 000000000..8843458f9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang.rb @@ -0,0 +1,20 @@ +class Pry + class Command::Bang < Pry::ClassCommand + match(/^\s*!\s*$/) + group 'Editing' + description 'Clear the input buffer.' + command_options :use_prefix => false + + banner <<-'BANNER' + Clear the input buffer. Useful if the parsing process goes wrong and you get + stuck in the read loop. + BANNER + + def process + output.puts 'Input buffer cleared!' + eval_string.replace('') + end + end + + Pry::Commands.add_command(Pry::Command::Bang) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang_pry.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang_pry.rb new file mode 100644 index 000000000..71f81ef12 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/bang_pry.rb @@ -0,0 +1,17 @@ +class Pry + class Command::BangPry < Pry::ClassCommand + match '!pry' + group 'Navigating Pry' + description 'Start a Pry session on current self.' + + banner <<-'BANNER' + Start a Pry session on current self. Also works mid multi-line expression. + BANNER + + def process + target.pry + end + end + + Pry::Commands.add_command(Pry::Command::BangPry) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat.rb new file mode 100644 index 000000000..8ca537fef --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat.rb @@ -0,0 +1,62 @@ +class Pry + class Command::Cat < Pry::ClassCommand + require 'pry/commands/cat/abstract_formatter.rb' + require 'pry/commands/cat/input_expression_formatter.rb' + require 'pry/commands/cat/exception_formatter.rb' + require 'pry/commands/cat/file_formatter.rb' + + match 'cat' + group 'Input and Output' + description "Show code from a file, Pry's input buffer, or the last exception." + + banner <<-'BANNER' + Usage: cat FILE + cat --ex [STACK_INDEX] + cat --in [INPUT_INDEX_OR_RANGE] + + `cat` is capable of showing part or all of a source file, the context of the + last exception, or an expression from Pry's input history. + + `cat --ex` defaults to showing the lines surrounding the location of the last + exception. Invoking it more than once travels up the exception's backtrace, and + providing a number shows the context of the given index of the backtrace. + BANNER + + def options(opt) + opt.on :ex, "Show the context of the last exception", :optional_argument => true, :as => Integer + opt.on :i, :in, "Show one or more entries from Pry's expression history", :optional_argument => true, :as => Range, :default => -5..-1 + opt.on :s, :start, "Starting line (defaults to the first line)", :optional_argument => true, :as => Integer + opt.on :e, :end, "Ending line (defaults to the last line)", :optional_argument => true, :as => Integer + opt.on :l, :'line-numbers', "Show line numbers" + opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", :argument => true, :as => Symbol + end + + def process + output = case + when opts.present?(:ex) + ExceptionFormatter.new(_pry_.last_exception, _pry_, opts).format + when opts.present?(:in) + InputExpressionFormatter.new(_pry_.input_array, opts).format + else + FileFormatter.new(args.first, _pry_, opts).format + end + + _pry_.pager.page output + end + + def complete(search) + super | load_path_completions + end + + def load_path_completions + $LOAD_PATH.flat_map do |path| + Dir[path + '/**/*'].map { |f| + next if File.directory?(f) + f.sub!(path + '/', '') + } + end + end + end + + Pry::Commands.add_command(Pry::Command::Cat) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/abstract_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/abstract_formatter.rb new file mode 100644 index 000000000..c5546476c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/abstract_formatter.rb @@ -0,0 +1,27 @@ +class Pry + class Command::Cat + class AbstractFormatter + include Pry::Helpers::CommandHelpers + include Pry::Helpers::BaseHelpers + + private + def decorate(content) + content.code_type = code_type + content.between(*between_lines). + with_line_numbers(use_line_numbers?).highlighted + end + + def code_type + opts[:type] || :ruby + end + + def use_line_numbers? + opts.present?(:'line-numbers') || opts.present?(:ex) + end + + def between_lines + [opts[:start] || 1, opts[:end] || -1] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/exception_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/exception_formatter.rb new file mode 100644 index 000000000..af10e9d50 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/exception_formatter.rb @@ -0,0 +1,77 @@ +class Pry + class Command::Cat + class ExceptionFormatter < AbstractFormatter + attr_reader :ex + attr_reader :opts + attr_reader :_pry_ + + def initialize(exception, _pry_, opts) + @ex = exception + @opts = opts + @_pry_ = _pry_ + end + + def format + check_for_errors + set_file_and_dir_locals(backtrace_file, _pry_, _pry_.current_context) + code = decorate(Pry::Code.from_file(backtrace_file). + between(*start_and_end_line_for_code_window). + with_marker(backtrace_line)) + "#{header}#{code}" + end + + private + + def code_window_size + _pry_.config.default_window_size || 5 + end + + def backtrace_level + return @backtrace_level if @backtrace_level + + bl = if opts[:ex].nil? + ex.bt_index + else + ex.bt_index = absolute_index_number(opts[:ex], ex.backtrace.size) + end + + increment_backtrace_level + @backtrace_level = bl + end + + def increment_backtrace_level + ex.inc_bt_index + end + + def backtrace_file + Array(ex.bt_source_location_for(backtrace_level)).first + end + + def backtrace_line + Array(ex.bt_source_location_for(backtrace_level)).last + end + + def check_for_errors + raise CommandError, "No exception found." unless ex + raise CommandError, "The given backtrace level is out of bounds." unless backtrace_file + end + + def start_and_end_line_for_code_window + start_line = backtrace_line - code_window_size + start_line = 1 if start_line < 1 + + [start_line, backtrace_line + code_window_size] + end + + def header + unindent %{ + #{Helpers::Text.bold 'Exception:'} #{ex.class}: #{ex.message} + -- + #{Helpers::Text.bold('From:')} #{backtrace_file} @ line #{backtrace_line} @ #{Helpers::Text.bold("level: #{backtrace_level}")} of backtrace (of #{ex.backtrace.size - 1}). + + } + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/file_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/file_formatter.rb new file mode 100644 index 000000000..a7a867995 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/file_formatter.rb @@ -0,0 +1,67 @@ +class Pry + class Command::Cat + class FileFormatter < AbstractFormatter + attr_reader :file_with_embedded_line + attr_reader :opts + attr_reader :_pry_ + + def initialize(file_with_embedded_line, _pry_, opts) + @file_with_embedded_line = file_with_embedded_line + @opts = opts + @_pry_ = _pry_ + @code_from_file = Pry::Code.from_file(file_name) + end + + def format + raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line + + set_file_and_dir_locals(file_name, _pry_, _pry_.current_context) + decorate(@code_from_file) + end + + def file_and_line + file_name, line_num = file_with_embedded_line.split(/:(?!\/|\\)/) + + [file_name, line_num ? line_num.to_i : nil] + end + + private + + def file_name + file_and_line.first + end + + def line_number + file_and_line.last + end + + def code_window_size + _pry_.config.default_window_size || 7 + end + + def decorate(content) + line_number ? super.around(line_number, code_window_size) : super + end + + def code_type + opts[:type] || detect_code_type_from_file(file_name) + end + + def detect_code_type_from_file(file_name) + code_type = @code_from_file.code_type + + if code_type == :unknown + name = File.basename(file_name).split('.', 2).first + case name + when "Rakefile", "Gemfile" + :ruby + else + :text + end + else + code_type + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/input_expression_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/input_expression_formatter.rb new file mode 100644 index 000000000..8791ac3f7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cat/input_expression_formatter.rb @@ -0,0 +1,43 @@ +class Pry + class Command::Cat + class InputExpressionFormatter < AbstractFormatter + attr_accessor :input_expressions + attr_accessor :opts + + def initialize(input_expressions, opts) + @input_expressions = input_expressions + @opts = opts + end + + def format + raise CommandError, "No input expressions!" if numbered_input_items.length < 1 + + if numbered_input_items.length > 1 + content = "" + numbered_input_items.each do |i, s| + content << "#{Helpers::Text.bold(i.to_s)}:\n" << decorate(Pry::Code(s).with_indentation(2)).to_s + end + + content + else + decorate(Pry::Code(selected_input_items.first)) + end + end + + private + + def selected_input_items + input_expressions[normalized_expression_range] || [] + end + + def numbered_input_items + @numbered_input_items ||= normalized_expression_range.zip(selected_input_items). + reject { |_, s| s.nil? || s == "" } + end + + def normalized_expression_range + absolute_index_range(opts[:i], input_expressions.length) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cd.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cd.rb new file mode 100644 index 000000000..667453a08 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/cd.rb @@ -0,0 +1,41 @@ +class Pry + class Command::Cd < Pry::ClassCommand + match 'cd' + group 'Context' + description 'Move into a new context (object or scope).' + + banner <<-'BANNER' + Usage: cd [OPTIONS] [--help] + + Move into new context (object or scope). As in UNIX shells use `cd ..` to go + back, `cd /` to return to Pry top-level and `cd -` to toggle between last two + scopes. Complex syntax (e.g `cd ../@x/@y`) also supported. + + cd @x + cd .. + cd / + cd - + + https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope + BANNER + + def process + state.old_stack ||= [] + + if arg_string.strip == "-" + unless state.old_stack.empty? + _pry_.binding_stack, state.old_stack = state.old_stack, _pry_.binding_stack + end + else + stack = ObjectPath.new(arg_string, _pry_.binding_stack).resolve + + if stack && stack != _pry_.binding_stack + state.old_stack = _pry_.binding_stack + _pry_.binding_stack = stack + end + end + end + end + + Pry::Commands.add_command(Pry::Command::Cd) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_inspector.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_inspector.rb new file mode 100644 index 000000000..183dec4f6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_inspector.rb @@ -0,0 +1,27 @@ +class Pry::Command::ChangeInspector < Pry::ClassCommand + match 'change-inspector' + group 'Input and Output' + description 'Change the current inspector proc.' + command_options argument_required: true + banner <<-BANNER + Usage: change-inspector NAME + + Change the proc used to print return values. See list-inspectors for a list + of available procs and a short description of what each one does. + BANNER + + def process(inspector) + if inspector_map.key?(inspector) + _pry_.print = inspector_map[inspector][:value] + output.puts "Switched to the '#{inspector}' inspector!" + else + raise Pry::CommandError, "'#{inspector}' isn't a known inspector!" + end + end + +private + def inspector_map + Pry::Inspector::MAP + end + Pry::Commands.add_command(self) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_prompt.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_prompt.rb new file mode 100644 index 000000000..13d36cbbc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/change_prompt.rb @@ -0,0 +1,26 @@ +class Pry::Command::ChangePrompt < Pry::ClassCommand + match 'change-prompt' + group 'Input and Output' + description 'Change the current prompt.' + command_options argument_required: true + banner <<-BANNER + Usage: change-prompt NAME + + Change the current prompt. See list-prompts for a list of available + prompts. + BANNER + + def process(prompt) + if prompt_map.key?(prompt) + _pry_.prompt = prompt_map[prompt][:value] + else + raise Pry::CommandError, "'#{prompt}' isn't a known prompt!" + end + end + +private + def prompt_map + Pry::Prompt::MAP + end + Pry::Commands.add_command(self) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/code_collector.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/code_collector.rb new file mode 100644 index 000000000..72e81815d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/code_collector.rb @@ -0,0 +1,165 @@ +class Pry + class Command::CodeCollector + include Helpers::CommandHelpers + + attr_reader :args + attr_reader :opts + attr_reader :_pry_ + + # The name of the explicitly given file (if any). + attr_accessor :file + + class << self + attr_accessor :input_expression_ranges + attr_accessor :output_result_ranges + end + + @input_expression_ranges = [] + @output_result_ranges = [] + + def initialize(args, opts, _pry_) + @args = args + @opts = opts + @_pry_ = _pry_ + end + + # Add the `--lines`, `-o`, `-i`, `-s`, `-d` options. + def self.inject_options(opt) + @input_expression_ranges = [] + @output_result_ranges = [] + + opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range", + :optional_argument => true, :as => Range, :default => 1..-1 + opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range", + :optional_argument => true, :as => Range, :default => -5..-1 do |r| + output_result_ranges << (r || (-5..-1)) + end + opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range", + :optional_argument => true, :as => Range, :default => -5..-1 do |r| + input_expression_ranges << (r || (-5..-1)) + end + opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", + :as => :count + opt.on :d, :doc, "Select lines from the code object's documentation" + end + + # The content (i.e code/docs) for the selected object. + # If the user provided a bare code object, it returns the source. + # If the user provided the `-i` or `-o` switches, it returns the + # selected input/output lines joined as a string. If the user used + # `-d CODE_OBJECT` it returns the docs for that code object. + # + # @return [String] + def content + return @content if @content + raise CommandError, "Only one of --out, --in, --doc and CODE_OBJECT may be specified." if bad_option_combination? + + content = case + when opts.present?(:o) + pry_output_content + when opts.present?(:i) + pry_input_content + when opts.present?(:d) + code_object_doc + else + code_object_source_or_file + end + + @content ||= restrict_to_lines(content, line_range) + end + + # The code object + # + # @return [Pry::WrappedModule, Pry::Method, Pry::Command] + def code_object + Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super]) + end + + # Given a string and a range, return the `range` lines of that + # string. + # + # @param [String] content + # @param [Range, Fixnum] range + # @return [String] The string restricted to the given range + def restrict_to_lines(content, range) + Array(content.lines.to_a[range]).join + end + + # The selected `_pry_.output_array` as a string, as specified by + # the `-o` switch. + # + # @return [String] + def pry_output_content + pry_array_content_as_string(_pry_.output_array, self.class.output_result_ranges) do |v| + _pry_.config.gist.inspecter.call(v) + end + end + + # The selected `_pry_.input_array` as a string, as specified by + # the `-i` switch. + # + # @return [String] + def pry_input_content + pry_array_content_as_string(_pry_.input_array, self.class.input_expression_ranges) { |v| v } + end + + # The line range passed to `--lines`, converted to a 0-indexed range. + def line_range + opts.present?(:lines) ? one_index_range_or_number(opts[:lines]) : 0..-1 + end + + # Name of the object argument + def obj_name + @obj_name ||= args.empty? ? "" : args.join(" ") + end + + private + + def bad_option_combination? + [opts.present?(:in), opts.present?(:out), + !args.empty?].count(true) > 1 + end + + def pry_array_content_as_string(array, ranges, &block) + all = '' + ranges.each do |range| + raise CommandError, "Minimum value for range is 1, not 0." if convert_to_range(range).first == 0 + + ranged_array = Array(array[range]) || [] + ranged_array.compact.each { |v| all << block.call(v) } + end + + all + end + + def code_object_doc + (code_object && code_object.doc) or could_not_locate(obj_name) + end + + def code_object_source_or_file + (code_object && code_object.source) || file_content + end + + def file_content + if File.exists?(obj_name) + # Set the file accessor. + self.file = obj_name + File.read(obj_name) + else + could_not_locate(obj_name) + end + end + + def could_not_locate(name) + raise CommandError, "Cannot locate: #{name}!" + end + + def convert_to_range(n) + if !n.is_a?(Range) + (n..n) + else + n + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disable_pry.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disable_pry.rb new file mode 100644 index 000000000..69bfc4e85 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disable_pry.rb @@ -0,0 +1,27 @@ +class Pry + class Command::DisablePry < Pry::ClassCommand + match 'disable-pry' + group 'Navigating Pry' + description 'Stops all future calls to pry and exits the current session.' + + banner <<-'BANNER' + Usage: disable-pry + + After this command is run any further calls to pry will immediately return `nil` + without interrupting the flow of your program. This is particularly useful when + you've debugged the problem you were having, and now wish the program to run to + the end. + + As alternatives, consider using `exit!` to force the current Ruby process + to quit immediately; or using `edit-method -p` to remove the `binding.pry` + from the code. + BANNER + + def process + ENV['DISABLE_PRY'] = 'true' + _pry_.run_command "exit" + end + end + + Pry::Commands.add_command(Pry::Command::DisablePry) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disabled_commands.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disabled_commands.rb new file mode 100644 index 000000000..9866f901c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/disabled_commands.rb @@ -0,0 +1,2 @@ +Pry::Commands.disabled_command("edit-method", "Use `edit` instead.") +Pry::Commands.disabled_command("show-command", "Use show-source [command_name] instead.") diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/easter_eggs.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/easter_eggs.rb new file mode 100644 index 000000000..84a97df96 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/easter_eggs.rb @@ -0,0 +1,112 @@ +class Pry + Pry::Commands.instance_eval do + command "nyan-cat", "", :requires_gem => ["nyancat"] do + run ".nyancat" + end + + command(/!s\/(.*?)\/(.*?)/, "") do |source, dest| + eval_string.gsub!(/#{source}/) { dest } + run "show-input" + end + + command "get-naked", "" do + text = %{ + -- + We dont have to take our clothes off to have a good time. + We could dance & party all night And drink some cherry wine. + -- Jermaine Stewart } + output.puts text + text + end + + command "east-coker", "" do + text = %{ + -- + Now the light falls + Across the open field, leaving the deep lane + Shuttered with branches, dark in the afternoon, + Where you lean against a bank while a van passes, + And the deep lane insists on the direction + Into the village, in the electric heat + Hypnotised. In a warm haze the sultry light + Is absorbed, not refracted, by grey stone. + The dahlias sleep in the empty silence. + Wait for the early owl. + -- T.S Eliot + } + output.puts text + text + end + + command "cohen-poem", "" do + text = %{ + -- + When this American woman, + whose thighs are bound in casual red cloth, + comes thundering past my sitting place + like a forest-burning Mongol tribe, + the city is ravished + and brittle buildings of a hundred years + splash into the street; + and my eyes are burnt + for the embroidered Chinese girls, + already old, + and so small between the thin pines + on these enormous landscapes, + that if you turn your head + they are lost for hours. + -- Leonard Cohen + } + output.puts text + text + end + + command "pessoa-poem", "" do + output.puts <<-TEXT + -- + I've gone to bed with every feeling, + I've been the pimp of every emotion, + All felt sensations have bought me drinks, + I've traded glances with every motive for every act, + I've held hands with every urge to depart, + .. + Rage, foam, the vastness that doesn't fit in my handkerchief, + The dog in heat howling in the night, + The pond from the farm going in circles around my insomnia, + The woods as they were, on our late-afternoon walks, the rose, + The indifferent tuft of hair, the moss, the pines, + The rage of not containing all this, not retaining all this, + O abstract hunger for things, impotent libido for moments, + Intellectual orgy of feeling life! + -- Fernando Pessoa +TEXT + end + + command "test-ansi", "" do + prev_color = _pry_.config.color + _pry_.config.color = true + + picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| text.red(s) } + ____ _______________________ + / \ | A W G | + / O O \ | N I O N ! | + | | | S S R I ! | + \ \__/ / __| I K ! | + \____/ \________________________| + EOS + + if windows_ansi? + move_up = proc { |n| "\e[#{n}F" } + else + move_up = proc { |n| "\e[#{n}A\e[0G" } + end + + output.puts "\n" * 6 + output.puts picture.lines.map(&:chomp).reverse.join(move_up[1]) + output.puts "\n" * 6 + output.puts "** ENV['TERM'] is #{ENV['TERM']} **\n\n" + + _pry_.config.color = prev_color + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit.rb new file mode 100644 index 000000000..cf2cc1c77 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit.rb @@ -0,0 +1,195 @@ +class Pry + class Command::Edit < Pry::ClassCommand + require 'pry/commands/edit/exception_patcher' + require 'pry/commands/edit/file_and_line_locator' + + match 'edit' + group 'Editing' + description 'Invoke the default editor on a file.' + + banner <<-'BANNER' + Usage: edit [--no-reload|--reload|--patch] [--line LINE] [--temp|--ex|FILE[:LINE]|OBJECT|--in N] + + Open a text editor. When no FILE is given, edits the pry input buffer. + When a method/module/command is given, the code is opened in an editor. + Ensure `Pry.config.editor` or `_pry_.config.editor` is set to your editor of choice. + + edit sample.rb edit -p MyClass#my_method + edit sample.rb --line 105 edit MyClass + edit MyClass#my_method edit --ex + edit --method edit --ex -p + + https://github.com/pry/pry/wiki/Editor-integration#wiki-Edit_command + BANNER + + def options(opt) + opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)", + :optional_argument => true, :as => Integer + opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range", + :optional_argument => true, :as => Range, :default => -1..-1 + opt.on :t, :temp, "Open an empty temporary file" + opt.on :l, :line, "Jump to this line in the opened file", + :argument => true, :as => Integer + opt.on :n, :"no-reload", "Don't automatically reload the edited file" + opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)" + opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)" + opt.on :p, :patch, "Instead of editing the object's file, try to edit in a tempfile and apply as a monkey patch" + opt.on :m, :method, "Explicitly edit the _current_ method (when inside a method context)." + end + + def process + if bad_option_combination? + raise CommandError, "Only one of --ex, --temp, --in, --method and FILE may be specified." + end + + if repl_edit? + # code defined in pry, eval'd within pry. + repl_edit + elsif runtime_patch? + # patch code without persisting changes + apply_runtime_patch + else + # code stored in actual files, eval'd at top-level + file_edit + end + end + + def repl_edit? + !opts.present?(:ex) && !opts.present?(:current) && !opts.present?(:method) && + filename_argument.empty? + end + + def repl_edit + content = Pry::Editor.new(_pry_).edit_tempfile_with_content(initial_temp_file_content, + initial_temp_file_content.lines.count) + silence_warnings do + eval_string.replace content + end + end + + def file_based_exception? + opts.present?(:ex) && !opts.present?(:patch) + end + + def runtime_patch? + !file_based_exception? && (opts.present?(:patch) || pry_method?(code_object)) + end + + def apply_runtime_patch + if patch_exception? + ExceptionPatcher.new(_pry_, state, file_and_line_for_current_exception).perform_patch + else + if code_object.is_a?(Pry::Method) + code_object.redefine Pry::Editor.new(_pry_).edit_tempfile_with_content(code_object.source) + else + raise NotImplementedError, "Cannot yet patch #{code_object} objects!" + end + end + end + + def ensure_file_name_is_valid(file_name) + raise CommandError, "Cannot find a valid file for #{filename_argument}" if !file_name + raise CommandError, "#{file_name} is not a valid file name, cannot edit!" if not_a_real_file?(file_name) + end + + def file_and_line_for_current_exception + FileAndLineLocator.from_exception(_pry_.last_exception, opts[:ex].to_i) + end + + def file_and_line + file_name, line = if opts.present?(:current) + FileAndLineLocator.from_binding(target) + elsif opts.present?(:ex) + file_and_line_for_current_exception + elsif code_object + FileAndLineLocator.from_code_object(code_object, filename_argument) + else + # when file and line are passed as a single arg, e.g my_file.rb:30 + FileAndLineLocator.from_filename_argument(filename_argument) + end + + [file_name, opts.present?(:line) ? opts[:l].to_i : line] + end + + def file_edit + file_name, line = file_and_line + + ensure_file_name_is_valid(file_name) + + Pry::Editor.new(_pry_).invoke_editor(file_name, line, reload?(file_name)) + set_file_and_dir_locals(file_name) + + if reload?(file_name) + silence_warnings do + load file_name + end + end + end + + def filename_argument + args.join(' ') + end + + def code_object + @code_object ||= !probably_a_file?(filename_argument) && + Pry::CodeObject.lookup(filename_argument, _pry_) + end + + def pry_method?(code_object) + code_object.is_a?(Pry::Method) && + code_object.pry_method? + end + + def patch_exception? + opts.present?(:ex) && opts.present?(:patch) + end + + def bad_option_combination? + [opts.present?(:ex), opts.present?(:temp), + opts.present?(:in), opts.present?(:method), !filename_argument.empty?].count(true) > 1 + end + + def input_expression + case opts[:i] + when Range + (_pry_.input_array[opts[:i]] || []).join + when Fixnum + _pry_.input_array[opts[:i]] || "" + else + raise Pry::CommandError, "Not a valid range: #{opts[:i]}" + end + end + + def reloadable? + opts.present?(:reload) || opts.present?(:ex) + end + + def never_reload? + opts.present?(:'no-reload') || _pry_.config.disable_auto_reload + end + + def reload?(file_name="") + (reloadable? || file_name.end_with?(".rb")) && !never_reload? + end + + def initial_temp_file_content + case + when opts.present?(:temp) + "" + when opts.present?(:in) + input_expression + when eval_string.strip != "" + eval_string + else + _pry_.input_array.reverse_each.find { |x| x && x.strip != "" } || "" + end + end + + def probably_a_file?(str) + [".rb", ".c", ".py", ".yml", ".gemspec"].include?(File.extname(str)) || + str =~ /\/|\\/ + end + end + + Pry::Commands.add_command(Pry::Command::Edit) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/exception_patcher.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/exception_patcher.rb new file mode 100644 index 000000000..07e13bc93 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/exception_patcher.rb @@ -0,0 +1,25 @@ +class Pry + class Command::Edit + class ExceptionPatcher + attr_accessor :_pry_ + attr_accessor :state + attr_accessor :file_and_line + + def initialize(_pry_, state, exception_file_and_line) + @_pry_ = _pry_ + @state = state + @file_and_line = exception_file_and_line + end + + # perform the patch + def perform_patch + file_name, _ = file_and_line + lines = state.dynamical_ex_file || File.read(file_name) + + source = Pry::Editor.new(_pry_).edit_tempfile_with_content(lines) + _pry_.evaluate_ruby source + state.dynamical_ex_file = source.split("\n") + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/file_and_line_locator.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/file_and_line_locator.rb new file mode 100644 index 000000000..5f712f3de --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/edit/file_and_line_locator.rb @@ -0,0 +1,36 @@ +class Pry + class Command::Edit + module FileAndLineLocator + class << self + def from_binding(target) + [target.eval("__FILE__"), target.eval("__LINE__")] + end + + def from_code_object(code_object, filename_argument) + if File.exists?(code_object.source_file.to_s) + [code_object.source_file, code_object.source_line] + else + raise CommandError, "Cannot find a file for #{filename_argument}!" + end + end + + def from_exception(exception, backtrace_level) + raise CommandError, "No exception found." if exception.nil? + + file_name, line = exception.bt_source_location_for(backtrace_level) + raise CommandError, "Exception has no associated file." if file_name.nil? + raise CommandError, "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name + + [file_name, line] + end + + # when file and line are passed as a single arg, e.g my_file.rb:30 + def from_filename_argument(filename_argument) + f = File.expand_path(filename_argument) + l = f.sub!(/:(\d+)$/, "") ? $1.to_i : 1 + [f, l] + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit.rb new file mode 100644 index 000000000..32c0c2ee3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit.rb @@ -0,0 +1,42 @@ +class Pry + class Command::Exit < Pry::ClassCommand + match 'exit' + group 'Navigating Pry' + description 'Pop the previous binding.' + command_options :keep_retval => true + + banner <<-'BANNER' + Usage: exit [OPTIONS] [--help] + Aliases: quit + + Pop the previous binding (does NOT exit program). It can be useful to exit a + context with a user-provided value. For instance an exit value can be used to + determine program flow. + + exit "pry this" + exit + + https://github.com/pry/pry/wiki/State-navigation#wiki-Exit_with_value + BANNER + + def process + if _pry_.binding_stack.one? + _pry_.run_command "exit-all #{arg_string}" + else + # otherwise just pop a binding and return user supplied value + process_pop_and_return + end + end + + def process_pop_and_return + popped_object = _pry_.binding_stack.pop.eval('self') + + # return a user-specified value if given otherwise return the object + return target.eval(arg_string) unless arg_string.empty? + popped_object + end + end + + Pry::Commands.add_command(Pry::Command::Exit) + Pry::Commands.alias_command 'quit', 'exit' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_all.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_all.rb new file mode 100644 index 000000000..1136de318 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_all.rb @@ -0,0 +1,29 @@ +class Pry + class Command::ExitAll < Pry::ClassCommand + match 'exit-all' + group 'Navigating Pry' + description 'End the current Pry session.' + + banner <<-'BANNER' + Usage: exit-all [--help] + Aliases: !!@ + + End the current Pry session (popping all bindings and returning to caller). + Accepts optional return value. + BANNER + + def process + # calculate user-given value + exit_value = target.eval(arg_string) + + # clear the binding stack + _pry_.binding_stack.clear + + # break out of the repl loop + throw(:breakout, exit_value) + end + end + + Pry::Commands.add_command(Pry::Command::ExitAll) + Pry::Commands.alias_command '!!@', 'exit-all' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_program.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_program.rb new file mode 100644 index 000000000..a4d9168b4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/exit_program.rb @@ -0,0 +1,23 @@ +class Pry + class Command::ExitProgram < Pry::ClassCommand + match 'exit-program' + group 'Navigating Pry' + description 'End the current program.' + + banner <<-'BANNER' + Usage: exit-program [--help] + Aliases: quit-program + !!! + + End the current program. + BANNER + + def process + Kernel.exit target.eval(arg_string).to_i + end + end + + Pry::Commands.add_command(Pry::Command::ExitProgram) + Pry::Commands.alias_command 'quit-program', 'exit-program' + Pry::Commands.alias_command '!!!', 'exit-program' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/find_method.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/find_method.rb new file mode 100644 index 000000000..c1ee2c5dc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/find_method.rb @@ -0,0 +1,193 @@ +class Pry + class Command::FindMethod < Pry::ClassCommand + extend Pry::Helpers::BaseHelpers + + match 'find-method' + group 'Context' + description 'Recursively search for a method within a Class/Module or the current namespace.' + command_options :shellwords => false + + banner <<-'BANNER' + Usage: find-method [-n|-c] METHOD [NAMESPACE] + + Recursively search for a method within a Class/Module or the current namespace. + Use the `-n` switch (the default) to search for methods whose name matches the + given regex. Use the `-c` switch to search for methods that contain the given + code. + + # Find all methods whose name match /re/ inside + # the Pry namespace. Matches Pry#repl, etc. + find-method re Pry + + # Find all methods that contain the code: + # output.puts inside the Pry namepsace. + find-method -c 'output.puts' Pry + BANNER + + def options(opt) + opt.on :n, :name, "Search for a method by name" + opt.on :c, :content, "Search for a method based on content in Regex form" + end + + def process + return if args.size < 1 + klass = search_class + + matches = if opts.content? + content_search(klass) + else + name_search(klass) + end + + show_search_results(matches) + end + + private + + # @return [Regexp] The pattern to search for. + def pattern + @pattern ||= ::Regexp.new args[0] + end + + # Output the result of the search. + # + # @param [Array] matches + def show_search_results(matches) + if matches.empty? + output.puts text.bold("No Methods Matched") + else + print_matches(matches) + end + end + + # The class to search for methods. + # We only search classes, so if the search object is an + # instance, return its class. If no search object is given + # search `target_self`. + def search_class + klass = if args[1] + target.eval(args[1]) + else + target_self + end + + klass.is_a?(Module) ? klass : klass.class + end + + # pretty-print a list of matching methods. + # + # @param [Array] matches + def print_matches(matches) + grouped = matches.group_by(&:owner) + order = grouped.keys.sort_by{ |x| x.name || x.to_s } + + order.each do |klass| + print_matches_for_class(klass, grouped) + end + end + + # Print matched methods for a class + def print_matches_for_class(klass, grouped) + output.puts text.bold(klass.name) + grouped[klass].each do |method| + header = method.name_with_owner + output.puts header + additional_info(header, method) + end + end + + # Return the matched lines of method source if `-c` is given or "" + # if `-c` was not given + def additional_info(header, method) + if opts.content? + ": " << colorize_code(matched_method_lines(header, method)) + else + "" + end + end + + def matched_method_lines(header, method) + method.source.split(/\n/).select {|x| x =~ pattern }.join("\n#{' ' * header.length}") + end + + # Run the given block against every constant in the provided namespace. + # + # @param [Module] klass The namespace in which to start the search. + # @param [Hash] done The namespaces we've already visited (private) + # @yieldparam klass Each class/module in the namespace. + # + def recurse_namespace(klass, done={}, &block) + return if !(Module === klass) || done[klass] + + done[klass] = true + + yield klass + + klass.constants.each do |name| + next if klass.autoload?(name) + begin + const = klass.const_get(name) + rescue RescuableException + # constant loading is an inexact science at the best of times, + # this often happens when a constant was .autoload? but someone + # tried to load it. It's now not .autoload? but will still raise + # a NameError when you access it. + else + recurse_namespace(const, done, &block) + end + end + end + + # Gather all the methods in a namespace that pass the given block. + # + # @param [Module] namespace The namespace in which to search. + # @yieldparam [Method] method The method to test + # @yieldreturn [Boolean] + # @return [Array] + # + def search_all_methods(namespace) + done = Hash.new{ |h,k| h[k] = {} } + matches = [] + + recurse_namespace(namespace) do |klass| + (Pry::Method.all_from_class(klass) + Pry::Method.all_from_obj(klass)).each do |method| + next if done[method.owner][method.name] + done[method.owner][method.name] = true + + matches << method if yield method + end + end + + matches + end + + # Search for all methods with a name that matches the given regex + # within a namespace. + # + # @param [Module] namespace The namespace to search + # @return [Array] + # + def name_search(namespace) + search_all_methods(namespace) do |meth| + meth.name =~ pattern + end + end + + # Search for all methods who's implementation matches the given regex + # within a namespace. + # + # @param [Module] namespace The namespace to search + # @return [Array] + # + def content_search(namespace) + search_all_methods(namespace) do |meth| + begin + meth.source =~ pattern + rescue RescuableException + false + end + end + end + end + + Pry::Commands.add_command(Pry::Command::FindMethod) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/fix_indent.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/fix_indent.rb new file mode 100644 index 000000000..75c48c746 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/fix_indent.rb @@ -0,0 +1,19 @@ +class Pry + class Command::FixIndent < Pry::ClassCommand + match 'fix-indent' + group 'Input and Output' + + description "Correct the indentation for contents of the input buffer" + + banner <<-USAGE + Usage: fix-indent + USAGE + + def process + indented_str = Pry::Indent.indent(eval_string) + eval_string.replace indented_str + end + end + + Pry::Commands.add_command(Pry::Command::FixIndent) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_cd.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_cd.rb new file mode 100644 index 000000000..da1907a60 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_cd.rb @@ -0,0 +1,26 @@ +class Pry + class Command::GemCd < Pry::ClassCommand + match 'gem-cd' + group 'Gems' + description "Change working directory to specified gem's directory." + command_options :argument_required => true + + banner <<-'BANNER' + Usage: gem-cd GEM_NAME + + Change the current working directory to that in which the given gem is + installed. + BANNER + + def process(gem) + Dir.chdir(Rubygem.spec(gem).full_gem_path) + output.puts(Dir.pwd) + end + + def complete(str) + Rubygem.complete(str) + end + end + + Pry::Commands.add_command(Pry::Command::GemCd) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_install.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_install.rb new file mode 100644 index 000000000..873e10602 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_install.rb @@ -0,0 +1,32 @@ +class Pry + class Command::GemInstall < Pry::ClassCommand + match 'gem-install' + group 'Gems' + description 'Install a gem and refresh the gem cache.' + command_options :argument_required => true + + banner <<-'BANNER' + Usage: gem-install GEM_NAME + + Installs the given gem, refreshes the gem cache, and requires the gem for you + based on a best guess from the gem name. + + gem-install pry-stack_explorer + BANNER + + def setup + require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller + end + + def process(gem) + Rubygem.install(gem) + output.puts "Gem `#{ text.green(gem) }` installed." + require gem + rescue LoadError + require_path = gem.split('-').join('/') + require require_path + end + end + + Pry::Commands.add_command(Pry::Command::GemInstall) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_list.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_list.rb new file mode 100644 index 000000000..e4a5d00e2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_list.rb @@ -0,0 +1,33 @@ +class Pry + class Command::GemList < Pry::ClassCommand + match 'gem-list' + group 'Gems' + description 'List and search installed gems.' + + banner <<-'BANNER' + Usage: gem-list [REGEX] + + List all installed gems, when a regex is provided, limit the output to those + that match the regex. + BANNER + + def process(pattern = nil) + pattern = Regexp.compile(pattern || '') + gems = Rubygem.list(pattern).group_by(&:name) + + gems.each do |gem, specs| + specs.sort! do |a,b| + Gem::Version.new(b.version) <=> Gem::Version.new(a.version) + end + + versions = specs.each_with_index.map do |spec, index| + index == 0 ? text.bright_green(spec.version.to_s) : text.green(spec.version.to_s) + end + + output.puts "#{text.default gem} (#{versions.join ', '})" + end + end + end + + Pry::Commands.add_command(Pry::Command::GemList) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_open.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_open.rb new file mode 100644 index 000000000..e21723aaa --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gem_open.rb @@ -0,0 +1,29 @@ +class Pry + class Command::GemOpen < Pry::ClassCommand + match 'gem-open' + group 'Gems' + description 'Opens the working directory of the gem in your editor.' + command_options :argument_required => true + + banner <<-'BANNER' + Usage: gem-open GEM_NAME + + Change the current working directory to that in which the given gem is + installed, and then opens your text editor. + + gem-open pry-exception_explorer + BANNER + + def process(gem) + Dir.chdir(Rubygem.spec(gem).full_gem_path) do + Pry::Editor.invoke_editor(".", 0, false) + end + end + + def complete(str) + Rubygem.complete(str) + end + end + + Pry::Commands.add_command(Pry::Command::GemOpen) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gist.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gist.rb new file mode 100644 index 000000000..83cdf2b8a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/gist.rb @@ -0,0 +1,101 @@ +class Pry + class Command::Gist < Pry::ClassCommand + match 'gist' + group 'Misc' + description 'Upload code, docs, history to https://gist.github.com/.' + command_options :requires_gem => "gist" + + banner <<-'BANNER' + Usage: gist [OPTIONS] [--help] + + The gist command enables you to gist code from files and methods to github. + + gist -i 20 --lines 1..3 + gist Pry#repl --lines 1..-1 + gist Rakefile --lines 5 + BANNER + + def setup + require 'gist' + end + + def options(opt) + CodeCollector.inject_options(opt) + opt.on :login, "Authenticate the gist gem with GitHub" + opt.on :p, :public, "Create a public gist (default: false)", :default => false + opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :default => false + end + + def process + return ::Gist.login! if opts.present?(:login) + cc = CodeCollector.new(args, opts, _pry_) + + if cc.content =~ /\A\s*\z/ + raise CommandError, "Found no code to gist." + end + + if opts.present?(:clip) + clipboard_content(cc.content) + else + # we're overriding the default behavior of the 'in' option (as + # defined on CodeCollector) with our local behaviour. + content = opts.present?(:in) ? input_content : cc.content + gist_content content, cc.file + end + end + + def clipboard_content(content) + ::Gist.copy(content) + output.puts "Copied content to clipboard!" + end + + def input_content + content = "" + CodeCollector.input_expression_ranges.each do |range| + input_expressions = _pry_.input_array[range] || [] + Array(input_expressions).each_with_index do |code, index| + corrected_index = index + range.first + if code && code != "" + content << code + if code !~ /;\Z/ + content << "#{comment_expression_result_for_gist(_pry_.config.gist.inspecter.call(_pry_.output_array[corrected_index]))}" + end + end + end + end + + content + end + + def comment_expression_result_for_gist(result) + content = "" + result.lines.each_with_index do |line, index| + if index == 0 + content << "# => #{line}" + else + content << "# #{line}" + end + end + + content + end + + def gist_content(content, filename) + response = ::Gist.gist(content, :filename => filename || "pry_gist.rb", :public => !!opts[:p]) + if response + url = response['html_url'] + message = "Gist created at URL #{url}" + begin + ::Gist.copy(url) + message << ", which is now in the clipboard." + rescue ::Gist::ClipboardError + end + + output.puts message + end + end + end + + Pry::Commands.add_command(Pry::Command::Gist) + Pry::Commands.alias_command 'clipit', 'gist --clip' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/help.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/help.rb new file mode 100644 index 000000000..3f29c2c86 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/help.rb @@ -0,0 +1,164 @@ +class Pry + class Command::Help < Pry::ClassCommand + match 'help' + group 'Help' + description 'Show a list of commands or information about a specific command.' + + banner <<-'BANNER' + Usage: help [COMMAND] + + With no arguments, help lists all the available commands along with their + descriptions. When given a command name as an argument, shows the help + for that command. + BANNER + + # We only want to show commands that have descriptions, so that the + # easter eggs don't show up. + def visible_commands + visible = {} + commands.each do |key, command| + visible[key] = command if command.description && !command.description.empty? + end + visible + end + + # Get a hash of available commands grouped by the "group" name. + def command_groups + visible_commands.values.group_by(&:group) + end + + def process + if args.empty? + display_index(command_groups) + else + display_search(args.first) + end + end + + # Display the index view, with headings and short descriptions per command. + # + # @param [Hash>] groups + def display_index(groups) + help_text = [] + + sorted_group_names(groups).each do |group_name| + commands = sorted_commands(groups[group_name]) + + if commands.any? + help_text << help_text_for_commands(group_name, commands) + end + end + + _pry_.pager.page help_text.join("\n\n") + end + + # Given a group name and an array of commands, + # return the help string for those commands. + # + # @param [String] name The group name. + # @param [Array] commands + # @return [String] The generated help string. + def help_text_for_commands(name, commands) + "#{text.bold(name.capitalize)}\n" << commands.map do |command| + " #{command.options[:listing].to_s.ljust(18)} #{command.description.capitalize}" + end.join("\n") + end + + # @param [Hash] groups + # @return [Array] An array of sorted group names. + def sorted_group_names(groups) + groups.keys.sort_by(&method(:group_sort_key)) + end + + # Sort an array of commands by their `listing` name. + # + # @param [Array] commands The commands to sort + # @return [Array] commands sorted by listing name. + def sorted_commands(commands) + commands.sort_by{ |command| command.options[:listing].to_s } + end + + # Display help for an individual command or group. + # + # @param [String] search The string to search for. + def display_search(search) + if command = command_set.find_command_for_help(search) + display_command(command) + else + display_filtered_search_results(search) + end + end + + # Display help for a searched item, filtered first by group + # and if that fails, filtered by command name. + # + # @param [String] search The string to search for. + def display_filtered_search_results(search) + groups = search_hash(search, command_groups) + + if groups.size > 0 + display_index(groups) + else + display_filtered_commands(search) + end + end + + # Display help for a searched item, filtered by group + # + # @param [String] search The string to search for. + def display_filtered_commands(search) + filtered = search_hash(search, visible_commands) + raise CommandError, "No help found for '#{args.first}'" if filtered.empty? + + if filtered.size == 1 + display_command(filtered.values.first) + else + display_index({"'#{search}' commands" => filtered.values}) + end + end + + # Display help for an individual command. + # + # @param [Pry::Command] command + def display_command(command) + _pry_.pager.page command.new.help + end + + # Find a subset of a hash that matches the user's search term. + # + # If there's an exact match a Hash of one element will be returned, + # otherwise a sub-Hash with every key that matches the search will + # be returned. + # + # @param [String] search the search term + # @param [Hash] hash the hash to search + def search_hash(search, hash) + matching = {} + + hash.each_pair do |key, value| + next unless key.is_a?(String) + if normalize(key) == normalize(search) + return {key => value} + elsif normalize(key).start_with?(normalize(search)) + matching[key] = value + end + end + + matching + end + + # Clean search terms to make it easier to search group names + # + # @param [String] key + # @return [String] + def normalize(key) + key.downcase.gsub(/pry\W+/, '') + end + + def group_sort_key(group_name) + [%w(Help Context Editing Introspection Input_and_output Navigating_pry Gems Basic Commands).index(group_name.gsub(' ', '_')) || 99, group_name] + end + end + + Pry::Commands.add_command(Pry::Command::Help) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/hist.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/hist.rb new file mode 100644 index 000000000..083d3f598 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/hist.rb @@ -0,0 +1,180 @@ +class Pry + class Command::Hist < Pry::ClassCommand + match 'hist' + group 'Editing' + description 'Show and replay Readline history.' + + banner <<-'BANNER' + Usage: hist [--head|--tail] + hist --all + hist --head N + hist --tail N + hist --show START..END + hist --grep PATTERN + hist --clear + hist --replay START..END + hist --save [START..END] FILE + Aliases: history + + Show and replay Readline history. + BANNER + + def options(opt) + opt.on :a, :all, "Display all history" + opt.on :H, :head, "Display the first N items", :optional_argument => true, :as => Integer + opt.on :T, :tail, "Display the last N items", :optional_argument => true, :as => Integer + opt.on :s, :show, "Show the given range of lines", :optional_argument => true, :as => Range + opt.on :G, :grep, "Show lines matching the given pattern", :argument => true, :as => String + opt.on :c, :clear , "Clear the current session's history" + opt.on :r, :replay, "Replay a line or range of lines", :argument => true, :as => Range + opt.on :save, "Save history to a file", :argument => true, :as => Range + opt.on :e, :'exclude-pry', "Exclude Pry commands from the history" + opt.on :n, :'no-numbers', "Omit line numbers" + end + + def process + @history = find_history + + if opts.present?(:show) + @history = @history.between(opts[:show]) + end + + if opts.present?(:grep) + @history = @history.grep(opts[:grep]) + end + + @history = case + when opts.present?(:head) + @history.take_lines(1, opts[:head] || 10) + when opts.present?(:tail) + @history.take_lines(-(opts[:tail] || 10), opts[:tail] || 10) + when opts.present?(:show) + @history.between(opts[:show]) + else + @history + end + + if opts.present?(:'exclude-pry') + @history = @history.select do |loc| + !command_set.valid_command?(loc.line) + end + end + + if opts.present?(:save) + process_save + elsif opts.present?(:clear) + process_clear + elsif opts.present?(:replay) + process_replay + else + process_display + end + end + + private + + def process_display + unless opts.present?(:'no-numbers') + @history = @history.with_line_numbers + end + + _pry_.pager.open do |pager| + @history.print_to_output(pager, true) + end + end + + def process_save + case opts[:save] + when Range + @history = @history.between(opts[:save]) + + unless args.first + raise CommandError, "Must provide a file name." + end + + file_name = File.expand_path(args.first) + when String + file_name = File.expand_path(opts[:save]) + end + + output.puts "Saving history in #{file_name}..." + + File.open(file_name, 'w') { |f| f.write(@history.raw) } + + output.puts "History saved." + end + + def process_clear + Pry.history.clear + output.puts "History cleared." + end + + def process_replay + @history = @history.between(opts[:r]) + replay_sequence = @history.raw + + # If we met follow-up "hist" call, check for the "--replay" option + # presence. If "hist" command is called with other options, proceed + # further. + check_for_juxtaposed_replay(replay_sequence) + + replay_sequence.lines.each do |line| + _pry_.eval line, :generated => true + end + end + + # Checks +replay_sequence+ for the presence of neighboring replay calls. + # @example + # [1] pry(main)> hist --show 46894 + # 46894: hist --replay 46675..46677 + # [2] pry(main)> hist --show 46675..46677 + # 46675: 1+1 + # 46676: a = 100 + # 46677: hist --tail + # [3] pry(main)> hist --replay 46894 + # Error: Replay index 46894 points out to another replay call: `hist -r 46675..46677` + # [4] pry(main)> + # + # @raise [Pry::CommandError] If +replay_sequence+ contains another + # "hist --replay" call + # @param [String] replay_sequence The sequence of commands to be replayed + # (per saltum) + # @return [Boolean] `false` if +replay_sequence+ does not contain another + # "hist --replay" call + def check_for_juxtaposed_replay(replay_sequence) + if replay_sequence =~ /\Ahist(?:ory)?\b/ + # Create *fresh* instance of Options for parsing of "hist" command. + _slop = self.slop + _slop.parse replay_sequence.split(' ')[1..-1] + + if _slop.present?(:r) + replay_sequence = replay_sequence.split("\n").join('; ') + index = opts[:r] + index = index.min if index.min == index.max || index.max.nil? + + raise CommandError, "Replay index #{ index } points out to another replay call: `#{ replay_sequence }`" + end + else + false + end + end + + # Finds history depending on the given switch. + # + # @return [Pry::Code] if it finds `--all` (or `-a`) switch, returns all + # entries in history. Without the switch returns only the entries from the + # current Pry session. + def find_history + h = if opts.present?(:all) + Pry.history.to_a + else + Pry.history.to_a.last(Pry.history.session_line_count) + end + # The last value in history will be the 'hist' command itself. + Pry::Code(h[0..-2]) + end + end + + Pry::Commands.add_command(Pry::Command::Hist) + Pry::Commands.alias_command 'history', 'hist' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/import_set.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/import_set.rb new file mode 100644 index 000000000..568988307 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/import_set.rb @@ -0,0 +1,22 @@ +class Pry + class Command::ImportSet < Pry::ClassCommand + match 'import-set' + group 'Commands' + # TODO: Provide a better description with examples and a general conception + # of this command. + description 'Import a Pry command set.' + + banner <<-'BANNER' + Import a Pry command set. + BANNER + + def process(command_set_name) + raise CommandError, "Provide a command set name" if command_set.nil? + + set = target.eval(arg_string) + _pry_.commands.import set + end + end + + Pry::Commands.add_command(Pry::Command::ImportSet) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/install_command.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/install_command.rb new file mode 100644 index 000000000..acafe7b3d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/install_command.rb @@ -0,0 +1,53 @@ +class Pry + class Command::InstallCommand < Pry::ClassCommand + match 'install-command' + group 'Commands' + description 'Install a disabled command.' + + banner <<-'BANNER' + Usage: install-command COMMAND + + Installs the gems necessary to run the given COMMAND. You will generally not + need to run this unless told to by an error message. + BANNER + + def process(name) + require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller + command = find_command(name) + + unless command + output.puts "Command #{ text.green(name) } is not found" + return + end + + if command_dependencies_met?(command.options) + output.puts "Dependencies for #{ text.green(name) } are met. Nothing to do" + return + end + + output.puts "Attempting to install #{ text.green(name) } command..." + gems_to_install = Array(command.options[:requires_gem]) + + gems_to_install.each do |g| + next if Rubygem.installed?(g) + output.puts "Installing #{ text.green(g) } gem..." + Rubygem.install(g) + end + + gems_to_install.each do |g| + begin + require g + rescue LoadError + fail_msg = "Required gem #{ text.green(g) } installed but not found." + fail_msg += " Aborting command installation\n" + fail_msg += 'Tips: 1. Check your PATH; 2. Run `bundle update`' + raise CommandError, fail_msg + end + end + + output.puts "Installation of #{ text.green(name) } successful! Type `help #{name}` for information" + end + end + + Pry::Commands.add_command(Pry::Command::InstallCommand) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/jump_to.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/jump_to.rb new file mode 100644 index 000000000..4179fc791 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/jump_to.rb @@ -0,0 +1,29 @@ +class Pry + class Command::JumpTo < Pry::ClassCommand + match 'jump-to' + group 'Navigating Pry' + description 'Jump to a binding further up the stack.' + + banner <<-'BANNER' + Jump to a binding further up the stack, popping all bindings below. + BANNER + + def process(break_level) + break_level = break_level.to_i + nesting_level = _pry_.binding_stack.size - 1 + + case break_level + when nesting_level + output.puts "Already at nesting level #{nesting_level}" + when (0...nesting_level) + _pry_.binding_stack.slice!(break_level + 1, _pry_.binding_stack.size) + + else + max_nest_level = nesting_level - 1 + output.puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{break_level}." + end + end + end + + Pry::Commands.add_command(Pry::Command::JumpTo) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_inspectors.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_inspectors.rb new file mode 100644 index 000000000..c96c3951a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_inspectors.rb @@ -0,0 +1,35 @@ +class Pry::Command::ListInspectors < Pry::ClassCommand + match 'list-inspectors' + group 'Input and Output' + description 'List the inspector procs available for use.' + banner <<-BANNER + Usage: list-inspectors + + List the inspector procs available to print return values. You can use + change-inspector to switch between them. + BANNER + + def process + output.puts heading("Available inspectors") + "\n" + inspector_map.each do |name, inspector| + output.write "Name: #{text.bold(name)}" + output.puts selected_inspector?(inspector) ? selected_text : "" + output.puts inspector[:description] + output.puts + end + end + +private + def inspector_map + Pry::Inspector::MAP + end + + def selected_text + text.red " (selected) " + end + + def selected_inspector?(inspector) + _pry_.print == inspector[:value] + end + Pry::Commands.add_command(self) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_prompts.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_prompts.rb new file mode 100644 index 000000000..436f719b6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/list_prompts.rb @@ -0,0 +1,35 @@ +class Pry::Command::ListPrompts < Pry::ClassCommand + match 'list-prompts' + group 'Input and Output' + description 'List the prompts available for use.' + banner <<-BANNER + Usage: list-prompts + + List the available prompts. You can use change-prompt to switch between + them. + BANNER + + def process + output.puts heading("Available prompts") + "\n" + prompt_map.each do |name, prompt| + output.write "Name: #{text.bold(name)}" + output.puts selected_prompt?(prompt) ? selected_text : "" + output.puts prompt[:description] + output.puts + end + end + +private + def prompt_map + Pry::Prompt::MAP + end + + def selected_text + text.red " (selected) " + end + + def selected_prompt?(prompt) + _pry_.prompt == prompt[:value] + end + Pry::Commands.add_command(self) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls.rb new file mode 100644 index 000000000..9f0e68f21 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls.rb @@ -0,0 +1,114 @@ +require 'pry/commands/ls/ls_entity' +class Pry + class Command::Ls < Pry::ClassCommand + DEFAULT_OPTIONS = { + :heading_color => :bright_blue, + :public_method_color => :default, + :private_method_color => :blue, + :protected_method_color => :blue, + :method_missing_color => :bright_red, + :local_var_color => :yellow, + :pry_var_color => :default, # e.g. _, _pry_, _file_ + :instance_var_color => :blue, # e.g. @foo + :class_var_color => :bright_blue, # e.g. @@foo + :global_var_color => :default, # e.g. $CODERAY_DEBUG, $eventmachine_library + :builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID + :pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO + :constant_color => :default, # e.g. VERSION, ARGF + :class_constant_color => :blue, # e.g. Object, Kernel + :exception_constant_color => :magenta, # e.g. Exception, RuntimeError + :unloaded_constant_color => :yellow, # Any constant that is still in .autoload? state + :separator => " ", + :ceiling => [Object, Module, Class] + } + + + match 'ls' + group 'Context' + description 'Show the list of vars and methods in the current scope.' + command_options :shellwords => false, :interpolate => false + + banner <<-'BANNER' + Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object] + ls [-g] [-l] + + ls shows you which methods, constants and variables are accessible to Pry. By + default it shows you the local variables defined in the current shell, and any + public methods or instance variables defined on the current object. + + The colours used are configurable using Pry.config.ls.*_color, and the separator + is Pry.config.ls.separator. + + Pry.config.ls.ceiling is used to hide methods defined higher up in the + inheritance chain, this is by default set to [Object, Module, Class] so that + methods defined on all Objects are omitted. The -v flag can be used to ignore + this setting and show all methods, while the -q can be used to set the ceiling + much lower and show only methods defined on the object or its direct class. + + Also check out `find-method` command (run `help find-method`). + BANNER + + + def options(opt) + opt.on :m, :methods, "Show public methods defined on the Object" + opt.on :M, "instance-methods", "Show public methods defined in a Module or Class" + opt.on :p, :ppp, "Show public, protected (in yellow) and private (in green) methods" + opt.on :q, :quiet, "Show only methods defined on object.singleton_class and object.class" + opt.on :v, :verbose, "Show methods and constants on all super-classes (ignores Pry.config.ls.ceiling)" + opt.on :g, :globals, "Show global variables, including those builtin to Ruby (in cyan)" + opt.on :l, :locals, "Show hash of local vars, sorted by descending size" + opt.on :c, :constants, "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" << + " " * 32 << "Constants that are pending autoload? are also shown (in yellow)" + opt.on :i, :ivars, "Show instance variables (in blue) and class variables (in bright blue)" + opt.on :G, :grep, "Filter output by regular expression", :argument => true + + if jruby? + opt.on :J, "all-java", "Show all the aliases for methods from java (default is to show only prettiest)" + end + end + + # Exclude -q, -v and --grep because they, + # don't specify what the user wants to see. + def no_user_opts? + !(opts[:methods] || opts['instance-methods'] || opts[:ppp] || + opts[:globals] || opts[:locals] || opts[:constants] || opts[:ivars]) + end + + def process + @interrogatee = args.empty? ? target_self : target.eval(args.join(' ')) + raise_errors_if_arguments_are_weird + ls_entity = LsEntity.new({ + :interrogatee => @interrogatee, + :no_user_opts => no_user_opts?, + :opts => opts, + :args => args, + :_pry_ => _pry_ + }) + + _pry_.pager.page ls_entity.entities_table + end + + private + + def error_list + any_args = args.any? + non_mod_interrogatee = !(Module === @interrogatee) + [ + ['-l does not make sense with a specified Object', :locals, any_args], + ['-g does not make sense with a specified Object', :globals, any_args], + ['-q does not make sense with -v', :quiet, opts.present?(:verbose)], + ['-M only makes sense with a Module or a Class', 'instance-methods', non_mod_interrogatee], + ['-c only makes sense with a Module or a Class', :constants, any_args && non_mod_interrogatee] + ] + end + + def raise_errors_if_arguments_are_weird + error_list.each do |message, option, invalid_expr| + raise Pry::CommandError, message if opts.present?(option) && invalid_expr + end + end + + end + + Pry::Commands.add_command(Pry::Command::Ls) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/constants.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/constants.rb new file mode 100644 index 000000000..3db81624b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/constants.rb @@ -0,0 +1,47 @@ +require 'pry/commands/ls/interrogatable' + +class Pry + class Command::Ls < Pry::ClassCommand + class Constants < Pry::Command::Ls::Formatter + include Pry::Command::Ls::Interrogatable + + + def initialize(interrogatee, no_user_opts, opts, _pry_) + super(_pry_) + @interrogatee = interrogatee + @no_user_opts = no_user_opts + @default_switch = opts[:constants] + @verbose_switch = opts[:verbose] + end + + def correct_opts? + super || (@no_user_opts && interrogating_a_module?) + end + + def output_self + mod = interrogatee_mod + constants = WrappedModule.new(mod).constants(@verbose_switch) + output_section('constants', grep.regexp[format(mod, constants)]) + end + + private + + def format(mod, constants) + constants.sort_by(&:downcase).map do |name| + if const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil) + if (const < Exception rescue false) + color(:exception_constant, name) + elsif (Module === mod.const_get(name) rescue false) + color(:class_constant, name) + else + color(:constant, name) + end + else + color(:unloaded_constant, name) + end + end + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/formatter.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/formatter.rb new file mode 100644 index 000000000..9ad117a67 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/formatter.rb @@ -0,0 +1,49 @@ +class Pry + class Command::Ls < Pry::ClassCommand + class Formatter + attr_writer :grep + attr_reader :_pry_ + + def initialize(_pry_) + @_pry_ = _pry_ + @target = _pry_.current_context + end + + def write_out + return false unless correct_opts? + output_self + end + + private + + def color(type, str) + Pry::Helpers::Text.send _pry_.config.ls["#{type}_color"], str + end + + # Add a new section to the output. + # Outputs nothing if the section would be empty. + def output_section(heading, body) + return '' if body.compact.empty? + fancy_heading = Pry::Helpers::Text.bold(color(:heading, heading)) + Pry::Helpers.tablify_or_one_line(fancy_heading, body) + end + + def format_value(value) + Pry::ColorPrinter.pp(value, '') + end + + def correct_opts? + @default_switch + end + + def output_self + raise NotImplementedError + end + + def grep + @grep || proc { |x| x } + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/globals.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/globals.rb new file mode 100644 index 000000000..2b3d0fde3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/globals.rb @@ -0,0 +1,48 @@ +class Pry + class Command::Ls < Pry::ClassCommand + class Globals < Pry::Command::Ls::Formatter + + # Taken from "puts global_variables.inspect". + BUILTIN_GLOBALS = + %w($" $$ $* $, $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w $. $/ $\\ + $: $; $< $= $> $0 $ARGV $CONSOLE $DEBUG $DEFAULT_INPUT $DEFAULT_OUTPUT + $FIELD_SEPARATOR $FILENAME $FS $IGNORECASE $INPUT_LINE_NUMBER + $INPUT_RECORD_SEPARATOR $KCODE $LOADED_FEATURES $LOAD_PATH $NR $OFS + $ORS $OUTPUT_FIELD_SEPARATOR $OUTPUT_RECORD_SEPARATOR $PID $PROCESS_ID + $PROGRAM_NAME $RS $VERBOSE $deferr $defout $stderr $stdin $stdout) + + # `$SAFE` and `$?` are thread-local, the exception stuff only works in a + # rescue clause, everything else is basically a local variable with a `$` + # in its name. + PSEUDO_GLOBALS = + %w($! $' $& $` $@ $? $+ $_ $~ $1 $2 $3 $4 $5 $6 $7 $8 $9 + $CHILD_STATUS $SAFE $ERROR_INFO $ERROR_POSITION $LAST_MATCH_INFO + $LAST_PAREN_MATCH $LAST_READ_LINE $MATCH $POSTMATCH $PREMATCH) + + def initialize(opts, _pry_) + super(_pry_) + @default_switch = opts[:globals] + end + + def output_self + variables = format(@target.eval('global_variables')) + output_section('global variables', grep.regexp[variables]) + end + + private + + def format(globals) + globals.map(&:to_s).sort_by(&:downcase).map do |name| + if PSEUDO_GLOBALS.include?(name) + color(:pseudo_global, name) + elsif BUILTIN_GLOBALS.include?(name) + color(:builtin_global, name) + else + color(:global_var, name) + end + end + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/grep.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/grep.rb new file mode 100644 index 000000000..14e6b00e4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/grep.rb @@ -0,0 +1,21 @@ +class Pry + class Command::Ls < Pry::ClassCommand + class Grep + + def initialize(grep_regexp) + @grep_regexp = grep_regexp + end + + def regexp + proc { |x| + if x.instance_of?(Array) + x.grep(@grep_regexp) + else + x =~ @grep_regexp + end + } + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/instance_vars.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/instance_vars.rb new file mode 100644 index 000000000..2f33677f3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/instance_vars.rb @@ -0,0 +1,39 @@ +require 'pry/commands/ls/interrogatable' + +class Pry + class Command::Ls < Pry::ClassCommand + class InstanceVars < Pry::Command::Ls::Formatter + include Pry::Command::Ls::Interrogatable + + def initialize(interrogatee, no_user_opts, opts, _pry_) + super(_pry_) + @interrogatee = interrogatee + @no_user_opts = no_user_opts + @default_switch = opts[:ivars] + end + + def correct_opts? + super || @no_user_opts + end + + def output_self + ivars = if Object === @interrogatee + Pry::Method.safe_send(@interrogatee, :instance_variables) + else + [] #TODO: BasicObject support + end + kvars = Pry::Method.safe_send(interrogatee_mod, :class_variables) + ivars_out = output_section('instance variables', format(:instance_var, ivars)) + kvars_out = output_section('class variables', format(:class_var, kvars)) + ivars_out + kvars_out + end + + private + + def format(type, vars) + vars.sort_by { |var| var.to_s.downcase }.map { |var| color(type, var) } + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/interrogatable.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/interrogatable.rb new file mode 100644 index 000000000..5904d1b48 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/interrogatable.rb @@ -0,0 +1,18 @@ +module Pry::Command::Ls::Interrogatable + + private + + def interrogating_a_module? + Module === @interrogatee + end + + def interrogatee_mod + if interrogating_a_module? + @interrogatee + else + singleton = Pry::Method.singleton_class_of(@interrogatee) + singleton.ancestors.grep(::Class).reject { |c| c == singleton }.first + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/jruby_hacks.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/jruby_hacks.rb new file mode 100644 index 000000000..0f73e08f0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/jruby_hacks.rb @@ -0,0 +1,49 @@ +module Pry::Command::Ls::JRubyHacks + + private + + # JRuby creates lots of aliases for methods imported from java in an attempt + # to make life easier for ruby programmers. (e.g. getFooBar becomes + # get_foo_bar and foo_bar, and maybe foo_bar? if it returns a Boolean). The + # full transformations are in the assignAliases method of: + # https://github.com/jruby/jruby/blob/master/src/org/jruby/javasupport/JavaClass.java + # + # This has the unfortunate side-effect of making the output of ls even more + # incredibly verbose than it normally would be for these objects; and so we + # filter out all but the nicest of these aliases here. + # + # TODO: This is a little bit vague, better heuristics could be used. + # JRuby also has a lot of scala-specific logic, which we don't copy. + def trim_jruby_aliases(methods) + grouped = methods.group_by do |m| + m.name.sub(/\A(is|get|set)(?=[A-Z_])/, '').gsub(/[_?=]/, '').downcase + end + + grouped.map do |key, values| + values = values.sort_by do |m| + rubbishness(m.name) + end + + found = [] + values.select do |x| + (!found.any? { |y| x == y }) && found << x + end + end.flatten(1) + end + + # When removing jruby aliases, we want to keep the alias that is + # "least rubbish" according to this metric. + def rubbishness(name) + name.each_char.map { |x| + case x + when /[A-Z]/ + 1 + when '?', '=', '!' + -2 + else + 0 + end + }.inject(&:+) + (name.size / 100.0) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_names.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_names.rb new file mode 100644 index 000000000..9d6350b5c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_names.rb @@ -0,0 +1,35 @@ +class Pry + class Command::Ls < Pry::ClassCommand + class LocalNames < Pry::Command::Ls::Formatter + + def initialize(no_user_opts, args, _pry_) + super(_pry_) + @no_user_opts = no_user_opts + @args = args + @sticky_locals = _pry_.sticky_locals + end + + def correct_opts? + super || (@no_user_opts && @args.empty?) + end + + def output_self + local_vars = grep.regexp[@target.eval('local_variables')] + output_section('locals', format(local_vars)) + end + + private + + def format(locals) + locals.sort_by(&:downcase).map do |name| + if @sticky_locals.include?(name.to_sym) + color(:pry_var, name) + else + color(:local_var, name) + end + end + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_vars.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_vars.rb new file mode 100644 index 000000000..d48ddae72 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/local_vars.rb @@ -0,0 +1,39 @@ +class Pry + class Command::Ls < Pry::ClassCommand + class LocalVars < Pry::Command::Ls::Formatter + + def initialize(opts, _pry_) + super(_pry_) + @default_switch = opts[:locals] + @sticky_locals = _pry_.sticky_locals + end + + def output_self + name_value_pairs = @target.eval('local_variables').reject { |e| + @sticky_locals.keys.include?(e.to_sym) + }.map { |name| + [name, (@target.eval(name.to_s))] + } + format(name_value_pairs).join('') + end + + private + + def format(name_value_pairs) + name_value_pairs.sort_by { |name, value| + value.to_s.size + }.reverse.map { |name, value| + colorized_assignment_style(name, format_value(value)) + } + end + + def colorized_assignment_style(lhs, rhs, desired_width = 7) + colorized_lhs = color(:local_var, lhs) + color_escape_padding = colorized_lhs.size - lhs.size + pad = desired_width + color_escape_padding + "%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs] + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/ls_entity.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/ls_entity.rb new file mode 100644 index 000000000..3d69bcdda --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/ls_entity.rb @@ -0,0 +1,70 @@ +require 'pry/commands/ls/grep' +require 'pry/commands/ls/formatter' +require 'pry/commands/ls/globals' +require 'pry/commands/ls/constants' +require 'pry/commands/ls/methods' +require 'pry/commands/ls/self_methods' +require 'pry/commands/ls/instance_vars' +require 'pry/commands/ls/local_names' +require 'pry/commands/ls/local_vars' + +class Pry + class Command::Ls < Pry::ClassCommand + + class LsEntity + attr_reader :_pry_ + + def initialize(opts) + @interrogatee = opts[:interrogatee] + @no_user_opts = opts[:no_user_opts] + @opts = opts[:opts] + @args = opts[:args] + @grep = Grep.new(Regexp.new(opts[:opts][:G] || '.')) + @_pry_ = opts.delete(:_pry_) + end + + def entities_table + entities.map(&:write_out).reject { |o| !o }.join('') + end + + private + + def grep(entity) + entity.tap { |o| o.grep = @grep } + end + + def globals + grep Globals.new(@opts, _pry_) + end + + def constants + grep Constants.new(@interrogatee, @no_user_opts, @opts, _pry_) + end + + def methods + grep(Methods.new(@interrogatee, @no_user_opts, @opts, _pry_)) + end + + def self_methods + grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, _pry_) + end + + def instance_vars + grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, _pry_) + end + + def local_names + grep LocalNames.new(@no_user_opts, @args, _pry_) + end + + def local_vars + LocalVars.new(@opts, _pry_) + end + + def entities + [globals, constants, methods, self_methods, instance_vars, local_names, + local_vars] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods.rb new file mode 100644 index 000000000..c085f421f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods.rb @@ -0,0 +1,57 @@ +require 'pry/commands/ls/methods_helper' +require 'pry/commands/ls/interrogatable' + +class Pry + class Command::Ls < Pry::ClassCommand + class Methods < Pry::Command::Ls::Formatter + + include Pry::Command::Ls::Interrogatable + include Pry::Command::Ls::MethodsHelper + + def initialize(interrogatee, no_user_opts, opts, _pry_) + super(_pry_) + @interrogatee = interrogatee + @no_user_opts = no_user_opts + @default_switch = opts[:methods] + @instance_methods_switch = opts['instance-methods'] + @ppp_switch = opts[:ppp] + @jruby_switch = opts['all-java'] + @quiet_switch = opts[:quiet] + @verbose_switch = opts[:verbose] + end + + def output_self + methods = all_methods.group_by(&:owner) + # Reverse the resolution order so that the most useful information + # appears right by the prompt. + resolution_order.take_while(&below_ceiling).reverse.map do |klass| + methods_here = (methods[klass] || []).select { |m| grep.regexp[m.name] } + heading = "#{ Pry::WrappedModule.new(klass).method_prefix }methods" + output_section(heading, format(methods_here)) + end.join('') + end + + private + + def correct_opts? + super || @instance_methods_switch || @ppp_switch || @no_user_opts + end + + + # Get a lambda that can be used with `take_while` to prevent over-eager + # traversal of the Object's ancestry graph. + def below_ceiling + ceiling = if @quiet_switch + [Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] + + _pry_.config.ls.ceiling + elsif @verbose_switch + [] + else + _pry_.config.ls.ceiling.dup + end + lambda { |klass| !ceiling.include?(klass) } + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods_helper.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods_helper.rb new file mode 100644 index 000000000..f0b4414d0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/methods_helper.rb @@ -0,0 +1,46 @@ +require 'pry/commands/ls/jruby_hacks' + +module Pry::Command::Ls::MethodsHelper + + include Pry::Command::Ls::JRubyHacks + + private + + # Get all the methods that we'll want to output. + def all_methods(instance_methods = false) + methods = if instance_methods || @instance_methods_switch + Pry::Method.all_from_class(@interrogatee) + else + Pry::Method.all_from_obj(@interrogatee) + end + + if Pry::Helpers::BaseHelpers.jruby? && !@jruby_switch + methods = trim_jruby_aliases(methods) + end + + methods.select { |method| @ppp_switch || method.visibility == :public } + end + + def resolution_order + if @instance_methods_switch + Pry::Method.instance_resolution_order(@interrogatee) + else + Pry::Method.resolution_order(@interrogatee) + end + end + + def format(methods) + methods.sort_by(&:name).map do |method| + if method.name == 'method_missing' + color(:method_missing, 'method_missing') + elsif method.visibility == :private + color(:private_method, method.name) + elsif method.visibility == :protected + color(:protected_method, method.name) + else + color(:public_method, method.name) + end + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/self_methods.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/self_methods.rb new file mode 100644 index 000000000..91f3490b5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ls/self_methods.rb @@ -0,0 +1,32 @@ +require 'pry/commands/ls/interrogatable' +require 'pry/commands/ls/methods_helper' + +class Pry + class Command::Ls < Pry::ClassCommand + class SelfMethods < Pry::Command::Ls::Formatter + include Pry::Command::Ls::Interrogatable + include Pry::Command::Ls::MethodsHelper + + def initialize(interrogatee, no_user_opts, opts, _pry_) + super(_pry_) + @interrogatee = interrogatee + @no_user_opts = no_user_opts + end + + def output_self + methods = all_methods(true).select do |m| + m.owner == @interrogatee && grep.regexp[m.name] + end + heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods" + output_section(heading, format(methods)) + end + + private + + def correct_opts? + @no_user_opts && interrogating_a_module? + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/nesting.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/nesting.rb new file mode 100644 index 000000000..f9c0297c8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/nesting.rb @@ -0,0 +1,25 @@ +class Pry + class Command::Nesting < Pry::ClassCommand + match 'nesting' + group 'Navigating Pry' + description 'Show nesting information.' + + banner <<-'BANNER' + Show nesting information. + BANNER + + def process + output.puts 'Nesting status:' + output.puts '--' + _pry_.binding_stack.each_with_index do |obj, level| + if level == 0 + output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)" + else + output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}" + end + end + end + end + + Pry::Commands.add_command(Pry::Command::Nesting) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/play.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/play.rb new file mode 100644 index 000000000..5498d38d5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/play.rb @@ -0,0 +1,103 @@ +class Pry + class Command::Play < Pry::ClassCommand + match 'play' + group 'Editing' + description 'Playback a string variable, method, line, or file as input.' + + banner <<-'BANNER' + Usage: play [OPTIONS] [--help] + + The play command enables you to replay code from files and methods as if they + were entered directly in the Pry REPL. + + play --lines 149..153 # assumes current context + play -i 20 --lines 1..3 # assumes lines of the input expression at 20 + play -o 4 # the output of of an expression at 4 + play Pry#repl -l 1..-1 # play the contents of Pry#repl method + play -e 2 # play from specified line until end of valid expression + play hello.rb # play a file + play Rakefile -l 5 # play line 5 of a file + play -d hi # play documentation of hi method + play hi --open # play hi method and leave it open + + https://github.com/pry/pry/wiki/User-Input#wiki-Play + BANNER + + def options(opt) + CodeCollector.inject_options(opt) + + opt.on :open, 'Plays the selected content except the last line. Useful' \ + ' for replaying methods and leaving the method definition' \ + ' "open". `amend-line` can then be used to' \ + ' modify the method.' + + opt.on :e, :expression=, 'Executes until end of valid expression', :as => Integer + opt.on :p, :print, 'Prints executed code' + end + + def process + @cc = CodeCollector.new(args, opts, _pry_) + + perform_play + show_input + end + + def perform_play + eval_string << content_after_options + run "fix-indent" + end + + def show_input + if opts.present?(:print) or !Pry::Code.complete_expression?(eval_string) + run "show-input" + end + end + + + def content_after_options + if opts.present?(:open) + restrict_to_lines(content, (0..-2)) + elsif opts.present?(:expression) + content_at_expression + else + content + end + end + + def content_at_expression + code_object.expression_at(opts[:expression]) + end + + def code_object + Pry::Code.new(content) + end + + def should_use_default_file? + !args.first && !opts.present?(:in) && !opts.present?(:out) + end + + def content + if should_use_default_file? + file_content + else + @cc.content + end + end + + # The file to play from when no code object is specified. + # e.g `play --lines 4..10` + def default_file + target.eval("__FILE__") && File.expand_path(target.eval("__FILE__")) + end + + def file_content + if default_file && File.exists?(default_file) + @cc.restrict_to_lines(File.read(default_file), @cc.line_range) + else + raise CommandError, "File does not exist! File was: #{default_file.inspect}" + end + end + end + + Pry::Commands.add_command(Pry::Command::Play) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_backtrace.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_backtrace.rb new file mode 100644 index 000000000..6795aa32c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_backtrace.rb @@ -0,0 +1,25 @@ +class Pry + class Command::PryBacktrace < Pry::ClassCommand + match 'pry-backtrace' + group 'Context' + description 'Show the backtrace for the Pry session.' + + banner <<-BANNER + Usage: pry-backtrace [OPTIONS] [--help] + + Show the backtrace for the position in the code where Pry was started. This can + be used to infer the behavior of the program immediately before it entered Pry, + just like the backtrace property of an exception. + + NOTE: if you are looking for the backtrace of the most recent exception raised, + just type: `_ex_.backtrace` instead. + See: https://github.com/pry/pry/wiki/Special-Locals + BANNER + + def process + _pry_.pager.page text.bold('Backtrace:') << "\n--\n" << _pry_.backtrace.join("\n") + end + end + + Pry::Commands.add_command(Pry::Command::PryBacktrace) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_version.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_version.rb new file mode 100644 index 000000000..8cb8fd857 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/pry_version.rb @@ -0,0 +1,17 @@ +class Pry + class Command::Version < Pry::ClassCommand + match 'pry-version' + group 'Misc' + description 'Show Pry version.' + + banner <<-'BANNER' + Show Pry version. + BANNER + + def process + output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}." + end + end + + Pry::Commands.add_command(Pry::Command::Version) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/raise_up.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/raise_up.rb new file mode 100644 index 000000000..70ad0872b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/raise_up.rb @@ -0,0 +1,32 @@ +class Pry + # N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing. + class Command::RaiseUp < Pry::ClassCommand + match(/raise-up(!?\b.*)/) + group 'Context' + description 'Raise an exception out of the current pry instance.' + command_options :listing => 'raise-up' + + banner <<-BANNER + Raise up, like exit, allows you to quit pry. Instead of returning a value + however, it raises an exception. If you don't provide the exception to be + raised, it will use the most recent exception (in pry `_ex_`). + + When called as raise-up! (with an exclamation mark), this command raises the + exception through any nested prys you have created by "cd"ing into objects. + + raise-up "get-me-out-of-here" + + # This is equivalent to the command above. + raise "get-me-out-of-here" + raise-up + BANNER + + def process + return _pry.pager.page help if captures[0] =~ /(-h|--help)\b/ + # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner + target.eval("_pry_.raise_up#{captures[0]}") + end + end + + Pry::Commands.add_command(Pry::Command::RaiseUp) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reload_code.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reload_code.rb new file mode 100644 index 000000000..704133862 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reload_code.rb @@ -0,0 +1,62 @@ +class Pry + class Command::ReloadCode < Pry::ClassCommand + match 'reload-code' + group 'Misc' + description 'Reload the source file that contains the specified code object.' + + banner <<-'BANNER' + Reload the source file that contains the specified code object. + + e.g reload-code MyClass#my_method #=> reload a method + reload-code MyClass #=> reload a class + reload-code my-command #=> reload a pry command + reload-code self #=> reload the current object + reload-code #=> reload the current file or object + BANNER + + def process + if !args.empty? + reload_object(args.join(" ")) + elsif internal_binding?(target) + reload_object("self") + else + reload_current_file + end + end + + private + + def current_file + File.expand_path target.eval("__FILE__") + end + + def reload_current_file + if !File.exists?(current_file) + raise CommandError, "Current file: #{current_file} cannot be found on disk!" + end + + load current_file + output.puts "The current file: #{current_file} was reloaded!" + end + + def reload_object(identifier) + code_object = Pry::CodeObject.lookup(identifier, _pry_) + check_for_reloadability(code_object, identifier) + load code_object.source_file + output.puts "#{identifier} was reloaded!" + end + + def check_for_reloadability(code_object, identifier) + if !code_object || !code_object.source_file + raise CommandError, "Cannot locate #{identifier}!" + elsif !File.exists?(code_object.source_file) + raise CommandError, + "Cannot reload #{identifier} as it has no associated file on disk. " \ + "File found was: #{code_object.source_file}" + end + end + end + + Pry::Commands.add_command(Pry::Command::ReloadCode) + Pry::Commands.alias_command 'reload-method', 'reload-code' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reset.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reset.rb new file mode 100644 index 000000000..4414cbb54 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/reset.rb @@ -0,0 +1,18 @@ +class Pry + class Command::Reset < Pry::ClassCommand + match 'reset' + group 'Context' + description 'Reset the REPL to a clean state.' + + banner <<-'BANNER' + Reset the REPL to a clean state. + BANNER + + def process + output.puts 'Pry reset.' + exec 'pry' + end + end + + Pry::Commands.add_command(Pry::Command::Reset) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ri.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ri.rb new file mode 100644 index 000000000..d29c426df --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/ri.rb @@ -0,0 +1,60 @@ +class Pry + class Command::Ri < Pry::ClassCommand + match 'ri' + group 'Introspection' + description 'View ri documentation.' + + banner <<-'BANNER' + Usage: ri [spec] + + View ri documentation. Relies on the "rdoc" gem being installed. + See also "show-doc" command. + + ri Array#each + BANNER + + def process(spec) + # Lazily load RI + require 'rdoc/ri/driver' + + unless defined? RDoc::RI::PryDriver + + # Subclass RI so that it formats its output nicely, and uses `lesspipe`. + subclass = Class.new(RDoc::RI::Driver) # the hard way. + + subclass.class_eval do + def initialize(pager, opts) + @pager = pager + super opts + end + def page + paging_text = StringIO.new + yield paging_text + @pager.page(paging_text.string) + end + + def formatter(io) + if @formatter_klass + @formatter_klass.new + else + RDoc::Markup::ToAnsi.new + end + end + end + + RDoc::RI.const_set :PryDriver, subclass # hook it up! + end + + # Spin-up an RI insance. + ri = RDoc::RI::PryDriver.new _pry_.pager, :use_stdout => true, :interactive => false + + begin + ri.display_names [spec] # Get the documentation (finally!) + rescue RDoc::RI::Driver::NotFoundError => e + output.puts "error: '#{e.name}' not found" + end + end + end + + Pry::Commands.add_command(Pry::Command::Ri) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/save_file.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/save_file.rb new file mode 100644 index 000000000..d22a69243 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/save_file.rb @@ -0,0 +1,61 @@ +require 'pry/commands/code_collector' + +class Pry + class Command::SaveFile < Pry::ClassCommand + match 'save-file' + group 'Input and Output' + description 'Export to a file using content from the REPL.' + + banner <<-'BANNER' + Usage: save-file [OPTIONS] --to [FILE] + + Export to a file using content from the REPL. + + save-file my_method --to hello.rb + save-file -i 1..10 --to hello.rb --append + save-file show-method --to my_command.rb + save-file sample_file.rb --lines 2..10 --to output_file.rb + BANNER + + def options(opt) + CodeCollector.inject_options(opt) + + opt.on :to=, "Specify the output file path" + opt.on :a, :append, "Append output to file" + end + + def process + @cc = CodeCollector.new(args, opts, _pry_) + raise CommandError, "Found no code to save." if @cc.content.empty? + + if !file_name + display_content + else + save_file + end + end + + def file_name + opts[:to] || nil + end + + def save_file + File.open(file_name, mode) do |f| + f.puts @cc.content + end + output.puts "#{file_name} successfully saved" + end + + def display_content + output.puts @cc.content + output.puts "\n\n--\nPlease use `--to FILE` to export to a file." + output.puts "No file saved!\n--" + end + + def mode + opts.present?(:append) ? "a" : "w" + end + end + + Pry::Commands.add_command(Pry::Command::SaveFile) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_command.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_command.rb new file mode 100644 index 000000000..78fccd53c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_command.rb @@ -0,0 +1,48 @@ +class Pry + class Command::ShellCommand < Pry::ClassCommand + match(/\.(.*)/) + group 'Input and Output' + description "All text following a '.' is forwarded to the shell." + command_options :listing => '.', :use_prefix => false, + :takes_block => true + + banner <<-'BANNER' + Usage: .COMMAND_NAME + + All text following a "." is forwarded to the shell. + + .ls -aF + .uname + BANNER + + def process(cmd) + if cmd =~ /^cd\s*(.*)/i + process_cd parse_destination($1) + else + pass_block(cmd) + if command_block + command_block.call `#{cmd}` + else + _pry_.config.system.call(output, cmd, _pry_) + end + end + end + + private + + def parse_destination(dest) + return "~" if dest.empty? + return dest unless dest == "-" + state.old_pwd || raise(CommandError, "No prior directory available") + end + + def process_cd(dest) + state.old_pwd = Dir.pwd + Dir.chdir File.expand_path(dest) + rescue Errno::ENOENT + raise CommandError, "No such directory: #{dest}" + end + end + + Pry::Commands.add_command(Pry::Command::ShellCommand) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_mode.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_mode.rb new file mode 100644 index 000000000..ee521d3b0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/shell_mode.rb @@ -0,0 +1,25 @@ +class Pry + class Command::ShellMode < Pry::ClassCommand + match 'shell-mode' + group 'Input and Output' + description 'Toggle shell mode. Bring in pwd prompt and file completion.' + + banner <<-'BANNER' + Toggle shell mode. Bring in pwd prompt and file completion. + BANNER + + def process + case _pry_.prompt + when Pry::SHELL_PROMPT + _pry_.pop_prompt + _pry_.custom_completions = _pry_.config.file_completions + else + _pry_.push_prompt Pry::SHELL_PROMPT + _pry_.custom_completions = _pry_.config.command_completions + end + end + end + + Pry::Commands.add_command(Pry::Command::ShellMode) + Pry::Commands.alias_command 'file-mode', 'shell-mode' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_doc.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_doc.rb new file mode 100644 index 000000000..4969bcdc7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_doc.rb @@ -0,0 +1,83 @@ +require 'pry/commands/show_info' + +class Pry + class Command::ShowDoc < Command::ShowInfo + include Pry::Helpers::DocumentationHelpers + + match 'show-doc' + group 'Introspection' + description 'Show the documentation for a method or class.' + + banner <<-BANNER + Usage: show-doc [OPTIONS] [METH] + Aliases: ? + + Show the documentation for a method or class. Tries instance methods first and + then methods by default. + + show-doc hi_method # docs for hi_method + show-doc Pry # for Pry class + show-doc Pry -a # for all definitions of Pry class (all monkey patches) + BANNER + + # The docs for code_object prepared for display. + def content_for(code_object) + Code.new(render_doc_markup_for(code_object), + start_line_for(code_object), :text). + with_line_numbers(use_line_numbers?).to_s + end + + # process the markup (if necessary) and apply colors + def render_doc_markup_for(code_object) + docs = docs_for(code_object) + + if code_object.command? + # command '--help' shouldn't use markup highlighting + docs + else + if docs.empty? + raise CommandError, "No docs found for: #{ + obj_name ? obj_name : 'current context' + }" + end + process_comment_markup(docs) + end + end + + # Return docs for the code_object, adjusting for whether the code_object + # has yard docs available, in which case it returns those. + # (note we only have to check yard docs for modules since they can + # have multiple docs, but methods can only be doc'd once so we + # dont need to check them) + def docs_for(code_object) + if code_object.module_with_yard_docs? + # yard docs + code_object.yard_doc + else + # normal docs (i.e comments above method/module/command) + code_object.doc + end + end + + # Which sections to include in the 'header', can toggle: :owner, + # :signature and visibility. + def header_options + super.merge :signature => true + end + + # figure out start line of docs by back-calculating based on + # number of lines in the comment and the start line of the code_object + # @return [Fixnum] start line of docs + def start_line_for(code_object) + if code_object.command? || opts.present?(:'base-one') + 1 + else + code_object.source_line.nil? ? 1 : + (code_object.source_line - code_object.doc.lines.count) + end + end + end + + Pry::Commands.add_command(Pry::Command::ShowDoc) + Pry::Commands.alias_command '?', 'show-doc' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_info.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_info.rb new file mode 100644 index 000000000..92958cb43 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_info.rb @@ -0,0 +1,195 @@ +class Pry + class Command::ShowInfo < Pry::ClassCommand + extend Pry::Helpers::BaseHelpers + + command_options :shellwords => false, :interpolate => false + + def options(opt) + opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", :as => :count + opt.on :l, "line-numbers", "Show line numbers" + opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)" + opt.on :a, :all, "Show all definitions and monkeypatches of the module/class" + end + + def process + code_object = Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super]) + raise CommandError, no_definition_message if !code_object + @original_code_object = code_object + + if show_all_modules?(code_object) + # show all monkey patches for a module + + result = content_and_headers_for_all_module_candidates(code_object) + else + # show a specific code object + co = code_object_with_accessible_source(code_object) + result = content_and_header_for_code_object(co) + end + + set_file_and_dir_locals(code_object.source_file) + _pry_.pager.page result + end + + # This method checks whether the `code_object` is a WrappedModule, + # if it is, then it returns the first candidate (monkeypatch) with + # accessible source (or docs). If `code_object` is not a WrappedModule (i.e a + # method or a command) then the `code_object` itself is just + # returned. + # + # @return [Pry::WrappedModule, Pry::Method, Pry::Command] + def code_object_with_accessible_source(code_object) + if code_object.is_a?(WrappedModule) + candidate = code_object.candidates.find(&:source) + if candidate + return candidate + else + raise CommandError, no_definition_message if !valid_superclass?(code_object) + + @used_super = true + code_object_with_accessible_source(code_object.super) + end + else + code_object + end + end + + def valid_superclass?(code_object) + code_object.super && code_object.super.wrapped != Object + end + + def content_and_header_for_code_object(code_object) + header(code_object) << content_for(code_object) + end + + def content_and_headers_for_all_module_candidates(mod) + result = "Found #{mod.number_of_candidates} candidates for `#{mod.name}` definition:\n" + mod.number_of_candidates.times do |v| + candidate = mod.candidate(v) + begin + result << "\nCandidate #{v+1}/#{mod.number_of_candidates}: #{candidate.source_file} @ line #{candidate.source_line}:\n" + content = content_for(candidate) + + result << "Number of lines: #{content.lines.count}\n\n" << content + rescue Pry::RescuableException + result << "\nNo content found.\n" + next + end + end + result + end + + def no_definition_message + "Couldn't locate a definition for #{obj_name}!" + end + + # Generate a header (meta-data information) for all the code + # object types: methods, modules, commands, procs... + def header(code_object) + file_name, line_num = file_and_line_for(code_object) + h = "\n#{Pry::Helpers::Text.bold('From:')} #{file_name} " + h << code_object_header(code_object, line_num) + h << "\n#{Pry::Helpers::Text.bold('Number of lines:')} " << + "#{content_for(code_object).lines.count}\n\n" + h << Helpers::Text.bold('** Warning:') << " Cannot find code for #{@original_code_object.nonblank_name}. Showing superclass #{code_object.nonblank_name} instead. **\n\n" if @used_super + h + end + + def code_object_header(code_object, line_num) + if code_object.real_method_object? + method_header(code_object, line_num) + + # It sucks we have to test for both Pry::WrappedModule and WrappedModule::Candidate, + # probably indicates a deep refactor needs to happen in those classes. + elsif code_object.is_a?(Pry::WrappedModule) || code_object.is_a?(Pry::WrappedModule::Candidate) + module_header(code_object, line_num) + else + "" + end + end + + def method_header(code_object, line_num) + h = "" + h << (code_object.c_method? ? "(C Method):" : "@ line #{line_num}:") + h << method_sections(code_object)[:owner] + h << method_sections(code_object)[:visibility] + h << method_sections(code_object)[:signature] + h + end + + def module_header(code_object, line_num) + h = "" + h << "@ line #{line_num}:\n" + h << text.bold(code_object.module? ? "Module" : "Class") + h << " #{text.bold('name:')} #{code_object.nonblank_name}" + + if code_object.number_of_candidates > 1 + h << (text.bold("\nNumber of monkeypatches: ") << code_object.number_of_candidates.to_s) + h << ". Use the `-a` option to display all available monkeypatches" + end + h + end + + def method_sections(code_object) + { + :owner => "\n#{text.bold("Owner:")} #{code_object.owner || "N/A"}\n", + :visibility => "#{text.bold("Visibility:")} #{code_object.visibility}", + :signature => "\n#{text.bold("Signature:")} #{code_object.signature}" + }.merge(header_options) { |key, old, new| (new && old).to_s } + end + + def header_options + { + :owner => true, + :visibility => true, + :signature => nil + } + end + + def show_all_modules?(code_object) + code_object.is_a?(Pry::WrappedModule) && opts.present?(:all) + end + + def obj_name + @obj_name ||= args.empty? ? nil : args.join(' ') + end + + def use_line_numbers? + opts.present?(:b) || opts.present?(:l) + end + + def start_line_for(code_object) + if opts.present?(:'base-one') + 1 + else + code_object.source_line || 1 + end + end + + # takes into account possible yard docs, and returns yard_file / yard_line + # Also adjusts for start line of comments (using start_line_for), which it has to infer + # by subtracting number of lines of comment from start line of code_object + def file_and_line_for(code_object) + if code_object.module_with_yard_docs? + [code_object.yard_file, code_object.yard_line] + else + [code_object.source_file, start_line_for(code_object)] + end + end + + def complete(input) + if input =~ /([^ ]*)#([a-z0-9_]*)\z/ + prefix, search = [$1, $2] + methods = begin + Pry::Method.all_from_class(binding.eval(prefix)) + rescue RescuableException + return super + end + methods.map do |method| + [prefix, method.name].join('#') if method.name.start_with?(search) + end.compact + else + super + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_input.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_input.rb new file mode 100644 index 000000000..8b7278770 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_input.rb @@ -0,0 +1,17 @@ +class Pry + class Command::ShowInput < Pry::ClassCommand + match 'show-input' + group 'Editing' + description 'Show the contents of the input buffer for the current multi-line expression.' + + banner <<-'BANNER' + Show the contents of the input buffer for the current multi-line expression. + BANNER + + def process + output.puts Code.new(eval_string).with_line_numbers + end + end + + Pry::Commands.add_command(Pry::Command::ShowInput) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_source.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_source.rb new file mode 100644 index 000000000..f8e3a5b0c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/show_source.rb @@ -0,0 +1,50 @@ +require 'pry/commands/show_info' + +class Pry + class Command::ShowSource < Command::ShowInfo + match 'show-source' + group 'Introspection' + description 'Show the source for a method or class.' + + banner <<-'BANNER' + Usage: show-source [OPTIONS] [METH|CLASS] + Aliases: $, show-method + + Show the source for a method or class. Tries instance methods first and then + methods by default. + + show-source hi_method + show-source hi_method + show-source Pry#rep # source for Pry#rep method + show-source Pry # for Pry class + show-source Pry -a # for all Pry class definitions (all monkey patches) + show-source Pry.foo -e # for class of the return value of expression `Pry.foo` + show-source Pry --super # for superclass of Pry (Object class) + + https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method + BANNER + + def options(opt) + opt.on :e, :eval, "evaluate the command's argument as a ruby expression and show the class its return value" + super(opt) + end + + def process + if opts.present?(:e) + obj = target.eval(args.first) + self.args = Array.new(1) { Module === obj ? obj.name : obj.class.name } + end + super + end + + # The source for code_object prepared for display. + def content_for(code_object) + Code.new(code_object.source, start_line_for(code_object)). + with_line_numbers(use_line_numbers?).highlighted + end + end + + Pry::Commands.add_command(Pry::Command::ShowSource) + Pry::Commands.alias_command 'show-method', 'show-source' + Pry::Commands.alias_command '$', 'show-source' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/simple_prompt.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/simple_prompt.rb new file mode 100644 index 000000000..4d1e6eca3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/simple_prompt.rb @@ -0,0 +1,22 @@ +class Pry + class Command::SimplePrompt < Pry::ClassCommand + match 'simple-prompt' + group 'prompts' + description 'Toggle the simple prompt.' + + banner <<-'BANNER' + Toggle the simple prompt. + BANNER + + def process + case _pry_.prompt + when Pry::SIMPLE_PROMPT + _pry_.pop_prompt + else + _pry_.push_prompt Pry::SIMPLE_PROMPT + end + end + end + + Pry::Commands.add_command(Pry::Command::SimplePrompt) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/stat.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/stat.rb new file mode 100644 index 000000000..06a191b57 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/stat.rb @@ -0,0 +1,40 @@ +class Pry + class Command::Stat < Pry::ClassCommand + match 'stat' + group 'Introspection' + description 'View method information and set _file_ and _dir_ locals.' + command_options :shellwords => false + + banner <<-'BANNER' + Usage: stat [OPTIONS] [METH] + + Show method information for method METH and set _file_ and _dir_ locals. + + stat hello_method + BANNER + + def options(opt) + method_options(opt) + end + + def process + meth = method_object + aliases = meth.aliases + + output.puts unindent <<-EOS + Method Information: + -- + Name: #{meth.name} + Alias#{ "es" if aliases.length > 1 }: #{ aliases.any? ? aliases.join(", ") : "None." } + Owner: #{meth.owner ? meth.owner : "Unknown"} + Visibility: #{meth.visibility} + Type: #{meth.is_a?(::Method) ? "Bound" : "Unbound"} + Arity: #{meth.arity} + Method Signature: #{meth.signature} + Source Location: #{meth.source_location ? meth.source_location.join(":") : "Not found."} + EOS + end + end + + Pry::Commands.add_command(Pry::Command::Stat) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/switch_to.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/switch_to.rb new file mode 100644 index 000000000..ad3e71c1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/switch_to.rb @@ -0,0 +1,23 @@ +class Pry + class Command::SwitchTo < Pry::ClassCommand + match 'switch-to' + group 'Navigating Pry' + description 'Start a new subsession on a binding in the current stack.' + + banner <<-'BANNER' + Start a new subsession on a binding in the current stack (numbered by nesting). + BANNER + + def process(selection) + selection = selection.to_i + + if selection < 0 || selection > _pry_.binding_stack.size - 1 + raise CommandError, "Invalid binding index #{selection} - use `nesting` command to view valid indices." + else + Pry.start(_pry_.binding_stack[selection]) + end + end + end + + Pry::Commands.add_command(Pry::Command::SwitchTo) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/toggle_color.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/toggle_color.rb new file mode 100644 index 000000000..602c293d6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/toggle_color.rb @@ -0,0 +1,24 @@ +class Pry + class Command::ToggleColor < Pry::ClassCommand + match 'toggle-color' + group 'Misc' + description 'Toggle syntax highlighting.' + + banner <<-'BANNER' + Usage: toggle-color + + Toggle syntax highlighting. + BANNER + + def process + _pry_.color = color_toggle + output.puts "Syntax highlighting #{_pry_.color ? "on" : "off"}" + end + + def color_toggle + !_pry_.color + end + + Pry::Commands.add_command(self) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression.rb new file mode 100644 index 000000000..d93b7c725 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression.rb @@ -0,0 +1,105 @@ +class Pry + class Command::WatchExpression < Pry::ClassCommand + require 'pry/commands/watch_expression/expression.rb' + + match 'watch' + group 'Context' + description 'Watch the value of an expression and print a notification whenever it changes.' + command_options :use_prefix => false + + banner <<-'BANNER' + Usage: watch [EXPRESSION] + watch + watch --delete [INDEX] + + watch [EXPRESSION] adds an expression to the list of those being watched. + It will be re-evaluated every time you hit enter in pry. If its value has + changed, the new value will be printed to the console. + + This is useful if you are step-through debugging and want to see how + something changes over time. It's also useful if you're trying to write + a method inside pry and want to check that it gives the right answers + every time you redefine it. + + watch on its own displays all the currently watched expressions and their + values, and watch --delete [INDEX] allows you to delete expressions from + the list being watched. + BANNER + + def options(opt) + opt.on :d, :delete, + "Delete the watch expression with the given index. If no index is given; clear all watch expressions.", + :optional_argument => true, :as => Integer + opt.on :l, :list, + "Show all current watch expressions and their values. Calling watch with no expressions or options will also show the watch expressions." + end + + def process + case + when opts.present?(:delete) + delete opts[:delete] + when opts.present?(:list) || args.empty? + list + else + add_hook + add_expression(args) + end + end + + private + + def expressions + _pry_.config.watch_expressions ||= [] + end + + def delete(index) + if index + output.puts "Deleting watch expression ##{index}: #{expressions[index-1]}" + expressions.delete_at(index-1) + else + output.puts "Deleting all watched expressions" + expressions.clear + end + end + + def list + if expressions.empty? + output.puts "No watched expressions" + else + _pry_.pager.open do |pager| + pager.puts "Listing all watched expressions:" + pager.puts "" + expressions.each_with_index do |expr, index| + pager.print text.with_line_numbers(expr.to_s, index+1) + end + pager.puts "" + end + end + end + + def eval_and_print_changed(output) + expressions.each do |expr| + expr.eval! + if expr.changed? + output.puts "#{text.blue "watch"}: #{expr.to_s}" + end + end + end + + def add_expression(arguments) + expressions << Expression.new(_pry_, target, arg_string) + output.puts "Watching #{Code.new(arg_string).highlighted}" + end + + def add_hook + hook = [:after_eval, :watch_expression] + unless _pry_.hooks.hook_exists?(*hook) + _pry_.hooks.add_hook(*hook) do |_, _pry_| + eval_and_print_changed _pry_.output + end + end + end + end + + Pry::Commands.add_command(Pry::Command::WatchExpression) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression/expression.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression/expression.rb new file mode 100644 index 000000000..514b95dd1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/watch_expression/expression.rb @@ -0,0 +1,38 @@ +class Pry + class Command::WatchExpression + class Expression + attr_reader :target, :source, :value, :previous_value, :_pry_ + + def initialize(_pry_, target, source) + @_pry_ = _pry_ + @target = target + @source = Code.new(source).strip + end + + def eval! + @previous_value = @value + @value = Pry::ColorPrinter.pp(target_eval(target, source), "") + end + + def to_s + "#{Code.new(source).highlighted.strip} => #{value}" + end + + # Has the value of the expression changed? + # + # We use the pretty-printed string represenation to detect differences + # as this avoids problems with dup (causes too many differences) and == (causes too few) + def changed? + (value != previous_value) + end + + private + + def target_eval(target, source) + target.eval(source) + rescue => e + e + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/whereami.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/whereami.rb new file mode 100644 index 000000000..ac701645b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/whereami.rb @@ -0,0 +1,190 @@ +class Pry + class Command::Whereami < Pry::ClassCommand + + class << self + attr_accessor :method_size_cutoff + end + + @method_size_cutoff = 30 + + match 'whereami' + description 'Show code surrounding the current context.' + group 'Context' + + banner <<-'BANNER' + Usage: whereami [-qn] [LINES] + + Describe the current location. If you use `binding.pry` inside a method then + whereami will print out the source for that method. + + If a number is passed, then LINES lines before and after the current line will be + shown instead of the method itself. + + The `-q` flag can be used to suppress error messages in the case that there's + no code to show. This is used by pry in the default before_session hook to show + you when you arrive at a `binding.pry`. + + The `-n` flag can be used to hide line numbers so that code can be copy/pasted + effectively. + + When pry was started on an Object and there is no associated method, whereami + will instead output a brief description of the current object. + BANNER + + def setup + @file = expand_path(target.eval('__FILE__')) + @line = target.eval('__LINE__') + @method = Pry::Method.from_binding(target) + end + + def options(opt) + opt.on :q, :quiet, "Don't display anything in case of an error" + opt.on :n, :"no-line-numbers", "Do not display line numbers" + opt.on :m, :"method", "Show the complete source for the current method." + opt.on :c, :"class", "Show the complete source for the current class or module." + opt.on :f, :"file", "Show the complete source for the current file." + end + + def code + @code ||= if opts.present?(:m) + method_code or raise CommandError, "Cannot find method code." + elsif opts.present?(:c) + class_code or raise CommandError, "Cannot find class code." + elsif opts.present?(:f) + Pry::Code.from_file(@file) + elsif args.any? + code_window + else + default_code + end + end + + def code? + !!code + rescue MethodSource::SourceNotFoundError + false + end + + def bad_option_combination? + [opts.present?(:m), opts.present?(:f), + opts.present?(:c), args.any?].count(true) > 1 + end + + def location + "#{@file} @ line #{@line} #{@method && @method.name_with_owner}" + end + + def process + if bad_option_combination? + raise CommandError, "Only one of -m, -c, -f, and LINES may be specified." + end + + if nothing_to_do? + return + elsif internal_binding?(target) + handle_internal_binding + return + end + + set_file_and_dir_locals(@file) + + out = "\n#{text.bold('From:')} #{location}:\n\n" << + code.with_line_numbers(use_line_numbers?).with_marker(marker).highlighted << "\n" + + _pry_.pager.page out + end + + private + + def nothing_to_do? + opts.quiet? && (internal_binding?(target) || !code?) + end + + def use_line_numbers? + !opts.present?(:n) + end + + def marker + !opts.present?(:n) && @line + end + + def top_level? + target_self == Pry.main + end + + def handle_internal_binding + if top_level? + output.puts "At the top level." + else + output.puts "Inside #{Pry.view_clip(target_self)}." + end + end + + def small_method? + @method.source_range.count < self.class.method_size_cutoff + end + + def default_code + if method_code && small_method? + method_code + else + code_window + end + end + + def code_window + Pry::Code.from_file(@file).around(@line, window_size) + end + + def method_code + return @method_code if @method_code + + if valid_method? + @method_code = Pry::Code.from_method(@method) + end + end + + # This either returns the `target_self` + # or it returns the class of `target_self` if `target_self` is not a class. + # @return [Pry::WrappedModule] + def target_class + target_self.is_a?(Module) ? Pry::WrappedModule(target_self) : + Pry::WrappedModule(target_self.class) + end + + def class_code + return @class_code if @class_code + + mod = @method ? Pry::WrappedModule(@method.owner) : target_class + + idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file } + @class_code = idx && Pry::Code.from_module(mod, idx) + end + + def valid_method? + @method && @method.source? && expand_path(@method.source_file) == @file && + @method.source_range.include?(@line) + end + + def expand_path(f) + return if !f + + if Pry.eval_path == f + f + else + File.expand_path(f) + end + end + + def window_size + if args.empty? + _pry_.config.default_window_size + else + args.first.to_i + end + end + end + + Pry::Commands.add_command(Pry::Command::Whereami) + Pry::Commands.alias_command '@', 'whereami' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/wtf.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/wtf.rb new file mode 100644 index 000000000..2d47dfac2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/commands/wtf.rb @@ -0,0 +1,57 @@ +class Pry + class Command::Wtf < Pry::ClassCommand + match(/wtf([?!]*)/) + group 'Context' + description 'Show the backtrace of the most recent exception.' + options :listing => 'wtf?' + + banner <<-'BANNER' + Usage: wtf[?|!] + + Show's a few lines of the backtrace of the most recent exception (also available + as `_ex_.backtrace`). If you want to see more lines, add more question marks or + exclamation marks. + + wtf? + wtf?!???!?!? + + # To see the entire backtrace, pass the `-v` or `--verbose` flag. + wtf -v + BANNER + + def options(opt) + opt.on :v, :verbose, "Show the full backtrace" + end + + def process + raise Pry::CommandError, "No most-recent exception" unless exception + + output.puts "#{text.bold('Exception:')} #{exception.class}: #{exception}\n--" + if opts.verbose? + output.puts with_line_numbers(backtrace) + else + output.puts with_line_numbers(backtrace.first(size_of_backtrace)) + end + end + + private + + def exception + _pry_.last_exception + end + + def with_line_numbers(bt) + Pry::Code.new(bt, 0, :text).with_line_numbers.to_s + end + + def backtrace + exception.backtrace + end + + def size_of_backtrace + [captures[0].size, 0.5].max * 10 + end + end + + Pry::Commands.add_command(Pry::Command::Wtf) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config.rb new file mode 100644 index 000000000..73b7742e2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config.rb @@ -0,0 +1,24 @@ +class Pry::Config + require_relative 'config/behavior' + require_relative 'config/default' + require_relative 'config/convenience' + include Pry::Config::Behavior + + def self.shortcuts + Convenience::SHORTCUTS + end + + # + # FIXME + # @param [Pry::Hooks] hooks + # + def hooks=(hooks) + if hooks.is_a?(Hash) + warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \ + "instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks" + self["hooks"] = Pry::Hooks.from_hash(hooks) + else + self["hooks"] = hooks + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/behavior.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/behavior.rb new file mode 100644 index 000000000..d2669ddee --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/behavior.rb @@ -0,0 +1,139 @@ +module Pry::Config::Behavior + ASSIGNMENT = "=".freeze + NODUP = [TrueClass, FalseClass, NilClass, Symbol, Numeric, Module, Proc].freeze + INSPECT_REGEXP = /#{Regexp.escape "default=#<"}/ + + module Builder + def from_hash(hash, default = nil) + new(default).tap do |config| + config.merge!(hash) + end + end + end + + def self.included(klass) + unless defined?(RESERVED_KEYS) + const_set :RESERVED_KEYS, instance_methods(false).map(&:to_s).freeze + end + klass.extend(Builder) + end + + def initialize(default = Pry.config) + @default = default + @lookup = {} + end + + # + # @return [Pry::Config::Behavior] + # returns the default used if a matching value for a key isn't found in self + # + def default + @default + end + + def [](key) + @lookup[key.to_s] + end + + def []=(key, value) + key = key.to_s + if RESERVED_KEYS.include?(key) + raise ArgumentError, "few things are reserved by pry, but using '#{key}' as a configuration key is." + end + @lookup[key] = value + end + + def method_missing(name, *args, &block) + key = name.to_s + if key[-1] == ASSIGNMENT + short_key = key[0..-2] + self[short_key] = args[0] + elsif key?(key) + self[key] + elsif @default.respond_to?(name) + value = @default.public_send(name, *args, &block) + # FIXME: refactor Pry::Hook so that it stores config on the config object, + # so that we can use the normal strategy. + self[key] = value = value.dup if key == 'hooks' + value + else + nil + end + end + + def merge!(other) + other = try_convert_to_hash(other) + raise TypeError, "unable to convert argument into a Hash" unless other + other.each do |key, value| + self[key] = value + end + end + + def ==(other) + @lookup == try_convert_to_hash(other) + end + alias_method :eql?, :== + + def respond_to_missing?(key, include_private=false) + key?(key) or @default.respond_to?(key) or super(key, include_private) + end + + def key?(key) + key = key.to_s + @lookup.key?(key) + end + + def clear + @lookup.clear + true + end + alias_method :refresh, :clear + + def forget(key) + @lookup.delete(key.to_s) + end + + def keys + @lookup.keys + end + + def to_hash + @lookup.dup + end + alias_method :to_h, :to_hash + + + def inspect + key_str = keys.map { |key| "'#{key}'" }.join(",") + "#<#{_clip_inspect(self)} local_keys=[#{key_str}] default=#{@default.inspect}>" + end + + def pretty_print(q) + q.text inspect[1..-1].gsub(INSPECT_REGEXP, "default=<") + end + +private + def _clip_inspect(obj) + "#{obj.class}:0x%x" % obj.object_id << 1 + end + + def _dup(value) + if NODUP.any? { |klass| klass === value } + value + else + value.dup + end + end + + def try_convert_to_hash(obj) + if Hash === obj + obj + elsif obj.respond_to?(:to_h) + obj.to_h + elsif obj.respond_to?(:to_hash) + obj.to_hash + else + nil + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/convenience.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/convenience.rb new file mode 100644 index 000000000..ddd39f492 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/convenience.rb @@ -0,0 +1,25 @@ +module Pry::Config::Convenience + SHORTCUTS = [ + :input, + :output, + :commands, + :print, + :exception_handler, + :hooks, + :color, + :pager, + :editor, + :memory_size, + :extra_sticky_locals + ] + + + def config_shortcut(*names) + names.each do |name| + reader = name + setter = "#{name}=" + define_method(reader) { config.public_send(name) } + define_method(setter) { |value| config.public_send(setter, value) } + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/default.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/default.rb new file mode 100644 index 000000000..db4d8aac1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/config/default.rb @@ -0,0 +1,161 @@ +class Pry::Config::Default + include Pry::Config::Behavior + + default = { + input: proc { + lazy_readline + }, + output: proc { + $stdout + }, + commands: proc { + Pry::Commands + }, + prompt_name: proc { + Pry::DEFAULT_PROMPT_NAME + }, + prompt: proc { + Pry::DEFAULT_PROMPT + }, + prompt_safe_objects: proc { + Pry::DEFAULT_PROMPT_SAFE_OBJECTS + }, + print: proc { + Pry::DEFAULT_PRINT + }, + quiet: proc { + false + }, + exception_handler: proc { + Pry::DEFAULT_EXCEPTION_HANDLER + }, + exception_whitelist: proc { + Pry::DEFAULT_EXCEPTION_WHITELIST + }, + hooks: proc { + Pry::DEFAULT_HOOKS + }, + pager: proc { + true + }, + system: proc { + Pry::DEFAULT_SYSTEM + }, + color: proc { + Pry::Helpers::BaseHelpers.use_ansi_codes? + }, + default_window_size: proc { + 5 + }, + editor: proc { + Pry.default_editor_for_platform + }, # TODO: Pry::Platform.editor + should_load_rc: proc { + true + }, + should_load_local_rc: proc { + true + }, + should_trap_interrupts: proc { + Pry::Helpers::BaseHelpers.jruby? + }, # TODO: Pry::Platform.jruby? + disable_auto_reload: proc { + false + }, + command_prefix: proc { + "" + }, + auto_indent: proc { + Pry::Helpers::BaseHelpers.use_ansi_codes? + }, + correct_indent: proc { + true + }, + collision_warning: proc { + false + }, + output_prefix: proc { + "=> " + }, + requires: proc { + [] + }, + should_load_requires: proc { + true + }, + should_load_plugins: proc { + true + }, + windows_console_warning: proc { + true + }, + control_d_handler: proc { + Pry::DEFAULT_CONTROL_D_HANDLER + }, + memory_size: proc { + 100 + }, + extra_sticky_locals: proc { + {} + }, + command_completions: proc { + proc { commands.keys } + }, + file_completions: proc { + proc { Dir["."] } + }, + ls: proc { + Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS) + }, + completer: proc { + require "pry/input_completer" + Pry::InputCompleter + } + } + + def initialize + super(nil) + configure_gist + configure_history + end + + default.each do |key, value| + define_method(key) do + if default[key].equal?(value) + default[key] = instance_eval(&value) + end + default[key] + end + end + +private + # TODO: + # all of this configure_* stuff is a relic of old code. + # we should try move this code to being command-local. + def configure_gist + self["gist"] = Pry::Config.from_hash(inspecter: proc(&:pretty_inspect)) + end + + def configure_history + self["history"] = Pry::Config.from_hash "should_save" => true, + "should_load" => true + history.file = File.expand_path("~/.pry_history") rescue nil + if history.file.nil? + self.should_load_rc = false + history.should_save = false + history.should_load = false + end + end + + def lazy_readline + require 'readline' + Readline + rescue LoadError + warn "Sorry, you can't use Pry without Readline or a compatible library." + warn "Possible solutions:" + warn " * Rebuild Ruby with Readline support using `--with-readline`" + warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline" + warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline" + raise + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/core_extensions.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/core_extensions.rb new file mode 100644 index 000000000..a418daf3b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/core_extensions.rb @@ -0,0 +1,131 @@ +class Pry + # @return [Array] Code of the method used when implementing Pry's + # __binding__, along with line indication to be used with instance_eval (and + # friends). + # + # @see Object#__binding__ + BINDING_METHOD_IMPL = [<<-METHOD, __FILE__, __LINE__ + 1] + # Get a binding with 'self' set to self, and no locals. + # + # The default definee is determined by the context in which the + # definition is eval'd. + # + # Please don't call this method directly, see {__binding__}. + # + # @return [Binding] + def __pry__ + binding + end + METHOD +end + +class Object + # Start a Pry REPL on self. + # + # If `self` is a Binding then that will be used to evaluate expressions; + # otherwise a new binding will be created. + # + # @param [Object] object the object or binding to pry + # (__deprecated__, use `object.pry`) + # @param [Hash] hash the options hash + # @example With a binding + # binding.pry + # @example On any object + # "dummy".pry + # @example With options + # def my_method + # binding.pry :quiet => true + # end + # my_method() + # @see Pry.start + def pry(object=nil, hash={}) + if object.nil? || Hash === object + Pry.start(self, object || {}) + else + Pry.start(object, hash) + end + end + + # Return a binding object for the receiver. + # + # The `self` of the binding is set to the current object, and it contains no + # local variables. + # + # The default definee (http://yugui.jp/articles/846) is set such that: + # + # * If `self` is a class or module, then new methods created in the binding + # will be defined in that class or module (as in `class Foo; end`). + # * If `self` is a normal object, then new methods created in the binding will + # be defined on its singleton class (as in `class << self; end`). + # * If `self` doesn't have a real singleton class (i.e. it is a Fixnum, Float, + # Symbol, nil, true, or false), then new methods will be created on the + # object's class (as in `self.class.class_eval{ }`) + # + # Newly created constants, including classes and modules, will also be added + # to the default definee. + # + # @return [Binding] + def __binding__ + # If you ever feel like changing this method, be careful about variables + # that you use. They shouldn't be inserted into the binding that will + # eventually be returning. + + # When you're cd'd into a class, methods you define should be added to it. + if is_a?(Module) + # class_eval sets both self and the default definee to this class. + return class_eval "binding" + end + + unless respond_to?(:__pry__) + # The easiest way to check whether an object has a working singleton class + # is to try and define a method on it. (just checking for the presence of + # the singleton class gives false positives for `true` and `false`). + # __pry__ is just the closest method we have to hand, and using + # it has the nice property that we can memoize this check. + begin + # instance_eval sets the default definee to the object's singleton class + instance_eval(*Pry::BINDING_METHOD_IMPL) + + # If we can't define methods on the Object's singleton_class. Then we fall + # back to setting the default definee to be the Object's class. That seems + # nicer than having a REPL in which you can't define methods. + rescue TypeError, Pry::FrozenObjectException + # class_eval sets the default definee to self.class + self.class.class_eval(*Pry::BINDING_METHOD_IMPL) + end + end + + __pry__ + end +end + +class BasicObject + # Return a binding object for the receiver. + # + # The `self` of the binding is set to the current object, and it contains no + # local variables. + # + # The default definee (http://yugui.jp/articles/846) is set such that new + # methods defined will be added to the singleton class of the BasicObject. + # + # @return [Binding] + def __binding__ + # BasicObjects don't have respond_to?, so we just define the method + # every time. As they also don't have `.freeze`, this call won't + # fail as it can for normal Objects. + (class << self; self; end).class_eval <<-EOF, __FILE__, __LINE__ + 1 + # Get a binding with 'self' set to self, and no locals. + # + # The default definee is determined by the context in which the + # definition is eval'd. + # + # Please don't call this method directly, see {__binding__}. + # + # @return [Binding] + def __pry__ + ::Kernel.binding + end + EOF + self.__pry__ + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/editor.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/editor.rb new file mode 100644 index 000000000..43e649f1f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/editor.rb @@ -0,0 +1,135 @@ +class Pry + class Editor + include Pry::Helpers::BaseHelpers + include Pry::Helpers::CommandHelpers + + attr_reader :_pry_ + + def initialize(_pry_) + @_pry_ = _pry_ + end + + def edit_tempfile_with_content(initial_content, line=1) + temp_file do |f| + f.puts(initial_content) + f.flush + f.close(false) + invoke_editor(f.path, line, true) + File.read(f.path) + end + end + + def invoke_editor(file, line, blocking=true) + raise CommandError, "Please set Pry.config.editor or export $VISUAL or $EDITOR" unless _pry_.config.editor + + editor_invocation = build_editor_invocation_string(file, line, blocking) + return nil unless editor_invocation + + if jruby? + open_editor_on_jruby(editor_invocation) + else + open_editor(editor_invocation) + end + end + + private + + # Generate the string that's used to start the editor. This includes + # all the flags we want as well as the file and line number we + # want to open at. + def build_editor_invocation_string(file, line, blocking) + + if _pry_.config.editor.respond_to?(:call) + args = [file, line, blocking][0...(_pry_.config.editor.arity)] + _pry_.config.editor.call(*args) + else + sanitized_file = if windows? + file.gsub(/\//, '\\') + else + Shellwords.escape(file) + end + + "#{_pry_.config.editor} #{blocking_flag_for_editor(blocking)} #{start_line_syntax_for_editor(sanitized_file, line)}" + end + end + + # Start the editor running, using the calculated invocation string + def open_editor(editor_invocation) + # Note we dont want to use Pry.config.system here as that + # may be invoked non-interactively (i.e via Open4), whereas we want to + # ensure the editor is always interactive + system(*Shellwords.split(editor_invocation)) or raise CommandError, "`#{editor_invocation}` gave exit status: #{$?.exitstatus}" + end + + # We need JRuby specific code here cos just shelling out using + # system() appears to be pretty broken :/ + def open_editor_on_jruby(editor_invocation) + begin + require 'spoon' + pid = Spoon.spawnp(*Shellwords.split(editor_invocation)) + Process.waitpid(pid) + rescue FFI::NotFoundError + system(editor_invocation) + end + end + + # Some editors that run outside the terminal allow you to control whether or + # not to block the process from which they were launched (in this case, Pry). + # For those editors, return the flag that produces the desired behavior. + def blocking_flag_for_editor(blocking) + case editor_name + when /^emacsclient/ + '--no-wait' unless blocking + when /^[gm]vim/ + '--nofork' if blocking + when /^jedit/ + '-wait' if blocking + when /^mate/, /^subl/, /^redcar/ + '-w' if blocking + end + end + + # Return the syntax for a given editor for starting the editor + # and moving to a particular line within that file + def start_line_syntax_for_editor(file_name, line_number) + # special case for 1st line + return file_name if line_number <= 1 + + case editor_name + when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/ + "+#{line_number} #{file_name}" + when /^mate/, /^geany/ + "-l #{line_number} #{file_name}" + when /^subl/ + "#{file_name}:#{line_number}" + when /^uedit32/ + "#{file_name}/#{line_number}" + when /^jedit/ + "#{file_name} +line:#{line_number}" + when /^redcar/ + "-l#{line_number} #{file_name}" + else + if windows? + "#{file_name}" + else + "+#{line_number} #{file_name}" + end + end + end + + # Get the name of the binary that Pry.config.editor points to. + # + # This is useful for deciding which flags we pass to the editor as + # we can just use the program's name and ignore any absolute paths. + # + # @example + # Pry.config.editor="/home/conrad/bin/textmate -w" + # editor_name + # # => textmate + # + def editor_name + File.basename(_pry_.config.editor).split(" ").first + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/exceptions.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/exceptions.rb new file mode 100644 index 000000000..0204d8407 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/exceptions.rb @@ -0,0 +1,77 @@ +class Pry + + # As a REPL, we often want to catch any unexpected exceptions that may have + # been raised; however we don't want to go overboard and prevent the user + # from exiting Pry when they want to. + module RescuableException + def self.===(exception) + case exception + # Catch when the user hits ^C (Interrupt < SignalException), and assume + # that they just wanted to stop the in-progress command (just like bash + # etc.) + when Interrupt + true + # Don't catch signals (particularly not SIGTERM) as these are unlikely + # to be intended for pry itself. We should also make sure that + # Kernel#exit works. + when *Pry.config.exception_whitelist + false + # All other exceptions will be caught. + else + true + end + end + end + + # Catches SecurityErrors if $SAFE is set + module Pry::TooSafeException + def self.===(exception) + $SAFE > 0 && SecurityError === exception + end + end + + # An Exception Tag (cf. Exceptional Ruby) that instructs Pry to show the error + # in a more user-friendly manner. This should be used when the exception + # happens within Pry itself as a direct consequence of the user typing + # something wrong. + # + # This allows us to distinguish between the user typing: + # + # pry(main)> def ) + # SyntaxError: unexpected ) + # + # pry(main)> method_that_evals("def )") + # SyntaxError: (eval):1: syntax error, unexpected ')' + # from ./a.rb:2 in `eval' + module UserError; end + + # When we try to get a binding for an object, we try to define a method on + # that Object's singleton class. This doesn't work for "frozen" Object's, and + # the exception is just a vanilla RuntimeError. + module FrozenObjectException + def self.===(exception) + ["can't modify frozen class/module", + "can't modify frozen Class", + ].include?(exception.message) + end + end + + # Don't catch these exceptions + DEFAULT_EXCEPTION_WHITELIST = [SystemExit, + SignalException, + Pry::TooSafeException] + + # CommandErrors are caught by the REPL loop and displayed to the user. They + # indicate an exceptional condition that's fatal to the current command. + class CommandError < StandardError; end + class MethodNotFound < CommandError; end + + # indicates obsolete API + class ObsoleteError < StandardError; end + + # This is to keep from breaking under Rails 3.2 for people who are doing that + # IRB = Pry thing. + module ExtendCommandBundle + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers.rb new file mode 100644 index 000000000..f59c3080e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers.rb @@ -0,0 +1,5 @@ +require "pry/helpers/base_helpers" +require "pry/helpers/options_helpers" +require "pry/helpers/command_helpers" +require "pry/helpers/text" +require "pry/helpers/table" diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/base_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/base_helpers.rb new file mode 100644 index 000000000..5dade4604 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/base_helpers.rb @@ -0,0 +1,113 @@ +class Pry + module Helpers + + module BaseHelpers + + module_function + + def silence_warnings + old_verbose = $VERBOSE + $VERBOSE = nil + begin + yield + ensure + $VERBOSE = old_verbose + end + end + + # Acts like send but ignores any methods defined below Object or Class in the + # inheritance hierarchy. + # This is required to introspect methods on objects like Net::HTTP::Get that + # have overridden the `method` method. + def safe_send(obj, method, *args, &block) + (Module === obj ? Module : Object).instance_method(method).bind(obj).call(*args, &block) + end + public :safe_send + + def find_command(name, set = Pry::Commands) + command_match = set.find do |_, command| + (listing = command.options[:listing]) == name && listing != nil + end + command_match.last if command_match + end + + def not_a_real_file?(file) + file =~ /(\(.*\))|<.*>/ || file =~ /__unknown__/ || file == "" || file == "-e" + end + + def command_dependencies_met?(options) + return true if !options[:requires_gem] + Array(options[:requires_gem]).all? do |g| + Rubygem.installed?(g) + end + end + + def use_ansi_codes? + windows_ansi? || ENV['TERM'] && ENV['TERM'] != "dumb" + end + + def colorize_code(code) + CodeRay.scan(code, :ruby).term + end + + def highlight(string, regexp, highlight_color=:bright_yellow) + string.gsub(regexp) { |match| "<#{highlight_color}>#{match}" } + end + + # formatting + def heading(text) + text = "#{text}\n--" + "\e[1m#{text}\e[0m" + end + + # have fun on the Windows platform. + def windows? + RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + end + + # are we able to use ansi on windows? + def windows_ansi? + defined?(Win32::Console) || ENV['ANSICON'] || (windows? && mri_2?) + end + + def jruby? + RbConfig::CONFIG['ruby_install_name'] == 'jruby' + end + + def jruby_19? + jruby? && RbConfig::CONFIG['ruby_version'] == '1.9' + end + + def rbx? + RbConfig::CONFIG['ruby_install_name'] == 'rbx' + end + + def mri? + RbConfig::CONFIG['ruby_install_name'] == 'ruby' + end + + def mri_19? + mri? && RUBY_VERSION =~ /^1\.9/ + end + + def mri_2? + mri? && RUBY_VERSION =~ /^2/ + end + + def mri_20? + mri? && RUBY_VERSION =~ /^2\.0/ + end + + def mri_21? + mri? && RUBY_VERSION =~ /^2\.1/ + end + + # Send the given text through the best available pager (if Pry.config.pager is + # enabled). Infers where to send the output if used as a mixin. + # DEPRECATED. + def stagger_output(text, out = nil) + Pry.new.pager.page text + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/command_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/command_helpers.rb new file mode 100644 index 000000000..7f7e2261e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/command_helpers.rb @@ -0,0 +1,156 @@ +class Pry + module Helpers + + module CommandHelpers + include OptionsHelpers + + module_function + + # Open a temp file and yield it to the block, closing it after + # @return [String] The path of the temp file + def temp_file(ext='.rb') + file = Tempfile.new(['pry', ext]) + yield file + ensure + file.close(true) if file + end + + def internal_binding?(target) + m = target.eval("::Kernel.__method__").to_s + # class_eval is here because of http://jira.codehaus.org/browse/JRUBY-6753 + ["__binding__", "__pry__", "class_eval"].include?(m) + end + + def get_method_or_raise(name, target, opts={}, omit_help=false) + meth = Pry::Method.from_str(name, target, opts) + + if name && !meth + command_error("The method '#{name}' could not be found.", omit_help, MethodNotFound) + end + + (opts[:super] || 0).times do + if meth.super + meth = meth.super + else + command_error("'#{meth.name_with_owner}' has no super method.", omit_help, MethodNotFound) + end + end + + if !meth || (!name && internal_binding?(target)) + command_error("No method name given, and context is not a method.", omit_help, MethodNotFound) + end + + set_file_and_dir_locals(meth.source_file) + meth + end + + def command_error(message, omit_help, klass=CommandError) + message += " Type `#{command_name} --help` for help." unless omit_help + raise klass, message + end + + # Remove any common leading whitespace from every line in `text`. + # + # This can be used to make a HEREDOC line up with the left margin, without + # sacrificing the indentation level of the source code. + # + # e.g. + # opt.banner unindent <<-USAGE + # Lorem ipsum dolor sit amet, consectetur adipisicing elit, + # sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + # "Ut enim ad minim veniam." + # USAGE + # + # Heavily based on textwrap.dedent from Python, which is: + # Copyright (C) 1999-2001 Gregory P. Ward. + # Copyright (C) 2002, 2003 Python Software Foundation. + # Written by Greg Ward + # + # Licensed under + # From + # + # @param [String] text The text from which to remove indentation + # @return [String] The text with indentation stripped. + def unindent(text, left_padding = 0) + # Empty blank lines + text = text.sub(/^[ \t]+$/, '') + + # Find the longest common whitespace to all indented lines + # Ignore lines containing just -- or ++ as these seem to be used by + # comment authors as delimeters. + margin = text.scan(/^[ \t]*(?!--\n|\+\+\n)(?=[^ \t\n])/).inject do |current_margin, next_indent| + if next_indent.start_with?(current_margin) + current_margin + elsif current_margin.start_with?(next_indent) + next_indent + else + "" + end + end + + text.gsub(/^#{margin}/, ' ' * left_padding) + end + + # Restrict a string to the given range of lines (1-indexed) + # @param [String] content The string. + # @param [Range, Fixnum] lines The line(s) to restrict it to. + # @return [String] The resulting string. + def restrict_to_lines(content, lines) + line_range = one_index_range_or_number(lines) + Array(content.lines.to_a[line_range]).join + end + + def one_index_number(line_number) + if line_number > 0 + line_number - 1 + else + line_number + end + end + + # convert a 1-index range to a 0-indexed one + def one_index_range(range) + Range.new(one_index_number(range.begin), one_index_number(range.end)) + end + + def one_index_range_or_number(range_or_number) + case range_or_number + when Range + one_index_range(range_or_number) + else + one_index_number(range_or_number) + end + end + + def absolute_index_number(line_number, array_length) + if line_number >= 0 + line_number + else + [array_length + line_number, 0].max + end + end + + def absolute_index_range(range_or_number, array_length) + case range_or_number + when Range + a = absolute_index_number(range_or_number.begin, array_length) + b = absolute_index_number(range_or_number.end, array_length) + else + a = b = absolute_index_number(range_or_number, array_length) + end + + Range.new(a, b) + end + + def set_file_and_dir_locals(file_name, _pry_=_pry_(), target=target()) + return if !target or !file_name + _pry_.last_file = File.expand_path(file_name) + _pry_.inject_local("_file_", _pry_.last_file, target) + + _pry_.last_dir = File.dirname(_pry_.last_file) + _pry_.inject_local("_dir_", _pry_.last_dir, target) + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/documentation_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/documentation_helpers.rb new file mode 100644 index 000000000..9f9870e88 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/documentation_helpers.rb @@ -0,0 +1,75 @@ +class Pry + module Helpers + + # This class contains methods useful for extracting + # documentation from methods and classes. + module DocumentationHelpers + + module_function + + def process_rdoc(comment) + comment = comment.dup + comment.gsub(/(?:\s*\n)?(.*?)\s*<\/code>/m) { CodeRay.scan($1, :ruby).term }. + gsub(/(?:\s*\n)?(.*?)\s*<\/em>/m) { "\e[1m#{$1}\e[0m" }. + gsub(/(?:\s*\n)?(.*?)\s*<\/i>/m) { "\e[1m#{$1}\e[0m" }. + gsub(/\B\+(\w+?)\+\B/) { "\e[32m#{$1}\e[0m" }. + gsub(/((?:^[ \t]+.+(?:\n+|\Z))+)/) { CodeRay.scan($1, :ruby).term }. + gsub(/`(?:\s*\n)?([^\e]*?)\s*`/) { "`#{CodeRay.scan($1, :ruby).term}`" } + end + + def process_yardoc_tag(comment, tag) + in_tag_block = nil + comment.lines.map do |v| + if in_tag_block && v !~ /^\S/ + Pry::Helpers::Text.strip_color Pry::Helpers::Text.strip_color(v) + elsif in_tag_block + in_tag_block = false + v + else + in_tag_block = true if v =~ /^@#{tag}/ + v + end + end.join + end + + def process_yardoc(comment) + yard_tags = ["param", "return", "option", "yield", "attr", "attr_reader", "attr_writer", + "deprecate", "example", "raise"] + (yard_tags - ["example"]).inject(comment) { |a, v| process_yardoc_tag(a, v) }. + gsub(/^@(#{yard_tags.join("|")})/) { "\e[33m#{$1}\e[0m" } + end + + def process_comment_markup(comment) + process_yardoc process_rdoc(comment) + end + + # @param [String] code + # @return [String] + def strip_comments_from_c_code(code) + code.sub(/\A\s*\/\*.*?\*\/\s*/m, '') + end + + # Given a string that makes up a comment in a source-code file parse out the content + # that the user is intended to read. (i.e. without leading indentation, #-characters + # or shebangs) + # + # @param [String] comment + # @return [String] + def get_comment_content(comment) + comment = comment.dup + # Remove #!/usr/bin/ruby + comment.gsub!(/\A\#!.*$/, '') + # Remove leading empty comment lines + comment.gsub!(/\A\#+?$/, '') + comment.gsub!(/^\s*#/, '') + strip_leading_whitespace(comment) + end + + # @param [String] text + # @return [String] + def strip_leading_whitespace(text) + Pry::Helpers::CommandHelpers.unindent(text) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/options_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/options_helpers.rb new file mode 100644 index 000000000..e566d3bcf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/options_helpers.rb @@ -0,0 +1,27 @@ +class Pry + module Helpers + module OptionsHelpers + module_function + + # Add method options to the Slop instance + def method_options(opt) + @method_target = target + opt.on :M, "instance-methods", "Operate on instance methods." + opt.on :m, :methods, "Operate on methods." + opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors.", :as => :count + opt.on :c, :context, "Select object context to run under.", :argument => true do |context| + @method_target = Pry.binding_for(target.eval(context)) + end + end + + # Get the method object parsed by the slop instance + def method_object + @method_object ||= get_method_or_raise(args.empty? ? nil : args.join(" "), @method_target, + :super => opts[:super], + :instance => opts.present?(:'instance-methods') && !opts.present?(:'methods'), + :methods => opts.present?(:'methods') && !opts.present?(:'instance-methods') + ) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/table.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/table.rb new file mode 100644 index 000000000..56e7e59b2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/table.rb @@ -0,0 +1,109 @@ +class Pry + module Helpers + def self.tablify_or_one_line(heading, things) + plain_heading = Pry::Helpers::Text.strip_color(heading) + attempt = Table.new(things, :column_count => things.size) + if attempt.fits_on_line?(Terminal.width! - plain_heading.size - 2) + "#{heading}: #{attempt}\n" + else + "#{heading}: \n#{tablify_to_screen_width(things, :indent => ' ')}\n" + end + end + + def self.tablify_to_screen_width(things, options = {}) + things = things.compact + if indent = options[:indent] + usable_width = Terminal.width! - indent.size + tablify(things, usable_width).to_s.gsub(/^/, indent) + else + tablify(things, Terminal.width!).to_s + end + end + + def self.tablify(things, line_length) + table = Table.new(things, :column_count => things.size) + table.column_count -= 1 until 1 == table.column_count or + table.fits_on_line?(line_length) + table + end + + class Table + attr_reader :items, :column_count + def initialize items, args = {} + @column_count = args[:column_count] + self.items = items + end + + def to_s + rows_to_s.join("\n") + end + + def rows_to_s style = :color_on + widths = columns.map{|e| _max_width(e)} + @rows_without_colors.map do |r| + padded = [] + r.each_with_index do |e,i| + next unless e + item = e.ljust(widths[i]) + item.sub! e, _recall_color_for(e) if :color_on == style + padded << item + end + padded.join(Pry.config.ls.separator) + end + end + + def items= items + @items = items + _rebuild_colorless_cache + _recolumn + items + end + + def column_count= n + @column_count = n + _recolumn + end + + def fits_on_line? line_length + _max_width(rows_to_s :no_color) <= line_length + end + + def columns + @rows_without_colors.transpose + end + + def ==(other); items == other.to_a end + def to_a; items.to_a end + + private + def _max_width(things) + things.compact.map(&:size).max || 0 + end + + def _rebuild_colorless_cache + @colorless_cache = {} + @plain_items = [] + items.map do |e| + plain = Pry::Helpers::Text.strip_color(e) + @colorless_cache[plain] = e + @plain_items << plain + end + end + + def _recolumn + @rows_without_colors = [] + return if items.size.zero? + row_count = (items.size.to_f/column_count).ceil + row_count.times do |i| + row_indices = (0...column_count).map{|e| row_count*e+i} + @rows_without_colors << row_indices.map{|e| @plain_items[e]} + end + end + + def _recall_color_for thing + @colorless_cache[thing] + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/text.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/text.rb new file mode 100644 index 000000000..13867cf1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/helpers/text.rb @@ -0,0 +1,107 @@ +class Pry + module Helpers + + # The methods defined on {Text} are available to custom commands via {Pry::Command#text}. + module Text + + COLORS = + { + "black" => 0, + "red" => 1, + "green" => 2, + "yellow" => 3, + "blue" => 4, + "purple" => 5, + "magenta" => 5, + "cyan" => 6, + "white" => 7 + } + + class << self + + COLORS.each_pair do |color, value| + define_method color do |text| + "\033[0;#{30+value}m#{text}\033[0m" + end + + define_method "bright_#{color}" do |text| + "\033[1;#{30+value}m#{text}\033[0m" + end + end + + # Remove any color codes from _text_. + # + # @param [String, #to_s] text + # @return [String] _text_ stripped of any color codes. + def strip_color(text) + text.to_s.gsub(/\e\[.*?(\d)+m/ , '') + end + + # Returns _text_ as bold text for use on a terminal. + # + # @param [String, #to_s] text + # @return [String] _text_ + def bold(text) + "\e[1m#{text}\e[0m" + end + + # Returns `text` in the default foreground colour. + # Use this instead of "black" or "white" when you mean absence of colour. + # + # @param [String, #to_s] text + # @return [String] + def default(text) + text.to_s + end + alias_method :bright_default, :bold + + # Executes the block with `Pry.config.color` set to false. + # @yield + # @return [void] + def no_color(&block) + boolean = Pry.config.color + Pry.config.color = false + yield + ensure + Pry.config.color = boolean + end + + # Executes the block with `Pry.config.pager` set to false. + # @yield + # @return [void] + def no_pager(&block) + boolean = Pry.config.pager + Pry.config.pager = false + yield + ensure + Pry.config.pager = boolean + end + + # Returns _text_ in a numbered list, beginning at _offset_. + # + # @param [#each_line] text + # @param [Fixnum] offset + # @return [String] + def with_line_numbers(text, offset, color=:blue) + lines = text.each_line.to_a + max_width = (offset + lines.count).to_s.length + lines.each_with_index.map do |line, index| + adjusted_index = (index + offset).to_s.rjust(max_width) + "#{self.send(color, adjusted_index)}: #{line}" + end.join + end + + # Returns _text_ indented by _chars_ spaces. + # + # @param [String] text + # @param [Fixnum] chars + def indent(text, chars) + text.lines.map { |l| "#{' ' * chars}#{l}" }.join + end + end + + end + + end +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history.rb new file mode 100644 index 000000000..81b74176e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history.rb @@ -0,0 +1,127 @@ +class Pry + # The History class is responsible for maintaining the user's input history, + # both internally and within Readline. + class History + attr_accessor :loader, :saver, :pusher, :clearer + + # @return [Fixnum] Number of lines in history when Pry first loaded. + attr_reader :original_lines + + def initialize(options={}) + @history = [] + @original_lines = 0 + @file_path = options[:file_path] + restore_default_behavior + end + + # Assign the default methods for loading, saving, pushing, and clearing. + def restore_default_behavior + Pry.config.input # force Readline to load if applicable + + @loader = method(:read_from_file) + @saver = method(:save_to_file) + + if defined?(Readline) + @pusher = method(:push_to_readline) + @clearer = method(:clear_readline) + else + @pusher = proc { } + @clearer = proc { } + end + end + + # Load the input history using `History.loader`. + # @return [Integer] The number of lines loaded + def load + @loader.call do |line| + @pusher.call(line.chomp) + @history << line.chomp + @original_lines += 1 + end + end + + # Add a line to the input history, ignoring blank and duplicate lines. + # @param [String] line + # @return [String] The same line that was passed in + def push(line) + unless line.empty? || (@history.last && line == @history.last) + @pusher.call(line) + @history << line + @saver.call(line) if Pry.config.history.should_save + end + line + end + alias << push + + # Clear this session's history. This won't affect the contents of the + # history file. + def clear + @clearer.call + @history = [] + end + + # @return [Fixnum] The number of lines in history. + def history_line_count + @history.count + end + + # @return [Fixnum] The number of lines in history from just this session. + def session_line_count + @history.count - @original_lines + end + + # Return an Array containing all stored history. + # @return [Array] An Array containing all lines of history loaded + # or entered by the user in the current session. + def to_a + @history.dup + end + + private + + # The default loader. Yields lines from `Pry.history.config.file`. + def read_from_file + path = history_file_path + + if File.exists?(path) + File.foreach(path) { |line| yield(line) } + end + rescue => error + warn "History file not loaded: #{error.message}" + end + + # The default pusher. Appends the given line to Readline::HISTORY. + # @param [String] line + def push_to_readline(line) + Readline::HISTORY << line + end + + # The default clearer. Clears Readline::HISTORY. + def clear_readline + Readline::HISTORY.shift until Readline::HISTORY.empty? + end + + # The default saver. Appends the given line to `Pry.history.config.file`. + def save_to_file(line) + history_file.puts line if history_file + end + + # The history file, opened for appending. + def history_file + if defined?(@history_file) + @history_file + else + @history_file = File.open(history_file_path, 'a', 0600).tap do |file| + file.sync = true + end + end + rescue Errno::EACCES + warn 'History not saved; unable to open your history file for writing.' + @history_file = false + end + + def history_file_path + File.expand_path(@file_path || Pry.config.history.file) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history_array.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history_array.rb new file mode 100644 index 000000000..60e41bcab --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/history_array.rb @@ -0,0 +1,121 @@ +class Pry + # A history array is an array to which you can only add elements. Older + # entries are removed progressively, so that the array never contains more than + # N elements. + # + # History arrays are used by Pry to store the output of the last commands. + # + # @example + # ary = Pry::HistoryArray.new 10 + # ary << 1 << 2 << 3 + # ary[0] # => 1 + # ary[1] # => 2 + # 10.times { |n| ary << n } + # ary[0] # => nil + # ary[-1] # => 9 + class HistoryArray + include Enumerable + + # @param [Integer] size Maximum amount of objects in the array + def initialize(size) + @max_size = size + + @hash = {} + @count = 0 + end + + # Pushes an object at the end of the array + # @param [Object] value Object to be added + def <<(value) + @hash[@count] = value + + if @hash.size > max_size + @hash.delete(@count - max_size) + end + + @count += 1 + + self + end + + # @overload [](index) + # @param [Integer] index Index of the item to access. + # @return [Object, nil] Item at that index or nil if it has been removed. + # @overload [](index, size) + # @param [Integer] index Index of the first item to access. + # @param [Integer] size Amount of items to access + # @return [Array, nil] The selected items. Nil if index is greater than + # the size of the array. + # @overload [](range) + # @param [Range] range Range of indices to access. + # @return [Array, nil] The selected items. Nil if index is greater than + # the size of the array. + def [](index_or_range, size = nil) + if index_or_range.is_a? Integer + index = convert_index(index_or_range) + + if size + end_index = index + size + index > @count ? nil : (index...[end_index, @count].min).map do |n| + @hash[n] + end + else + @hash[index] + end + else + range = convert_range(index_or_range) + range.begin > @count ? nil : range.map { |n| @hash[n] } + end + end + + # @return [Integer] Amount of objects in the array + def size + @count + end + alias count size + alias length size + + def empty? + size == 0 + end + + def each + ((@count - size)...@count).each do |n| + yield @hash[n] + end + end + + def to_a + ((@count - size)...@count).map { |n| @hash[n] } + end + + # Returns [Hash] copy of the internal @hash history + def to_h + @hash.dup + end + + def pop! + @hash.delete @count - 1 + @count -= 1 + end + + def inspect + "#<#{self.class} size=#{size} first=#{@count - size} max_size=#{max_size}>" + end + + # @return [Integer] Maximum amount of objects in the array + attr_reader :max_size + + private + def convert_index(n) + n >= 0 ? n : @count + n + end + + def convert_range(range) + end_index = convert_index(range.end) + end_index += 1 unless range.exclude_end? + + Range.new(convert_index(range.begin), [end_index, @count].min, true) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/hooks.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/hooks.rb new file mode 100644 index 000000000..48291ee7b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/hooks.rb @@ -0,0 +1,230 @@ +class Pry + + # Implements a hooks system for Pry. A hook is a callable that is + # associated with an event. A number of events are currently + # provided by Pry, these include: `:when_started`, `:before_session`, `:after_session`. + # A hook must have a name, and is connected with an event by the + # `Pry::Hooks#add_hook` method. + # @example Adding a hook for the `:before_session` event. + # Pry.config.hooks.add_hook(:before_session, :say_hi) do + # puts "hello" + # end + class Hooks + + # Converts a hash to a `Pry::Hooks` instance. All hooks defined + # this way are anonymous. This functionality is primarily to + # provide backwards-compatibility with the old hash-based hook + # system in Pry versions < 0.9.8 + # @param [Hash] hash The hash to convert to `Pry::Hooks`. + # @return [Pry::Hooks] The resulting `Pry::Hooks` instance. + def self.from_hash(hash) + return hash if hash.instance_of?(self) + instance = new + hash.each do |k, v| + instance.add_hook(k, nil, v) + end + instance + end + + def initialize + @hooks = {} + end + + # Ensure that duplicates have their @hooks object + def initialize_copy(orig) + hooks_dup = @hooks.dup + @hooks.each do |k, v| + hooks_dup[k] = v.dup + end + + @hooks = hooks_dup + end + + def hooks + @hooks + end + protected :hooks + + def errors + @errors ||= [] + end + + # Destructively merge the contents of two `Pry:Hooks` instances. + # @param [Pry::Hooks] other The `Pry::Hooks` instance to merge + # @return [Pry:Hooks] Returns the receiver. + # @example + # hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # Pry::Hooks.new.merge!(hooks) + def merge!(other) + @hooks.merge!(other.dup.hooks) do |key, v1, v2| + merge_arrays(v1, v2) + end + + self + end + + def merge_arrays(array1, array2) + uniq_keeping_last(array1 + array2, &:first) + end + private :merge_arrays + + def uniq_keeping_last(input, &block) + hash, output = {}, [] + input.reverse.each{ |i| hash[block[i]] ||= (output.unshift i) } + output + end + private :uniq_keeping_last + + # Return a new `Pry::Hooks` instance containing a merge of the contents of two `Pry:Hooks` instances, + # @param [Pry::Hooks] other The `Pry::Hooks` instance to merge + # @return [Pry::Hooks] The new hash. + # @example + # hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # Pry::Hooks.new.merge(hooks) + def merge(other) + self.dup.tap do |v| + v.merge!(other) + end + end + + # Add a new hook to be executed for the `name` even. + # @param [Symbol] event_name The name of the event. + # @param [Symbol] hook_name The name of the hook. + # @param [#call] callable The callable. + # @yield The block to use as the callable (if `callable` parameter not provided) + # @return [Pry:Hooks] Returns the receiver. + # @example + # Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + def add_hook(event_name, hook_name, callable=nil, &block) + @hooks[event_name] ||= [] + + # do not allow duplicates, but allow multiple `nil` hooks + # (anonymous hooks) + if hook_exists?(event_name, hook_name) && !hook_name.nil? + raise ArgumentError, "Hook with name '#{hook_name}' already defined!" + end + + if !block && !callable + raise ArgumentError, "Must provide a block or callable." + end + + # ensure we only have one anonymous hook + @hooks[event_name].delete_if { |h, k| h.nil? } if hook_name.nil? + + if block + @hooks[event_name] << [hook_name, block] + elsif callable + @hooks[event_name] << [hook_name, callable] + end + + self + end + + # Execute the list of hooks for the `event_name` event. + # @param [Symbol] event_name The name of the event. + # @param [Array] args The arguments to pass to each hook function. + # @return [Object] The return value of the last executed hook. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.exec_hook(:before_session) #=> OUTPUT: "hi!" + def exec_hook(event_name, *args, &block) + @hooks[event_name] ||= [] + + @hooks[event_name].map do |hook_name, callable| + begin + callable.call(*args, &block) + rescue RescuableException => e + errors << e + e + end + end.last + end + + # Return the number of hook functions registered for the `event_name` event. + # @param [Symbol] event_name The name of the event. + # @return [Fixnum] The number of hook functions for `event_name`. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.count(:before_session) #=> 1 + def hook_count(event_name) + @hooks[event_name] ||= [] + @hooks[event_name].size + end + + # Return a specific hook for a given event. + # @param [Symbol] event_name The name of the event. + # @param [Symbol] hook_name The name of the hook + # @return [#call] The requested hook. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.get_hook(:before_session, :say_hi).call #=> "hi!" + def get_hook(event_name, hook_name) + @hooks[event_name] ||= [] + hook = @hooks[event_name].find { |current_hook_name, callable| current_hook_name == hook_name } + hook.last if hook + end + + # Return the hash of hook names / hook functions for a + # given event. (Note that modifying the returned hash does not + # alter the hooks, use add_hook/delete_hook for that). + # @param [Symbol] event_name The name of the event. + # @return [Hash] The hash of hook names / hook functions. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.get_hooks(:before_session) #=> {:say_hi=>#} + def get_hooks(event_name) + @hooks[event_name] ||= [] + Hash[@hooks[event_name]] + end + + # Delete a hook for an event. + # @param [Symbol] event_name The name of the event. + # @param [Symbol] hook_name The name of the hook. + # to delete. + # @return [#call] The deleted hook. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.delete_hook(:before_session, :say_hi) + def delete_hook(event_name, hook_name) + @hooks[event_name] ||= [] + deleted_callable = nil + + @hooks[event_name].delete_if do |current_hook_name, callable| + if current_hook_name == hook_name + deleted_callable = callable + true + else + false + end + end + deleted_callable + end + + # Clear all hooks functions for a given event. + # @param [String] event_name The name of the event. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.delete_hook(:before_session) + def delete_hooks(event_name) + @hooks[event_name] = [] + end + + alias_method :clear, :delete_hooks + + # Remove all events and hooks, clearing out the Pry::Hooks + # instance completely. + # @example + # my_hooks = Pry::Hooks.new.add_hook(:before_session, :say_hi) { puts "hi!" } + # my_hooks.clear_all + def clear_all + @hooks = {} + end + + # @param [Symbol] event_name Name of the event. + # @param [Symbol] hook_name Name of the hook. + # @return [Boolean] Whether the hook by the name `hook_name` + def hook_exists?(event_name, hook_name) + !!(@hooks[event_name] && @hooks[event_name].find { |name, _| name == hook_name }) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/indent.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/indent.rb new file mode 100644 index 000000000..72fbf69bc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/indent.rb @@ -0,0 +1,406 @@ +require 'coderay' + +class Pry + ## + # Pry::Indent is a class that can be used to indent a number of lines + # containing Ruby code similar as to how IRB does it (but better). The class + # works by tokenizing a string using CodeRay and then looping over those + # tokens. Based on the tokens in a line of code that line (or the next one) + # will be indented or un-indented by correctly. + # + class Indent + include Helpers::BaseHelpers + + # Raised if {#module_nesting} would not work. + class UnparseableNestingError < StandardError; end + + # @return [String] String containing the spaces to be inserted before the next line. + attr_reader :indent_level + + # @return [Array] The stack of open tokens. + attr_reader :stack + + # The amount of spaces to insert for each indent level. + SPACES = ' ' + + # Hash containing all the tokens that should increase the indentation + # level. The keys of this hash are open tokens, the values the matching + # tokens that should prevent a line from being indented if they appear on + # the same line. + OPEN_TOKENS = { + 'def' => 'end', + 'class' => 'end', + 'module' => 'end', + 'do' => 'end', + 'if' => 'end', + 'unless' => 'end', + 'while' => 'end', + 'until' => 'end', + 'for' => 'end', + 'case' => 'end', + 'begin' => 'end', + '[' => ']', + '{' => '}', + '(' => ')' + } + + # Which tokens can either be open tokens, or appear as modifiers on + # a single-line. + SINGLELINE_TOKENS = %w(if while until unless rescue) + + # Which tokens can be followed by an optional "do" keyword. + OPTIONAL_DO_TOKENS = %w(for while until) + + # Collection of token types that should be ignored. Without this list + # keywords such as "class" inside strings would cause the code to be + # indented incorrectly. + # + # :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0 + # classifications of "true", "false", and "nil". + IGNORE_TOKENS = [:space, :content, :string, :method, :ident, + :constant, :pre_constant, :predefined_constant] + + # Tokens that indicate the end of a statement (i.e. that, if they appear + # directly before an "if" indicates that that if applies to the same line, + # not the next line) + # + # :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively + # classifications of "super", "next", "return", etc. + STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float, :keyword, + :delimiter, :reserved] + + # Collection of tokens that should appear dedented even though they + # don't affect the surrounding code. + MIDWAY_TOKENS = %w(when else elsif ensure rescue) + + # Clean the indentation of a fragment of ruby. + # + # @param [String] str + # @return [String] + def self.indent(str) + new.indent(str) + end + + # Get the module nesting at the given point in the given string. + # + # NOTE If the line specified contains a method definition, then the nesting + # at the start of the method definition is used. Otherwise the nesting from + # the end of the line is used. + # + # @param [String] str The ruby code to analyze + # @param [Fixnum] line_number The line number (starting from 1) + # @return [Array] + def self.nesting_at(str, line_number) + indent = new + lines = str.split("\n") + n = line_number - 1 + to_indent = lines[0...n] << (lines[n] || "").split("def").first(1) + indent.indent(to_indent.join("\n") << "\n") + indent.module_nesting + end + + def initialize + reset + end + + # reset internal state + def reset + @stack = [] + @indent_level = '' + @heredoc_queue = [] + @close_heredocs = {} + @string_start = nil + @awaiting_class = false + @module_nesting = [] + self + end + + # Indents a string and returns it. This string can either be a single line + # or multiple ones. + # + # @example + # str = <] + def module_nesting + @module_nesting.map do |(kind, token)| + raise UnparseableNestingError, @module_nesting.inspect if token.nil? + + "#{kind} #{token}" + end + end + + # Return a string which, when printed, will rewrite the previous line with + # the correct indentation. Mostly useful for fixing 'end'. + # + # @param [String] prompt The user's prompt + # @param [String] code The code the user just typed in. + # @param [Fixnum] overhang (0) The number of chars to erase afterwards (i.e., + # the difference in length between the old line and the new one). + # @return [String] + def correct_indentation(prompt, code, overhang=0) + prompt = prompt.delete("\001\002") + line_to_measure = Pry::Helpers::Text.strip_color(prompt) << code + whitespace = ' ' * overhang + + _, cols = Terminal.screen_size + + cols = cols.to_i + lines = (cols != 0 ? (line_to_measure.length / cols + 1) : 1).to_i + + if Pry::Helpers::BaseHelpers.windows_ansi? + move_up = "\e[#{lines}F" + move_down = "\e[#{lines}E" + else + move_up = "\e[#{lines}A\e[0G" + move_down = "\e[#{lines}B\e[0G" + end + + "#{move_up}#{prompt}#{colorize_code(code)}#{whitespace}#{move_down}" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_completer.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_completer.rb new file mode 100644 index 000000000..363baa4ac --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_completer.rb @@ -0,0 +1,242 @@ +# taken from irb +# Implements tab completion for Readline in Pry +class Pry::InputCompleter + NUMERIC_REGEXP = /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/ + ARRAY_REGEXP = /^([^\]]*\])\.([^.]*)$/ + SYMBOL_REGEXP = /^(:[^:.]*)$/ + SYMBOL_METHOD_CALL_REGEXP = /^(:[^:.]+)\.([^.]*)$/ + REGEX_REGEXP = /^(\/[^\/]*\/)\.([^.]*)$/ + PROC_OR_HASH_REGEXP = /^([^\}]*\})\.([^.]*)$/ + TOPLEVEL_LOOKUP_REGEXP = /^::([A-Z][^:\.\(]*)$/ + CONSTANT_REGEXP = /^([A-Z][A-Za-z0-9]*)$/ + CONSTANT_OR_METHOD_REGEXP = /^([A-Z].*)::([^:.]*)$/ + HEX_REGEXP = /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/ + GLOBALVARIABLE_REGEXP = /^(\$[^.]*)$/ + VARIABLE_REGEXP = /^([^."].*)\.([^.]*)$/ + + ReservedWords = [ + "BEGIN", "END", + "alias", "and", + "begin", "break", + "case", "class", + "def", "defined", "do", + "else", "elsif", "end", "ensure", + "false", "for", + "if", "in", + "module", + "next", "nil", "not", + "or", + "redo", "rescue", "retry", "return", + "self", "super", + "then", "true", + "undef", "unless", "until", + "when", "while", + "yield" ] + + Operators = [ + "%", "&", "*", "**", "+", "-", "/", + "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>", + "[]", "[]=", "^", "!", "!=", "!~" + ] + + WORD_ESCAPE_STR = " \t\n\"\\'`><=;|&{(" + + def initialize(input, pry = nil) + @pry = pry + @input = input + @input.basic_word_break_characters = WORD_ESCAPE_STR if @input.respond_to?(:basic_word_break_characters=) + @input.completion_append_character = nil if @input.respond_to?(:completion_append_character=) + end + + # + # Return a new completion proc for use by Readline. + # + def call(str, options = {}) + custom_completions = options[:custom_completions] || [] + # if there are multiple contexts e.g. cd 1/2/3 + # get new target for 1/2 and find candidates for 3 + path, input = build_path(str) + + if path.call.empty? + target = options[:target] + else + # Assume the user is tab-completing the 'cd' command + begin + target = Pry::ObjectPath.new(path.call, @pry.binding_stack).resolve.last + # but if that doesn't work, assume they're doing division with no spaces + rescue Pry::CommandError + target = options[:target] + end + end + + begin + bind = target + # Complete stdlib symbols + case input + when REGEX_REGEXP # Regexp + receiver = $1 + message = Regexp.quote($2) + candidates = Regexp.instance_methods.collect(&:to_s) + select_message(path, receiver, message, candidates) + when ARRAY_REGEXP # Array + receiver = $1 + message = Regexp.quote($2) + candidates = Array.instance_methods.collect(&:to_s) + select_message(path, receiver, message, candidates) + when PROC_OR_HASH_REGEXP # Proc or Hash + receiver = $1 + message = Regexp.quote($2) + candidates = Proc.instance_methods.collect(&:to_s) + candidates |= Hash.instance_methods.collect(&:to_s) + select_message(path, receiver, message, candidates) + when SYMBOL_REGEXP # Symbol + if Symbol.respond_to?(:all_symbols) + sym = Regexp.quote($1) + candidates = Symbol.all_symbols.collect{|s| ":" << s.id2name} + candidates.grep(/^#{sym}/) + else + [] + end + when TOPLEVEL_LOOKUP_REGEXP # Absolute Constant or class methods + receiver = $1 + candidates = Object.constants.collect(&:to_s) + candidates.grep(/^#{receiver}/).collect{|e| "::" << e} + when CONSTANT_REGEXP # Constant + message = $1 + begin + context = target.eval("self") + context = context.class unless context.respond_to? :constants + candidates = context.constants.collect(&:to_s) + rescue + candidates = [] + end + candidates = candidates.grep(/^#{message}/).collect(&path) + when CONSTANT_OR_METHOD_REGEXP # Constant or class methods + receiver = $1 + message = Regexp.quote($2) + begin + candidates = eval("#{receiver}.constants.collect(&:to_s)", bind) + candidates |= eval("#{receiver}.methods.collect(&:to_s)", bind) + rescue Pry::RescuableException + candidates = [] + end + candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e} + when SYMBOL_METHOD_CALL_REGEXP # method call on a Symbol + receiver = $1 + message = Regexp.quote($2) + candidates = Symbol.instance_methods.collect(&:to_s) + select_message(path, receiver, message, candidates) + when NUMERIC_REGEXP + # Numeric + receiver = $1 + message = Regexp.quote($5) + begin + candidates = eval(receiver, bind).methods.collect(&:to_s) + rescue Pry::RescuableException + candidates = [] + end + select_message(path, receiver, message, candidates) + when HEX_REGEXP + # Numeric(0xFFFF) + receiver = $1 + message = Regexp.quote($2) + begin + candidates = eval(receiver, bind).methods.collect(&:to_s) + rescue Pry::RescuableException + candidates = [] + end + select_message(path, receiver, message, candidates) + when GLOBALVARIABLE_REGEXP # global + regmessage = Regexp.new(Regexp.quote($1)) + candidates = global_variables.collect(&:to_s).grep(regmessage) + when VARIABLE_REGEXP # variable + receiver = $1 + message = Regexp.quote($2) + + gv = eval("global_variables", bind).collect(&:to_s) + lv = eval("local_variables", bind).collect(&:to_s) + cv = eval("self.class.constants", bind).collect(&:to_s) + + if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver + # foo.func and foo is local var. OR + # Foo::Bar.func + begin + candidates = eval("#{receiver}.methods", bind).collect(&:to_s) + rescue Pry::RescuableException + candidates = [] + end + else + # func1.func2 + candidates = [] + ObjectSpace.each_object(Module){|m| + begin + name = m.name.to_s + rescue Pry::RescuableException + name = "" + end + next if name != "IRB::Context" and + /^(IRB|SLex|RubyLex|RubyToken)/ =~ name + + # jruby doesn't always provide #instance_methods() on each + # object. + if m.respond_to?(:instance_methods) + candidates.concat m.instance_methods(false).collect(&:to_s) + end + } + candidates.sort! + candidates.uniq! + end + select_message(path, receiver, message, candidates) + when /^\.([^.]*)$/ + # Unknown(maybe String) + receiver = "" + message = Regexp.quote($1) + candidates = String.instance_methods(true).collect(&:to_s) + select_message(path, receiver, message, candidates) + else + candidates = eval( + "methods | private_methods | local_variables | " \ + "self.class.constants | instance_variables", + bind + ).collect(&:to_s) + + if eval("respond_to?(:class_variables)", bind) + candidates += eval("class_variables", bind).collect(&:to_s) + end + candidates = (candidates|ReservedWords|custom_completions).grep(/^#{Regexp.quote(input)}/) + candidates.collect(&path) + end + rescue Pry::RescuableException + [] + end + end + + def select_message(path, receiver, message, candidates) + candidates.grep(/^#{message}/).collect { |e| + case e + when /^[a-zA-Z_]/ + path.call(receiver + "." << e) + when /^[0-9]/ + when *Operators + #receiver + " " << e + end + }.compact + end + + # build_path seperates the input into two parts: path and input. + # input is the partial string that should be completed + # path is a proc that takes an input and builds a full path. + def build_path(input) + # check to see if the input is a regex + return proc {|i| i.to_s }, input if input[/\/\./] + trailing_slash = input.end_with?('/') + contexts = input.chomp('/').split(/\//) + input = contexts[-1] + path = proc do |i| + p = contexts[0..-2].push(i).join('/') + p += '/' if trailing_slash && !i.nil? + p + end + return path, input + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_lock.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_lock.rb new file mode 100644 index 000000000..8adfed4bf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/input_lock.rb @@ -0,0 +1,132 @@ +require 'thread' + +class Pry + # There is one InputLock per input (such as STDIN) as two REPLs on the same + # input makes things delirious. InputLock serializes accesses to the input so + # that threads to not conflict with each other. The latest thread to request + # ownership of the input wins. + class InputLock + class Interrupt < Exception; end + + class << self + attr_accessor :input_locks + attr_accessor :global_lock + end + + self.input_locks = {} + self.global_lock = Mutex.new + + def self.for(input) + # XXX This method leaks memory, as we never unregister an input once we + # are done with it. Fortunately, the leak is tiny (or so we hope). In + # usual scenarios, we would leak the StringIO that is passed to be + # evaluated from the command line. + global_lock.synchronize do + input_locks[input] ||= Pry::InputLock.new + end + end + + def initialize + @mutex = Mutex.new + @cond = ConditionVariable.new + @owners = [] + @interruptible = false + end + + # Adds ourselves to the ownership list. The last one in the list may access + # the input through interruptible_region(). + def __with_ownership(&block) + @mutex.synchronize do + # Three cases: + # 1) There are no owners, in this case we are good to go. + # 2) The current owner of the input is not reading the input (it might + # just be evaluating some ruby that the user typed). + # The current owner will figure out that it cannot go back to reading + # the input since we are adding ourselves to the @owners list, which + # in turns makes us the current owner. + # 3) The owner of the input is in the interruptible region, reading from + # the input. It's safe to send an Interrupt exception to interrupt + # the owner. It will then proceed like in case 2). + # We wait until the owner sets the interruptible flag back + # to false, meaning that he's out of the interruptible region. + # Note that the owner may receive multiple interrupts since, but that + # should be okay (and trying to avoid it is futile anyway). + while @interruptible + @owners.last.raise Interrupt + @cond.wait(@mutex) + end + @owners << Thread.current + end + + block.call + + ensure + @mutex.synchronize do + # We are releasing any desire to have the input ownership by removing + # ourselves from the list. + @owners.delete(Thread.current) + + # We need to wake up the thread at the end of the @owners list, but + # sadly Ruby doesn't allow us to choose which one we wake up, so we wake + # them all up. + @cond.broadcast + end + end + + def with_ownership(&block) + # If we are in a nested with_ownership() call (nested pry context), we do nothing. + nested = @mutex.synchronize { @owners.include?(Thread.current) } + nested ? block.call : __with_ownership(&block) + end + + def enter_interruptible_region + @mutex.synchronize do + # We patiently wait until we are the owner. This may happen as another + # thread calls with_ownership() because of a binding.pry happening in + # another thread. + @cond.wait(@mutex) until @owners.last == Thread.current + + # We are the legitimate owner of the input. We mark ourselves as + # interruptible, so other threads can send us an Interrupt exception + # while we are blocking from reading the input. + @interruptible = true + end + end + + def leave_interruptible_region + @mutex.synchronize do + # We check if we are still the owner, because we could have received an + # Interrupt right after the following @cond.broadcast, making us retry. + @interruptible = false if @owners.last == Thread.current + @cond.broadcast + end + rescue Interrupt + # We need to guard against a spurious interrupt delivered while we are + # trying to acquire the lock (the rescue block is no longer in our scope). + retry + end + + def interruptible_region(&block) + enter_interruptible_region + + # XXX Note that there is a chance that we get the interrupt right after + # the readline call succeeded, but we'll never know, and we will retry the + # call, discarding that piece of input. + block.call + + rescue Interrupt + # We were asked to back off. The one requesting the interrupt will be + # waiting on the conditional for the interruptible flag to change to false. + # Note that there can be some inefficiency, as we could immediately + # succeed in enter_interruptible_region(), even before the one requesting + # the ownership has the chance to register itself as an owner. + # To mitigate the issue, we sleep a little bit. + leave_interruptible_region + sleep 0.01 + retry + + ensure + leave_interruptible_region + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/inspector.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/inspector.rb new file mode 100644 index 000000000..c56b02fea --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/inspector.rb @@ -0,0 +1,27 @@ +class Pry::Inspector + MAP = { + "default" => { + value: Pry::DEFAULT_PRINT, + description: <<-DESCRIPTION.each_line.map(&:lstrip!) + The default Pry inspector. It has paging and color support, and uses + pretty_inspect when printing an object. + DESCRIPTION + }, + + "simple" => { + value: Pry::SIMPLE_PRINT, + description: <<-DESCRIPTION.each_line.map(&:lstrip) + A simple inspector that uses #puts and #inspect when printing an + object. It has no pager, color, or pretty_inspect support. + DESCRIPTION + }, + + "clipped" => { + value: Pry::CLIPPED_PRINT, + description: <<-DESCRIPTION.each_line.map(&:lstrip) + The clipped inspector has the same features as the 'simple' inspector + but prints large objects as a smaller string. + DESCRIPTION + } + } +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/last_exception.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/last_exception.rb new file mode 100644 index 000000000..2841113da --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/last_exception.rb @@ -0,0 +1,61 @@ +# +# {Pry::LastException} is a proxy class who wraps an Exception object for +# {Pry#last_exception}. it extends the exception object with methods that +# help pry commands be useful. +# +# the original exception object is not modified and method calls are forwarded +# to the wrapped exception object. +# +class Pry::LastException < BasicObject + attr_accessor :bt_index + + def initialize(e) + @e = e + @bt_index = 0 + @file, @line = bt_source_location_for(0) + end + + def method_missing(name, *args, &block) + if @e.respond_to?(name) + @e.public_send(name, *args, &block) + else + super + end + end + + def respond_to_missing?(name, include_private = false) + @e.respond_to?(name) + end + + # + # @return [String] + # returns the path to a file for the current backtrace. see {#bt_index}. + # + def file + @file + end + + # + # @return [Fixnum] + # returns the line for the current backtrace. see {#bt_index}. + # + def line + @line + end + + # @return [Exception] + # returns the wrapped exception + # + def wrapped_exception + @e + end + + def bt_source_location_for(index) + backtrace[index] =~ /(.*):(\d+)/ + [$1, $2.to_i] + end + + def inc_bt_index + @bt_index = (@bt_index + 1) % backtrace.size + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method.rb new file mode 100644 index 000000000..03eb60a15 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method.rb @@ -0,0 +1,546 @@ +require 'pry/helpers/documentation_helpers' + +class Pry + class << self + # If the given object is a `Pry::Method`, return it unaltered. If it's + # anything else, return it wrapped in a `Pry::Method` instance. + def Method(obj) + if obj.is_a? Pry::Method + obj + else + Pry::Method.new(obj) + end + end + end + + # This class wraps the normal `Method` and `UnboundMethod` classes + # to provide extra functionality useful to Pry. + class Method + require 'pry/method/weird_method_locator' + require 'pry/method/disowned' + require 'pry/method/patcher' + + extend Helpers::BaseHelpers + include Helpers::BaseHelpers + include Helpers::DocumentationHelpers + include CodeObject::Helpers + + class << self + # Given a string representing a method name and optionally a binding to + # search in, find and return the requested method wrapped in a `Pry::Method` + # instance. + # + # @param [String] name The name of the method to retrieve. + # @param [Binding] target The context in which to search for the method. + # @param [Hash] options + # @option options [Boolean] :instance Look for an instance method if `name` doesn't + # contain any context. + # @option options [Boolean] :methods Look for a bound/singleton method if `name` doesn't + # contain any context. + # @return [Pry::Method, nil] A `Pry::Method` instance containing the requested + # method, or `nil` if name is `nil` or no method could be located matching the parameters. + def from_str(name, target=TOPLEVEL_BINDING, options={}) + if name.nil? + nil + elsif name.to_s =~ /(.+)\#(\S+)\Z/ + context, meth_name = $1, $2 + from_module(target.eval(context), meth_name, target) + elsif name.to_s =~ /(.+)(\[\])\Z/ + context, meth_name = $1, $2 + from_obj(target.eval(context), meth_name, target) + elsif name.to_s =~ /(.+)(\.|::)(\S+)\Z/ + context, meth_name = $1, $3 + from_obj(target.eval(context), meth_name, target) + elsif options[:instance] + from_module(target.eval("self"), name, target) + elsif options[:methods] + from_obj(target.eval("self"), name, target) + else + from_str(name, target, :instance => true) or + from_str(name, target, :methods => true) + end + + rescue Pry::RescuableException + nil + end + + # Given a `Binding`, try to extract the `::Method` it originated from and + # use it to instantiate a `Pry::Method`. Return `nil` if this isn't + # possible. + # + # @param [Binding] b + # @return [Pry::Method, nil] + # + def from_binding(b) + meth_name = b.eval('::Kernel.__method__') + if [:__script__, nil].include?(meth_name) + nil + else + method = begin + if Object === b.eval('self') + new(Kernel.instance_method(:method).bind(b.eval("self")).call(meth_name)) + else + new(b.eval('class << self; self; end.instance_method(::Kernel.__method__).bind(self)')) + end + rescue NameError, NoMethodError + Disowned.new(b.eval('self'), meth_name.to_s) + end + + if WeirdMethodLocator.weird_method?(method, b) + WeirdMethodLocator.new(method, b).get_method || method + else + method + end + end + end + + # In order to support 2.0 Refinements we need to look up methods + # inside the relevant Binding. + # @param [Object] obj The owner/receiver of the method. + # @param [Symbol] method_name The name of the method. + # @param [Symbol] method_type The type of method: :method or :instance_method + # @param [Binding] target The binding where the method is looked up. + # @return [Method, UnboundMethod] The 'refined' method object. + def lookup_method_via_binding(obj, method_name, method_type, target=TOPLEVEL_BINDING) + Pry.current[:obj] = obj + Pry.current[:name] = method_name + receiver = obj.is_a?(Module) ? "Module" : "Kernel" + target.eval("::#{receiver}.instance_method(:#{method_type}).bind(Pry.current[:obj]).call(Pry.current[:name])") + ensure + Pry.current[:obj] = Pry.current[:name] = nil + end + + # Given a `Class` or `Module` and the name of a method, try to + # instantiate a `Pry::Method` containing the instance method of + # that name. Return `nil` if no such method exists. + # + # @param [Class, Module] klass + # @param [String] name + # @param [Binding] target The binding where the method is looked up. + # @return [Pry::Method, nil] + def from_class(klass, name, target=TOPLEVEL_BINDING) + new(lookup_method_via_binding(klass, name, :instance_method, target)) rescue nil + end + alias from_module from_class + + # Given an object and the name of a method, try to instantiate + # a `Pry::Method` containing the method of that name bound to + # that object. Return `nil` if no such method exists. + # + # @param [Object] obj + # @param [String] name + # @param [Binding] target The binding where the method is looked up. + # @return [Pry::Method, nil] + def from_obj(obj, name, target=TOPLEVEL_BINDING) + new(lookup_method_via_binding(obj, name, :method, target)) rescue nil + end + + # Get all of the instance methods of a `Class` or `Module` + # @param [Class,Module] klass + # @param [Boolean] include_super Whether to include methods from ancestors. + # @return [Array[Pry::Method]] + def all_from_class(klass, include_super=true) + %w(public protected private).map do |visibility| + safe_send(klass, :"#{visibility}_instance_methods", include_super).map do |method_name| + new(safe_send(klass, :instance_method, method_name), :visibility => visibility.to_sym) + end + end.flatten(1) + end + + # + # Get all of the methods on an `Object` + # + # @param [Object] obj + # + # @param [Boolean] include_super + # indicates whether or not to include methods from ancestors. + # + # @return [Array[Pry::Method]] + # + def all_from_obj(obj, include_super=true) + all_from_class(singleton_class_of(obj), include_super) + end + + # + # @deprecated + # please use {#all_from_obj} instead. + # the `method_type` argument is ignored. + # + def all_from_common(obj, method_type = nil, include_super=true) + all_from_obj(obj, include_super) + end + + # Get every `Class` and `Module`, in order, that will be checked when looking + # for an instance method to call on this object. + # @param [Object] obj + # @return [Array[Class, Module]] + def resolution_order(obj) + if Class === obj + singleton_class_resolution_order(obj) + instance_resolution_order(Class) + else + klass = singleton_class_of(obj) rescue obj.class + instance_resolution_order(klass) + end + end + + # Get every `Class` and `Module`, in order, that will be checked when looking + # for methods on instances of the given `Class` or `Module`. + # This does not treat singleton classes of classes specially. + # @param [Class, Module] klass + # @return [Array[Class, Module]] + def instance_resolution_order(klass) + # include klass in case it is a singleton class, + ([klass] + Pry::Method.safe_send(klass, :ancestors)).uniq + end + + def method_definition?(name, definition_line) + singleton_method_definition?(name, definition_line) || + instance_method_definition?(name, definition_line) + end + + def singleton_method_definition?(name, definition_line) + /^define_singleton_method\(?\s*[:\"\']#{Regexp.escape(name)}|^def\s*self\.#{Regexp.escape(name)}/ =~ definition_line.strip + end + + def instance_method_definition?(name, definition_line) + /^define_method\(?\s*[:\"\']#{Regexp.escape(name)}|^def\s*#{Regexp.escape(name)}/ =~ definition_line.strip + end + + # Get the singleton classes of superclasses that could define methods on + # the given class object, and any modules they include. + # If a module is included at multiple points in the ancestry, only + # the lowest copy will be returned. + def singleton_class_resolution_order(klass) + ancestors = Pry::Method.safe_send(klass, :ancestors) + resolution_order = ancestors.grep(Class).map do |anc| + [singleton_class_of(anc), *singleton_class_of(anc).included_modules] + end.flatten(1) + + resolution_order.reverse.uniq.reverse - Class.included_modules + end + + def singleton_class_of(obj) + begin + class << obj; self; end + rescue TypeError # can't define singleton. Fixnum, Symbol, Float, ... + obj.class + end + end + end + + # A new instance of `Pry::Method` wrapping the given `::Method`, `UnboundMethod`, or `Proc`. + # + # @param [::Method, UnboundMethod, Proc] method + # @param [Hash] known_info Can be used to pre-cache expensive to compute stuff. + # @return [Pry::Method] + def initialize(method, known_info={}) + @method = method + @visibility = known_info[:visibility] + end + + # Get the name of the method as a String, regardless of the underlying Method#name type. + # @return [String] + def name + @method.name.to_s + end + + # Get the owner of the method as a Pry::Module + # @return [Pry::Module] + def wrapped_owner + @wrapped_owner ||= Pry::WrappedModule.new(owner) + end + + # Get underlying object wrapped by this Pry::Method instance + # @return [Method, UnboundMethod, Proc] + def wrapped + @method + end + + # Is the method undefined? (aka `Disowned`) + # @return [Boolean] false + def undefined? + false + end + + # Get the name of the method including the class on which it was defined. + # @example + # method(:puts).method_name + # => "Kernel.puts" + # @return [String] + def name_with_owner + "#{wrapped_owner.method_prefix}#{name}" + end + + # @return [String, nil] The source code of the method, or `nil` if it's unavailable. + def source + @source ||= case source_type + when :c + c_source + when :ruby + ruby_source + end + end + + # Update the live copy of the method's source. + def redefine(source) + Patcher.new(self).patch_in_ram source + Pry::Method(owner.instance_method(name)) + end + + # Can we get the source code for this method? + # @return [Boolean] + def source? + !!source + rescue MethodSource::SourceNotFoundError + false + end + + # @return [String, nil] The documentation for the method, or `nil` if it's + # unavailable. + def doc + @doc ||= case source_type + when :c + info = pry_doc_info + info.docstring if info + when :ruby + get_comment_content(comment) + end + end + + # @return [Symbol] The source type of the method. The options are + # `:ruby` for Ruby methods or `:c` for methods written in C. + def source_type + source_location.nil? ? :c : :ruby + end + + # @return [String, nil] The name of the file the method is defined in, or + # `nil` if the filename is unavailable. + def source_file + if source_location.nil? + if !rbx? and source_type == :c + info = pry_doc_info + info.file if info + end + else + source_location.first + end + end + + # @return [Fixnum, nil] The line of code in `source_file` which begins + # the method's definition, or `nil` if that information is unavailable. + def source_line + source_location.nil? ? nil : source_location.last + end + + # @return [Range, nil] The range of lines in `source_file` which contain + # the method's definition, or `nil` if that information is unavailable. + def source_range + source_location.nil? ? nil : (source_line)..(source_line + source.lines.count - 1) + end + + # @return [Symbol] The visibility of the method. May be `:public`, + # `:protected`, or `:private`. + def visibility + @visibility ||= if owner.public_instance_methods.any? { |m| m.to_s == name } + :public + elsif owner.protected_instance_methods.any? { |m| m.to_s == name } + :protected + elsif owner.private_instance_methods.any? { |m| m.to_s == name } + :private + else + :none + end + end + + # @return [String] A representation of the method's signature, including its + # name and parameters. Optional and "rest" parameters are marked with `*` + # and block parameters with `&`. If the parameter names are unavailable, + # they're given numbered names instead. + # Paraphrased from `awesome_print` gem. + def signature + if respond_to?(:parameters) + args = parameters.inject([]) do |arr, (type, name)| + name ||= (type == :block ? 'block' : "arg#{arr.size + 1}") + arr << case type + when :req then name.to_s + when :opt then "#{name}=?" + when :rest then "*#{name}" + when :block then "&#{name}" + else '?' + end + end + else + args = (1..arity.abs).map { |i| "arg#{i}" } + args[-1] = "*#{args[-1]}" if arity < 0 + end + + "#{name}(#{args.join(', ')})" + end + + # @return [Pry::Method, nil] The wrapped method that is called when you + # use "super" in the body of this method. + def super(times=1) + if UnboundMethod === @method + sup = super_using_ancestors(Pry::Method.instance_resolution_order(owner), times) + else + sup = super_using_ancestors(Pry::Method.resolution_order(receiver), times) + sup &&= sup.bind(receiver) + end + Pry::Method.new(sup) if sup + end + + # @return [String, nil] The original name the method was defined under, + # before any aliasing, or `nil` if it can't be determined. + def original_name + return nil if source_type != :ruby + method_name_from_first_line(source.lines.first) + end + + # @return [Boolean] Was the method defined outside a source file? + def dynamically_defined? + !!(source_file and source_file =~ /(\(.*\))|<.*>/) + end + + # @return [Boolean] Whether the method is unbound. + def unbound_method? + is_a?(::UnboundMethod) + end + + # @return [Boolean] Whether the method is bound. + def bound_method? + is_a?(::Method) + end + + # @return [Boolean] Whether the method is a singleton method. + def singleton_method? + wrapped_owner.singleton_class? + end + + # @return [Boolean] Was the method defined within the Pry REPL? + def pry_method? + source_file == Pry.eval_path + end + + # @return [Array] All known aliases for the method. + def aliases + owner = @method.owner + # Avoid using `to_sym` on {Method#name}, which returns a `String`, because + # it won't be garbage collected. + name = @method.name + + all_methods_to_compare = owner.instance_methods | owner.private_instance_methods + alias_list = all_methods_to_compare.combination(2).select do |pair| + pair.include?(name) && + owner.instance_method(pair.first) == owner.instance_method(pair.last) + end.flatten + alias_list.delete(name) + + alias_list.map(&:to_s) + end + + # @return [Boolean] Is the method definitely an alias? + def alias? + name != original_name + end + + # @return [Boolean] + def ==(obj) + if obj.is_a? Pry::Method + obj == @method + else + @method == obj + end + end + + # @param [Class] klass + # @return [Boolean] + def is_a?(klass) + klass == Pry::Method or @method.is_a?(klass) + end + alias kind_of? is_a? + + # @param [String, Symbol] method_name + # @return [Boolean] + def respond_to?(method_name) + super or @method.respond_to?(method_name) + end + + # Delegate any unknown calls to the wrapped method. + def method_missing(method_name, *args, &block) + @method.send(method_name, *args, &block) + end + + def comment + Pry::Code.from_file(source_file).comment_describing(source_line) + end + + private + + # @return [YARD::CodeObjects::MethodObject] + # @raise [CommandError] when the method can't be found or `pry-doc` isn't installed. + def pry_doc_info + if Pry.config.has_pry_doc + Pry::MethodInfo.info_for(@method) or raise CommandError, "Cannot locate this method: #{name}. (source_location returns nil)" + else + fail_msg = "Cannot locate this method: #{name}." + if mri? + fail_msg += ' Try `gem-install pry-doc` to get access to Ruby Core documentation.' + end + raise CommandError, fail_msg + end + end + + # @param [Class, Module] ancestors The ancestors to investigate + # @return [Method] The unwrapped super-method + def super_using_ancestors(ancestors, times=1) + next_owner = self.owner + times.times do + i = ancestors.index(next_owner) + 1 + while ancestors[i] && !(ancestors[i].method_defined?(name) || ancestors[i].private_method_defined?(name)) + i += 1 + end + next_owner = ancestors[i] or return nil + end + + safe_send(next_owner, :instance_method, name) rescue nil + end + + # @param [String] first_ln The first line of a method definition. + # @return [String, nil] + def method_name_from_first_line(first_ln) + return nil if first_ln.strip !~ /^def / + + tokens = CodeRay.scan(first_ln, :ruby) + tokens = tokens.tokens.each_slice(2) if tokens.respond_to?(:tokens) + tokens.each_cons(2) do |t1, t2| + if t2.last == :method || t2.last == :ident && t1 == [".", :operator] + return t2.first + end + end + + nil + end + + def c_source + info = pry_doc_info + if info and info.source + strip_comments_from_c_code(info.source) + end + end + + def ruby_source + # clone of MethodSource.source_helper that knows to use our + # hacked version of source_location for rbx core methods, and + # our input buffer for methods defined in (pry) + file, line = *source_location + raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file + + begin + code = Pry::Code.from_file(file).expression_at(line) + rescue SyntaxError => e + raise MethodSource::SourceNotFoundError.new(e.message) + end + strip_leading_whitespace(code) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/disowned.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/disowned.rb new file mode 100644 index 000000000..35908c985 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/disowned.rb @@ -0,0 +1,53 @@ +class Pry + class Method + # A Disowned Method is one that's been removed from the class on which it was defined. + # + # e.g. + # class C + # def foo + # C.send(:undefine_method, :foo) + # Pry::Method.from_binding(binding) + # end + # end + # + # In this case we assume that the "owner" is the singleton class of the receiver. + # + # This occurs mainly in Sinatra applications. + class Disowned < Method + attr_reader :receiver, :name + + # Create a new Disowned method. + # + # @param [Object] receiver + # @param [String] method_name + def initialize(receiver, method_name, binding=nil) + @receiver, @name = receiver, method_name + end + + # Is the method undefined? (aka `Disowned`) + # @return [Boolean] true + def undefined? + true + end + + # Can we get the source for this method? + # @return [Boolean] false + def source? + false + end + + # Get the hypothesized owner of the method. + # + # @return [Object] + def owner + class << receiver; self; end + end + + # Raise a more useful error message instead of trying to forward to nil. + def method_missing(meth_name, *args, &block) + raise "Cannot call '#{meth_name}' on an undef'd method." if method(:name).respond_to?(meth_name) + Object.instance_method(:method_missing).bind(self).call(meth_name, *args, &block) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/patcher.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/patcher.rb new file mode 100644 index 000000000..3f736f6d1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/patcher.rb @@ -0,0 +1,125 @@ +class Pry + class Method + class Patcher + attr_accessor :method + + @@source_cache = {} + + def initialize(method) + @method = method + end + + def self.code_for(filename) + @@source_cache[filename] + end + + # perform the patch + def patch_in_ram(source) + if method.alias? + with_method_transaction do + redefine source + end + else + redefine source + end + end + + private + + def redefine(source) + @@source_cache[cache_key] = source + TOPLEVEL_BINDING.eval wrap(source), cache_key + end + + def cache_key + "pry-redefined(0x#{method.owner.object_id.to_s(16)}##{method.name})" + end + + # Run some code ensuring that at the end target#meth_name will not have changed. + # + # When we're redefining aliased methods we will overwrite the method at the + # unaliased name (so that super continues to work). By wrapping that code in a + # transation we make that not happen, which means that alias_method_chains, etc. + # continue to work. + # + # @param [String] meth_name The method name before aliasing + # @param [Module] target The owner of the method + + def with_method_transaction + temp_name = "__pry_#{method.original_name}__" + method = self.method + method.owner.class_eval do + alias_method temp_name, method.original_name + yield + alias_method method.name, method.original_name + alias_method method.original_name, temp_name + end + + ensure + method.send(:remove_method, temp_name) rescue nil + end + + # Update the definition line so that it can be eval'd directly on the Method's + # owner instead of from the original context. + # + # In particular this takes `def self.foo` and turns it into `def foo` so that we + # don't end up creating the method on the singleton class of the singleton class + # by accident. + # + # This is necessarily done by String manipulation because we can't find out what + # syntax is needed for the argument list by ruby-level introspection. + # + # @param [String] line The original definition line. e.g. def self.foo(bar, baz=1) + # @return [String] The new definition line. e.g. def foo(bar, baz=1) + def definition_for_owner(line) + if line =~ /\Adef (?:.*?\.)?#{Regexp.escape(method.original_name)}(?=[\(\s;]|$)/ + "def #{method.original_name}#{$'}" + else + raise CommandError, "Could not find original `def #{method.original_name}` line to patch." + end + end + + # Apply wrap_for_owner and wrap_for_nesting successively to `source` + # @param [String] source + # @return [String] The wrapped source. + def wrap(source) + wrap_for_nesting(wrap_for_owner(source)) + end + + # Update the source code so that when it has the right owner when eval'd. + # + # This (combined with definition_for_owner) is backup for the case that + # wrap_for_nesting fails, to ensure that the method will stil be defined in + # the correct place. + # + # @param [String] source The source to wrap + # @return [String] + def wrap_for_owner(source) + Pry.current[:pry_owner] = method.owner + owner_source = definition_for_owner(source) + visibility_fix = "#{method.visibility.to_s} #{method.name.to_sym.inspect}" + "Pry.current[:pry_owner].class_eval do; #{owner_source}\n#{visibility_fix}\nend" + end + + # Update the new source code to have the correct Module.nesting. + # + # This method uses syntactic analysis of the original source file to determine + # the new nesting, so that we can tell the difference between: + # + # class A; def self.b; end; end + # class << A; def b; end; end + # + # The resulting code should be evaluated in the TOPLEVEL_BINDING. + # + # @param [String] source The source to wrap. + # @return [String] + def wrap_for_nesting(source) + nesting = Pry::Code.from_file(method.source_file).nesting_at(method.source_line) + + (nesting + [source] + nesting.map{ "end" } + [""]).join(";") + rescue Pry::Indent::UnparseableNestingError + source + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/weird_method_locator.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/weird_method_locator.rb new file mode 100644 index 000000000..a668d16d3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/method/weird_method_locator.rb @@ -0,0 +1,186 @@ +class Pry + class Method + + # This class is responsible for locating the *real* `Pry::Method` + # object captured by a binding. + # + # Given a `Binding` from inside a method and a 'seed' Pry::Method object, + # there are primarily two situations where the seed method doesn't match + # the Binding: + # 1. The Pry::Method is from a subclass 2. The Pry::Method represents a method of the same name + # while the original was renamed to something else. For 1. we + # search vertically up the inheritance chain, + # and for 2. we search laterally along the object's method table. + # + # When we locate the method that matches the Binding we wrap it in + # Pry::Method and return it, or return nil if we fail. + class WeirdMethodLocator + class << self + + # Whether the given method object matches the associated binding. + # If the method object does not match the binding, then it's + # most likely not the method captured by the binding, and we + # must commence a search. + # + # @param [Pry::Method] method + # @param [Binding] b + # @return [Boolean] + def normal_method?(method, b) + method && (method.source_file && method.source_range rescue false) && + File.expand_path(method.source_file) == File.expand_path(b.eval('__FILE__')) && + method.source_range.include?(b.eval('__LINE__')) + end + + def weird_method?(method, b) + !normal_method?(method, b) + end + end + + attr_accessor :method + attr_accessor :target + + # @param [Pry::Method] method The seed method. + # @param [Binding] target The Binding that captures the method + # we want to locate. + def initialize(method, target) + @method, @target = method, target + end + + # @return [Pry::Method, nil] The Pry::Method that matches the + # given binding. + def get_method + find_method_in_superclass || find_renamed_method + end + + # @return [Boolean] Whether the Pry::Method is unrecoverable + # This usually happens when the method captured by the Binding + # has been subsequently deleted. + def lost_method? + !!(get_method.nil? && renamed_method_source_location) + end + + private + + def normal_method?(method) + self.class.normal_method?(method, target) + end + + def target_self + target.eval('self') + end + + def target_file + pry_file? ? target.eval('__FILE__') : File.expand_path(target.eval('__FILE__')) + end + + def target_line + target.eval('__LINE__') + end + + def pry_file? + Pry.eval_path == target.eval('__FILE__') + end + + # it's possible in some cases that the method we find by this approach is a sub-method of + # the one we're currently in, consider: + # + # class A; def b; binding.pry; end; end + # class B < A; def b; super; end; end + # + # Given that we can normally find the source_range of methods, and that we know which + # __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases. + # + # This obviously won't work if the source is unavaiable for some reason, or if both + # methods have the same __FILE__ and __LINE__, or if we're in rbx where b.eval('__LINE__') + # is broken. + # + # @return [Pry::Method, nil] The Pry::Method representing the + # superclass method. + def find_method_in_superclass + guess = method + + while guess + # needs rescue if this is a Disowned method or a C method or something... + # TODO: Fix up the exception handling so we don't need a bare rescue + if normal_method?(guess) + return guess + else + guess = guess.super + end + end + + # Uhoh... none of the methods in the chain had the right __FILE__ and __LINE__ + # This may be caused by rbx https://github.com/rubinius/rubinius/issues/953, + # or other unknown circumstances (TODO: we should warn the user when this happens) + nil + end + + # This is the case where the name of a method has changed + # (via alias_method) so we locate the Method object for the + # renamed method. + # + # @return [Pry::Method, nil] The Pry::Method representing the + # renamed method + def find_renamed_method + return if !valid_file?(target_file) + alias_name = all_methods_for(target_self).find do |v| + expanded_source_location(target_self.method(v).source_location) == renamed_method_source_location + end + + alias_name && Pry::Method(target_self.method(alias_name)) + end + + def expanded_source_location(sl) + return if !sl + + if pry_file? + sl + else + [File.expand_path(sl.first), sl.last] + end + end + + # Use static analysis to locate the start of the method definition. + # We have the `__FILE__` and `__LINE__` from the binding and the + # original name of the method so we search up until we find a + # def/define_method, etc defining a method of the appropriate name. + # + # @return [Array] The `source_location` of the + # renamed method + def renamed_method_source_location + return @original_method_source_location if defined?(@original_method_source_location) + + source_index = lines_for_file(target_file)[0..(target_line - 1)].rindex do |v| + Pry::Method.method_definition?(method.name, v) + end + + @original_method_source_location = source_index && + [target_file, index_to_line_number(source_index)] + end + + def index_to_line_number(index) + # Pry.line_buffer is 0-indexed + pry_file? ? index : index + 1 + end + + def valid_file?(file) + (File.exist?(file) && !File.directory?(file)) || Pry.eval_path == file + end + + def lines_for_file(file) + @lines_for_file ||= {} + @lines_for_file[file] ||= if Pry.eval_path == file + Pry.line_buffer + else + File.readlines(file) + end + end + + def all_methods_for(obj) + obj.public_methods(false) + + obj.private_methods(false) + + obj.protected_methods(false) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/module_candidate.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/module_candidate.rb new file mode 100644 index 000000000..4c97f134d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/module_candidate.rb @@ -0,0 +1,136 @@ +require 'pry/helpers/documentation_helpers' +require 'forwardable' + +class Pry + class WrappedModule + + # This class represents a single candidate for a module/class definition. + # It provides access to the source, documentation, line and file + # for a monkeypatch (reopening) of a class/module. + class Candidate + include Pry::Helpers::DocumentationHelpers + include Pry::CodeObject::Helpers + extend Forwardable + + # @return [String] The file where the module definition is located. + attr_reader :file + alias_method :source_file, :file + + # @return [Fixnum] The line where the module definition is located. + attr_reader :line + alias_method :source_line, :line + + # Methods to delegate to associated `Pry::WrappedModule + # instance`. + private_delegates = [:lines_for_file, :method_candidates, + :yard_docs?] + + public_delegates = [:wrapped, :module?, :class?, :name, :nonblank_name, + :number_of_candidates] + + def_delegators :@wrapper, *(private_delegates + public_delegates) + private(*private_delegates) + public(*public_delegates) + + # @raise [Pry::CommandError] If `rank` is out of bounds. + # @param [Pry::WrappedModule] wrapper The associated + # `Pry::WrappedModule` instance that owns the candidates. + # @param [Fixnum] rank The rank of the candidate to + # retrieve. Passing 0 returns 'primary candidate' (the candidate with largest + # number of methods), passing 1 retrieves candidate with + # second largest number of methods, and so on, up to + # `Pry::WrappedModule#number_of_candidates() - 1` + def initialize(wrapper, rank) + @wrapper = wrapper + + if number_of_candidates <= 0 + raise CommandError, "Cannot find a definition for #{name} module!" + elsif rank > (number_of_candidates - 1) + raise CommandError, "No such module candidate. Allowed candidates range is from 0 to #{number_of_candidates - 1}" + end + + @rank = rank + @file, @line = source_location + end + + # @raise [Pry::CommandError] If source code cannot be found. + # @return [String] The source for the candidate, i.e the + # complete module/class definition. + def source + return nil if file.nil? + return @source if @source + + @source = strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk)) + end + + # @raise [Pry::CommandError] If documentation cannot be found. + # @return [String] The documentation for the candidate. + def doc + return nil if file.nil? + return @doc if @doc + + @doc = get_comment_content(Pry::Code.from_file(file).comment_describing(line)) + end + + # @return [Array, nil] A `[String, Fixnum]` pair representing the + # source location (file and line) for the candidate or `nil` + # if no source location found. + def source_location + return @source_location if @source_location + + file, line = first_method_source_location + return nil if !file.is_a?(String) + + @source_location = [file, first_line_of_module_definition(file, line)] + rescue Pry::RescuableException + nil + end + + private + + # Locate the first line of the module definition. + # @param [String] file The file that contains the module + # definition (somewhere). + # @param [Fixnum] line The module definition should appear + # before this line (if it exists). + # @return [Fixnum] The line where the module is defined. This + # line number is one-indexed. + def first_line_of_module_definition(file, line) + searchable_lines = lines_for_file(file)[0..(line - 2)] + searchable_lines.rindex { |v| class_regexes.any? { |r| r =~ v } } + 1 + end + + def class_regexes + mod_type_string = wrapped.class.to_s.downcase + [/^\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped.name.split(/::/).last}/, + /^\s*(::)?#{wrapped.name.split(/::/).last}\s*?=\s*?#{wrapped.class}/, + /^\s*(::)?#{wrapped.name.split(/::/).last}\.(class|instance)_eval/] + end + + # This method is used by `Candidate#source_location` as a + # starting point for the search for the candidate's definition. + # @return [Array] The source location of the base method used to + # calculate the source location of the candidate. + def first_method_source_location + @first_method_source_location ||= method_candidates[@rank].first.source_location + end + + # @return [Array] The source location of the last method in this + # candidate's module definition. + def last_method_source_location + @end_method_source_location ||= method_candidates[@rank].last.source_location + end + + # Return the number of lines between the start of the class definition + # and the start of the last method. We use this value so we can + # quickly grab these lines from the file (without having to + # check each intervening line for validity, which is expensive) speeding up source extraction. + # @return [Fixum] Number of lines. + def number_of_lines_in_first_chunk + end_method_line = last_method_source_location.last + + end_method_line - line + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/object_path.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/object_path.rb new file mode 100644 index 000000000..5bffb02c5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/object_path.rb @@ -0,0 +1,82 @@ +class Pry + # `ObjectPath` implements the resolution of "object paths", which are strings + # that are similar to filesystem paths but meant for traversing Ruby objects. + # Examples of valid object paths include: + # + # x + # @foo/@bar + # "string"/upcase + # Pry/Method + # + # Object paths are mostly relevant in the context of the `cd` command. + # @see https://github.com/pry/pry/wiki/State-navigation + class ObjectPath + SPECIAL_TERMS = ["", "::", ".", ".."] + + # @param [String] path_string The object path expressed as a string. + # @param [Array] current_stack The current state of the binding + # stack. + def initialize(path_string, current_stack) + @path_string = path_string + @current_stack = current_stack + end + + # @return [Array] a new stack resulting from applying the given + # path to the current stack. + def resolve + scanner = StringScanner.new(@path_string.strip) + stack = @current_stack.dup + + begin + next_segment = "" + + loop do + # Scan for as long as we don't see a slash + next_segment << scanner.scan(/[^\/]*/) + + if complete?(next_segment) || scanner.eos? + scanner.getch # consume the slash + break + else + next_segment << scanner.getch # append the slash + end + end + + case next_segment.chomp + when "" + stack = [stack.first] + when "::" + stack.push(TOPLEVEL_BINDING) + when "." + next + when ".." + stack.pop unless stack.size == 1 + else + stack.push(Pry.binding_for(stack.last.eval(next_segment))) + end + rescue RescuableException => e + return handle_failure(next_segment, e) + end until scanner.eos? + + stack + end + + private + + def complete?(segment) + SPECIAL_TERMS.include?(segment) || Pry::Code.complete_expression?(segment) + end + + def handle_failure(context, err) + msg = [ + "Bad object path: #{@path_string.inspect}", + "Failed trying to resolve: #{context.inspect}", + "Exception: #{err.inspect}" + ].join("\n") + + raise CommandError.new(msg).tap { |e| + e.set_backtrace err.backtrace + } + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/output.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/output.rb new file mode 100644 index 000000000..b5f6bb3e8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/output.rb @@ -0,0 +1,50 @@ +class Pry + class Output + attr_reader :_pry_ + + def initialize(_pry_) + @_pry_ = _pry_ + end + + def puts(*objs) + return print "\n" if objs.empty? + + objs.each do |obj| + if ary = Array.try_convert(obj) + puts(*ary) + else + print "#{obj.to_s.chomp}\n" + end + end + + nil + end + + def print(*objs) + objs.each do |obj| + _pry_.config.output.print decolorize_maybe(obj.to_s) + end + + nil + end + alias << print + alias write print + + # If _pry_.config.color is currently false, removes ansi escapes from the string. + def decolorize_maybe(str) + if _pry_.config.color + str + else + Helpers::Text.strip_color str + end + end + + def method_missing(name, *args, &block) + _pry_.config.output.send(name, *args, &block) + end + + def respond_to_missing?(*a) + _pry_.config.respond_to?(*a) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pager.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pager.rb new file mode 100644 index 000000000..e5451d2ed --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pager.rb @@ -0,0 +1,236 @@ +require 'pry/terminal' + +# A pager is an `IO`-like object that accepts text and either prints it +# immediately, prints it one page at a time, or streams it to an external +# program to print one page at a time. +class Pry::Pager + class StopPaging < StandardError + end + + attr_reader :_pry_ + + def initialize(_pry_) + @_pry_ = _pry_ + end + + # Send the given text through the best available pager (if `Pry.config.pager` is + # enabled). + # If you want to send text through in chunks as you generate it, use `open` to + # get a writable object instead. + # @param [String] text A piece of text to run through a pager. + # @param [IO] output (`$stdout`) An object to send output to. + def page(text) + open do |pager| + pager << text + end + end + + # Yields a pager object (`NullPager`, `SimplePager`, or `SystemPager`). All + # pagers accept output with `#puts`, `#print`, `#write`, and `#<<`. + # @param [IO] output (`$stdout`) An object to send output to. + def open + pager = best_available + yield pager + rescue StopPaging + ensure + pager.close if pager + end + + private + + def enabled?; !!@enabled; end + + def output; @output; end + + # Return an instance of the "best" available pager class -- `SystemPager` if + # possible, `SimplePager` if `SystemPager` isn't available, and `NullPager` + # if the user has disabled paging. All pagers accept output with `#puts`, + # `#print`, `#write`, and `#<<`. You must call `#close` when you're done + # writing output to a pager, and you must rescue `Pry::Pager::StopPaging`. + # These requirements can be avoided by using `.open` instead. + # @param [#<<] output ($stdout) An object to send output to. + def best_available + if !_pry_.config.pager + NullPager.new(_pry_.output) + elsif !SystemPager.available? || Pry::Helpers::BaseHelpers.jruby? + SimplePager.new(_pry_.output) + else + SystemPager.new(_pry_.output) + end + end + + # `NullPager` is a "pager" that actually just prints all output as it comes + # in. Used when `Pry.config.pager` is false. + class NullPager + def initialize(out) + @out = out + end + + def puts(str) + print "#{str.chomp}\n" + end + + def print(str) + write str + end + alias << print + + def write(str) + @out.write str + end + + def close + end + + private + + def height + @height ||= Pry::Terminal.height! + end + + def width + @width ||= Pry::Terminal.width! + end + end + + # `SimplePager` is a straightforward pure-Ruby pager. We use it on JRuby and + # when we can't find a usable external pager. + class SimplePager < NullPager + def initialize(*) + super + @tracker = PageTracker.new(height - 3, width) + end + + def write(str) + str.lines.each do |line| + @out.print line + @tracker.record line + + if @tracker.page? + @out.print "\n" + @out.print "\e[0m" + @out.print " --- Press enter to continue " \ + "( q to break ) --- \n" + raise StopPaging if Readline.readline("").chomp == "q" + @tracker.reset + end + end + end + end + + # `SystemPager` buffers output until we're pretty sure it's at least a page + # long, then invokes an external pager and starts streaming output to it. If + # `#close` is called before then, it just prints out the buffered content. + class SystemPager < NullPager + def self.default_pager + pager = ENV["PAGER"] || "" + + # Default to less, and make sure less is being passed the correct options + if pager.strip.empty? or pager =~ /^less\b/ + pager = "less -R -F -X" + end + + pager + end + + def self.available? + if @system_pager.nil? + @system_pager = begin + pager_executable = default_pager.split(' ').first + `which #{pager_executable}` + $?.success? + rescue + false + end + else + @system_pager + end + end + + def initialize(*) + super + @tracker = PageTracker.new(height, width) + @buffer = "" + end + + def write(str) + if invoked_pager? + write_to_pager str + else + @tracker.record str + @buffer << str + + if @tracker.page? + write_to_pager @buffer + end + end + rescue Errno::EPIPE + raise StopPaging + end + + def close + if invoked_pager? + pager.close + else + @out.puts @buffer + end + end + + private + + def write_to_pager(text) + pager.write @out.decolorize_maybe(text) + end + + def invoked_pager? + @pager + end + + def pager + @pager ||= IO.popen(self.class.default_pager, 'w') + end + end + + # `PageTracker` tracks output to determine whether it's likely to take up a + # whole page. This doesn't need to be super precise, but we can use it for + # `SimplePager` and to avoid invoking the system pager unnecessarily. + # + # One simplifying assumption is that we don't need `#page?` to return `true` + # on the basis of an incomplete line. Long lines should be counted as + # multiple lines, but we don't have to transition from `false` to `true` + # until we see a newline. + class PageTracker + def initialize(rows, cols) + @rows, @cols = rows, cols + reset + end + + def record(str) + str.lines.each do |line| + if line.end_with? "\n" + @row += ((@col + line_length(line) - 1) / @cols) + 1 + @col = 0 + else + @col += line_length(line) + end + end + end + + def page? + @row >= @rows + end + + def reset + @row = 0 + @col = 0 + end + + private + + # Approximation of the printable length of a given line, without the + # newline and without ANSI color codes. + def line_length(line) + line.chomp.gsub(/\e\[[\d;]*m/, '').length + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/plugins.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/plugins.rb new file mode 100644 index 000000000..1d0519598 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/plugins.rb @@ -0,0 +1,103 @@ +class Pry + class PluginManager + PRY_PLUGIN_PREFIX = /^pry-/ + + # Placeholder when no associated gem found, displays warning + class NoPlugin + def initialize(name) + @name = name + end + + def method_missing(*args) + warn "Warning: The plugin '#{@name}' was not found! (no gem found)" + end + end + + class Plugin + attr_accessor :name, :gem_name, :enabled, :spec, :active + + def initialize(name, gem_name, spec, enabled) + @name, @gem_name, @enabled, @spec = name, gem_name, enabled, spec + end + + # Disable a plugin. (prevents plugin from being loaded, cannot + # disable an already activated plugin) + def disable! + self.enabled = false + end + + # Enable a plugin. (does not load it immediately but puts on + # 'white list' to be loaded) + def enable! + self.enabled = true + end + + # Load the Command line options defined by this plugin (if they exist) + def load_cli_options + cli_options_file = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb") + require cli_options_file if File.exist?(cli_options_file) + end + # Activate the plugin (require the gem - enables/loads the + # plugin immediately at point of call, even if plugin is + # disabled) + # Does not reload plugin if it's already active. + def activate! + # Create the configuration object for the plugin. + Pry.config.send("#{gem_name.gsub('-', '_')}=", Pry::Config.from_hash({})) + + begin + require gem_name if !active? + rescue LoadError => e + warn "Found plugin #{gem_name}, but could not require '#{gem_name}'" + warn e + rescue => e + warn "require '#{gem_name}' # Failed, saying: #{e}" + end + + self.active = true + self.enabled = true + end + + alias active? active + alias enabled? enabled + end + + def initialize + @plugins = [] + end + + # Find all installed Pry plugins and store them in an internal array. + def locate_plugins + Gem.refresh + (Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem| + next if gem.name !~ PRY_PLUGIN_PREFIX + plugin_name = gem.name.split('-', 2).last + @plugins << Plugin.new(plugin_name, gem.name, gem, true) if !gem_located?(gem.name) + end + @plugins + end + + # @return [Hash] A hash with all plugin names (minus the 'pry-') as + # keys and Plugin objects as values. + def plugins + h = Hash.new { |_, key| NoPlugin.new(key) } + @plugins.each do |plugin| + h[plugin.name] = plugin + end + h + end + + # Require all enabled plugins, disabled plugins are skipped. + def load_plugins + @plugins.each do |plugin| + plugin.activate! if plugin.enabled? + end + end + + private + def gem_located?(gem_name) + @plugins.any? { |plugin| plugin.gem_name == gem_name } + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/prompt.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/prompt.rb new file mode 100644 index 000000000..62f0bc1f5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/prompt.rb @@ -0,0 +1,26 @@ +class Pry::Prompt + MAP = { + "default" => { + value: Pry::DEFAULT_PROMPT, + description: "The default Pry prompt. Includes information about the\n" \ + "current expression number, evaluation context, and nesting\n" \ + "level, plus a reminder that you're using Pry." + }, + + "simple" => { + value: Pry::SIMPLE_PROMPT, + description: "A simple '>>'." + }, + + "nav" => { + value: Pry::NAV_PROMPT, + description: "A prompt that displays the binding stack as a path and\n" \ + "includes information about _in_ and _out_." + }, + + "none" => { + value: Pry::NO_PROMPT, + description: "Wave goodbye to the Pry prompt." + } + } +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_class.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_class.rb new file mode 100644 index 000000000..69f68e47f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_class.rb @@ -0,0 +1,375 @@ +require 'pry/config' +class Pry + + HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc" + LOCAL_RC_FILE = "./.pryrc" + + class << self + extend Forwardable + attr_accessor :custom_completions + attr_accessor :current_line + attr_accessor :line_buffer + attr_accessor :eval_path + attr_accessor :cli + attr_accessor :quiet + attr_accessor :last_internal_error + attr_accessor :config + attr_writer :history + + def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins + + extend Pry::Config::Convenience + config_shortcut(*Pry::Config.shortcuts) + + def prompt=(value) + config.prompt = value + end + + def prompt + config.prompt + end + + def history + @history ||= History.new + end + end + + # + # @return [main] + # returns the special instance of Object, "main". + # + def self.main + @main ||= TOPLEVEL_BINDING.eval "self" + end + + # + # @return [Pry::Config] + # Returns a value store for an instance of Pry running on the current thread. + # + def self.current + Thread.current[:__pry__] ||= Pry::Config.from_hash({}, nil) + end + + # Load the given file in the context of `Pry.toplevel_binding` + # @param [String] file The unexpanded file path. + def self.load_file_at_toplevel(file) + toplevel_binding.eval(File.read(file), file) + rescue RescuableException => e + puts "Error loading #{file}: #{e}\n#{e.backtrace.first}" + end + + # Load HOME_RC_FILE and LOCAL_RC_FILE if appropriate + # This method can also be used to reload the files if they have changed. + def self.load_rc_files + rc_files_to_load.each do |file| + critical_section do + load_file_at_toplevel(file) + end + end + end + + # Load the local RC file (./.pryrc) + def self.rc_files_to_load + files = [] + files << HOME_RC_FILE if Pry.config.should_load_rc + files << LOCAL_RC_FILE if Pry.config.should_load_local_rc + files.map { |file| real_path_to(file) }.compact.uniq + end + + # Expand a file to its canonical name (following symlinks as appropriate) + def self.real_path_to(file) + expanded = Pathname.new(File.expand_path(file)).realpath.to_s + # For rbx 1.9 mode [see rubinius issue #2165] + File.exist?(expanded) ? expanded : nil + rescue Errno::ENOENT + nil + end + + # Load any Ruby files specified with the -r flag on the command line. + def self.load_requires + Pry.config.requires.each do |file| + require file + end + end + + # Trap interrupts on jruby, and make them behave like MRI so we can + # catch them. + def self.load_traps + trap('INT'){ raise Interrupt } + end + + def self.load_win32console + begin + require 'win32console' + # The mswin and mingw versions of pry require win32console, so this should + # only fail on jruby (where win32console doesn't work). + # Instead we'll recommend ansicon, which does. + rescue LoadError + warn <<-WARNING if Pry.config.windows_console_warning +For a better Pry experience on Windows, please use ansicon: + https://github.com/adoxa/ansicon +If you use an alternative to ansicon and don't want to see this warning again, +you can add "Pry.config.windows_console_warning = false" to your .pryrc. + WARNING + end + end + + # Do basic setup for initial session. + # Including: loading .pryrc, loading plugins, loading requires, and + # loading history. + def self.initial_session_setup + return unless initial_session? + @initial_session = false + + # note these have to be loaded here rather than in pry_instance as + # we only want them loaded once per entire Pry lifetime. + load_rc_files + load_plugins if Pry.config.should_load_plugins + load_requires if Pry.config.should_load_requires + load_history if Pry.config.history.should_load + load_traps if Pry.config.should_trap_interrupts + load_win32console if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi? + end + + # Start a Pry REPL. + # This method also loads `~/.pryrc` and `./.pryrc` as necessary the + # first time it is invoked. + # @param [Object, Binding] target The receiver of the Pry session + # @param [Hash] options + # @option options (see Pry#initialize) + # @example + # Pry.start(Object.new, :input => MyInput.new) + def self.start(target=nil, options={}) + return if ENV['DISABLE_PRY'] + options = options.to_hash + + if in_critical_section? + output.puts "ERROR: Pry started inside Pry." + output.puts "This can happen if you have a binding.pry inside a #to_s or #inspect function." + return + end + + options[:target] = Pry.binding_for(target || toplevel_binding) + options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks) + initial_session_setup + + # Unless we were given a backtrace, save the current one + if options[:backtrace].nil? + options[:backtrace] = caller + + # If Pry was started via `binding.pry`, elide that from the backtrace + if options[:backtrace].first =~ /pry.*core_extensions.*pry/ + options[:backtrace].shift + end + end + + driver = options[:driver] || Pry::REPL + + # Enter the matrix + driver.start(options) + rescue Pry::TooSafeException + puts "ERROR: Pry cannot work with $SAFE > 0" + raise + end + + # Execute the file through the REPL loop, non-interactively. + # @param [String] file_name File name to load through the REPL. + def self.load_file_through_repl(file_name) + require "pry/repl_file_loader" + REPLFileLoader.new(file_name).load + end + + # + # An inspector that clips the output to `max_length` chars. + # In case of > `max_length` chars the `# notation is used. + # + # @param [Object] obj + # The object to view. + # + # @param [Hash] options + # @option options [Integer] :max_length (60) + # The maximum number of chars before clipping occurs. + # + # @option options [Boolean] :id (false) + # Boolean to indicate whether or not a hex reprsentation of the object ID + # is attached to the return value when the length of inspect is greater than + # value of `:max_length`. + # + # @return [String] + # The string representation of `obj`. + # + def self.view_clip(obj, options = {}) + max = options.fetch :max_length, 60 + id = options.fetch :id, false + if obj.kind_of?(Module) && obj.name.to_s != "" && obj.name.to_s.length <= max + obj.name.to_s + elsif Pry.main == obj + # special-case to support jruby. + # fixed as of https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039 + # we can drop in the future. + obj.to_s + elsif Pry.config.prompt_safe_objects.any? { |v| v === obj } && obj.inspect.length <= max + obj.inspect + else + id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>" + end + rescue RescuableException + "unknown" + end + + # Load Readline history if required. + def self.load_history + Pry.history.load + end + + # @return [Boolean] Whether this is the first time a Pry session has + # been started since loading the Pry class. + def self.initial_session? + @initial_session + end + + # Run a Pry command from outside a session. The commands available are + # those referenced by `Pry.config.commands` (the default command set). + # @param [String] command_string The Pry command (including arguments, + # if any). + # @param [Hash] options Optional named parameters. + # @return [Object] The return value of the Pry command. + # @option options [Object, Binding] :target The object to run the + # command under. Defaults to `TOPLEVEL_BINDING` (main). + # @option options [Boolean] :show_output Whether to show command + # output. Defaults to true. + # @example Run at top-level with no output. + # Pry.run_command "ls" + # @example Run under Pry class, returning only public methods. + # Pry.run_command "ls -m", :target => Pry + # @example Display command output. + # Pry.run_command "ls -av", :show_output => true + def self.run_command(command_string, options={}) + options = { + :target => TOPLEVEL_BINDING, + :show_output => true, + :output => Pry.config.output, + :commands => Pry.config.commands + }.merge!(options) + + # :context for compatibility with <= 0.9.11.4 + target = options[:context] || options[:target] + output = options[:show_output] ? options[:output] : StringIO.new + + pry = Pry.new(:output => output, :target => target, :commands => options[:commands]) + pry.eval command_string + end + + def self.default_editor_for_platform + return ENV['VISUAL'] if ENV['VISUAL'] and not ENV['VISUAL'].empty? + return ENV['EDITOR'] if ENV['EDITOR'] and not ENV['EDITOR'].empty? + if Helpers::BaseHelpers.windows? + 'notepad' + else + %w(editor nano vi).detect do |editor| + system("which #{editor} > /dev/null 2>&1") + end + end + end + + def self.auto_resize! + Pry.config.input # by default, load Readline + + if !defined?(Readline) || Pry.config.input != Readline + warn "Sorry, you must be using Readline for Pry.auto_resize! to work." + return + end + + if Readline::VERSION =~ /edit/i + warn <<-EOT +Readline version #{Readline::VERSION} detected - will not auto_resize! correctly. + For the fix, use GNU Readline instead: + https://github.com/guard/guard/wiki/Add-proper-Readline-support-to-Ruby-on-Mac-OS-X + EOT + return + end + + trap :WINCH do + begin + Readline.set_screen_size(*Terminal.size!) + rescue => e + warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}" + end + begin + Readline.refresh_line + rescue => e + warn "\nPry.auto_resize!'s Readline.refresh_line failed: #{e}" + end + end + end + + # Set all the configurable options back to their default values + def self.reset_defaults + @initial_session = true + self.config = Pry::Config.new Pry::Config::Default.new + self.cli = false + self.current_line = 1 + self.line_buffer = [""] + self.eval_path = "(pry)" + end + + # Basic initialization. + def self.init + @plugin_manager ||= PluginManager.new + reset_defaults + locate_plugins + end + + # Return a `Binding` object for `target` or return `target` if it is + # already a `Binding`. + # In the case where `target` is top-level then return `TOPLEVEL_BINDING` + # @param [Object] target The object to get a `Binding` object for. + # @return [Binding] The `Binding` object. + def self.binding_for(target) + if Binding === target + target + else + if Pry.main == target + TOPLEVEL_BINDING + else + target.__binding__ + end + end + end + + def self.toplevel_binding + unless defined?(@toplevel_binding) && @toplevel_binding + # Grab a copy of the TOPLEVEL_BINDING without any local variables. + # This binding has a default definee of Object, and new methods are + # private (just as in TOPLEVEL_BINDING). + TOPLEVEL_BINDING.eval <<-RUBY + def self.__pry__ + binding + end + Pry.toplevel_binding = __pry__ + class << self; undef __pry__; end + RUBY + end + @toplevel_binding.eval('private') + @toplevel_binding + end + + def self.toplevel_binding=(binding) + @toplevel_binding = binding + end + + def self.in_critical_section? + Thread.current[:pry_critical_section] ||= 0 + Thread.current[:pry_critical_section] > 0 + end + + def self.critical_section(&block) + Thread.current[:pry_critical_section] ||= 0 + Thread.current[:pry_critical_section] += 1 + yield + ensure + Thread.current[:pry_critical_section] -= 1 + end +end + +Pry.init diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_instance.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_instance.rb new file mode 100644 index 000000000..0877ab24d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/pry_instance.rb @@ -0,0 +1,664 @@ +# -*- coding: utf-8 -*- +## +# Pry is a powerful alternative to the standard IRB shell for Ruby. It +# features syntax highlighting, a flexible plugin architecture, runtime +# invocation and source and documentation browsing. +# +# Pry can be started similar to other command line utilities by simply running +# the following command: +# +# pry +# +# Once inside Pry you can invoke the help message: +# +# help +# +# This will show a list of available commands and their usage. For more +# information about Pry you can refer to the following resources: +# +# * http://pry.github.com/ +# * https://github.com/pry/pry +# * the IRC channel, which is #pry on the Freenode network +# + +class Pry + attr_accessor :binding_stack + attr_accessor :custom_completions + attr_accessor :eval_string + attr_accessor :backtrace + attr_accessor :suppress_output + attr_accessor :last_result + attr_accessor :last_file + attr_accessor :last_dir + + attr_reader :last_exception + attr_reader :command_state + attr_reader :exit_value + attr_reader :input_array + attr_reader :output_array + attr_reader :config + + extend Pry::Config::Convenience + config_shortcut(*Pry::Config.shortcuts) + EMPTY_COMPLETIONS = [].freeze + + # Create a new {Pry} instance. + # @param [Hash] options + # @option options [#readline] :input + # The object to use for input. + # @option options [#puts] :output + # The object to use for output. + # @option options [Pry::CommandBase] :commands + # The object to use for commands. + # @option options [Hash] :hooks + # The defined hook Procs. + # @option options [Array] :prompt + # The array of Procs to use for prompts. + # @option options [Proc] :print + # The Proc to use for printing return values. + # @option options [Boolean] :quiet + # Omit the `whereami` banner when starting. + # @option options [Array] :backtrace + # The backtrace of the session's `binding.pry` line, if applicable. + # @option options [Object] :target + # The initial context for this session. + def initialize(options={}) + @binding_stack = [] + @indent = Pry::Indent.new + @command_state = {} + @eval_string = "" + @backtrace = options.delete(:backtrace) || caller + target = options.delete(:target) + @config = Pry::Config.new + config.merge!(options) + push_prompt(config.prompt) + @input_array = Pry::HistoryArray.new config.memory_size + @output_array = Pry::HistoryArray.new config.memory_size + @custom_completions = config.command_completions + set_last_result nil + @input_array << nil + push_initial_binding(target) + exec_hook(:when_started, target, options, self) + end + + # The current prompt. + # This is the prompt at the top of the prompt stack. + # + # @example + # self.prompt = Pry::SIMPLE_PROMPT + # self.prompt # => Pry::SIMPLE_PROMPT + # + # @return [Array] Current prompt. + def prompt + prompt_stack.last + end + + def prompt=(new_prompt) + if prompt_stack.empty? + push_prompt new_prompt + else + prompt_stack[-1] = new_prompt + end + end + + # Initialize this instance by pushing its initial context into the binding + # stack. If no target is given, start at the top level. + def push_initial_binding(target=nil) + push_binding(target || Pry.toplevel_binding) + end + + # The currently active `Binding`. + # @return [Binding] The currently active `Binding` for the session. + def current_binding + binding_stack.last + end + alias current_context current_binding # support previous API + + # Push a binding for the given object onto the stack. If this instance is + # currently stopped, mark it as usable again. + def push_binding(object) + @stopped = false + binding_stack << Pry.binding_for(object) + end + + # + # Generate completions. + # + # @param [String] input + # What the user has typed so far + # + # @return [Array] + # Possible completions + # + def complete(str) + return EMPTY_COMPLETIONS unless config.completer + Pry.critical_section do + completer = config.completer.new(config.input, self) + completer.call str, target: current_binding, custom_completions: custom_completions.call.push(*sticky_locals.keys) + end + end + + # + # Injects a local variable into the provided binding. + # + # @param [String] name + # The name of the local to inject. + # + # @param [Object] value + # The value to set the local to. + # + # @param [Binding] b + # The binding to set the local on. + # + # @return [Object] + # The value the local was set to. + # + def inject_local(name, value, b) + value = Proc === value ? value.call : value + if b.respond_to?(:local_variable_set) + b.local_variable_set name, value + else # < 2.1 + begin + Pry.current[:pry_local] = value + b.eval "#{name} = ::Pry.current[:pry_local]" + ensure + Pry.current[:pry_local] = nil + end + end + end + + undef :memory_size if method_defined? :memory_size + # @return [Integer] The maximum amount of objects remembered by the inp and + # out arrays. Defaults to 100. + def memory_size + @output_array.max_size + end + + undef :memory_size= if method_defined? :memory_size= + def memory_size=(size) + @input_array = Pry::HistoryArray.new(size) + @output_array = Pry::HistoryArray.new(size) + end + + # Inject all the sticky locals into the current binding. + def inject_sticky_locals! + sticky_locals.each_pair do |name, value| + inject_local(name, value, current_binding) + end + end + + # Add a sticky local to this Pry instance. + # A sticky local is a local that persists between all bindings in a session. + # @param [Symbol] name The name of the sticky local. + # @yield The block that defines the content of the local. The local + # will be refreshed at each tick of the repl loop. + def add_sticky_local(name, &block) + config.extra_sticky_locals[name] = block + end + + def sticky_locals + { _in_: input_array, + _out_: output_array, + _pry_: self, + _ex_: last_exception && last_exception.wrapped_exception, + _file_: last_file, + _dir_: last_dir, + _: proc { last_result }, + __: proc { output_array[-2] } + }.merge(config.extra_sticky_locals) + end + + # Reset the current eval string. If the user has entered part of a multiline + # expression, this discards that input. + def reset_eval_string + @eval_string = "" + end + + # Pass a line of input to Pry. + # + # This is the equivalent of `Binding#eval` but with extra Pry! + # + # In particular: + # 1. Pry commands will be executed immediately if the line matches. + # 2. Partial lines of input will be queued up until a complete expression has + # been accepted. + # 3. Output is written to `#output` in pretty colours, not returned. + # + # Once this method has raised an exception or returned false, this instance + # is no longer usable. {#exit_value} will return the session's breakout + # value if applicable. + # + # @param [String?] line The line of input; `nil` if the user types `` + # @option options [Boolean] :generated Whether this line was generated automatically. + # Generated lines are not stored in history. + # @return [Boolean] Is Pry ready to accept more input? + # @raise [Exception] If the user uses the `raise-up` command, this method + # will raise that exception. + def eval(line, options={}) + return false if @stopped + + exit_value = nil + exception = catch(:raise_up) do + exit_value = catch(:breakout) do + handle_line(line, options) + # We use 'return !@stopped' here instead of 'return true' so that if + # handle_line has stopped this pry instance (e.g. by opening _pry_.repl and + # then popping all the bindings) we still exit immediately. + return !@stopped + end + exception = false + end + + @stopped = true + @exit_value = exit_value + + # TODO: make this configurable? + raise exception if exception + return false + end + + def handle_line(line, options) + if line.nil? + config.control_d_handler.call(@eval_string, self) + return + end + + ensure_correct_encoding!(line) + Pry.history << line unless options[:generated] + + @suppress_output = false + inject_sticky_locals! + begin + if !process_command_safely(line.lstrip) + @eval_string << "#{line.chomp}\n" if !line.empty? || !@eval_string.empty? + end + rescue RescuableException => e + self.last_exception = e + result = e + + Pry.critical_section do + show_result(result) + end + return + end + + # This hook is supposed to be executed after each line of ruby code + # has been read (regardless of whether eval_string is yet a complete expression) + exec_hook :after_read, eval_string, self + + begin + complete_expr = Pry::Code.complete_expression?(@eval_string) + rescue SyntaxError => e + output.puts "SyntaxError: #{e.message.sub(/.*syntax error, */m, '')}" + reset_eval_string + end + + if complete_expr + if @eval_string =~ /;\Z/ || @eval_string.empty? || @eval_string =~ /\A *#.*\n\z/ + @suppress_output = true + end + + # A bug in jruby makes java.lang.Exception not rescued by + # `rescue Pry::RescuableException` clause. + # + # * https://github.com/pry/pry/issues/854 + # * https://jira.codehaus.org/browse/JRUBY-7100 + # + # Until that gets fixed upstream, treat java.lang.Exception + # as an additional exception to be rescued explicitly. + # + # This workaround has a side effect: java exceptions specified + # in `Pry.config.exception_whitelist` are ignored. + jruby_exceptions = [] + if Pry::Helpers::BaseHelpers.jruby? + jruby_exceptions << Java::JavaLang::Exception + end + + begin + # Reset eval string, in case we're evaluating Ruby that does something + # like open a nested REPL on this instance. + eval_string = @eval_string + reset_eval_string + + result = evaluate_ruby(eval_string) + rescue RescuableException, *jruby_exceptions => e + # Eliminate following warning: + # warning: singleton on non-persistent Java type X + # (http://wiki.jruby.org/Persistence) + if Pry::Helpers::BaseHelpers.jruby? && e.class.respond_to?('__persistent__') + e.class.__persistent__ = true + end + self.last_exception = e + result = e + end + + Pry.critical_section do + show_result(result) + end + end + + throw(:breakout) if current_binding.nil? + end + private :handle_line + + # Potentially deprecated — Use `Pry::REPL.new(pry, :target => target).start` + # (If nested sessions are going to exist, this method is fine, but a goal is + # to come up with an alternative to nested sessions altogether.) + def repl(target = nil) + Pry::REPL.new(self, :target => target).start + end + + def evaluate_ruby(code) + inject_sticky_locals! + exec_hook :before_eval, code, self + + result = current_binding.eval(code, Pry.eval_path, Pry.current_line) + set_last_result(result, code) + ensure + update_input_history(code) + exec_hook :after_eval, result, self + end + + # Output the result or pass to an exception handler (if result is an exception). + def show_result(result) + if last_result_is_exception? + exception_handler.call(output, result, self) + elsif should_print? + print.call(output, result, self) + else + # nothin' + end + rescue RescuableException => e + # Being uber-paranoid here, given that this exception arose because we couldn't + # serialize something in the user's program, let's not assume we can serialize + # the exception either. + begin + output.puts "(pry) output error: #{e.inspect}" + rescue RescuableException => e + if last_result_is_exception? + output.puts "(pry) output error: failed to show exception" + else + output.puts "(pry) output error: failed to show result" + end + end + ensure + output.flush if output.respond_to?(:flush) + end + + # Force `eval_string` into the encoding of `val`. [Issue #284] + def ensure_correct_encoding!(val) + if @eval_string.empty? && + val.respond_to?(:encoding) && + val.encoding != @eval_string.encoding + @eval_string.force_encoding(val.encoding) + end + end + private :ensure_correct_encoding! + + # If the given line is a valid command, process it in the context of the + # current `eval_string` and binding. + # @param [String] val The line to process. + # @return [Boolean] `true` if `val` is a command, `false` otherwise + def process_command(val) + val = val.chomp + result = commands.process_line(val, + :target => current_binding, + :output => output, + :eval_string => @eval_string, + :pry_instance => self + ) + + # set a temporary (just so we can inject the value we want into eval_string) + Pry.current[:pry_cmd_result] = result + + # note that `result` wraps the result of command processing; if a + # command was matched and invoked then `result.command?` returns true, + # otherwise it returns false. + if result.command? + if !result.void_command? + # the command that was invoked was non-void (had a return value) and so we make + # the value of the current expression equal to the return value + # of the command. + @eval_string.replace "::Pry.current[:pry_cmd_result].retval\n" + end + true + else + false + end + end + + # Same as process_command, but outputs exceptions to `#output` instead of + # raising. + # @param [String] val The line to process. + # @return [Boolean] `true` if `val` is a command, `false` otherwise + def process_command_safely(val) + process_command(val) + rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e + Pry.last_internal_error = e + output.puts "Error: #{e.message}" + true + end + + # Run the specified command. + # @param [String] val The command (and its params) to execute. + # @return [Pry::Command::VOID_VALUE] + # @example + # pry_instance.run_command("ls -m") + def run_command(val) + commands.process_line(val, + :eval_string => @eval_string, + :target => current_binding, + :pry_instance => self, + :output => output + ) + Pry::Command::VOID_VALUE + end + + # Execute the specified hook. + # @param [Symbol] name The hook name to execute + # @param [*Object] args The arguments to pass to the hook + # @return [Object, Exception] The return value of the hook or the exception raised + # + # If executing a hook raises an exception, we log that and then continue sucessfully. + # To debug such errors, use the global variable $pry_hook_error, which is set as a + # result. + def exec_hook(name, *args, &block) + e_before = hooks.errors.size + hooks.exec_hook(name, *args, &block).tap do + hooks.errors[e_before..-1].each do |e| + output.puts "#{name} hook failed: #{e.class}: #{e.message}" + output.puts "#{e.backtrace.first}" + output.puts "(see _pry_.hooks.errors to debug)" + end + end + end + + # Set the last result of an eval. + # This method should not need to be invoked directly. + # @param [Object] result The result. + # @param [String] code The code that was run. + def set_last_result(result, code="") + @last_result_is_exception = false + @output_array << result + + self.last_result = result unless code =~ /\A\s*\z/ + end + + # + # Set the last exception for a session. + # + # @param [Exception] e + # the last exception. + # + def last_exception=(e) + last_exception = Pry::LastException.new(e) + @last_result_is_exception = true + @output_array << last_exception + @last_exception = last_exception + end + + # Update Pry's internal state after evalling code. + # This method should not need to be invoked directly. + # @param [String] code The code we just eval'd + def update_input_history(code) + # Always push to the @input_array as the @output_array is always pushed to. + @input_array << code + if code + Pry.line_buffer.push(*code.each_line) + Pry.current_line += code.lines.count + end + end + + # @return [Boolean] True if the last result is an exception that was raised, + # as opposed to simply an instance of Exception (like the result of + # Exception.new) + def last_result_is_exception? + @last_result_is_exception + end + + # Whether the print proc should be invoked. + # Currently only invoked if the output is not suppressed. + # @return [Boolean] Whether the print proc should be invoked. + def should_print? + !@suppress_output + end + + # Returns the appropriate prompt to use. + # @return [String] The prompt. + def select_prompt + object = current_binding.eval('self') + + open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last : + @indent.stack.last + + c = Pry::Config.from_hash({ + :object => object, + :nesting_level => binding_stack.size - 1, + :open_token => open_token, + :session_line => Pry.history.session_line_count + 1, + :history_line => Pry.history.history_line_count + 1, + :expr_number => input_array.count, + :_pry_ => self, + :binding_stack => binding_stack, + :input_array => input_array, + :eval_string => @eval_string, + :cont => !@eval_string.empty?}) + + Pry.critical_section do + # If input buffer is empty then use normal prompt + if eval_string.empty? + generate_prompt(Array(prompt).first, c) + + # Otherwise use the wait prompt (indicating multi-line expression) + else + generate_prompt(Array(prompt).last, c) + end + end + end + + def generate_prompt(prompt_proc, conf) + if prompt_proc.arity == 1 + prompt_proc.call(conf) + else + prompt_proc.call(conf.object, conf.nesting_level, conf._pry_) + end + end + private :generate_prompt + + # the array that the prompt stack is stored in + def prompt_stack + @prompt_stack ||= Array.new + end + private :prompt_stack + + # Pushes the current prompt onto a stack that it can be restored from later. + # Use this if you wish to temporarily change the prompt. + # @param [Array] new_prompt + # @return [Array] new_prompt + # @example + # new_prompt = [ proc { '>' }, proc { '>>' } ] + # push_prompt(new_prompt) # => new_prompt + def push_prompt(new_prompt) + prompt_stack.push new_prompt + end + + # Pops the current prompt off of the prompt stack. + # If the prompt you are popping is the last prompt, it will not be popped. + # Use this to restore the previous prompt. + # @return [Array] Prompt being popped. + # @example + # prompt1 = [ proc { '>' }, proc { '>>' } ] + # prompt2 = [ proc { '$' }, proc { '>' } ] + # pry = Pry.new :prompt => prompt1 + # pry.push_prompt(prompt2) + # pry.pop_prompt # => prompt2 + # pry.pop_prompt # => prompt1 + # pry.pop_prompt # => prompt1 + def pop_prompt + prompt_stack.size > 1 ? prompt_stack.pop : prompt + end + + undef :pager if method_defined? :pager + # Returns the currently configured pager + # @example + # _pry_.pager.page text + def pager + Pry::Pager.new(self) + end + + undef :output if method_defined? :output + # Returns an output device + # @example + # _pry_.output.puts "ohai!" + def output + Pry::Output.new(self) + end + + # Raise an exception out of Pry. + # + # See Kernel#raise for documentation of parameters. + # See rb_make_exception for the inbuilt implementation. + # + # This is necessary so that the raise-up command can tell the + # difference between an exception the user has decided to raise, + # and a mistake in specifying that exception. + # + # (i.e. raise-up RunThymeError.new should not be the same as + # raise-up NameError, "unititialized constant RunThymeError") + # + def raise_up_common(force, *args) + exception = if args == [] + last_exception || RuntimeError.new + elsif args.length == 1 && args.first.is_a?(String) + RuntimeError.new(args.first) + elsif args.length > 3 + raise ArgumentError, "wrong number of arguments" + elsif !args.first.respond_to?(:exception) + raise TypeError, "exception class/object expected" + elsif args.length === 1 + args.first.exception + else + args.first.exception(args[1]) + end + + raise TypeError, "exception object expected" unless exception.is_a? Exception + + exception.set_backtrace(args.length === 3 ? args[2] : caller(1)) + + if force || binding_stack.one? + binding_stack.clear + throw :raise_up, exception + else + binding_stack.pop + raise exception + end + end + def raise_up(*args); raise_up_common(false, *args); end + def raise_up!(*args); raise_up_common(true, *args); end + + # Convenience accessor for the `quiet` config key. + # @return [Boolean] + def quiet? + config.quiet + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rbx_path.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rbx_path.rb new file mode 100644 index 000000000..bd969c6ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rbx_path.rb @@ -0,0 +1,22 @@ +class Pry + module RbxPath + module_function + def is_core_path?(path) + Pry::Helpers::BaseHelpers.rbx? && (path.start_with?("kernel") || path.start_with?("lib")) && File.exist?(convert_path_to_full(path)) + end + + def convert_path_to_full(path) + if path.start_with?("kernel") + File.join File.dirname(Rubinius::KERNEL_PATH), path + elsif path.start_with?("lib") + File.join File.dirname(Rubinius::LIB_PATH), path + else + path + end + end + + def rvm_ruby?(path) + !!(path =~ /\.rvm/) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl.rb new file mode 100644 index 000000000..4748785a8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl.rb @@ -0,0 +1,202 @@ +require 'forwardable' + +class Pry + class REPL + extend Forwardable + def_delegators :@pry, :input, :output + + # @return [Pry] The instance of {Pry} that the user is controlling. + attr_accessor :pry + + # Instantiate a new {Pry} instance with the given options, then start a + # {REPL} instance wrapping it. + # @option options See {Pry#initialize} + def self.start(options) + new(Pry.new(options)).start + end + + # Create an instance of {REPL} wrapping the given {Pry}. + # @param [Pry] pry The instance of {Pry} that this {REPL} will control. + # @param [Hash] options Options for this {REPL} instance. + # @option options [Object] :target The initial target of the session. + def initialize(pry, options = {}) + @pry = pry + @indent = Pry::Indent.new + + if options[:target] + @pry.push_binding options[:target] + end + end + + # Start the read-eval-print loop. + # @return [Object?] If the session throws `:breakout`, return the value + # thrown with it. + # @raise [Exception] If the session throws `:raise_up`, raise the exception + # thrown with it. + def start + prologue + Pry::InputLock.for(:all).with_ownership { repl } + ensure + epilogue + end + + private + + # Set up the repl session. + # @return [void] + def prologue + pry.exec_hook :before_session, pry.output, pry.current_binding, pry + + # Clear the line before starting Pry. This fixes issue #566. + if pry.config.correct_indent + Kernel.print Pry::Helpers::BaseHelpers.windows_ansi? ? "\e[0F" : "\e[0G" + end + end + + # The actual read-eval-print loop. + # + # The {REPL} instance is responsible for reading and looping, whereas the + # {Pry} instance is responsible for evaluating user input and printing + # return values and command output. + # + # @return [Object?] If the session throws `:breakout`, return the value + # thrown with it. + # @raise [Exception] If the session throws `:raise_up`, raise the exception + # thrown with it. + def repl + loop do + case val = read + when :control_c + output.puts "" + pry.reset_eval_string + when :no_more_input + output.puts "" if output.tty? + break + else + output.puts "" if val.nil? && output.tty? + return pry.exit_value unless pry.eval(val) + end + end + end + + # Clean up after the repl session. + # @return [void] + def epilogue + pry.exec_hook :after_session, pry.output, pry.current_binding, pry + end + + # Read a line of input from the user. + # @return [String] The line entered by the user. + # @return [nil] On ``. + # @return [:control_c] On ``. + # @return [:no_more_input] On EOF. + def read + @indent.reset if pry.eval_string.empty? + current_prompt = pry.select_prompt + indentation = pry.config.auto_indent ? @indent.current_prefix : '' + + val = read_line("#{current_prompt}#{indentation}") + + # Return nil for EOF, :no_more_input for error, or :control_c for + return val unless String === val + + if pry.config.auto_indent + original_val = "#{indentation}#{val}" + indented_val = @indent.indent(val) + + if output.tty? && pry.config.correct_indent && Pry::Helpers::BaseHelpers.use_ansi_codes? + output.print @indent.correct_indentation( + current_prompt, indented_val, + original_val.length - indented_val.length + ) + output.flush + end + else + indented_val = val + end + + indented_val + end + + # Manage switching of input objects on encountering `EOFError`s. + # @return [Object] Whatever the given block returns. + # @return [:no_more_input] Indicates that no more input can be read. + def handle_read_errors + should_retry = true + exception_count = 0 + + begin + yield + rescue EOFError + pry.config.input = Pry.config.input + if !should_retry + output.puts "Error: Pry ran out of things to read from! " \ + "Attempting to break out of REPL." + return :no_more_input + end + should_retry = false + retry + + # Handle like Bash: empty the current input buffer, but don't + # quit. This is only for MRI 1.9; other versions of Ruby don't let you + # send Interrupt from within Readline. + rescue Interrupt + return :control_c + + # If we get a random error when trying to read a line we don't want to + # automatically retry, as the user will see a lot of error messages + # scroll past and be unable to do anything about it. + rescue RescuableException => e + puts "Error: #{e.message}" + output.puts e.backtrace + exception_count += 1 + if exception_count < 5 + retry + end + puts "FATAL: Pry failed to get user input using `#{input}`." + puts "To fix this you may be able to pass input and output file " \ + "descriptors to pry directly. e.g." + puts " Pry.config.input = STDIN" + puts " Pry.config.output = STDOUT" + puts " binding.pry" + return :no_more_input + end + end + + # Returns the next line of input to be sent to the {Pry} instance. + # @param [String] current_prompt The prompt to use for input. + # @return [String?] The next line of input, or `nil` on . + def read_line(current_prompt) + handle_read_errors do + if defined? Coolline and input.is_a? Coolline + input.completion_proc = proc do |cool| + completions = @pry.complete cool.completed_word + completions.compact + end + elsif input.respond_to? :completion_proc= + input.completion_proc = proc do |input| + @pry.complete input + end + end + + if defined?(Readline) and input == Readline + input_readline(current_prompt, false) # false since we'll add it manually + elsif defined? Coolline and input.is_a? Coolline + input_readline(current_prompt) + else + if input.method(:readline).arity == 1 + input_readline(current_prompt) + else + input_readline + end + end + end + end + + def input_readline(*args) + Pry::InputLock.for(:all).interruptible_region do + input.readline(*args) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl_file_loader.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl_file_loader.rb new file mode 100644 index 000000000..cd8de9a14 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/repl_file_loader.rb @@ -0,0 +1,74 @@ +class Pry + + # A class to manage the loading of files through the REPL loop. + # This is an interesting trick as it processes your file as if it + # was user input in an interactive session. As a result, all Pry + # commands are available, and they are executed non-interactively. Furthermore + # the session becomes interactive when the repl loop processes a + # 'make-interactive' command in the file. The session also becomes + # interactive when an exception is encountered, enabling you to fix + # the error before returning to non-interactive processing with the + # 'make-non-interactive' command. + + class REPLFileLoader + def initialize(file_name) + full_name = File.expand_path(file_name) + raise RuntimeError, "No such file: #{full_name}" if !File.exists?(full_name) + + define_additional_commands + @content = File.read(full_name) + end + + # Switch to interactive mode, i.e take input from the user + # and use the regular print and exception handlers. + # @param [Pry] _pry_ the Pry instance to make interactive. + def interactive_mode(_pry_) + _pry_.config.input = Pry.config.input + _pry_.config.print = Pry.config.print + _pry_.config.exception_handler = Pry.config.exception_handler + Pry::REPL.new(_pry_).start + end + + # Switch to non-interactive mode. Essentially + # this means there is no result output + # and that the session becomes interactive when an exception is encountered. + # @param [Pry] _pry_ the Pry instance to make non-interactive. + def non_interactive_mode(_pry_, content) + _pry_.print = proc {} + _pry_.exception_handler = proc do |o, e, _p_| + _p_.run_command "cat --ex" + o.puts "...exception encountered, going interactive!" + interactive_mode(_pry_) + end + + content.lines.each do |line| + break unless _pry_.eval line, :generated => true + end + + unless _pry_.eval_string.empty? + _pry_.output.puts "#{_pry_.eval_string}...exception encountered, going interactive!" + interactive_mode(_pry_) + end + end + + # Define a few extra commands useful for flipping back & forth + # between interactive/non-interactive modes + def define_additional_commands + s = self + + Pry::Commands.command "make-interactive", "Make the session interactive" do + s.interactive_mode(_pry_) + end + + Pry::Commands.command "load-file", "Load another file through the repl" do |file_name| + s.non_interactive_mode(_pry_, File.read(File.expand_path(file_name))) + end + end + + # Actually load the file through the REPL by setting file content + # as the REPL input stream. + def load + non_interactive_mode(Pry.new, @content) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rubygem.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rubygem.rb new file mode 100644 index 000000000..36f788da8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/rubygem.rb @@ -0,0 +1,82 @@ +require 'rubygems' + +class Pry + module Rubygem + + class << self + def installed?(name) + if Gem::Specification.respond_to?(:find_all_by_name) + Gem::Specification.find_all_by_name(name).any? + else + Gem.source_index.find_name(name).first + end + end + + # Get the gem spec object for the given gem name. + # + # @param [String] name + # @return [Gem::Specification] + def spec(name) + specs = if Gem::Specification.respond_to?(:each) + Gem::Specification.find_all_by_name(name) + else + Gem.source_index.find_name(name) + end + + first_spec = specs.sort_by{ |spec| Gem::Version.new(spec.version) }.last + + first_spec or raise CommandError, "Gem `#{name}` not found" + end + + # List gems matching a pattern. + # + # @param [Regexp] pattern + # @return [Array] + def list(pattern = /.*/) + if Gem::Specification.respond_to?(:each) + Gem::Specification.select{|spec| spec.name =~ pattern } + else + Gem.source_index.gems.values.select{|spec| spec.name =~ pattern } + end + end + + # Completion function for gem-cd and gem-open. + # + # @param [String] so_far what the user's typed so far + # @return [Array] completions + def complete(so_far) + if so_far =~ / ([^ ]*)\z/ + self.list(%r{\A#{$2}}).map(&:name) + else + self.list.map(&:name) + end + end + + # Installs a gem with all its dependencies. + # + # @param [String] name + # @return [void] + def install(name) + gemrc_opts = Gem.configuration['gem'].split(' ') + destination = if gemrc_opts.include?('--user-install') + Gem.user_dir + elsif File.writable?(Gem.dir) + Gem.dir + else + Gem.user_dir + end + installer = Gem::DependencyInstaller.new(:install_dir => destination) + installer.install(name) + rescue Errno::EACCES + raise CommandError, + "Insufficient permissions to install #{ Pry::Helpers::Text.green(name) }." + rescue Gem::GemNotFoundException + raise CommandError, + "Gem #{ Pry::Helpers::Text.green(name) } not found. Aborting installation." + else + Gem.refresh + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/terminal.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/terminal.rb new file mode 100644 index 000000000..d04f7bd10 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/terminal.rb @@ -0,0 +1,79 @@ +class Pry::Terminal + class << self + # Return a pair of [rows, columns] which gives the size of the window. + # + # If the window size cannot be determined, return nil. + def screen_size + rows, cols = actual_screen_size + if rows.to_i != 0 && cols.to_i != 0 + [rows.to_i, cols.to_i] + else + nil + end + end + + # Return a screen size or a default if that fails. + def size! default = [27, 80] + screen_size || default + end + + # Return a screen width or the default if that fails. + def width! + size![1] + end + + # Return a screen height or the default if that fails. + def height! + size![0] + end + + def actual_screen_size + # The best way, if possible (requires non-jruby ≥1.9 or io-console gem) + screen_size_according_to_io_console or + # Fall back to the old standby, though it might be stale: + screen_size_according_to_env or + # Fall further back, though this one is also out of date without something + # calling Readline.set_screen_size + screen_size_according_to_readline or + # Windows users can otherwise run ansicon and get a decent answer: + screen_size_according_to_ansicon_env + end + + def screen_size_according_to_io_console + return if Pry::Helpers::BaseHelpers.jruby? + require 'io/console' + $stdout.winsize if $stdout.tty? and $stdout.respond_to?(:winsize) + rescue LoadError + # They probably don't have the io/console stdlib or the io-console gem. + # We'll keep trying. + end + + def screen_size_according_to_env + size = [ENV['LINES'] || ENV['ROWS'], ENV['COLUMNS']] + size if nonzero_column?(size) + end + + def screen_size_according_to_readline + if defined?(Readline) && Readline.respond_to?(:get_screen_size) + size = Readline.get_screen_size + size if nonzero_column?(size) + end + rescue Java::JavaLang::NullPointerException + # This rescue won't happen on jrubies later than: + # https://github.com/jruby/jruby/pull/436 + nil + end + + def screen_size_according_to_ansicon_env + return unless ENV['ANSICON'] =~ /\((.*)x(.*)\)/ + size = [$2, $1] + size if nonzero_column?(size) + end + + private + + def nonzero_column?(size) + size[1].to_i > 0 + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/test/helper.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/test/helper.rb new file mode 100644 index 000000000..8ddf14462 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/test/helper.rb @@ -0,0 +1,170 @@ +require 'pry' + +# in case the tests call reset_defaults, ensure we reset them to +# amended (test friendly) values +class << Pry + alias_method :orig_reset_defaults, :reset_defaults + def reset_defaults + orig_reset_defaults + + Pry.config.color = false + Pry.config.pager = false + Pry.config.should_load_rc = false + Pry.config.should_load_local_rc= false + Pry.config.should_load_plugins = false + Pry.config.history.should_load = false + Pry.config.history.should_save = false + Pry.config.correct_indent = false + Pry.config.hooks = Pry::Hooks.new + Pry.config.collision_warning = false + end +end +Pry.reset_defaults + +# A global space for storing temporary state during tests. + +module PryTestHelpers + + module_function + + # inject a variable into a binding + def inject_var(name, value, b) + Pry.current[:pry_local] = value + b.eval("#{name} = ::Pry.current[:pry_local]") + ensure + Pry.current[:pry_local] = nil + end + + def constant_scope(*names) + names.each do |name| + Object.remove_const name if Object.const_defined?(name) + end + + yield + ensure + names.each do |name| + Object.remove_const name if Object.const_defined?(name) + end + end + + # Open a temp file and yield it to the block, closing it after + # @return [String] The path of the temp file + def temp_file(ext='.rb') + file = Tempfile.new(['pry', ext]) + yield file + ensure + file.close(true) if file + File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx + end + + def unindent(*args) + Pry::Helpers::CommandHelpers.unindent(*args) + end + + def mock_command(cmd, args=[], opts={}) + output = StringIO.new + pry = Pry.new(output: output) + ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args) + Struct.new(:output, :return).new(output.string, ret) + end + + def mock_exception(*mock_backtrace) + StandardError.new.tap do |e| + e.define_singleton_method(:backtrace) { mock_backtrace } + end + end +end + +def pry_tester(*args, &block) + if args.length == 0 || args[0].is_a?(Hash) + args.unshift(Pry.toplevel_binding) + end + + PryTester.new(*args).tap do |t| + (class << t; self; end).class_eval(&block) if block + end +end + +def pry_eval(*eval_strs) + if eval_strs.first.is_a? String + binding = Pry.toplevel_binding + else + binding = Pry.binding_for(eval_strs.shift) + end + + pry_tester(binding).eval(*eval_strs) +end + +class PryTester + extend Forwardable + + attr_reader :pry, :out + + def_delegators :@pry, :eval_string, :eval_string= + + def initialize(target = TOPLEVEL_BINDING, options = {}) + @pry = Pry.new(options.merge(:target => target)) + @history = options[:history] + + @pry.inject_sticky_locals! + reset_output + end + + def eval(*strs) + reset_output + result = nil + + strs.flatten.each do |str| + str = "#{str.strip}\n" + @history.push str if @history + + if @pry.process_command(str) + result = last_command_result_or_output + else + result = @pry.evaluate_ruby(str) + end + end + + result + end + + def push(*lines) + Array(lines).flatten.each do |line| + @pry.eval(line) + end + end + + def push_binding(context) + @pry.push_binding context + end + + def last_output + @out.string if @out + end + + def process_command(command_str) + @pry.process_command(command_str) or raise "Not a valid command" + last_command_result_or_output + end + + def last_command_result + result = Pry.current[:pry_cmd_result] + result.retval if result + end + + protected + + def last_command_result_or_output + result = last_command_result + if result != Pry::Command::VOID_VALUE + result + else + last_output + end + end + + def reset_output + @out = StringIO.new + @pry.output = @out + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/version.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/version.rb new file mode 100644 index 000000000..547171e04 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/version.rb @@ -0,0 +1,3 @@ +class Pry + VERSION = "0.10.1" +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/wrapped_module.rb b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/wrapped_module.rb new file mode 100644 index 000000000..bfa5793f6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-0.10.1/lib/pry/wrapped_module.rb @@ -0,0 +1,377 @@ +require 'pry/module_candidate' + +class Pry + class << self + # If the given object is a `Pry::WrappedModule`, return it unaltered. If it's + # anything else, return it wrapped in a `Pry::WrappedModule` instance. + def WrappedModule(obj) + if obj.is_a? Pry::WrappedModule + obj + else + Pry::WrappedModule.new(obj) + end + end + end + + class WrappedModule + include Helpers::BaseHelpers + include CodeObject::Helpers + + attr_reader :wrapped + + # Convert a string to a module. + # + # @param [String] mod_name + # @param [Binding] target The binding where the lookup takes place. + # @return [Module, nil] The module or `nil` (if conversion failed). + # @example + # Pry::WrappedModule.from_str("Pry::Code") + def self.from_str(mod_name, target=TOPLEVEL_BINDING) + if safe_to_evaluate?(mod_name, target) + Pry::WrappedModule.new(target.eval(mod_name)) + else + nil + end + rescue RescuableException + nil + end + + class << self + private + + # We use this method to decide whether code is safe to eval. Method's are + # generally not, but everything else is. + # TODO: is just checking != "method" enough?? + # TODO: see duplication of this method in Pry::CodeObject + # @param [String] str The string to lookup. + # @param [Binding] target Where the lookup takes place. + # @return [Boolean] + def safe_to_evaluate?(str, target) + return true if str.strip == "self" + kind = target.eval("defined?(#{str})") + kind =~ /variable|constant/ + end + end + + # @raise [ArgumentError] if the argument is not a `Module` + # @param [Module] mod + def initialize(mod) + raise ArgumentError, "Tried to initialize a WrappedModule with a non-module #{mod.inspect}" unless ::Module === mod + @wrapped = mod + @memoized_candidates = [] + @host_file_lines = nil + @source = nil + @source_location = nil + @doc = nil + end + + # Returns an array of the names of the constants accessible in the wrapped + # module. This avoids the problem of accidentally calling the singleton + # method `Module.constants`. + # @param [Boolean] inherit Include the names of constants from included + # modules? + def constants(inherit = true) + Module.instance_method(:constants).bind(@wrapped).call(inherit) + end + + # The prefix that would appear before methods defined on this class. + # + # i.e. the "String." or "String#" in String.new and String#initialize. + # + # @return String + def method_prefix + if singleton_class? + if Module === singleton_instance + "#{WrappedModule.new(singleton_instance).nonblank_name}." + else + "self." + end + else + "#{nonblank_name}#" + end + end + + # The name of the Module if it has one, otherwise #. + # + # @return [String] + def nonblank_name + if name.to_s == "" + wrapped.inspect + else + name + end + end + + # Is this a singleton class? + # @return [Boolean] + def singleton_class? + if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?) + Pry::Method.safe_send(wrapped, :singleton_class?) + elsif defined?(Rubinius) + # https://github.com/rubinius/rubinius/commit/2e71722dba53d1a92c54d5e3968d64d1042486fe singleton_class? added 30 Jul 2014 + # https://github.com/rubinius/rubinius/commit/4310f6b2ef3c8fc88135affe697db4e29e4621c4 has been around since 2011 + !!Rubinius::Type.singleton_class_object(wrapped) + else + wrapped != Pry::Method.safe_send(wrapped, :ancestors).first + end + end + + # Is this strictly a module? (does not match classes) + # @return [Boolean] + def module? + wrapped.instance_of?(Module) + end + + # Is this strictly a class? + # @return [Boolean] + def class? + wrapped.instance_of?(Class) + end + + # Get the instance associated with this singleton class. + # + # @raise ArgumentError: tried to get instance of non singleton class + # + # @return [Object] + def singleton_instance + raise ArgumentError, "tried to get instance of non singleton class" unless singleton_class? + + if Helpers::BaseHelpers.jruby? + wrapped.to_java.attached + else + @singleton_instance ||= ObjectSpace.each_object(wrapped).detect{ |x| (class << x; self; end) == wrapped } + end + end + + # Forward method invocations to the wrapped module + def method_missing(method_name, *args, &block) + wrapped.send(method_name, *args, &block) + end + + def respond_to?(method_name) + super || wrapped.respond_to?(method_name) + end + + # Retrieve the source location of a module. Return value is in same + # format as Method#source_location. If the source location + # cannot be found this method returns `nil`. + # + # @param [Module] mod The module (or class). + # @return [Array, nil] The source location of the + # module (or class), or `nil` if no source location found. + def source_location + @source_location ||= primary_candidate.source_location + rescue Pry::RescuableException + nil + end + + # @return [String, nil] The associated file for the module (i.e + # the primary candidate: highest ranked monkeypatch). + def file + Array(source_location).first + end + alias_method :source_file, :file + + # @return [Fixnum, nil] The associated line for the module (i.e + # the primary candidate: highest ranked monkeypatch). + def line + Array(source_location).last + end + alias_method :source_line, :line + + # Returns documentation for the module. + # This documentation is for the primary candidate, if + # you would like documentation for other candidates use + # `WrappedModule#candidate` to select the candidate you're + # interested in. + # @raise [Pry::CommandError] If documentation cannot be found. + # @return [String] The documentation for the module. + def doc + @doc ||= primary_candidate.doc + end + + # Returns the source for the module. + # This source is for the primary candidate, if + # you would like source for other candidates use + # `WrappedModule#candidate` to select the candidate you're + # interested in. + # @raise [Pry::CommandError] If source cannot be found. + # @return [String] The source for the module. + def source + @source ||= primary_candidate.source + end + + # @return [String] Return the associated file for the + # module from YARD, if one exists. + def yard_file + YARD::Registry.at(name).file if yard_docs? + end + + # @return [Fixnum] Return the associated line for the + # module from YARD, if one exists. + def yard_line + YARD::Registry.at(name).line if yard_docs? + end + + # @return [String] Return the YARD docs for this module. + def yard_doc + YARD::Registry.at(name).docstring.to_s if yard_docs? + end + + # Return a candidate for this module of specified rank. A `rank` + # of 0 is equivalent to the 'primary candidate', which is the + # module definition with the highest number of methods. A `rank` + # of 1 is the module definition with the second highest number of + # methods, and so on. Module candidates are necessary as modules + # can be reopened multiple times and in multiple places in Ruby, + # the candidate API gives you access to the module definition + # representing each of those reopenings. + # @raise [Pry::CommandError] If the `rank` is out of range. That + # is greater than `number_of_candidates - 1`. + # @param [Fixnum] rank + # @return [Pry::WrappedModule::Candidate] + def candidate(rank) + @memoized_candidates[rank] ||= Candidate.new(self, rank) + end + + # @return [Fixnum] The number of candidate definitions for the + # current module. + def number_of_candidates + method_candidates.count + end + + # @note On JRuby 1.9 and higher, in certain conditions, this method chucks + # away its ability to be quick (when there are lots of monkey patches, + # like in Rails). However, it should be efficient enough on other rubies. + # @see https://github.com/jruby/jruby/issues/525 + # @return [Enumerator, Array] on JRuby 1.9 and higher returns Array, on + # other rubies returns Enumerator + def candidates + enum = Enumerator.new do |y| + (0...number_of_candidates).each do |num| + y.yield candidate(num) + end + end + Pry::Helpers::BaseHelpers.jruby_19? ? enum.to_a : enum + end + + # @return [Boolean] Whether YARD docs are available for this module. + def yard_docs? + !!(defined?(YARD) && YARD::Registry.at(name)) + end + + # @param [Fixnum] times How far to travel up the ancestor chain. + # @return [Pry::WrappedModule, nil] The wrapped module that is the + # superclass. + # When `self` is a `Module` then return the + # nth ancestor, otherwise (in the case of classes) return the + # nth ancestor that is a class. + def super(times=1) + return self if times.zero? + + if wrapped.is_a?(Class) + sup = ancestors.select { |v| v.is_a?(Class) }[times] + else + sup = ancestors[times] + end + + Pry::WrappedModule(sup) if sup + end + + private + + # @return [Pry::WrappedModule::Candidate] The candidate with the + # highest rank, that is the 'monkey patch' of this module with the + # highest number of methods, which contains a source code line that + # defines the module. It is considered the 'canonical' definition + # for the module. In the absense of a suitable candidate, the + # candidate of rank 0 will be returned, or a CommandError raised if + # there are no candidates at all. + def primary_candidate + @primary_candidate ||= candidates.find { |c| c.file } || + # This will raise an exception if there is no candidate at all. + candidate(0) + end + + # @return [Array>] The array of `Pry::Method` objects, + # there are two associated with each candidate. The first is the 'base + # method' for a candidate and it serves as the start point for + # the search in uncovering the module definition. The second is + # the last method defined for that candidate and it is used to + # speed up source code extraction. + def method_candidates + @method_candidates ||= all_source_locations_by_popularity.map do |group| + methods_sorted_by_source_line = group.last.sort_by(&:source_line) + [methods_sorted_by_source_line.first, methods_sorted_by_source_line.last] + end + end + + # A helper method. + def all_source_locations_by_popularity + return @all_source_locations_by_popularity if @all_source_locations_by_popularity + + ims = all_relevant_methods_for(wrapped) + @all_source_locations_by_popularity = ims.group_by { |v| Array(v.source_location).first }. + sort_by do |path, methods| + expanded = File.expand_path(path) + load_order = $LOADED_FEATURES.index{ |file| expanded.end_with?(file) } + + [-methods.size, load_order || (1.0 / 0.0)] + end + end + + # We only want methods that have a non-nil `source_location`. We also + # skip some spooky internal methods. + # (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.) + # @return [Array] + def all_relevant_methods_for(mod) + methods = all_methods_for(mod).select(&:source_location). + reject{ |x| x.name == '__class_init__' || method_defined_by_forwardable_module?(x) } + + return methods unless methods.empty? + + safe_send(mod, :constants).map do |const_name| + if const = nested_module?(mod, const_name) + all_relevant_methods_for(const) + else + [] + end + end.flatten + end + + # Return all methods (instance methods and class methods) for a + # given module. + # @return [Array] + def all_methods_for(mod) + Pry::Method.all_from_obj(mod, false) + Pry::Method.all_from_class(mod, false) + end + + def nested_module?(parent, name) + return if safe_send(parent, :autoload?, name) + child = safe_send(parent, :const_get, name) + return unless Module === child + return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}" + child + end + + # Detect methods that are defined with `def_delegator` from the Forwardable + # module. We want to reject these methods as they screw up module + # extraction since the `source_location` for such methods points at forwardable.rb + # TODO: make this more robust as valid user-defined files called + # forwardable.rb are also skipped. + def method_defined_by_forwardable_module?(method) + method.source_location.first =~ /forwardable\.rb/ + end + + # memoized lines for file + def lines_for_file(file) + @lines_for_file ||= {} + + if file == Pry.eval_path + @lines_for_file[file] ||= Pry.line_buffer.drop(1) + else + @lines_for_file[file] ||= File.readlines(file) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/CHANGELOG.md b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/CHANGELOG.md new file mode 100644 index 000000000..762d63d86 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/CHANGELOG.md @@ -0,0 +1,134 @@ +## 3.2.0 (2015-07-18) + +- Improvements: + * Allow continue to receive a line number argument (#56). + * Refactorings + RuboCop. + * Up to date dependencies. + +- Bugfixes: + * Don't conflict with `break` and `next` Ruby keywords inside multiline +statements (#44). + +- Removals: + * `breaks` command. It was broken anyways (#47). + + +## 3.1.0 (2015-04-14) + +- Improvements: + * Add frame nav commands up, down and frame. + + +## 3.0.1 (2015-04-02) + +- Improvements: + * Fix several formatting and alignment issues. + + +## 3.0.0 (2015-02-02) + +- Improvements: + * Adds RuboCop to enforce a consistent code style. + * Several refactorings to keep code simpler. + +- Bugfixes: + * `binding.pry` would not stop at the correct place when called at the last +line of a method/block. + +- Removals: + * Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and +`continue` (`c`). See #34. + + +## 2.0.0 (2014-01-09) + +- Improvements: + * Compatibility with byebug 3 + * Now pry starts at the first line after binding.pry, not at binding.pry +- Bugfixes: + * 'continue' doesn't finish pry instance (issue #13) + + +## 1.3.3 (2014-25-06) + +* Relaxes pry dependency to support pry 0.10 series and further minor version +level releases. + + +## 1.3.2 (2014-24-02) + +* Bumps byebug dependency to get rid of bug in byebug. + + +## 1.3.1 (2014-08-02) + +* Fix #22 (thanks @andreychernih) + + +## 1.3.0 (2014-05-02) + +* Add breakpoints on method names (thanks @andreychernih & @palkan) +* Fix "undefined method `interface`" error (huge thanks to @andreychernih) + + +## 1.2.1 (2013-30-12) + +* Fix for "uncaught throw :breakout_nav" (thanks @lukebergen) + + +## 1.2.0 (2013-24-09) + +* Compatibility with byebug's 2.x series + + +## 1.1.2 (2013-11-07) + +* Allow pry-byebug to use backwards compatible versions of byebug + + +## 1.1.1 (2013-02-07) + +* Adds some initial tests to the test suite +* Fixes bug when doing "step n" or "next n" where n > 1 right after binding.pry + + +## 1.1.0 (2013-06-06) + +* Adds a test suite (thanks @teeparham!) +* Uses byebug ~> 1.4.0 +* Uses s, n, f and c aliases by default (thanks @jgakos!) + + +## 1.0.0, 1.0.1 (2013-05-07) + +* Forked from [pry-debugger](https://github.com/nixme/pry-debugger) to support + byebug +* Dropped pry-remote support + + +## 0.2.2 (2013-03-07) + +* Relaxed [byebug][byebug] dependency. + + +## 0.2.1 (2012-12-26) + +* Support breakpoints on methods defined in the pry console. (@banister) +* Fix support for specifying breakpoints by *file:line_number*. (@nviennot) +* Validate breakpoint conditionals are real Ruby expressions. +* Support for debugger ~> 1.2.0. (@jshou) +* Safer `alias_method_chain`-style patching of `Pry.start` and + `PryRemote::Server#teardown`. (@benizi) + + +## 0.2.0 (2012-06-11) + +* Breakpoints +* **finish** command +* Internal cleanup and bug fixes + + +## 0.1.0 (2012-06-07) + +* First release. **step**, **next**, and **continue** commands. + [pry-remote 0.1.4][pry-remote] support. diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/LICENSE b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/LICENSE new file mode 100644 index 000000000..bc6dfb7f4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/LICENSE @@ -0,0 +1,20 @@ +MIT/Expat License + +Copyright (c) David Rodríguez + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/README.md b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/README.md new file mode 100644 index 000000000..8b38bd579 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/README.md @@ -0,0 +1,152 @@ +# pry-byebug +[![Version][VersionBadge]][VersionURL] +[![Build][TravisBadge]][TravisURL] +[![Inline docs][InchCIBadge]][InchCIURL] +[![Gittip][GittipBadge]][GittipURL] +[![Coverage][CoverageBadge]][CoverageURL] + +_Fast execution control in Pry_ + +Adds **step**, **next**, **finish** and **continue** commands and +**breakpoints** to [Pry][pry] using [byebug][byebug]. + +To use, invoke pry normally. No need to start your script or app differently. +Execution will stop in the first statement after your `binding.pry`. + +```ruby +def some_method + puts 'Hello World' # Run 'step' in the console to move here +end + +binding.pry +some_method # Execution will stop here. +puts 'Goodbye World' # Run 'next' in the console to move here. +``` + + +## Installation + +Drop + +```ruby +gem 'pry-byebug' +``` + +in your Gemfile and run + + bundle install + +_Make sure you include the gem globally or inside the `:test` group if you plan +to use it to debug your tests!_ + + +## Execution Commands + +**step:** Step execution into the next line or method. Takes an optional numeric +argument to step multiple times. + +**next:** Step over to the next line within the same frame. Also takes an +optional numeric argument to step multiple lines. + +**finish:** Execute until current stack frame returns. + +**continue:** Continue program execution and end the Pry session. + +**up:** Moves the stack frame up. Takes an optional numeric argument to move +multiple frames. + +**down:** Moves the stack frame down. Takes an optional numeric argument to move +multiple frames. + +**frame:** Moves to a specific frame. Called without arguments will show the +current frame. + +## Matching Byebug Behaviour + +If you're coming from Byebug or from Pry-Byebug versions previous to 3.0, you +may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands. +These aliases were removed by default because they usually conflict with +scratch variable names. But it's very easy to reenable them if you still want +them, just add the following shortcuts to your `~/.pryrc` file: + +```ruby +if defined?(PryByebug) + Pry.commands.alias_command 'c', 'continue' + Pry.commands.alias_command 's', 'step' + Pry.commands.alias_command 'n', 'next' + Pry.commands.alias_command 'f', 'finish' +end +``` + +Also, you might find useful as well the repeat the last command by just hitting +the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to +your `~/.pryrc` file: + +```ruby +# Hit Enter to repeat last command +Pry::Commands.command /^$/, "repeat last command" do + _pry_.run_command Pry.history.to_a.last +end +``` + + +## Breakpoints + +You can set and adjust breakpoints directly from a Pry session using the +`break` command: + +**break:** Set a new breakpoint from a line number in the current file, a file +and line number, or a method. Pass an optional expression to create a +conditional breakpoint. Edit existing breakpoints via various flags. + +Examples: + +```ruby +break SomeClass#run # Break at the start of `SomeClass#run`. +break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`. +break app/models/user.rb:15 # Break at line 15 in user.rb. +break 14 # Break at line 14 in the current file. + +break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'. +break --condition 3 # Remove the condition on breakpoint #3. + +break --delete 5 # Delete breakpoint #5. +break --disable-all # Disable all breakpoints. + +break # List all breakpoints. +break --show 2 # Show details about breakpoint #2. +``` + +Type `break --help` from a Pry session to see all available options. + + +## Caveats + +Only supports MRI 2.0.0 or newer. For MRI 1.9.3 or older, use +[pry-debugger][pry-debugger] + + +## Credits + +* Gopal Patel (@nixme), creator of [pry-debugger][pry-debugger], and everybody +who contributed to it. pry-byebug is a fork of pry-debugger so it wouldn't +exist as it is without those contributions. +* John Mair (@banister), creator of [pry][pry]. + +Patches and bug reports are welcome. + +[pry]: http://pry.github.com +[byebug]: https://github.com/deivid-rodriguez/byebug +[pry-debugger]: https://github.com/nixme/pry-debugger +[pry-stack_explorer]: https://github.com/pry/pry-stack_explorer + +[VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg +[VersionURL]: http://badge.fury.io/rb/pry-byebug +[TravisBadge]: https://secure.travis-ci.org/deivid-rodriguez/pry-byebug.svg +[TravisURL]: http://travis-ci.org/deivid-rodriguez/pry-byebug +[InchCIBadge]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug.svg?branch=master +[InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug +[GittipBadge]: http://img.shields.io/gittip/deivid-rodriguez.svg +[GittipURL]: https://www.gittip.com/deivid-rodriguez +[CoverageBadge]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/pry-byebug.svg +[CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/pry-byebug diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/byebug/processors/pry_processor.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/byebug/processors/pry_processor.rb new file mode 100644 index 000000000..7f268d907 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/byebug/processors/pry_processor.rb @@ -0,0 +1,164 @@ +require 'byebug' + +module Byebug + # + # Extends raw byebug's processor. + # + class PryProcessor < Processor + attr_accessor :pry + attr_reader :state + + extend Forwardable + def_delegators :@pry, :output + def_delegators Pry::Helpers::Text, :bold + + def initialize(interface = LocalInterface.new) + super(interface) + + Byebug.handler = self + Byebug::Setting[:autolist] = false + end + + def start + Byebug.start + Byebug.current_context.step_out(3, true) + end + + # + # Wrap a Pry REPL to catch navigational commands and act on them. + # + def run(&_block) + @state ||= Byebug::RegularState.new( + Byebug.current_context, + [], + Byebug.current_context.frame_file, + interface, + Byebug.current_context.frame_line + ) + + return_value = nil + + command = catch(:breakout_nav) do # Throws from PryByebug::Commands + return_value = yield + {} # Nothing thrown == no navigational command + end + + # Pry instance to resume after stepping + @pry = command[:pry] + + perform(command[:action], command[:options]) + + return_value + end + + # + # Set up a number of navigational commands to be performed by Byebug. + # + def perform(action, options = {}) + return unless %i(next step finish up down frame).include?(action) + + send("perform_#{action}", options) + end + + # --- Callbacks from byebug C extension --- + + # + # Called when the wants to stop at a regular line + # + def at_line(context, _file, _line) + resume_pry(context) + end + + # + # Called when the wants to stop right before a method return + # + def at_return(context, _file, _line) + resume_pry(context) + end + + # + # Called when a breakpoint is hit. Note that `at_line`` is called + # inmediately after with the context's `stop_reason == :breakpoint`, so we + # must not resume the pry instance here + # + def at_breakpoint(_context, breakpoint) + @pry ||= Pry.new + + output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint) + + expr = breakpoint.expr + return unless expr + + output.puts bold('Condition: ') + expr + end + + private + + def n_hits(breakpoint) + n_hits = breakpoint.hit_count + + n_hits == 1 ? 'First hit' : "Hit #{n_hits} times." + end + + # + # Resume an existing Pry REPL at the paused point. + # + def resume_pry(context) + frame_position = state ? state.frame : 0 + + new_binding = context.frame_binding(frame_position) + + run do + if defined?(@pry) && @pry + @pry.repl(new_binding) + else + @pry = Pry.start_without_pry_byebug(new_binding) + end + end + end + + def perform_next(options) + lines = (options[:lines] || 1).to_i + state.context.step_over(lines, state.frame) + end + + def perform_step(options) + times = (options[:times] || 1).to_i + state.context.step_into(times, state.frame) + end + + def perform_finish(*) + state.context.step_out(1) + end + + def perform_up(options) + times = (options[:times] || 1).to_i + + command = Byebug::UpCommand.new(state) + command.match("up #{times}") + command.execute + + resume_pry(state.context) + end + + def perform_down(options) + times = (options[:times] || 1).to_i + + command = Byebug::DownCommand.new(state) + command.match("down #{times}") + command.execute + + resume_pry(state.context) + end + + def perform_frame(options) + index = options[:index] ? options[:index].to_i : '' + + command = Byebug::FrameCommand.new(state) + command.match("frame #{index}") + command.execute + + resume_pry(state.context) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug.rb new file mode 100644 index 000000000..ae42eecd5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug.rb @@ -0,0 +1,4 @@ +require 'pry' +require 'pry-byebug/base' +require 'pry-byebug/pry_ext' +require 'pry-byebug/commands' diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/base.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/base.rb new file mode 100644 index 000000000..0a018be5f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/base.rb @@ -0,0 +1,25 @@ +# +# Main container module for Pry-Byebug functionality +# +module PryByebug + # + # Checks that a target binding is in a local file context. + # + def file_context?(target) + file = target.eval('__FILE__') + file == Pry.eval_path || !Pry::Helpers::BaseHelpers.not_a_real_file?(file) + end + module_function :file_context? + + # + # Ensures that a command is executed in a local file context. + # + def check_file_context(target, e = nil) + e ||= 'Cannot find local context. Did you use `binding.pry`?' + fail(Pry::CommandError, e) unless file_context?(target) + end + module_function :check_file_context + + # Reference to currently running pry-remote server. Used by the processor. + attr_accessor :current_remote_server +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/cli.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/cli.rb new file mode 100644 index 000000000..b405b2a8f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/cli.rb @@ -0,0 +1,3 @@ +require 'pry-byebug/base' +require 'pry-byebug/pry_ext' +require 'pry-byebug/commands' diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands.rb new file mode 100644 index 000000000..64a66f307 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands.rb @@ -0,0 +1,8 @@ +require 'pry-byebug/commands/next' +require 'pry-byebug/commands/step' +require 'pry-byebug/commands/continue' +require 'pry-byebug/commands/finish' +require 'pry-byebug/commands/up' +require 'pry-byebug/commands/down' +require 'pry-byebug/commands/frame' +require 'pry-byebug/commands/breakpoint' diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/breakpoint.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/breakpoint.rb new file mode 100644 index 000000000..cfbe72060 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/breakpoint.rb @@ -0,0 +1,135 @@ +require 'pry/byebug/breakpoints' +require 'pry-byebug/helpers/breakpoints' +require 'pry-byebug/helpers/multiline' + +module PryByebug + # + # Add, show and remove breakpoints + # + class BreakCommand < Pry::ClassCommand + include Helpers::Breakpoints + include Helpers::Multiline + + match 'break' + group 'Byebug' + description 'Set or edit a breakpoint.' + + banner <<-BANNER + Usage: break [if CONDITION] + break --condition N [CONDITION] + break [--show | --delete | --enable | --disable] N + break [--delete-all | --disable-all] + break + Aliases: breakpoint + + Set a breakpoint. Accepts a line number in the current file, a file and + line number, or a method, and an optional condition. + + Pass appropriate flags to manipulate existing breakpoints. + + Examples: + + break SomeClass#run Break at the start of `SomeClass#run`. + break Foo#bar if baz? Break at `Foo#bar` only if `baz?`. + break app/models/user.rb:15 Break at line 15 in user.rb. + break 14 Break at line 14 in the current file. + + break --condition 4 x > 2 Add/change condition on breakpoint #4. + break --condition 3 Remove the condition on breakpoint #3. + + break --delete 5 Delete breakpoint #5. + break --disable-all Disable all breakpoints. + + break --show 2 Show details about breakpoint #2. + break List all breakpoints. + BANNER + + def options(opt) + defaults = { argument: true, as: Integer } + + opt.on :c, :condition, 'Change condition of a breakpoint.', defaults + opt.on :s, :show, 'Show breakpoint details and source.', defaults + opt.on :D, :delete, 'Delete a breakpoint.', defaults + opt.on :d, :disable, 'Disable a breakpoint.', defaults + opt.on :e, :enable, 'Enable a disabled breakpoint.', defaults + opt.on :'disable-all', 'Disable all breakpoints.' + opt.on :'delete-all', 'Delete all breakpoints.' + end + + def process + return if check_multiline_context + + PryByebug.check_file_context(target) + + option, = opts.to_hash.find { |key, _value| opts.present?(key) } + return send(option_to_method(option)) if option + + return new_breakpoint unless args.empty? + + print_all + end + + private + + %w(delete disable enable disable_all delete_all).each do |command| + define_method(:"process_#{command}") do + breakpoints.send(*[command, opts[command]].compact) + print_all + end + end + + def process_show + print_full_breakpoint(breakpoints.find_by_id(opts[:show])) + end + + def process_condition + expr = args.empty? ? nil : args.join(' ') + breakpoints.change(opts[:condition], expr) + end + + def new_breakpoint + place = args.shift + condition = args.join(' ') if 'if' == args.shift + + bp = add_breakpoint(place, condition) + + print_full_breakpoint(bp) + end + + def option_to_method(option) + "process_#{option.to_s.gsub('-', '_')}" + end + + def print_all + print_breakpoints_header + breakpoints.each { |b| print_short_breakpoint(b) } + end + + def add_breakpoint(place, condition) + case place + when /^(\d+)$/ + errmsg = 'Line number declaration valid only in a file context.' + PryByebug.check_file_context(target, errmsg) + + lineno = Regexp.last_match[1].to_i + breakpoints.add_file(current_file, lineno, condition) + when /^(.+):(\d+)$/ + file = Regexp.last_match[1] + lineno = Regexp.last_match[2].to_i + breakpoints.add_file(file, lineno, condition) + when /^(.*)[.#].+$/ # Method or class name + if Regexp.last_match[1].strip.empty? + errmsg = 'Method name declaration valid only in a file context.' + PryByebug.check_file_context(target, errmsg) + place = target.eval('self.class.to_s') + place + end + breakpoints.add_method(place, condition) + else + fail(ArgumentError, 'Cannot identify arguments as breakpoint') + end + end + end +end + +Pry::Commands.add_command(PryByebug::BreakCommand) +Pry::Commands.alias_command 'breakpoint', 'break' diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/continue.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/continue.rb new file mode 100644 index 000000000..b28a781db --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/continue.rb @@ -0,0 +1,37 @@ +require 'pry-byebug/helpers/navigation' +require 'pry-byebug/helpers/breakpoints' + +module PryByebug + # + # Continue program execution until the next breakpoint + # + class ContinueCommand < Pry::ClassCommand + include Helpers::Navigation + include Helpers::Breakpoints + + match 'continue' + group 'Byebug' + description 'Continue program execution and end the Pry session.' + + banner <<-BANNER + Usage: continue [LINE] + + Continue program execution until the next breakpoint, or the program + ends. Optionally continue to the specified line number. + + Examples: + continue #=> Continue until the next breakpoint. + continue 4 #=> Continue to line number 4. + BANNER + + def process + PryByebug.check_file_context(target) + + breakpoints.add_file(current_file, args.first.to_i) if args.first + + breakout_navigation :continue + end + end +end + +Pry::Commands.add_command(PryByebug::ContinueCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/down.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/down.rb new file mode 100644 index 000000000..150b718c6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/down.rb @@ -0,0 +1,33 @@ +require 'pry-byebug/helpers/navigation' + +module PryByebug + # + # Travel down the frame stack + # + class DownCommand < Pry::ClassCommand + include Helpers::Navigation + + match 'down' + group 'Byebug' + + description 'Move current frame down.' + + banner <<-BANNER + Usage: down [TIMES] + + Move current frame down. By default, moves by 1 frame. + + Examples: + down #=> Move down 1 frame. + down 5 #=> Move down 5 frames. + BANNER + + def process + PryByebug.check_file_context(target) + + breakout_navigation :down, times: args.first + end + end +end + +Pry::Commands.add_command(PryByebug::DownCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/finish.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/finish.rb new file mode 100644 index 000000000..a875fa186 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/finish.rb @@ -0,0 +1,26 @@ +require 'pry-byebug/helpers/navigation' + +module PryByebug + # + # Run until the end of current frame + # + class FinishCommand < Pry::ClassCommand + include PryByebug::Helpers::Navigation + + match 'finish' + group 'Byebug' + description 'Execute until current stack frame returns.' + + banner <<-BANNER + Usage: finish + BANNER + + def process + PryByebug.check_file_context(target) + + breakout_navigation :finish + end + end +end + +Pry::Commands.add_command(PryByebug::FinishCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/frame.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/frame.rb new file mode 100644 index 000000000..38651fe21 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/frame.rb @@ -0,0 +1,33 @@ +require 'pry-byebug/helpers/navigation' + +module PryByebug + # + # Move to a specific frame in the callstack + # + class FrameCommand < Pry::ClassCommand + include Helpers::Navigation + + match 'frame' + group 'Byebug' + + description 'Move to specified frame #.' + + banner <<-BANNER + Usage: frame [TIMES] + + Move to specified frame #. + + Examples: + frame #=> Show current frame #. + frame 5 #=> Move to frame 5. + BANNER + + def process + PryByebug.check_file_context(target) + + breakout_navigation :frame, index: args.first + end + end +end + +Pry::Commands.add_command(PryByebug::FrameCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/next.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/next.rb new file mode 100644 index 000000000..17f816099 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/next.rb @@ -0,0 +1,37 @@ +require 'pry-byebug/helpers/navigation' +require 'pry-byebug/helpers/multiline' + +module PryByebug + # + # Run a number of lines and then stop again + # + class NextCommand < Pry::ClassCommand + include Helpers::Navigation + include Helpers::Multiline + + match 'next' + group 'Byebug' + description 'Execute the next line within the current stack frame.' + + banner <<-BANNER + Usage: next [LINES] + + Step over within the same frame. By default, moves forward a single + line. + + Examples: + next #=> Move a single line forward. + next 4 #=> Execute the next 4 lines. + BANNER + + def process + return if check_multiline_context + + PryByebug.check_file_context(target) + + breakout_navigation :next, lines: args.first + end + end +end + +Pry::Commands.add_command(PryByebug::NextCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/step.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/step.rb new file mode 100644 index 000000000..fdf96e8b1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/step.rb @@ -0,0 +1,32 @@ +require 'pry-byebug/helpers/navigation' + +module PryByebug + # + # Run a number of Ruby statements and then stop again + # + class StepCommand < Pry::ClassCommand + include Helpers::Navigation + + match 'step' + group 'Byebug' + description 'Step execution into the next line or method.' + + banner <<-BANNER + Usage: step [TIMES] + + Step execution forward. By default, moves a single step. + + Examples: + step #=> Move a single step forward. + step 5 #=> Execute the next 5 steps. + BANNER + + def process + PryByebug.check_file_context(target) + + breakout_navigation :step, times: args.first + end + end +end + +Pry::Commands.add_command(PryByebug::StepCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/up.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/up.rb new file mode 100644 index 000000000..b6189767f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/commands/up.rb @@ -0,0 +1,33 @@ +require 'pry-byebug/helpers/navigation' + +module PryByebug + # + # Travel up the frame stack + # + class UpCommand < Pry::ClassCommand + include Helpers::Navigation + + match 'up' + group 'Byebug' + + description 'Move current frame up.' + + banner <<-BANNER + Usage: up [TIMES] + + Move current frame up. By default, moves by 1 frame. + + Examples: + up #=> Move up 1 frame. + up 5 #=> Move up 5 frames. + BANNER + + def process + PryByebug.check_file_context(target) + + breakout_navigation :up, times: args.first + end + end +end + +Pry::Commands.add_command(PryByebug::UpCommand) diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/breakpoints.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/breakpoints.rb new file mode 100644 index 000000000..395b4118a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/breakpoints.rb @@ -0,0 +1,84 @@ +require 'byebug' + +module PryByebug + module Helpers + # + # Common helpers for breakpoint related commands + # + module Breakpoints + # + # Byebug's array of breakpoints. + # + def breakpoints + Pry::Byebug::Breakpoints + end + + # + # Current file in the target binding. Used as the default breakpoint + # location. + # + def current_file + target.eval('__FILE__') + end + + # + # Prints a message with bold font. + # + def bold_puts(msg) + output.puts(text.bold(msg)) + end + + # + # Print out full information about a breakpoint. + # + # Includes surrounding code at that point. + # + def print_full_breakpoint(br) + header = "Breakpoint #{br.id}:" + status = br.enabled? ? 'Enabled' : 'Disabled' + code = br.source_code.with_line_numbers.to_s + condition = br.expr ? "#{text.bold('Condition:')} #{br.expr}\n" : '' + + output.puts <<-EOP.gsub(/ {8}/, '') + + #{text.bold(header)} #{br} (#{status}) #{condition} + + #{code} + + EOP + end + + # + # Print out concise information about a breakpoint. + # + def print_short_breakpoint(breakpoint) + id = format('%*d', max_width, breakpoint.id) + status = breakpoint.enabled? ? 'Yes' : 'No ' + expr = breakpoint.expr ? " #{breakpoint.expr} " : '' + + output.puts(" #{id} #{status} #{breakpoint}#{expr}") + end + + # + # Prints a header for the breakpoint list. + # + def print_breakpoints_header + header = "#{' ' * (max_width - 1)}# Enabled At " + + output.puts <<-EOP.gsub(/ {8}/, '') + + #{text.bold(header)} + #{text.bold('-' * header.size)} + + EOP + end + + # + # Max width of breakpoints id column + # + def max_width + breakpoints.last ? breakpoints.last.id.to_s.length : 1 + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/multiline.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/multiline.rb new file mode 100644 index 000000000..9209588a9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/multiline.rb @@ -0,0 +1,21 @@ +module PryByebug + module Helpers + # + # Helpers to help handling multiline inputs + # + module Multiline + # + # Returns true if we are in a multiline context and, as a side effect, + # updates the partial evaluation string with the current input. + # + # Returns false otherwise + # + def check_multiline_context + return false if eval_string.empty? + + eval_string.replace("#{eval_string}#{match} #{arg_string}\n") + true + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/navigation.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/navigation.rb new file mode 100644 index 000000000..d3b095bd6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/helpers/navigation.rb @@ -0,0 +1,17 @@ +module PryByebug + module Helpers + # + # Helpers to aid breaking out of the REPL loop + # + module Navigation + # + # Breaks out of the REPL loop and signals tracer + # + def breakout_navigation(action, options = {}) + _pry_.binding_stack.clear + + throw :breakout_nav, action: action, options: options, pry: _pry_ + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_ext.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_ext.rb new file mode 100644 index 000000000..96cbd6399 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_ext.rb @@ -0,0 +1,19 @@ +require 'byebug/processors/pry_processor' + +class << Pry + alias_method :start_without_pry_byebug, :start + attr_reader :processor + + def start_with_pry_byebug(target = TOPLEVEL_BINDING, options = {}) + @processor ||= Byebug::PryProcessor.new + + if target.is_a?(Binding) && PryByebug.file_context?(target) + # Wrap processor around the usual Pry.start to catch navigation commands + @processor.start + else + # No need for the tracer unless we have a file context to step through + start_without_pry_byebug(target, options) + end + end + alias_method :start, :start_with_pry_byebug +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_remote_ext.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_remote_ext.rb new file mode 100644 index 000000000..6e9340f71 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/pry_remote_ext.rb @@ -0,0 +1,42 @@ +require 'pry-remote' + +module PryRemote + # + # Overrides PryRemote::Server + # + class Server + # + # Override the call to Pry.start to save off current Server, and not + # teardown the server right after Pry.start finishes. + # + def run + fail('Already running a pry-remote session!') if + PryByebug.current_remote_server + + PryByebug.current_remote_server = self + + setup + Pry.start @object, input: client.input_proxy, output: client.output + end + + # + # Override to reset our saved global current server session. + # + alias_method :teardown_without_pry_byebug, :teardown + def teardown_with_pry_byebug + return if @torn + + teardown_without_pry_byebug + PryByebug.current_remote_server = nil + @torn = true + end + alias_method :teardown, :teardown_with_pry_byebug + end +end + +# Ensure cleanup when a program finishes without another break. For example, +# 'next' on the last line of a program won't hit Byebug::PryProcessor#run, +# which normally handles cleanup. +at_exit do + PryByebug.current_remote_server.teardown if PryByebug.current_remote_server +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/version.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/version.rb new file mode 100644 index 000000000..94ebd754e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry-byebug/version.rb @@ -0,0 +1,6 @@ +# +# Main container module for Pry-Byebug functionality +# +module PryByebug + VERSION = '3.2.0' +end diff --git a/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry/byebug/breakpoints.rb b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry/byebug/breakpoints.rb new file mode 100644 index 000000000..ff0ef21f4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/pry-byebug-3.2.0/lib/pry/byebug/breakpoints.rb @@ -0,0 +1,164 @@ +class Pry + module Byebug + # + # Wrapper for Byebug.breakpoints that respects our Processor and has better + # failure behavior. Acts as an Enumerable. + # + module Breakpoints + extend Enumerable + extend self + + # + # Breakpoint in a file:line location + # + class FileBreakpoint < SimpleDelegator + def source_code + Pry::Code.from_file(source).around(pos, 3).with_marker(pos) + end + + def to_s + "#{source} @ #{pos}" + end + end + + # + # Breakpoint in a Class#method location + # + class MethodBreakpoint < SimpleDelegator + def initialize(byebug_bp, method) + __setobj__ byebug_bp + @method = method + end + + def source_code + Pry::Code.from_method(Pry::Method.from_str(@method)) + end + + def to_s + @method + end + end + + def breakpoints + @breakpoints ||= [] + end + + # + # Adds a method breakpoint. + # + def add_method(method, expression = nil) + validate_expression expression + owner, name = method.split(/[\.#]/) + byebug_bp = ::Byebug::Breakpoint.add(owner, name.to_sym, expression) + bp = MethodBreakpoint.new byebug_bp, method + breakpoints << bp + bp + end + + # + # Adds a file breakpoint. + # + def add_file(file, line, expression = nil) + real_file = (file != Pry.eval_path) + fail(ArgumentError, 'Invalid file!') if real_file && !File.exist?(file) + validate_expression expression + + path = (real_file ? File.expand_path(file) : file) + bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) + breakpoints << bp + bp + end + + # + # Changes the conditional expression for a breakpoint. + # + def change(id, expression = nil) + validate_expression expression + + breakpoint = find_by_id(id) + breakpoint.expr = expression + breakpoint + end + + # + # Deletes an existing breakpoint with the given ID. + # + def delete(id) + deleted = + ::Byebug.started? && + ::Byebug::Breakpoint.remove(id) && + breakpoints.delete(find_by_id(id)) + + fail(ArgumentError, "No breakpoint ##{id}") unless deleted + end + + # + # Deletes all breakpoints. + # + def delete_all + @breakpoints = [] + ::Byebug.breakpoints.clear if ::Byebug.started? + end + + # + # Enables a disabled breakpoint with the given ID. + # + def enable(id) + change_status id, true + end + + # + # Disables a breakpoint with the given ID. + # + def disable(id) + change_status id, false + end + + # + # Disables all breakpoints. + # + def disable_all + each do |breakpoint| + breakpoint.enabled = false + end + end + + def to_a + breakpoints + end + + def size + to_a.size + end + + def each(&block) + to_a.each(&block) + end + + def last + to_a.last + end + + def find_by_id(id) + breakpoint = find { |b| b.id == id } + fail(ArgumentError, "No breakpoint ##{id}!") unless breakpoint + breakpoint + end + + private + + def change_status(id, enabled = true) + breakpoint = find_by_id(id) + breakpoint.enabled = enabled + breakpoint + end + + def validate_expression(exp) + valid = exp && (exp.empty? || !Pry::Code.complete_expression?(exp)) + return unless valid + + fail("Invalid breakpoint conditional: #{expression}") + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.autotest b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.autotest new file mode 100644 index 000000000..0988b12a8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.autotest @@ -0,0 +1,7 @@ +require 'autotest/restart' + +Autotest.add_hook :initialize do |at| + at.testlib = '' + at.add_exception '.git' +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.gemtest b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.gemtest new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.rubocop.yml b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.rubocop.yml new file mode 100644 index 000000000..6d2bfcdbd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.rubocop.yml @@ -0,0 +1,27 @@ +StringLiterals: + Enabled: false + +MultilineBlocks: + Enabled: false + +SingleLineBlocks: + Enabled: false + +NewLambdaLiteral: + Enabled: false + +SpaceAroundEqualsInParameterDefault: + Enabled: false + +HashSyntax: + Enabled: false + +LineLength: + Enabled: true + Max: 90 + +WhileUntilModifier: + Enabled: false + +IfUnlessModifier: + Enabled: false diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.togglerc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.togglerc new file mode 100644 index 000000000..c8c5a0a97 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/.togglerc @@ -0,0 +1,7 @@ +(add-to-list + 'toggle-mapping-styles + '(rake . ( + ("test/test_rake_\\1.rb" . "lib/rake/\\1.rb") + ) )) + +(buffer-toggle-style 'rake) diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/CONTRIBUTING.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/CONTRIBUTING.rdoc new file mode 100644 index 000000000..243cfe84e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/CONTRIBUTING.rdoc @@ -0,0 +1,34 @@ += Source Repository + +Rake is currently hosted at github. The github web page is +http://github.com/ruby/rake . The public git clone URL is + + git://github.com/ruby/rake.git + += Running the Rake Test Suite + +If you wish to run the unit and functional tests that come with Rake: + +* CD into the top project directory of rake. +* Type one of the following: + + rake newb # If you have never run rake's tests + rake # If you have run rake's tests + += Issues and Bug Reports + +Feel free to submit commits or feature requests. If you send a patch, +remember to update the corresponding unit tests. In fact, I prefer +new feature to be submitted in the form of new unit tests. + +For other information, feel free to ask on the ruby-talk mailing list. + +If you have found a bug in rake please try with the latest version of rake +before filing an issue. Also check History.rdoc for bug fixes that may have +addressed your issue. + +When submitting pull requests please check the rake Travis-CI page for test +failures: + + https://travis-ci.org/ruby/rake + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/History.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/History.rdoc new file mode 100644 index 000000000..e50d23704 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/History.rdoc @@ -0,0 +1,651 @@ +=== 10.4.2 / 2014-12-02 + +Bug fixes: + +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Pull requset #9 by Matt Palmer. +* Documented how Rake::DSL#desc handles sentences in task descriptions. + Issue #7 by Raza Sayed. +* Fixed test error on 1.9.3 with legacy RubyGems. Issue #8 by Matt Palmer. +* Deleted duplicated History entry. Pull request #10 by Yuji Yamamoto. + +=== 10.4.1 / 2014-12-01 + +Bug fixes: + +* Reverted fix for #277 as it caused numerous issues for rake users. + rails/spring issue #366 by Gustavo Dutra. + +=== 10.4.0 / 2014-11-22 + +Enhancements: + +* Upgraded to minitest 5. Pull request #292 by Teo Ljungberg. +* Added support for Pathname in rake tasks. Pull request #271 by Randy + Coulman. +* Rake now ignores falsy dependencies which allows for easier programmatic + creation of tasks. Pull request #273 by Manav. +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Issue #277 by Matt Palmer. +* Etc.nprocessors is used for counting the number of CPUs. + +Bug fixes: + +* Updated rake manpage. Issue #283 by Nathan Long, pull request #291 by + skittleys. +* Add Rake::LATE to allow rebuilding of files that depend on deleted files. + Bug #286, pull request #287 by David Grayson. +* Fix relinking of files when repackaging. Bug #276 by Muenze. +* Fixed some typos. Pull request #280 by Jed Northridge. +* Try counting CPUs via cpuinfo if host_os was not matched. Pull request + #282 by Edouard B. + +=== 10.3.2 / 2014-05-15 + +Bug fixes: + +* Rake no longer infinitely loops when showing exception causes that refer to + each other. Bug #272 by Chris Bandy. +* Fixed documentation typos. Bug #275 by Jake Worth. + +=== 10.3.1 / 2014-04-17 + +Bug fixes: + +* Really stop reporting an error when cleaning already-deleted files. Pull + request #269 by Randy Coulman +* Fixed infinite loop when cleaning already-deleted files on windows. + +=== 10.3 / 2014-04-15 + +Enhancements: + +* Added --build-all option to rake which treats all file prerequisites as + out-of-date. Pull request #254 by Andrew Gilbert. +* Added Rake::NameSpace#scope. Issue #263 by Jon San Miguel. + +Bug fixes: + +* Suppress org.jruby package files in rake error messages for JRuby users. + Issue #213 by Charles Nutter. +* Fixed typo, removed extra "h". Pull request #267 by Hsing-Hui Hsu. +* Rake no longer reports an error when cleaning already-deleted files. Pull + request #266 by Randy Coulman. +* Consume stderr while determining CPU count to avoid hang. Issue #268 by + Albert Sun. + +=== 10.2.2 / 2014-03-27 + +Bug fixes: + +* Restored Ruby 1.8.7 compatibility + +=== 10.2.1 / 2014-03-25 + +Bug fixes: + +* File tasks including a ':' are now top-level tasks again. Issue #262 by + Josh Holtrop. +* Use sysctl for CPU count for all BSDs. Pull request #261 by Joshua Stein. +* Fixed CPU detection for unknown platforms. + +=== 10.2.0 / 2014-03-24 + +Enhancements: + +* Rake now requires Ruby 1.9 or newer. For me, this is a breaking change, but + it seems that Jim planned to release it with Rake 10.2. See also pull + request #247 by Philip Arndt. +* Rake now allows you to declare tasks under a namespace like: + + task 'a:b' do ... end + + Pull request #232 by Judson Lester. +* Task#source defaults to the first prerequisite in non-rule tasks. Pull + request #215 by Avdi Grimm. +* Rake now automatically rebuilds and reloads imported files. Pull request + #209 by Randy Coulman. +* The rake task arguments can contain escaped commas. Pull request #214 by + Filip Hrbek. +* Rake now prints the exception class on errors. Patch #251 by David Cornu. + +Bug fixes: + +* Fixed typos. Pull request #256 by Valera Rozuvan, #250 via Jake Worth, #260 + by Zachary Scott. +* Fixed documentation for calling tasks with arguments. Pull request #235 by + John Varghese. +* Clarified `rake -f` usage message. Pull request #252 by Marco Pfatschbacher. +* Fixed a test failure on windows. Pull request #231 by Hiroshi Shirosaki. +* Fixed corrupted rake.1.gz. Pull request #225 by Michel Boaventura. +* Fixed bug in can_detect_signals? in test. Patch from #243 by Alexey + Borzenkov. + +=== 10.1.1 and earlier + +Additions to the old CHANGES file were not made consistently so some +versions are missing from this file. These changes are usually described in +the individual release notes files. + +=== 0.9.3 + +* The rake test loader now removes arguments it has processed. Issue #51 +* Rake::TaskArguments now responds to #values_at +* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 +* Rake tests are now directory-independent +* Rake tests are no longer require flexmock +* Commands constant is no longer polluting top level namespace. +* Show only the interesting portion of the backtrace by default (James M. Lawrence). +* Added --reduce-compat optiont to remove backward compatible DSL hacks (James M. Lawrence). +* lib/rake/file_list.rb (Rake::FileList#egrep): there is no need to + open files in binary mode. (NAKAMURA Usaku) + +=== 0.9.2 + +* Unknown + +=== 0.9.1 + +* Added deprecation warnings to the Rake DSL methods. + +=== 0.9.0 + +* *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.) are + no longer private methods in Object. If you need to call 'task :xzy' inside + your class, include Rake::DSL into the class. The DSL is still available at + the top level scope (via the top level object which extends Rake::DSL). + +* Rake now warns when the deprecated :needs syntax used. + +* Rake history is now UTF-8 encoded. + +* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. + Based on patch by Roger Pack. + +* Rake now requires (instead of loads) files in the test task. Patch by Cezary + Baginski. + +* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. + +* Rake now prints the Rakefile directory only when it's different from the + current directory. Patch by Alex Chaffee. + +* Improved rakefile_location discovery on Windows. Patch by James Tucker. + +* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias + Lüdtke + +* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require + 'rdoc/task') + +* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require + 'rubygems/package_task') + +* Rake now outputs various messages to $stderr instead of $stdout. + +* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. + +* Split rake.rb into individual files. + +* Support for the --where (-W) flag for showing where a task is defined. + +* Fixed quoting in test task. + (http://onestepback.org/redmine/issues/show/44, + http://www.pivotaltracker.com/story/show/1223138) + +* Fixed the silent option parsing problem. + (http://onestepback.org/redmine/issues/show/47) + +* Fixed :verbose=>false flag on sh and ruby commands. + +* Rake command line options may be given by default in a RAKEOPT + environment variable. + +* Errors in Rake will now display the task invocation chain in effect + at the time of the error. + +* Accepted change by warnickr to not expand test patterns in shell + (allowing more files in the test suite). + +* Fixed that file tasks did not perform prereq lookups in scope + (Redmine #57). + +=== 0.8.7 + +* Fixed EXEEXT for JRuby on windows. + +=== 0.8.6 + +* Minor fixes to the RDoc generation (removed dependency on darkfish + and removed inline source option). + +* Now allow # comments to comment a task definition. + +=== 0.8.5 + +* Better support for the system command on Windows. + +=== 0.8.4 + +* Preserve case when locating rakefiles (patch from James + M. Lawrence/quix) + +* Better support for windows paths in the test task (patch from Simon + Chiang/bahuvrihi) + +* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, + APPDATA, USERPROFILE (patch from Luis Lavena) + +* MingGW is now recognized as a windows platform. (patch from Luis + Lavena) + +* Numerous fixes to the windows test suite (patch from Luis Lavena). + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Fixed stray ARGV option problem that was interfering with + Test::Unit::Runner. + +* Fixed default verbose mode (was accidently changed to false). + +* Removed reference to manage_gem to fix the warning produced by the + gem package task. + +=== 0.8.3 + +* Enhanced the system directory detection in windows. We now check + HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch + supplied by James Tucker). Rake no long aborts if it can't find the + directory. + +* Added fix to handle ruby installations in directories with spaces in + their name. + +=== 0.8.2 + +* Fixed bug in package task so that it will include the subdir + directory in the package for testing. (Bug found by Adam Majer) + +* Added ENV var to rakefile to prevent OS X from including extended + attribute junk in a tar file. (Bug found by Adam Majer) + +* Fixed filename dependency order bug in test_inspect_pending and + test_to_s_pending. (Bug found by Adam Majer) + +* Fixed check for file utils options to make them immune to the + symbol/string differences. (Patch supplied by Edwin Pratomo) + +* Fixed bug with rules involving multiple source (Patch supplied by + Emanuel Indermühle) + +* Switched from getoptlong to optparse (patches supplied by Edwin + Pratomo) + +* The -T option will now attempt to dynamically sense the size of the + terminal. RAKE_COLUMNS will override any dynamic sensing. + +* FileList#clone and FileList#dup have better sematics w.r.t. taint + and freeze. + +* Added ability clear prerequisites, and/or actions from an existing + task. + +* Added the ability to reenable a task to be invoked a second time. + +* Changed RDoc test task to have no default template. This makes it + easier for the tempate to pick up the template from the environment. + +* Changed from using Mutex to Monitor. Evidently Mutex causes thread + join errors when Ruby is compiled with -disable-pthreads. (Patch + supplied by Ittay Dror) + +* Fixed bug in makefile parser that had problems with extra spaces in + file task names. (Patch supplied by Ittay Dror) + +* Added a performance patch for reading large makefile dependency + files. (Patch supplied by Ittay Dror) + +* Default values for task arguments can easily be specified with the + :with_defaults method. (Idea for default argument merging supplied + by (Adam Q. Salter) + +* The -T output will only self-truncate if the output is a tty. + However, if RAKE_COLUMNS is explicitly set, it will be honored in + any case. (Patch provided by Gavin Stark). + +* Numerous fixes for running under windows. A big thanks to Bheeshmar + Redheendran for spending a good part of the afternoon at the + Lonestar Ruby Conference to help me work out these issues. + +=== 0.8.1 + +* Removed requires on parsedate.rb (in Ftptools) +* Removed ftools from rake.rb. Made it options in sys.rb + +=== 0.8.0 + +* Added task parameters (e.g. "rake build[version7]") +* Made task parameters passable to prerequisites. +* Comments are limited to 80 columns or so (suggested by Jamis Buck). +* Added -D to display full comments (suggested by Jamis Buck). +* The rake program will set the status value used in any explicit + exit(n) calls. (patch provided by Stephen Touset) +* Fixed error in functional tests that were not including session (and + silently skipping the functionl tests. +* Removed --usage and make -h the same as -H. +* Make a prettier inspect for tasks. + +=== 0.7.3 + +* Added existing and existing! methods to FileList +* FileLists now claim to be Arrays (via is_a?) to get better support + from the FileUtil module. +* Added init and top_level for custom rake applications. + +=== 0.7.2 + +* Error messages are now send to stderr rather than stdout (from + Payton Quackenbush). +* Better error handling on invalid command line arguments (from Payton + Quackenbush). +* Added rcov task and updated unit testing for better code coverage. +* Fixed some bugs where the application object was going to the global + appliation instead of using its own data. +* Added square and curly bracket patterns to FileList#include (Tilman + Sauerbeck). +* Added plain filename support to rule dependents (suggested by Nobu + Nakada). +* Added pathmap support to rule dependents. +* Added a 'tasks' method to a namespace to get a list of tasks + associated with the namespace. +* Fixed the method name leak from FileUtils (bug found by Glenn + Vanderburg). +* Added rake_extension to handle detection of extension collisions. +* Added test for noop, bad_option and verbose flags to sh command. +* Removed dependency on internal fu_xxx functions from FileUtils. +* Added a 'shame' task to the Rakefile. +* Added tar_command and zip_command options to the Package task. +* Added a description to the gem task in GemPackageTask. +* Fixed a bug when rules have multiple prerequisites (patch by Joel + VanderWerf) +* Added a protected 'require "rubygems"' to test/test_application to + unbreak cruisecontrol.rb. +* Added the handful of RakeFileUtils to the private method as well. +* Added block based exclusion. +* The clean task will no longer delete 'core' if it is a directory. +* Removed rake_dup. Now we just simply rescue a bad dup. +* Refactored the FileList reject logic to remove duplication. +* Removed if __FILE__ at the end of the rake.rb file. + +=== 0.7.1 + +* Added optional filter parameter to the --tasks command line option. +* Added flatten to allow rule transform procs to return lists of + prereqs (Joel VanderWerf provided patch). +* Added pathmap to String and FileList. +* The -r option will now load .rake files (but a straight require + doesn't yet). NOTE: This is experimental ... it may be + discontinued. +* The -f option without a value will disable the search for a + Rakefile. The assumption is that the -r files are adequate. +* Fixed the safe_ln function to fall back to cp in more error + scenarios. + +=== 0.7.0 + +* Added Rake.original_dir to return the original starting directory of + the rake application. +* Added safe_ln support for openAFS (from Ludvig Omholt). +* Added --trace reminder on short exception messages (David Heinemeier + Hansson suggestion). +* Added multitask declaration that executes prerequisites in + parallel. (Doug Young providied an initial implementation). +* Fixed missing_const hack to be compatible with Rails. (Jamis Buck + supplied test case). +* Made the RDoc task default to internal (in-process) RDoc formatting. + The old behavior is still available by setting the +external+ flag + to true. +* Rakefiles are now loaded with the expanded path to prevent + accidental polution from the Ruby load path. +* The +namespace+ command now returns a NameSpace object that can be + used to lookup tasks defined in that namespace. This allows for + better anonymous namespace behavior. +* Task objects my now be used in prerequisite lists directly. + +=== 0.6.1 + +* Rebuilt 0.6.0 gem without signing. + +=== 0.6.0 + +* Fixed file creation bug in the unit tests (caused infinite loop on + windows). +* Fixed bug where session based functional tests were run under + windows. +* Fixed bug in directory tasks so that updating a directory will not + retrigger file tasks depending on the directory (see + FileCreationTask and EarlyTime). +* Added egrep to FileList +* ruby command now runs same ruby version as rake. +* Added investigation to task object. (suggested by Martin Fowler) +* Added ruby_opts to the test task to allow arbitrary ruby options to + be passed to the test script. (Greg Fast) +* Fixed the test loader to ignore options. (Greg Fast) +* Moved Task, FileTask, FileCreationTask and RakeApp into the Rake + module namespace. Old style namespace behavior can be invoked via + the --classic-namespace option. (requested by Kelly Felkins). +* GemTask is now sensitive to the gem platform (Masao Mutoh). +* A non-existing file prerequisite will no longer cause an exception + (Philipp Neubeck). +* Multiple prerequisites on Rake rules now allowed (initial patch + supplied by Stuart Jansen). + +=== 0.5.4 + +* Added double quotes to the test runner. +* Added .svn to default ignore list. +* Updated FileList#include to support nested arrays and filelists. + +=== 0.5.3 + +* Added support for importing Rakefile and other dependencies. +* Fixed bug so that now rules can chain off of existing tasks as well + as existing files. +* Fixed verbose flag bug in the testing task. Shortened some failure + messages. +* Make FileUtils methods private at the top level module to avoid + accidental method leaking into other objects. +* Added test loader option to test task. "testrb" is no longer the + default test loader. It is now eating syntax errors that should + halt the unit tests. +* Revamped FileList so that it works more like and array (addressed + flatten bug). Added many tests around file list. +* Added +ext+ method to both String and FileList. + +=== 0.5.0 + +* Fixed documentation that was lacking the Rake module name (Tilman + Sauerbeck). +* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). +* Recursive rules are now supported (Tilman Sauerbeck). +* Added warning option for the Test Task (requested by Eric Hodel). +* The jamis rdoc template is only used if it exists. +* Added fix for Ruby 1.8.2 test/unit and rails problem. +* Added contributed rake man file (Jani Monoses). +* Added Brian Candler's fix for problems in --trace and --dry-run + mode. + +=== 0.4.15 + +* Fixed a bug that prevented the TESTOPTS flag from working with the + revised for 1.8.2 test task. +* Updated the docs on --trace to indicate that it also enables a full + backtrace on errors. + +=== 0.4.14 + +* Modified the TestTask to workaround the Ruby 1.8.2 change in + autoexecuting unit tests. + +=== 0.4.13 + +* Fixed the dry-run flag so it is operating again. +* Multiple arguments to sh and ruby commands will not be interpreted + by the shell (patch provided by Jonathan Paisley). + +=== 0.4.12 + +* Added --silent (-s) to suppress the (in directory) rake message. + +=== 0.4.11 + +* Changed the "don't know how to rake" message (finally) +* Changes references to a literal "Rakefile" to reference the global + variable $rakefile (which contains the actual name of the rakefile). + +=== 0.4.10 + +* Added block support to the "sh" command, allowing users to take + special actions on the result of the system call. E.g. + + sh "shell_command" do |ok, res| + puts "Program returned #{res.exitstatus}" if ! ok + end + +=== 0.4.9 + +* Switched to Jamis Buck's RDoc template. +* Removed autorequire from Rake's gem spec. This prevents the Rake + libraries from loading while using rails. + +=== 0.4.8 + +* Added support for .rb versions of Rakefile. +* Removed \\\n's from test task. +* Fixed Ruby 1.9 compatibility issue with FileList. + +=== 0.4.7 + +* Fixed problem in FileList that caused Ruby 1.9 to go into infinite + recursion. Since to_a was removed from Object, it does not need to + added back into the list of methods to rewrite in FileList. (Thanks + to Kent Sibilev for pointing this out). + +=== 0.4.6 +* Removed test version of ln in FileUtils that prevented safe_ln from + using ln. + +=== 0.4.5 +* Upgraded comments in TestTask. +* FileList to_s and inspect now automatically resolve pending changes. +* FileList#exclude properly returns the FileList. + +=== 0.4.4 +* Fixed initialization problem with @comment. +* Now using multi -r technique in TestTask. Switch Rakefile back to + using the built-in test task macros because the rake runtime is no + longer needed. +* Added 'TEST=filename' and 'TESTOPTS=options' to the Test Task + macros. +* Allow a +test_files+ attribute in test tasks. This allows more + flexibility in specifying test files. + +=== 0.4.3 +* Fixed Comment leakage. + +=== 0.4.2 +* Added safe_ln that falls back to a copy if a file link is not supported. +* Package builder now uses safe_ln. + +=== 0.4.1 +* Task comments are now additive, combined with "/". +* Works with (soon to be released) rubygems 0.6.2 (or 0.7.0) + +=== 0.4.0 +* FileList now uses deferred loading. The file system is not searched + until the first call that needs the file names. +* VAR=VALUE options are now accepted on the command line and are + treated like environment variables. The values may be tested in a + Rakefile by referencing ENV['VAR']. +* File.mtime is now used (instead of File.new().mtime). + +=== 0.3.2.x + +* Removed some hidden dependencies on rubygems. Tests now will test + gems only if they are installed. +* Removed Sys from some example files. I believe that is that last + reference to Sys outside of the contrib area. +* Updated all copyright notices to include 2004. + +=== 0.3.2 + +* GEM Installation now works with the application stub. + +=== 0.3.1 + +* FileLists now automatically ignore CVS, .bak, ! +* GEM Installation now works. + +=== 0.3.0 + +Promoted 0.2.10. + +=== 0.2.10 +General + +* Added title to Rake's rdocs +* Contrib packages are no longer included in the documentation. + +RDoc Issues + +* Removed default for the '--main' option +* Fixed rendering of the rdoc options +* Fixed clean/clobber confusion with rerdoc +* 'title' attribute added + +Package Task Library Issues + +* Version (or explicit :noversion) is required. +* +package_file+ attribute is now writable + +FileList Issues + +* Dropped bang version of exclude. Now using ant-like include/exclude semantics. +* Enabled the "yield self" idiom in FileList#initialize. + +=== 0.2.9 + +This version contains numerous changes as the RubyConf.new(2003) +presentation was being prepared. The changes include: + +* The monolithic rubyapp task library is in the process of being + dropped in favor of lighter weight task libraries. + +=== 0.2.7 + +* Added "desc" for task descriptions. +* -T will now display tasks with descriptions. +* -P will display tasks and prerequisites. +* Dropped the Sys module in favor of the 1.8.x FileUtils module. Sys + is still supported in the contrib area. + +=== 0.2.6 + +* Moved to RubyForge + +=== 0.2.5 + +* Switched to standard ruby app builder. +* Added no_match option to file matcher. + +=== 0.2.4 + +* Fixed indir, which neglected to actually change directories. + +=== 0.2.3 + +* Added rake module for a help target +* Added 'for_files' to Sys +* Added a $rakefile constant +* Added test for selecting proper rule with multiple targets. diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/MIT-LICENSE b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/MIT-LICENSE new file mode 100644 index 000000000..4292f3b3c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/MIT-LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Jim Weirich + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Manifest.txt b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Manifest.txt new file mode 100644 index 000000000..a7829c97b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Manifest.txt @@ -0,0 +1,166 @@ +.autotest +.rubocop.yml +.togglerc +CONTRIBUTING.rdoc +History.rdoc +MIT-LICENSE +Manifest.txt +README.rdoc +Rakefile +bin/rake +doc/command_line_usage.rdoc +doc/example/Rakefile1 +doc/example/Rakefile2 +doc/example/a.c +doc/example/b.c +doc/example/main.c +doc/glossary.rdoc +doc/jamis.rb +doc/proto_rake.rdoc +doc/rake.1 +doc/rakefile.rdoc +doc/rational.rdoc +doc/release_notes/rake-0.4.14.rdoc +doc/release_notes/rake-0.4.15.rdoc +doc/release_notes/rake-0.5.0.rdoc +doc/release_notes/rake-0.5.3.rdoc +doc/release_notes/rake-0.5.4.rdoc +doc/release_notes/rake-0.6.0.rdoc +doc/release_notes/rake-0.7.0.rdoc +doc/release_notes/rake-0.7.1.rdoc +doc/release_notes/rake-0.7.2.rdoc +doc/release_notes/rake-0.7.3.rdoc +doc/release_notes/rake-0.8.0.rdoc +doc/release_notes/rake-0.8.2.rdoc +doc/release_notes/rake-0.8.3.rdoc +doc/release_notes/rake-0.8.4.rdoc +doc/release_notes/rake-0.8.5.rdoc +doc/release_notes/rake-0.8.6.rdoc +doc/release_notes/rake-0.8.7.rdoc +doc/release_notes/rake-0.9.0.rdoc +doc/release_notes/rake-0.9.1.rdoc +doc/release_notes/rake-0.9.2.2.rdoc +doc/release_notes/rake-0.9.2.rdoc +doc/release_notes/rake-0.9.3.rdoc +doc/release_notes/rake-0.9.4.rdoc +doc/release_notes/rake-0.9.5.rdoc +doc/release_notes/rake-0.9.6.rdoc +doc/release_notes/rake-10.0.0.rdoc +doc/release_notes/rake-10.0.1.rdoc +doc/release_notes/rake-10.0.2.rdoc +doc/release_notes/rake-10.0.3.rdoc +doc/release_notes/rake-10.1.0.rdoc +lib/rake.rb +lib/rake/alt_system.rb +lib/rake/application.rb +lib/rake/backtrace.rb +lib/rake/clean.rb +lib/rake/cloneable.rb +lib/rake/contrib/.document +lib/rake/contrib/compositepublisher.rb +lib/rake/contrib/ftptools.rb +lib/rake/contrib/publisher.rb +lib/rake/contrib/rubyforgepublisher.rb +lib/rake/contrib/sshpublisher.rb +lib/rake/contrib/sys.rb +lib/rake/cpu_counter.rb +lib/rake/default_loader.rb +lib/rake/dsl_definition.rb +lib/rake/early_time.rb +lib/rake/ext/core.rb +lib/rake/ext/module.rb +lib/rake/ext/pathname.rb +lib/rake/ext/string.rb +lib/rake/ext/time.rb +lib/rake/file_creation_task.rb +lib/rake/file_list.rb +lib/rake/file_task.rb +lib/rake/file_utils.rb +lib/rake/file_utils_ext.rb +lib/rake/gempackagetask.rb +lib/rake/invocation_chain.rb +lib/rake/invocation_exception_mixin.rb +lib/rake/late_time.rb +lib/rake/linked_list.rb +lib/rake/loaders/makefile.rb +lib/rake/multi_task.rb +lib/rake/name_space.rb +lib/rake/packagetask.rb +lib/rake/pathmap.rb +lib/rake/phony.rb +lib/rake/private_reader.rb +lib/rake/promise.rb +lib/rake/pseudo_status.rb +lib/rake/rake_module.rb +lib/rake/rake_test_loader.rb +lib/rake/rdoctask.rb +lib/rake/ruby182_test_unit_fix.rb +lib/rake/rule_recursion_overflow_error.rb +lib/rake/runtest.rb +lib/rake/scope.rb +lib/rake/task.rb +lib/rake/task_argument_error.rb +lib/rake/task_arguments.rb +lib/rake/task_manager.rb +lib/rake/tasklib.rb +lib/rake/testtask.rb +lib/rake/thread_history_display.rb +lib/rake/thread_pool.rb +lib/rake/trace_output.rb +lib/rake/version.rb +lib/rake/win32.rb +rakelib/publish.rake +rakelib/test_times.rake +test/file_creation.rb +test/helper.rb +test/support/rakefile_definitions.rb +test/support/ruby_runner.rb +test/test_private_reader.rb +test/test_rake.rb +test/test_rake_application.rb +test/test_rake_application_options.rb +test/test_rake_backtrace.rb +test/test_rake_clean.rb +test/test_rake_cpu_counter.rb +test/test_rake_definitions.rb +test/test_rake_directory_task.rb +test/test_rake_dsl.rb +test/test_rake_early_time.rb +test/test_rake_extension.rb +test/test_rake_file_creation_task.rb +test/test_rake_file_list.rb +test/test_rake_file_list_path_map.rb +test/test_rake_file_task.rb +test/test_rake_file_utils.rb +test/test_rake_ftp_file.rb +test/test_rake_functional.rb +test/test_rake_invocation_chain.rb +test/test_rake_late_time.rb +test/test_rake_linked_list.rb +test/test_rake_makefile_loader.rb +test/test_rake_multi_task.rb +test/test_rake_name_space.rb +test/test_rake_package_task.rb +test/test_rake_path_map.rb +test/test_rake_path_map_explode.rb +test/test_rake_path_map_partial.rb +test/test_rake_pathname_extensions.rb +test/test_rake_pseudo_status.rb +test/test_rake_rake_test_loader.rb +test/test_rake_reduce_compat.rb +test/test_rake_require.rb +test/test_rake_rules.rb +test/test_rake_scope.rb +test/test_rake_task.rb +test/test_rake_task_argument_parsing.rb +test/test_rake_task_arguments.rb +test/test_rake_task_lib.rb +test/test_rake_task_manager.rb +test/test_rake_task_manager_argument_resolution.rb +test/test_rake_task_with_arguments.rb +test/test_rake_test_task.rb +test/test_rake_thread_pool.rb +test/test_rake_top_level_functions.rb +test/test_rake_win32.rb +test/test_thread_history_display.rb +test/test_trace_output.rb diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/README.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/README.rdoc new file mode 100644 index 000000000..683e0c0e8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/README.rdoc @@ -0,0 +1,140 @@ += RAKE -- Ruby Make + +home :: https://github.com/ruby/rake +bugs :: https://github.com/ruby/rake/issues +docs :: http://docs.seattlerb.org/rake + +== Description + +Rake is a Make-like program implemented in Ruby. Tasks and dependencies are +specified in standard Ruby syntax. + +Rake has the following features: + +* Rakefiles (rake's version of Makefiles) are completely defined in + standard Ruby syntax. No XML files to edit. No quirky Makefile + syntax to worry about (is that a tab or a space?) + +* Users can specify tasks with prerequisites. + +* Rake supports rule patterns to synthesize implicit tasks. + +* Flexible FileLists that act like arrays but know about manipulating + file names and paths. + +* A library of prepackaged tasks to make building rakefiles easier. For example, + tasks for building tarballs and publishing to FTP or SSH sites. (Formerly + tasks for building RDoc and Gems were included in rake but they're now + available in RDoc and RubyGems respectively.) + +* Supports parallel execution of tasks. + +== Installation + +=== Gem Installation + +Download and install rake with the following. + + gem install rake + +== Usage + +=== Simple Example + +First, you must write a "Rakefile" file which contains the build rules. Here's +a simple example: + + task default: %w[test] + + task :test do + ruby "test/unittest.rb" + end + +This Rakefile has two tasks: + +* A task named "test", which -- upon invocation -- will run a unit test file + in Ruby. +* A task named "default". This task does nothing by itself, but it has exactly + one dependency, namely the "test" task. Invoking the "default" task will + cause Rake to invoke the "test" task as well. + +Running the "rake" command without any options will cause it to run the +"default" task in the Rakefile: + + % ls + Rakefile test/ + % rake + (in /home/some_user/Projects/rake) + ruby test/unittest.rb + ....unit test output here... + +Type "rake --help" for all available options. + +== Resources + +=== Rake Information + +* {Rake command-line}[rdoc-ref:doc/command_line_usage.rdoc] +* {Writing Rakefiles}[rdoc-ref:doc/rakefile.rdoc] +* The original {Rake announcement}[rdoc-ref:doc/rational.rdoc] +* Rake {glossary}[rdoc-ref:doc/glossary.rdoc] + +=== Presentations and Articles about Rake + +* Avdi Grimm's rake series: + 1. {Rake Basics}[http://devblog.avdi.org/2014/04/21/rake-part-1-basics/] + 2. {Rake File Lists}[http://devblog.avdi.org/2014/04/22/rake-part-2-file-lists/] + 3. {Rake Rules}[http://devblog.avdi.org/2014/04/23/rake-part-3-rules/] + 4. {Rake Pathmap}[http://devblog.avdi.org/2014/04/24/rake-part-4-pathmap/] + 5. {File Operations}[http://devblog.avdi.org/2014/04/25/rake-part-5-file-operations/] + 6. {Clean and Clobber}[http://devblog.avdi.org/2014/04/28/rake-part-6-clean-and-clobber/] + 7. {MultiTask}[http://devblog.avdi.org/2014/04/29/rake-part-7-multitask/] +* Jim Weirich's 2003 RubyConf presentation: + http://onestepback.org/articles/buildingwithrake/ +* Martin Fowler's article on Rake: http://martinfowler.com/articles/rake.html + +== Other Make Re-envisionings ... + +Rake is a late entry in the make replacement field. Here are links to +other projects with similar (and not so similar) goals. + +* http://directory.fsf.org/bras.html -- Bras, one of earliest + implementations of "make in a scripting language". +* http://www.a-a-p.org -- Make in Python +* http://www.aromatic.com/tools/jam.txt -- JAM, Java Automated Make +* http://ant.apache.org -- The Ant project +* http://search.cpan.org/search?query=PerlBuildSystem -- The Perl Build System +* http://rubydoc.info/gems/rant/0.5.7/frames -- Rant, another Ruby make tool. + +== Credits + +[Ryan Dlugosz] For the initial conversation that sparked Rake. + +[nobu.nokada@softhome.net] For the initial patch for rule support. + +[Tilman Sauerbeck ] For the recursive rule patch. + +[Eric Hodel] For aid in maintaining rake. + +== License + +Rake is available under an MIT-style license. + +:include: MIT-LICENSE + +--- + += Other stuff + +Author:: Jim Weirich +Requires:: Ruby 1.8.7 or later +License:: Copyright Jim Weirich. + Released under an MIT-style license. See the MIT-LICENSE + file included in the distribution. + +== Warranty + +This software is provided "as is" and without any express or implied +warranties, including, without limitation, the implied warranties of +merchantability and fitness for a particular purpose. + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Rakefile b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Rakefile new file mode 100644 index 000000000..375ca8805 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/Rakefile @@ -0,0 +1,81 @@ +# Rakefile for rake -*- ruby -*- + +# Copyright 2003, 2004, 2005 by Jim Weirich (jim@weirichhouse.org) +# All rights reserved. + +# This file may be distributed under an MIT style license. See +# MIT-LICENSE for details. + +require 'rbconfig' + +system_rake = File.join RbConfig::CONFIG['rubylibdir'], 'rake.rb' + +# Use our rake, not the installed rake from system +if $".include? system_rake or $".grep(/rake\/name_space\.rb$/).empty? then + exec Gem.ruby, '-Ilib', 'bin/rake', *ARGV +end + +require 'hoe' + +Hoe.plugin :git +Hoe.plugin :minitest +Hoe.plugin :travis + +hoe = Hoe.spec 'rake' do + developer 'Eric Hodel', 'drbrain@segment7.net' + developer 'Jim Weirich', '' + + require_ruby_version '>= 1.8.7' + require_rubygems_version '>= 1.3.2' + + dependency 'minitest', '~> 5.0', :developer + + license "MIT" + + self.readme_file = 'README.rdoc' + self.history_file = 'History.rdoc' + + self.extra_rdoc_files.concat FileList[ + 'MIT-LICENSE', + 'doc/**/*.rdoc', + '*.rdoc', + ] + + self.local_rdoc_dir = 'html' + self.rsync_args = '-avz --delete' + rdoc_locations << 'docs.seattlerb.org:/data/www/docs.seattlerb.org/rake/' + + self.clean_globs += [ + '**/*.o', + '**/*.rbc', + '*.dot', + 'TAGS', + 'doc/example/main', + ] +end + +hoe.test_prelude = 'gem "minitest", "~> 5.0"' + +# Use custom rdoc task due to existence of doc directory + +Rake::Task['docs'].clear +Rake::Task['clobber_docs'].clear + +begin + require 'rdoc/task' + + RDoc::Task.new :rdoc => 'docs', :clobber_rdoc => 'clobber_docs' do |doc| + doc.main = hoe.readme_file + doc.title = 'Rake -- Ruby Make' + + rdoc_files = Rake::FileList.new %w[lib History.rdoc MIT-LICENSE doc] + rdoc_files.add hoe.extra_rdoc_files + + doc.rdoc_files = rdoc_files + + doc.rdoc_dir = 'html' + end +rescue LoadError + warn 'run `rake newb` to install rdoc' +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/bin/rake b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/bin/rake new file mode 100755 index 000000000..4e0bbb7b7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/bin/rake @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby + +#-- +# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +#++ + +begin + require 'rubygems' + gem 'rake' +rescue LoadError +end + +require 'rake' + +Rake.application.run diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/command_line_usage.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/command_line_usage.rdoc new file mode 100644 index 000000000..105d6c8e9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/command_line_usage.rdoc @@ -0,0 +1,158 @@ += Rake Command Line Usage + +Rake is invoked from the command line using: + + % rake [options ...] [VAR=VALUE ...] [targets ...] + +Options are: + +[name=value] + Set the environment variable name to value + during the execution of the rake command. You can access + the value by using ENV['name']. + +[--all (-A)] + Used in combination with the -T and -D options, will force + those options to show all the tasks, even the ones without comments. + +[--backtrace{=_output_} (-n)] + Enable a full backtrace (i.e. like --trace, but without the task + tracing details). The _output_ parameter is optional, but if + specified it controls where the backtrace output is sent. If + _output_ is stdout, then backtrace output is directed to + standard output. If _output_ is stderr, or if it is + missing, then the backtrace output is sent to standard error. + +[--comments] + Used in combination with the -W options to force the output to + contain commented options only. This is the reverse of + --all. + +[--describe _pattern_ (-D)] + Describe the tasks (matching optional PATTERN), then exit. + +[--dry-run (-n)] + Do a dry run. Print the tasks invoked and executed, but do not + actually execute any of the actions. + +[--execute _code_ (-e)] + Execute some Ruby code and exit. + +[--execute-print _code_ (-p)] + Execute some Ruby code, print the result, and exit. + +[--execute-continue _code_ (-E)] + Execute some Ruby code, then continue with normal task processing. + +[--help (-H)] + Display some help text and exit. + +[--jobs _number_ (-j)] + + Specifies the maximum number of concurrent threads allowed. Rake + will allocate threads as needed up to this maximum number. + + If omitted, Rake will attempt to estimate the number of CPUs on + the system and add 4 to that number. + + The concurrent threads are used to execute the multitask + prerequisites. Also see the -m option which turns all + tasks into multitasks. + + Sample values: + (no -j) : Allow up to (# of CPUs + 4) number of threads + --jobs : Allow unlimited number of threads + --jobs=1 : Allow only one thread (the main thread) + --jobs=16 : Allow up to 16 concurrent threads + +[--job-stats _level_] + + Display job statistics at the completion of the run. By default, + this will display the requested number of active threads (from the + -j options) and the maximum number of threads in play at any given + time. + + If the optional _level_ is history, then a complete trace + of task history will be displayed on standard output. + +[--libdir _directory_ (-I)] + Add _directory_ to the list of directories searched for require. + +[--multitask (-m)] + Treat all tasks as multitasks. ('make/drake' semantics) + +[--nosearch (-N)] + Do not search for a Rakefile in parent directories. + +[--prereqs (-P)] + Display a list of all tasks and their immediate prerequisites. + +[--quiet (-q)] + Do not echo commands from FileUtils. + +[--rakefile _filename_ (-f)] + Use _filename_ as the name of the rakefile. The default rakefile + names are +rakefile+ and +Rakefile+ (with +rakefile+ taking + precedence). If the rakefile is not found in the current + directory, +rake+ will search parent directories for a match. The + directory where the Rakefile is found will become the current + directory for the actions executed in the Rakefile. + +[--rakelibdir _rakelibdir_ (-R)] + Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib') + +[--require _name_ (-r)] + Require _name_ before executing the Rakefile. + +[--rules] + Trace the rules resolution. + +[--silent (-s)] + Like --quiet, but also suppresses the 'in directory' announcement. + +[--suppress-backtrace _pattern_ ] + Line matching the regular expression _pattern_ will be removed + from the backtrace output. Note that the --backtrace option is the + full backtrace without these lines suppressed. + +[--system (-g)] + Use the system wide (global) rakefiles. The project Rakefile is + ignored. By default, the system wide rakefiles are used only if no + project Rakefile is found. On Unix-like system, the system wide + rake files are located in $HOME/.rake. On a windows system they + are stored in $APPDATA/Rake. + +[--no-system (-G)] + Use the project level Rakefile, ignoring the system-wide (global) + rakefiles. + +[--tasks pattern (-T)] + Display a list of the major tasks and their comments. Comments + are defined using the "desc" command. If a pattern is given, then + only tasks matching the pattern are displayed. + +[--trace{=_output_} (-t)] + Turn on invoke/execute tracing. Also enable full backtrace on + errors. The _output_ parameter is optional, but if specified it + controls where the trace output is sent. If _output_ is + stdout, then trace output is directed to standard output. + If _output_ is stderr, or if it is missing, then trace + output is sent to standard error. + +[--verbose (-v)] + Echo the Sys commands to standard output. + +[--version (-V)] + Display the program version and exit. + +[--where pattern (-W)] + Display tasks that match pattern and the file and line + number where the task is defined. By default this option will + display all tasks, not just the tasks that have descriptions. + +[--no-deprecation-warnings (-X)] + Do not display the deprecation warnings. + +In addition, any command line option of the form +VAR=VALUE will be added to the environment hash +ENV and may be tested in the Rakefile. diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile1 b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile1 new file mode 100644 index 000000000..39f8bcceb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile1 @@ -0,0 +1,38 @@ +# Example Rakefile -*- ruby -*- + +task :default => [:main] + +file "a.o" => ["a.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +file "b.o" => ["b.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +file "main.o" => ["main.c"] do |t| + src = t.name.sub(/\.o$/, '.c') + sh "gcc #{src} -c -o #{t.name}" +end + +OBJFILES = ["a.o", "b.o", "main.o"] +task :obj => OBJFILES + +file "main" => OBJFILES do |t| + sh "gcc -o #{t.name} main.o a.o b.o" +end + +task :clean do + rm_f FileList['*.o'] + Dir['*~'].each { |fn| rm_f fn } +end + +task :clobber => [:clean] do + rm_f "main" +end + +task :run => ["main"] do + sh "./main" +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile2 b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile2 new file mode 100644 index 000000000..35310eceb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/Rakefile2 @@ -0,0 +1,35 @@ +# Example Rakefile -*- ruby -*- +# Using the power of Ruby + +task :default => [:main] + +def ext(fn, newext) + fn.sub(/\.[^.]+$/, newext) +end + +SRCFILES = Dir['*.c'] +OBJFILES = SRCFILES.collect { |fn| ext(fn,".o") } + +OBJFILES.each do |objfile| + srcfile = ext(objfile, ".c") + file objfile => [srcfile] do |t| + sh "gcc #{srcfile} -c -o #{t.name}" + end +end + +file "main" => OBJFILES do |t| + sh "gcc -o #{t.name} main.o a.o b.o" +end + +task :clean do + rm_f FileList['*.o'] + Dir['*~'].each { |fn| rm_f fn } +end + +task :clobber => [:clean] do + rm_f "main" +end + +task :run => ["main"] do + sh "./main" +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/a.c b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/a.c new file mode 100644 index 000000000..620e6f800 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/a.c @@ -0,0 +1,6 @@ +#include + +void a() +{ + printf ("In function a\n"); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/b.c b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/b.c new file mode 100644 index 000000000..9b24aa127 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/b.c @@ -0,0 +1,6 @@ +#include + +void b() +{ + printf ("In function b\n"); +} diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/main.c b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/main.c new file mode 100644 index 000000000..a04558a25 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/example/main.c @@ -0,0 +1,11 @@ +#include + +extern void a(); +extern void b(); + +int main () +{ + a(); + b(); + return 0; +} diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/glossary.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/glossary.rdoc new file mode 100644 index 000000000..bdbccb4e0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/glossary.rdoc @@ -0,0 +1,43 @@ += Glossary + +action :: + Code to be executed in order to perform a task. Actions in a rakefile are + specified in a code block (usually delimited by +do+/+end+ pairs. + +execute :: + When a task is executed, all of its actions are performed, in the order they + were defined. Note that unlike invoke, execute always + executes the actions (without invoking or executing the prerequisites). + +file task (Rake::FileTask) :: + A file task is a task whose purpose is to create a file (which has the same + name as the task). When invoked, a file task will only execute if one or + more of the following conditions are true. + + 1. The associated file does not exist. + 2. A prerequisite has a later time stamp than the existing file. + + Because normal Tasks always have the current time as timestamp, a FileTask + that has a normal Task prerequisite will always execute. + +invoke :: + When a task is invoked, first we check to see if it has been invoked before. + If it has been, then nothing else is done. If this is the first time its + been invoked, then we invoke each of its prerequisites. Finally, we check + to see if we need to execute the actions of this task by calling + Rake::Task#needed?. Finally, if the task is needed, we execute its actions. + + NOTE: Prerequisites are invoked even if the task is not needed. + +prerequisites :: + Every task has a set (possibly empty) of prerequisites. A prerequisite P to + Task T is itself a task that must be invoked before Task T. + +rule :: + A rule is a recipe for synthesizing a task when no task is explicitly + defined. Rules generally synthesize file tasks. + +task (Rake::Task) :: + Basic unit of work in a rakefile. A task has a name, a set of prerequisites + and a list of actions to be performed. + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/jamis.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/jamis.rb new file mode 100644 index 000000000..c7bc84ac5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/jamis.rb @@ -0,0 +1,591 @@ +module RDoc +module Page + +FONTS = "\"Bitstream Vera Sans\", Verdana, Arial, Helvetica, sans-serif" + +STYLE = < pre { + padding: 0.5em; + border: 1px dotted black; + background: #FFE; +} + +CSS + +XHTML_PREAMBLE = %{ + +} + +HEADER = XHTML_PREAMBLE + < + + %title% + + + + + + + +ENDHEADER + +FILE_PAGE = < + + + + +
File
%short_name%
+ + + + + + + + + +
Path:%full_path% +IF:cvsurl +  (CVS) +ENDIF:cvsurl +
Modified:%dtm_modified%
+
+ +
+HTML + +################################################################### + +CLASS_PAGE = < + %classmod%
%full_name% + + + + + + +IF:parent + + + + +ENDIF:parent +
In: +START:infiles +HREF:full_path_url:full_path: +IF:cvsurl + (CVS) +ENDIF:cvsurl +END:infiles +
Parent: +IF:par_url + +ENDIF:par_url +%parent% +IF:par_url + +ENDIF:par_url +
+ + + +HTML + +################################################################### + +METHOD_LIST = < +IF:diagram +
+ %diagram% +
+ENDIF:diagram + +IF:description +
%description%
+ENDIF:description + +IF:requires +
Required Files
+
    +START:requires +
  • HREF:aref:name:
  • +END:requires +
+ENDIF:requires + +IF:toc +
Contents
+ +ENDIF:toc + +IF:methods +
Methods
+
    +START:methods +
  • HREF:aref:name:
  • +END:methods +
+ENDIF:methods + +IF:includes +
Included Modules
+
    +START:includes +
  • HREF:aref:name:
  • +END:includes +
+ENDIF:includes + +START:sections +IF:sectitle + +IF:seccomment +
+%seccomment% +
+ENDIF:seccomment +ENDIF:sectitle + +IF:classlist +
Classes and Modules
+ %classlist% +ENDIF:classlist + +IF:constants +
Constants
+ +START:constants + + + + + +IF:desc + + + + +ENDIF:desc +END:constants +
%name%=%value%
 %desc%
+ENDIF:constants + +IF:attributes +
Attributes
+ +START:attributes + + + + + +END:attributes +
+IF:rw +[%rw%] +ENDIF:rw + %name%%a_desc%
+ENDIF:attributes + +IF:method_list +START:method_list +IF:methods +
%type% %category% methods
+START:methods +
+
+IF:callseq + %callseq% +ENDIF:callseq +IFNOT:callseq + %name%%params% +ENDIF:callseq +IF:codeurl +[ source ] +ENDIF:codeurl +
+IF:m_desc +
+ %m_desc% +
+ENDIF:m_desc +IF:aka +
+ This method is also aliased as +START:aka + %name% +END:aka +
+ENDIF:aka +IF:sourcecode +
+ +
+
+%sourcecode%
+
+
+
+ENDIF:sourcecode +
+END:methods +ENDIF:methods +END:method_list +ENDIF:method_list +END:sections +
+HTML + +FOOTER = < + +ENDFOOTER + +BODY = HEADER + < + +
+ #{METHOD_LIST} +
+ + #{FOOTER} +ENDBODY + +########################## Source code ########################## + +SRC_PAGE = XHTML_PREAMBLE + < +%title% + + + + +
%code%
+ + +HTML + +########################## Index ################################ + +FR_INDEX_BODY = < + + + + + + + +
+START:entries +%name%
+END:entries +
+ +HTML + +CLASS_INDEX = FILE_INDEX +METHOD_INDEX = FILE_INDEX + +INDEX = XHTML_PREAMBLE + < + + %title% + + + + + + + + + +IF:inline_source + +ENDIF:inline_source +IFNOT:inline_source + + + + +ENDIF:inline_source + + <body bgcolor="white"> + Click <a href="html/index.html">here</a> for a non-frames + version of this page. + </body> + + + + +HTML + +end +end + + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/proto_rake.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/proto_rake.rdoc new file mode 100644 index 000000000..a9e33d11d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/proto_rake.rdoc @@ -0,0 +1,127 @@ += Original Prototype Rake + +This is the original 100 line prototype rake program. + +--- + #!/usr/bin/env ruby + + require 'ftools' + + class Task + TASKS = Hash.new + + attr_reader :prerequisites + + def initialize(task_name) + @name = task_name + @prerequisites = [] + @actions = [] + end + + def enhance(deps=nil, &block) + @prerequisites |= deps if deps + @actions << block if block_given? + self + end + + def name + @name.to_s + end + + def invoke + @prerequisites.each { |n| Task[n].invoke } + execute if needed? + end + + def execute + return if @triggered + @triggered = true + @actions.collect { |act| result = act.call(self) }.last + end + + def needed? + true + end + + def timestamp + Time.now + end + + class << self + def [](task_name) + TASKS[intern(task_name)] or fail "Don't know how to rake #{task_name}" + end + + def define_task(args, &block) + case args + when Hash + fail "Too Many Target Names: #{args.keys.join(' ')}" if args.size > 1 + fail "No Task Name Given" if args.size < 1 + task_name = args.keys[0] + deps = args[task_name] + else + task_name = args + deps = [] + end + deps = deps.collect {|d| intern(d) } + get(task_name).enhance(deps, &block) + end + + def get(task_name) + name = intern(task_name) + TASKS[name] ||= self.new(name) + end + + def intern(task_name) + (Symbol === task_name) ? task_name : task_name.intern + end + end + end + + class FileTask < Task + def needed? + return true unless File.exist?(name) + latest_prereq = @prerequisites.collect{|n| Task[n].timestamp}.max + return false if latest_prereq.nil? + timestamp < latest_prereq + end + + def timestamp + File.new(name.to_s).mtime + end + end + + def task(args, &block) + Task.define_task(args, &block) + end + + def file(args, &block) + FileTask.define_task(args, &block) + end + + def sys(cmd) + puts cmd + system(cmd) or fail "Command Failed: [#{cmd}]" + end + + def rake + begin + here = Dir.pwd + while ! File.exist?("Rakefile") + Dir.chdir("..") + fail "No Rakefile found" if Dir.pwd == here + here = Dir.pwd + end + puts "(in #{Dir.pwd})" + load "./Rakefile" + ARGV.push("default") if ARGV.size == 0 + ARGV.each { |task_name| Task[task_name].invoke } + rescue Exception => ex + puts "rake aborted ... #{ex.message}" + puts ex.backtrace.find {|str| str =~ /Rakefile/ } || "" + end + end + + if __FILE__ == $0 then + rake + end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rake.1 b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rake.1 new file mode 100644 index 000000000..b63ed49ed --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rake.1 @@ -0,0 +1,141 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH RAKE 1 "August 27, 2014" "rake 10.3.2" "Rake User Commands" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +rake \- a make-like build utility for Ruby +.SH SYNOPSIS +\fBrake\fR [\fI\-f rakefile\fR] {\fIOPTIONS\fR} \fITARGETS...\fR +.br +.SH DESCRIPTION +.B rake +is a make-like build utility for Ruby. Tasks and dependencies are specified in +standard Ruby syntax. +.SH OPTIONS +.TP +\fB\-m\fR, \fB\-\-multitask\fR +Treat all tasks as multitasks. +.TP +\fB\-B\fR, \fB\-\-build\-all\fR +Build all prerequisites, including those which are up\-to\-date. + +.TP +\fB\-j\fR, \fB\-\-jobs\fR [\fINUMBER\fR] +Specifies the maximum number of tasks to execute in parallel (default is number of CPU cores + 4). + +.SS Modules +.TP +\fB\-I\fR, \fB\-\-libdir\fR \fILIBDIR\fR +Include \fILIBDIR\fR in the search path for required modules. +.TP +\fB\-r\fR, \fB\-\-require\fR \fIMODULE\fR +Require \fIMODULE\fR before executing rakefile. + +.SS Rakefile location +.TP +\fB\-f\fR, \fB\-\-rakefile\fR [\fIFILENAME\fR] +Use \fIFILENAME\fR as the rakefile to search for. +.TP +\fB\-N\fR, \fB\-\-no\-search\fR, \fB\-\-nosearch\fR +Do not search parent directories for the Rakefile. +.TP +\fB\-G\fR, \fB\-\-no\-system\fR, \fB\-\-nosystem\fR +Use standard project Rakefile search paths, ignore system wide rakefiles. +.TP +\fB\-R\fR, \fB\-\-rakelibdir\fR \fIRAKELIBDIR\fR +Auto\-import any .rake files in \fIRAKELIBDIR\fR (default is 'rakelib') +.HP +\fB\-\-rakelib\fR +.TP +\fB\-g\fR, \fB\-\-system\fR +Using system wide (global) rakefiles (usually '\fI~/.rake/*.rake\fR'). + +.SS Debugging +.TP +\fB\-\-backtrace\fR=\fI\,[OUT]\/\fR +Enable full backtrace. \fIOUT\fR can be stderr (default) or stdout. +.TP +\fB\-t\fR, \fB\-\-trace\fR=\fI\,[OUT]\/\fR +Turn on invoke/execute tracing, enable full backtrace. \fIOUT\fR can be stderr (default) or stdout. +.TP +\fB\-\-suppress\-backtrace\fR \fIPATTERN\fR +Suppress backtrace lines matching regexp \fIPATTERN\fR. Ignored if \fI\-\-trace\fR is on. +.TP +\fB\-\-rules\fR +Trace the rules resolution. + +.TP +\fB\-n\fR, \fB\-\-dry\-run\fR +Do a dry run without executing actions. +.TP +\fB\-T\fR, \fB\-\-tasks\fR [\fIPATTERN\fR] +Display the tasks (matching optional \fIPATTERN\fR) with descriptions, then exit. +.TP +\fB\-D\fR, \fB\-\-describe\fR [\fIPATTERN\fR] +Describe the tasks (matching optional \fIPATTERN\fR), then exit. +.TP +\fB\-W\fR, \fB\-\-where\fR [\fIPATTERN\fR] +Describe the tasks (matching optional \fIPATTERN\fR), then exit. +.TP +\fB\-P\fR, \fB\-\-prereqs\fR +Display the tasks and dependencies, then exit. + +.TP +\fB\-e\fR, \fB\-\-execute\fR \fICODE\fR +Execute some Ruby code and exit. +.TP +\fB\-p\fR, \fB\-\-execute\-print\fR \fICODE\fR +Execute some Ruby code, print the result, then exit. +.TP +\fB\-E\fR, \fB\-\-execute\-continue\fR \fICODE\fR +Execute some Ruby code, then continue with normal task processing. + +.SS Information +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Log message to standard output. +.TP +\fB\-q\fR, \fB\-\-quiet\fR +Do not log messages to standard output. +.TP +\fB\-s\fR, \fB\-\-silent\fR +Like \fB\-\-quiet\fR, but also suppresses the 'in directory' announcement. +.TP +\fB\-X\fR, \fB\-\-no\-deprecation\-warnings\fR +Disable the deprecation warnings. +.TP +\fB\-\-comments\fR +Show commented tasks only +.TP +\fB\-A\fR, \fB\-\-all\fR +Show all tasks, even uncommented ones (in combination with \fB\-T\fR or \fB\-D\fR) +.TP +\fB\-\-job\-stats\fR [\fILEVEL\fR] +Display job statistics. \fILEVEL=history\fR displays a complete job list +.TP +\fB\-V\fR, \fB\-\-version\fR +Display the program version. +.TP +\fB\-h\fR, \fB\-H\fR, \fB\-\-help\fR +Display a help message. + +.SH SEE ALSO +The complete documentation for \fBrake\fR has been installed at \fI/usr/share/doc/rake-doc/html/index.html\fR. It is also available online at \fIhttp://docs.seattlerb.org/rake\fR. +.SH AUTHOR +.B rake +was written by Jim Weirich +.PP +This manual was created by Caitlin Matos for the Debian project (but may be used by others). It was inspired by the manual by Jani Monoses for the Ubuntu project. diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rakefile.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rakefile.rdoc new file mode 100644 index 000000000..fd652c741 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rakefile.rdoc @@ -0,0 +1,653 @@ += Rakefile Format + +First of all, there is no special format for a Rakefile. A Rakefile +contains executable Ruby code. Anything legal in a ruby script is +allowed in a Rakefile. + +Now that we understand there is no special syntax in a Rakefile, there +are some conventions that are used in a Rakefile that are a little +unusual in a typical Ruby program. Since a Rakefile is tailored to +specifying tasks and actions, the idioms used in a Rakefile are +designed to support that. + +So, what goes into a Rakefile? + +== Tasks + +Tasks are the main unit of work in a Rakefile. Tasks have a name +(usually given as a symbol or a string), a list of prerequisites (more +symbols or strings) and a list of actions (given as a block). + +=== Simple Tasks + +A task is declared by using the +task+ method. +task+ takes a single +parameter that is the name of the task. + + task :name + +=== Tasks with Prerequisites + +Any prerequisites are given as a list (enclosed in square brackets) +following the name and an arrow (=>). + + task name: [:prereq1, :prereq2] + +*NOTE:* Although this syntax looks a little funky, it is legal +Ruby. We are constructing a hash where the key is :name and the value +for that key is the list of prerequisites. It is equivalent to the +following ... + + hash = Hash.new + hash[:name] = [:prereq1, :prereq2] + task(hash) + +You can also use strings for task names and prerequisites, rake doesn't care. +This is the same task definition: + + task 'name' => %w[prereq1 prereq2] + +As is this: + + task name: %w[prereq1 prereq2] + +We'll prefer this style for regular tasks with prerequisites throughout the +rest of the document. Using an array of strings for the prerequisites means +you will need to make fewer changes if you need to move tasks into namespaces +or perform other refactorings. + +=== Tasks with Actions + +Actions are defined by passing a block to the +task+ method. Any Ruby +code can be placed in the block. The block may reference the task +object via the block parameter. + + task name: [:prereq1, :prereq2] do |t| + # actions (may reference t) + end + +=== Multiple Definitions + +A task may be specified more than once. Each specification adds its +prerequisites and actions to the existing definition. This allows one +part of a rakefile to specify the actions and a different rakefile +(perhaps separately generated) to specify the dependencies. + +For example, the following is equivalent to the single task +specification given above. + + task :name + task name: :prereq1 + task name: %w[prereq2] + task :name do |t| + # actions + end + +== File Tasks + +Some tasks are designed to create a file from one or more other files. +Tasks that generate these files may be skipped if the file already +exists. File tasks are used to specify file creation tasks. + +File tasks are declared using the +file+ method (instead of the +task+ +method). In addition, file tasks are usually named with a string +rather than a symbol. + +The following file task creates a executable program (named +prog+) +given two object files named +a.o+ and +b.o+. The tasks +for creating +a.o+ and +b.o+ are not shown. + + file "prog" => ["a.o", "b.o"] do |t| + sh "cc -o #{t.name} #{t.prerequisites.join(' ')}" + end + +== Directory Tasks + +It is common to need to create directories upon demand. The ++directory+ convenience method is a short-hand for creating a FileTask +that creates the directory. For example, the following declaration +... + + directory "testdata/examples/doc" + +is equivalent to ... + + file "testdata" do |t| mkdir t.name end + file "testdata/examples" => ["testdata"] do |t| mkdir t.name end + file "testdata/examples/doc" => ["testdata/examples"] do |t| mkdir t.name end + +The +directory+ method does not accept prerequisites or actions, but +both prerequisites and actions can be added later. For example ... + + directory "testdata" + file "testdata" => ["otherdata"] + file "testdata" do + cp Dir["standard_data/*.data"], "testdata" + end + +== Tasks with Parallel Prerequisites + +Rake allows parallel execution of prerequisites using the following syntax: + + multitask copy_files: %w[copy_src copy_doc copy_bin] do + puts "All Copies Complete" + end + +In this example, +copy_files+ is a normal rake task. Its actions are +executed whenever all of its prerequisites are done. The big +difference is that the prerequisites (+copy_src+, +copy_bin+ and ++copy_doc+) are executed in parallel. Each of the prerequisites are +run in their own Ruby thread, possibly allowing faster overall runtime. + +=== Secondary Prerequisites + +If any of the primary prerequisites of a multitask have common secondary +prerequisites, all of the primary/parallel prerequisites will wait +until the common prerequisites have been run. + +For example, if the copy_xxx tasks have the +following prerequisites: + + task copy_src: :prep_for_copy + task copy_bin: :prep_for_copy + task copy_doc: :prep_for_copy + +Then the +prep_for_copy+ task is run before starting all the copies in +parallel. Once +prep_for_copy+ is complete, +copy_src+, +copy_bin+, +and +copy_doc+ are all run in parallel. Note that +prep_for_copy+ is +run only once, even though it is referenced in multiple threads. + +=== Thread Safety + +The Rake internal data structures are thread-safe with respect +to the multitask parallel execution, so there is no need for the user +to do extra synchronization for Rake's benefit. However, if there are +user data structures shared between the parallel prerequisites, the +user must do whatever is necessary to prevent race conditions. + +== Tasks with Arguments + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.2] + +And the string "0.8.2" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire name + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Task Arguments and the Environment + +Task argument values can also be picked up from the environment. For +example, if the "release" task expected a parameter named +"release_version", then either + + rake release[0.8.2] + +or + + RELEASE_VERSION=0.8.2 rake release + +or, alternatively + + rake release RELEASE_VERSION=0.8.2 + +will work. Environment variable names must either match the task +parameter exactly, or match an all-uppercase version of the task +parameter. + +*NOTE:* A variable declared within a rake command will +not persist in the environment: + + $ export VALUE=old + $ rake print_value VALUE=new + new + $ rake print_value + old + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, [:first_name, :last_name] + +The first argument is still the name of the task (:name in this case). +The next two arguments are the names of the parameters expected by +:name in an array (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, [:first_name, :last_name] do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +picked up from matching environment variables. If there are no +matching environment variables, they are given the nil value. + +If you wish to specify default values for the arguments, you can use +the with_defaults method in the task body. Here is the above example +where we specify default values for the first and last names: + + task :name, [:first_name, :last_name] do |t, args| + args.with_defaults(:first_name => "John", :last_name => "Dough") + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +=== Tasks that Expect Parameters and Have Prerequisites + +Tasks that use parameters have a slightly different format for +prerequisites. Use the arrow notation to indicate the prerequisites +for tasks with arguments. For example: + + task :name, [:first_name, :last_name] => [:pre_name] do |t, args| + args.with_defaults(:first_name => "John", :last_name => "Dough") + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +=== Tasks that take Variable-length Parameters + +Tasks that need to handle a list of values as a parameter can use the +extras method of the args variable. This allows for tasks that can +loop over a variable number of values, and its compatible with named +parameters as well: + + task :email, [:message] do |t, args| + mail = Mail.new(args.message) + recipients = args.extras + recipients.each do |target| + mail.send_to(target) + end + end + +There is also the convenience method to_a that returns all parameters +in the sequential order they were given, including those associated +with named parameters. + +=== Deprecated Task Parameters Format + +There is an older format for declaring task parameters that omitted +the task argument array and used the :needs keyword to introduce the +dependencies. That format is still supported for compatibility, but +is not recommended for use. The older format may be dropped in future +versions of rake. + +== Accessing Task Programmatically + +Sometimes it is useful to manipulate tasks programmatically in a +Rakefile. To find a task object use Rake::Task.[]. + +=== Programmatic Task Example + +For example, the following Rakefile defines two tasks. The :doit task +simply prints a simple "DONE" message. The :dont class will lookup +the doit class and remove (clear) all of its prerequisites and +actions. + + task :doit do + puts "DONE" + end + + task :dont do + Rake::Task[:doit].clear + end + +Running this example: + + $ rake doit + (in /Users/jim/working/git/rake/x) + DONE + $ rake dont doit + (in /Users/jim/working/git/rake/x) + $ + +The ability to programmatically manipulate tasks gives rake very +powerful meta-programming capabilities w.r.t. task execution, but +should be used with caution. + +== Rules + +When a file is named as a prerequisite, but does not have a file task +defined for it, Rake will attempt to synthesize a task by looking at a +list of rules supplied in the Rakefile. + +Suppose we were trying to invoke task "mycode.o", but no task is +defined for it. But the rakefile has a rule that look like this ... + + rule '.o' => ['.c'] do |t| + sh "cc #{t.source} -c -o #{t.name}" + end + +This rule will synthesize any task that ends in ".o". It has a +prerequisite a source file with an extension of ".c" must exist. If +Rake is able to find a file named "mycode.c", it will automatically +create a task that builds "mycode.o" from "mycode.c". + +If the file "mycode.c" does not exist, rake will attempt +to recursively synthesize a rule for it. + +When a task is synthesized from a rule, the +source+ attribute of the +task is set to the matching source file. This allows us to write +rules with actions that reference the source file. + +=== Advanced Rules + +Any regular expression may be used as the rule pattern. Additionally, +a proc may be used to calculate the name of the source file. This +allows for complex patterns and sources. + +The following rule is equivalent to the example above. + + rule( /\.o$/ => [ + proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') } + ]) do |t| + sh "cc #{t.source} -c -o #{t.name}" + end + +*NOTE:* Because of a _quirk_ in Ruby syntax, parenthesis are +required on *rule* when the first argument is a regular expression. + +The following rule might be used for Java files ... + + rule '.class' => [ + proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') } + ] do |t| + java_compile(t.source, t.name) + end + +*NOTE:* +java_compile+ is a hypothetical method that invokes the +java compiler. + +== Importing Dependencies + +Any ruby file (including other rakefiles) can be included with a +standard Ruby +require+ command. The rules and declarations in the +required file are just added to the definitions already accumulated. + +Because the files are loaded _before_ the rake targets are evaluated, +the loaded files must be "ready to go" when the rake command is +invoked. This makes generated dependency files difficult to use. By +the time rake gets around to updating the dependencies file, it is too +late to load it. + +The +import+ command addresses this by specifying a file to be loaded +_after_ the main rakefile is loaded, but _before_ any targets on the +command line are invoked. In addition, if the file name matches an +explicit task, that task is invoked before loading the file. This +allows dependency files to be generated and used in a single rake +command invocation. + +Example: + + require 'rake/loaders/makefile' + + file ".depends.mf" => [SRC_LIST] do |t| + sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}" + end + + import ".depends.mf" + +If ".depends" does not exist, or is out of date w.r.t. the source +files, a new ".depends" file is generated using +makedepend+ before +loading. + +== Comments + +Standard Ruby comments (beginning with "#") can be used anywhere it is +legal in Ruby source code, including comments for tasks and rules. +However, if you wish a task to be described using the "-T" switch, +then you need to use the +desc+ command to describe the task. + +Example: + + desc "Create a distribution package" + task package: %w[ ... ] do ... end + +The "-T" switch (or "--tasks" if you like to spell things out) will +display a list of tasks that have a description. If you use +desc+ to +describe your major tasks, you have a semi-automatic way of generating +a summary of your Rake file. + + traken$ rake -T + (in /home/.../rake) + rake clean # Remove any temporary products. + rake clobber # Remove any generated file. + rake clobber_rdoc # Remove rdoc products + rake contrib_test # Run tests for contrib_test + rake default # Default Task + rake install # Install the application + rake lines # Count lines in the main rake file + rake rdoc # Build the rdoc HTML Files + rake rerdoc # Force a rebuild of the RDOC files + rake test # Run tests + rake testall # Run all test targets + +Only tasks with descriptions will be displayed with the "-T" switch. +Use "-P" (or "--prereqs") to get a list of all tasks and their +prerequisites. + +== Namespaces + +As projects grow (and along with it, the number of tasks), it is +common for task names to begin to clash. For example, if you might +have a main program and a set of sample programs built by a single +Rakefile. By placing the tasks related to the main program in one +namespace, and the tasks for building the sample programs in a +different namespace, the task names will not interfere with each other. + +For example: + + namespace "main" do + task :build do + # Build the main program + end + end + + namespace "samples" do + task :build do + # Build the sample programs + end + end + + task build: %w[main:build samples:build] + +Referencing a task in a separate namespace can be achieved by +prefixing the task name with the namespace and a colon +(e.g. "main:build" refers to the :build task in the +main+ namespace). +Nested namespaces are supported. + +Note that the name given in the +task+ command is always the unadorned +task name without any namespace prefixes. The +task+ command always +defines a task in the current namespace. + +=== FileTasks + +File task names are not scoped by the namespace command. Since the +name of a file task is the name of an actual file in the file system, +it makes little sense to include file task names in name space. +Directory tasks (created by the +directory+ command) are a type of +file task and are also not affected by namespaces. + +=== Name Resolution + +When looking up a task name, rake will start with the current +namespace and attempt to find the name there. If it fails to find a +name in the current namespace, it will search the parent namespaces +until a match is found (or an error occurs if there is no match). + +The "rake" namespace is a special implicit namespace that refers to +the toplevel names. + +If a task name begins with a "^" character, the name resolution will +start in the parent namespace. Multiple "^" characters are allowed. + +Here is an example file with multiple :run tasks and how various names +resolve in different locations. + + task :run + + namespace "one" do + task :run + + namespace "two" do + task :run + + # :run => "one:two:run" + # "two:run" => "one:two:run" + # "one:two:run" => "one:two:run" + # "one:run" => "one:run" + # "^run" => "one:run" + # "^^run" => "rake:run" (the top level task) + # "rake:run" => "rake:run" (the top level task) + end + + # :run => "one:run" + # "two:run" => "one:two:run" + # "^run" => "rake:run" + end + + # :run => "rake:run" + # "one:run" => "one:run" + # "one:two:run" => "one:two:run" + +== FileLists + +FileLists are the way Rake manages lists of files. You can treat a +FileList as an array of strings for the most part, but FileLists +support some additional operations. + +=== Creating a FileList + +Creating a file list is easy. Just give it the list of file names: + + fl = FileList['file1.rb', file2.rb'] + +Or give it a glob pattern: + + fl = FileList['*.rb'] + +== Odds and Ends + +=== do/end versus { } + +Blocks may be specified with either a +do+/+end+ pair, or with curly +braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the +actions for tasks and rules. Because the rakefile idiom tends to +leave off parentheses on the task/file/rule methods, unusual +ambiguities can arise when using curly braces. + +For example, suppose that the method +object_files+ returns a list of +object files in a project. Now we use +object_files+ as the +prerequisites in a rule specified with actions in curly braces. + + # DON'T DO THIS! + file "prog" => object_files { + # Actions are expected here (but it doesn't work)! + } + +Because curly braces have a higher precedence than +do+/+end+, the +block is associated with the +object_files+ method rather than the ++file+ method. + +This is the proper way to specify the task ... + + # THIS IS FINE + file "prog" => object_files do + # Actions go here + end + +== Rakefile Path + +When issuing the +rake+ command in a terminal, Rake will look +for a Rakefile in the current directory. If a Rakefile is not found, +it will search parent directories until one is found. + +For example, if a Rakefile resides in the +project/+ directory, +moving deeper into the project's directory tree will not have an adverse +effect on rake tasks: + + $ pwd + /home/user/project + + $ cd lib/foo/bar + $ pwd + /home/user/project/lib/foo/bar + + $ rake run_pwd + /home/user/project + +As far as rake is concerned, all tasks are run from the directory in +which the Rakefile resides. + +=== Multiple Rake Files + +Not all tasks need to be included in a single Rakefile. Additional +rake files (with the file extension "+.rake+") may be placed in ++rakelib+ directory located at the top level of a project (i.e. +the same directory that contains the main +Rakefile+). + +Also, rails projects may include additional rake files in the ++lib/tasks+ directory. + +=== Clean and Clobber Tasks + +Through require 'rake/clean' Rake provides +clean+ and +clobber+ +tasks: + ++clean+ :: + Clean up the project by deleting scratch files and backup files. Add files + to the +CLEAN+ FileList to have the +clean+ target handle them. + ++clobber+ :: + Clobber all generated and non-source files in a project. The task depends + on +clean+, so all the +CLEAN+ files will be deleted as well as files in the + +CLOBBER+ FileList. The intent of this task is to return a project to its + pristine, just unpacked state. + +You can add file names or glob patterns to both the +CLEAN+ and +CLOBBER+ +lists. + +=== Phony Task + +The phony task can be used as a dependency to allow file-based tasks to use +non-file-based-tasks as prerequisites without forcing them to rebuild. You +can require 'rake/phony' to add the +phony+ task. + +---- + +== See + +* README.rdoc -- Main documentation for Rake. diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rational.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rational.rdoc new file mode 100644 index 000000000..0e1c33873 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/rational.rdoc @@ -0,0 +1,151 @@ += Why rake? + +Ok, let me state from the beginning that I never intended to write this +code. I'm not convinced it is useful, and I'm not convinced anyone +would even be interested in it. All I can say is that Why's onion truck +must by been passing through the Ohio valley. + +What am I talking about? ... A Ruby version of Make. + +See, I can sense you cringing already, and I agree. The world certainly +doesn't need yet another reworking of the "make" program. I mean, we +already have "ant". Isn't that enough? + +It started yesterday. I was helping a coworker fix a problem in one of +the Makefiles we use in our project. Not a particularly tough problem, +but during the course of the conversation I began lamenting some of the +shortcomings of make. In particular, in one of my makefiles I wanted to +determine the name of a file dynamically and had to resort to some +simple scripting (in Ruby) to make it work. "Wouldn't it be nice if you +could just use Ruby inside a Makefile" I said. + +My coworker (a recent convert to Ruby) agreed, but wondered what it +would look like. So I sketched the following on the whiteboard... + + "What if you could specify the make tasks in Ruby, like this ..." + + task "build" do + java_compile(...args, etc ...) + end + + "The task function would register "build" as a target to be made, + and the block would be the action executed whenever the build + system determined that it was time to do the build target." + +We agreed that would be cool, but writing make from scratch would be WAY +too much work. And that was the end of that! + +... Except I couldn't get the thought out of my head. What exactly +would be needed to make the about syntax work as a make file? Hmmm, you +would need to register the tasks, you need some way of specifying +dependencies between tasks, and some way of kicking off the process. +Hey! What if we did ... and fifteen minutes later I had a working +prototype of Ruby make, complete with dependencies and actions. + +I showed the code to my coworker and we had a good laugh. It was just +about a page worth of code that reproduced an amazing amount of the +functionality of make. We were both truly stunned with the power of +Ruby. + +But it didn't do everything make did. In particular, it didn't have +timestamp based file dependencies (where a file is rebuilt if any of its +prerequisite files have a later timestamp). Obviously THAT would be a +pain to add and so Ruby Make would remain an interesting experiment. + +... Except as I walked back to my desk, I started thinking about what +file based dependencies would really need. Rats! I was hooked again, +and by adding a new class and two new methods, file/timestamp +dependencies were implemented. + +Ok, now I was really hooked. Last night (during CSI!) I massaged the +code and cleaned it up a bit. The result is a bare-bones replacement +for make in exactly 100 lines of code. + +For the curious, you can see it at ... +* doc/proto_rake.rdoc + +Oh, about the name. When I wrote the example Ruby Make task on my +whiteboard, my coworker exclaimed "Oh! I have the perfect name: Rake ... +Get it? Ruby-Make. Rake!" He said he envisioned the tasks as leaves +and Rake would clean them up ... or something like that. Anyways, the +name stuck. + +Some quick examples ... + +A simple task to delete backup files ... + + task :clean do + Dir['*~'].each {|fn| rm fn rescue nil} + end + +Note that task names are symbols (they are slightly easier to type +than quoted strings ... but you may use quoted string if you would +rather). Rake makes the methods of the FileUtils module directly +available, so we take advantage of the rm command. Also note +the use of "rescue nil" to trap and ignore errors in the rm +command. + +To run it, just type "rake clean". Rake will automatically find a +Rakefile in the current directory (or above!) and will invoke the +targets named on the command line. If there are no targets explicitly +named, rake will invoke the task "default". + +Here's another task with dependencies ... + + task :clobber => [:clean] do + rm_r "tempdir" + end + +Task :clobber depends upon task :clean, so :clean will be run before +:clobber is executed. + +Files are specified by using the "file" command. It is similar to the +task command, except that the task name represents a file, and the task +will be run only if the file doesn't exist, or if its modification time +is earlier than any of its prerequisites. + +Here is a file based dependency that will compile "hello.cc" to +"hello.o". + + file "hello.cc" + file "hello.o" => ["hello.cc"] do |t| + srcfile = t.name.sub(/\.o$/, ".cc") + sh %{g++ #{srcfile} -c -o #{t.name}} + end + +I normally specify file tasks with string (rather than symbols). Some +file names can't be represented by symbols. Plus it makes the +distinction between them more clear to the casual reader. + +Currently writing a task for each and every file in the project would be +tedious at best. I envision a set of libraries to make this job +easier. For instance, perhaps something like this ... + + require 'rake/ctools' + Dir['*.c'].each do |fn| + c_source_file(fn) + end + +where "c_source_file" will create all the tasks need to compile all the +C source files in a directory. Any number of useful libraries could be +created for rake. + +That's it. There's no documentation (other than whats in this +message). Does this sound interesting to anyone? If so, I'll continue +to clean it up and write it up and publish it on RAA. Otherwise, I'll +leave it as an interesting exercise and a tribute to the power of Ruby. + +Why /might/ rake be interesting to Ruby programmers. I don't know, +perhaps ... + +* No weird make syntax (only weird Ruby syntax :-) +* No need to edit or read XML (a la ant) +* Platform independent build scripts. +* Will run anywhere Ruby exists, so no need to have "make" installed. + If you stay away from the "sys" command and use things like + 'ftools', you can have a perfectly platform independent + build script. Also rake is only 100 lines of code, so it can + easily be packaged along with the rest of your code. + +So ... Sorry for the long rambling message. Like I said, I never +intended to write this code at all. diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.14.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.14.rdoc new file mode 100644 index 000000000..b2f1f84f3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.14.rdoc @@ -0,0 +1,23 @@ += Rake 0.4.14 Released + +== Changes + +Version 0.4.14 is a compatibility fix to allow Rake's test task to +work under Ruby 1.8.2. A change in the Test::Unit autorun feature +prevented Rake from running any tests. This release fixes the +problem. + +Rake 0.4.14 is the recommended release for anyone using Ruby 1.8.2. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.15.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.15.rdoc new file mode 100644 index 000000000..975708863 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.4.15.rdoc @@ -0,0 +1,35 @@ += Rake 0.4.15 Released + +== Changes + +Version 0.4.15 is a bug fix update for the Ruby 1.8.2 compatibility +changes. This release includes: + +* Fixed a bug that prevented the TESTOPTS flag from working with the + revised for 1.8.2 test task. + +* Updated the docs on --trace to indicate that it also enables a full + backtrace on errors. + +* Several fixes for new warnings generated. + +== Mini-Roadmap + +I will continue to issue Rake updates in the 0.4.xx series as new +Ruby-1.8.2 issues become manifest. Once the codebase stabilizes, I +will release a 0.5.0 version incorporating all the changes. If you +are not using Ruby-1.8.2 and wish to avoid version churn, I recommend +staying with a release prior to Rake-0.4.14. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.0.rdoc new file mode 100644 index 000000000..f5cb9f307 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.0.rdoc @@ -0,0 +1,53 @@ += Rake 0.5.0 Released + +It has been a long time in coming, but we finally have a new version +of Rake available. + +== Changes + +* Fixed bug where missing intermediate file dependencies could cause + an abort with --trace or --dry-run. (Brian Candler) + +* Recursive rules are now supported (Tilman Sauerbeck). + +* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). + +* Added warning option for the Test Task (requested by Eric Hodel). + +* The jamis rdoc template is only used if it exists. + +* Added fix for Ruby 1.8.2 test/unit and rails problem. + +* Added contributed rake man file. (Jani Monoses) + +* Fixed documentation that was lacking the Rake module name (Tilman + Sauerbeck). + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +Lots of people provided input to this release. Thanks to Tilman +Sauerbeck for numerous patches, documentation fixes and suggestions. +And for also pushing me to get this release out. Also, thanks to +Brian Candler for the finding and fixing --trace/dry-run fix. That +was an obscure bug. Also to Eric Hodel for some good suggestions. + +-- Jim Weirich + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.3.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.3.rdoc new file mode 100644 index 000000000..451da4a0a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.3.rdoc @@ -0,0 +1,78 @@ += Rake 0.5.3 Released + +Although it has only been two weeks since the last release, we have +enough updates to the Rake program to make it time for another +release. + +== Changes + +Here are the changes for version 0.5.3 ... + +* FileLists have been extensively changed so that they mimic the + behavior of real arrays even more closely. In particular, + operations on FileLists that return a new collection (e.g. collect, + reject) will now return a FileList rather than an array. In + addition, several places where FileLists were not properly expanded + before use have been fixed. + +* A method (+ext+) to simplify the handling of file extensions was + added to String and to Array. + +* The 'testrb' script in test/unit tends to silently swallow syntax + errors in test suites. Because of that, the default test loader is + now a rake-provided script. You can still use 'testrb' by setting + the loader flag in the test task to :testrb. (See the API documents + for TestTask for all the loader flag values). + +* FileUtil methods (e.g. cp, mv, install) are now declared to be + private. This will cut down on the interference with user defined + methods of the same name. + +* Fixed the verbose flag in the TestTask so that the test code is + controlled by the flag. Also shortened up some failure messages. + (Thanks to Tobias Luetke for the suggestion). + +* Rules will now properly detect a task that can generate a source + file. Previously rules would only consider source files that were + already present. + +* Added an +import+ command that allows Rake to dynamically import + dependendencies into a running Rake session. The +import+ command + can run tasks to update the dependency file before loading them. + Dependency files can be in rake or make format, allowing rake to + work with tools designed to generate dependencies for make. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Brian Gernhardt for the rules fix (especially for the patience to + explain the problem to me until I got what he was talking about). +* Stefan Lang for pointing out problems in the dark corners of the + FileList implementation. +* Alexey Verkhovsky pointing out the silently swallows syntax errors + in tests. +* Tobias Luetke for beautifying the test task output. +* Sam Roberts for some of the ideas behind dependency loading. + +-- Jim Weirich + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.4.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.4.rdoc new file mode 100644 index 000000000..112587fb9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.5.4.rdoc @@ -0,0 +1,46 @@ += Rake 0.5.4 Released + +Time for some minor bug fixes and small enhancements + +== Changes + +Here are the changes for version 0.5.4 ... + +* Added double quotes to the test runner. This allows the location of + the tests (and runner) to be in a directory path that contains + spaces (e.g. "C:/Program Files/ruby/bin"). + +* Added .svn to default ignore list. Now subversion project metadata + is automatically ignored by Rake's FileList. + +* Updated FileList#include to support nested arrays and filelists. + FileLists are flat lists of file names. Using a FileList in an + include will flatten out the nested file names. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Tilman Sauerbeck for the nested FileList suggestion. +* Josh Knowles for pointing out the spaces in directory name problem. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.6.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.6.0.rdoc new file mode 100644 index 000000000..340c07bf7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.6.0.rdoc @@ -0,0 +1,141 @@ += Rake 0.6.0 Released + +Its time for some long requested enhancements and lots of bug fixes +... And a whole new web page. + +== New Web Page + +The primary documentation for rake has moved from the RubyForge based +wiki to its own Hieraki based web site. Constant spam on the wiki +made it a difficult to keep clean. The new site will be easier to +update and organize. + +Check out the new documentation at: http://docs.rubyrake.org + +We will be adding new documentation to the site as time goes on. + +In addition to the new docs page, make sure you check out Martin +Fowlers article on rake at http://martinfowler.com/articles/rake.html + +== Changes + +=== New Features + +* Multiple prerequisites on Rake rules now allowed. However, keep the + following in mind: + + 1. All the prerequisites of a rule must be available before a rule + is triggered, where "enabled" means (a) an existing file, (b) a + defined rule, or (c) another rule which also must be + trigger-able. + 2. Rules are checked in order of definition, so it is important to + order your rules properly. If a file can be created by two + different rules, put the more specific rule first (otherwise the + more general rule will trigger first and the specific one will + never be triggered). + 3. The source method now returns the name of the first + prerequisite listed in the rule. sources returns the + names of all the rule prerequisites, ordered as they are defined + in the rule. If the task has other prerequisites not defined in + the rule (but defined in an explicit task definition), then they + will _not_ be included in the sources list. + +* FileLists may now use the egrep command. This popular enhancement + is now a core part of the FileList object. If you want to get a + list of all your to-dos, fixmes and TBD comments, add the following + to your Rakefile. + + desc "Look for TODO and FIXME tags in the code" + task :todo do + FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/ + end + +* The investigation method was added to task object to dump + out some important values. This makes it a bit easier to debug Rake + tasks. + + For example, if you are having problems with a particular task, just + print it out: + + task :huh do + puts Rake::Task['huh'].investigation + end + +* The Rake::TestTask class now supports a "ruby_opts" option to pass + arbitrary ruby options to a test subprocess. + +=== Some Incompatibilities + +* When using the ruby command to start a Ruby subprocess, the + Ruby interpreter that is currently running rake is used by default. + This makes it easier to use rake in an environment with multiple + ruby installation. (Previously, the first ruby command found in the + PATH was used). + + If you wish to chose a different Ruby interpreter, you can + explicitly choose the interpreter via the sh command. + +* The major rake classes (Task, FileTask, FileCreationTask, RakeApp) + have been moved out of the toplevel scope and are now accessible as + Rake::Task, Rake::FileTask, Rake::FileCreationTask and + Rake::Application. If your Rakefile + directly references any one of these tasks, you may: + + 1. Update your Rakefile to use the new classnames + 2. Use the --classic-namespace option on the rake command to get the + old behavior, + 3. Add require 'rake/classic_namespace' to the + Rakefile to get the old behavior. + + rake will print a rather annoying warning whenever a + deprecated class name is referenced without enabling classic + namespace. + +=== Bug Fixes + +* Several unit tests and functional tests were fixed to run better + under windows. + +* Directory tasks are now a specialized version of a File task. A + directory task will only be triggered if it doesn't exist. It will + not be triggered if it is out of date w.r.t. any of its + prerequisites. + +* Fixed a bug in the Rake::GemPackageTask class so that the gem now + properly contains the platform name. + +* Fixed a bug where a prerequisite on a file task would cause + an exception if the prerequisite did not exist. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Greg Fast (better ruby_opt test options) +* Kelly Felkins (requested by better namespace support) +* Martin Fowler (suggested Task.investigation) +* Stuart Jansen (send initial patch for multiple prerequisites). +* Masao Mutch (better support for non-ruby Gem platforms) +* Philipp Neubeck (patch for file task exception fix) + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.0.rdoc new file mode 100644 index 000000000..b8bf56ebb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.0.rdoc @@ -0,0 +1,119 @@ += Rake 0.7.0 Released + +These changes for Rake have been brewing for a long time. Here they +are, I hope you enjoy them. + +== Changes + +=== New Features + +* Name space support for task names (see below). + +* Prerequisites can be executed in parallel (see below). + +* Added safe_ln support for openAFS (via Ludvig Omholt). + +* RDoc defaults to internal (in-process) invocation. The old behavior + is still available by setting the +external+ flag to true. + +* Rakefiles are now loaded with the expanded path to prevent + accidental polution from the Ruby load path. + +* Task objects my now be used in prerequisite lists directly. + +* Task objects (in addition to task names) may now be included in the + prerequisite list of a task. + +* Internals cleanup and refactoring. + +=== Bug Fixes + +* Compatibility fixes for Ruby 1.8.4 FileUtils changes. + +=== Namespaces + +Tasks can now be nested inside their own namespaces. Tasks within one +namespace will not accidently interfer with tasks named in a different +namespace. + +For example: + + namespace "main" do + task :build do + # Build the main program + end + end + + namespace "samples" do + task :build do + # Build the sample programs + end + end + + task :build_all => ["main:build", "samples:build"] + +Even though both tasks are named :build, they are separate tasks in +their own namespaces. The :build_all task (defined in the toplevel +namespace) references both build tasks in its prerequisites. + +You may invoke each of the individual build tasks with the following +commands: + + rake main:build + rake samples:build + +Or invoke both via the :build_all command: + + rake build_all + +Namespaces may be nested arbitrarily. Since the name of file tasks +correspond to the name of a file in the external file system, +FileTasks are not affected by the namespaces. + +See the Rakefile format documentation (in the Rake API documents) for +more information. + +=== Parallel Tasks + +Sometimes you have several tasks that can be executed in parallel. By +specifying these tasks as prerequisites to a +multitask+ task. + +In the following example the tasks copy_src, copy_doc and copy_bin +will all execute in parallel in their own thread. + + multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do + puts "All Copies Complete" + end + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Doug Young (inspriation for the parallel task) + +* David Heinemeier Hansson (for --trace message enhancement and for + pushing for namespace support). + +* Ludvig Omholt (for the openAFS fix) + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.1.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.1.rdoc new file mode 100644 index 000000000..c17088ee9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.1.rdoc @@ -0,0 +1,59 @@ += Rake 0.7.1 Released + +Version 0.7.1 supplies a bug fix and a few minor enhancements. + +== Changes + +=== Bug Fixes in 0.7.1 + +* Changes in the exception reported for the FileUtils.ln caused + safe_ln to fail with a NotImplementedError. Rake 0.7.1 will now + catch that error or any StandardError and properly fall back to + using +cp+. + +=== New Features in 0.7.1 + +* You can filter the results of the --task option by supplying an + optional regular expression. This allows the user to easily find a + particular task name in a long list of possible names. + +* Transforming procs in a rule may now return a list of prerequisites. + This allows more flexible rule formation. + +* FileList and String now support a +pathmap+ melthod that makes the + transforming paths a bit easier. See the API docs for +pathmap+ for + details. + +* The -f option without a value will disable the search for a + Rakefile. This allows the Rakefile to be defined entirely in a + library (and loaded with the -r option). The current working + directory is not changed when this is done. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* James Britt and Assaph Mehr for reporting and helping to debug the + safe_ln issue. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.2.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.2.rdoc new file mode 100644 index 000000000..ec99ee0c0 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.2.rdoc @@ -0,0 +1,121 @@ += Rake 0.7.2 Released + +Version 0.7.2 supplies a bug fix and a few minor enhancements. In +particular, the new version fixes an incompatibility with the soon to +be released Ruby 1.8.6. We strongly recommend upgrading to Rake 0.7.2 +in order to be compatible with the new version of Ruby. + +== Changes + +=== Bug Fixes in 0.7.2 + +There are quite a number of bug fixes in the new 0.7.2 version of +Rake: + +* Removed dependency on internal fu_xxx functions from FileUtils. + +* Error messages are now send to stderr rather than stdout (from + Payton Quackenbush). + +* Better error handling on invalid command line arguments (from Payton + Quackenbush). + +* Fixed some bugs where the application object was going to the global + appliation instead of using its own data. + +* Fixed the method name leak from FileUtils (bug found by Glenn + Vanderburg). + +* Added test for noop, bad_option and verbose flags to sh command. + +* Added a description to the gem task in GemPackageTask. + +* Fixed a bug when rules have multiple prerequisites (patch by Joel + VanderWerf) + +* Added the handful of RakeFileUtils to the private method as well. + +=== New Features in 0.7.2 + +The following new features are available in Rake version 0.7.2: + +* Added square and curly bracket patterns to FileList#include (Tilman + Sauerbeck). + +* FileLists can now pass a block to FileList#exclude to exclude files + based on calculated values. + +* Added plain filename support to rule dependents (suggested by Nobu + Nakada). + +* Added pathmap support to rule dependents. In other words, if a + pathmap format (beginning with a '%') is given as a Rake rule + dependent, then the name of the depend will be the name of the + target with the pathmap format applied. + +* Added a 'tasks' method to a namespace to get a list of tasks + associated with the namespace. + +* Added tar_command and zip_command options to the Package task. + +* The clean task will no longer delete 'core' if it is a directory. + +=== Internal Rake Improvements + +The following changes will are mainly internal improvements and +refactorings and have little effect on the end user. But they may be +of interest to the general public. + +* Added rcov task and updated unit testing for better code coverage. + +* Added a 'shame' task to the Rakefile. + +* Added rake_extension to handle detection of extension collisions. + +* Added a protected 'require "rubygems"' to test/test_application to + unbreak cruisecontrol.rb. + +* Removed rake_dup. Now we just simply rescue a bad dup. + +* Refactored the FileList reject logic to remove duplication. + +* Removed if __FILE__ at the end of the rake.rb file. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Payton Quackenbush -- For several error handling improvements. + +* Glenn Vanderburg -- For finding and fixing the method name leak from + FileUtils. + +* Joel VanderWerf -- for finding and fixing a bug in the handling of + multiple prerequisites. + +* Tilman Sauerbeck -- For some enhancing FileList to support more + advanced file globbing. + +* Nobu Nakada -- For suggesting plain file name support to rule dependents. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.3.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.3.rdoc new file mode 100755 index 000000000..7e9f92198 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.7.3.rdoc @@ -0,0 +1,47 @@ += Rake 0.7.3 Released + +Rake version 0.7.3 is a minor release that includes some refactoring to better +support custom Rake applications. + +== Changes + +=== New Features in Version 0.7.3 + +* Added the +init+ and +top_level+ methods to make the creation of custom Rake applications a bit easier. E.g. + + gem 'rake', ">= 0.7.3" + require 'rake' + + Rake.application.init('myrake') + + task :default do + something_interesting + end + + Rake.application.top_level + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But instead of +cryptic make recipes, Rake uses standard Ruby code to declare tasks and +dependencies. You have the full power of a modern scripting language built +right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.0.rdoc new file mode 100644 index 000000000..4fc7fdd7b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.0.rdoc @@ -0,0 +1,114 @@ += Rake 0.8.0/0.8.1 Released + +Rake version 0.8.0 is a new release of rake that includes serveral new +features. + +== Changes + +=== New Features in Version 0.8.0 + +* Tasks can now receive command line parameters. See the examples + below for more details. + +* Comments are limited to 80 columns on output, but full comments can + be seen by using the -D parameter. (feature suggested by Jamis + Buck). + +* Explicit exit(n) calls will now set the exit status to n. (patch + provided by Stephen Touset). + +* Rake is now compatible with Ruby 1.9. + +Version 0.8.1 is a minor update that includes additional Ruby 1.9 +compatibility fixes. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.0] + +And the string "0.8.0" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the paramters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Jamis Buck (for comment formatting suggestions) +* Stephen Touset (for exit status patch). + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.2.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.2.rdoc new file mode 100644 index 000000000..a822a9497 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.2.rdoc @@ -0,0 +1,165 @@ += Rake 0.8.2 Released + +Rake version 0.8.2 is a new release of rake that includes a number of +new features and numerous bug fixes. + +== Changes + +=== New Features in Version 0.8.2 + +* Switched from getoptlong to optparse (patches supplied by Edwin + Pratomo). + +* The -T option will now attempt to dynamically sense the size of the + terminal. The -T output will only self-truncate if the output is a + tty. However, if RAKE_COLUMNS is explicitly set, it will be honored + in any case. (Patch provided by Gavin Stark). + +* The following public methods have been added to rake task objects: + + * task.clear -- Clear both the prerequisites and actions of the + target rake task. + * task.clear_prerequisites -- Clear all the existing prerequisites + from the target rake task. + * task.clear_actions -- Clear all the existing actions from the + target rake task. + * task.reenable -- Re-enable a task, allowing its actions to be + executed again if the task is invoked. + +* Changed RDoc test task to have no default template. This makes it + easier for the tempate to pick up the template from the environment. + +* Default values for task arguments can easily be specified with the + :with_defaults method. (Idea for default argument merging supplied + by (Adam Q. Salter) + +=== Bug Fixes in Version 0.8.2 + +* Fixed bug in package task so that it will include the subdir + directory in the package for testing. (Bug found by Adam Majer) + +* Fixed filename dependency order bug in test_inspect_pending and + test_to_s_pending. (Bug found by Adam Majer) + +* Fixed check for file utils options to make them immune to the + symbol/string differences. (Patch supplied by Edwin Pratomo) + +* Fixed bug with rules involving multiple source, where only the first + dependency of a rule has any effect (Patch supplied by Emanuel + Indermühle) + +* FileList#clone and FileList#dup have better sematics w.r.t. taint + and freeze. + +* Changed from using Mutex to Monitor. Evidently Mutex causes thread + join errors when Ruby is compiled with -disable-pthreads. (Patch + supplied by Ittay Dror) + +* Fixed bug in makefile parser that had problems with extra spaces in + file task names. (Patch supplied by Ittay Dror) + +== Other changes in Version 0.8.2 + +* Added ENV var to rake's own Rakefile to prevent OS X from including + extended attribute junk in the rake package tar file. (Bug found by + Adam Majer) + +* Added a performance patch for reading large makefile dependency + files. (Patch supplied by Ittay Dror) + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.2] + +And the string "0.8.2" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the paramters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.3.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.3.rdoc new file mode 100644 index 000000000..97184c390 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.3.rdoc @@ -0,0 +1,112 @@ += Rake 0.8.3 Released + +Rake version 0.8.3 is a bug-fix release of rake. + +== Changes + +=== Bug Fixes in Version 0.8.3 + +* Enhanced the system directory detection in windows. We now check + HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch + supplied by James Tucker). Rake no long aborts if it can't find the + directory. + +* Added fix to handle ruby installations in directories with spaces in + their name. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 + +== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.3] + +And the string "0.8.3" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the paramters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.4.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.4.rdoc new file mode 100644 index 000000000..d27de8b27 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.4.rdoc @@ -0,0 +1,147 @@ += Rake 0.8.4 Released + +Rake version 0.8.4 is a bug-fix release of rake. + +NOTE: The version of Rake that comes with Ruby 1.9 has diverged + slightly from the core Rake code base. Rake 0.8.4 will work + with Ruby 1.9, but is not a strict upgrade for the Rake that + comes with Ruby 1.9. A (near) future release of Rake will unify + those two codebases. + +== Letter Writing Campaign + +Thanks to Aaron Patterson (@tenderlove) and Eric Hodel (@drbrain) for +their encouraging support in organizing a letter writing campaign to +lobby for the "Warning Free" release of rake 0.8.4. A special callout +goes to Jonathan D. Lord, Sr (Dr. Wingnut) whose postcard was the +first to actually reach me. (see +http://tenderlovemaking.com/2009/02/26/we-need-a-new-version-of-rake/ +for details) + +== Changes + +=== New Features / Enhancements in Version 0.8.4 + +* Case is preserved on rakefile names. (patch from James + M. Lawrence/quix) + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, + APPDATA, USERPROFILE (patch from Luis Lavena) + +* MingGW is now recognized as a windows platform. (patch from Luis + Lavena) + +=== Bug Fixes in Version 0.8.4 + +* Removed reference to manage_gem to fix the warning produced by the + gem package task. + +* Fixed stray ARGV option problem that was interfering with + Test::Unit::Runner. (patch from Pivotal Labs) + +=== Infrastructure Improvements in Version 0.8.4 + +* Numerous fixes to the windows test suite (patch from Luis Lavena). + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Better support for windows paths in the test task (patch from Simon + Chiang/bahuvrihi) + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.4] + +And the string "0.8.4" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +=== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the paramters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena +* Pivotal Labs +* Simon Chiang/bahuvrihi + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.5.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.5.rdoc new file mode 100644 index 000000000..0ee2583dd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.5.rdoc @@ -0,0 +1,53 @@ += Rake 0.8.5 Released + +Rake version 0.8.5 is a new release of Rake with greatly improved +support for executing commands on Windows. The "sh" command now has +the same semantics on Windows that it has on Unix based platforms. + +== Changes + +=== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +=== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.6.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.6.rdoc new file mode 100644 index 000000000..54782ed02 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.6.rdoc @@ -0,0 +1,37 @@ += Rake 0.8.6 Released + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.5 includes minor fixes the the RDoc generation. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.7.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.7.rdoc new file mode 100644 index 000000000..884f4c659 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.8.7.rdoc @@ -0,0 +1,55 @@ += Rake 0.8.7 Released + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.6 includes minor fixes the the RDoc generation. +Rake version 0.8.7 includes a minor fix for JRuby running on windows. + +== Changes + +=== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +=== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Charles Nutter + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.0.rdoc new file mode 100644 index 000000000..823483cc2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.0.rdoc @@ -0,0 +1,112 @@ += Rake 0.9.0 Released + +Rake version 0.9.0 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +== Changes + +=== New Features / Enhancements / Bug Fixes in Version 0.9.0 + +* Rake now warns when the deprecated :needs syntax used (and suggests + the proper syntax in the warning). + +* Moved Rake DSL commands to top level ruby object 'main'. Rake DSL + commands are no longer private methods in Object. (Suggested by + James M. Lawrence/quix) + +* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. + Based on patch by Roger Pack. + +* Rake now requires (instead of loads) files in the test task. Patch by Cezary + Baginski. + +* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. + +* Rake now prints the Rakefile directory only when it's different from the + current directory. Patch by Alex Chaffee. + +* Improved rakefile_location discovery on Windows. Patch by James Tucker. + +* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias + Lüdtke + +* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require + 'rdoc/task') + +* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require + 'rubygems/package_task') + +* Rake now outputs various messages to $stderr instead of $stdout. + +* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. + +* Removed Rake's DSL methods from the top level scope. If you need to + call 'task :xzy' in your code, include Rake::DSL into your class, or + put the code in a Rake::DSL.environment do ... end block. + +* Split rake.rb into individual files. + +* Support for the --where (-W) flag for showing where a task is defined. + +* Fixed quoting in test task. + (http://onestepback.org/redmine/issues/show/44, + http://www.pivotaltracker.com/story/show/1223138) + +* Fixed the silent option parsing problem. + (http://onestepback.org/redmine/issues/show/47) + +* Fixed :verbose=>false flag on sh and ruby commands. + +* Rake command line options may be given by default in a RAKEOPT + environment variable. + +* Errors in Rake will now display the task invocation chain in effect + at the time of the error. + +* Accepted change by warnickr to not expand test patterns in shell + (allowing more files in the test suite). + +* Fixed that file tasks did not perform prereq lookups in scope + (Redmine #57). + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.1.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.1.rdoc new file mode 100644 index 000000000..70be8b568 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.1.rdoc @@ -0,0 +1,52 @@ += Rake 0.9.1 Released + +Rake version 0.9.1 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +== Changes + +Rake 0.9.1 adds back the global DSL methods, but with deprecation +messages. This allows Rake 0.9.1 to be used with older rakefiles with +warning messages. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.2.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.2.rdoc new file mode 100644 index 000000000..d848f227b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.2.rdoc @@ -0,0 +1,55 @@ += Rake 0.9.2.2 Released + +Rake version 0.9.2.2 is mainly bug fixes. + +== Changes + +* The rake test loader now removes arguments it has processed. Issue #51 +* Rake::TaskArguments now responds to #values_at +* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 +* Rake tests are now directory-independent +* Rake tests are no longer require flexmock +* Commands constant is no longer polluting top level namespace. +* Show only the interesting portion of the backtrace by default (James M. Lawrence). +* Added --reduce-compat option to remove backward compatible DSL hacks (James M. Lawrence). + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.rdoc new file mode 100644 index 000000000..2314193f5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.2.rdoc @@ -0,0 +1,49 @@ += Rake 0.9.2 Released + +Rake version 0.9.2 has a few small fixes. See below for details. + +== Changes + +* Support for Ruby 1.8.6 was fixed. +* Global DSL warnings now honor --no-deprecate + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.3.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.3.rdoc new file mode 100644 index 000000000..4476b4f18 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.3.rdoc @@ -0,0 +1,102 @@ += Rake 0.9.3 Released + +Rake version 0.9.3 contains some new, backwards compatible features and +a number of bug fixes. + +== Changes + +=== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --supress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +=== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.4.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.4.rdoc new file mode 100644 index 000000000..099ebc91b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.4.rdoc @@ -0,0 +1,60 @@ += Rake 0.9.4 Released + +Rake version 0.9.4 contains a number of bug fixes. + +== Changes + +=== Bug Fixes (0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.5.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.5.rdoc new file mode 100644 index 000000000..40c35ee69 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.5.rdoc @@ -0,0 +1,55 @@ += Rake 0.9.5 Released + +Rake version 0.9.5 contains a number of bug fixes. + +== Changes + +=== Bug Fixes (0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.6.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.6.rdoc new file mode 100644 index 000000000..fb247e794 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-0.9.6.rdoc @@ -0,0 +1,64 @@ += Rake 0.9.6 Released + +Rake version 0.9.6 contains a number of fixes mainly for merging +Rake into the Ruby source tree and fixing tests. + +== Changes + +=== Bug Fixes (0.9.6) + +* Better trace output when using a multi-threaded Rakefile. +* Arg parsing is now consistent for tasks and multitasks. +* Skip exit code test in versions of Ruby that don't support it well. + +Changes for better integration with the Ruby source tree: + +* Fix version literal for Ruby source tree build. +* Better loading of libraries for testing in Ruby build. +* Use the ruby version provided by Ruby's tests. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.0.rdoc new file mode 100644 index 000000000..7bf68fb73 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.0.rdoc @@ -0,0 +1,178 @@ += Rake 10.0 Released + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +== Changes in 10.0 + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show_tasks, + $show_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +== Changes (from 0.9.3) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for version 0.9.3 here. + +=== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --supress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +=== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.1.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.1.rdoc new file mode 100644 index 000000000..152af25a5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.1.rdoc @@ -0,0 +1,58 @@ += Rake 10.0.1 Released + +== Changes in 10.0.1 + +=== Bug Fixes + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.2.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.2.rdoc new file mode 100644 index 000000000..bb6bda874 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.2.rdoc @@ -0,0 +1,53 @@ += Rake 10.0.2 Released + +== Changes in Rake 10.0.2 + +=== Bug Fixes + +* --trace and --backtrace no longer swallow following task names. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.3.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.3.rdoc new file mode 100644 index 000000000..dbc84c1c1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.0.3.rdoc @@ -0,0 +1,191 @@ += Rake 10.0.3 Released + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +== Changes in Version 10 + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show_tasks, + $show_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +== Changes (from 0.9.3, 0.9.4, 0.9.5) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for versions 0.9.3 through 0.9.5 here. + +=== New Features (in 0.9.3) + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --supress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +=== Bug Fixes (in 0.9.3) + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +=== Bug Fixes (in 0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +=== Bug Fixes (in 0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://github.com/jimweirich/rake +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.1.0.rdoc b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.1.0.rdoc new file mode 100644 index 000000000..a9f4bb396 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/doc/release_notes/rake-10.1.0.rdoc @@ -0,0 +1,61 @@ += Rake 10.1.0 Released + +== Changes in Version 10.1 + +=== New Features + +* Add support for variable length task argument lists. If more actual + arguments are supplied than named arguments, then the extra + arguments values will be in args.extras. + +* Application name is not displayed in the help banner. (Previously + "rake" was hardcoded, now rake-based applications can display their + own names). + +=== Bug Fixes + +Bug fixes include: + +* Fix backtrace suppression issues. + +* Rules now explicit get task arguments passed to them. + +* Rename FileList#exclude? to FileList#exclude_from_list? to avoid + conflict with new Rails method. + +* Clean / Clobber tasks now report failure to remove files. + +* Plus heaps of internal code cleanup. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more from GitHub: + +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a lot of these changes. +The following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Michael Nikitochkin (general code cleanup) +* Vipul A M (general code cleanup) +* Dennis Bell (variable length task argument lists) +* Jacob Swanner (rules arguments) +* Rafael Rosa Fu (documentation typo) +* Stuart Nelson (install.rb fixes) +* Lee Hambley (application name in help banner) + +-- Jim Weirich diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake.rb new file mode 100644 index 000000000..7366862ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake.rb @@ -0,0 +1,79 @@ +#-- +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +#++ + +module Rake + VERSION = '10.4.2' +end + +require 'rake/version' + +# :stopdoc: +# TODO: Remove in Rake 11 +RAKEVERSION = Rake::VERSION +# :startdoc: + +require 'rbconfig' +require 'fileutils' +require 'singleton' +require 'monitor' +require 'optparse' +require 'ostruct' + +require 'rake/ext/module' +require 'rake/ext/string' +require 'rake/ext/time' + +require 'rake/win32' + +require 'rake/linked_list' +require 'rake/cpu_counter' +require 'rake/scope' +require 'rake/task_argument_error' +require 'rake/rule_recursion_overflow_error' +require 'rake/rake_module' +require 'rake/trace_output' +require 'rake/pseudo_status' +require 'rake/task_arguments' +require 'rake/invocation_chain' +require 'rake/task' +require 'rake/file_task' +require 'rake/file_creation_task' +require 'rake/multi_task' +require 'rake/dsl_definition' +require 'rake/file_utils_ext' +require 'rake/file_list' +require 'rake/default_loader' +require 'rake/early_time' +require 'rake/late_time' +require 'rake/name_space' +require 'rake/task_manager' +require 'rake/application' +require 'rake/backtrace' + +$trace = false + +# :stopdoc: +# +# Some top level Constants. + +FileList = Rake::FileList +RakeFileUtils = Rake::FileUtilsExt diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/alt_system.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/alt_system.rb new file mode 100644 index 000000000..aa7b7791b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/alt_system.rb @@ -0,0 +1,110 @@ +# +# Copyright (c) 2008 James M. Lawrence +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +require 'rbconfig' + +## +# Alternate implementations of system() and backticks `` on Windows +# for ruby-1.8 and earlier. +#-- +# TODO: Remove in Rake 11 + +module Rake::AltSystem # :nodoc: all + WINDOWS = RbConfig::CONFIG["host_os"] =~ + %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! + + class << self + def define_module_function(name, &block) + define_method(name, &block) + module_function(name) + end + end + + if WINDOWS && RUBY_VERSION < "1.9.0" + RUNNABLE_EXTS = %w[com exe bat cmd] + RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i + + define_module_function :kernel_system, &Kernel.method(:system) + define_module_function :kernel_backticks, &Kernel.method(:'`') + + module_function + + def repair_command(cmd) + "call " + ( + if cmd =~ %r!\A\s*\".*?\"! + # already quoted + cmd + elsif match = cmd.match(%r!\A\s*(\S+)!) + if match[1] =~ %r!/! + # avoid x/y.bat interpretation as x with option /y + %Q!"#{match[1]}"! + match.post_match + else + # a shell command will fail if quoted + cmd + end + else + # empty or whitespace + cmd + end + ) + end + + def find_runnable(file) + if file =~ RUNNABLE_PATTERN + file + else + RUNNABLE_EXTS.each { |ext| + test = "#{file}.#{ext}" + return test if File.exist?(test) + } + nil + end + end + + def system(cmd, *args) + repaired = ( + if args.empty? + [repair_command(cmd)] + elsif runnable = find_runnable(cmd) + [File.expand_path(runnable), *args] + else + # non-existent file + [cmd, *args] + end + ) + kernel_system(*repaired) + end + + def backticks(cmd) + kernel_backticks(repair_command(cmd)) + end + + define_module_function :'`', &method(:backticks) + else + # Non-Windows or ruby-1.9+: same as Kernel versions + define_module_function :system, &Kernel.method(:system) + define_module_function :backticks, &Kernel.method(:'`') + define_module_function :'`', &Kernel.method(:'`') + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/application.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/application.rb new file mode 100644 index 000000000..bd72a2efa --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/application.rb @@ -0,0 +1,790 @@ +require 'shellwords' +require 'optparse' + +require 'rake/task_manager' +require 'rake/file_list' +require 'rake/thread_pool' +require 'rake/thread_history_display' +require 'rake/trace_output' +require 'rake/win32' + +module Rake + + CommandLineOptionError = Class.new(StandardError) + + ## + # Rake main application object. When invoking +rake+ from the + # command line, a Rake::Application object is created and run. + + class Application + include TaskManager + include TraceOutput + + # The name of the application (typically 'rake') + attr_reader :name + + # The original directory where rake was invoked. + attr_reader :original_dir + + # Name of the actual rakefile used. + attr_reader :rakefile + + # Number of columns on the terminal + attr_accessor :terminal_columns + + # List of the top level task names (task names from the command line). + attr_reader :top_level_tasks + + DEFAULT_RAKEFILES = [ + 'rakefile', + 'Rakefile', + 'rakefile.rb', + 'Rakefile.rb' + ].freeze + + # Initialize a Rake::Application object. + def initialize + super + @name = 'rake' + @rakefiles = DEFAULT_RAKEFILES.dup + @rakefile = nil + @pending_imports = [] + @imported = [] + @loaders = {} + @default_loader = Rake::DefaultLoader.new + @original_dir = Dir.pwd + @top_level_tasks = [] + add_loader('rb', DefaultLoader.new) + add_loader('rf', DefaultLoader.new) + add_loader('rake', DefaultLoader.new) + @tty_output = STDOUT.tty? + @terminal_columns = ENV['RAKE_COLUMNS'].to_i + end + + # Run the Rake application. The run method performs the following + # three steps: + # + # * Initialize the command line options (+init+). + # * Define the tasks (+load_rakefile+). + # * Run the top level tasks (+top_level+). + # + # If you wish to build a custom rake command, you should call + # +init+ on your application. Then define any tasks. Finally, + # call +top_level+ to run your top level tasks. + def run + standard_exception_handling do + init + load_rakefile + top_level + end + end + + # Initialize the command line parameters and app name. + def init(app_name='rake') + standard_exception_handling do + @name = app_name + args = handle_options + collect_command_line_tasks(args) + end + end + + # Find the rakefile and then load it and any pending imports. + def load_rakefile + standard_exception_handling do + raw_load_rakefile + end + end + + # Run the top level tasks of a Rake application. + def top_level + run_with_threads do + if options.show_tasks + display_tasks_and_comments + elsif options.show_prereqs + display_prerequisites + else + top_level_tasks.each { |task_name| invoke_task(task_name) } + end + end + end + + # Run the given block with the thread startup and shutdown. + def run_with_threads + thread_pool.gather_history if options.job_stats == :history + + yield + + thread_pool.join + if options.job_stats + stats = thread_pool.statistics + puts "Maximum active threads: #{stats[:max_active_threads]} + main" + puts "Total threads in play: #{stats[:total_threads_in_play]} + main" + end + ThreadHistoryDisplay.new(thread_pool.history).show if + options.job_stats == :history + end + + # Add a loader to handle imported files ending in the extension + # +ext+. + def add_loader(ext, loader) + ext = ".#{ext}" unless ext =~ /^\./ + @loaders[ext] = loader + end + + # Application options from the command line + def options + @options ||= OpenStruct.new + end + + # Return the thread pool used for multithreaded processing. + def thread_pool # :nodoc: + @thread_pool ||= ThreadPool.new(options.thread_pool_size || Rake.suggested_thread_count-1) + end + + # internal ---------------------------------------------------------------- + + # Invokes a task with arguments that are extracted from +task_string+ + def invoke_task(task_string) # :nodoc: + name, args = parse_task_string(task_string) + t = self[name] + t.invoke(*args) + end + + def parse_task_string(string) # :nodoc: + /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s + + name = $1 + remaining_args = $2 + + return string, [] unless name + return name, [] if remaining_args.empty? + + args = [] + + begin + /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args + + remaining_args = $2 + args << $1.gsub(/\\(.)/, '\1') + end while remaining_args + + return name, args + end + + # Provide standard exception handling for the given block. + def standard_exception_handling # :nodoc: + yield + rescue SystemExit + # Exit silently with current status + raise + rescue OptionParser::InvalidOption => ex + $stderr.puts ex.message + exit(false) + rescue Exception => ex + # Exit with error message + display_error_message(ex) + exit_because_of_exception(ex) + end + + # Exit the program because of an unhandle exception. + # (may be overridden by subclasses) + def exit_because_of_exception(ex) # :nodoc: + exit(false) + end + + # Display the error message that caused the exception. + def display_error_message(ex) # :nodoc: + trace "#{name} aborted!" + display_exception_details(ex) + trace "Tasks: #{ex.chain}" if has_chain?(ex) + trace "(See full trace by running task with --trace)" unless + options.backtrace + end + + def display_exception_details(ex) # :nodoc: + seen = Thread.current[:rake_display_exception_details_seen] ||= [] + return if seen.include? ex + seen << ex + + display_exception_message_details(ex) + display_exception_backtrace(ex) + display_exception_details(ex.cause) if has_cause?(ex) + end + + def has_cause?(ex) # :nodoc: + ex.respond_to?(:cause) && ex.cause + end + + def display_exception_message_details(ex) # :nodoc: + if ex.instance_of?(RuntimeError) + trace ex.message + else + trace "#{ex.class.name}: #{ex.message}" + end + end + + def display_exception_backtrace(ex) # :nodoc: + if options.backtrace + trace ex.backtrace.join("\n") + else + trace Backtrace.collapse(ex.backtrace).join("\n") + end + end + + # Warn about deprecated usage. + # + # Example: + # Rake.application.deprecate("import", "Rake.import", caller.first) + # + def deprecate(old_usage, new_usage, call_site) # :nodoc: + unless options.ignore_deprecate + $stderr.puts "WARNING: '#{old_usage}' is deprecated. " + + "Please use '#{new_usage}' instead.\n" + + " at #{call_site}" + end + end + + # Does the exception have a task invocation chain? + def has_chain?(exception) # :nodoc: + exception.respond_to?(:chain) && exception.chain + end + private :has_chain? + + # True if one of the files in RAKEFILES is in the current directory. + # If a match is found, it is copied into @rakefile. + def have_rakefile # :nodoc: + @rakefiles.each do |fn| + if File.exist?(fn) + others = FileList.glob(fn, File::FNM_CASEFOLD) + return others.size == 1 ? others.first : fn + elsif fn == '' + return fn + end + end + return nil + end + + # True if we are outputting to TTY, false otherwise + def tty_output? # :nodoc: + @tty_output + end + + # Override the detected TTY output state (mostly for testing) + def tty_output=(tty_output_state) # :nodoc: + @tty_output = tty_output_state + end + + # We will truncate output if we are outputting to a TTY or if we've been + # given an explicit column width to honor + def truncate_output? # :nodoc: + tty_output? || @terminal_columns.nonzero? + end + + # Display the tasks and comments. + def display_tasks_and_comments # :nodoc: + displayable_tasks = tasks.select { |t| + (options.show_all_tasks || t.comment) && + t.name =~ options.show_task_pattern + } + case options.show_tasks + when :tasks + width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10 + if truncate_output? + max_column = terminal_width - name.size - width - 7 + else + max_column = nil + end + + displayable_tasks.each do |t| + printf("#{name} %-#{width}s # %s\n", + t.name_with_args, + max_column ? truncate(t.comment, max_column) : t.comment) + end + when :describe + displayable_tasks.each do |t| + puts "#{name} #{t.name_with_args}" + comment = t.full_comment || "" + comment.split("\n").each do |line| + puts " #{line}" + end + puts + end + when :lines + displayable_tasks.each do |t| + t.locations.each do |loc| + printf "#{name} %-30s %s\n", t.name_with_args, loc + end + end + else + fail "Unknown show task mode: '#{options.show_tasks}'" + end + end + + def terminal_width # :nodoc: + if @terminal_columns.nonzero? + result = @terminal_columns + else + result = unix? ? dynamic_width : 80 + end + (result < 10) ? 80 : result + rescue + 80 + end + + # Calculate the dynamic width of the + def dynamic_width # :nodoc: + @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) + end + + def dynamic_width_stty # :nodoc: + %x{stty size 2>/dev/null}.split[1].to_i + end + + def dynamic_width_tput # :nodoc: + %x{tput cols 2>/dev/null}.to_i + end + + def unix? # :nodoc: + RbConfig::CONFIG['host_os'] =~ + /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i + end + + def windows? # :nodoc: + Win32.windows? + end + + def truncate(string, width) # :nodoc: + if string.nil? + "" + elsif string.length <= width + string + else + (string[0, width - 3] || "") + "..." + end + end + + # Display the tasks and prerequisites + def display_prerequisites # :nodoc: + tasks.each do |t| + puts "#{name} #{t.name}" + t.prerequisites.each { |pre| puts " #{pre}" } + end + end + + def trace(*strings) # :nodoc: + options.trace_output ||= $stderr + trace_on(options.trace_output, *strings) + end + + def sort_options(options) # :nodoc: + options.sort_by { |opt| + opt.select { |o| o =~ /^-/ }.map { |o| o.downcase }.sort.reverse + } + end + private :sort_options + + # A list of all the standard options used in rake, suitable for + # passing to OptionParser. + def standard_rake_options # :nodoc: + sort_options( + [ + ['--all', '-A', + "Show all tasks, even uncommented ones (in combination with -T or -D)", + lambda { |value| + options.show_all_tasks = value + } + ], + ['--backtrace=[OUT]', + "Enable full backtrace. OUT can be stderr (default) or stdout.", + lambda { |value| + options.backtrace = true + select_trace_output(options, 'backtrace', value) + } + ], + ['--build-all', '-B', + "Build all prerequisites, including those which are up-to-date.", + lambda { |value| + options.build_all = true + } + ], + ['--comments', + "Show commented tasks only", + lambda { |value| + options.show_all_tasks = !value + } + ], + ['--describe', '-D [PATTERN]', + "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + select_tasks_to_show(options, :describe, value) + } + ], + ['--dry-run', '-n', + "Do a dry run without executing actions.", + lambda { |value| + Rake.verbose(true) + Rake.nowrite(true) + options.dryrun = true + options.trace = true + } + ], + ['--execute', '-e CODE', + "Execute some Ruby code and exit.", + lambda { |value| + eval(value) + exit + } + ], + ['--execute-print', '-p CODE', + "Execute some Ruby code, print the result, then exit.", + lambda { |value| + puts eval(value) + exit + } + ], + ['--execute-continue', '-E CODE', + "Execute some Ruby code, " + + "then continue with normal task processing.", + lambda { |value| eval(value) } + ], + ['--jobs', '-j [NUMBER]', + "Specifies the maximum number of tasks to execute in parallel. " + + "(default is number of CPU cores + 4)", + lambda { |value| + if value.nil? || value == '' + value = FIXNUM_MAX + elsif value =~ /^\d+$/ + value = value.to_i + else + value = Rake.suggested_thread_count + end + value = 1 if value < 1 + options.thread_pool_size = value - 1 + } + ], + ['--job-stats [LEVEL]', + "Display job statistics. " + + "LEVEL=history displays a complete job list", + lambda { |value| + if value =~ /^history/i + options.job_stats = :history + else + options.job_stats = true + end + } + ], + ['--libdir', '-I LIBDIR', + "Include LIBDIR in the search path for required modules.", + lambda { |value| $:.push(value) } + ], + ['--multitask', '-m', + "Treat all tasks as multitasks.", + lambda { |value| options.always_multitask = true } + ], + ['--no-search', '--nosearch', + '-N', "Do not search parent directories for the Rakefile.", + lambda { |value| options.nosearch = true } + ], + ['--prereqs', '-P', + "Display the tasks and dependencies, then exit.", + lambda { |value| options.show_prereqs = true } + ], + ['--quiet', '-q', + "Do not log messages to standard output.", + lambda { |value| Rake.verbose(false) } + ], + ['--rakefile', '-f [FILENAME]', + "Use FILENAME as the rakefile to search for.", + lambda { |value| + value ||= '' + @rakefiles.clear + @rakefiles << value + } + ], + ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', + "Auto-import any .rake files in RAKELIBDIR. " + + "(default is 'rakelib')", + lambda { |value| + options.rakelib = value.split(File::PATH_SEPARATOR) + } + ], + ['--require', '-r MODULE', + "Require MODULE before executing rakefile.", + lambda { |value| + begin + require value + rescue LoadError => ex + begin + rake_require value + rescue LoadError + raise ex + end + end + } + ], + ['--rules', + "Trace the rules resolution.", + lambda { |value| options.trace_rules = true } + ], + ['--silent', '-s', + "Like --quiet, but also suppresses the " + + "'in directory' announcement.", + lambda { |value| + Rake.verbose(false) + options.silent = true + } + ], + ['--suppress-backtrace PATTERN', + "Suppress backtrace lines matching regexp PATTERN. " + + "Ignored if --trace is on.", + lambda { |value| + options.suppress_backtrace_pattern = Regexp.new(value) + } + ], + ['--system', '-g', + "Using system wide (global) rakefiles " + + "(usually '~/.rake/*.rake').", + lambda { |value| options.load_system = true } + ], + ['--no-system', '--nosystem', '-G', + "Use standard project Rakefile search paths, " + + "ignore system wide rakefiles.", + lambda { |value| options.ignore_system = true } + ], + ['--tasks', '-T [PATTERN]', + "Display the tasks (matching optional PATTERN) " + + "with descriptions, then exit.", + lambda { |value| + select_tasks_to_show(options, :tasks, value) + } + ], + ['--trace=[OUT]', '-t', + "Turn on invoke/execute tracing, enable full backtrace. " + + "OUT can be stderr (default) or stdout.", + lambda { |value| + options.trace = true + options.backtrace = true + select_trace_output(options, 'trace', value) + Rake.verbose(true) + } + ], + ['--verbose', '-v', + "Log message to standard output.", + lambda { |value| Rake.verbose(true) } + ], + ['--version', '-V', + "Display the program version.", + lambda { |value| + puts "rake, version #{RAKEVERSION}" + exit + } + ], + ['--where', '-W [PATTERN]', + "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + select_tasks_to_show(options, :lines, value) + options.show_all_tasks = true + } + ], + ['--no-deprecation-warnings', '-X', + "Disable the deprecation warnings.", + lambda { |value| + options.ignore_deprecate = true + } + ], + ]) + end + + def select_tasks_to_show(options, show_tasks, value) # :nodoc: + options.show_tasks = show_tasks + options.show_task_pattern = Regexp.new(value || '') + Rake::TaskManager.record_task_metadata = true + end + private :select_tasks_to_show + + def select_trace_output(options, trace_option, value) # :nodoc: + value = value.strip unless value.nil? + case value + when 'stdout' + options.trace_output = $stdout + when 'stderr', nil + options.trace_output = $stderr + else + fail CommandLineOptionError, + "Unrecognized --#{trace_option} option '#{value}'" + end + end + private :select_trace_output + + # Read and handle the command line options. Returns the command line + # arguments that we didn't understand, which should (in theory) be just + # task names and env vars. + def handle_options # :nodoc: + options.rakelib = ['rakelib'] + options.trace_output = $stderr + + OptionParser.new do |opts| + opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..." + opts.separator "" + opts.separator "Options are ..." + + opts.on_tail("-h", "--help", "-H", "Display this help message.") do + puts opts + exit + end + + standard_rake_options.each { |args| opts.on(*args) } + opts.environment('RAKEOPT') + end.parse(ARGV) + end + + # Similar to the regular Ruby +require+ command, but will check + # for *.rake files in addition to *.rb files. + def rake_require(file_name, paths=$LOAD_PATH, loaded=$") # :nodoc: + fn = file_name + ".rake" + return false if loaded.include?(fn) + paths.each do |path| + full_path = File.join(path, fn) + if File.exist?(full_path) + Rake.load_rakefile(full_path) + loaded << fn + return true + end + end + fail LoadError, "Can't find #{file_name}" + end + + def find_rakefile_location # :nodoc: + here = Dir.pwd + until (fn = have_rakefile) + Dir.chdir("..") + return nil if Dir.pwd == here || options.nosearch + here = Dir.pwd + end + [fn, here] + ensure + Dir.chdir(Rake.original_dir) + end + + def print_rakefile_directory(location) # :nodoc: + $stderr.puts "(in #{Dir.pwd})" unless + options.silent or original_dir == location + end + + def raw_load_rakefile # :nodoc: + rakefile, location = find_rakefile_location + if (! options.ignore_system) && + (options.load_system || rakefile.nil?) && + system_dir && File.directory?(system_dir) + print_rakefile_directory(location) + glob("#{system_dir}/*.rake") do |name| + add_import name + end + else + fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if + rakefile.nil? + @rakefile = rakefile + Dir.chdir(location) + print_rakefile_directory(location) + Rake.load_rakefile(File.expand_path(@rakefile)) if + @rakefile && @rakefile != '' + options.rakelib.each do |rlib| + glob("#{rlib}/*.rake") do |name| + add_import name + end + end + end + load_imports + end + + def glob(path, &block) # :nodoc: + FileList.glob(path.gsub("\\", '/')).each(&block) + end + private :glob + + # The directory path containing the system wide rakefiles. + def system_dir # :nodoc: + @system_dir ||= + begin + if ENV['RAKE_SYSTEM'] + ENV['RAKE_SYSTEM'] + else + standard_system_dir + end + end + end + + # The standard directory containing system wide rake files. + if Win32.windows? + def standard_system_dir #:nodoc: + Win32.win32_system_dir + end + else + def standard_system_dir #:nodoc: + File.join(File.expand_path('~'), '.rake') + end + end + private :standard_system_dir + + # Collect the list of tasks on the command line. If no tasks are + # given, return a list containing only the default task. + # Environmental assignments are processed at this time as well. + # + # `args` is the list of arguments to peruse to get the list of tasks. + # It should be the command line that was given to rake, less any + # recognised command-line options, which OptionParser.parse will + # have taken care of already. + def collect_command_line_tasks(args) # :nodoc: + @top_level_tasks = [] + args.each do |arg| + if arg =~ /^(\w+)=(.*)$/m + ENV[$1] = $2 + else + @top_level_tasks << arg unless arg =~ /^-/ + end + end + @top_level_tasks.push(default_task_name) if @top_level_tasks.empty? + end + + # Default task name ("default"). + # (May be overridden by subclasses) + def default_task_name # :nodoc: + "default" + end + + # Add a file to the list of files to be imported. + def add_import(fn) # :nodoc: + @pending_imports << fn + end + + # Load the pending list of imported files. + def load_imports # :nodoc: + while fn = @pending_imports.shift + next if @imported.member?(fn) + fn_task = lookup(fn) and fn_task.invoke + ext = File.extname(fn) + loader = @loaders[ext] || @default_loader + loader.load(fn) + if fn_task = lookup(fn) and fn_task.needed? + fn_task.reenable + fn_task.invoke + loader.load(fn) + end + @imported << fn + end + end + + def rakefile_location(backtrace=caller) # :nodoc: + backtrace.map { |t| t[/([^:]+):/, 1] } + + re = /^#{@rakefile}$/ + re = /#{re.source}/i if windows? + + backtrace.find { |str| str =~ re } || '' + end + + private + FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc: + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/backtrace.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/backtrace.rb new file mode 100644 index 000000000..dc1877343 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/backtrace.rb @@ -0,0 +1,23 @@ +module Rake + module Backtrace # :nodoc: all + SYS_KEYS = RbConfig::CONFIG.keys.grep(/(?:[a-z]prefix|libdir)\z/) + SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq + + [ File.join(File.dirname(__FILE__), "..") ] + + SUPPRESSED_PATHS = SYS_PATHS. + map { |s| s.gsub("\\", "/") }. + map { |f| File.expand_path(f) }. + reject { |s| s.nil? || s =~ /^ *$/ } + SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|") + SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if + Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby' + + SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i + + def self.collapse(backtrace) + pattern = Rake.application.options.suppress_backtrace_pattern || + SUPPRESS_PATTERN + backtrace.reject { |elem| elem =~ pattern } + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/clean.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/clean.rb new file mode 100644 index 000000000..a49cd4416 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/clean.rb @@ -0,0 +1,76 @@ +# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and +# two rake tasks (:clean and :clobber). +# +# [:clean] Clean up the project by deleting scratch files and backup +# files. Add files to the CLEAN file list to have the :clean +# target handle them. +# +# [:clobber] Clobber all generated and non-source files in a project. +# The task depends on :clean, so all the clean files will +# be deleted as well as files in the CLOBBER file list. +# The intent of this task is to return a project to its +# pristine, just unpacked state. + +require 'rake' + +# :stopdoc: + +module Rake + module Cleaner + extend FileUtils + + module_function + + def cleanup_files(file_names) + file_names.each do |file_name| + cleanup(file_name) + end + end + + def cleanup(file_name, opts={}) + begin + rm_r file_name, opts + rescue StandardError => ex + puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name) + end + end + + def file_already_gone?(file_name) + return false if File.exist?(file_name) + + path = file_name + prev = nil + + while path = File.dirname(path) + return false if cant_be_deleted?(path) + break if [prev, "."].include?(path) + prev = path + end + true + end + private_class_method :file_already_gone? + + def cant_be_deleted?(path_name) + File.exist?(path_name) && + (!File.readable?(path_name) || !File.executable?(path_name)) + end + private_class_method :cant_be_deleted? + end +end + +CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"] +CLEAN.clear_exclude.exclude { |fn| + fn.pathmap("%f").downcase == 'core' && File.directory?(fn) +} + +desc "Remove any temporary products." +task :clean do + Rake::Cleaner.cleanup_files(CLEAN) +end + +CLOBBER = ::Rake::FileList.new + +desc "Remove any generated file." +task :clobber => [:clean] do + Rake::Cleaner.cleanup_files(CLOBBER) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cloneable.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cloneable.rb new file mode 100644 index 000000000..d53645f2f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cloneable.rb @@ -0,0 +1,16 @@ +module Rake + ## + # Mixin for creating easily cloned objects. + + module Cloneable # :nodoc: + # The hook that is invoked by 'clone' and 'dup' methods. + def initialize_copy(source) + super + source.instance_variables.each do |var| + src_value = source.instance_variable_get(var) + value = src_value.clone rescue src_value + instance_variable_set(var, value) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/.document b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/.document new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/.document @@ -0,0 +1 @@ + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/compositepublisher.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/compositepublisher.rb new file mode 100644 index 000000000..69952a080 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/compositepublisher.rb @@ -0,0 +1,21 @@ +module Rake + + # Manage several publishers as a single entity. + class CompositePublisher + def initialize + @publishers = [] + end + + # Add a publisher to the composite. + def add(pub) + @publishers << pub + end + + # Upload all the individual publishers. + def upload + @publishers.each { |p| p.upload } + end + end + +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/ftptools.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/ftptools.rb new file mode 100644 index 000000000..b178523bc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/ftptools.rb @@ -0,0 +1,137 @@ +# = Tools for FTP uploading. +# +# This file is still under development and is not released for general +# use. + +require 'date' +require 'net/ftp' +require 'rake/file_list' + +module Rake # :nodoc: + + class FtpFile # :nodoc: all + attr_reader :name, :size, :owner, :group, :time + + def self.date + @date_class ||= Date + end + + def self.time + @time_class ||= Time + end + + def initialize(path, entry) + @path = path + @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') + @size = size.to_i + @time = determine_time(d1, d2, d3) + end + + def path + File.join(@path, @name) + end + + def directory? + @mode[0] == ?d + end + + def mode + parse_mode(@mode) + end + + def symlink? + @mode[0] == ?l + end + + private # -------------------------------------------------------- + + def parse_mode(m) + result = 0 + (1..9).each do |i| + result = 2 * result + ((m[i] == ?-) ? 0 : 1) + end + result + end + + def determine_time(d1, d2, d3) + now = self.class.time.now + if /:/ !~ d3 + result = Time.parse("#{d1} #{d2} #{d3}") + else + result = Time.parse("#{d1} #{d2} #{now.year} #{d3}") + result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if + result > now + end + result + end + end + + ## + # Manage the uploading of files to an FTP account. + class FtpUploader # :nodoc: + + # Log uploads to standard output when true. + attr_accessor :verbose + + class << FtpUploader + # Create an uploader and pass it to the given block as +up+. + # When the block is complete, close the uploader. + def connect(path, host, account, password) + up = self.new(path, host, account, password) + begin + yield(up) + ensure + up.close + end + end + end + + # Create an FTP uploader targeting the directory +path+ on +host+ + # using the given account and password. +path+ will be the root + # path of the uploader. + def initialize(path, host, account, password) + @created = Hash.new + @path = path + @ftp = Net::FTP.new(host, account, password) + makedirs(@path) + @ftp.chdir(@path) + end + + # Create the directory +path+ in the uploader root path. + def makedirs(path) + route = [] + File.split(path).each do |dir| + route << dir + current_dir = File.join(route) + if @created[current_dir].nil? + @created[current_dir] = true + $stderr.puts "Creating Directory #{current_dir}" if @verbose + @ftp.mkdir(current_dir) rescue nil + end + end + end + + # Upload all files matching +wildcard+ to the uploader's root + # path. + def upload_files(wildcard) + FileList.glob(wildcard).each do |fn| + upload(fn) + end + end + + # Close the uploader. + def close + @ftp.close + end + + private # -------------------------------------------------------- + + # Upload a single file to the uploader's root path. + def upload(file) + $stderr.puts "Uploading #{file}" if @verbose + dir = File.dirname(file) + makedirs(dir) + @ftp.putbinaryfile(file, file) unless File.directory?(file) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/publisher.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/publisher.rb new file mode 100644 index 000000000..f4ee1abf8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/publisher.rb @@ -0,0 +1,81 @@ +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) +# All rights reserved. + +# :stopdoc: + +# Configuration information about an upload host system. +# name :: Name of host system. +# webdir :: Base directory for the web information for the +# application. The application name (APP) is appended to +# this directory before using. +# pkgdir :: Directory on the host system where packages can be +# placed. +HostInfo = Struct.new(:name, :webdir, :pkgdir) + +# :startdoc: + +# TODO: Move to contrib/sshpublisher +#-- +# Manage several publishers as a single entity. +class CompositePublisher # :nodoc: + def initialize + @publishers = [] + end + + # Add a publisher to the composite. + def add(pub) + @publishers << pub + end + + # Upload all the individual publishers. + def upload + @publishers.each { |p| p.upload } + end +end + +# TODO: Remove in Rake 11, duplicated +#-- +# Publish an entire directory to an existing remote directory using +# SSH. +class SshDirPublisher # :nodoc: all + def initialize(host, remote_dir, local_dir) + @host = host + @remote_dir = remote_dir + @local_dir = local_dir + end + + def upload + run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}} + end +end + +# TODO: Remove in Rake 11, duplicated +#-- +# Publish an entire directory to a fresh remote directory using SSH. +class SshFreshDirPublisher < SshDirPublisher # :nodoc: all + def upload + run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil + run %{ssh #{@host} mkdir #{@remote_dir}} + super + end +end + +# TODO: Remove in Rake 11, duplicated +#-- +# Publish a list of files to an existing remote directory. +class SshFilePublisher # :nodoc: all + # Create a publisher using the give host information. + def initialize(host, remote_dir, local_dir, *files) + @host = host + @remote_dir = remote_dir + @local_dir = local_dir + @files = files + end + + # Upload the local directory to the remote directory. + def upload + @files.each do |fn| + run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}} + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/rubyforgepublisher.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/rubyforgepublisher.rb new file mode 100644 index 000000000..00889ad7b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/rubyforgepublisher.rb @@ -0,0 +1,18 @@ +# TODO: Remove in Rake 11 + +require 'rake/contrib/sshpublisher' + +module Rake + + class RubyForgePublisher < SshDirPublisher # :nodoc: all + attr_reader :project, :proj_id, :user + + def initialize(projname, user) + super( + "#{user}@rubyforge.org", + "/var/www/gforge-projects/#{projname}", + "html") + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sshpublisher.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sshpublisher.rb new file mode 100644 index 000000000..64f577017 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sshpublisher.rb @@ -0,0 +1,61 @@ +require 'rake/dsl_definition' +require 'rake/contrib/compositepublisher' + +module Rake + + # Publish an entire directory to an existing remote directory using + # SSH. + class SshDirPublisher + include Rake::DSL + + # Creates an SSH publisher which will scp all files in +local_dir+ to + # +remote_dir+ on +host+ + + def initialize(host, remote_dir, local_dir) + @host = host + @remote_dir = remote_dir + @local_dir = local_dir + end + + # Uploads the files + + def upload + sh "scp", "-rq", "#{@local_dir}/*", "#{@host}:#{@remote_dir}" + end + end + + # Publish an entire directory to a fresh remote directory using SSH. + class SshFreshDirPublisher < SshDirPublisher + + # Uploads the files after removing the existing remote directory. + + def upload + sh "ssh", @host, "rm", "-rf", @remote_dir rescue nil + sh "ssh", @host, "mkdir", @remote_dir + super + end + end + + # Publish a list of files to an existing remote directory. + class SshFilePublisher + include Rake::DSL + + # Creates an SSH publisher which will scp all +files+ in +local_dir+ to + # +remote_dir+ on +host+. + + def initialize(host, remote_dir, local_dir, *files) + @host = host + @remote_dir = remote_dir + @local_dir = local_dir + @files = files + end + + # Uploads the files + + def upload + @files.each do |fn| + sh "scp", "-q", "#{@local_dir}/#{fn}", "#{@host}:#{@remote_dir}" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sys.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sys.rb new file mode 100644 index 000000000..8d4c73543 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/contrib/sys.rb @@ -0,0 +1,4 @@ +# TODO: Remove in Rake 11 + +fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " + + "Use 'FileUtils' instead." diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cpu_counter.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cpu_counter.rb new file mode 100644 index 000000000..f29778ed5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/cpu_counter.rb @@ -0,0 +1,125 @@ +module Rake + + # Based on a script at: + # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed + class CpuCounter # :nodoc: all + def self.count + new.count_with_default + end + + def count_with_default(default=4) + count || default + rescue StandardError + default + end + + begin + require 'etc' + rescue LoadError + else + if Etc.respond_to?(:nprocessors) + def count + return Etc.nprocessors + end + end + end + end +end + +unless Rake::CpuCounter.method_defined?(:count) + Rake::CpuCounter.class_eval <<-'end;', __FILE__, __LINE__+1 + require 'rbconfig' + + # TODO: replace with IO.popen using array-style arguments in Rake 11 + require 'open3' + + def count + if defined?(Java::Java) + count_via_java_runtime + else + case RbConfig::CONFIG['host_os'] + when /darwin9/ + count_via_hwprefs_cpu_count + when /darwin/ + count_via_hwprefs_thread_count || count_via_sysctl + when /linux/ + count_via_cpuinfo + when /bsd/ + count_via_sysctl + when /mswin|mingw/ + count_via_win32 + else + # Try everything + count_via_win32 || + count_via_sysctl || + count_via_hwprefs_thread_count || + count_via_hwprefs_cpu_count || + count_via_cpuinfo + end + end + end + + def count_via_java_runtime + Java::Java.lang.Runtime.getRuntime.availableProcessors + rescue StandardError + nil + end + + def count_via_win32 + require 'win32ole' + wmi = WIN32OLE.connect("winmgmts://") + cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # TODO count hyper-threaded in this + cpu.to_enum.first.NumberOfCores + rescue StandardError, LoadError + nil + end + + def count_via_cpuinfo + open('/proc/cpuinfo') { |f| f.readlines }.grep(/processor/).size + rescue StandardError + nil + end + + def count_via_hwprefs_thread_count + run 'hwprefs', 'thread_count' + end + + def count_via_hwprefs_cpu_count + run 'hwprefs', 'cpu_count' + end + + def count_via_sysctl + run 'sysctl', '-n', 'hw.ncpu' + end + + def run(command, *args) + cmd = resolve_command(command) + if cmd + Open3.popen3 cmd, *args do |inn, out, err,| + inn.close + err.read + out.read.to_i + end + else + nil + end + end + + def resolve_command(command) + look_for_command("/usr/sbin", command) || + look_for_command("/sbin", command) || + in_path_command(command) + end + + def look_for_command(dir, command) + path = File.join(dir, command) + File.exist?(path) ? path : nil + end + + def in_path_command(command) + Open3.popen3 'which', command do |_, out,| + out.eof? ? nil : command + end + end + end; +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/default_loader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/default_loader.rb new file mode 100644 index 000000000..6154408f4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/default_loader.rb @@ -0,0 +1,14 @@ +module Rake + + # Default Rakefile loader used by +import+. + class DefaultLoader + + ## + # Loads a rakefile into the current application from +fn+ + + def load(fn) + Rake.load_rakefile(File.expand_path(fn)) + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/dsl_definition.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/dsl_definition.rb new file mode 100644 index 000000000..26f4ca828 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/dsl_definition.rb @@ -0,0 +1,201 @@ +# Rake DSL functions. +require 'rake/file_utils_ext' + +module Rake + + ## + # DSL is a module that provides #task, #desc, #namespace, etc. Use this + # when you'd like to use rake outside the top level scope. + # + # For a Rakefile you run from the comamnd line this module is automatically + # included. + + module DSL + + #-- + # Include the FileUtils file manipulation functions in the top + # level module, but mark them private so that they don't + # unintentionally define methods on other objects. + #++ + + include FileUtilsExt + private(*FileUtils.instance_methods(false)) + private(*FileUtilsExt.instance_methods(false)) + + private + + # :call-seq: + # task task_name + # task task_name: dependencies + # task task_name, arguments => dependencies + # task task_name, argument[, argument ...], :needs: dependencies + # + # Declare a basic task. The +task_name+ is always the first argument. If + # the task name contains a ":" it is defined in that namespace. + # + # The +dependencies+ may be a single task name or an Array of task names. + # The +argument+ (a single name) or +arguments+ (an Array of names) define + # the arguments provided to the task. + # + # The task, argument and dependency names may be either symbols or + # strings. + # + # A task with a single dependency: + # + # task clobber: %w[clean] do + # rm_rf "html" + # end + # + # A task with an argument and a dependency: + # + # task :package, [:version] => :test do |t, args| + # # ... + # end + # + # To invoke this task from the command line: + # + # $ rake package[1.2.3] + # + # Alternate definition: + # + # task :package, :version, needs: :test do |t, args| + # # ... + # end + # + def task(*args, &block) # :doc: + Rake::Task.define_task(*args, &block) + end + + # Declare a file task. + # + # Example: + # file "config.cfg" => ["config.template"] do + # open("config.cfg", "w") do |outfile| + # open("config.template") do |infile| + # while line = infile.gets + # outfile.puts line + # end + # end + # end + # end + # + def file(*args, &block) # :doc: + Rake::FileTask.define_task(*args, &block) + end + + # Declare a file creation task. + # (Mainly used for the directory command). + def file_create(*args, &block) + Rake::FileCreationTask.define_task(*args, &block) + end + + # Declare a set of files tasks to create the given directories on + # demand. + # + # Example: + # directory "testdata/doc" + # + def directory(*args, &block) # :doc: + result = file_create(*args, &block) + dir, _ = *Rake.application.resolve_args(args) + dir = Rake.from_pathname(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name unless File.exist?(t.name) + end + end + result + end + + # Declare a task that performs its prerequisites in + # parallel. Multitasks does *not* guarantee that its prerequisites + # will execute in any given order (which is obvious when you think + # about it) + # + # Example: + # multitask deploy: %w[deploy_gem deploy_rdoc] + # + def multitask(*args, &block) # :doc: + Rake::MultiTask.define_task(*args, &block) + end + + # Create a new rake namespace and use it for evaluating the given + # block. Returns a NameSpace object that can be used to lookup + # tasks defined in the namespace. + # + # Example: + # + # ns = namespace "nested" do + # # the "nested:run" task + # task :run + # end + # task_run = ns[:run] # find :run in the given namespace. + # + # Tasks can also be defined in a namespace by using a ":" in the task + # name: + # + # task "nested:test" do + # # ... + # end + # + def namespace(name=nil, &block) # :doc: + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) || name.nil? + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end + Rake.application.in_namespace(name, &block) + end + + # Declare a rule for auto-tasks. + # + # Example: + # rule '.o' => '.c' do |t| + # sh 'cc', '-o', t.name, t.source + # end + # + def rule(*args, &block) # :doc: + Rake::Task.create_rule(*args, &block) + end + + # Describes the next rake task. Duplicate descriptions are discarded. + # Descriptions are shown with rake -T (up to the first + # sentence) and rake -D (the entire description). + # + # Example: + # desc "Run the Unit Tests" + # task test: [:build] + # # ... run tests + # end + # + def desc(description) # :doc: + Rake.application.last_description = description + end + + # Import the partial Rakefiles +fn+. Imported files are loaded + # _after_ the current file is completely loaded. This allows the + # import statement to appear anywhere in the importing file, and yet + # allowing the imported files to depend on objects defined in the + # importing file. + # + # A common use of the import statement is to include files + # containing dependency declarations. + # + # See also the --rakelibdir command line option. + # + # Example: + # import ".depend", "my_rules" + # + def import(*fns) # :doc: + fns.each do |fn| + Rake.application.add_import(fn) + end + end + end + extend FileUtilsExt +end + +# Extend the main object with the DSL commands. This allows top-level +# calls to task, etc. to work from a Rakefile without polluting the +# object inheritance tree. +self.extend Rake::DSL diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/early_time.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/early_time.rb new file mode 100644 index 000000000..abcb1872b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/early_time.rb @@ -0,0 +1,21 @@ +module Rake + + # EarlyTime is a fake timestamp that occurs _before_ any other time value. + class EarlyTime + include Comparable + include Singleton + + ## + # The EarlyTime always comes before +other+! + + def <=>(other) + -1 + end + + def to_s # :nodoc: + "" + end + end + + EARLY = EarlyTime.instance +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/core.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/core.rb new file mode 100644 index 000000000..7575df15a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/core.rb @@ -0,0 +1,25 @@ +class Module + # Check for an existing method in the current class before extending. If + # the method already exists, then a warning is printed and the extension is + # not added. Otherwise the block is yielded and any definitions in the + # block will take effect. + # + # Usage: + # + # class String + # rake_extension("xyz") do + # def xyz + # ... + # end + # end + # end + # + def rake_extension(method) # :nodoc: + if method_defined?(method) + $stderr.puts "WARNING: Possible conflict with Rake extension: " + + "#{self}##{method} already exists" + else + yield + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/module.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/module.rb new file mode 100644 index 000000000..3ee155ff6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/module.rb @@ -0,0 +1,2 @@ + +# TODO: remove in Rake 11 diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/pathname.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/pathname.rb new file mode 100644 index 000000000..49e2cd47a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/pathname.rb @@ -0,0 +1,25 @@ +require 'rake/ext/core' +require 'pathname' + +class Pathname + + rake_extension("ext") do + # Return a new Pathname with String#ext applied to it. + # + # This Pathname extension comes from Rake + def ext(newext='') + Pathname.new(Rake.from_pathname(self).ext(newext)) + end + end + + rake_extension("pathmap") do + # Apply the pathmap spec to the Pathname, returning a + # new Pathname with the modified paths. (See String#pathmap for + # details.) + # + # This Pathname extension comes from Rake + def pathmap(spec=nil, &block) + Pathname.new(Rake.from_pathname(self).pathmap(spec, &block)) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/string.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/string.rb new file mode 100644 index 000000000..b47b055a7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/string.rb @@ -0,0 +1,173 @@ +require 'rake/ext/core' + +class String + + rake_extension("ext") do + # Replace the file extension with +newext+. If there is no extension on + # the string, append the new extension to the end. If the new extension + # is not given, or is the empty string, remove any existing extension. + # + # +ext+ is a user added method for the String class. + # + # This String extension comes from Rake + def ext(newext='') + return self.dup if ['.', '..'].include? self + newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != '' + self.chomp(File.extname(self)) << newext + end + end + + rake_extension("pathmap") do + # Explode a path into individual components. Used by +pathmap+. + # + # This String extension comes from Rake + def pathmap_explode + head, tail = File.split(self) + return [self] if head == self + return [tail] if head == '.' || tail == '/' + return [head, tail] if head == '/' + return head.pathmap_explode + [tail] + end + protected :pathmap_explode + + # Extract a partial path from the path. Include +n+ directories from the + # front end (left hand side) if +n+ is positive. Include |+n+| + # directories from the back end (right hand side) if +n+ is negative. + # + # This String extension comes from Rake + def pathmap_partial(n) + dirs = File.dirname(self).pathmap_explode + partial_dirs = + if n > 0 + dirs[0...n] + elsif n < 0 + dirs.reverse[0...-n].reverse + else + "." + end + File.join(partial_dirs) + end + protected :pathmap_partial + + # Perform the pathmap replacement operations on the given path. The + # patterns take the form 'pat1,rep1;pat2,rep2...'. + # + # This String extension comes from Rake + def pathmap_replace(patterns, &block) + result = self + patterns.split(';').each do |pair| + pattern, replacement = pair.split(',') + pattern = Regexp.new(pattern) + if replacement == '*' && block_given? + result = result.sub(pattern, &block) + elsif replacement + result = result.sub(pattern, replacement) + else + result = result.sub(pattern, '') + end + end + result + end + protected :pathmap_replace + + # Map the path according to the given specification. The specification + # controls the details of the mapping. The following special patterns are + # recognized: + # + # %p :: The complete path. + # %f :: The base file name of the path, with its file extension, + # but without any directories. + # %n :: The file name of the path without its file extension. + # %d :: The directory list of the path. + # %x :: The file extension of the path. An empty string if there + # is no extension. + # %X :: Everything *but* the file extension. + # %s :: The alternate file separator if defined, otherwise use # + # the standard file separator. + # %% :: A percent sign. + # + # The %d specifier can also have a numeric prefix (e.g. '%2d'). + # If the number is positive, only return (up to) +n+ directories in the + # path, starting from the left hand side. If +n+ is negative, return (up + # to) +n+ directories from the right hand side of the path. + # + # Examples: + # + # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b' + # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' + # + # Also the %d, %p, %f, %n, + # %x, and %X operators can take a pattern/replacement + # argument to perform simple string substitutions on a particular part of + # the path. The pattern and replacement are separated by a comma and are + # enclosed by curly braces. The replacement spec comes after the % + # character but before the operator letter. (e.g. "%{old,new}d"). + # Multiple replacement specs should be separated by semi-colons (e.g. + # "%{old,new;src,bin}d"). + # + # Regular expressions may be used for the pattern, and back refs may be + # used in the replacement text. Curly braces, commas and semi-colons are + # excluded from both the pattern and replacement text (let's keep parsing + # reasonable). + # + # For example: + # + # "src/org/onestepback/proj/A.java".pathmap("%{^src,class}X.class") + # + # returns: + # + # "class/org/onestepback/proj/A.class" + # + # If the replacement text is '*', then a block may be provided to perform + # some arbitrary calculation for the replacement. + # + # For example: + # + # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext| + # ext.downcase + # } + # + # Returns: + # + # "/path/to/file.txt" + # + # This String extension comes from Rake + def pathmap(spec=nil, &block) + return self if spec.nil? + result = '' + spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag| + case frag + when '%f' + result << File.basename(self) + when '%n' + result << File.basename(self).ext + when '%d' + result << File.dirname(self) + when '%x' + result << File.extname(self) + when '%X' + result << self.ext + when '%p' + result << self + when '%s' + result << (File::ALT_SEPARATOR || File::SEPARATOR) + when '%-' + # do nothing + when '%%' + result << "%" + when /%(-?\d+)d/ + result << pathmap_partial($1.to_i) + when /^%\{([^}]*)\}(\d*[dpfnxX])/ + patterns, operator = $1, $2 + result << pathmap('%' + operator).pathmap_replace(patterns, &block) + when /^%/ + fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'" + else + result << frag + end + end + result + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/time.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/time.rb new file mode 100644 index 000000000..d3b8cf9dc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ext/time.rb @@ -0,0 +1,16 @@ +#-- +# Extensions to time to allow comparisons with early and late time classes. + +require 'rake/early_time' +require 'rake/late_time' + +class Time # :nodoc: all + alias rake_original_time_compare :<=> + def <=>(other) + if Rake::EarlyTime === other || Rake::LateTime === other + - other.<=>(self) + else + rake_original_time_compare(other) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_creation_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_creation_task.rb new file mode 100644 index 000000000..c87e2192b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_creation_task.rb @@ -0,0 +1,24 @@ +require 'rake/file_task' +require 'rake/early_time' + +module Rake + + # A FileCreationTask is a file task that when used as a dependency will be + # needed if and only if the file has not been created. Once created, it is + # not re-triggered if any of its dependencies are newer, nor does trigger + # any rebuilds of tasks that depend on it whenever it is updated. + # + class FileCreationTask < FileTask + # Is this file task needed? Yes if it doesn't exist. + def needed? + ! File.exist?(name) + end + + # Time stamp for file creation task. This time stamp is earlier + # than any other time stamp. + def timestamp + Rake::EARLY + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_list.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_list.rb new file mode 100644 index 000000000..006ec7703 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_list.rb @@ -0,0 +1,428 @@ +require 'rake/cloneable' +require 'rake/file_utils_ext' +require 'rake/pathmap' + + +module Rake + + ## + # A FileList is essentially an array with a few helper methods defined to + # make file manipulation a bit easier. + # + # FileLists are lazy. When given a list of glob patterns for possible files + # to be included in the file list, instead of searching the file structures + # to find the files, a FileList holds the pattern for latter use. + # + # This allows us to define a number of FileList to match any number of + # files, but only search out the actual files when then FileList itself is + # actually used. The key is that the first time an element of the + # FileList/Array is requested, the pending patterns are resolved into a real + # list of file names. + # + class FileList + + include Cloneable + + # == Method Delegation + # + # The lazy evaluation magic of FileLists happens by implementing all the + # array specific methods to call +resolve+ before delegating the heavy + # lifting to an embedded array object (@items). + # + # In addition, there are two kinds of delegation calls. The regular kind + # delegates to the @items array and returns the result directly. Well, + # almost directly. It checks if the returned value is the @items object + # itself, and if so will return the FileList object instead. + # + # The second kind of delegation call is used in methods that normally + # return a new Array object. We want to capture the return value of these + # methods and wrap them in a new FileList object. We enumerate these + # methods in the +SPECIAL_RETURN+ list below. + + # List of array methods (that are not in +Object+) that need to be + # delegated. + ARRAY_METHODS = (Array.instance_methods - Object.instance_methods). + map { |n| n.to_s } + + # List of additional methods that must be delegated. + MUST_DEFINE = %w[inspect <=>] + + # List of methods that should not be delegated here (we define special + # versions of them explicitly below). + MUST_NOT_DEFINE = %w[to_a to_ary partition * <<] + + # List of delegated methods that return new array values which need + # wrapping. + SPECIAL_RETURN = %w[ + map collect sort sort_by select find_all reject grep + compact flatten uniq values_at + + - & | + ] + + DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE). + map { |s| s.to_s }.sort.uniq + + # Now do the delegation. + DELEGATING_METHODS.each do |sym| + if SPECIAL_RETURN.include?(sym) + ln = __LINE__ + 1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + FileList.new.import(result) + end + }, __FILE__, ln + else + ln = __LINE__ + 1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + result.object_id == @items.object_id ? self : result + end + }, __FILE__, ln + end + end + + # Create a file list from the globbable patterns given. If you wish to + # perform multiple includes or excludes at object build time, use the + # "yield self" pattern. + # + # Example: + # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb') + # + # pkg_files = FileList.new('lib/**/*') do |fl| + # fl.exclude(/\bCVS\b/) + # end + # + def initialize(*patterns) + @pending_add = [] + @pending = false + @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup + @exclude_procs = DEFAULT_IGNORE_PROCS.dup + @items = [] + patterns.each { |pattern| include(pattern) } + yield self if block_given? + end + + # Add file names defined by glob patterns to the file list. If an array + # is given, add each element of the array. + # + # Example: + # file_list.include("*.java", "*.cfg") + # file_list.include %w( math.c lib.h *.o ) + # + def include(*filenames) + # TODO: check for pending + filenames.each do |fn| + if fn.respond_to? :to_ary + include(*fn.to_ary) + else + @pending_add << Rake.from_pathname(fn) + end + end + @pending = true + self + end + alias :add :include + + # Register a list of file name patterns that should be excluded from the + # list. Patterns may be regular expressions, glob patterns or regular + # strings. In addition, a block given to exclude will remove entries that + # return true when given to the block. + # + # Note that glob patterns are expanded against the file system. If a file + # is explicitly added to a file list, but does not exist in the file + # system, then an glob pattern in the exclude list will not exclude the + # file. + # + # Examples: + # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c'] + # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c'] + # + # If "a.c" is a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c'] + # + # If "a.c" is not a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c'] + # + def exclude(*patterns, &block) + patterns.each do |pat| + @exclude_patterns << Rake.from_pathname(pat) + end + @exclude_procs << block if block_given? + resolve_exclude unless @pending + self + end + + # Clear all the exclude patterns so that we exclude nothing. + def clear_exclude + @exclude_patterns = [] + @exclude_procs = [] + self + end + + # A FileList is equal through array equality. + def ==(array) + to_ary == array + end + + # Return the internal array object. + def to_a + resolve + @items + end + + # Return the internal array object. + def to_ary + to_a + end + + # Lie about our class. + def is_a?(klass) + klass == Array || super(klass) + end + alias kind_of? is_a? + + # Redefine * to return either a string or a new file list. + def *(other) + result = @items * other + case result + when Array + FileList.new.import(result) + else + result + end + end + + def <<(obj) + resolve + @items << Rake.from_pathname(obj) + self + end + + # Resolve all the pending adds now. + def resolve + if @pending + @pending = false + @pending_add.each do |fn| resolve_add(fn) end + @pending_add = [] + resolve_exclude + end + self + end + + def resolve_add(fn) # :nodoc: + case fn + when %r{[*?\[\{]} + add_matching(fn) + else + self << fn + end + end + private :resolve_add + + def resolve_exclude # :nodoc: + reject! { |fn| excluded_from_list?(fn) } + self + end + private :resolve_exclude + + # Return a new FileList with the results of running +sub+ against each + # element of the original list. + # + # Example: + # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] + # + def sub(pat, rep) + inject(FileList.new) { |res, fn| res << fn.sub(pat, rep) } + end + + # Return a new FileList with the results of running +gsub+ against each + # element of the original list. + # + # Example: + # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\") + # => ['lib\\test\\file', 'x\\y'] + # + def gsub(pat, rep) + inject(FileList.new) { |res, fn| res << fn.gsub(pat, rep) } + end + + # Same as +sub+ except that the original file list is modified. + def sub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.sub(pat, rep) } + self + end + + # Same as +gsub+ except that the original file list is modified. + def gsub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) } + self + end + + # Apply the pathmap spec to each of the included file names, returning a + # new file list with the modified paths. (See String#pathmap for + # details.) + def pathmap(spec=nil) + collect { |fn| fn.pathmap(spec) } + end + + # Return a new FileList with String#ext method applied to + # each member of the array. + # + # This method is a shortcut for: + # + # array.collect { |item| item.ext(newext) } + # + # +ext+ is a user added method for the Array class. + def ext(newext='') + collect { |fn| fn.ext(newext) } + end + + # Grep each of the files in the filelist using the given pattern. If a + # block is given, call the block on each matching line, passing the file + # name, line number, and the matching line of text. If no block is given, + # a standard emacs style file:linenumber:line message will be printed to + # standard out. Returns the number of matched items. + def egrep(pattern, *options) + matched = 0 + each do |fn| + begin + open(fn, "r", *options) do |inf| + count = 0 + inf.each do |line| + count += 1 + if pattern.match(line) + matched += 1 + if block_given? + yield fn, count, line + else + puts "#{fn}:#{count}:#{line}" + end + end + end + end + rescue StandardError => ex + $stderr.puts "Error while processing '#{fn}': #{ex}" + end + end + matched + end + + # Return a new file list that only contains file names from the current + # file list that exist on the file system. + def existing + select { |fn| File.exist?(fn) } + end + + # Modify the current file list so that it contains only file name that + # exist on the file system. + def existing! + resolve + @items = @items.select { |fn| File.exist?(fn) } + self + end + + # FileList version of partition. Needed because the nested arrays should + # be FileLists in this version. + def partition(&block) # :nodoc: + resolve + result = @items.partition(&block) + [ + FileList.new.import(result[0]), + FileList.new.import(result[1]), + ] + end + + # Convert a FileList to a string by joining all elements with a space. + def to_s + resolve + self.join(' ') + end + + # Add matching glob patterns. + def add_matching(pattern) + FileList.glob(pattern).each do |fn| + self << fn unless excluded_from_list?(fn) + end + end + private :add_matching + + # Should the given file name be excluded from the list? + # + # NOTE: This method was formerly named "exclude?", but Rails + # introduced an exclude? method as an array method and setup a + # conflict with file list. We renamed the method to avoid + # confusion. If you were using "FileList#exclude?" in your user + # code, you will need to update. + def excluded_from_list?(fn) + return true if @exclude_patterns.any? do |pat| + case pat + when Regexp + fn =~ pat + when /[*?]/ + File.fnmatch?(pat, fn, File::FNM_PATHNAME) + else + fn == pat + end + end + @exclude_procs.any? { |p| p.call(fn) } + end + + DEFAULT_IGNORE_PATTERNS = [ + /(^|[\/\\])CVS([\/\\]|$)/, + /(^|[\/\\])\.svn([\/\\]|$)/, + /\.bak$/, + /~$/ + ] + DEFAULT_IGNORE_PROCS = [ + proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) } + ] + + def import(array) # :nodoc: + @items = array + self + end + + class << self + # Create a new file list including the files listed. Similar to: + # + # FileList.new(*args) + def [](*args) + new(*args) + end + + # Get a sorted list of files matching the pattern. This method + # should be preferred to Dir[pattern] and Dir.glob(pattern) because + # the files returned are guaranteed to be sorted. + def glob(pattern, *args) + Dir.glob(pattern, *args).sort + end + end + end +end + +module Rake + class << self + + # Yield each file or directory component. + def each_dir_parent(dir) # :nodoc: + old_length = nil + while dir != '.' && dir.length != old_length + yield(dir) + old_length = dir.length + dir = File.dirname(dir) + end + end + + # Convert Pathname and Pathname-like objects to strings; + # leave everything else alone + def from_pathname(path) # :nodoc: + path = path.to_path if path.respond_to?(:to_path) + path = path.to_str if path.respond_to?(:to_str) + path + end + end +end # module Rake diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_task.rb new file mode 100644 index 000000000..4c9b04074 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_task.rb @@ -0,0 +1,46 @@ +require 'rake/task.rb' +require 'rake/early_time' + +module Rake + + # A FileTask is a task that includes time based dependencies. If any of a + # FileTask's prerequisites have a timestamp that is later than the file + # represented by this task, then the file must be rebuilt (using the + # supplied actions). + # + class FileTask < Task + + # Is this file task needed? Yes if it doesn't exist, or if its time stamp + # is out of date. + def needed? + ! File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all + end + + # Time stamp for file task. + def timestamp + if File.exist?(name) + File.mtime(name.to_s) + else + Rake::LATE + end + end + + private + + # Are there any prerequisites with a later time than the given time stamp? + def out_of_date?(stamp) + @prerequisites.any? { |n| application[n, @scope].timestamp > stamp } + end + + # ---------------------------------------------------------------- + # Task class methods. + # + class << self + # Apply the scope to the task name according to the rules for this kind + # of task. File based tasks ignore the scope when creating the name. + def scope_name(scope, task_name) + Rake.from_pathname(task_name) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils.rb new file mode 100644 index 000000000..27f4e2e1d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils.rb @@ -0,0 +1,128 @@ +require 'rbconfig' +require 'fileutils' + +#-- +# This a FileUtils extension that defines several additional commands to be +# added to the FileUtils utility functions. +module FileUtils + # Path to the currently running Ruby program + RUBY = ENV['RUBY'] || File.join( + RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']). + sub(/.*\s.*/m, '"\&"') + + OPT_TABLE['sh'] = %w(noop verbose) + OPT_TABLE['ruby'] = %w(noop verbose) + + # Run the system command +cmd+. If multiple arguments are given the command + # is run directly (without the shell, same semantics as Kernel::exec and + # Kernel::system). + # + # It is recommended you use the multiple argument form over interpolating + # user input for both usability and security reasons. With the multiple + # argument form you can easily process files with spaces or other shell + # reserved characters in them. With the multiple argument form your rake + # tasks are not vulnerable to users providing an argument like + # ; rm # -rf /. + # + # If a block is given, upon command completion the block is called with an + # OK flag (true on a zero exit status) and a Process::Status object. + # Without a block a RuntimeError is raised when the command exits non-zero. + # + # Examples: + # + # sh 'ls -ltr' + # + # sh 'ls', 'file with spaces' + # + # # check exit status after command runs + # sh %{grep pattern file} do |ok, res| + # if ! ok + # puts "pattern not found (status = #{res.exitstatus})" + # end + # end + # + def sh(*cmd, &block) + options = (Hash === cmd.last) ? cmd.pop : {} + shell_runner = block_given? ? block : create_shell_runner(cmd) + set_verbose_option(options) + options[:noop] ||= Rake::FileUtilsExt.nowrite_flag + Rake.rake_check_options options, :noop, :verbose + Rake.rake_output_message cmd.join(" ") if options[:verbose] + + unless options[:noop] + res = rake_system(*cmd) + status = $? + status = Rake::PseudoStatus.new(1) if !res && status.nil? + shell_runner.call(res, status) + end + end + + def create_shell_runner(cmd) # :nodoc: + show_command = cmd.join(" ") + show_command = show_command[0, 42] + "..." unless $trace + lambda do |ok, status| + ok or + fail "Command failed with status (#{status.exitstatus}): " + + "[#{show_command}]" + end + end + private :create_shell_runner + + def set_verbose_option(options) # :nodoc: + unless options.key? :verbose + options[:verbose] = + (Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT) || + Rake::FileUtilsExt.verbose_flag + end + end + private :set_verbose_option + + def rake_system(*cmd) # :nodoc: + Rake::AltSystem.system(*cmd) + end + private :rake_system + + # Run a Ruby interpreter with the given arguments. + # + # Example: + # ruby %{-pe '$_.upcase!' 1 + sh(*([RUBY] + args + [options]), &block) + else + sh("#{RUBY} #{args.first}", options, &block) + end + end + + LN_SUPPORTED = [true] + + # Attempt to do a normal file link, but fall back to a copy if the link + # fails. + def safe_ln(*args) + if ! LN_SUPPORTED[0] + cp(*args) + else + begin + ln(*args) + rescue StandardError, NotImplementedError + LN_SUPPORTED[0] = false + cp(*args) + end + end + end + + # Split a file path into individual directory names. + # + # Example: + # split_all("a/b/c") => ['a', 'b', 'c'] + # + def split_all(path) + head, tail = File.split(path) + return [tail] if head == '.' || tail == '/' + return [head, tail] if head == '/' + return split_all(head) + [tail] + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils_ext.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils_ext.rb new file mode 100644 index 000000000..309159aec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/file_utils_ext.rb @@ -0,0 +1,144 @@ +require 'rake/file_utils' + +module Rake + # + # FileUtilsExt provides a custom version of the FileUtils methods + # that respond to the verbose and nowrite + # commands. + # + module FileUtilsExt + include FileUtils + + class << self + attr_accessor :verbose_flag, :nowrite_flag + end + + DEFAULT = Object.new + + FileUtilsExt.verbose_flag = DEFAULT + FileUtilsExt.nowrite_flag = false + + FileUtils.commands.each do |name| + opts = FileUtils.options_of name + default_options = [] + if opts.include?("verbose") + default_options << ':verbose => FileUtilsExt.verbose_flag' + end + if opts.include?("noop") + default_options << ':noop => FileUtilsExt.nowrite_flag' + end + + next if default_options.empty? + module_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{name}( *args, &block ) + super( + *rake_merge_option(args, + #{default_options.join(', ')} + ), &block) + end + EOS + end + + # Get/set the verbose flag controlling output from the FileUtils + # utilities. If verbose is true, then the utility method is + # echoed to standard output. + # + # Examples: + # verbose # return the current value of the + # # verbose flag + # verbose(v) # set the verbose flag to _v_. + # verbose(v) { code } # Execute code with the verbose flag set + # # temporarily to _v_. Return to the + # # original value when code is done. + def verbose(value=nil) + oldvalue = FileUtilsExt.verbose_flag + FileUtilsExt.verbose_flag = value unless value.nil? + if block_given? + begin + yield + ensure + FileUtilsExt.verbose_flag = oldvalue + end + end + FileUtilsExt.verbose_flag + end + + # Get/set the nowrite flag controlling output from the FileUtils + # utilities. If verbose is true, then the utility method is + # echoed to standard output. + # + # Examples: + # nowrite # return the current value of the + # # nowrite flag + # nowrite(v) # set the nowrite flag to _v_. + # nowrite(v) { code } # Execute code with the nowrite flag set + # # temporarily to _v_. Return to the + # # original value when code is done. + def nowrite(value=nil) + oldvalue = FileUtilsExt.nowrite_flag + FileUtilsExt.nowrite_flag = value unless value.nil? + if block_given? + begin + yield + ensure + FileUtilsExt.nowrite_flag = oldvalue + end + end + oldvalue + end + + # Use this function to prevent potentially destructive ruby code + # from running when the :nowrite flag is set. + # + # Example: + # + # when_writing("Building Project") do + # project.build + # end + # + # The following code will build the project under normal + # conditions. If the nowrite(true) flag is set, then the example + # will print: + # + # DRYRUN: Building Project + # + # instead of actually building the project. + # + def when_writing(msg=nil) + if FileUtilsExt.nowrite_flag + $stderr.puts "DRYRUN: #{msg}" if msg + else + yield + end + end + + # Merge the given options with the default values. + def rake_merge_option(args, defaults) + if Hash === args.last + defaults.update(args.last) + args.pop + end + args.push defaults + args + end + + # Send the message to the default rake output (which is $stderr). + def rake_output_message(message) + $stderr.puts(message) + end + + # Check that the options do not contain options not listed in + # +optdecl+. An ArgumentError exception is thrown if non-declared + # options are found. + def rake_check_options(options, *optdecl) + h = options.dup + optdecl.each do |name| + h.delete name + end + raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless + h.empty? + end + + extend self + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/gempackagetask.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/gempackagetask.rb new file mode 100644 index 000000000..16e7ce042 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/gempackagetask.rb @@ -0,0 +1,4 @@ +# TODO: Remove in Rake 11 + +fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported. " + + "Use 'rubygems/package_task' instead." diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_chain.rb new file mode 100644 index 000000000..540628957 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_chain.rb @@ -0,0 +1,56 @@ +module Rake + + # InvocationChain tracks the chain of task invocations to detect + # circular dependencies. + class InvocationChain < LinkedList + + # Is the invocation already in the chain? + def member?(invocation) + head == invocation || tail.member?(invocation) + end + + # Append an invocation to the chain of invocations. It is an error + # if the invocation already listed. + def append(invocation) + if member?(invocation) + fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}" + end + conj(invocation) + end + + # Convert to string, ie: TOP => invocation => invocation + def to_s + "#{prefix}#{head}" + end + + # Class level append. + def self.append(invocation, chain) + chain.append(invocation) + end + + private + + def prefix + "#{tail} => " + end + + # Null object for an empty chain. + class EmptyInvocationChain < LinkedList::EmptyLinkedList + @parent = InvocationChain + + def member?(obj) + false + end + + def append(invocation) + conj(invocation) + end + + def to_s + "TOP" + end + end + + EMPTY = EmptyInvocationChain.new + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_exception_mixin.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_exception_mixin.rb new file mode 100644 index 000000000..84ff3353b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/invocation_exception_mixin.rb @@ -0,0 +1,16 @@ +module Rake + module InvocationExceptionMixin + # Return the invocation chain (list of Rake tasks) that were in + # effect when this exception was detected by rake. May be null if + # no tasks were active. + def chain + @rake_invocation_chain ||= nil + end + + # Set the invocation chain in effect when this exception was + # detected. + def chain=(value) + @rake_invocation_chain = value + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/late_time.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/late_time.rb new file mode 100644 index 000000000..d959a7821 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/late_time.rb @@ -0,0 +1,17 @@ +module Rake + # LateTime is a fake timestamp that occurs _after_ any other time value. + class LateTime + include Comparable + include Singleton + + def <=>(other) + 1 + end + + def to_s + '' + end + end + + LATE = LateTime.instance +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/linked_list.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/linked_list.rb new file mode 100644 index 000000000..b5ab79780 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/linked_list.rb @@ -0,0 +1,103 @@ +module Rake + + # Polylithic linked list structure used to implement several data + # structures in Rake. + class LinkedList + include Enumerable + + attr_reader :head, :tail + + def initialize(head, tail=EMPTY) + @head = head + @tail = tail + end + + # Polymorphically add a new element to the head of a list. The + # type of head node will be the same list type as the tail. + def conj(item) + self.class.cons(item, self) + end + + # Is the list empty? + def empty? + false + end + + # Lists are structurally equivalent. + def ==(other) + current = self + while ! current.empty? && ! other.empty? + return false if current.head != other.head + current = current.tail + other = other.tail + end + current.empty? && other.empty? + end + + # Convert to string: LL(item, item...) + def to_s + items = map { |item| item.to_s }.join(", ") + "LL(#{items})" + end + + # Same as +to_s+, but with inspected items. + def inspect + items = map { |item| item.inspect }.join(", ") + "LL(#{items})" + end + + # For each item in the list. + def each + current = self + while ! current.empty? + yield(current.head) + current = current.tail + end + self + end + + # Make a list out of the given arguments. This method is + # polymorphic + def self.make(*args) + result = empty + args.reverse_each do |item| + result = cons(item, result) + end + result + end + + # Cons a new head onto the tail list. + def self.cons(head, tail) + new(head, tail) + end + + # The standard empty list class for the given LinkedList class. + def self.empty + self::EMPTY + end + + # Represent an empty list, using the Null Object Pattern. + # + # When inheriting from the LinkedList class, you should implement + # a type specific Empty class as well. Make sure you set the class + # instance variable @parent to the associated list class (this + # allows conj, cons and make to work polymorphically). + class EmptyLinkedList < LinkedList + @parent = LinkedList + + def initialize + end + + def empty? + true + end + + def self.cons(head, tail) + @parent.cons(head, tail) + end + end + + EMPTY = EmptyLinkedList.new + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/loaders/makefile.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/loaders/makefile.rb new file mode 100644 index 000000000..4ece4323a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/loaders/makefile.rb @@ -0,0 +1,40 @@ +module Rake + + # Makefile loader to be used with the import file loader. + class MakefileLoader + include Rake::DSL + + SPACE_MARK = "\0" + + # Load the makefile dependencies in +fn+. + def load(fn) + lines = File.read fn + lines.gsub!(/\\ /, SPACE_MARK) + lines.gsub!(/#[^\n]*\n/m, "") + lines.gsub!(/\\\n/, ' ') + lines.each_line do |line| + process_line(line) + end + end + + private + + # Process one logical line of makefile data. + def process_line(line) + file_tasks, args = line.split(':', 2) + return if args.nil? + dependents = args.split.map { |d| respace(d) } + file_tasks.scan(/\S+/) do |file_task| + file_task = respace(file_task) + file file_task => dependents + end + end + + def respace(str) + str.tr SPACE_MARK, ' ' + end + end + + # Install the handler + Rake.application.add_loader('mf', MakefileLoader.new) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/multi_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/multi_task.rb new file mode 100644 index 000000000..5418a7a7b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/multi_task.rb @@ -0,0 +1,13 @@ +module Rake + + # Same as a regular task, but the immediate prerequisites are done in + # parallel using Ruby threads. + # + class MultiTask < Task + private + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: + invoke_prerequisites_concurrently(task_args, invocation_chain) + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/name_space.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/name_space.rb new file mode 100644 index 000000000..58f911e43 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/name_space.rb @@ -0,0 +1,38 @@ +## +# The NameSpace class will lookup task names in the scope defined by a +# +namespace+ command. + +class Rake::NameSpace + + ## + # Create a namespace lookup object using the given task manager + # and the list of scopes. + + def initialize(task_manager, scope_list) + @task_manager = task_manager + @scope = scope_list.dup + end + + ## + # Lookup a task named +name+ in the namespace. + + def [](name) + @task_manager.lookup(name, @scope) + end + + ## + # The scope of the namespace (a LinkedList) + + def scope + @scope.dup + end + + ## + # Return the list of tasks defined in this and nested namespaces. + + def tasks + @task_manager.tasks_in_scope(@scope) + end + +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/packagetask.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/packagetask.rb new file mode 100644 index 000000000..249ee72b1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/packagetask.rb @@ -0,0 +1,199 @@ +# Define a package task library to aid in the definition of +# redistributable package files. + +require 'rake' +require 'rake/tasklib' + +module Rake + + # Create a packaging task that will package the project into + # distributable files (e.g zip archive or tar files). + # + # The PackageTask will create the following targets: + # + # +:package+ :: + # Create all the requested package files. + # + # +:clobber_package+ :: + # Delete all the package files. This target is automatically + # added to the main clobber target. + # + # +:repackage+ :: + # Rebuild the package files from scratch, even if they are not out + # of date. + # + # "package_dir/name-version.tgz" :: + # Create a gzipped tar package (if need_tar is true). + # + # "package_dir/name-version.tar.gz" :: + # Create a gzipped tar package (if need_tar_gz is true). + # + # "package_dir/name-version.tar.bz2" :: + # Create a bzip2'd tar package (if need_tar_bz2 is true). + # + # "package_dir/name-version.zip" :: + # Create a zip package archive (if need_zip is true). + # + # Example: + # + # Rake::PackageTask.new("rake", "1.2.3") do |p| + # p.need_tar = true + # p.package_files.include("lib/**/*.rb") + # end + # + class PackageTask < TaskLib + # Name of the package (from the GEM Spec). + attr_accessor :name + + # Version of the package (e.g. '1.3.2'). + attr_accessor :version + + # Directory used to store the package files (default is 'pkg'). + attr_accessor :package_dir + + # True if a gzipped tar file (tgz) should be produced (default is + # false). + attr_accessor :need_tar + + # True if a gzipped tar file (tar.gz) should be produced (default + # is false). + attr_accessor :need_tar_gz + + # True if a bzip2'd tar file (tar.bz2) should be produced (default + # is false). + attr_accessor :need_tar_bz2 + + # True if a zip file should be produced (default is false) + attr_accessor :need_zip + + # List of files to be included in the package. + attr_accessor :package_files + + # Tar command for gzipped or bzip2ed archives. The default is 'tar'. + attr_accessor :tar_command + + # Zip command for zipped archives. The default is 'zip'. + attr_accessor :zip_command + + # Create a Package Task with the given name and version. Use +:noversion+ + # as the version to build a package without a version or to provide a + # fully-versioned package name. + + def initialize(name=nil, version=nil) + init(name, version) + yield self if block_given? + define unless name.nil? + end + + # Initialization that bypasses the "yield self" and "define" step. + def init(name, version) + @name = name + @version = version + @package_files = Rake::FileList.new + @package_dir = 'pkg' + @need_tar = false + @need_tar_gz = false + @need_tar_bz2 = false + @need_zip = false + @tar_command = 'tar' + @zip_command = 'zip' + end + + # Create the tasks defined by this task library. + def define + fail "Version required (or :noversion)" if @version.nil? + @version = nil if :noversion == @version + + desc "Build all the packages" + task :package + + desc "Force a rebuild of the package files" + task :repackage => [:clobber_package, :package] + + desc "Remove package products" + task :clobber_package do + rm_r package_dir rescue nil + end + + task :clobber => [:clobber_package] + + [ + [need_tar, tgz_file, "z"], + [need_tar_gz, tar_gz_file, "z"], + [need_tar_bz2, tar_bz2_file, "j"] + ].each do |(need, file, flag)| + if need + task :package => ["#{package_dir}/#{file}"] + file "#{package_dir}/#{file}" => + [package_dir_path] + package_files do + chdir(package_dir) do + sh @tar_command, "#{flag}cvf", file, package_name + end + end + end + end + + if need_zip + task :package => ["#{package_dir}/#{zip_file}"] + file "#{package_dir}/#{zip_file}" => + [package_dir_path] + package_files do + chdir(package_dir) do + sh @zip_command, "-r", zip_file, package_name + end + end + end + + directory package_dir_path => @package_files do + @package_files.each do |fn| + f = File.join(package_dir_path, fn) + fdir = File.dirname(f) + mkdir_p(fdir) unless File.exist?(fdir) + if File.directory?(fn) + mkdir_p(f) + else + rm_f f + safe_ln(fn, f) + end + end + end + self + end + + # The name of this package + + def package_name + @version ? "#{@name}-#{@version}" : @name + end + + # The directory this package will be built in + + def package_dir_path + "#{package_dir}/#{package_name}" + end + + # The package name with .tgz added + + def tgz_file + "#{package_name}.tgz" + end + + # The package name with .tar.gz added + + def tar_gz_file + "#{package_name}.tar.gz" + end + + # The package name with .tar.bz2 added + + def tar_bz2_file + "#{package_name}.tar.bz2" + end + + # The package name with .zip added + + def zip_file + "#{package_name}.zip" + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pathmap.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pathmap.rb new file mode 100644 index 000000000..9a840cda2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pathmap.rb @@ -0,0 +1,3 @@ +# TODO: Remove in Rake 11 + +require 'rake/ext/string' diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/phony.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/phony.rb new file mode 100644 index 000000000..29633ae06 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/phony.rb @@ -0,0 +1,15 @@ +# Defines a :phony task that you can use as a dependency. This allows +# file-based tasks to use non-file-based tasks as prerequisites +# without forcing them to rebuild. +# +# See FileTask#out_of_date? and Task#timestamp for more info. + +require 'rake' + +task :phony + +Rake::Task[:phony].tap do |task| + def task.timestamp # :nodoc: + Time.at 0 + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/private_reader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/private_reader.rb new file mode 100644 index 000000000..162097857 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/private_reader.rb @@ -0,0 +1,20 @@ +module Rake + + # Include PrivateReader to use +private_reader+. + module PrivateReader # :nodoc: all + + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + + # Declare a list of private accessors + def private_reader(*names) + attr_reader(*names) + private(*names) + end + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/promise.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/promise.rb new file mode 100644 index 000000000..31c456347 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/promise.rb @@ -0,0 +1,99 @@ +module Rake + + # A Promise object represents a promise to do work (a chore) in the + # future. The promise is created with a block and a list of + # arguments for the block. Calling value will return the value of + # the promised chore. + # + # Used by ThreadPool. + # + class Promise # :nodoc: all + NOT_SET = Object.new.freeze # :nodoc: + + attr_accessor :recorder + + # Create a promise to do the chore specified by the block. + def initialize(args, &block) + @mutex = Mutex.new + @result = NOT_SET + @error = NOT_SET + @args = args + @block = block + end + + # Return the value of this promise. + # + # If the promised chore is not yet complete, then do the work + # synchronously. We will wait. + def value + unless complete? + stat :sleeping_on, :item_id => object_id + @mutex.synchronize do + stat :has_lock_on, :item_id => object_id + chore + stat :releasing_lock_on, :item_id => object_id + end + end + error? ? raise(@error) : @result + end + + # If no one else is working this promise, go ahead and do the chore. + def work + stat :attempting_lock_on, :item_id => object_id + if @mutex.try_lock + stat :has_lock_on, :item_id => object_id + chore + stat :releasing_lock_on, :item_id => object_id + @mutex.unlock + else + stat :bailed_on, :item_id => object_id + end + end + + private + + # Perform the chore promised + def chore + if complete? + stat :found_completed, :item_id => object_id + return + end + stat :will_execute, :item_id => object_id + begin + @result = @block.call(*@args) + rescue Exception => e + @error = e + end + stat :did_execute, :item_id => object_id + discard + end + + # Do we have a result for the promise + def result? + ! @result.equal?(NOT_SET) + end + + # Did the promise throw an error + def error? + ! @error.equal?(NOT_SET) + end + + # Are we done with the promise + def complete? + result? || error? + end + + # free up these items for the GC + def discard + @args = nil + @block = nil + end + + # Record execution statistics if there is a recorder + def stat(*args) + @recorder.call(*args) if @recorder + end + + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pseudo_status.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pseudo_status.rb new file mode 100644 index 000000000..16e1903bd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/pseudo_status.rb @@ -0,0 +1,29 @@ +module Rake + + ## + # Exit status class for times the system just gives us a nil. + class PseudoStatus # :nodoc: all + attr_reader :exitstatus + + def initialize(code=0) + @exitstatus = code + end + + def to_i + @exitstatus << 8 + end + + def >>(n) + to_i >> n + end + + def stopped? + false + end + + def exited? + true + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_module.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_module.rb new file mode 100644 index 000000000..369275343 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_module.rb @@ -0,0 +1,38 @@ +require 'rake/application' + +module Rake + + class << self + # Current Rake Application + def application + @application ||= Rake::Application.new + end + + # Set the current Rake application object. + def application=(app) + @application = app + end + + def suggested_thread_count # :nodoc: + @cpu_count ||= Rake::CpuCounter.count + @cpu_count + 4 + end + + # Return the original directory where the Rake application was started. + def original_dir + application.original_dir + end + + # Load a rakefile. + def load_rakefile(path) + load(path) + end + + # Add files to the rakelib list + def add_rakelib(*files) + application.options.rakelib ||= [] + application.options.rakelib.concat(files) + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb new file mode 100644 index 000000000..7e3a6b3f3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb @@ -0,0 +1,22 @@ +require 'rake' + +# Load the test files from the command line. +argv = ARGV.select do |argument| + case argument + when /^-/ then + argument + when /\*/ then + FileList[argument].to_a.each do |file| + require File.expand_path file + end + + false + else + require File.expand_path argument + + false + end +end + +ARGV.replace argv + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rdoctask.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rdoctask.rb new file mode 100644 index 000000000..8d7df4f12 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rdoctask.rb @@ -0,0 +1,4 @@ +# TODO: Remove in Rake 11 + +fail "ERROR: 'rake/rdoctask' is obsolete and no longer supported. " + + "Use 'rdoc/task' (available in RDoc 2.4.2+) instead." diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ruby182_test_unit_fix.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ruby182_test_unit_fix.rb new file mode 100644 index 000000000..40b30a6fd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/ruby182_test_unit_fix.rb @@ -0,0 +1,29 @@ +# TODO: Remove in rake 11 + +# Local Rake override to fix bug in Ruby 0.8.2 +module Test # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + module Unit # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + module Collector # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + class Dir # :nodoc: + undef collect_file + def collect_file(name, suites, already_gathered) # :nodoc: + dir = File.dirname(File.expand_path(name)) + $:.unshift(dir) unless $:.first == dir + if @req + @req.require(name) + else + require(name) + end + find_test_cases(already_gathered).each do |t| + add_suite(suites, t.suite) + end + ensure + $:.delete_at $:.rindex(dir) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rule_recursion_overflow_error.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rule_recursion_overflow_error.rb new file mode 100644 index 000000000..da4318da9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/rule_recursion_overflow_error.rb @@ -0,0 +1,20 @@ + +module Rake + + # Error indicating a recursion overflow error in task selection. + class RuleRecursionOverflowError < StandardError + def initialize(*args) + super + @targets = [] + end + + def add_target(target) + @targets << target + end + + def message + super + ": [" + @targets.reverse.join(' => ') + "]" + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/runtest.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/runtest.rb new file mode 100644 index 000000000..4774b0e26 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/runtest.rb @@ -0,0 +1,27 @@ +require 'test/unit' +require 'test/unit/assertions' +require 'rake/file_list' + +module Rake + include Test::Unit::Assertions + + ## + # Deprecated way of running tests in process, but only for Test::Unit. + #-- + # TODO: Remove in rake 11 + + def run_tests(pattern='test/test*.rb', log_enabled=false) # :nodoc: + FileList.glob(pattern).each do |fn| + $stderr.puts fn if log_enabled + begin + require fn + rescue Exception => ex + $stderr.puts "Error in #{fn}: #{ex.message}" + $stderr.puts ex.backtrace + assert false + end + end + end + + extend self +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/scope.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/scope.rb new file mode 100644 index 000000000..dbefcea46 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/scope.rb @@ -0,0 +1,42 @@ +module Rake + class Scope < LinkedList # :nodoc: all + + # Path for the scope. + def path + map { |item| item.to_s }.reverse.join(":") + end + + # Path for the scope + the named path. + def path_with_task_name(task_name) + "#{path}:#{task_name}" + end + + # Trim +n+ innermost scope levels from the scope. In no case will + # this trim beyond the toplevel scope. + def trim(n) + result = self + while n > 0 && ! result.empty? + result = result.tail + n -= 1 + end + result + end + + # Scope lists always end with an EmptyScope object. See Null + # Object Pattern) + class EmptyScope < EmptyLinkedList + @parent = Scope + + def path + "" + end + + def path_with_task_name(task_name) + task_name + end + end + + # Singleton null object for an empty scope. + EMPTY = EmptyScope.new + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task.rb new file mode 100644 index 000000000..9bcf72552 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task.rb @@ -0,0 +1,383 @@ +require 'rake/invocation_exception_mixin' + +module Rake + + ## + # A Task is the basic unit of work in a Rakefile. Tasks have associated + # actions (possibly more than one) and a list of prerequisites. When + # invoked, a task will first ensure that all of its prerequisites have an + # opportunity to run and then it will execute its own actions. + # + # Tasks are not usually created directly using the new method, but rather + # use the +file+ and +task+ convenience methods. + # + class Task + # List of prerequisites for a task. + attr_reader :prerequisites + + # List of actions attached to a task. + attr_reader :actions + + # Application owning this task. + attr_accessor :application + + # Array of nested namespaces names used for task lookup by this task. + attr_reader :scope + + # File/Line locations of each of the task definitions for this + # task (only valid if the task was defined with the detect + # location option set). + attr_reader :locations + + # Return task name + def to_s + name + end + + def inspect # :nodoc: + "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>" + end + + # List of sources for task. + attr_writer :sources + def sources + if defined?(@sources) + @sources + else + prerequisites + end + end + + # List of prerequisite tasks + def prerequisite_tasks + prerequisites.map { |pre| lookup_prerequisite(pre) } + end + + def lookup_prerequisite(prerequisite_name) # :nodoc: + application[prerequisite_name, @scope] + end + private :lookup_prerequisite + + # List of all unique prerequisite tasks including prerequisite tasks' + # prerequisites. + # Includes self when cyclic dependencies are found. + def all_prerequisite_tasks + seen = {} + collect_prerequisites(seen) + seen.values + end + + def collect_prerequisites(seen) # :nodoc: + prerequisite_tasks.each do |pre| + next if seen[pre.name] + seen[pre.name] = pre + pre.collect_prerequisites(seen) + end + end + protected :collect_prerequisites + + # First source from a rule (nil if no sources) + def source + sources.first + end + + # Create a task named +task_name+ with no actions or prerequisites. Use + # +enhance+ to add actions and prerequisites. + def initialize(task_name, app) + @name = task_name.to_s + @prerequisites = [] + @actions = [] + @already_invoked = false + @comments = [] + @lock = Monitor.new + @application = app + @scope = app.current_scope + @arg_names = nil + @locations = [] + end + + # Enhance a task with prerequisites or actions. Returns self. + def enhance(deps=nil, &block) + @prerequisites |= deps if deps + @actions << block if block_given? + self + end + + # Name of the task, including any namespace qualifiers. + def name + @name.to_s + end + + # Name of task with argument list description. + def name_with_args # :nodoc: + if arg_description + "#{name}#{arg_description}" + else + name + end + end + + # Argument description (nil if none). + def arg_description # :nodoc: + @arg_names ? "[#{arg_names.join(',')}]" : nil + end + + # Name of arguments for this task. + def arg_names + @arg_names || [] + end + + # Reenable the task, allowing its tasks to be executed if the task + # is invoked again. + def reenable + @already_invoked = false + end + + # Clear the existing prerequisites and actions of a rake task. + def clear + clear_prerequisites + clear_actions + clear_comments + self + end + + # Clear the existing prerequisites of a rake task. + def clear_prerequisites + prerequisites.clear + self + end + + # Clear the existing actions on a rake task. + def clear_actions + actions.clear + self + end + + # Clear the existing comments on a rake task. + def clear_comments + @comments = [] + self + end + + # Invoke the task if it is needed. Prerequisites are invoked first. + def invoke(*args) + task_args = TaskArguments.new(arg_names, args) + invoke_with_call_chain(task_args, InvocationChain::EMPTY) + end + + # Same as invoke, but explicitly pass a call chain to detect + # circular dependencies. + def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: + new_chain = InvocationChain.append(self, invocation_chain) + @lock.synchronize do + if application.options.trace + application.trace "** Invoke #{name} #{format_trace_flags}" + end + return if @already_invoked + @already_invoked = true + invoke_prerequisites(task_args, new_chain) + execute(task_args) if needed? + end + rescue Exception => ex + add_chain_to(ex, new_chain) + raise ex + end + protected :invoke_with_call_chain + + def add_chain_to(exception, new_chain) # :nodoc: + exception.extend(InvocationExceptionMixin) unless + exception.respond_to?(:chain) + exception.chain = new_chain if exception.chain.nil? + end + private :add_chain_to + + # Invoke all the prerequisites of a task. + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: + if application.options.always_multitask + invoke_prerequisites_concurrently(task_args, invocation_chain) + else + prerequisite_tasks.each { |p| + prereq_args = task_args.new_scope(p.arg_names) + p.invoke_with_call_chain(prereq_args, invocation_chain) + } + end + end + + # Invoke all the prerequisites of a task in parallel. + def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc: + futures = prerequisite_tasks.map do |p| + prereq_args = task_args.new_scope(p.arg_names) + application.thread_pool.future(p) do |r| + r.invoke_with_call_chain(prereq_args, invocation_chain) + end + end + futures.each { |f| f.value } + end + + # Format the trace flags for display. + def format_trace_flags + flags = [] + flags << "first_time" unless @already_invoked + flags << "not_needed" unless needed? + flags.empty? ? "" : "(" + flags.join(", ") + ")" + end + private :format_trace_flags + + # Execute the actions associated with this task. + def execute(args=nil) + args ||= EMPTY_TASK_ARGS + if application.options.dryrun + application.trace "** Execute (dry run) #{name}" + return + end + application.trace "** Execute #{name}" if application.options.trace + application.enhance_with_matching_rule(name) if @actions.empty? + @actions.each do |act| + case act.arity + when 1 + act.call(self) + else + act.call(self, args) + end + end + end + + # Is this task needed? + def needed? + true + end + + # Timestamp for this task. Basic tasks return the current time for their + # time stamp. Other tasks can be more sophisticated. + def timestamp + Time.now + end + + # Add a description to the task. The description can consist of an option + # argument list (enclosed brackets) and an optional comment. + def add_description(description) + return unless description + comment = description.strip + add_comment(comment) if comment && ! comment.empty? + end + + def comment=(comment) # :nodoc: + add_comment(comment) + end + + def add_comment(comment) # :nodoc: + return if comment.nil? + @comments << comment unless @comments.include?(comment) + end + private :add_comment + + # Full collection of comments. Multiple comments are separated by + # newlines. + def full_comment + transform_comments("\n") + end + + # First line (or sentence) of all comments. Multiple comments are + # separated by a "/". + def comment + transform_comments(" / ") { |c| first_sentence(c) } + end + + # Transform the list of comments as specified by the block and + # join with the separator. + def transform_comments(separator, &block) + if @comments.empty? + nil + else + block ||= lambda { |c| c } + @comments.map(&block).join(separator) + end + end + private :transform_comments + + # Get the first sentence in a string. The sentence is terminated + # by the first period or the end of the line. Decimal points do + # not count as periods. + def first_sentence(string) + string.split(/\.[ \t]|\.$|\n/).first + end + private :first_sentence + + # Set the names of the arguments for this task. +args+ should be + # an array of symbols, one for each argument name. + def set_arg_names(args) + @arg_names = args.map { |a| a.to_sym } + end + + # Return a string describing the internal state of a task. Useful for + # debugging. + def investigation + result = "------------------------------\n" + result << "Investigating #{name}\n" + result << "class: #{self.class}\n" + result << "task needed: #{needed?}\n" + result << "timestamp: #{timestamp}\n" + result << "pre-requisites: \n" + prereqs = prerequisite_tasks + prereqs.sort! { |a, b| a.timestamp <=> b.timestamp } + prereqs.each do |p| + result << "--#{p.name} (#{p.timestamp})\n" + end + latest_prereq = prerequisite_tasks.map { |pre| pre.timestamp }.max + result << "latest-prerequisite time: #{latest_prereq}\n" + result << "................................\n\n" + return result + end + + # ---------------------------------------------------------------- + # Rake Module Methods + # + class << self + + # Clear the task list. This cause rake to immediately forget all the + # tasks that have been assigned. (Normally used in the unit tests.) + def clear + Rake.application.clear + end + + # List of all defined tasks. + def tasks + Rake.application.tasks + end + + # Return a task with the given name. If the task is not currently + # known, try to synthesize one from the defined rules. If no rules are + # found, but an existing file matches the task name, assume it is a file + # task with no dependencies or actions. + def [](task_name) + Rake.application[task_name] + end + + # TRUE if the task name is already defined. + def task_defined?(task_name) + Rake.application.lookup(task_name) != nil + end + + # Define a task given +args+ and an option block. If a rule with the + # given name already exists, the prerequisites and actions are added to + # the existing task. Returns the defined task. + def define_task(*args, &block) + Rake.application.define_task(self, *args, &block) + end + + # Define a rule for synthesizing tasks. + def create_rule(*args, &block) + Rake.application.create_rule(*args, &block) + end + + # Apply the scope to the task name according to the rules for + # this kind of task. Generic tasks will accept the scope as + # part of the name. + def scope_name(scope, task_name) +# (scope + [task_name]).join(':') + scope.path_with_task_name(task_name) + end + + end # class << Rake::Task + end # class Rake::Task +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_argument_error.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_argument_error.rb new file mode 100644 index 000000000..3e1dda64d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_argument_error.rb @@ -0,0 +1,7 @@ +module Rake + + # Error indicating an ill-formed task declaration. + class TaskArgumentError < ArgumentError + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_arguments.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_arguments.rb new file mode 100644 index 000000000..fc0d65727 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_arguments.rb @@ -0,0 +1,98 @@ +module Rake + + ## + # TaskArguments manage the arguments passed to a task. + # + class TaskArguments + include Enumerable + + # Argument names + attr_reader :names + + # Create a TaskArgument object with a list of argument +names+ and a set + # of associated +values+. +parent+ is the parent argument object. + def initialize(names, values, parent=nil) + @names = names + @parent = parent + @hash = {} + @values = values + names.each_with_index { |name, i| + @hash[name.to_sym] = values[i] unless values[i].nil? + } + end + + # Retrieve the complete array of sequential values + def to_a + @values.dup + end + + # Retrieve the list of values not associated with named arguments + def extras + @values[@names.length..-1] || [] + end + + # Create a new argument scope using the prerequisite argument + # names. + def new_scope(names) + values = names.map { |n| self[n] } + self.class.new(names, values + extras, self) + end + + # Find an argument value by name or index. + def [](index) + lookup(index.to_sym) + end + + # Specify a hash of default values for task arguments. Use the + # defaults only if there is no specific value for the given + # argument. + def with_defaults(defaults) + @hash = defaults.merge(@hash) + end + + # Enumerates the arguments and their values + def each(&block) + @hash.each(&block) + end + + # Extracts the argument values at +keys+ + def values_at(*keys) + keys.map { |k| lookup(k) } + end + + # Returns the value of the given argument via method_missing + def method_missing(sym, *args) + lookup(sym.to_sym) + end + + # Returns a Hash of arguments and their values + def to_hash + @hash + end + + def to_s # :nodoc: + @hash.inspect + end + + def inspect # :nodoc: + to_s + end + + # Returns true if +key+ is one of the arguments + def has_key?(key) + @hash.has_key?(key) + end + + protected + + def lookup(name) # :nodoc: + if @hash.has_key?(name) + @hash[name] + elsif @parent + @parent.lookup(name) + end + end + end + + EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc: +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_manager.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_manager.rb new file mode 100644 index 000000000..cbb9f5ee2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/task_manager.rb @@ -0,0 +1,310 @@ +module Rake + + # The TaskManager module is a mixin for managing tasks. + module TaskManager + # Track the last comment made in the Rakefile. + attr_accessor :last_description + + # TODO: Remove in Rake 11 + + alias :last_comment :last_description # :nodoc: Backwards compatibility + + def initialize # :nodoc: + super + @tasks = Hash.new + @rules = Array.new + @scope = Scope.make + @last_description = nil + end + + def create_rule(*args, &block) # :nodoc: + pattern, args, deps = resolve_args(args) + pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern + @rules << [pattern, args, deps, block] + end + + def define_task(task_class, *args, &block) # :nodoc: + task_name, arg_names, deps = resolve_args(args) + + original_scope = @scope + if String === task_name and + not task_class.ancestors.include? Rake::FileTask then + task_name, *definition_scope = *(task_name.split(":").reverse) + @scope = Scope.make(*(definition_scope + @scope.to_a)) + end + + task_name = task_class.scope_name(@scope, task_name) + deps = [deps] unless deps.respond_to?(:to_ary) + deps = deps.map { |d| Rake.from_pathname(d).to_s } + task = intern(task_class, task_name) + task.set_arg_names(arg_names) unless arg_names.empty? + if Rake::TaskManager.record_task_metadata + add_location(task) + task.add_description(get_description(task)) + end + task.enhance(deps, &block) + ensure + @scope = original_scope + end + + # Lookup a task. Return an existing task if found, otherwise + # create a task of the current type. + def intern(task_class, task_name) + @tasks[task_name.to_s] ||= task_class.new(task_name, self) + end + + # Find a matching task for +task_name+. + def [](task_name, scopes=nil) + task_name = task_name.to_s + self.lookup(task_name, scopes) or + enhance_with_matching_rule(task_name) or + synthesize_file_task(task_name) or + fail "Don't know how to build task '#{task_name}'" + end + + def synthesize_file_task(task_name) # :nodoc: + return nil unless File.exist?(task_name) + define_task(Rake::FileTask, task_name) + end + + # Resolve the arguments for a task/rule. Returns a triplet of + # [task_name, arg_name_list, prerequisites]. + def resolve_args(args) + if args.last.is_a?(Hash) + deps = args.pop + resolve_args_with_dependencies(args, deps) + else + resolve_args_without_dependencies(args) + end + end + + # Resolve task arguments for a task or rule when there are no + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t + # task :t, [:a] + # + def resolve_args_without_dependencies(args) + task_name = args.shift + if args.size == 1 && args.first.respond_to?(:to_ary) + arg_names = args.first.to_ary + else + arg_names = args + end + [task_name, arg_names, []] + end + private :resolve_args_without_dependencies + + # Resolve task arguments for a task or rule when there are + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t => [:d] + # task :t, [a] => [:d] + # + def resolve_args_with_dependencies(args, hash) # :nodoc: + fail "Task Argument Error" if hash.size != 1 + key, value = hash.map { |k, v| [k, v] }.first + if args.empty? + task_name = key + arg_names = [] + deps = value || [] + else + task_name = args.shift + arg_names = key + deps = value + end + deps = [deps] unless deps.respond_to?(:to_ary) + [task_name, arg_names, deps] + end + private :resolve_args_with_dependencies + + # If a rule can be found that matches the task name, enhance the + # task with the prerequisites and actions from the rule. Set the + # source attribute of the task appropriately for the rule. Return + # the enhanced task or nil of no rule was found. + def enhance_with_matching_rule(task_name, level=0) + fail Rake::RuleRecursionOverflowError, + "Rule Recursion Too Deep" if level >= 16 + @rules.each do |pattern, args, extensions, block| + if pattern.match(task_name) + task = attempt_rule(task_name, args, extensions, block, level) + return task if task + end + end + nil + rescue Rake::RuleRecursionOverflowError => ex + ex.add_target(task_name) + fail ex + end + + # List of all defined tasks in this application. + def tasks + @tasks.values.sort_by { |t| t.name } + end + + # List of all the tasks defined in the given scope (and its + # sub-scopes). + def tasks_in_scope(scope) + prefix = scope.path + tasks.select { |t| + /^#{prefix}:/ =~ t.name + } + end + + # Clear all tasks in this application. + def clear + @tasks.clear + @rules.clear + end + + # Lookup a task, using scope and the scope hints in the task name. + # This method performs straight lookups without trying to + # synthesize file tasks or rules. Special scope names (e.g. '^') + # are recognized. If no scope argument is supplied, use the + # current scope. Return nil if the task cannot be found. + def lookup(task_name, initial_scope=nil) + initial_scope ||= @scope + task_name = task_name.to_s + if task_name =~ /^rake:/ + scopes = Scope.make + task_name = task_name.sub(/^rake:/, '') + elsif task_name =~ /^(\^+)/ + scopes = initial_scope.trim($1.size) + task_name = task_name.sub(/^(\^+)/, '') + else + scopes = initial_scope + end + lookup_in_scope(task_name, scopes) + end + + # Lookup the task name + def lookup_in_scope(name, scope) + loop do + tn = scope.path_with_task_name(name) + task = @tasks[tn] + return task if task + break if scope.empty? + scope = scope.tail + end + nil + end + private :lookup_in_scope + + # Return the list of scope names currently active in the task + # manager. + def current_scope + @scope + end + + # Evaluate the block in a nested namespace named +name+. Create + # an anonymous namespace if +name+ is nil. + def in_namespace(name) + name ||= generate_name + @scope = Scope.new(name, @scope) + ns = NameSpace.new(self, @scope) + yield(ns) + ns + ensure + @scope = @scope.tail + end + + private + + # Add a location to the locations field of the given task. + def add_location(task) + loc = find_location + task.locations << loc if loc + task + end + + # Find the location that called into the dsl layer. + def find_location + locations = caller + i = 0 + while locations[i] + return locations[i + 1] if locations[i] =~ /rake\/dsl_definition.rb/ + i += 1 + end + nil + end + + # Generate an anonymous namespace name. + def generate_name + @seed ||= 0 + @seed += 1 + "_anon_#{@seed}" + end + + def trace_rule(level, message) # :nodoc: + options.trace_output.puts "#{" " * level}#{message}" if + Rake.application.options.trace_rules + end + + # Attempt to create a rule given the list of prerequisites. + def attempt_rule(task_name, args, extensions, block, level) + sources = make_sources(task_name, extensions) + prereqs = sources.map { |source| + trace_rule level, "Attempting Rule #{task_name} => #{source}" + if File.exist?(source) || Rake::Task.task_defined?(source) + trace_rule level, "(#{task_name} => #{source} ... EXIST)" + source + elsif parent = enhance_with_matching_rule(source, level + 1) + trace_rule level, "(#{task_name} => #{source} ... ENHANCE)" + parent.name + else + trace_rule level, "(#{task_name} => #{source} ... FAIL)" + return nil + end + } + task = FileTask.define_task(task_name, {args => prereqs}, &block) + task.sources = prereqs + task + end + + # Make a list of sources from the list of file name extensions / + # translation procs. + def make_sources(task_name, extensions) + result = extensions.map { |ext| + case ext + when /%/ + task_name.pathmap(ext) + when %r{/} + ext + when /^\./ + task_name.ext(ext) + when String + ext + when Proc, Method + if ext.arity == 1 + ext.call(task_name) + else + ext.call + end + else + fail "Don't know how to handle rule dependent: #{ext.inspect}" + end + } + result.flatten + end + + + private + + # Return the current description, clearing it in the process. + def get_description(task) + desc = @last_description + @last_description = nil + desc + end + + class << self + attr_accessor :record_task_metadata # :nodoc: + TaskManager.record_task_metadata = false + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/tasklib.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/tasklib.rb new file mode 100644 index 000000000..6203d9402 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/tasklib.rb @@ -0,0 +1,24 @@ +require 'rake' + +module Rake + + # Base class for Task Libraries. + class TaskLib + include Cloneable + include Rake::DSL + + # Make a symbol by pasting two strings together. + # + # NOTE: DEPRECATED! This method is kinda stupid. I don't know why + # I didn't just use string interpolation. But now other task + # libraries depend on this so I can't remove it without breaking + # other people's code. So for now it stays for backwards + # compatibility. BUT DON'T USE IT. + #-- + # TODO: Remove in Rake 11 + def paste(a, b) # :nodoc: + (a.to_s + b.to_s).intern + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/testtask.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/testtask.rb new file mode 100644 index 000000000..2daa58963 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/testtask.rb @@ -0,0 +1,212 @@ +require 'rake' +require 'rake/tasklib' + +module Rake + + # Create a task that runs a set of tests. + # + # Example: + # + # Rake::TestTask.new do |t| + # t.libs << "test" + # t.test_files = FileList['test/test*.rb'] + # t.verbose = true + # end + # + # If rake is invoked with a "TEST=filename" command line option, + # then the list of test files will be overridden to include only the + # filename specified on the command line. This provides an easy way + # to run just one test. + # + # If rake is invoked with a "TESTOPTS=options" command line option, + # then the given options are passed to the test process after a + # '--'. This allows Test::Unit options to be passed to the test + # suite. + # + # Examples: + # + # rake test # run tests normally + # rake test TEST=just_one_file.rb # run just one test file. + # rake test TESTOPTS="-v" # run in verbose mode + # rake test TESTOPTS="--runner=fox" # use the fox test runner + # + class TestTask < TaskLib + + # Name of test task. (default is :test) + attr_accessor :name + + # List of directories to added to $LOAD_PATH before running the + # tests. (default is 'lib') + attr_accessor :libs + + # True if verbose test output desired. (default is false) + attr_accessor :verbose + + # Test options passed to the test suite. An explicit + # TESTOPTS=opts on the command line will override this. (default + # is NONE) + attr_accessor :options + + # Request that the tests be run with the warning flag set. + # E.g. warning=true implies "ruby -w" used to run the tests. + attr_accessor :warning + + # Glob pattern to match test files. (default is 'test/test*.rb') + attr_accessor :pattern + + # Style of test loader to use. Options are: + # + # * :rake -- Rake provided test loading script (default). + # * :testrb -- Ruby provided test loading script. + # * :direct -- Load tests using command line loader. + # + attr_accessor :loader + + # Array of commandline options to pass to ruby when running test loader. + attr_accessor :ruby_opts + + # Description of the test task. (default is 'Run tests') + attr_accessor :description + + # Explicitly define the list of test files to be included in a + # test. +list+ is expected to be an array of file names (a + # FileList is acceptable). If both +pattern+ and +test_files+ are + # used, then the list of test files is the union of the two. + def test_files=(list) + @test_files = list + end + + # Create a testing task. + def initialize(name=:test) + @name = name + @libs = ["lib"] + @pattern = nil + @options = nil + @test_files = nil + @verbose = false + @warning = false + @loader = :rake + @ruby_opts = [] + @description = "Run tests" + (@name == :test ? "" : " for #{@name}") + yield self if block_given? + @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? + define + end + + # Create the tasks defined by this task lib. + def define + desc @description + task @name do + FileUtilsExt.verbose(@verbose) do + args = + "#{ruby_opts_string} #{run_code} " + + "#{file_list_string} #{option_list}" + ruby args do |ok, status| + if !ok && status.respond_to?(:signaled?) && status.signaled? + raise SignalException.new(status.termsig) + elsif !ok + fail "Command failed with status (#{status.exitstatus}): " + + "[ruby #{args}]" + end + end + end + end + self + end + + def option_list # :nodoc: + (ENV['TESTOPTS'] || + ENV['TESTOPT'] || + ENV['TEST_OPTS'] || + ENV['TEST_OPT'] || + @options || + "") + end + + def ruby_opts_string # :nodoc: + opts = @ruby_opts.dup + opts.unshift("-I\"#{lib_path}\"") unless @libs.empty? + opts.unshift("-w") if @warning + opts.join(" ") + end + + def lib_path # :nodoc: + @libs.join(File::PATH_SEPARATOR) + end + + def file_list_string # :nodoc: + file_list.map { |fn| "\"#{fn}\"" }.join(' ') + end + + def file_list # :nodoc: + if ENV['TEST'] + FileList[ENV['TEST']] + else + result = [] + result += @test_files.to_a if @test_files + result << @pattern if @pattern + result + end + end + + def fix # :nodoc: + case ruby_version + when '1.8.2' + "\"#{find_file 'rake/ruby182_test_unit_fix'}\"" + else + nil + end || '' + end + + def ruby_version # :nodoc: + RUBY_VERSION + end + + def run_code # :nodoc: + case @loader + when :direct + "-e \"ARGV.each{|f| require f}\"" + when :testrb + "-S testrb #{fix}" + when :rake + "#{rake_include_arg} \"#{rake_loader}\"" + end + end + + def rake_loader # :nodoc: + find_file('rake/rake_test_loader') or + fail "unable to find rake test loader" + end + + def find_file(fn) # :nodoc: + $LOAD_PATH.each do |path| + file_path = File.join(path, "#{fn}.rb") + return file_path if File.exist? file_path + end + nil + end + + def rake_include_arg # :nodoc: + spec = Gem.loaded_specs['rake'] + if spec.respond_to?(:default_gem?) && spec.default_gem? + "" + else + "-I\"#{rake_lib_dir}\"" + end + end + + def rake_lib_dir # :nodoc: + find_dir('rake') or + fail "unable to find rake lib" + end + + def find_dir(fn) # :nodoc: + $LOAD_PATH.each do |path| + file_path = File.join(path, "#{fn}.rb") + return path if File.exist? file_path + end + nil + end + + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_history_display.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_history_display.rb new file mode 100644 index 000000000..c2af9ecef --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_history_display.rb @@ -0,0 +1,48 @@ +require 'rake/private_reader' + +module Rake + + class ThreadHistoryDisplay # :nodoc: all + include Rake::PrivateReader + + private_reader :stats, :items, :threads + + def initialize(stats) + @stats = stats + @items = { :_seq_ => 1 } + @threads = { :_seq_ => "A" } + end + + def show + puts "Job History:" + stats.each do |stat| + stat[:data] ||= {} + rename(stat, :thread, threads) + rename(stat[:data], :item_id, items) + rename(stat[:data], :new_thread, threads) + rename(stat[:data], :deleted_thread, threads) + printf("%8d %2s %-20s %s\n", + (stat[:time] * 1_000_000).round, + stat[:thread], + stat[:event], + stat[:data].map do |k, v| "#{k}:#{v}" end.join(" ")) + end + end + + private + + def rename(hash, key, renames) + if hash && hash[key] + original = hash[key] + value = renames[original] + unless value + value = renames[:_seq_] + renames[:_seq_] = renames[:_seq_].succ + renames[original] = value + end + hash[key] = value + end + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_pool.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_pool.rb new file mode 100644 index 000000000..d2ac6e7ac --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/thread_pool.rb @@ -0,0 +1,164 @@ +require 'thread' +require 'set' + +require 'rake/promise' + +module Rake + + class ThreadPool # :nodoc: all + + # Creates a ThreadPool object. The +thread_count+ parameter is the size + # of the pool. + def initialize(thread_count) + @max_active_threads = [thread_count, 0].max + @threads = Set.new + @threads_mon = Monitor.new + @queue = Queue.new + @join_cond = @threads_mon.new_cond + + @history_start_time = nil + @history = [] + @history_mon = Monitor.new + @total_threads_in_play = 0 + end + + # Creates a future executed by the +ThreadPool+. + # + # The args are passed to the block when executing (similarly to + # Thread#new) The return value is an object representing + # a future which has been created and added to the queue in the + # pool. Sending #value to the object will sleep the + # current thread until the future is finished and will return the + # result (or raise an exception thrown from the future) + def future(*args, &block) + promise = Promise.new(args, &block) + promise.recorder = lambda { |*stats| stat(*stats) } + + @queue.enq promise + stat :queued, :item_id => promise.object_id + start_thread + promise + end + + # Waits until the queue of futures is empty and all threads have exited. + def join + @threads_mon.synchronize do + begin + stat :joining + @join_cond.wait unless @threads.empty? + stat :joined + rescue Exception => e + stat :joined + $stderr.puts e + $stderr.print "Queue contains #{@queue.size} items. " + + "Thread pool contains #{@threads.count} threads\n" + $stderr.print "Current Thread #{Thread.current} status = " + + "#{Thread.current.status}\n" + $stderr.puts e.backtrace.join("\n") + @threads.each do |t| + $stderr.print "Thread #{t} status = #{t.status}\n" + # 1.8 doesn't support Thread#backtrace + $stderr.puts t.backtrace.join("\n") if t.respond_to? :backtrace + end + raise e + end + end + end + + # Enable the gathering of history events. + def gather_history #:nodoc: + @history_start_time = Time.now if @history_start_time.nil? + end + + # Return a array of history events for the thread pool. + # + # History gathering must be enabled to be able to see the events + # (see #gather_history). Best to call this when the job is + # complete (i.e. after ThreadPool#join is called). + def history # :nodoc: + @history_mon.synchronize { @history.dup }. + sort_by { |i| i[:time] }. + each { |i| i[:time] -= @history_start_time } + end + + # Return a hash of always collected statistics for the thread pool. + def statistics # :nodoc: + { + :total_threads_in_play => @total_threads_in_play, + :max_active_threads => @max_active_threads, + } + end + + private + + # processes one item on the queue. Returns true if there was an + # item to process, false if there was no item + def process_queue_item #:nodoc: + return false if @queue.empty? + + # Even though we just asked if the queue was empty, it + # still could have had an item which by this statement + # is now gone. For this reason we pass true to Queue#deq + # because we will sleep indefinitely if it is empty. + promise = @queue.deq(true) + stat :dequeued, :item_id => promise.object_id + promise.work + return true + + rescue ThreadError # this means the queue is empty + false + end + + def safe_thread_count + @threads_mon.synchronize do + @threads.count + end + end + + def start_thread # :nodoc: + @threads_mon.synchronize do + next unless @threads.count < @max_active_threads + + t = Thread.new do + begin + while safe_thread_count <= @max_active_threads + break unless process_queue_item + end + ensure + @threads_mon.synchronize do + @threads.delete Thread.current + stat :ended, :thread_count => @threads.count + @join_cond.broadcast if @threads.empty? + end + end + end + + @threads << t + stat( + :spawned, + :new_thread => t.object_id, + :thread_count => @threads.count) + @total_threads_in_play = @threads.count if + @threads.count > @total_threads_in_play + end + end + + def stat(event, data=nil) # :nodoc: + return if @history_start_time.nil? + info = { + :event => event, + :data => data, + :time => Time.now, + :thread => Thread.current.object_id, + } + @history_mon.synchronize { @history << info } + end + + # for testing only + + def __queue__ # :nodoc: + @queue + end + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/trace_output.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/trace_output.rb new file mode 100644 index 000000000..396096d4d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/trace_output.rb @@ -0,0 +1,22 @@ +module Rake + module TraceOutput # :nodoc: all + + # Write trace output to output stream +out+. + # + # The write is done as a single IO call (to print) to lessen the + # chance that the trace output is interrupted by other tasks also + # producing output. + def trace_on(out, *strings) + sep = $\ || "\n" + if strings.empty? + output = sep + else + output = strings.map { |s| + next if s.nil? + s =~ /#{sep}$/ ? s : s + sep + }.join + end + out.print(output) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/version.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/version.rb new file mode 100644 index 000000000..b9b1b2d48 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/version.rb @@ -0,0 +1,7 @@ +module Rake + module Version # :nodoc: all + MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split '.' + + NUMBERS = [MAJOR, MINOR, BUILD, *OTHER] + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/win32.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/win32.rb new file mode 100644 index 000000000..6b4873da2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/lib/rake/win32.rb @@ -0,0 +1,56 @@ + +module Rake + require 'rake/alt_system' + + # Win 32 interface methods for Rake. Windows specific functionality + # will be placed here to collect that knowledge in one spot. + module Win32 # :nodoc: all + + # Error indicating a problem in locating the home directory on a + # Win32 system. + class Win32HomeError < RuntimeError + end + + class << self + # True if running on a windows system. + def windows? + AltSystem::WINDOWS + end + + # Run a command line on windows. + def rake_system(*cmd) + AltSystem.system(*cmd) + end + + # The standard directory containing system wide rake files on + # Win 32 systems. Try the following environment variables (in + # order): + # + # * HOME + # * HOMEDRIVE + HOMEPATH + # * APPDATA + # * USERPROFILE + # + # If the above are not defined, the return nil. + def win32_system_dir #:nodoc: + win32_shared_path = ENV['HOME'] + if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH'] + win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH'] + end + + win32_shared_path ||= ENV['APPDATA'] + win32_shared_path ||= ENV['USERPROFILE'] + raise Win32HomeError, + "Unable to determine home path environment variable." if + win32_shared_path.nil? or win32_shared_path.empty? + normalize(File.join(win32_shared_path, 'Rake')) + end + + # Normalize a win32 path so that the slashes are all forward slashes. + def normalize(path) + path.gsub(/\\/, '/') + end + + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/publish.rake b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/publish.rake new file mode 100644 index 000000000..40474abab --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/publish.rake @@ -0,0 +1,20 @@ +# Optional publish task for Rake + +begin + require 'rake/contrib/sshpublisher' + require 'rake/contrib/rubyforgepublisher' + + publisher = Rake::SshDirPublisher.new( + 'linode', + 'htdocs/software/rake', + 'html') + + desc "Publish the Documentation to RubyForge." + task :publish => [:rdoc] do + publisher.upload + end + +rescue LoadError => ex + puts "#{ex.message} (#{ex.class})" + puts "No Publisher Task Available" +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/test_times.rake b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/test_times.rake new file mode 100644 index 000000000..daf1bc6e9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/rakelib/test_times.rake @@ -0,0 +1,25 @@ +module TestTimes + def self.run(test_results, limit=0) + limit = limit.nonzero? || 10 + tests = [] + test_results.split(/\n/).each do |line| + if line =~ /^(.+?#[^:]+): ([0-9.]+) s: \.$/ + tests << [$1, $2.to_f, line] + end + end + + puts "#{limit} Slowest tests" + puts tests.sort_by { |item| + item[1] + }.reverse[0...limit].map { |item| + "%6.3f: %-s\n" % [item[1], item[0]] + } + end +end + +namespace :test do + desc "Find the slowest unit tests" + task :times, [:limit] do |t, args| + TestTimes.run `rake test:units TESTOPTS='--verbose'`, args.limit.to_i + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/file_creation.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/file_creation.rb new file mode 100644 index 000000000..facc57a03 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/file_creation.rb @@ -0,0 +1,34 @@ +module FileCreation + OLDFILE = "old" + NEWFILE = "new" + + def create_timed_files(oldfile, *newfiles) + return if (File.exist?(oldfile) && + newfiles.all? { |newfile| + File.exist?(newfile) && File.stat(newfile).mtime > File.stat(oldfile).mtime + }) + now = Time.now + + create_file(oldfile, now - 60) + + newfiles.each do |newfile| + create_file(newfile, now) + end + end + + def create_dir(dirname) + FileUtils.mkdir_p(dirname) unless File.exist?(dirname) + File.stat(dirname).mtime + end + + def create_file(name, file_time=nil) + create_dir(File.dirname(name)) + FileUtils.touch(name) unless File.exist?(name) + File.utime(file_time, file_time, name) unless file_time.nil? + File.stat(name).mtime + end + + def delete_file(name) + File.delete(name) rescue nil + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/helper.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/helper.rb new file mode 100644 index 000000000..2ff599e61 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/helper.rb @@ -0,0 +1,130 @@ +require 'rubygems' +$:.unshift File.expand_path('../../lib', __FILE__) + +begin + gem 'minitest', '~> 5' +rescue Gem::LoadError +end + +require 'minitest/autorun' +require 'rake' +require 'tmpdir' +require File.expand_path('../file_creation', __FILE__) + + +begin + require_relative '../ruby/envutil' + require_relative 'support/ruby_runner' + require_relative 'support/rakefile_definitions' +rescue NoMethodError, LoadError + # ruby 1.8 + require 'test/support/ruby_runner' + require 'test/support/rakefile_definitions' +end + +class Rake::TestCase < Minitest::Test + include FileCreation + + include Rake::DSL + + class TaskManager + include Rake::TaskManager + end + + RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby + + def setup + ARGV.clear + + test_dir = File.basename File.dirname File.expand_path __FILE__ + + @rake_root = + if test_dir == 'test' + # rake repository + File.expand_path '../../', __FILE__ + else + # ruby repository + File.expand_path '../../../', __FILE__ + end + + @verbose = ENV['VERBOSE'] + + @rake_exec = File.join @rake_root, 'bin', 'rake' + @rake_lib = File.join @rake_root, 'lib' + @ruby_options = ["-I#{@rake_lib}", "-I."] + + @orig_pwd = Dir.pwd + @orig_appdata = ENV['APPDATA'] + @orig_home = ENV['HOME'] + @orig_homedrive = ENV['HOMEDRIVE'] + @orig_homepath = ENV['HOMEPATH'] + @orig_rake_columns = ENV['RAKE_COLUMNS'] + @orig_rake_system = ENV['RAKE_SYSTEM'] + @orig_rakeopt = ENV['RAKEOPT'] + @orig_userprofile = ENV['USERPROFILE'] + ENV.delete 'RAKE_COLUMNS' + ENV.delete 'RAKE_SYSTEM' + ENV.delete 'RAKEOPT' + + tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end + @tempdir = File.join tmpdir, "test_rake_#{$$}" + + FileUtils.mkdir_p @tempdir + + Dir.chdir @tempdir + + Rake.application = Rake::Application.new + Rake::TaskManager.record_task_metadata = true + RakeFileUtils.verbose_flag = false + end + + def teardown + Dir.chdir @orig_pwd + FileUtils.rm_rf @tempdir + + if @orig_appdata + ENV['APPDATA'] = @orig_appdata + else + ENV.delete 'APPDATA' + end + + ENV['HOME'] = @orig_home + ENV['HOMEDRIVE'] = @orig_homedrive + ENV['HOMEPATH'] = @orig_homepath + ENV['RAKE_COLUMNS'] = @orig_rake_columns + ENV['RAKE_SYSTEM'] = @orig_rake_system + ENV['RAKEOPT'] = @orig_rakeopt + ENV['USERPROFILE'] = @orig_userprofile + end + + def ignore_deprecations + Rake.application.options.ignore_deprecate = true + yield + ensure + Rake.application.options.ignore_deprecate = false + end + + def rake_system_dir + @system_dir = 'system' + + FileUtils.mkdir_p @system_dir + + open File.join(@system_dir, 'sys1.rake'), 'w' do |io| + io << <<-SYS +task "sys1" do + puts "SYS1" +end + SYS + end + + ENV['RAKE_SYSTEM'] = @system_dir + end + + def rakefile(contents) + open 'Rakefile', 'w' do |io| + io << contents + end + end + + include RakefileDefinitions +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/rakefile_definitions.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/rakefile_definitions.rb new file mode 100644 index 000000000..a637c7e94 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/rakefile_definitions.rb @@ -0,0 +1,478 @@ +module RakefileDefinitions + include FileUtils + + def rakefile_access + rakefile <<-ACCESS +TOP_LEVEL_CONSTANT = 0 + +def a_top_level_function +end + +task :default => [:work, :obj, :const] + +task :work do + begin + a_top_level_function + puts "GOOD:M Top level methods can be called in tasks" + rescue NameError => ex + puts "BAD:M Top level methods can not be called in tasks" + end +end + +# TODO: remove `disabled_' when DeprecatedObjectDSL removed +task :obj +task :disabled_obj do + begin + Object.new.instance_eval { task :xyzzy } + puts "BAD:D Rake DSL are polluting objects" + rescue StandardError => ex + puts "GOOD:D Rake DSL are not polluting objects" + end +end + +task :const do + begin + TOP_LEVEL_CONSTANT + puts "GOOD:C Top level constants are available in tasks" + rescue StandardError => ex + puts "BAD:C Top level constants are NOT available in tasks" + end +end + ACCESS + end + + def rakefile_test_task + rakefile <<-RAKEFILE + require "rake/testtask" + + Rake::TestTask.new(:unit) do |t| + t.description = "custom test task description" + end + RAKEFILE + end + + def rakefile_chains + rakefile <<-DEFAULT +task :default => "play.app" + +file "play.scpt" => "base" do |t| + cp t.prerequisites.first, t.name +end + +rule ".app" => ".scpt" do |t| + cp t.source, t.name +end + +file 'base' do + touch 'base' +end + DEFAULT + end + + def rakefile_comments + rakefile <<-COMMENTS +# comment for t1 +task :t1 do +end + +# no comment or task because there's a blank line + +task :t2 do +end + +desc "override comment for t3" +# this is not the description +multitask :t3 do +end + +# this is not the description +desc "override comment for t4" +file :t4 do +end + COMMENTS + end + + def rakefile_default + rakefile <<-DEFAULT +if ENV['TESTTOPSCOPE'] + puts "TOPSCOPE" +end + +task :default do + puts "DEFAULT" +end + +task :other => [:default] do + puts "OTHER" +end + +task :task_scope do + if ENV['TESTTASKSCOPE'] + puts "TASKSCOPE" + end +end + DEFAULT + end + + def rakefile_dryrun + rakefile <<-DRYRUN +task :default => ["temp_main"] + +file "temp_main" => [:all_apps] do touch "temp_main" end + +task :all_apps => [:one, :two] +task :one => ["temp_one"] +task :two => ["temp_two"] + +file "temp_one" do |t| + touch "temp_one" +end +file "temp_two" do |t| + touch "temp_two" +end + +task :clean do + ["temp_one", "temp_two", "temp_main"].each do |file| + rm_f file + end +end + DRYRUN + + FileUtils.touch 'temp_main' + FileUtils.touch 'temp_two' + end + + def rakefile_extra + rakefile 'task :default' + + FileUtils.mkdir_p 'rakelib' + + open File.join('rakelib', 'extra.rake'), 'w' do |io| + io << <<-EXTRA_RAKE +# Added for testing + +namespace :extra do + desc "An Extra Task" + task :extra do + puts "Read all about it" + end +end + EXTRA_RAKE + end + end + + def rakefile_file_creation + rakefile <<-'FILE_CREATION' +N = 2 + +task :default => :run + +BUILD_DIR = 'build' +task :clean do + rm_rf 'build' + rm_rf 'src' +end + +task :run + +TARGET_DIR = 'build/copies' + +FileList['src/*'].each do |src| + directory TARGET_DIR + target = File.join TARGET_DIR, File.basename(src) + file target => [src, TARGET_DIR] do + cp src, target + end + task :run => target +end + +task :prep => :clean do + mkdir_p 'src' + N.times do |n| + touch "src/foo#{n}" + end +end + FILE_CREATION + end + + def rakefile_imports + rakefile <<-IMPORTS +require 'rake/loaders/makefile' + +task :default + +task :other do + puts "OTHER" +end + +file "dynamic_deps" do |t| + open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end +end + +import "dynamic_deps" +import "static_deps" +import "static_deps" +import "deps.mf" +puts "FIRST" + IMPORTS + + open 'deps.mf', 'w' do |io| + io << <<-DEPS +default: other + DEPS + end + + open "static_deps", "w" do |f| + f.puts 'puts "STATIC"' + end + end + + def rakefile_regenerate_imports + rakefile <<-REGENERATE_IMPORTS +task :default + +task :regenerate do + open("deps", "w") do |f| + f << <<-CONTENT +file "deps" => :regenerate +puts "REGENERATED" + CONTENT + end +end + +import "deps" + REGENERATE_IMPORTS + + open "deps", "w" do |f| + f << <<-CONTENT +file "deps" => :regenerate +puts "INITIAL" + CONTENT + end + end + + def rakefile_multidesc + rakefile <<-MULTIDESC +task :b + +desc "A" +task :a + +desc "B" +task :b + +desc "A2" +task :a + +task :c + +desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +task :d + MULTIDESC + end + + def rakefile_namespace + rakefile <<-NAMESPACE +desc "copy" +task :copy do + puts "COPY" +end + +namespace "nest" do + desc "nest copy" + task :copy do + puts "NEST COPY" + end + task :xx => :copy +end + +anon_ns = namespace do + desc "anonymous copy task" + task :copy do + puts "ANON COPY" + end +end + +desc "Top level task to run the anonymous version of copy" +task :anon => anon_ns[:copy] + +namespace "very" do + namespace "nested" do + task "run" => "rake:copy" + end +end + +namespace "a" do + desc "Run task in the 'a' namespace" + task "run" do + puts "IN A" + end +end + +namespace "b" do + desc "Run task in the 'b' namespace" + task "run" => "a:run" do + puts "IN B" + end +end + +namespace "file1" do + file "xyz.rb" do + puts "XYZ1" + end +end + +namespace "file2" do + file "xyz.rb" do + puts "XYZ2" + end +end + +namespace "scopedep" do + task :prepare do + touch "scopedep.rb" + puts "PREPARE" + end + file "scopedep.rb" => [:prepare] do + puts "SCOPEDEP" + end +end + NAMESPACE + end + + def rakefile_nosearch + FileUtils.touch 'dummy' + end + + def rakefile_rakelib + FileUtils.mkdir_p 'rakelib' + + Dir.chdir 'rakelib' do + open 'test1.rb', 'w' do |io| + io << <<-TEST1 +task :default do + puts "TEST1" +end + TEST1 + end + + open 'test2.rake', 'w' do |io| + io << <<-TEST1 +task :default do + puts "TEST2" +end + TEST1 + end + end + end + + def rakefile_rbext + open 'rakefile.rb', 'w' do |io| + io << 'task :default do puts "OK" end' + end + end + + def rakefile_unittest + rakefile '# Empty Rakefile for Unit Test' + + readme = File.join 'subdir', 'README' + FileUtils.mkdir_p File.dirname readme + + FileUtils.touch readme + end + + def rakefile_verbose + rakefile <<-VERBOSE +task :standalone_verbose_true do + verbose true + sh "#{RUBY} -e '0'" +end + +task :standalone_verbose_false do + verbose false + sh "#{RUBY} -e '0'" +end + +task :inline_verbose_default do + sh "#{RUBY} -e '0'" +end + +task :inline_verbose_false do + sh "#{RUBY} -e '0'", :verbose => false +end + +task :inline_verbose_true do + sh "#{RUBY} -e '0'", :verbose => true +end + +task :block_verbose_true do + verbose(true) do + sh "#{RUBY} -e '0'" + end +end + +task :block_verbose_false do + verbose(false) do + sh "#{RUBY} -e '0'" + end +end + VERBOSE + end + + def rakefile_test_signal + rakefile <<-TEST_SIGNAL +require 'rake/testtask' + +Rake::TestTask.new(:a) do |t| + t.test_files = ['a_test.rb'] +end + +Rake::TestTask.new(:b) do |t| + t.test_files = ['b_test.rb'] +end + +task :test do + Rake::Task[:a].invoke + Rake::Task[:b].invoke +end + +task :default => :test + TEST_SIGNAL + open 'a_test.rb', 'w' do |io| + io << 'puts "ATEST"' << "\n" + io << '$stdout.flush' << "\n" + io << 'Process.kill("TERM", $$)' << "\n" + end + open 'b_test.rb', 'w' do |io| + io << 'puts "BTEST"' << "\n" + io << '$stdout.flush' << "\n" + end + end + + def rakefile_failing_test_task + rakefile <<-TEST_TASK +require 'rake/testtask' + +task :default => :test +Rake::TestTask.new(:test) do |t| + t.test_files = ['a_test.rb'] +end + TEST_TASK + open 'a_test.rb', 'w' do |io| + io << "require 'minitest/autorun'\n" + io << "class ExitTaskTest < Minitest::Test\n" + io << " def test_exit\n" + io << " assert false, 'this should fail'\n" + io << " end\n" + io << "end\n" + end + end + + def rakefile_stand_alone_filelist + open 'stand_alone_filelist.rb', 'w' do |io| + io << "require 'rake/file_list'\n" + io << "FL = Rake::FileList['*.rb']\n" + io << "puts FL\n" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/ruby_runner.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/ruby_runner.rb new file mode 100644 index 000000000..d51dd24b8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/support/ruby_runner.rb @@ -0,0 +1,34 @@ +module RubyRunner + include FileUtils + + # Run a shell Ruby command with command line options (using the + # default test options). Output is captured in @out and @err + def ruby(*option_list) + run_ruby(@ruby_options + option_list) + end + + # Run a command line rake with the give rake options. Default + # command line ruby options are included. Output is captured in + # @out and @err + def rake(*rake_options) + run_ruby @ruby_options + [@rake_exec] + rake_options + end + + # Low level ruby command runner ... + def run_ruby(option_list) + puts "COMMAND: [#{RUBY} #{option_list.join ' '}]" if @verbose + + Open3.popen3(RUBY, *option_list) {|inn, out, err, wait| + inn.close + + @exit = wait ? wait.value : $? + @out = out.read + @err = err.read + } + + puts "OUTPUT: [#{@out}]" if @verbose + puts "ERROR: [#{@err}]" if @verbose + puts "EXIT: [#{@exit.inspect}]" if @verbose + puts "PWD: [#{Dir.pwd}]" if @verbose + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_private_reader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_private_reader.rb new file mode 100644 index 000000000..f86d4249b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_private_reader.rb @@ -0,0 +1,42 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/private_reader' + +class TestPrivateAttrs < Rake::TestCase + + class Sample + include Rake::PrivateReader + + private_reader :reader, :a + + def initialize + @reader = :RVALUE + end + + def get_reader + reader + end + + end + + def setup + super + @sample = Sample.new + end + + def test_private_reader_is_private + assert_private do @sample.reader end + assert_private do @sample.a end + end + + def test_private_reader_returns_data + assert_equal :RVALUE, @sample.get_reader + end + + private + + def assert_private + ex = assert_raises(NoMethodError) do yield end + assert_match(/private/, ex.message) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake.rb new file mode 100644 index 000000000..b2a3928b2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake.rb @@ -0,0 +1,40 @@ +require File.expand_path('../helper', __FILE__) + +class TestRake < Rake::TestCase + def test_each_dir_parent + assert_equal ['a'], alldirs('a') + assert_equal ['a/b', 'a'], alldirs('a/b') + assert_equal ['/a/b', '/a', '/'], alldirs('/a/b') + if File.dirname("c:/foo") == "c:" + # Under Unix + assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b') + assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b') + else + # Under Windows + assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b') + assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b') + end + end + + def alldirs(fn) + result = [] + Rake.each_dir_parent(fn) { |d| result << d } + result + end + + def test_can_override_application + old_app = Rake.application + fake_app = Object.new + Rake.application = fake_app + + assert_equal fake_app, Rake.application + + ensure + Rake.application = old_app + end + + def test_original_dir_reports_current_dir + assert_equal @tempdir, Rake.original_dir + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application.rb new file mode 100644 index 000000000..c01088917 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application.rb @@ -0,0 +1,643 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeApplication < Rake::TestCase + + def setup + super + + @app = Rake.application + @app.options.rakelib = [] + end + + def setup_command_line(*options) + ARGV.clear + options.each do |option| + ARGV << option + end + end + + def test_display_exception_details + obj = Object.new + obj.instance_eval("def #{__method__}; raise 'test'; end", "ruby") + begin + obj.__send__(__method__) + rescue => ex + end + + out, err = capture_io do + @app.display_error_message ex + end + + assert_empty out + + assert_match 'rake aborted!', err + assert_match __method__.to_s, err + end + + def test_display_exception_details_cause + skip 'Exception#cause not implemented' unless + Exception.method_defined? :cause + + begin + raise 'cause a' + rescue + begin + raise 'cause b' + rescue => ex + end + end + + out, err = capture_io do + @app.display_error_message ex + end + + assert_empty out + + assert_match 'cause a', err + assert_match 'cause b', err + end + + def test_display_exception_details_cause_loop + skip 'Exception#cause not implemented' unless + Exception.method_defined? :cause + + begin + begin + raise 'cause a' + rescue => a + begin + raise 'cause b' + rescue + raise a + end + end + rescue => ex + end + + out, err = capture_io do + @app.display_error_message ex + end + + assert_empty out + + assert_match 'cause a', err + assert_match 'cause b', err + end + + def test_display_tasks + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + @app.last_description = "COMMENT" + @app.define_task(Rake::Task, "t") + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + assert_match(/^rake t/, out) + assert_match(/# COMMENT/, out) + end + + def test_display_tasks_with_long_comments + @app.terminal_columns = 80 + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + numbers = "1234567890" * 8 + @app.last_description = numbers + @app.define_task(Rake::Task, "t") + + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + + assert_match(/^rake t/, out) + assert_match(/# #{numbers[0, 65]}\.\.\./, out) + end + + def test_display_tasks_with_task_name_wider_than_tty_display + @app.terminal_columns = 80 + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + task_name = "task name" * 80 + @app.last_description = "something short" + @app.define_task(Rake::Task, task_name) + + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + + # Ensure the entire task name is output and we end up showing no description + assert_match(/rake #{task_name} # .../, out) + end + + def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + @app.tty_output = false + description = "something short" + task_name = "task name" * 80 + @app.last_description = "something short" + @app.define_task(Rake::Task, task_name) + + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + + # Ensure the entire task name is output and we end up showing no description + assert_match(/rake #{task_name} # #{description}/, out) + end + + def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + @app.tty_output = false + @app.last_description = "1234567890" * 8 + @app.define_task(Rake::Task, "t") + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + assert_match(/^rake t/, out) + assert_match(/# #{@app.last_description}/, out) + end + + def test_truncating_comments_to_a_non_tty + @app.terminal_columns = 80 + @app.options.show_tasks = :tasks + @app.options.show_task_pattern = // + @app.tty_output = false + numbers = "1234567890" * 8 + @app.last_description = numbers + @app.define_task(Rake::Task, "t") + + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + + assert_match(/^rake t/, out) + assert_match(/# #{numbers[0, 65]}\.\.\./, out) + end + + def test_describe_tasks + @app.options.show_tasks = :describe + @app.options.show_task_pattern = // + @app.last_description = "COMMENT" + @app.define_task(Rake::Task, "t") + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + assert_match(/^rake t$/, out) + assert_match(/^ {4}COMMENT$/, out) + end + + def test_show_lines + @app.options.show_tasks = :lines + @app.options.show_task_pattern = // + @app.last_description = "COMMENT" + @app.define_task(Rake::Task, "t") + @app['t'].locations << "HERE:1" + out, = capture_io do @app.instance_eval { display_tasks_and_comments } end + assert_match(/^rake t +[^:]+:\d+ *$/, out) + end + + def test_finding_rakefile + rakefile_default + + assert_match(/Rakefile/i, @app.instance_eval { have_rakefile }) + end + + def test_not_finding_rakefile + @app.instance_eval { @rakefiles = ['NEVER_FOUND'] } + assert(! @app.instance_eval do have_rakefile end) + assert_nil @app.rakefile + end + + def test_load_rakefile + rakefile_unittest + + @app.instance_eval do + handle_options + options.silent = true + load_rakefile + end + + assert_equal "rakefile", @app.rakefile.downcase + assert_equal @tempdir, Dir.pwd + end + + def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir + rakefile_unittest + + _, err = capture_io do + @app.instance_eval do + # pretend we started from the unittest dir + @original_dir = File.expand_path(".") + raw_load_rakefile + end + end + + assert_empty err + end + + def test_load_rakefile_from_subdir + rakefile_unittest + Dir.chdir 'subdir' + + @app.instance_eval do + handle_options + options.silent = true + load_rakefile + end + + assert_equal "rakefile", @app.rakefile.downcase + assert_equal @tempdir, Dir.pwd + end + + def test_load_rakefile_prints_rakefile_directory_from_subdir + rakefile_unittest + Dir.chdir 'subdir' + + app = Rake::Application.new + app.options.rakelib = [] + + _, err = capture_io do + app.instance_eval do + raw_load_rakefile + end + end + + assert_equal "(in #{@tempdir}\)\n", err + end + + def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent + rakefile_unittest + Dir.chdir 'subdir' + + _, err = capture_io do + @app.instance_eval do + handle_options + options.silent = true + raw_load_rakefile + end + end + + assert_empty err + end + + def test_load_rakefile_not_found + ARGV.clear + Dir.chdir @tempdir + ENV['RAKE_SYSTEM'] = 'not_exist' + + @app.instance_eval do + handle_options + options.silent = true + end + + + ex = assert_raises(RuntimeError) do + @app.instance_eval do + raw_load_rakefile + end + end + + assert_match(/no rakefile found/i, ex.message) + end + + def test_load_from_system_rakefile + rake_system_dir + + @app.instance_eval do + handle_options + options.silent = true + options.load_system = true + options.rakelib = [] + load_rakefile + end + + assert_equal @system_dir, @app.system_dir + assert_nil @app.rakefile + rescue SystemExit + flunk 'failed to load rakefile' + end + + def test_load_from_calculated_system_rakefile + rakefile_default + def @app.standard_system_dir + "__STD_SYS_DIR__" + end + + ENV['RAKE_SYSTEM'] = nil + + @app.instance_eval do + handle_options + options.silent = true + options.load_system = true + options.rakelib = [] + load_rakefile + end + + assert_equal "__STD_SYS_DIR__", @app.system_dir + rescue SystemExit + flunk 'failed to find system rakefile' + end + + def test_terminal_columns + old_rake_columns = ENV['RAKE_COLUMNS'] + + ENV['RAKE_COLUMNS'] = '42' + + app = Rake::Application.new + + assert_equal 42, app.terminal_columns + ensure + if old_rake_columns + ENV['RAKE_COLUMNS'].delete + else + ENV['RAKE_COLUMNS'] = old_rake_columns + end + end + + def test_windows + assert ! (@app.windows? && @app.unix?) + end + + def test_loading_imports + loader = util_loader + + @app.instance_eval do + add_loader("dummy", loader) + add_import("x.dummy") + load_imports + end + + # HACK no assertions + end + + def test_building_imported_files_on_demand + loader = util_loader + + @app.instance_eval do + intern(Rake::Task, "x.dummy").enhance do loader.make_dummy end + add_loader("dummy", loader) + add_import("x.dummy") + load_imports + end + + # HACK no assertions + end + + def test_handle_options_should_not_strip_options_from_argv + assert !@app.options.trace + + valid_option = '--trace' + setup_command_line(valid_option) + + @app.handle_options + + assert ARGV.include?(valid_option) + assert @app.options.trace + end + + def test_handle_options_trace_default_is_stderr + setup_command_line("--trace") + + @app.handle_options + + assert_equal STDERR, @app.options.trace_output + assert @app.options.trace + end + + def test_handle_options_trace_overrides_to_stdout + setup_command_line("--trace=stdout") + + @app.handle_options + + assert_equal STDOUT, @app.options.trace_output + assert @app.options.trace + end + + def test_handle_options_trace_does_not_eat_following_task_names + assert !@app.options.trace + + setup_command_line("--trace", "sometask") + + @app.handle_options + assert ARGV.include?("sometask") + assert @app.options.trace + end + + def test_good_run + ran = false + + ARGV << '--rakelib=""' + + @app.options.silent = true + + @app.instance_eval do + intern(Rake::Task, "default").enhance { ran = true } + end + + rakefile_default + + out, err = capture_io do + @app.run + end + + assert ran + assert_empty err + assert_equal "DEFAULT\n", out + end + + def test_display_task_run + ran = false + setup_command_line('-f', '-s', '--tasks', '--rakelib=""') + @app.last_description = "COMMENT" + @app.define_task(Rake::Task, "default") + out, = capture_io { @app.run } + assert @app.options.show_tasks + assert ! ran + assert_match(/rake default/, out) + assert_match(/# COMMENT/, out) + end + + def test_display_prereqs + ran = false + setup_command_line('-f', '-s', '--prereqs', '--rakelib=""') + @app.last_description = "COMMENT" + t = @app.define_task(Rake::Task, "default") + t.enhance([:a, :b]) + @app.define_task(Rake::Task, "a") + @app.define_task(Rake::Task, "b") + out, = capture_io { @app.run } + assert @app.options.show_prereqs + assert ! ran + assert_match(/rake a$/, out) + assert_match(/rake b$/, out) + assert_match(/rake default\n( *(a|b)\n){2}/m, out) + end + + def test_bad_run + @app.intern(Rake::Task, "default").enhance { fail } + setup_command_line('-f', '-s', '--rakelib=""') + _, err = capture_io { + assert_raises(SystemExit){ @app.run } + } + assert_match(/see full trace/i, err) + ensure + ARGV.clear + end + + def test_bad_run_with_trace + @app.intern(Rake::Task, "default").enhance { fail } + setup_command_line('-f', '-s', '-t') + _, err = capture_io { + assert_raises(SystemExit) { @app.run } + } + refute_match(/see full trace/i, err) + ensure + ARGV.clear + end + + def test_bad_run_with_backtrace + @app.intern(Rake::Task, "default").enhance { fail } + setup_command_line('-f', '-s', '--backtrace') + _, err = capture_io { + assert_raises(SystemExit) { + @app.run + } + } + refute_match(/see full trace/, err) + ensure + ARGV.clear + end + + CustomError = Class.new(RuntimeError) + + def test_bad_run_includes_exception_name + @app.intern(Rake::Task, "default").enhance { + raise CustomError, "intentional" + } + setup_command_line('-f', '-s') + _, err = capture_io { + assert_raises(SystemExit) { + @app.run + } + } + assert_match(/CustomError: intentional/, err) + end + + def test_rake_error_excludes_exception_name + @app.intern(Rake::Task, "default").enhance { + fail "intentional" + } + setup_command_line('-f', '-s') + _, err = capture_io { + assert_raises(SystemExit) { + @app.run + } + } + refute_match(/RuntimeError/, err) + assert_match(/intentional/, err) + end + + def cause_supported? + ex = StandardError.new + ex.respond_to?(:cause) + end + + def test_printing_original_exception_cause + custom_error = Class.new(StandardError) + @app.intern(Rake::Task, "default").enhance { + begin + raise custom_error, "Original Error" + rescue custom_error + raise custom_error, "Secondary Error" + end + } + setup_command_line('-f', '-s') + _ ,err = capture_io { + assert_raises(SystemExit) { + @app.run + } + } + if cause_supported? + assert_match(/Original Error/, err) + end + assert_match(/Secondary Error/, err) + ensure + ARGV.clear + end + + def test_run_with_bad_options + @app.intern(Rake::Task, "default").enhance { fail } + setup_command_line('-f', '-s', '--xyzzy') + assert_raises(SystemExit) { + capture_io { @app.run } + } + ensure + ARGV.clear + end + + def test_standard_exception_handling_invalid_option + out, err = capture_io do + e = assert_raises SystemExit do + @app.standard_exception_handling do + raise OptionParser::InvalidOption, 'blah' + end + end + + assert_equal 1, e.status + end + + assert_empty out + assert_equal "invalid option: blah\n", err + end + + def test_standard_exception_handling_other + out, err = capture_io do + e = assert_raises SystemExit do + @app.standard_exception_handling do + raise 'blah' + end + end + + assert_equal 1, e.status + end + + assert_empty out + assert_match "rake aborted!\n", err + assert_match "blah\n", err + end + + def test_standard_exception_handling_system_exit + out, err = capture_io do + e = assert_raises SystemExit do + @app.standard_exception_handling do + exit 0 + end + end + + assert_equal 0, e.status + end + + assert_empty out + assert_empty err + end + + def test_standard_exception_handling_system_exit_nonzero + out, err = capture_io do + e = assert_raises SystemExit do + @app.standard_exception_handling do + exit 5 + end + end + + assert_equal 5, e.status + end + + assert_empty out + assert_empty err + end + + def util_loader + loader = Object.new + + loader.instance_variable_set :@load_called, false + def loader.load arg + raise ArgumentError, arg unless arg == 'x.dummy' + @load_called = true + end + + loader.instance_variable_set :@make_dummy_called, false + def loader.make_dummy + @make_dummy_called = true + end + + loader + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application_options.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application_options.rb new file mode 100644 index 000000000..37adfacd7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_application_options.rb @@ -0,0 +1,466 @@ +require File.expand_path('../helper', __FILE__) + +TESTING_REQUIRE = [] + +class TestRakeApplicationOptions < Rake::TestCase + + def setup + super + + clear_argv + Rake::FileUtilsExt.verbose_flag = false + Rake::FileUtilsExt.nowrite_flag = false + TESTING_REQUIRE.clear + end + + def teardown + clear_argv + Rake::FileUtilsExt.verbose_flag = false + Rake::FileUtilsExt.nowrite_flag = false + + super + end + + def clear_argv + ARGV.pop until ARGV.empty? + end + + def test_default_options + opts = command_line + assert_nil opts.backtrace + assert_nil opts.dryrun + assert_nil opts.ignore_system + assert_nil opts.load_system + assert_nil opts.always_multitask + assert_nil opts.nosearch + assert_equal ['rakelib'], opts.rakelib + assert_nil opts.show_prereqs + assert_nil opts.show_task_pattern + assert_nil opts.show_tasks + assert_nil opts.silent + assert_nil opts.trace + assert_nil opts.thread_pool_size + assert_equal ['rakelib'], opts.rakelib + assert ! Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag + end + + def test_dry_run + flags('--dry-run', '-n') do |opts| + assert opts.dryrun + assert opts.trace + assert Rake::FileUtilsExt.verbose_flag + assert Rake::FileUtilsExt.nowrite_flag + end + end + + def test_describe + flags('--describe') do |opts| + assert_equal :describe, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + end + end + + def test_describe_with_pattern + flags('--describe=X') do |opts| + assert_equal :describe, opts.show_tasks + assert_equal(/X/.to_s, opts.show_task_pattern.to_s) + end + end + + def test_execute + $xyzzy = 0 + flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts| + assert_equal 1, $xyzzy + assert_equal :exit, @exit + $xyzzy = 0 + end + end + + def test_execute_and_continue + $xyzzy = 0 + flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts| + assert_equal 1, $xyzzy + refute_equal :exit, @exit + $xyzzy = 0 + end + end + + def test_execute_and_print + $xyzzy = 0 + out, = capture_io do + flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts| + assert_equal 'pugh', $xyzzy + assert_equal :exit, @exit + $xyzzy = 0 + end + end + + assert_match(/^pugh$/, out) + end + + def test_help + out, = capture_io do + flags '--help', '-H', '-h' + end + + assert_match(/\Arake/, out) + assert_match(/\boptions\b/, out) + assert_match(/\btargets\b/, out) + assert_equal :exit, @exit + end + + def test_jobs + flags([]) do |opts| + assert_nil opts.thread_pool_size + end + flags(['--jobs', '0'], ['-j', '0']) do |opts| + assert_equal 0, opts.thread_pool_size + end + flags(['--jobs', '1'], ['-j', '1']) do |opts| + assert_equal 0, opts.thread_pool_size + end + flags(['--jobs', '4'], ['-j', '4']) do |opts| + assert_equal 3, opts.thread_pool_size + end + flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts| + assert_equal Rake.suggested_thread_count-1, opts.thread_pool_size + end + flags('--jobs', '-j') do |opts| + assert opts.thread_pool_size > 1_000_000, "thread pool size should be huge (was #{opts.thread_pool_size})" + end + end + + def test_libdir + flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts| + $:.include?('xx') + end + ensure + $:.delete('xx') + end + + def test_multitask + flags('--multitask', '-m') do |opts| + assert_equal opts.always_multitask, true + end + end + + def test_rakefile + flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts| + assert_equal ['RF'], @app.instance_eval { @rakefiles } + end + end + + def test_rakelib + dirs = %w(A B C).join(File::PATH_SEPARATOR) + flags( + ['--rakelibdir', dirs], + ["--rakelibdir=#{dirs}"], + ['-R', dirs], + ["-R#{dirs}"]) do |opts| + assert_equal ['A', 'B', 'C'], opts.rakelib + end + end + + def test_require + $LOAD_PATH.unshift @tempdir + + open 'reqfile.rb', 'w' do |io| io << 'TESTING_REQUIRE << 1' end + open 'reqfile2.rb', 'w' do |io| io << 'TESTING_REQUIRE << 2' end + open 'reqfile3.rake', 'w' do |io| io << 'TESTING_REQUIRE << 3' end + + flags(['--require', 'reqfile'], '-rreqfile2', '-rreqfile3') + + assert_includes TESTING_REQUIRE, 1 + assert_includes TESTING_REQUIRE, 2 + assert_includes TESTING_REQUIRE, 3 + + assert_equal 3, TESTING_REQUIRE.size + ensure + $LOAD_PATH.delete @tempdir + end + + def test_missing_require + ex = assert_raises(LoadError) do + flags(['--require', 'test/missing']) do |opts| + end + end + assert_match(/such file/, ex.message) + assert_match(/test\/missing/, ex.message) + end + + def test_prereqs + flags('--prereqs', '-P') do |opts| + assert opts.show_prereqs + end + end + + def test_quiet + Rake::FileUtilsExt.verbose_flag = true + flags('--quiet', '-q') do |opts| + assert ! Rake::FileUtilsExt.verbose_flag, "verbose flag shoud be false" + assert ! opts.silent, "should not be silent" + end + end + + def test_no_search + flags('--nosearch', '--no-search', '-N') do |opts| + assert opts.nosearch + end + end + + def test_silent + Rake::FileUtilsExt.verbose_flag = true + flags('--silent', '-s') do |opts| + assert ! Rake::FileUtilsExt.verbose_flag, "verbose flag should be false" + assert opts.silent, "should be silent" + end + end + + def test_system + flags('--system', '-g') do |opts| + assert opts.load_system + end + end + + def test_no_system + flags('--no-system', '-G') do |opts| + assert opts.ignore_system + end + end + + def test_trace + flags('--trace', '-t') do |opts| + assert opts.trace, "should enable trace option" + assert opts.backtrace, "should enabled backtrace option" + assert_equal $stderr, opts.trace_output + assert Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag + end + end + + def test_trace_with_stdout + flags('--trace=stdout', '-tstdout') do |opts| + assert opts.trace, "should enable trace option" + assert opts.backtrace, "should enabled backtrace option" + assert_equal $stdout, opts.trace_output + assert Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag + end + end + + def test_trace_with_stderr + flags('--trace=stderr', '-tstderr') do |opts| + assert opts.trace, "should enable trace option" + assert opts.backtrace, "should enabled backtrace option" + assert_equal $stderr, opts.trace_output + assert Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag + end + end + + def test_trace_with_error + ex = assert_raises(Rake::CommandLineOptionError) do + flags('--trace=xyzzy') do |opts| end + end + assert_match(/un(known|recognized).*\btrace\b.*xyzzy/i, ex.message) + end + + def test_trace_with_following_task_name + flags(['--trace', 'taskname'], ['-t', 'taskname']) do |opts| + assert opts.trace, "should enable trace option" + assert opts.backtrace, "should enabled backtrace option" + assert_equal $stderr, opts.trace_output + assert Rake::FileUtilsExt.verbose_flag + assert_equal ['taskname'], @app.top_level_tasks + end + end + + def test_backtrace + flags('--backtrace') do |opts| + assert opts.backtrace, "should enable backtrace option" + assert_equal $stderr, opts.trace_output + assert ! opts.trace, "should not enable trace option" + end + end + + def test_backtrace_with_stdout + flags('--backtrace=stdout') do |opts| + assert opts.backtrace, "should enable backtrace option" + assert_equal $stdout, opts.trace_output + assert ! opts.trace, "should not enable trace option" + end + end + + def test_backtrace_with_stderr + flags('--backtrace=stderr') do |opts| + assert opts.backtrace, "should enable backtrace option" + assert_equal $stderr, opts.trace_output + assert ! opts.trace, "should not enable trace option" + end + end + + def test_backtrace_with_error + ex = assert_raises(Rake::CommandLineOptionError) do + flags('--backtrace=xyzzy') do |opts| end + end + assert_match(/un(known|recognized).*\bbacktrace\b.*xyzzy/i, ex.message) + end + + def test_backtrace_with_following_task_name + flags(['--backtrace', 'taskname']) do |opts| + assert ! opts.trace, "should enable trace option" + assert opts.backtrace, "should enabled backtrace option" + assert_equal $stderr, opts.trace_output + assert_equal ['taskname'], @app.top_level_tasks + end + end + + def test_trace_rules + flags('--rules') do |opts| + assert opts.trace_rules + end + end + + def test_tasks + flags('--tasks', '-T') do |opts| + assert_equal :tasks, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + assert_equal nil, opts.show_all_tasks + end + flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| + assert_equal :tasks, opts.show_tasks + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + assert_equal nil, opts.show_all_tasks + end + flags(['--tasks', 'xyz', '--comments']) do |opts| + assert_equal :tasks, opts.show_tasks + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + assert_equal false, opts.show_all_tasks + end + end + + def test_where + flags('--where', '-W') do |opts| + assert_equal :lines, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + assert_equal true, opts.show_all_tasks + end + flags(['--where', 'xyz'], ['-Wxyz']) do |opts| + assert_equal :lines, opts.show_tasks + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + assert_equal true, opts.show_all_tasks + end + flags(['--where', 'xyz', '--comments'], ['-Wxyz', '--comments']) do |opts| + assert_equal :lines, opts.show_tasks + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + assert_equal false, opts.show_all_tasks + end + end + + def test_no_deprecated_messages + flags('--no-deprecation-warnings', '-X') do |opts| + assert opts.ignore_deprecate + end + end + + def test_verbose + capture_io do + flags('--verbose', '-v') do |opts| + assert Rake::FileUtilsExt.verbose_flag, "verbose should be true" + assert ! opts.silent, "opts should not be silent" + end + end + end + + def test_version + out, _ = capture_io do + flags '--version', '-V' + end + + assert_match(/\bversion\b/, out) + assert_match(/\b#{RAKEVERSION}\b/, out) + assert_equal :exit, @exit + end + + def test_bad_option + _, err = capture_io do + ex = assert_raises(OptionParser::InvalidOption) do + flags('--bad-option') + end + + if ex.message =~ /^While/ # Ruby 1.9 error message + assert_match(/while parsing/i, ex.message) + else # Ruby 1.8 error message + assert_match(/(invalid|unrecognized) option/i, ex.message) + assert_match(/--bad-option/, ex.message) + end + end + + assert_equal '', err + end + + def test_task_collection + command_line("a", "b") + assert_equal ["a", "b"], @tasks.sort + end + + def test_default_task_collection + command_line() + assert_equal ["default"], @tasks + end + + def test_environment_definition + ENV.delete('TESTKEY') + command_line("TESTKEY=12") + assert_equal '12', ENV['TESTKEY'] + end + + def test_multiline_environment_definition + ENV.delete('TESTKEY') + command_line("TESTKEY=a\nb\n") + assert_equal "a\nb\n", ENV['TESTKEY'] + end + + def test_environment_and_tasks_together + ENV.delete('TESTKEY') + command_line("a", "b", "TESTKEY=12") + assert_equal ["a", "b"], @tasks.sort + assert_equal '12', ENV['TESTKEY'] + end + + def test_rake_explicit_task_library + Rake.add_rakelib 'app/task', 'other' + + libs = Rake.application.options.rakelib + + assert libs.include?("app/task") + assert libs.include?("other") + end + + private + + def flags(*sets) + sets.each do |set| + ARGV.clear + + @exit = catch(:system_exit) { command_line(*set) } + + yield(@app.options) if block_given? + end + end + + def command_line(*options) + options.each do |opt| ARGV << opt end + @app = Rake::Application.new + def @app.exit(*args) + throw :system_exit, :exit + end + @app.instance_eval do + args = handle_options + collect_command_line_tasks(args) + end + @tasks = @app.top_level_tasks + @app.options + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_backtrace.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_backtrace.rb new file mode 100644 index 000000000..78eaa8d52 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_backtrace.rb @@ -0,0 +1,119 @@ +require File.expand_path('../helper', __FILE__) +require 'open3' + +class TestBacktraceSuppression < Rake::TestCase + def test_bin_rake_suppressed + paths = ["something/bin/rake:12"] + + actual = Rake::Backtrace.collapse(paths) + + assert_equal [], actual + end + + def test_system_dir_suppressed + path = RbConfig::CONFIG['rubylibprefix'] + skip if path.nil? + path = File.expand_path path + + paths = [path + ":12"] + + actual = Rake::Backtrace.collapse(paths) + + assert_equal [], actual + end + + def test_near_system_dir_isnt_suppressed + path = RbConfig::CONFIG['rubylibprefix'] + skip if path.nil? + path = File.expand_path path + + paths = [" " + path + ":12"] + + actual = Rake::Backtrace.collapse(paths) + + assert_equal paths, actual + end +end + +class TestRakeBacktrace < Rake::TestCase + include RubyRunner + + def setup + super + + skip 'tmpdir is suppressed in backtrace' if + Rake::Backtrace::SUPPRESS_PATTERN =~ Dir.pwd + end + + def invoke(*args) + rake(*args) + @err + end + + def test_single_collapse + rakefile %q{ + task :foo do + raise "foooo!" + end + } + + lines = invoke("foo").split("\n") + + assert_equal "rake aborted!", lines[0] + assert_equal "foooo!", lines[1] + assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!i, lines + assert_something_matches %r!\ATasks:!, lines + end + + def test_multi_collapse + rakefile %q{ + task :foo do + Rake.application.invoke_task(:bar) + end + task :bar do + raise "barrr!" + end + } + + lines = invoke("foo").split("\n") + + assert_equal "rake aborted!", lines[0] + assert_equal "barrr!", lines[1] + assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:6!i, lines + assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!i, lines + assert_something_matches %r!\ATasks:!, lines + end + + def test_suppress_option + rakefile %q{ + task :baz do + raise "bazzz!" + end + } + + lines = invoke("baz").split("\n") + assert_equal "rake aborted!", lines[0] + assert_equal "bazzz!", lines[1] + assert_something_matches %r!Rakefile!i, lines + + lines = invoke("--suppress-backtrace", ".ak.file", "baz").split("\n") + assert_equal "rake aborted!", lines[0] + assert_equal "bazzz!", lines[1] + refute_match %r!Rakefile!i, lines[2] + end + + private + + # Assert that the pattern matches at least one line in +lines+. + def assert_something_matches(pattern, lines) + lines.each do |ln| + if pattern =~ ln + assert_match pattern, ln + return + end + end + flunk "expected #{pattern.inspect} to match something in:\n" + + "#{lines.join("\n ")}" + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_clean.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_clean.rb new file mode 100644 index 000000000..0bce7bc0b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_clean.rb @@ -0,0 +1,61 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/clean' + +class TestRakeClean < Rake::TestCase + def test_clean + load 'rake/clean.rb', true + + assert Rake::Task['clean'], "Should define clean" + assert Rake::Task['clobber'], "Should define clobber" + assert Rake::Task['clobber'].prerequisites.include?("clean"), + "Clobber should require clean" + end + + def test_cleanup + file_name = create_undeletable_file + + out, _ = capture_io do + Rake::Cleaner.cleanup(file_name, :verbose => false) + end + assert_match(/failed to remove/i, out) + + ensure + remove_undeletable_file + end + + def test_cleanup_ignores_missing_files + file_name = File.join(@tempdir, "missing_directory", "no_such_file") + + out, _ = capture_io do + Rake::Cleaner.cleanup(file_name, :verbose => false) + end + refute_match(/failed to remove/i, out) + end + + private + + def create_undeletable_file + dir_name = File.join(@tempdir, "deletedir") + file_name = File.join(dir_name, "deleteme") + FileUtils.mkdir(dir_name) + FileUtils.touch(file_name) + FileUtils.chmod(0, file_name) + FileUtils.chmod(0, dir_name) + begin + FileUtils.chmod(0644, file_name) + rescue + file_name + else + skip "Permission to delete files is different on thie system" + end + end + + def remove_undeletable_file + dir_name = File.join(@tempdir, "deletedir") + file_name = File.join(dir_name, "deleteme") + FileUtils.chmod(0777, dir_name) + FileUtils.chmod(0777, file_name) + Rake::Cleaner.cleanup(file_name, :verbose => false) + Rake::Cleaner.cleanup(dir_name, :verbose => false) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb new file mode 100644 index 000000000..87d0601c6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb @@ -0,0 +1,68 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeCpuCounter < Rake::TestCase + + def setup + super + + @cpu_counter = Rake::CpuCounter.new + end + + def test_count + num = @cpu_counter.count + skip 'cannot count CPU' if num == nil + assert_kind_of Numeric, num + assert_operator num, :>=, 1 + end + + def test_count_with_default_nil + def @cpu_counter.count; nil; end + assert_equal(8, @cpu_counter.count_with_default(8)) + assert_equal(4, @cpu_counter.count_with_default) + end + + def test_count_with_default_raise + def @cpu_counter.count; raise; end + assert_equal(8, @cpu_counter.count_with_default(8)) + assert_equal(4, @cpu_counter.count_with_default) + end + + class TestClassMethod < Rake::TestCase + def setup + super + + @klass = Class.new(Rake::CpuCounter) + end + + def test_count + @klass.class_eval do + def count; 8; end + end + assert_equal(8, @klass.count) + end + + def test_count_nil + counted = false + @klass.class_eval do + define_method(:count) do + counted = true + nil + end + end + assert_equal(4, @klass.count) + assert_equal(true, counted) + end + + def test_count_raise + counted = false + @klass.class_eval do + define_method(:count) do + counted = true + raise + end + end + assert_equal(4, @klass.count) + assert_equal(true, counted) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_definitions.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_definitions.rb new file mode 100644 index 000000000..ee474cb7c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_definitions.rb @@ -0,0 +1,84 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' + +class TestRakeDefinitions < Rake::TestCase + include Rake + + EXISTINGFILE = "existing" + + def setup + super + + Task.clear + end + + def test_task + done = false + task :one => [:two] do done = true end + task :two + task :three => [:one, :two] + check_tasks(:one, :two, :three) + assert done, "Should be done" + end + + def test_file_task + done = false + file "one" => "two" do done = true end + file "two" + file "three" => ["one", "two"] + check_tasks("one", "two", "three") + assert done, "Should be done" + end + + def check_tasks(n1, n2, n3) + t = Task[n1] + assert Task === t, "Should be a Task" + assert_equal n1.to_s, t.name + assert_equal [n2.to_s], t.prerequisites.map { |n| n.to_s } + t.invoke + t2 = Task[n2] + assert_equal FileList[], t2.prerequisites + t3 = Task[n3] + assert_equal [n1.to_s, n2.to_s], t3.prerequisites.map { |n| n.to_s } + end + + def test_incremental_definitions + runs = [] + task :t1 => [:t2] do runs << "A"; 4321 end + task :t1 => [:t3] do runs << "B"; 1234 end + task :t1 => [:t3] + task :t2 + task :t3 + Task[:t1].invoke + assert_equal ["A", "B"], runs + assert_equal ["t2", "t3"], Task[:t1].prerequisites + end + + def test_missing_dependencies + task :x => ["missing"] + assert_raises(RuntimeError) { Task[:x].invoke } + end + + def test_falsey_dependencies + task :x => nil + assert_equal [], Task[:x].prerequisites + end + + def test_implicit_file_dependencies + runs = [] + create_existing_file + task :y => [EXISTINGFILE] do |t| runs << t.name end + Task[:y].invoke + assert_equal runs, ['y'] + end + + private # ---------------------------------------------------------- + + def create_existing_file + Dir.mkdir File.dirname(EXISTINGFILE) unless + File.exist?(File.dirname(EXISTINGFILE)) + open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless + File.exist?(EXISTINGFILE) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_directory_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_directory_task.rb new file mode 100644 index 000000000..0014d1c15 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_directory_task.rb @@ -0,0 +1,76 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' +require 'pathname' + +class TestRakeDirectoryTask < Rake::TestCase + include Rake + + def test_directory + desc "DESC" + + directory "a/b/c" + + assert_equal FileCreationTask, Task["a"].class + assert_equal FileCreationTask, Task["a/b"].class + assert_equal FileCreationTask, Task["a/b/c"].class + + assert_nil Task["a"].comment + assert_nil Task["a/b"].comment + assert_equal "DESC", Task["a/b/c"].comment + + verbose(false) { + Task['a/b'].invoke + } + + assert File.exist?("a/b") + refute File.exist?("a/b/c") + end + + def test_directory_colon + directory "a:b" + + assert_equal FileCreationTask, Task['a:b'].class + end unless Rake::Win32.windows? + + if Rake::Win32.windows? + def test_directory_win32 + desc "WIN32 DESC" + directory 'c:/a/b/c' + assert_equal FileTask, Task['c:'].class + assert_equal FileCreationTask, Task['c:/a'].class + assert_equal FileCreationTask, Task['c:/a/b'].class + assert_equal FileCreationTask, Task['c:/a/b/c'].class + assert_nil Task['c:/'].comment + assert_equal "WIN32 DESC", Task['c:/a/b/c'].comment + assert_nil Task['c:/a/b'].comment + end + end + + def test_can_use_blocks + runlist = [] + + t1 = directory("a/b/c" => :t2) { |t| runlist << t.name } + task(:t2) { |t| runlist << t.name } + + verbose(false) { + t1.invoke + } + + assert_equal Task["a/b/c"], t1 + assert_equal FileCreationTask, Task["a/b/c"].class + assert_equal ["t2", "a/b/c"], runlist + assert File.directory?("a/b/c") + end + + def test_can_use_pathname + directory Pathname.new "a/b/c" + + assert_equal FileCreationTask, Task["a/b/c"].class + + verbose(false) { + Task['a/b/c'].invoke + } + + assert File.directory?("a/b/c") + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_dsl.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_dsl.rb new file mode 100644 index 000000000..ad52f760b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_dsl.rb @@ -0,0 +1,40 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeDsl < Rake::TestCase + + def setup + super + Rake::Task.clear + end + + def test_namespace_command + namespace "n" do + task "t" + end + refute_nil Rake::Task["n:t"] + end + + def test_namespace_command_with_bad_name + ex = assert_raises(ArgumentError) do + namespace 1 do end + end + assert_match(/string/i, ex.message) + assert_match(/symbol/i, ex.message) + end + + def test_namespace_command_with_a_string_like_object + name = Object.new + def name.to_str + "bob" + end + namespace name do + task "t" + end + refute_nil Rake::Task["bob:t"] + end + + def test_no_commands_constant + assert ! defined?(Commands), "should not define Commands" + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_early_time.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_early_time.rb new file mode 100644 index 000000000..18c4dad32 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_early_time.rb @@ -0,0 +1,31 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeEarlyTime < Rake::TestCase + def test_create + early = Rake::EarlyTime.instance + assert early <= Time.now + assert early < Time.now + assert early != Time.now + assert Time.now > early + assert Time.now >= early + assert Time.now != early + end + + def test_equality + early = Rake::EarlyTime.instance + assert_equal early, early, "two early times should be equal" + end + + def test_original_time_compare_is_not_messed_up + t1 = Time.mktime(1970, 1, 1, 0, 0, 0) + t2 = Time.now + assert t1 < t2 + assert t2 > t1 + assert t1 == t1 + assert t2 == t2 + end + + def test_to_s + assert_equal "", Rake::EARLY.to_s + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_extension.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_extension.rb new file mode 100644 index 000000000..18d55f19f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_extension.rb @@ -0,0 +1,59 @@ +require File.expand_path('../helper', __FILE__) +require 'stringio' + +class TestRakeExtension < Rake::TestCase + + module Redirect + def error_redirect + old_err = $stderr + result = StringIO.new + $stderr = result + yield + result + ensure + $stderr = old_err + end + end + + class Sample + extend Redirect + + def duplicate_method + :original + end + + OK_ERRS = error_redirect do + rake_extension("a") do + def ok_method + end + end + end + + + DUP_ERRS = error_redirect do + rake_extension("duplicate_method") do + def duplicate_method + :override + end + end + end + end + + def test_methods_actually_exist + sample = Sample.new + sample.ok_method + sample.duplicate_method + end + + def test_no_warning_when_defining_ok_method + assert_equal "", Sample::OK_ERRS.string + end + + def test_extension_complains_when_a_method_that_is_present + assert_match(/warning:/i, Sample::DUP_ERRS.string) + assert_match(/already exists/i, Sample::DUP_ERRS.string) + assert_match(/duplicate_method/i, Sample::DUP_ERRS.string) + assert_equal :original, Sample.new.duplicate_method + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_creation_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_creation_task.rb new file mode 100644 index 000000000..d8dcd965a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_creation_task.rb @@ -0,0 +1,56 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' + +###################################################################### +class TestRakeFileCreationTask < Rake::TestCase + include Rake + include Rake::DSL + + DUMMY_DIR = 'dummy_dir' + + def setup + super + + Task.clear + end + + def test_file_needed + create_dir DUMMY_DIR + fc_task = Task[DUMMY_DIR] + assert_equal DUMMY_DIR, fc_task.name + FileUtils.rm_rf fc_task.name + assert fc_task.needed?, "file should be needed" + FileUtils.mkdir fc_task.name + assert_equal nil, fc_task.prerequisites.map { |n| Task[n].timestamp }.max + assert ! fc_task.needed?, "file should not be needed" + end + + def test_directory + directory DUMMY_DIR + fc_task = Task[DUMMY_DIR] + assert_equal DUMMY_DIR, fc_task.name + assert FileCreationTask === fc_task + end + + def test_no_retriggers_on_filecreate_task + create_timed_files(OLDFILE, NEWFILE) + t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE]) + t2 = Rake.application.intern(FileCreationTask, NEWFILE) + assert ! t2.needed?, "Should not need to build new file" + assert ! t1.needed?, "Should not need to rebuild old file because of new" + end + + def test_no_retriggers_on_file_task + create_timed_files(OLDFILE, NEWFILE) + t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE]) + t2 = Rake.application.intern(FileCreationTask, NEWFILE) + assert ! t2.needed?, "Should not need to build new file" + assert ! t1.needed?, "Should not need to rebuild old file because of new" + end + + def test_very_early_timestamp + t1 = Rake.application.intern(FileCreationTask, OLDFILE) + assert t1.timestamp < Time.now + assert t1.timestamp < Time.now - 1_000_000 + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list.rb new file mode 100644 index 000000000..c1b4c9208 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list.rb @@ -0,0 +1,655 @@ +require File.expand_path('../helper', __FILE__) +require 'pathname' + +class TestRakeFileList < Rake::TestCase + FileList = Rake::FileList + + def setup + super + + FileUtils.mkdir "CVS" rescue nil + FileUtils.mkdir ".svn" rescue nil + @cdir = "cfiles" + FileUtils.mkdir @cdir rescue nil + FileUtils.touch ".dummy" + FileUtils.touch "x.bak" + FileUtils.touch "x~" + FileUtils.touch "core" + FileUtils.touch "x.c" + FileUtils.touch "xyz.c" + FileUtils.touch "abc.c" + FileUtils.touch "abc.h" + FileUtils.touch "abc.x" + FileUtils.touch "existing" + + open 'xyzzy.txt', 'w' do |io| + io.puts 'x' + io.puts 'XYZZY' + end + + end + + def test_delegating_methods_do_not_include_to_a_or_to_ary + assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a" + assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a" + assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary" + assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary" + end + + def test_create + fl = FileList.new + assert_equal 0, fl.size + end + + def test_create_with_args + fl = FileList.new("*.c", "x") + assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort, + fl.sort + end + + def test_create_with_pathname + fl = FileList.new(Pathname.new("*.c")) + assert_equal ["abc.c", "x.c", "xyz.c"].sort, + fl.sort + end + + def test_create_with_block + fl = FileList.new { |f| f.include("x") } + assert_equal ["x"], fl.resolve + end + + def test_create_with_brackets + fl = FileList["*.c", "x"] + assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort, + fl.sort + end + + def test_create_with_brackets_and_filelist + fl = FileList[FileList["*.c", "x"]] + assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort, + fl.sort + end + + def test_include_with_another_array + fl = FileList.new.include(["x", "y", "z"]) + assert_equal ["x", "y", "z"].sort, fl.sort + end + + def test_include_with_another_filelist + fl = FileList.new.include(FileList["*.c", "x"]) + assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort, + fl.sort + end + + def test_include_with_pathname + fl = FileList.new.include(Pathname.new("*.c")) + assert_equal ["abc.c", "x.c", "xyz.c"].sort, + fl.sort + end + + def test_append + fl = FileList.new + fl << "a.rb" << "b.rb" + assert_equal ['a.rb', 'b.rb'], fl + end + + def test_append_pathname + fl = FileList.new + fl << Pathname.new("a.rb") + assert_equal ['a.rb'], fl + end + + def test_add_many + fl = FileList.new + fl.include %w(a d c) + fl.include('x', 'y') + assert_equal ['a', 'd', 'c', 'x', 'y'], fl + assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve + end + + def test_add_return + f = FileList.new + g = f << "x" + assert_equal f.object_id, g.object_id + h = f.include("y") + assert_equal f.object_id, h.object_id + end + + def test_match + fl = FileList.new + fl.include '*.c' + + assert_equal %w[abc.c x.c xyz.c], fl.sort + end + + def test_add_matching + fl = FileList.new + fl << "a.java" + fl.include '*.c' + + assert_equal %w[a.java abc.c x.c xyz.c], fl.sort + end + + def test_multiple_patterns + fl = FileList.new + fl.include('*.z', '*foo*') + + assert_equal [], fl + + fl.include('*.c', '*xist*') + assert_equal %w[x.c xyz.c abc.c existing].sort, fl.sort + end + + def test_square_bracket_pattern + fl = FileList.new + fl.include("abc.[ch]") + assert fl.size == 2 + assert fl.include?("abc.c") + assert fl.include?("abc.h") + end + + def test_curly_bracket_pattern + fl = FileList.new + fl.include("abc.{c,h}") + assert fl.size == 2 + assert fl.include?("abc.c") + assert fl.include?("abc.h") + end + + def test_reject + fl = FileList.new + fl.include %w(x.c abc.c xyz.c existing) + fl.reject! { |fn| fn =~ /^x/ } + assert_equal %w[abc.c existing], fl + end + + def test_exclude + fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing'] + fl.each { |fn| touch fn, :verbose => false } + + x = fl.exclude(%r{^x.+\.}) + + assert_equal FileList, x.class + assert_equal %w(x.c abc.c existing), fl + assert_equal fl.object_id, x.object_id + + fl.exclude('*.c') + + assert_equal ['existing'], fl + + fl.exclude('existing') + + assert_equal [], fl + end + + def test_exclude_pathname + fl = FileList['x.c', 'abc.c', 'other'] + fl.each { |fn| touch fn, :verbose => false } + + fl.exclude(Pathname.new('*.c')) + + assert_equal ['other'], fl + end + + def test_excluding_via_block + fl = FileList['a.c', 'b.c', 'xyz.c'] + fl.exclude { |fn| fn.pathmap('%n') == 'xyz' } + assert fl.excluded_from_list?("xyz.c"), "Should exclude xyz.c" + assert_equal ['a.c', 'b.c'], fl + end + + def test_exclude_return_on_create + fl = FileList['*'].exclude(/.*\.[hcx]$/) + assert_equal %w[cfiles existing xyzzy.txt], fl.sort + assert_equal FileList, fl.class + end + + def test_exclude_with_string_return_on_create + fl = FileList['*'].exclude('abc.c') + assert_equal %w[abc.h abc.x cfiles existing x.c xyz.c xyzzy.txt], fl.sort + assert_equal FileList, fl.class + end + + def test_default_exclude + fl = FileList.new + fl.clear_exclude + fl.include("**/*~", "**/*.bak", "**/core") + assert fl.member?("core"), "Should include core" + assert fl.member?("x.bak"), "Should include .bak files" + end + + def test_unique + fl = FileList.new + fl << "x.c" << "a.c" << "b.rb" << "a.c" + assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl + fl.uniq! + assert_equal ['x.c', 'a.c', 'b.rb'], fl + end + + def test_to_string + fl = FileList.new + fl << "a.java" << "b.java" + assert_equal "a.java b.java", fl.to_s + assert_equal "a.java b.java", "#{fl}" + end + + def test_to_array + fl = FileList['a.java', 'b.java'] + assert_equal ['a.java', 'b.java'], fl.to_a + assert_equal Array, fl.to_a.class + assert_equal ['a.java', 'b.java'], fl.to_ary + assert_equal Array, fl.to_ary.class + end + + def test_to_s_pending + fl = FileList['abc.*'] + result = fl.to_s + assert_match(%r{abc\.c}, result) + assert_match(%r{abc\.h}, result) + assert_match(%r{abc\.x}, result) + assert_match(%r{(abc\..\b ?){2}}, result) + end + + def test_inspect_pending + fl = FileList['abc.*'] + result = fl.inspect + assert_match(%r{"abc\.c"}, result) + assert_match(%r{"abc\.h"}, result) + assert_match(%r{"abc\.x"}, result) + assert_match(%r|^\[("abc\..", ){2}"abc\.."\]$|, result) + end + + def test_sub + fl = FileList["*.c"] + f2 = fl.sub(/\.c$/, ".o") + assert_equal FileList, f2.class + assert_equal ["abc.o", "x.o", "xyz.o"].sort, + f2.sort + f3 = fl.gsub(/\.c$/, ".o") + assert_equal FileList, f3.class + assert_equal ["abc.o", "x.o", "xyz.o"].sort, + f3.sort + end + + def test_claim_to_be_a_kind_of_array + fl = FileList['*.c'] + assert fl.is_a?(Array) + assert fl.kind_of?(Array) + end + + def test_claim_to_be_a_kind_of_filelist + fl = FileList['*.c'] + assert fl.is_a?(FileList) + assert fl.kind_of?(FileList) + end + + def test_claim_to_be_a_filelist_instance + fl = FileList['*.c'] + assert fl.instance_of?(FileList) + end + + def test_dont_claim_to_be_an_array_instance + fl = FileList['*.c'] + assert ! fl.instance_of?(Array) + end + + def test_sub! + f = "x/a.c" + fl = FileList[f, "x/b.c"] + res = fl.sub!(/\.c$/, ".o") + assert_equal ["x/a.o", "x/b.o"].sort, fl.sort + assert_equal "x/a.c", f + assert_equal fl.object_id, res.object_id + end + + def test_sub_with_block + fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"] +# The block version doesn't work the way I want it to ... +# f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" } + f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class") + assert_equal [ + "classes/org/onestepback/a.class", + "classes/org/onestepback/b.class" + ].sort, + f2.sort + end + + def test_string_ext + assert_equal "one.net", "one.two".ext("net") + assert_equal "one.net", "one.two".ext(".net") + assert_equal "one.net", "one".ext("net") + assert_equal "one.net", "one".ext(".net") + assert_equal "one.two.net", "one.two.c".ext(".net") + assert_equal "one/two.net", "one/two.c".ext(".net") + assert_equal "one.x/two.net", "one.x/two.c".ext(".net") + assert_equal "one.x/two.net", "one.x/two".ext(".net") + assert_equal ".onerc.net", ".onerc.dot".ext("net") + assert_equal ".onerc.net", ".onerc".ext("net") + assert_equal ".a/.onerc.net", ".a/.onerc".ext("net") + assert_equal "one", "one.two".ext('') + assert_equal "one", "one.two".ext + assert_equal ".one", ".one.two".ext + assert_equal ".one", ".one".ext + assert_equal ".", ".".ext("c") + assert_equal "..", "..".ext("c") + # These only need to work in windows + if Rake::Win32.windows? + assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net") + assert_equal "one.x\\two.net", "one.x\\two".ext(".net") + end + end + + def test_filelist_ext + assert_equal FileList['one.c', '.one.c'], + FileList['one.net', '.one'].ext('c') + end + + def test_gsub + fl = FileList["*.c"] + f2 = fl.gsub(/a/, "A") + assert_equal ["Abc.c", "x.c", "xyz.c"].sort, + f2.sort + end + + def test_gsub! + f = FileList["*.c"] + f.gsub!(/a/, "A") + assert_equal ["Abc.c", "x.c", "xyz.c"].sort, + f.sort + end + + def test_egrep_returns_0_if_no_matches + files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb") + assert_equal 0, files.egrep(/XYZZY/) { } + end + + def test_egrep_with_output + files = FileList['*.txt'] + + out, = capture_io do + files.egrep(/XYZZY/) + end + + assert_equal "xyzzy.txt:2:XYZZY\n", out + end + + def test_egrep_with_block + files = FileList['*.txt'] + found = nil + + files.egrep(/XYZZY/) do |fn, ln, line| + found = [fn, ln, line] + end + + assert_equal ["xyzzy.txt", 2, "XYZZY\n"], found + end + + def test_egrep_with_error + files = FileList['*.txt'] + + _, err = capture_io do + files.egrep(/XYZZY/) do |fn, ln, line | + raise "_EGREP_FAILURE_" + end + end + + assert_equal "Error while processing 'xyzzy.txt': _EGREP_FAILURE_\n", err + end + + def test_existing + fl = FileList['abc.c', 'notthere.c'] + assert_equal ["abc.c"], fl.existing + assert fl.existing.is_a?(FileList) + end + + def test_existing! + fl = FileList['abc.c', 'notthere.c'] + result = fl.existing! + assert_equal ["abc.c"], fl + assert_equal fl.object_id, result.object_id + end + + def test_ignore_special + f = FileList['*'] + assert ! f.include?("CVS"), "Should not contain CVS" + assert ! f.include?(".svn"), "Should not contain .svn" + assert ! f.include?(".dummy"), "Should not contain dot files" + assert ! f.include?("x.bak"), "Should not contain .bak files" + assert ! f.include?("x~"), "Should not contain ~ files" + assert ! f.include?("core"), "Should not contain core files" + end + + def test_clear_ignore_patterns + f = FileList['*', '.svn'] + f.clear_exclude + assert f.include?("abc.c") + assert f.include?("xyz.c") + assert f.include?("CVS") + assert f.include?(".svn") + assert f.include?("x.bak") + assert f.include?("x~") + end + + def test_exclude_with_alternate_file_seps + fl = FileList.new + assert fl.excluded_from_list?("x/CVS/y") + assert fl.excluded_from_list?("x\\CVS\\y") + assert fl.excluded_from_list?("x/.svn/y") + assert fl.excluded_from_list?("x\\.svn\\y") + assert fl.excluded_from_list?("x/core") + assert fl.excluded_from_list?("x\\core") + end + + def test_add_default_exclude_list + fl = FileList.new + fl.exclude(/~\d+$/) + assert fl.excluded_from_list?("x/CVS/y") + assert fl.excluded_from_list?("x\\CVS\\y") + assert fl.excluded_from_list?("x/.svn/y") + assert fl.excluded_from_list?("x\\.svn\\y") + assert fl.excluded_from_list?("x/core") + assert fl.excluded_from_list?("x\\core") + assert fl.excluded_from_list?("x/abc~1") + end + + def test_basic_array_functions + f = FileList['b', 'c', 'a'] + assert_equal 'b', f.first + assert_equal 'b', f[0] + assert_equal 'a', f.last + assert_equal 'a', f[2] + assert_equal 'a', f[-1] + assert_equal ['a', 'b', 'c'], f.sort + f.sort! + assert_equal ['a', 'b', 'c'], f + end + + def test_flatten + assert_equal ['a', 'x.c', 'xyz.c', 'abc.c'].sort, + ['a', FileList['*.c']].flatten.sort + end + + def test_clone_and_dup + a = FileList['a', 'b', 'c'] + c = a.clone + d = a.dup + a << 'd' + assert_equal ['a', 'b', 'c', 'd'], a + assert_equal ['a', 'b', 'c'], c + assert_equal ['a', 'b', 'c'], d + end + + def test_dup_and_clone_replicate_taint + a = FileList['a', 'b', 'c'] + a.taint + c = a.clone + d = a.dup + assert c.tainted?, "Clone should be tainted" + assert d.tainted?, "Dup should be tainted" + end + + def test_duped_items_will_thaw + a = FileList['a', 'b', 'c'] + a.freeze + d = a.dup + d << 'more' + assert_equal ['a', 'b', 'c', 'more'], d + end + + def test_cloned_items_stay_frozen + a = FileList['a', 'b', 'c'] + a.freeze + c = a.clone + assert_raises(TypeError, RuntimeError) do + c << 'more' + end + end + + def test_array_comparisons + fl = FileList['b', 'b'] + a = ['b', 'a'] + b = ['b', 'b'] + c = ['b', 'c'] + assert_equal(1, fl <=> a) + assert_equal(0, fl <=> b) + assert_equal(-1, fl <=> c) + assert_equal(-1, a <=> fl) + assert_equal(0, b <=> fl) + assert_equal(1, c <=> fl) + end + + def test_array_equality + a = FileList['a', 'b'] + b = ['a', 'b'] + assert a == b + assert b == a +# assert a.eql?(b) +# assert b.eql?(a) + assert ! a.equal?(b) + assert ! b.equal?(a) + end + + def test_enumeration_methods + a = FileList['a', 'b'] + b = a.map { |it| it.upcase } + assert_equal ['A', 'B'], b + assert_equal FileList, b.class + + b = a.map { |it| it.upcase } + assert_equal ['A', 'B'], b + assert_equal FileList, b.class + + b = a.sort + assert_equal ['a', 'b'], b + assert_equal FileList, b.class + + b = a.sort_by { |it| it } + assert_equal ['a', 'b'], b + assert_equal FileList, b.class + + b = a.select { |it| it == 'b' } + assert_equal ['b'], b + assert_equal FileList, b.class + + b = a.select { |it| it.size == 1 } + assert_equal ['a', 'b'], b + assert_equal FileList, b.class + + b = a.reject { |it| it == 'b' } + assert_equal ['a'], b + assert_equal FileList, b.class + + b = a.grep(/./) + assert_equal ['a', 'b'], b + assert_equal FileList, b.class + + b = a.partition { |it| it == 'b' } + assert_equal [['b'], ['a']], b + assert_equal Array, b.class + assert_equal FileList, b[0].class + assert_equal FileList, b[1].class + + b = a.zip(['x', 'y']).to_a + assert_equal [['a', 'x'], ['b', 'y']], b + assert_equal Array, b.class + assert_equal Array, b[0].class + assert_equal Array, b[1].class + end + + def test_array_operators + a = ['a', 'b'] + b = ['c', 'd'] + f = FileList['x', 'y'] + g = FileList['w', 'z'] + + r = f + g + assert_equal ['x', 'y', 'w', 'z'], r + assert_equal FileList, r.class + + r = a + g + assert_equal ['a', 'b', 'w', 'z'], r + assert_equal Array, r.class + + r = f + b + assert_equal ['x', 'y', 'c', 'd'], r + assert_equal FileList, r.class + + r = FileList['w', 'x', 'y', 'z'] - f + assert_equal ['w', 'z'], r + assert_equal FileList, r.class + + r = FileList['w', 'x', 'y', 'z'] & f + assert_equal ['x', 'y'], r + assert_equal FileList, r.class + + r = f * 2 + assert_equal ['x', 'y', 'x', 'y'], r + assert_equal FileList, r.class + + r = f * ',' + assert_equal 'x,y', r + assert_equal String, r.class + + r = f | ['a', 'x'] + assert_equal ['a', 'x', 'y'].sort, r.sort + assert_equal FileList, r.class + end + + def test_other_array_returning_methods + f = FileList['a', nil, 'b'] + r = f.compact + assert_equal ['a', 'b'], r + assert_equal FileList, r.class + + f = FileList['a', 'b'] + r = f.concat(['x', 'y']) + assert_equal ['a', 'b', 'x', 'y'], r + assert_equal FileList, r.class + + f = FileList['a', ['b', 'c'], FileList['d', 'e']] + r = f.flatten + assert_equal ['a', 'b', 'c', 'd', 'e'], r + assert_equal FileList, r.class + + f = FileList['a', 'b', 'a'] + r = f.uniq + assert_equal ['a', 'b'], r + assert_equal FileList, r.class + + f = FileList['a', 'b', 'c', 'd'] + r = f.values_at(1, 3) + assert_equal ['b', 'd'], r + assert_equal FileList, r.class + end + + def test_file_utils_can_use_filelists + cfiles = FileList['*.c'] + + cp cfiles, @cdir, :verbose => false + + assert File.exist?(File.join(@cdir, 'abc.c')) + assert File.exist?(File.join(@cdir, 'xyz.c')) + assert File.exist?(File.join(@cdir, 'x.c')) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list_path_map.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list_path_map.rb new file mode 100644 index 000000000..5935dc268 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_list_path_map.rb @@ -0,0 +1,8 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeFileListPathMap < Rake::TestCase + def test_file_list_supports_pathmap + assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n") + end +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_task.rb new file mode 100644 index 000000000..a24951144 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_task.rb @@ -0,0 +1,197 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' +require 'pathname' + +class TestRakeFileTask < Rake::TestCase + include Rake + + def setup + super + + Task.clear + @runs = Array.new + FileUtils.rm_f NEWFILE + FileUtils.rm_f OLDFILE + end + + def test_file_need + name = "dummy" + file name + + ftask = Task[name] + + assert_equal name.to_s, ftask.name + File.delete(ftask.name) rescue nil + + assert ftask.needed?, "file should be needed" + assert_equal Rake::LATE, ftask.timestamp + + open(ftask.name, "w") { |f| f.puts "HI" } + + assert_equal nil, ftask.prerequisites.map { |n| Task[n].timestamp }.max + assert ! ftask.needed?, "file should not be needed" + ensure + File.delete(ftask.name) rescue nil + end + + def test_file_times_new_depends_on_old + create_timed_files(OLDFILE, NEWFILE) + + t1 = Rake.application.intern(FileTask, NEWFILE).enhance([OLDFILE]) + t2 = Rake.application.intern(FileTask, OLDFILE) + assert ! t2.needed?, "Should not need to build old file" + assert ! t1.needed?, "Should not need to rebuild new file because of old" + end + + def test_file_times_new_depend_on_regular_task_timestamps + load_phony + + name = "dummy" + task name + + create_timed_files(NEWFILE) + + t1 = Rake.application.intern(FileTask, NEWFILE).enhance([name]) + + assert t1.needed?, "depending on non-file task uses Time.now" + + task(name => :phony) + + assert t1.needed?, "unless the non-file task has a timestamp" + end + + def test_file_times_old_depends_on_new + create_timed_files(OLDFILE, NEWFILE) + + t1 = Rake.application.intern(FileTask, OLDFILE).enhance([NEWFILE]) + t2 = Rake.application.intern(FileTask, NEWFILE) + assert ! t2.needed?, "Should not need to build new file" + preq_stamp = t1.prerequisites.map { |t| Task[t].timestamp }.max + assert_equal t2.timestamp, preq_stamp + assert t1.timestamp < preq_stamp, "T1 should be older" + assert t1.needed?, "Should need to rebuild old file because of new" + end + + def test_file_depends_on_task_depend_on_file + create_timed_files(OLDFILE, NEWFILE) + + file NEWFILE => [:obj] do |t| @runs << t.name end + task :obj => [OLDFILE] do |t| @runs << t.name end + file OLDFILE do |t| @runs << t.name end + + Task[:obj].invoke + Task[NEWFILE].invoke + assert @runs.include?(NEWFILE) + end + + def test_existing_file_depends_on_non_existing_file + create_file(OLDFILE) + delete_file(NEWFILE) + file NEWFILE do |t| @runs << t.name end + file OLDFILE => NEWFILE do |t| @runs << t.name end + + Task[OLDFILE].invoke + + assert_equal [NEWFILE, OLDFILE], @runs + end + + def test_needed_eh_build_all + create_file 'a' + + file 'a' + + a_task = Task['a'] + + refute a_task.needed? + + Rake.application.options.build_all = true + + assert a_task.needed? + ensure + delete_file 'a' + end + + def test_needed_eh_dependency + create_file 'a', Time.now + create_file 'b', Time.now - 60 + + create_file 'c', Time.now + create_file 'd', Time.now - 60 + + file 'b' => 'a' + + b_task = Task['b'] + + assert b_task.needed? + + file 'c' => 'd' + + c_task = Task['c'] + + refute c_task.needed? + ensure + delete_file 'old' + delete_file 'new' + end + + def test_needed_eh_exists + name = "dummy" + file name + + ftask = Task[name] + + assert ftask.needed? + + create_file name + + refute ftask.needed? + ensure + delete_file name + end + + def test_source_is_first_prerequisite + t = file :f => ["preqA", "preqB"] + assert_equal "preqA", t.source + end + + def test_sources_is_all_prerequisites + t = file :f => ["preqA", "preqB"] + assert_equal ["preqA", "preqB"], t.sources + end + + def test_task_can_be_pathname + name = "dummy" + file Pathname.new name + + ftask = Task[name] + + assert_equal name.to_s, ftask.name + end + + def test_prerequisite_can_be_pathname + t = file :f => Pathname.new("preq") + assert_equal "preq", t.source + end + + # I have currently disabled this test. I'm not convinced that + # deleting the file target on failure is always the proper thing to + # do. I'm willing to hear input on this topic. + def ztest_file_deletes_on_failure + task :obj + file NEWFILE => [:obj] do |t| + FileUtils.touch NEWFILE + fail "Ooops" + end + assert Task[NEWFILE] + begin + Task[NEWFILE].invoke + rescue Exception + end + assert(! File.exist?(NEWFILE), "NEWFILE should be deleted") + end + + def load_phony + load File.join(@rake_lib, "rake/phony.rb") + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_utils.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_utils.rb new file mode 100644 index 000000000..37d33dc39 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_file_utils.rb @@ -0,0 +1,309 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' +require 'stringio' + +class TestRakeFileUtils < Rake::TestCase + + def teardown + FileUtils::LN_SUPPORTED[0] = true + RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT + + super + end + + def test_rm_one_file + create_file("a") + FileUtils.rm_rf "a" + refute File.exist?("a") + end + + def test_rm_two_files + create_file("a") + create_file("b") + FileUtils.rm_rf ["a", "b"] + refute File.exist?("a") + refute File.exist?("b") + end + + def test_rm_filelist + list = Rake::FileList.new << "a" << "b" + list.each { |fn| create_file(fn) } + FileUtils.rm_r list + refute File.exist?("a") + refute File.exist?("b") + end + + def test_ln + open("a", "w") { |f| f.puts "TEST_LN" } + + Rake::FileUtilsExt.safe_ln("a", "b", :verbose => false) + + assert_equal "TEST_LN\n", File.read('b') + end + + class BadLink + include Rake::FileUtilsExt + attr_reader :cp_args + + def initialize(klass) + @failure_class = klass + end + + def cp(*args) + @cp_args = args + end + + def ln(*args) + fail @failure_class, "ln not supported" + end + + public :safe_ln + end + + def test_safe_ln_failover_to_cp_on_standard_error + FileUtils::LN_SUPPORTED[0] = true + c = BadLink.new(StandardError) + c.safe_ln "a", "b" + assert_equal ['a', 'b'], c.cp_args + c.safe_ln "x", "y" + assert_equal ['x', 'y'], c.cp_args + end + + def test_safe_ln_failover_to_cp_on_not_implemented_error + FileUtils::LN_SUPPORTED[0] = true + c = BadLink.new(NotImplementedError) + c.safe_ln "a", "b" + assert_equal ['a', 'b'], c.cp_args + end + + def test_safe_ln_fails_on_script_error + FileUtils::LN_SUPPORTED[0] = true + c = BadLink.new(ScriptError) + assert_raises(ScriptError) do c.safe_ln "a", "b" end + end + + def test_verbose + verbose true + assert_equal true, verbose + verbose false + assert_equal false, verbose + verbose(true) { + assert_equal true, verbose + } + assert_equal false, verbose + end + + def test_nowrite + nowrite true + assert_equal true, nowrite + nowrite false + assert_equal false, nowrite + nowrite(true) { + assert_equal true, nowrite + } + assert_equal false, nowrite + end + + def test_file_utils_methods_are_available_at_top_level + create_file("a") + + capture_io do + rm_rf "a" + end + + refute File.exist?("a") + end + + def test_fileutils_methods_dont_leak + obj = Object.new + assert_raises(NoMethodError) { obj.copy } # from FileUtils + assert_raises(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils + end + + def test_sh + shellcommand + + verbose(false) { sh %{#{Rake::TestCase::RUBY} shellcommand.rb} } + assert true, "should not fail" + end + + def test_sh_with_a_single_string_argument + check_expansion + + ENV['RAKE_TEST_SH'] = 'someval' + verbose(false) { + sh %{#{RUBY} check_expansion.rb #{env_var} someval} + } + end + + def test_sh_with_multiple_arguments + check_no_expansion + ENV['RAKE_TEST_SH'] = 'someval' + + verbose(false) { + sh RUBY, 'check_no_expansion.rb', env_var, 'someval' + } + end + + def test_sh_failure + shellcommand + + assert_raises(RuntimeError) { + verbose(false) { sh %{#{RUBY} shellcommand.rb 1} } + } + end + + def test_sh_special_handling + shellcommand + + count = 0 + verbose(false) { + sh(%{#{RUBY} shellcommand.rb}) do |ok, res| + assert(ok) + assert_equal 0, res.exitstatus + count += 1 + end + sh(%{#{RUBY} shellcommand.rb 1}) do |ok, res| + assert(!ok) + assert_equal 1, res.exitstatus + count += 1 + end + } + assert_equal 2, count, "Block count should be 2" + end + + def test_sh_noop + shellcommand + + verbose(false) { sh %{shellcommand.rb 1}, :noop=>true } + assert true, "should not fail" + end + + def test_sh_bad_option + shellcommand + + ex = assert_raises(ArgumentError) { + verbose(false) { sh %{shellcommand.rb}, :bad_option=>true } + } + assert_match(/bad_option/, ex.message) + end + + def test_sh_verbose + shellcommand + + _, err = capture_io do + verbose(true) { + sh %{shellcommand.rb}, :noop=>true + } + end + + assert_equal "shellcommand.rb\n", err + end + + def test_sh_verbose_false + shellcommand + + _, err = capture_io do + verbose(false) { + sh %{shellcommand.rb}, :noop=>true + } + end + + assert_equal '', err + end + + def test_sh_verbose_flag_nil + shellcommand + + RakeFileUtils.verbose_flag = nil + + assert_silent do + sh %{shellcommand.rb}, :noop=>true + end + end + + def test_ruby_with_a_single_string_argument + check_expansion + + ENV['RAKE_TEST_SH'] = 'someval' + + verbose(false) { + replace_ruby { + ruby %{check_expansion.rb #{env_var} someval} + } + } + end + + def test_ruby_with_multiple_arguments + check_no_expansion + + ENV['RAKE_TEST_SH'] = 'someval' + verbose(false) { + replace_ruby { + ruby 'check_no_expansion.rb', env_var, 'someval' + } + } + end + + def test_split_all + assert_equal ['a'], Rake::FileUtilsExt.split_all('a') + assert_equal ['..'], Rake::FileUtilsExt.split_all('..') + assert_equal ['/'], Rake::FileUtilsExt.split_all('/') + assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b') + assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b') + assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b') + end + + def command(name, text) + open name, 'w', 0750 do |io| + io << text + end + end + + def check_no_expansion + command 'check_no_expansion.rb', <<-CHECK_EXPANSION +if ARGV[0] != ARGV[1] + exit 0 +else + exit 1 +end + CHECK_EXPANSION + end + + def check_expansion + command 'check_expansion.rb', <<-CHECK_EXPANSION +if ARGV[0] != ARGV[1] + exit 1 +else + exit 0 +end + CHECK_EXPANSION + end + + def replace_ruby + ruby = FileUtils::RUBY + FileUtils.send :remove_const, :RUBY + FileUtils.const_set :RUBY, RUBY + yield + ensure + FileUtils.send :remove_const, :RUBY + FileUtils.const_set:RUBY, ruby + end + + def shellcommand + command 'shellcommand.rb', <<-SHELLCOMMAND +#!/usr/bin/env ruby + +exit((ARGV[0] || "0").to_i) + SHELLCOMMAND + end + + def env_var + windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH' + end + + def windows? + ! File::ALT_SEPARATOR.nil? + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_ftp_file.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_ftp_file.rb new file mode 100644 index 000000000..5749b8a5e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_ftp_file.rb @@ -0,0 +1,74 @@ +require File.expand_path('../helper', __FILE__) +require 'date' +require 'time' +require 'rake/contrib/ftptools' + +class FakeDate + def self.today + Date.new(2003, 10, 3) + end + + def self.now + Time.local(2003, 10, 3, 12, 00, 00) + end +end + +class TestRakeFtpFile < Rake::TestCase + + def setup + super + + Rake::FtpFile.class_eval { + @date_class = FakeDate + @time_class = FakeDate + } + end + + def test_general + file = Rake::FtpFile.new( + "here", + "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl") + assert_equal "wiki.pl", file.name + assert_equal "here/wiki.pl", file.path + assert_equal "a279376", file.owner + assert_equal "develop", file.group + assert_equal 0644, file.mode + assert_equal 121_770, file.size + assert_equal Time.mktime(2003, 3, 6, 14, 50, 0, 0), file.time + assert ! file.directory? + assert ! file.symlink? + end + + def test_far_date + file = Rake::FtpFile.new( + ".", + "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss") + assert_equal Time.mktime(2001, 11, 26, 0, 0, 0, 0), file.time + end + + def test_close_date + file = Rake::FtpFile.new( + ".", + "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss") + assert_equal Time.mktime(2002, 11, 26, 15, 35, 0, 0), file.time + end + + def test_directory + file = Rake::FtpFile.new( + ".", + "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working") + assert file.directory? + assert !file.symlink? + end + + def test_symlink + file = Rake::FtpFile.new( + ".", + "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 " + + "xtrac -> /home/a279376/working/ics/development/java/" + + "com/fmr/fwp/ics/xtrac") + assert_equal 'xtrac', file.name + assert file.symlink? + assert !file.directory? + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_functional.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_functional.rb new file mode 100644 index 000000000..bf7ba92f7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_functional.rb @@ -0,0 +1,482 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' +require 'open3' + +class TestRakeFunctional < Rake::TestCase + include RubyRunner + + def setup + super + + if @verbose + puts + puts + puts '-' * 80 + puts @__name__ + puts '-' * 80 + end + end + + def test_rake_default + rakefile_default + + rake + + assert_match(/^DEFAULT$/, @out) + end + + def test_rake_error_on_bad_task + rakefile_default + + rake '-t', 'xyz' + + assert_match(/rake aborted/, @err) + end + + def test_env_available_at_top_scope + rakefile_default + + rake "TESTTOPSCOPE=1" + + assert_match(/^TOPSCOPE$/, @out) + end + + def test_env_available_at_task_scope + rakefile_default + + rake 'TESTTASKSCOPE=1', 'task_scope' + + assert_match(/^TASKSCOPE$/, @out) + end + + def test_multi_desc + ENV['RAKE_COLUMNS'] = '80' + rakefile_multidesc + + rake "-T" + + assert_match %r{^rake a *# A / A2 *$}, @out + assert_match %r{^rake b *# B *$}, @out + refute_match %r{^rake c}, @out + assert_match %r{^rake d *# x{65}\.\.\.$}, @out + end + + def test_long_description + rakefile_multidesc + + rake "--describe" + + assert_match %r{^rake a\n *A\n *A2 *$}m, @out + assert_match %r{^rake b\n *B *$}m, @out + assert_match %r{^rake d\n *x{80}}m, @out + refute_match %r{^rake c\n}m, @out + end + + def test_proper_namespace_access + rakefile_access + + rake + + refute_match %r{^BAD:}, @out + end + + def test_rbext + rakefile_rbext + + rake "-N" + + assert_match %r{^OK$}, @out + end + + def test_system + rake_system_dir + + rake '-g', "sys1" + + assert_match %r{^SYS1}, @out + end + + def test_system_excludes_rakelib_files_too + rake_system_dir + + rake '-g', "sys1", '-T', 'extra' + + refute_match %r{extra:extra}, @out + end + + def test_by_default_rakelib_files_are_included + rake_system_dir + rakefile_extra + + rake '-T', 'extra', '--trace' + + assert_match %r{extra:extra}, @out + end + + def test_implicit_system + rake_system_dir + Dir.chdir @tempdir + + rake "sys1", "--trace" + + assert_match %r{^SYS1}, @out + end + + def test_no_system + rake_system_dir + rakefile_extra + + rake '-G', "sys1" + + assert_match %r{^Don't know how to build task}, @err # emacs wart: ' + end + + def test_nosearch_with_rakefile_uses_local_rakefile + rakefile_default + + rake "--nosearch" + + assert_match %r{^DEFAULT}, @out + end + + def test_nosearch_without_rakefile_finds_system + rakefile_nosearch + rake_system_dir + + rake "--nosearch", "sys1" + + assert_match %r{^SYS1}, @out + end + + def test_nosearch_without_rakefile_and_no_system_fails + rakefile_nosearch + ENV['RAKE_SYSTEM'] = 'not_exist' + + rake "--nosearch" + + assert_match %r{^No Rakefile found}, @err + end + + def test_invalid_command_line_options + rakefile_default + + rake "--bad-options" + + assert_match %r{invalid +option}i, @err + end + + def test_inline_verbose_default_should_show_command + rakefile_verbose + + rake "inline_verbose_default" + + assert_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_inline_verbose_true_should_show_command + rakefile_verbose + + rake "inline_verbose_true" + + assert_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_inline_verbose_false_should_not_show_command + rakefile_verbose + + rake "inline_verbose_false" + + refute_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_block_verbose_false_should_not_show_command + rakefile_verbose + + rake "block_verbose_false" + + refute_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_block_verbose_true_should_show_command + rakefile_verbose + + rake "block_verbose_true" + + assert_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_standalone_verbose_true_should_show_command + rakefile_verbose + + rake "standalone_verbose_true" + + assert_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_standalone_verbose_false_should_not_show_command + rakefile_verbose + + rake "standalone_verbose_false" + + refute_match(/#{Regexp.quote(RUBY)} -e/, @err) + end + + def test_dry_run + rakefile_default + + rake "-n", "other" + + assert_match %r{Execute \(dry run\) default}, @err + assert_match %r{Execute \(dry run\) other}, @err + refute_match %r{DEFAULT}, @out + refute_match %r{OTHER}, @out + end + + # Test for the trace/dry_run bug found by Brian Chandler + def test_dry_run_bug + rakefile_dryrun + + rake + + FileUtils.rm_f 'temp_one' + + rake "--dry-run" + + refute_match(/No such file/, @out) + end + + # Test for the trace/dry_run bug found by Brian Chandler + def test_trace_bug + rakefile_dryrun + + rake + + FileUtils.rm_f 'temp_one' + + rake "--trace" + + refute_match(/No such file/, @out) + end + + def test_imports + rakefile_imports + + rake + + assert File.exist?(File.join(@tempdir, 'dynamic_deps')), + "'dynamic_deps' file should exist" + assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out) + end + + def test_regenerate_imports + rakefile_regenerate_imports + + rake + + assert_match(/^INITIAL\s+^REGENERATED$/, @out) + end + + def test_rules_chaining_to_file_task + rakefile_chains + + rake + + assert File.exist?(File.join(@tempdir, 'play.app')), + "'play.app' file should exist" + end + + def test_file_creation_task + rakefile_file_creation + + rake "prep" + rake "run" + rake "run" + + assert(@err !~ /^cp src/, "Should not recopy data") + end + + def test_dash_f_with_no_arg_foils_rakefile_lookup + rakefile_rakelib + + rake '-I', 'rakelib', '-rtest1', '-f' + + assert_match(/^TEST1$/, @out) + end + + def test_dot_rake_files_can_be_loaded_with_dash_r + rakefile_rakelib + + rake '-I', 'rakelib', '-rtest2', '-f' + + assert_empty @err + assert_match(/^TEST2$/, @out) + end + + def test_can_invoke_task_in_toplevel_namespace + rakefile_namespace + + rake "copy" + + assert_match(/^COPY$/, @out) + end + + def test_can_invoke_task_in_nested_namespace + rakefile_namespace + + rake "nest:copy" + + assert_match(/^NEST COPY$/, @out) + end + + def test_tasks_can_reference_task_in_same_namespace + rakefile_namespace + + rake "nest:xx" + + assert_match(/^NEST COPY$/m, @out) + end + + def test_tasks_can_reference_task_in_other_namespaces + rakefile_namespace + + rake "b:run" + + assert_match(/^IN A\nIN B$/m, @out) + end + + def test_anonymous_tasks_can_be_invoked_indirectly + rakefile_namespace + + rake "anon" + + assert_match(/^ANON COPY$/m, @out) + end + + def test_rake_namespace_refers_to_toplevel + rakefile_namespace + + rake "very:nested:run" + + assert_match(/^COPY$/m, @out) + end + + def test_file_task_are_not_scoped_by_namespaces + rakefile_namespace + + rake "xyz.rb" + + assert_match(/^XYZ1\nXYZ2$/m, @out) + end + + def test_file_task_dependencies_scoped_by_namespaces + rakefile_namespace + + rake "scopedep.rb" + + assert_match(/^PREPARE\nSCOPEDEP$/m, @out) + end + + def test_test_task_descriptions + rakefile_test_task + + rake "-T" + + assert_match(/custom test task description/, @out) + end + + def test_comment_before_task_acts_like_desc + rakefile_comments + + rake "-T" + + refute_match(/comment for t1/, @out) + end + + def test_comment_separated_from_task_by_blank_line_is_not_picked_up + rakefile_comments + + rake "-T" + + refute_match("t2", @out) + end + + def test_comment_after_desc_is_ignored + rakefile_comments + + rake "-T" + + assert_match("override comment for t3", @out) + end + + def test_comment_before_desc_is_ignored + rakefile_comments + + rake "-T" + + assert_match("override comment for t4", @out) + end + + def test_correct_number_of_tasks_reported + rakefile_comments + + rake "-T" + + assert_equal(2, @out.split(/\n/).grep(/t\d/).size) + end + + def test_file_list_is_requirable_separately + ruby '-rrake/file_list', '-e', 'puts Rake::FileList["a"].size' + assert_equal "1\n", @out + end + + def can_detect_signals? + system RUBY, '-e', 'Process.kill "TERM", $$' + status = $? + if @verbose + puts " SIG status = #{$?.inspect}" + puts " SIG status.respond_to?(:signaled?) = " + + "#{$?.respond_to?(:signaled?).inspect}" + puts " SIG status.signaled? = #{status.signaled?}" if + status.respond_to?(:signaled?) + end + status.respond_to?(:signaled?) && status.signaled? + end + + def test_signal_propagation_in_tests + if can_detect_signals? + rakefile_test_signal + rake + assert_match(/ATEST/, @out) + refute_match(/BTEST/, @out) + else + skip "Signal detect seems broken on this system" + end + end + + def test_failing_test_sets_exit_status + skip if uncertain_exit_status? + rakefile_failing_test_task + rake + assert @exit.exitstatus > 0, "should be non-zero" + end + + def test_stand_alone_filelist + rakefile_stand_alone_filelist + + run_ruby @ruby_options + ["stand_alone_filelist.rb"] + + assert_match(/^stand_alone_filelist\.rb$/, @out) + assert_equal 0, @exit.exitstatus unless uncertain_exit_status? + end + + private + + # We are unable to accurately verify that Rake returns a proper + # error exit status using popen3 in Ruby 1.8.7 and JRuby. This + # predicate function can be used to skip tests or assertions as + # needed. + def uncertain_exit_status? + RUBY_VERSION < "1.9" || defined?(JRUBY_VERSION) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_invocation_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_invocation_chain.rb new file mode 100644 index 000000000..0176339bd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_invocation_chain.rb @@ -0,0 +1,64 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeInvocationChain < Rake::TestCase + include Rake + + def setup + super + + @empty = InvocationChain.empty + + @first_member = "A" + @second_member = "B" + @one = @empty.append(@first_member) + @two = @one.append(@second_member) + end + + def test_conj_on_invocation_chains + list = InvocationChain.empty.conj("B").conj("A") + assert_equal InvocationChain.make("A", "B"), list + assert_equal InvocationChain, list.class + end + + def test_make_on_invocation_chains + assert_equal @empty, InvocationChain.make() + assert_equal @one, InvocationChain.make(@first_member) + assert_equal @two, InvocationChain.make(@second_member, @first_member) + end + + def test_append_with_one_argument + chain = @empty.append("A") + + assert_equal 'TOP => A', chain.to_s # HACK + end + + def test_append_one_circular + ex = assert_raises RuntimeError do + @one.append(@first_member) + end + assert_match(/circular +dependency/i, ex.message) + assert_match(/A.*=>.*A/, ex.message) + end + + def test_append_two_circular + ex = assert_raises RuntimeError do + @two.append(@first_member) + end + assert_match(/A.*=>.*B.*=>.*A/, ex.message) + end + + def test_member_eh_one + assert @one.member?(@first_member) + end + + def test_member_eh_two + assert @two.member?(@first_member) + assert @two.member?(@second_member) + end + + def test_to_s_empty + assert_equal "TOP", @empty.to_s + assert_equal "TOP => A", @one.to_s + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_late_time.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_late_time.rb new file mode 100644 index 000000000..4b910a708 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_late_time.rb @@ -0,0 +1,18 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeLateTime < Rake::TestCase + def test_late_time_comparisons + late = Rake::LATE + assert_equal late, late + assert late >= Time.now + assert late > Time.now + assert late != Time.now + assert Time.now < late + assert Time.now <= late + assert Time.now != late + end + + def test_to_s + assert_equal '', Rake::LATE.to_s + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_linked_list.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_linked_list.rb new file mode 100644 index 000000000..10957fba6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_linked_list.rb @@ -0,0 +1,84 @@ +require File.expand_path('../helper', __FILE__) + +class TestLinkedList < Rake::TestCase + include Rake + + def test_empty_list + empty = LinkedList::EMPTY + assert empty.empty?, "should be empty" + end + + def test_list_with_one_item + list = LinkedList.make(:one) + assert ! list.empty?, "should not be empty" + assert_equal :one, list.head + assert_equal LinkedList::EMPTY, list.tail + end + + def test_make_with_no_arguments + empty = LinkedList.make() + assert_equal LinkedList::EMPTY, empty + end + + def test_make_with_one_argument + list = LinkedList.make(:one) + assert ! list.empty? + assert_equal :one, list.head + assert_equal LinkedList::EMPTY, list.tail + end + + def test_make_with_two_arguments + list = LinkedList.make(:one, :two) + assert ! list.empty? + assert_equal :one, list.head + assert_equal :two, list.tail.head + assert_equal LinkedList::EMPTY, list.tail.tail + end + + def test_list_with_several_items + list = LinkedList.make(:one, :two, :three) + + assert ! list.empty?, "should not be empty" + assert_equal :one, list.head + assert_equal :two, list.tail.head + assert_equal :three, list.tail.tail.head + assert_equal LinkedList::EMPTY, list.tail.tail.tail + end + + def test_lists_are_structurally_equivalent + list = LinkedList.make(1, 2, 3) + same = LinkedList.make(1, 2, 3) + diff = LinkedList.make(1, 2, 4) + short = LinkedList.make(1, 2) + + assert_equal list, same + refute_equal list, diff + refute_equal list, short + refute_equal short, list + end + + def test_converstion_to_string + list = LinkedList.make(:one, :two, :three) + assert_equal "LL(one, two, three)", list.to_s + assert_equal "LL()", LinkedList.make().to_s + end + + def test_converstion_with_inspect + list = LinkedList.make(:one, :two, :three) + assert_equal "LL(:one, :two, :three)", list.inspect + assert_equal "LL()", LinkedList.make().inspect + end + + def test_lists_are_enumerable + list = LinkedList.make(1, 2, 3) + new_list = list.map { |item| item + 10 } + expected = [11, 12, 13] + assert_equal expected, new_list + end + + def test_conjunction + list = LinkedList.make.conj("C").conj("B").conj("A") + assert_equal LinkedList.make("A", "B", "C"), list + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_makefile_loader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_makefile_loader.rb new file mode 100644 index 000000000..9e9265ad1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_makefile_loader.rb @@ -0,0 +1,46 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/loaders/makefile' + +class TestRakeMakefileLoader < Rake::TestCase + include Rake + + def test_parse + Dir.chdir @tempdir + + open 'sample.mf', 'w' do |io| + io << <<-'SAMPLE_MF' +# Comments +a: a1 a2 a3 a4 +b: b1 b2 b3 \ + b4 b5 b6\ +# Mid: Comment +b7 + + a : a5 a6 a7 +c: c1 +d: d1 d2 \ + +e f : e1 f1 + +g\ 0: g1 g\ 2 g\ 3 g4 + SAMPLE_MF + end + + Task.clear + loader = Rake::MakefileLoader.new + loader.load 'sample.mf' + %w(a b c d).each do |t| + assert Task.task_defined?(t), "#{t} should be a defined task" + end + assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task['a'].prerequisites.sort + assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort + assert_equal %w(c1).sort, Task['c'].prerequisites.sort + assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort + assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort + assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort + assert_equal( + ["g1", "g 2", "g 3", "g4"].sort, + Task['g 0'].prerequisites.sort) + assert_equal 7, Task.tasks.size + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_multi_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_multi_task.rb new file mode 100644 index 000000000..9f8fed6d5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_multi_task.rb @@ -0,0 +1,64 @@ +require File.expand_path('../helper', __FILE__) +require 'thread' + +class TestRakeMultiTask < Rake::TestCase + include Rake + include Rake::DSL + + def setup + super + + Task.clear + @runs = Array.new + @mutex = Mutex.new + end + + def teardown + Rake.application.thread_pool.join + + super + end + + def add_run(obj) + @mutex.synchronize do + @runs << obj + end + end + + def test_running_multitasks + task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end + task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01; end end + multitask :both => [:a, :b] + Task[:both].invoke + assert_equal 6, @runs.size + assert @runs.index("A0") < @runs.index("A1") + assert @runs.index("A1") < @runs.index("A2") + assert @runs.index("B0") < @runs.index("B1") + assert @runs.index("B1") < @runs.index("B2") + end + + def test_all_multitasks_wait_on_slow_prerequisites + task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end + task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end + task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end + multitask :both => [:a, :b] + Task[:both].invoke + assert_equal 9, @runs.size + assert @runs.index("S0") < @runs.index("S1") + assert @runs.index("S1") < @runs.index("S2") + assert @runs.index("S2") < @runs.index("A0") + assert @runs.index("S2") < @runs.index("B0") + assert @runs.index("A0") < @runs.index("A1") + assert @runs.index("A1") < @runs.index("A2") + assert @runs.index("B0") < @runs.index("B1") + assert @runs.index("B1") < @runs.index("B2") + end + + def test_multitasks_with_parameters + task :a, [:arg] do |t, args| add_run(args[:arg]) end + multitask :b, [:arg] => [:a] do |t, args| add_run(args[:arg] + 'mt') end + Task[:b].invoke "b" + assert @runs[0] == "b" + assert @runs[1] == "bmt" + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_name_space.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_name_space.rb new file mode 100644 index 000000000..d35e70e17 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_name_space.rb @@ -0,0 +1,57 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeNameSpace < Rake::TestCase + + class TM + include Rake::TaskManager + end + + def test_namespace_creation + mgr = TM.new + ns = Rake::NameSpace.new(mgr, []) + refute_nil ns + end + + def test_namespace_lookup + mgr = TM.new + ns = mgr.in_namespace("n") do + mgr.define_task(Rake::Task, "t") + end + + refute_nil ns["t"] + assert_equal mgr["n:t"], ns["t"] + end + + def test_namespace_reports_tasks_it_owns + mgr = TM.new + nns = nil + ns = mgr.in_namespace("n") do + mgr.define_task(Rake::Task, :x) + mgr.define_task(Rake::Task, :y) + nns = mgr.in_namespace("nn") do + mgr.define_task(Rake::Task, :z) + end + end + mgr.in_namespace("m") do + mgr.define_task(Rake::Task, :x) + end + + assert_equal ["n:nn:z", "n:x", "n:y"], + ns.tasks.map { |tsk| tsk.name } + assert_equal ["n:nn:z"], nns.tasks.map { |t| t.name } + end + + def test_scope + mgr = TM.new + + scope = Rake::LinkedList.new 'b' + scope = scope.conj 'a' + + ns = Rake::NameSpace.new mgr, scope + + assert_equal scope, ns.scope + + refute_same scope, ns.scope + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_package_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_package_task.rb new file mode 100644 index 000000000..87cb57c10 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_package_task.rb @@ -0,0 +1,79 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/packagetask' + +class TestRakePackageTask < Rake::TestCase + + def test_initialize + touch 'install.rb' + touch 'a.c' + touch 'b.c' + mkdir 'CVS' + touch 'a.rb~' + + pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p| + p.package_files << "install.rb" + p.package_files.include '*.c' + p.package_files.exclude(/\bCVS\b/) + p.package_files.exclude(/~$/) + p.package_dir = 'pkg' + p.need_tar = true + p.need_tar_gz = true + p.need_tar_bz2 = true + p.need_zip = true + } + + assert_equal "pkg", pkg.package_dir + + assert_includes pkg.package_files, 'a.c' + + assert_equal 'pkgr', pkg.name + assert_equal '1.2.3', pkg.version + assert Rake::Task[:package] + assert Rake::Task['pkg/pkgr-1.2.3.tgz'] + assert Rake::Task['pkg/pkgr-1.2.3.tar.gz'] + assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2'] + assert Rake::Task['pkg/pkgr-1.2.3.zip'] + assert Rake::Task['pkg/pkgr-1.2.3'] + assert Rake::Task[:clobber_package] + assert Rake::Task[:repackage] + end + + def test_initialize_no_version + e = assert_raises RuntimeError do + Rake::PackageTask.new 'pkgr' + end + + assert_equal 'Version required (or :noversion)', e.message + end + + def test_initialize_noversion + pkg = Rake::PackageTask.new 'pkgr', :noversion + + assert_equal 'pkg', pkg.package_dir + assert_equal 'pkgr', pkg.name + assert_equal nil, pkg.version + end + + def test_clone + pkg = Rake::PackageTask.new("x", :noversion) + p2 = pkg.clone + pkg.package_files << "y" + p2.package_files << "x" + assert_equal ["y"], pkg.package_files + assert_equal ["x"], p2.package_files + end + + def test_package_name + pkg = Rake::PackageTask.new 'a', '1' + + assert_equal 'a-1', pkg.package_name + end + + def test_package_name_noversion + pkg = Rake::PackageTask.new 'a', :noversion + + assert_equal 'a', pkg.package_name + end + +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map.rb new file mode 100644 index 000000000..038ba1f9a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map.rb @@ -0,0 +1,168 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakePathMap < Rake::TestCase + + def test_returns_self_with_no_args + assert_equal "abc.rb", "abc.rb".pathmap + end + + def test_s_returns_file_separator + sep = File::ALT_SEPARATOR || File::SEPARATOR + assert_equal sep, "abc.rb".pathmap("%s") + assert_equal sep, "".pathmap("%s") + assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f") + end + + def test_f_returns_basename + assert_equal "abc.rb", "abc.rb".pathmap("%f") + assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f") + assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f") + end + + def test_n_returns_basename_without_extension + assert_equal "abc", "abc.rb".pathmap("%n") + assert_equal "abc", "abc".pathmap("%n") + assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n") + assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n") + assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n") + end + + def test_d_returns_dirname + assert_equal ".", "abc.rb".pathmap("%d") + assert_equal "/", "/abc".pathmap("%d") + assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d") + assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d") + end + + def test_9d_returns_partial_dirname + assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d") + assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d") + assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d") + assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d") + assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d") + assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d") + assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d") + end + + def test_x_returns_extension + assert_equal "", "abc".pathmap("%x") + assert_equal ".rb", "abc.rb".pathmap("%x") + assert_equal ".rb", "abc.xyz.rb".pathmap("%x") + assert_equal "", ".depends".pathmap("%x") + assert_equal "", "dir/.depends".pathmap("%x") + end + + def test_x_returns_everything_but_extension + assert_equal "abc", "abc".pathmap("%X") + assert_equal "abc", "abc.rb".pathmap("%X") + assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X") + assert_equal "ab.xyz", "ab.xyz.rb".pathmap("%X") + assert_equal "a.xyz", "a.xyz.rb".pathmap("%X") + assert_equal "abc", "abc.rb".pathmap("%X") + assert_equal "ab", "ab.rb".pathmap("%X") + assert_equal "a", "a.rb".pathmap("%X") + assert_equal ".depends", ".depends".pathmap("%X") + assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X") + assert_equal "/.depends", "/.depends".pathmap("%X") + end + + def test_p_returns_entire_pathname + assert_equal "abc.rb", "abc.rb".pathmap("%p") + assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p") + assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p") + end + + def test_dash_returns_empty_string + assert_equal "", "abc.rb".pathmap("%-") + assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x") + end + + def test_percent_percent_returns_percent + assert_equal "a%b", "".pathmap("a%%b") + end + + def test_undefined_percent_causes_error + assert_raises(ArgumentError) { + "dir/abc.rb".pathmap("%z") + } + end + + def test_pattern_returns_substitutions + assert_equal "bin/org/osb", + "src/org/osb/Xyz.java".pathmap("%{src,bin}d") + end + + def test_pattern_can_use_backreferences + assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p") + end + + def test_pattern_with_star_replacement_string_uses_block + assert_equal "src/ORG/osb", + "src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase } + assert_equal "Xyz.java", + "src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize } + end + + def test_pattern_with_no_replacement_nor_block_substitutes_empty_string + assert_equal "bc.rb", "abc.rb".pathmap("%{a}f") + end + + def test_pattern_works_with_certain_valid_operators + assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p") + assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d") + assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f") + assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x") + assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n") + end + + def test_multiple_patterns + assert_equal "this/is/b/directory/abc.rb", + "this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p") + end + + def test_partial_directory_selection_works_with_patterns + assert_equal "this/is/a/long", + "this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d") + end + + def test_pattern_with_invalid_operator + ex = assert_raises(ArgumentError) do + "abc.xyz".pathmap("%{src,bin}z") + end + assert_match(/unknown.*pathmap.*spec.*z/i, ex.message) + end + + def test_works_with_windows_separators + if File::ALT_SEPARATOR + assert_equal "abc", 'dir\abc.rb'.pathmap("%n") + assert_equal 'this\is\a\dir', + 'this\is\a\dir\abc.rb'.pathmap("%d") + end + end + + def test_complex_patterns + sep = "".pathmap("%s") + assert_equal( + "dir/abc.rb", + "dir/abc.rb".pathmap("%d/%n%x")) + assert_equal( + "./abc.rb", + "abc.rb".pathmap("%d/%n%x")) + assert_equal( + "Your file extension is '.rb'", + "dir/abc.rb".pathmap("Your file extension is '%x'")) + assert_equal( + "bin/org/onstepback/proj/A.class", + "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")) + assert_equal( + "src_work/bin/org/onstepback/proj/A.class", + "src_work/src/org/onstepback/proj/A.java". + pathmap('%{\bsrc\b,bin}X.class')) + assert_equal( + ".depends.bak", + ".depends".pathmap("%X.bak")) + assert_equal( + "d#{sep}a/b/c#{sep}file.txt", + "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_explode.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_explode.rb new file mode 100644 index 000000000..a79235ee7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_explode.rb @@ -0,0 +1,34 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakePathMapExplode < Rake::TestCase + def setup + super + + String.class_eval { public :pathmap_explode } + end + + def teardown + String.class_eval { protected :pathmap_explode } + + super + end + + def test_explode + assert_equal ['a'], 'a'.pathmap_explode + assert_equal ['a', 'b'], 'a/b'.pathmap_explode + assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode + assert_equal ['/', 'a'], '/a'.pathmap_explode + assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode + assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode + + if File::ALT_SEPARATOR + assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode + assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode + assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode + assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode + assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode + assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode + end + end +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_partial.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_partial.rb new file mode 100644 index 000000000..566e681bb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_path_map_partial.rb @@ -0,0 +1,18 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakePathMapPartial < Rake::TestCase + def test_pathmap_partial + @path = "1/2/file" + def @path.call(n) + pathmap_partial(n) + end + assert_equal("1", @path.call(1)) + assert_equal("1/2", @path.call(2)) + assert_equal("1/2", @path.call(3)) + assert_equal(".", @path.call(0)) + assert_equal("2", @path.call(-1)) + assert_equal("1/2", @path.call(-2)) + assert_equal("1/2", @path.call(-3)) + end +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pathname_extensions.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pathname_extensions.rb new file mode 100644 index 000000000..7da702d0c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pathname_extensions.rb @@ -0,0 +1,15 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/ext/pathname' + +class TestRakePathnameExtensions < Rake::TestCase + def test_ext_works_on_pathnames + pathname = Pathname.new("abc.foo") + assert_equal Pathname.new("abc.bar"), pathname.ext("bar") + end + + def test_path_map_works_on_pathnames + pathname = Pathname.new("this/is/a/dir/abc.rb") + assert_equal Pathname.new("abc.rb"), pathname.pathmap("%f") + assert_equal Pathname.new("this/is/a/dir"), pathname.pathmap("%d") + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pseudo_status.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pseudo_status.rb new file mode 100644 index 000000000..51b3fef34 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_pseudo_status.rb @@ -0,0 +1,21 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakePseudoStatus < Rake::TestCase + def test_with_zero_exit_status + s = Rake::PseudoStatus.new + assert_equal 0, s.exitstatus + assert_equal 0, s.to_i + assert_equal 0, s >> 8 + refute s.stopped? + assert s.exited? + end + + def test_with_99_exit_status + s = Rake::PseudoStatus.new(99) + assert_equal 99, s.exitstatus + assert_equal 25344, s.to_i + assert_equal 99, s >> 8 + refute s.stopped? + assert s.exited? + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rake_test_loader.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rake_test_loader.rb new file mode 100644 index 000000000..0485c4c8a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rake_test_loader.rb @@ -0,0 +1,20 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeRakeTestLoader < Rake::TestCase + + def test_pattern + orig_loaded_features = $:.dup + FileUtils.touch 'foo.rb' + FileUtils.touch 'test_a.rb' + FileUtils.touch 'test_b.rb' + + ARGV.replace %w[foo.rb test_*.rb -v] + + load File.join(@rake_lib, 'rake/rake_test_loader.rb') + + assert_equal %w[-v], ARGV + ensure + $:.replace orig_loaded_features + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_reduce_compat.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_reduce_compat.rb new file mode 100644 index 000000000..d29526654 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_reduce_compat.rb @@ -0,0 +1,26 @@ +require File.expand_path('../helper', __FILE__) +require 'open3' + +class TestRakeReduceCompat < Rake::TestCase + include RubyRunner + + def invoke_normal(task_name) + rake task_name.to_s + @out + end + + def test_no_deprecated_dsl + rakefile %q{ + task :check_task do + Module.new { p defined?(task) } + end + + task :check_file do + Module.new { p defined?(file) } + end + } + + assert_equal "nil", invoke_normal(:check_task).chomp + assert_equal "nil", invoke_normal(:check_file).chomp + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_require.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_require.rb new file mode 100644 index 000000000..d229edbc2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_require.rb @@ -0,0 +1,40 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeRequire < Rake::TestCase + + def test_can_load_rake_library + rakefile_rakelib + app = Rake::Application.new + + assert app.instance_eval { + rake_require("test2", ['rakelib'], []) + } + end + + def test_wont_reload_rake_library + rakefile_rakelib + app = Rake::Application.new + + paths = ['rakelib'] + loaded_files = [] + app.rake_require("test2", paths, loaded_files) + + assert ! app.instance_eval { + rake_require("test2", paths, loaded_files) + } + end + + def test_throws_error_if_library_not_found + rakefile_rakelib + + app = Rake::Application.new + ex = assert_raises(LoadError) { + assert app.instance_eval { + rake_require("testx", ['rakelib'], []) + } + } + assert_match(/(can *not|can't)\s+find/i, ex.message) + assert_match(/testx/, ex.message) + end +end + diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rules.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rules.rb new file mode 100644 index 000000000..ece75e5d9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_rules.rb @@ -0,0 +1,388 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' + +class TestRakeRules < Rake::TestCase + include Rake + + SRCFILE = "abc.c" + SRCFILE2 = "xyz.c" + FTNFILE = "abc.f" + OBJFILE = "abc.o" + FOOFILE = "foo" + DOTFOOFILE = ".foo" + + def setup + super + + Task.clear + @runs = [] + end + + def test_multiple_rules1 + create_file(FTNFILE) + delete_file(SRCFILE) + delete_file(OBJFILE) + rule(/\.o$/ => ['.c']) do @runs << :C end + rule(/\.o$/ => ['.f']) do @runs << :F end + t = Task[OBJFILE] + t.invoke + Task[OBJFILE].invoke + assert_equal [:F], @runs + end + + def test_multiple_rules2 + create_file(FTNFILE) + delete_file(SRCFILE) + delete_file(OBJFILE) + rule(/\.o$/ => ['.f']) do @runs << :F end + rule(/\.o$/ => ['.c']) do @runs << :C end + Task[OBJFILE].invoke + assert_equal [:F], @runs + end + + def test_create_with_source + create_file(SRCFILE) + rule(/\.o$/ => ['.c']) do |t| + @runs << t.name + assert_equal OBJFILE, t.name + assert_equal SRCFILE, t.source + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + + def test_single_dependent + create_file(SRCFILE) + rule(/\.o$/ => '.c') do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + + def test_rule_can_be_created_by_string + create_file(SRCFILE) + rule '.o' => ['.c'] do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + + def test_rule_prereqs_can_be_created_by_string + create_file(SRCFILE) + rule '.o' => '.c' do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + + def test_plain_strings_as_dependents_refer_to_files + create_file(SRCFILE) + rule '.o' => SRCFILE do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + + def test_file_names_beginning_with_dot_can_be_tricked_into_referring_to_file + verbose(false) do + create_file('.foo') + rule '.o' => "./.foo" do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + end + + def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda + verbose(false) do + + create_file(".foo") + rule '.o' => lambda { ".foo" } do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - .foo"], @runs + end + end + + def test_file_names_containing_percent_can_be_wrapped_in_lambda + verbose(false) do + create_file("foo%x") + rule '.o' => lambda { "foo%x" } do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - foo%x"], @runs + end + end + + def test_non_extension_rule_name_refers_to_file + verbose(false) do + create_file("abc.c") + rule "abc" => '.c' do |t| + @runs << t.name + end + Task["abc"].invoke + assert_equal ["abc"], @runs + end + end + + def test_pathmap_automatically_applies_to_name + verbose(false) do + create_file("zzabc.c") + rule ".o" => 'zz%{x,a}n.c' do |t| + @runs << "#{t.name} - #{t.source}" + end + Task["xbc.o"].invoke + assert_equal ["xbc.o - zzabc.c"], @runs + end + end + + def test_plain_strings_are_just_filenames + verbose(false) do + create_file("plainname") + rule ".o" => 'plainname' do |t| + @runs << "#{t.name} - #{t.source}" + end + Task["xbc.o"].invoke + assert_equal ["xbc.o - plainname"], @runs + end + end + + def test_rule_runs_when_explicit_task_has_no_actions + create_file(SRCFILE) + create_file(SRCFILE2) + delete_file(OBJFILE) + rule '.o' => '.c' do |t| + @runs << t.source + end + file OBJFILE => [SRCFILE2] + Task[OBJFILE].invoke + assert_equal [SRCFILE], @runs + end + + def test_close_matches_on_name_do_not_trigger_rule + create_file("x.c") + rule '.o' => ['.c'] do |t| + @runs << t.name + end + assert_raises(RuntimeError) { Task['x.obj'].invoke } + assert_raises(RuntimeError) { Task['x.xyo'].invoke } + end + + def test_rule_rebuilds_obj_when_source_is_newer + create_timed_files(OBJFILE, SRCFILE) + rule(/\.o$/ => ['.c']) do + @runs << :RULE + end + Task[OBJFILE].invoke + assert_equal [:RULE], @runs + end + + def test_rule_with_two_sources_runs_if_both_sources_are_present + create_timed_files(OBJFILE, SRCFILE, SRCFILE2) + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do + @runs << :RULE + end + Task[OBJFILE].invoke + assert_equal [:RULE], @runs + end + + def test_rule_with_two_sources_but_one_missing_does_not_run + create_timed_files(OBJFILE, SRCFILE) + delete_file(SRCFILE2) + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do + @runs << :RULE + end + Task[OBJFILE].invoke + assert_equal [], @runs + end + + def test_rule_with_two_sources_builds_both_sources + task 'x.aa' + task 'x.bb' + rule '.a' => '.aa' do + @runs << "A" + end + rule '.b' => '.bb' do + @runs << "B" + end + rule ".c" => ['.a', '.b'] do + @runs << "C" + end + Task["x.c"].invoke + assert_equal ["A", "B", "C"], @runs.sort + end + + def test_second_rule_runs_when_first_rule_doesnt + create_timed_files(OBJFILE, SRCFILE) + delete_file(SRCFILE2) + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do + @runs << :RULE1 + end + rule OBJFILE => [lambda { SRCFILE }] do + @runs << :RULE2 + end + Task[OBJFILE].invoke + assert_equal [:RULE2], @runs + end + + def test_second_rule_doest_run_if_first_triggers + create_timed_files(OBJFILE, SRCFILE, SRCFILE2) + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do + @runs << :RULE1 + end + rule OBJFILE => [lambda { SRCFILE }] do + @runs << :RULE2 + end + Task[OBJFILE].invoke + assert_equal [:RULE1], @runs + end + + def test_second_rule_doest_run_if_first_triggers_with_reversed_rules + create_timed_files(OBJFILE, SRCFILE, SRCFILE2) + rule OBJFILE => [lambda { SRCFILE }] do + @runs << :RULE1 + end + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do + @runs << :RULE2 + end + Task[OBJFILE].invoke + assert_equal [:RULE1], @runs + end + + def test_rule_with_proc_dependent_will_trigger + mkdir_p("src/jw") + create_file("src/jw/X.java") + rule %r(classes/.*\.class) => [ + proc { |fn| fn.pathmap("%{classes,src}d/%n.java") } + ] do |task| + assert_equal task.name, 'classes/jw/X.class' + assert_equal task.source, 'src/jw/X.java' + @runs << :RULE + end + Task['classes/jw/X.class'].invoke + assert_equal [:RULE], @runs + ensure + rm_r("src", :verbose=>false) rescue nil + end + + def test_proc_returning_lists_are_flattened_into_prereqs + ran = false + mkdir_p("flatten") + create_file("flatten/a.txt") + task 'flatten/b.data' do |t| + ran = true + touch t.name, :verbose => false + end + rule '.html' => + proc { |fn| + [ + fn.ext("txt"), + "flatten/b.data" + ] + } do |task| + end + Task['flatten/a.html'].invoke + assert ran, "Should have triggered flattened dependency" + ensure + rm_r("flatten", :verbose=>false) rescue nil + end + + def test_recursive_rules_will_work_as_long_as_they_terminate + actions = [] + create_file("abc.xml") + rule '.y' => '.xml' do actions << 'y' end + rule '.c' => '.y' do actions << 'c'end + rule '.o' => '.c' do actions << 'o'end + rule '.exe' => '.o' do actions << 'exe'end + Task["abc.exe"].invoke + assert_equal ['y', 'c', 'o', 'exe'], actions + end + + def test_recursive_rules_that_dont_terminate_will_overflow + create_file("a.a") + prev = 'a' + ('b'..'z').each do |letter| + rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end + prev = letter + end + ex = assert_raises(Rake::RuleRecursionOverflowError) { + Task["a.z"].invoke + } + assert_match(/a\.z => a.y/, ex.message) + end + + def test_rules_with_bad_dependents_will_fail + rule "a" => [1] do |t| puts t.name end + assert_raises(RuntimeError) do Task['a'].invoke end + end + + def test_string_rule_with_args + delete_file(OBJFILE) + create_file(SRCFILE) + rule '.o', [:a] => SRCFILE do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_regex_rule_with_args + delete_file(OBJFILE) + create_file(SRCFILE) + rule(/.o$/, [:a] => SRCFILE) do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_string_rule_with_args_and_lambda_prereq + delete_file(OBJFILE) + create_file(SRCFILE) + rule '.o', [:a] => [lambda{SRCFILE}]do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_regex_rule_with_args_and_lambda_prereq + delete_file(OBJFILE) + create_file(SRCFILE) + rule(/.o$/, [:a] => [lambda{SRCFILE}]) do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_rule_with_method_prereq + create_file(".foo") + obj = Object.new + def obj.find_prereq + ".foo" + end + rule '.o' => obj.method(:find_prereq) do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - .foo"], @runs + end + + def test_rule_with_one_arg_method_prereq + create_file(SRCFILE) + obj = Object.new + def obj.find_prereq(task_name) + task_name.ext(".c") + end + rule '.o' => obj.method(:find_prereq) do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - abc.c"], @runs + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_scope.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_scope.rb new file mode 100644 index 000000000..ef06618ba --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_scope.rb @@ -0,0 +1,44 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeScope < Rake::TestCase + include Rake + + def test_path_against_empty_scope + scope = Scope.make + assert_equal scope, Scope::EMPTY + assert_equal scope.path, "" + end + + def test_path_against_one_element + scope = Scope.make(:one) + assert_equal "one", scope.path + end + + def test_path_against_two_elements + scope = Scope.make(:inner, :outer) + assert_equal "outer:inner", scope.path + end + + def test_path_with_task_name + scope = Scope.make(:inner, :outer) + assert_equal "outer:inner:task", scope.path_with_task_name("task") + end + + def test_path_with_task_name_against_empty_scope + scope = Scope.make + assert_equal "task", scope.path_with_task_name("task") + end + + def test_conj_against_two_elements + scope = Scope.make.conj("B").conj("A") + assert_equal Scope.make("A", "B"), scope + end + + def test_trim + scope = Scope.make("A", "B") + assert_equal scope, scope.trim(0) + assert_equal scope.tail, scope.trim(1) + assert_equal scope.tail.tail, scope.trim(2) + assert_equal scope.tail.tail, scope.trim(3) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task.rb new file mode 100644 index 000000000..d7f14efcd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task.rb @@ -0,0 +1,393 @@ +require File.expand_path('../helper', __FILE__) +require 'fileutils' + +class TestRakeTask < Rake::TestCase + include Rake + + def setup + super + + Task.clear + Rake::TaskManager.record_task_metadata = true + end + + def teardown + Rake::TaskManager.record_task_metadata = false + Rake.application.thread_pool.join + + super + end + + def test_create + arg = nil + t = task(:name) { |task| arg = task; 1234 } + assert_equal "name", t.name + assert_equal [], t.prerequisites + assert t.needed? + t.execute(0) + assert_equal t, arg + assert_nil t.source + assert_equal [], t.sources + assert_equal 1, t.locations.size + assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first) + end + + def test_inspect + t = task(:foo => [:bar, :baz]) + assert_equal " [bar, baz]>", t.inspect + end + + def test_invoke + runlist = [] + t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } + task(:t2) { |t| runlist << t.name } + task(:t3) { |t| runlist << t.name } + assert_equal ["t2", "t3"], t1.prerequisites + t1.invoke + assert_equal ["t2", "t3", "t1"], runlist + end + + def test_invoke_with_circular_dependencies + runlist = [] + t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 } + t2 = task(:t2 => [:t1]) { |t| runlist << t.name } + assert_equal ["t2"], t1.prerequisites + assert_equal ["t1"], t2.prerequisites + ex = assert_raises RuntimeError do + t1.invoke + end + assert_match(/circular dependency/i, ex.message) + assert_match(/t1 => t2 => t1/, ex.message) + end + + def test_dry_run_prevents_actions + Rake.application.options.dryrun = true + runlist = [] + t1 = task(:t1) { |t| runlist << t.name; 3321 } + _, err = capture_io { t1.invoke } + assert_match(/execute .*t1/i, err) + assert_match(/dry run/i, err) + refute_match(/invoke/i, err) + assert_equal [], runlist + ensure + Rake.application.options.dryrun = false + end + + def test_tasks_can_be_traced + Rake.application.options.trace = true + t1 = task(:t1) + _, err = capture_io { + t1.invoke + } + assert_match(/invoke t1/i, err) + assert_match(/execute t1/i, err) + ensure + Rake.application.options.trace = false + end + + def test_no_double_invoke + runlist = [] + t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } + task(:t2 => [:t3]) { |t| runlist << t.name } + task(:t3) { |t| runlist << t.name } + t1.invoke + assert_equal ["t3", "t2", "t1"], runlist + end + + def test_can_double_invoke_with_reenable + runlist = [] + t1 = task(:t1) { |t| runlist << t.name } + t1.invoke + t1.reenable + t1.invoke + assert_equal ["t1", "t1"], runlist + end + + def test_clear + desc "a task" + t = task("t" => "a") { } + t.clear + assert t.prerequisites.empty?, "prerequisites should be empty" + assert t.actions.empty?, "actions should be empty" + assert_nil t.comment, "comments should be empty" + end + + def test_clear_prerequisites + t = task("t" => ["a", "b"]) + assert_equal ['a', 'b'], t.prerequisites + t.clear_prerequisites + assert_equal [], t.prerequisites + end + + def test_clear_actions + t = task("t") { } + t.clear_actions + assert t.actions.empty?, "actions should be empty" + end + + def test_clear_comments + desc "the original foo" + task :foo => [:x] do + # Dummy action + end + + task(:foo).clear_comments + + desc "a slightly different foo" + task :foo + + assert_equal "a slightly different foo", task(:foo).comment + assert_equal ["x"], task(:foo).prerequisites + assert_equal 1, task(:foo).actions.size + end + + def test_find + task :tfind + assert_equal "tfind", Task[:tfind].name + ex = assert_raises(RuntimeError) { Task[:leaves] } + assert_equal "Don't know how to build task 'leaves'", ex.message + end + + def test_defined + assert ! Task.task_defined?(:a) + task :a + assert Task.task_defined?(:a) + end + + def test_multi_invocations + runs = [] + p = proc do |t| runs << t.name end + task({ :t1 => [:t2, :t3] }, &p) + task({ :t2 => [:t3] }, &p) + task(:t3, &p) + Task[:t1].invoke + assert_equal ["t1", "t2", "t3"], runs.sort + end + + def test_task_list + task :t2 + task :t1 => [:t2] + assert_equal ["t1", "t2"], Task.tasks.map { |t| t.name } + end + + def test_task_gives_name_on_to_s + task :abc + assert_equal "abc", Task[:abc].to_s + end + + def test_symbols_can_be_prerequisites + task :a => :b + assert_equal ["b"], Task[:a].prerequisites + end + + def test_strings_can_be_prerequisites + task :a => "b" + assert_equal ["b"], Task[:a].prerequisites + end + + def test_arrays_can_be_prerequisites + task :a => ["b", "c"] + assert_equal ["b", "c"], Task[:a].prerequisites + end + + def test_filelists_can_be_prerequisites + task :a => FileList.new.include("b", "c") + assert_equal ["b", "c"], Task[:a].prerequisites + end + + def test_prerequiste_tasks_returns_tasks_not_strings + a = task :a => ["b", "c"] + b = task :b + c = task :c + assert_equal [b, c], a.prerequisite_tasks + end + + def test_prerequiste_tasks_fails_if_prerequisites_are_undefined + a = task :a => ["b", "c"] + task :b + assert_raises(RuntimeError) do + a.prerequisite_tasks + end + end + + def test_prerequiste_tasks_honors_namespaces + a = b = nil + namespace "X" do + a = task :a => ["b", "c"] + b = task :b + end + c = task :c + + assert_equal [b, c], a.prerequisite_tasks + end + + def test_all_prerequisite_tasks_includes_all_prerequisites + a = task :a => "b" + b = task :b => ["c", "d"] + c = task :c => "e" + d = task :d + e = task :e + + assert_equal [b, c, d, e], a.all_prerequisite_tasks.sort_by { |t| t.name } + end + + def test_all_prerequisite_tasks_does_not_include_duplicates + a = task :a => ["b", "c"] + b = task :b => "c" + c = task :c + + assert_equal [b, c], a.all_prerequisite_tasks.sort_by { |t| t.name } + end + + def test_all_prerequisite_tasks_includes_self_on_cyclic_dependencies + a = task :a => "b" + b = task :b => "a" + + assert_equal [a, b], a.all_prerequisite_tasks.sort_by { |t| t.name } + end + + def test_timestamp_returns_now_if_all_prereqs_have_no_times + a = task :a => ["b", "c"] + task :b + task :c + + assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?' + end + + def test_timestamp_returns_latest_prereq_timestamp + a = task :a => ["b", "c"] + b = task :b + c = task :c + + now = Time.now + def b.timestamp() Time.now + 10 end + def c.timestamp() Time.now + 5 end + + assert_in_delta now, a.timestamp, 0.1, 'computer too slow?' + end + + def test_always_multitask + mx = Mutex.new + result = [] + + t_a = task(:a) do |t| + sleep 0.2 + mx.synchronize { result << t.name } + end + + t_b = task(:b) do |t| + mx.synchronize { result << t.name } + end + + t_c = task(:c => [:a, :b]) do |t| + mx.synchronize { result << t.name } + end + + t_c.invoke + + # task should always run in order + assert_equal ['a', 'b', 'c'], result + + [t_a, t_b, t_c].each { |t| t.reenable } + result.clear + + Rake.application.options.always_multitask = true + t_c.invoke + + # with multitask, task 'b' should grab the mutex first + assert_equal ['b', 'a', 'c'], result + end + + def test_investigation_output + t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } + task(:t2) + task(:t3) + out = t1.investigation + assert_match(/class:\s*Rake::Task/, out) + assert_match(/needed:\s*true/, out) + assert_match(/pre-requisites:\s*--t[23]/, out) + end + + # NOTE: Rail-ties uses comment=. + def test_comment_setting + t = task(:t, :name, :rev) + t.comment = "A Comment" + assert_equal "A Comment", t.comment + end + + def test_comments_with_sentences + desc "Comment 1. Comment 2." + t = task(:t, :name, :rev) + assert_equal "Comment 1", t.comment + end + + def test_comments_with_tabbed_sentences + desc "Comment 1.\tComment 2." + t = task(:t, :name, :rev) + assert_equal "Comment 1", t.comment + end + + def test_comments_with_decimal_points + desc "Revision 1.2.3." + t = task(:t, :name, :rev) + assert_equal "Revision 1.2.3", t.comment + end + + def test_comments_do_not_set + t = task(:t, :name, :rev) + assert_equal nil, t.comment + end + + def test_comments_is_nil + t = task(:t, :name, :rev) + t.comment = nil + assert_equal nil, t.comment + end + + def test_extended_comments + desc %{ + This is a comment. + + And this is the extended comment. + name -- Name of task to execute. + rev -- Software revision to use. + } + t = task(:t, :name, :rev) + assert_equal "[name,rev]", t.arg_description + assert_equal "This is a comment", t.comment + assert_match(/^\s*name -- Name/, t.full_comment) + assert_match(/^\s*rev -- Software/, t.full_comment) + assert_match(/\A\s*This is a comment\.$/, t.full_comment) + end + + def test_multiple_comments + desc "line one" + t = task(:t) + desc "line two" + task(:t) + assert_equal "line one / line two", t.comment + end + + def test_duplicate_comments + desc "line one" + t = task(:t) + desc "line one" + task(:t) + assert_equal "line one", t.comment + end + + def test_interspersed_duplicate_comments + desc "line one" + t = task(:t) + desc "line two" + task(:t) + desc "line one" + task(:t) + assert_equal "line one / line two", t.comment + end + + def test_source_is_first_prerequisite + t = task :t => ["preqA", "preqB"] + assert_equal "preqA", t.source + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_argument_parsing.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_argument_parsing.rb new file mode 100644 index 000000000..3cb5d9cfe --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_argument_parsing.rb @@ -0,0 +1,119 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTaskArgumentParsing < Rake::TestCase + def setup + super + + @app = Rake::Application.new + end + + def test_name_only + name, args = @app.parse_task_string("name") + assert_equal "name", name + assert_equal [], args + end + + def test_empty_args + name, args = @app.parse_task_string("name[]") + assert_equal "name", name + assert_equal [], args + end + + def test_one_argument + name, args = @app.parse_task_string("name[one]") + assert_equal "name", name + assert_equal ["one"], args + end + + def test_two_arguments + name, args = @app.parse_task_string("name[one,two]") + assert_equal "name", name + assert_equal ["one", "two"], args + end + + def test_can_handle_spaces_between_args + name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]") + assert_equal "name", name + assert_equal ["one", "two", "three", "four"], args + end + + def test_keeps_embedded_spaces + name, args = @app.parse_task_string("name[a one ana, two]") + assert_equal "name", name + assert_equal ["a one ana", "two"], args + end + + def test_can_handle_commas_in_args + name, args = @app.parse_task_string("name[one, two, three_a\\, three_b, four]") + assert_equal "name", name + assert_equal ["one", "two", "three_a, three_b", "four"], args + end + + def test_treat_blank_arg_as_empty_string + name, args = @app.parse_task_string("name[one,]") + assert_equal "name", name + assert_equal ["one", ""], args + + name, args = @app.parse_task_string("name[one,,two]") + assert_equal "name", name + assert_equal ["one", "", "two"], args + end + + def test_terminal_width_using_env + app = Rake::Application.new + app.terminal_columns = 1234 + + assert_equal 1234, app.terminal_width + end + + def test_terminal_width_using_stty + def @app.unix?() true end + def @app.dynamic_width_stty() 1235 end + def @app.dynamic_width_tput() 0 end + + assert_equal 1235, @app.terminal_width + end + + def test_terminal_width_using_tput + def @app.unix?() true end + def @app.dynamic_width_stty() 0 end + def @app.dynamic_width_tput() 1236 end + + assert_equal 1236, @app.terminal_width + end + + def test_terminal_width_using_hardcoded_80 + def @app.unix?() false end + + assert_equal 80, @app.terminal_width + end + + def test_terminal_width_with_failure + def @app.unix?() raise end + + assert_equal 80, @app.terminal_width + end + + def test_no_rakeopt + ARGV << '--trace' + app = Rake::Application.new + app.init + assert !app.options.silent + end + + def test_rakeopt_with_blank_options + ARGV << '--trace' + app = Rake::Application.new + app.init + assert !app.options.silent + end + + def test_rakeopt_with_silent_options + ENV['RAKEOPT'] = '-s' + app = Rake::Application.new + + app.init + + assert app.options.silent + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_arguments.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_arguments.rb new file mode 100644 index 000000000..369ecf6e5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_arguments.rb @@ -0,0 +1,127 @@ +require File.expand_path('../helper', __FILE__) + +###################################################################### +class TestRakeTaskArguments < Rake::TestCase + def teardown + ENV.delete('rev') + ENV.delete('VER') + + super + end + + def test_empty_arg_list_is_empty + ta = Rake::TaskArguments.new([], []) + assert_equal({}, ta.to_hash) + end + + def test_multiple_values_in_args + ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three]) + assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash) + end + + def test_has_key + ta = Rake::TaskArguments.new([:a], [:one]) + assert(ta.has_key?(:a)) + refute(ta.has_key?(:b)) + end + + def test_to_s + ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3]) + assert_equal ta.to_hash.inspect, ta.to_s + assert_equal ta.to_hash.inspect, ta.inspect + end + + def test_enumerable_behavior + ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3]) + assert_equal [10, 20, 30], ta.map { |k, v| v * 10 }.sort + end + + def test_named_args + ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2]) + assert_equal 1, ta.aa + assert_equal 1, ta[:aa] + assert_equal 1, ta["aa"] + assert_equal 2, ta.bb + assert_nil ta.cc + end + + def test_args_knows_its_names + ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2]) + assert_equal ["aa", "bb"], ta.names + end + + def test_extra_names_are_nil + ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2]) + assert_nil ta.cc + end + + def test_args_do_not_reference_env_values + ta = Rake::TaskArguments.new(["aa"], [1]) + ENV['rev'] = "1.2" + ENV['VER'] = "2.3" + assert_nil ta.rev + assert_nil ta.ver + end + + def test_creating_new_argument_scopes + parent = Rake::TaskArguments.new(['p'], [1]) + child = parent.new_scope(['c', 'p']) + assert_equal({:p=>1}, child.to_hash) + assert_equal 1, child.p + assert_equal 1, child["p"] + assert_equal 1, child[:p] + assert_nil child.c + end + + def test_child_hides_parent_arg_names + parent = Rake::TaskArguments.new(['aa'], [1]) + child = Rake::TaskArguments.new(['aa'], [2], parent) + assert_equal 2, child.aa + end + + def test_default_arguments_values_can_be_merged + ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) + ta.with_defaults({ :aa => 'default_val' }) + assert_equal 'default_val', ta[:aa] + assert_equal 'original_val', ta[:bb] + end + + def test_default_arguments_that_dont_match_names_are_ignored + ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) + ta.with_defaults({ "cc" => "default_val" }) + assert_nil ta[:cc] + end + + def test_all_and_extra_arguments_without_named_arguments + app = Rake::Application.new + _, args = app.parse_task_string("task[1,two,more]") + ta = Rake::TaskArguments.new([], args) + assert_equal [], ta.names + assert_equal ['1', 'two', 'more'], ta.to_a + assert_equal ['1', 'two', 'more'], ta.extras + end + + def test_all_and_extra_arguments_with_named_arguments + app = Rake::Application.new + _, args = app.parse_task_string("task[1,two,more,still more]") + ta = Rake::TaskArguments.new([:first, :second], args) + assert_equal [:first, :second], ta.names + assert_equal "1", ta[:first] + assert_equal "two", ta[:second] + assert_equal ['1', 'two', 'more', 'still more'], ta.to_a + assert_equal ['more', 'still more'], ta.extras + end + + def test_extra_args_with_less_than_named_arguments + app = Rake::Application.new + _, args = app.parse_task_string("task[1,two]") + ta = Rake::TaskArguments.new([:first, :second, :third], args) + assert_equal [:first, :second, :third], ta.names + assert_equal "1", ta[:first] + assert_equal "two", ta[:second] + assert_equal nil, ta[:third] + assert_equal ['1', 'two'], ta.to_a + assert_equal [], ta.extras + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_lib.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_lib.rb new file mode 100644 index 000000000..9f3f7e9da --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_lib.rb @@ -0,0 +1,9 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/tasklib' + +class TestRakeTaskLib < Rake::TestCase + def test_paste + tl = Rake::TaskLib.new + assert_equal :ab, tl.paste(:a, :b) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager.rb new file mode 100644 index 000000000..c2730b67e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager.rb @@ -0,0 +1,178 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTaskManager < Rake::TestCase + + def setup + super + + @tm = Rake::TestCase::TaskManager.new + end + + def test_create_task_manager + refute_nil @tm + assert_equal [], @tm.tasks + end + + def test_define_task + t = @tm.define_task(Rake::Task, :t) + assert_equal "t", t.name + assert_equal @tm, t.application + end + + def test_index + e = assert_raises RuntimeError do + @tm['bad'] + end + + assert_equal "Don't know how to build task 'bad'", e.message + end + + def test_name_lookup + t = @tm.define_task(Rake::Task, :t) + assert_equal t, @tm[:t] + end + + def test_namespace_task_create + @tm.in_namespace("x") do + t = @tm.define_task(Rake::Task, :t) + assert_equal "x:t", t.name + end + assert_equal ["x:t"], @tm.tasks.map { |t| t.name } + end + + def test_define_namespaced_task + t = @tm.define_task(Rake::Task, 'n:a:m:e:t') + assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope + assert_equal "n:a:m:e:t", t.name + assert_equal @tm, t.application + end + + def test_define_namespace_in_namespace + t = nil + @tm.in_namespace("n") do + t = @tm.define_task(Rake::Task, 'a:m:e:t') + end + assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope + assert_equal "n:a:m:e:t", t.name + assert_equal @tm, t.application + end + + def test_anonymous_namespace + anon_ns = @tm.in_namespace(nil) do + t = @tm.define_task(Rake::Task, :t) + assert_equal "_anon_1:t", t.name + end + task = anon_ns[:t] + assert_equal "_anon_1:t", task.name + end + + def test_create_filetask_in_namespace + @tm.in_namespace("x") do + t = @tm.define_task(Rake::FileTask, "fn") + assert_equal "fn", t.name + end + + assert_equal ["fn"], @tm.tasks.map { |t| t.name } + end + + def test_namespace_yields_same_namespace_as_returned + yielded_namespace = nil + returned_namespace = @tm.in_namespace("x") do |ns| + yielded_namespace = ns + end + assert_equal returned_namespace, yielded_namespace + end + + def test_name_lookup_with_implicit_file_tasks + FileUtils.touch 'README.rdoc' + + t = @tm["README.rdoc"] + + assert_equal "README.rdoc", t.name + assert Rake::FileTask === t + end + + def test_name_lookup_with_nonexistent_task + assert_raises(RuntimeError) { + @tm["DOES NOT EXIST"] + } + end + + def test_name_lookup_in_multiple_scopes + aa = nil + bb = nil + xx = @tm.define_task(Rake::Task, :xx) + top_z = @tm.define_task(Rake::Task, :z) + @tm.in_namespace("a") do + aa = @tm.define_task(Rake::Task, :aa) + mid_z = @tm.define_task(Rake::Task, :z) + ns_d = @tm.define_task(Rake::Task, "n:t") + @tm.in_namespace("b") do + bb = @tm.define_task(Rake::Task, :bb) + bot_z = @tm.define_task(Rake::Task, :z) + + assert_equal Rake::Scope.make("b", "a"), @tm.current_scope + + assert_equal bb, @tm["a:b:bb"] + assert_equal aa, @tm["a:aa"] + assert_equal xx, @tm["xx"] + assert_equal bot_z, @tm["z"] + assert_equal mid_z, @tm["^z"] + assert_equal top_z, @tm["^^z"] + assert_equal top_z, @tm["^^^z"] # Over the top + assert_equal top_z, @tm["rake:z"] + end + + assert_equal Rake::Scope.make("a"), @tm.current_scope + + assert_equal bb, @tm["a:b:bb"] + assert_equal aa, @tm["a:aa"] + assert_equal xx, @tm["xx"] + assert_equal bb, @tm["b:bb"] + assert_equal aa, @tm["aa"] + assert_equal mid_z, @tm["z"] + assert_equal top_z, @tm["^z"] + assert_equal top_z, @tm["^^z"] # Over the top + assert_equal top_z, @tm["rake:z"] + assert_equal ns_d, @tm["n:t"] + assert_equal ns_d, @tm["a:n:t"] + end + + assert_equal Rake::Scope.make, @tm.current_scope + + assert_equal Rake::Scope.make, xx.scope + assert_equal Rake::Scope.make('a'), aa.scope + assert_equal Rake::Scope.make('b', 'a'), bb.scope + end + + def test_lookup_with_explicit_scopes + t1, t2, t3, s = (0...4).map { nil } + t1 = @tm.define_task(Rake::Task, :t) + @tm.in_namespace("a") do + t2 = @tm.define_task(Rake::Task, :t) + s = @tm.define_task(Rake::Task, :s) + @tm.in_namespace("b") do + t3 = @tm.define_task(Rake::Task, :t) + end + end + assert_equal t1, @tm[:t, Rake::Scope.make] + assert_equal t2, @tm[:t, Rake::Scope.make("a")] + assert_equal t3, @tm[:t, Rake::Scope.make("b", "a")] + assert_equal s, @tm[:s, Rake::Scope.make("b", "a")] + assert_equal s, @tm[:s, Rake::Scope.make("a")] + end + + def test_correctly_scoped_prerequisites_are_invoked + values = [] + @tm = Rake::Application.new + @tm.define_task(Rake::Task, :z) do values << "top z" end + @tm.in_namespace("a") do + @tm.define_task(Rake::Task, :z) do values << "next z" end + @tm.define_task(Rake::Task, :x => :z) + end + + @tm["a:x"].invoke + assert_equal ["next z"], values + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager_argument_resolution.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager_argument_resolution.rb new file mode 100644 index 000000000..43fa2ac44 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_manager_argument_resolution.rb @@ -0,0 +1,19 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTaskManagerArgumentResolution < Rake::TestCase + + def test_good_arg_patterns + assert_equal [:t, [], []], task(:t) + assert_equal [:t, [], [:x]], task(:t => :x) + assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y]) + + assert_equal [:t, [:a, :b], []], task(:t, [:a, :b]) + assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x) + assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y]) + end + + def task(*args) + tm = Rake::TestCase::TaskManager.new + tm.resolve_args(args) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_with_arguments.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_with_arguments.rb new file mode 100644 index 000000000..8646fc041 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_task_with_arguments.rb @@ -0,0 +1,172 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTaskWithArguments < Rake::TestCase + include Rake + + def setup + super + + Task.clear + Rake::TaskManager.record_task_metadata = true + end + + def teardown + Rake::TaskManager.record_task_metadata = false + Rake.application.thread_pool.join + + super + end + + def test_no_args_given + t = task :t + assert_equal [], t.arg_names + end + + def test_args_given + t = task :t, :a, :b + assert_equal [:a, :b], t.arg_names + end + + def test_name_and_needs + t = task(:t => [:pre]) + assert_equal "t", t.name + assert_equal [], t.arg_names + assert_equal ["pre"], t.prerequisites + end + + def test_name_args_and_prereqs + t = task(:t, [:x, :y] => [:pre]) + assert_equal "t", t.name + assert_equal [:x, :y], t.arg_names + assert_equal ["pre"], t.prerequisites + end + + def test_arg_list_is_empty_if_no_args_given + t = task(:t) { |tt, args| assert_equal({}, args.to_hash) } + t.invoke(1, 2, 3) + end + + def test_tasks_can_access_arguments_as_hash + t = task :t, :a, :b, :c do |tt, args| + assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash) + assert_equal 1, args[:a] + assert_equal 2, args[:b] + assert_equal 3, args[:c] + assert_equal 1, args.a + assert_equal 2, args.b + assert_equal 3, args.c + end + t.invoke(1, 2, 3) + end + + def test_actions_of_various_arity_are_ok_with_args + notes = [] + t = task(:t, :x) do + notes << :a + end + t.enhance do | | + notes << :b + end + t.enhance do |task| + notes << :c + assert_kind_of Task, task + end + t.enhance do |t2, args| + notes << :d + assert_equal t, t2 + assert_equal({:x => 1}, args.to_hash) + end + t.invoke(1) + assert_equal [:a, :b, :c, :d], notes + end + + def test_arguments_are_passed_to_block + t = task(:t, :a, :b) { |tt, args| + assert_equal({ :a => 1, :b => 2 }, args.to_hash) + } + t.invoke(1, 2) + end + + def test_extra_parameters_are_ignored + t = task(:t, :a) { |tt, args| + assert_equal 1, args.a + assert_nil args.b + } + t.invoke(1, 2) + end + + def test_arguments_are_passed_to_all_blocks + counter = 0 + t = task :t, :a + task :t do |tt, args| + assert_equal 1, args.a + counter += 1 + end + task :t do |tt, args| + assert_equal 1, args.a + counter += 1 + end + t.invoke(1) + assert_equal 2, counter + end + + def test_block_with_no_parameters_is_ok + t = task(:t) { } + t.invoke(1, 2) + end + + def test_name_with_args + desc "T" + t = task(:tt, :a, :b) + assert_equal "tt", t.name + assert_equal "T", t.comment + assert_equal "[a,b]", t.arg_description + assert_equal "tt[a,b]", t.name_with_args + assert_equal [:a, :b], t.arg_names + end + + def test_named_args_are_passed_to_prereqs + value = nil + task(:pre, :rev) { |t, args| value = args.rev } + t = task(:t, [:name, :rev] => [:pre]) + t.invoke("bill", "1.2") + assert_equal "1.2", value + end + + def test_args_not_passed_if_no_prereq_names_on_task + task(:pre) { |t, args| + assert_equal({}, args.to_hash) + assert_equal "bill", args.name + } + t = task(:t, [:name, :rev] => [:pre]) + t.invoke("bill", "1.2") + end + + def test_args_not_passed_if_no_prereq_names_on_multitask + task(:pre) { |t, args| + assert_equal({}, args.to_hash) + assert_equal "bill", args.name + } + t = multitask(:t, [:name, :rev] => [:pre]) + t.invoke("bill", "1.2") + end + + def test_args_not_passed_if_no_arg_names + task(:pre, :rev) { |t, args| + assert_equal({}, args.to_hash) + } + t = task(:t => [:pre]) + t.invoke("bill", "1.2") + end + + def test_values_at + t = task(:pre, [:a, :b, :c]) { |task, args| + a, b, c = args.values_at(:a, :b, :c) + assert_equal %w[1 2 3], [a, b, c] + } + + t.invoke(*%w[1 2 3]) + + # HACK no assertions + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_test_task.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_test_task.rb new file mode 100644 index 000000000..5c4be797c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_test_task.rb @@ -0,0 +1,146 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/testtask' + +class TestRakeTestTask < Rake::TestCase + include Rake + + def test_initialize + tt = Rake::TestTask.new do |t| end + refute_nil tt + assert_equal :test, tt.name + assert_equal ['lib'], tt.libs + assert_equal 'test/test*.rb', tt.pattern + assert_equal false, tt.verbose + assert Task.task_defined?(:test) + end + + def test_initialize_override + tt = Rake::TestTask.new(:example) do |t| + t.description = "Run example tests" + t.libs = ['src', 'ext'] + t.pattern = 'test/tc_*.rb' + t.verbose = true + end + refute_nil tt + assert_equal "Run example tests", tt.description + assert_equal :example, tt.name + assert_equal ['src', 'ext'], tt.libs + assert_equal 'test/tc_*.rb', tt.pattern + assert_equal true, tt.verbose + assert Task.task_defined?(:example) + end + + def test_file_list_env_test + ENV['TEST'] = 'testfile.rb' + tt = Rake::TestTask.new do |t| + t.pattern = '*' + end + + assert_equal ["testfile.rb"], tt.file_list.to_a + ensure + ENV.delete 'TEST' + end + + def test_libs_equals + test_task = Rake::TestTask.new do |t| + t.libs << ["A", "B"] + end + + path = %w[lib A B].join File::PATH_SEPARATOR + + assert_equal "-I\"#{path}\"", test_task.ruby_opts_string + end + + def test_libs_equals_empty + test_task = Rake::TestTask.new do |t| + t.libs = [] + end + + assert_equal '', test_task.ruby_opts_string + end + + def test_pattern_equals + tt = Rake::TestTask.new do |t| + t.pattern = '*.rb' + end + assert_equal ['*.rb'], tt.file_list.to_a + end + + def test_pattern_equals_test_files_equals + tt = Rake::TestTask.new do |t| + t.test_files = FileList['a.rb', 'b.rb'] + t.pattern = '*.rb' + end + assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a + end + + def test_run_code_direct + test_task = Rake::TestTask.new do |t| + t.loader = :direct + end + + assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code + end + + def test_run_code_rake + spec = Gem::Specification.new 'rake', 0 + spec.loaded_from = File.join Gem::Specification.dirs.last, 'rake-0.gemspec' + rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], spec + + test_task = Rake::TestTask.new do |t| + t.loader = :rake + end + + assert_match(/\A-I".*?" ".*?"\Z/, test_task.run_code) + ensure + Gem.loaded_specs['rake'] = rake + end + + def test_run_code_rake_default_gem + skip 'this ruby does not have default gems' unless + Gem::Specification.method_defined? :default_specifications_dir + + default_spec = Gem::Specification.new 'rake', 0 + default_spec.loaded_from = File.join Gem::Specification.default_specifications_dir, 'rake-0.gemspec' + begin + rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], default_spec + + test_task = Rake::TestTask.new do |t| + t.loader = :rake + end + + assert_match(/\A(-I".*?" *)* ".*?"\Z/, test_task.run_code) + ensure + Gem.loaded_specs['rake'] = rake + end + end + + def test_run_code_testrb_ruby_1_8_2 + test_task = Rake::TestTask.new do |t| + t.loader = :testrb + end + + def test_task.ruby_version() '1.8.2' end + + assert_match(/^-S testrb +".*"$/, test_task.run_code) + end + + def test_run_code_testrb_ruby_1_8_6 + test_task = Rake::TestTask.new do |t| + t.loader = :testrb + end + + def test_task.ruby_version() '1.8.6' end + + assert_match(/^-S testrb +$/, test_task.run_code) + end + + def test_test_files_equals + tt = Rake::TestTask.new do |t| + t.test_files = FileList['a.rb', 'b.rb'] + end + + assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_thread_pool.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_thread_pool.rb new file mode 100644 index 000000000..35a1fe9d1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_thread_pool.rb @@ -0,0 +1,145 @@ +require File.expand_path('../helper', __FILE__) +require 'rake/thread_pool' + +class TestRakeTestThreadPool < Rake::TestCase + include Rake + + def test_pool_executes_in_current_thread_for_zero_threads + pool = ThreadPool.new(0) + f = pool.future { Thread.current } + pool.join + assert_equal Thread.current, f.value + end + + def test_pool_executes_in_other_thread_for_pool_of_size_one + pool = ThreadPool.new(1) + f = pool.future { Thread.current } + pool.join + refute_equal Thread.current, f.value + end + + def test_pool_executes_in_two_other_threads_for_pool_of_size_two + pool = ThreadPool.new(2) + threads = 2.times.map { + pool.future { + sleep 0.1 + Thread.current + } + }.each { |f| + f.value + } + + refute_equal threads[0], threads[1] + refute_equal Thread.current, threads[0] + refute_equal Thread.current, threads[1] + ensure + pool.join + end + + def test_pool_creates_the_correct_number_of_threads + pool = ThreadPool.new(2) + threads = Set.new + t_mutex = Mutex.new + 10.times.each do + pool.future do + sleep 0.02 + t_mutex.synchronize { threads << Thread.current } + end + end + pool.join + assert_equal 2, threads.count + end + + def test_pool_future_does_not_duplicate_arguments + pool = ThreadPool.new(2) + obj = Object.new + captured = nil + pool.future(obj) { |var| captured = var } + pool.join + assert_equal obj, captured + end + + def test_pool_join_empties_queue + pool = ThreadPool.new(2) + repeat = 25 + repeat.times { + pool.future do + repeat.times { + pool.future do + repeat.times { + pool.future do end + } + end + } + end + } + + pool.join + assert_equal( + true, + pool.__send__(:__queue__).empty?, + "queue should be empty") + end + + CustomError = Class.new(StandardError) + + # test that throwing an exception way down in the blocks propagates + # to the top + def test_exceptions + pool = ThreadPool.new(10) + + deep_exception_block = lambda do |count| + raise CustomError if count < 1 + pool.future(count - 1, &deep_exception_block).value + end + + assert_raises(CustomError) do + pool.future(2, &deep_exception_block).value + end + ensure + pool.join + end + + def test_pool_prevents_deadlock + pool = ThreadPool.new(5) + + common_dependency_a = pool.future { sleep 0.2 } + futures_a = 10.times.map { + pool.future { + common_dependency_a.value + sleep(rand() * 0.01) + } + } + + common_dependency_b = pool.future { futures_a.each { |f| f.value } } + futures_b = 10.times.map { + pool.future { + common_dependency_b.value + sleep(rand() * 0.01) + } + } + + futures_b.each { |f| f.value } + pool.join + end + + def test_pool_reports_correct_results + pool = ThreadPool.new(7) + + a = 18 + b = 5 + c = 3 + + result = a.times.map do + pool.future do + b.times.map do + pool.future { sleep rand * 0.001; c } + end.reduce(0) { |m, f| m + f.value } + end + end.reduce(0) { |m, f| m + f.value } + + assert_equal a * b * c, result + pool.join + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_top_level_functions.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_top_level_functions.rb new file mode 100644 index 000000000..fee702dc1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_top_level_functions.rb @@ -0,0 +1,71 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTopLevelFunctions < Rake::TestCase + + def setup + super + + @app = Object.new + + def @app.called + @called + end + + def @app.method_missing(*a, &b) + @called ||= [] + @called << [a, b] + nil + end + + Rake.application = @app + end + + def test_namespace + block = proc do end + + namespace("xyz", &block) + + expected = [ + [[:in_namespace, 'xyz'], block] + ] + + assert_equal expected, @app.called + end + + def test_import + import('x', 'y', 'z') + + expected = [ + [[:add_import, 'x'], nil], + [[:add_import, 'y'], nil], + [[:add_import, 'z'], nil], + ] + + assert_equal expected, @app.called + end + + def test_when_writing + out, = capture_io do + when_writing("NOTWRITING") do + puts "WRITING" + end + end + assert_equal "WRITING\n", out + end + + def test_when_not_writing + Rake::FileUtilsExt.nowrite_flag = true + _, err = capture_io do + when_writing("NOTWRITING") do + puts "WRITING" + end + end + assert_equal "DRYRUN: NOTWRITING\n", err + ensure + Rake::FileUtilsExt.nowrite_flag = false + end + + def test_missing_other_constant + assert_raises(NameError) do Object.const_missing(:Xyz) end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_win32.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_win32.rb new file mode 100644 index 000000000..fc2746a0a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_rake_win32.rb @@ -0,0 +1,72 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeWin32 < Rake::TestCase + + Win32 = Rake::Win32 + + def test_win32_system_dir_uses_home_if_defined + ENV['HOME'] = 'C:\\HP' + + assert_equal "C:/HP/Rake", Win32.win32_system_dir + end + + def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined + ENV['HOME'] = nil + ENV['HOMEDRIVE'] = 'C:' + ENV['HOMEPATH'] = '\\HP' + + assert_equal "C:/HP/Rake", Win32.win32_system_dir + end + + def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo + ENV['APPDATA'] = "C:\\Documents and Settings\\HP\\Application Data" + ENV['HOME'] = nil + ENV['HOMEDRIVE'] = nil + ENV['HOMEPATH'] = nil + + assert_equal "C:/Documents and Settings/HP/Application Data/Rake", + Win32.win32_system_dir + end + + def test_win32_system_dir_fallback_to_userprofile_otherwise + ENV['HOME'] = nil + ENV['HOMEDRIVE'] = nil + ENV['HOMEPATH'] = nil + ENV['APPDATA'] = nil + ENV['USERPROFILE'] = "C:\\Documents and Settings\\HP" + + assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir + end + + def test_win32_system_dir_nil_of_no_env_vars + ENV['APPDATA'] = nil + ENV['HOME'] = nil + ENV['HOMEDRIVE'] = nil + ENV['HOMEPATH'] = nil + ENV['RAKE_SYSTEM'] = nil + ENV['USERPROFILE'] = nil + + assert_raises(Rake::Win32::Win32HomeError) do + Win32.win32_system_dir + end + end + + def test_win32_backtrace_with_different_case + ex = nil + begin + raise 'test exception' + rescue => ex + end + + ex.set_backtrace ['abc', 'rakefile'] + + rake = Rake::Application.new + rake.options.trace = true + rake.instance_variable_set(:@rakefile, 'Rakefile') + + _, err = capture_io { rake.display_error_message(ex) } + + assert_match(/rakefile/, err) + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_thread_history_display.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_thread_history_display.rb new file mode 100644 index 000000000..bb5879cff --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_thread_history_display.rb @@ -0,0 +1,101 @@ +require File.expand_path('../helper', __FILE__) + +require 'rake/thread_history_display' + +class TestThreadHistoryDisplay < Rake::TestCase + def setup + super + @time = 1_000_000 + @stats = [] + @display = Rake::ThreadHistoryDisplay.new(@stats) + end + + def test_banner + out, _ = capture_io do + @display.show + end + assert_match(/Job History/i, out) + end + + def test_item_queued + @stats << event(:item_queued, :item_id => 123) + out, _ = capture_io do + @display.show + end + assert_match(/^ *1000000 +A +item_queued +item_id:1$/, out) + end + + def test_item_dequeued + @stats << event(:item_dequeued, :item_id => 123) + out, _ = capture_io do + @display.show + end + assert_match(/^ *1000000 +A +item_dequeued +item_id:1$/, out) + end + + def test_multiple_items + @stats << event(:item_queued, :item_id => 123) + @stats << event(:item_queued, :item_id => 124) + out, _ = capture_io do + @display.show + end + assert_match(/^ *1000000 +A +item_queued +item_id:1$/, out) + assert_match(/^ *1000001 +A +item_queued +item_id:2$/, out) + end + + def test_waiting + @stats << event(:waiting, :item_id => 123) + out, _ = capture_io do + @display.show + end + assert_match(/^ *1000000 +A +waiting +item_id:1$/, out) + end + + def test_continue + @stats << event(:continue, :item_id => 123) + out, _ = capture_io do + @display.show + end + assert_match(/^ *1000000 +A +continue +item_id:1$/, out) + end + + def test_thread_deleted + @stats << event( + :thread_deleted, + :deleted_thread => 123_456, + :thread_count => 12) + out, _ = capture_io do + @display.show + end + assert_match( + /^ *1000000 +A +thread_deleted( +deleted_thread:B| +thread_count:12){2}$/, + out) + end + + def test_thread_created + @stats << event( + :thread_created, + :new_thread => 123_456, + :thread_count => 13) + out, _ = capture_io do + @display.show + end + assert_match( + /^ *1000000 +A +thread_created( +new_thread:B| +thread_count:13){2}$/, + out) + end + + private + + def event(type, data = {}) + result = { + :event => type, + :time => @time / 1_000_000.0, + :data => data, + :thread => Thread.current.object_id + } + @time += 1 + result + end + +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_trace_output.rb b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_trace_output.rb new file mode 100644 index 000000000..f9aead989 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rake-10.4.2/test/test_trace_output.rb @@ -0,0 +1,52 @@ +require File.expand_path('../helper', __FILE__) +require 'stringio' + +class TestTraceOutput < Rake::TestCase + include Rake::TraceOutput + + class PrintSpy + attr_reader :result, :calls + + def initialize + @result = "" + @calls = 0 + end + + def print(string) + @result << string + @calls += 1 + end + end + + def test_trace_issues_single_io_for_args_with_empty_args + spy = PrintSpy.new + trace_on(spy) + assert_equal "\n", spy.result + assert_equal 1, spy.calls + end + + def test_trace_issues_single_io_for_args_multiple_strings + spy = PrintSpy.new + trace_on(spy, "HI\n", "LO") + assert_equal "HI\nLO\n", spy.result + assert_equal 1, spy.calls + end + + def test_trace_handles_nil_objects + spy = PrintSpy.new + trace_on(spy, "HI\n", nil, "LO") + assert_equal "HI\nLO\n", spy.result + assert_equal 1, spy.calls + end + + def test_trace_issues_single_io_for_args_multiple_strings_and_alternate_sep + old_sep = $\ + $\ = "\r" + spy = PrintSpy.new + trace_on(spy, "HI\r", "LO") + assert_equal "HI\rLO\r", spy.result + assert_equal 1, spy.calls + ensure + $\ = old_sep + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/License.txt b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/License.txt new file mode 100644 index 000000000..02bc06c4e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/License.txt @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2009 Chad Humphries, David Chelimsky +Copyright (c) 2006 David Chelimsky, The RSpec Development Team +Copyright (c) 2005 Steven Baker + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/README.md b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/README.md new file mode 100644 index 000000000..a0d6fc151 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/README.md @@ -0,0 +1,47 @@ +# RSpec + +Behaviour Driven Development for Ruby + +# Description + +rspec is a meta-gem, which depends on the rspec-core, rspec-expectations +and rspec-mocks gems. Each of these can be installed separately and actived in +isolation with the `gem` command. Among other benefits, this allows you to use +rspec-expectations, for example, in Test::Unit::TestCase if you happen to +prefer that style. + +Conversely, if you like RSpec's approach to declaring example groups and +examples (`describe` and `it`) but prefer Test::Unit assertions and mocha, rr +or flexmock for mocking, you'll be able to do that without having to load the +components of rspec that you're not using. + +## Documentation + +### rspec-core + +* [Cucumber features](http://relishapp.com/rspec/rspec-core) +* [RDoc](http://rubydoc.info/gems/rspec-core/frames) + +### rspec-expectations + +* [Cucumber features](http://relishapp.com/rspec/rspec-expectations) +* [RDoc](http://rubydoc.info/gems/rspec-expectations/frames) + +### rspec-mocks + +* [Cucumber features](http://relishapp.com/rspec/rspec-mocks) +* [RDoc](http://rubydoc.info/gems/rspec-mocks/frames) + +## Install + + gem install rspec + +## Contribute + +* [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev) + +## Also see + +* [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core) +* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations) +* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks) diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec.rb new file mode 100644 index 000000000..36149e09e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec.rb @@ -0,0 +1,3 @@ +require 'rspec/core' +require 'rspec/version' + diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec/version.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec/version.rb new file mode 100644 index 000000000..48a95f106 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-3.1.0/lib/rspec/version.rb @@ -0,0 +1,5 @@ +module RSpec # :nodoc: + module Version # :nodoc: + STRING = '3.1.0' + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.document b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.document new file mode 100644 index 000000000..050e20457 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.document @@ -0,0 +1,5 @@ +lib/**/*.rb +- +README.md +License.txt +Changelog.md diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.yardopts b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.yardopts new file mode 100644 index 000000000..0feceb4a3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/.yardopts @@ -0,0 +1,7 @@ +--exclude features +--no-private +--markup markdown +--default-return void +- +Changelog.md +License.txt diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/Changelog.md b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/Changelog.md new file mode 100644 index 000000000..ac877738c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/Changelog.md @@ -0,0 +1,1641 @@ +### 3.1.7 / 2014-10-11 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.6...v3.1.7) + +Bug Fixes: + +* Fix `Metadata.relative_path` so that for a current directory of + `/foo/bar`, `/foo/bar_1` is not wrongly converted to `._1`. + (Akos Vandra, #1730) +* Prevent constant lookup mistakenly finding `RSpec::ExampleGroups` generated + constants on 1.9.2 by appending a trailing `_` to the generated names. + (Jon Rowe, #1737) +* Fix bug in `:pending` metadata. If it got set in any way besides passing + it as part of the metadata literal passed to `it` (such as by using + `define_derived_metadata`), it did not have the desired effect, + instead marking the example as `:passed`. (Myron Marston, #1739) + +### 3.1.6 / 2014-10-08 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.5...v3.1.6) + +Bug Fixes: + +* Fix regression in rake task pattern handling, that prevented patterns + that were relative from the current directory rather than from `spec` + from working properly. (Myron Marston, #1734) +* Prevent rake task from generating duplicate load path entries. + (Myron Marston, #1735) + +### 3.1.5 / 2014-09-29 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.4...v3.1.5) + +Bug Fixes: + +* Fix issue with the rake task incorrectly escaping strings on Windows. + (Jon Rowe #1718) +* Support absolute path patterns. While this wasn't officially supported + previously, setting `rake_task.pattern` to an absolute path pattern in + RSpec 3.0 and before worked since it delegated to `FileList` internally + (but now just forwards the pattern on to the `rspec` command). + (Myron Marston, #1726) + +### 3.1.4 / 2014-09-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.3...v3.1.4) + +Bug Fixes: + +* Fix implicit `subject` when using `describe false` or `describe nil` + so that it returns the provided primitive rather than the string + representation. (Myron Marston, #1710) +* Fix backtrace filtering to allow code in subdirectories of your + current working directory (such as vendor/bundle/...) to be filtered + from backtraces. (Myron Marston, #1708) + +### 3.1.3 / 2014-09-15 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.2...v3.1.3) + +Bug Fixes: + +* Fix yet another regression in rake task pattern handling, to allow + `task.pattern = FileList["..."]` to work. That was never intended + to be supported but accidentally worked in 3.0 and earlier. + (Myron Marston, #1701) +* Fix pattern handling so that files are normalized to absolute paths + before subtracting the `--exclude-pattern` matched files from the + `--pattern` matched files so that it still works even if the patterns + are in slightly different forms (e.g. one starting with `./`). + (Christian Nelson, #1698) + +### 3.1.2 / 2014-09-08 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.1...v3.1.2) + +Bug Fixes: + +* Fix another regression in rake task pattern handling, so that patterns + that start with `./` still work. (Christian Nelson, #1696) + +### 3.1.1 / 2014-09-05 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.1.0...v3.1.1) + +Bug Fixes: + +* Fix a regression in rake task pattern handling, so that `rake_task.pattern = array` + works again. While we never intended to support array values (or even knew that worked!), + the implementation from 3.0 and earlier used `FileList` internally, which allows arrays. + The fix restores the old behavior. (Myron Marston, #1694) + +### 3.1.0 / 2014-09-04 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.4...v3.1.0) + +Enhancements: + +* Update files generated by `rspec --init` so that warnings are enabled + in commented out section of `spec_helper` rather than `.rspec` so users + have to consciously opt-in to the setting. (Andrew Hooker, #1572) +* Update `spec_helper` generated by `rspec --init` so that it sets the new + rspec-expectations `include_chain_clauses_in_custom_matcher_descriptions` + config option (which will be on by default in RSpec 4) and also sets the + rspec-mocks `verify_partial_doubles` option (which will also default + to on in RSpec 4). (Myron Marston, #1647) +* Provide an `inspect` output for example procsy objects (used in around + hooks) that doesn't make them look like procs. (Jon Rowe, #1620) +* Remove a few unneeded `require` statements from + `rspec/core/rake_task.rb`, making it even more lighterweight. + (Myron Marston, #1640) +* Allow rspec-core to be used when neither rspec-mocks or + rspec-expectations are installed, without requiring any + user configuration. (Sam Phippen, Myron Marston, #1615) +* Don't filter out gems from backtraces by default. (The RSpec + gems will still be filtered). User feedback has indicated + that including gems in default backtraces will be useful. + (Myron Marston, #1641) +* Add new `config.filter_gems_from_backtrace "rack", "rake"` API + to easily filter the named gems from backtraces. (Myron Marston, #1682) +* Fix default backtrace filters so that the RSpec binary is + excluded when installing RSpec as a bundler `:git` dependency. + (Myron Marston, #1648) +* Simplify command generated by the rake task so that it no longer + includes unnecessary `-S`. (Myron Marston, #1559) +* Add `--exclude-pattern` CLI option, `config.exclude_pattern =` config + option and `task.exclude_pattern =` rake task config option. Matching + files will be excluded. (John Gesimondo, Myron Marston, #1651, #1671) +* When an around hook fails to execute the example, mark it as + pending (rather than passing) so the user is made aware of the + fact that the example did not actually run. (Myron Marston, #1660) +* Remove dependency on `FileUtils` from the standard library so that users do + not get false positives where their code relies on it but they are not + requiring it. (Sam Phippen, #1565) + +Bug Fixes: + +* Fix rake task `t.pattern =` option so that it does not run all specs + when it matches no files, by passing along a `--pattern` option to + the `rspec` command, rather than resolving the file list and passing + along the files individually. (Evgeny Zislis, #1653) +* Fix rake task default pattern so that it follows symlinks properly. + (Myron Marston, #1672) +* Fix default pattern used with `rspec` command so that it follows + symlinks properly. (Myron Marston, #1672) +* Change how we assign constant names to example group classes so that + it avoids a problem with `describe "Core"`. (Daniela Wellisz, #1679) +* Handle rendering exceptions that have a different encoding than that + of their original source file. (Jon Rowe, #1681) +* Allow access to message_lines without colour for failed examples even + when they're part of a shared example group. (tomykaira, #1689) + +### 3.0.4 / 2014-08-14 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.3...v3.0.4) + +Bug Fixes: + +* Fix processing order of CLI options so that if `config.files_to_run` + is accessed from a file loaded by `--require`, `--pattern` is still + applied. (Myron Marston, #1652) +* Fix `config.pattern=` so that it still takes affect even if + `config.files_to_run` has already been accessed. (Myron Marston, #1652) + +### 3.0.3 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.2...v3.0.3) + +Bug Fixes: + +* Properly convert both parts of a description into strings before + concatenation. (@nicklink483, #1636) +* Exclude the working directory when figuring out folders to ignore. + (Jon Rowe, Myron Marston, #1616) +* Allow `::RSpec::Core::Notifications::FailedExampleNotification#message_lines` + to be accessed without a colouriser. (@tomykaira, #1637) + +### 3.0.2 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.1...v3.0.2) + +Bug Fixes: + +* Fix regression in CLI option handling that prevented `--tag slow` + passed at the command line from overriding `--tag ~slow` in `.rspec`. + (Colin Jones, #1602) +* Fix metadata `:example_group` deprecation warning so that it gets + issued at the call site of the configuration that specified it as + a filter rather than later when an example group is defined. + (Myron Marston, #1562) +* Make the line that is printed when a shared example group fails indicating + where the concrete example group is white, separating it from the stack trace + that is produced for the failure. (Sam Phippen, Jon Rowe, #1606) + +### 3.0.1 / 2014-06-12 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.0...v3.0.1) + +Bug Fixes: + +* Fix a couple ruby warnings caused by rspec-core when loaded. + (Prem Sichanugrist, #1584) +* Example groups named `Config` will no longer cause a Ruby warning to be + issued. (Jimmy Cuadra, #1580) + +### 3.0.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.0.rc1...v3.0.0) + +Bug Fixes: + +* Fix `BaseTextFormatter` so that it does not re-close a closed output + stream. (Myron Marston) +* Fix regression in metadata that caused the metadata hash of a top-level + example group to have a `:parent_example_group` key even though it has + no parent example group. (Myron Marston) + +Enhancements: + +* Alter the default `spec_helper.rb` to no longer recommend + `config.full_backtrace = true` see #1536 for discussion. (Jon Rowe) + +### 3.0.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.0.beta2...v3.0.0.rc1) + +Breaking Changes for 3.0.0: + +* Change `described_class` so that in a nested group like `describe + MyClass`, it returns `MyClass` rather than the outer group's described + class. (Myron Marston) +* Refactor filter manager so that it no longer subclasses Hash and has a + tighter, more domain-specific interface. (Sergey Pchelincev) +* Remove legacy colours definitions from `BaseTextFormatter`. (Jon Rowe) +* Remove console color definitions from `BaseTextFormatter`. (Jon Rowe) +* Restructure example group metadata so that the computed keys are + exposed directly off of the metadata hash rather than being on + a nested `:example_group` subhash. In addition, the parent example + group metadata is now available as `[:parent_example_group]` rather + than `[:example_group][:example_group]`. Deprecated access via the + old key structure is still provided. (Myron Marston) +* Remove `:describes` metadata key. It duplicates `:described_class` + for no good reason. Deprecated access via `:describes` is still + provided. (Myron Marston) +* Rename `:example_group_block` metadata key to `:block`. + (Myron Marston) +* Remove deprecated `RSpec::Core::Example#options`. (Myron Marston) +* Move `BaseTextFormatter#colorize_summary` to `SummaryNotification#colorize_with` + (Jon Rowe). +* `describe some_hash` treated `some_hash` as metadata in RSpec 2.x but + will treat it as the described object in RSpec 3.0. Metadata must + always come after the description args. (Myron Marston) +* Remove deprecated `display_name` alias of `ExampleGroup.description`. + (Myron Marston) +* Remove deprecated `describes` alias of `ExampleGroup.described_class`. + (Myron Marston) +* Remove deprecated `RSpec::Core::ExampleGroup.alias_it_behaves_like_to`. + Use `RSpec::Core::Configuration#alias_it_behaves_like_to` instead. + (Myron Marston) +* Remove deprecated `RSpec::Core::ExampleGroup.alias_example_to`. + Use `RSpec::Core::Configuration#alias_example_to` instead. + (Myron Marston) +* Removed `focused` example alias and change example/group aliases + `fit`, `focus`, `fcontext` and `fdescribe` to no longer include + `:focused => true` metadata. They only contain `:focus => true` + metadata now. This means that you will need to filter them with + `filter_run :focus`, not `filter_run :focused`. (Myron Marston) +* Remove `--line-number` filtering. It's semantically dubious since it's + a global filter (potentially applied to multiple files) but there's no + meaningful connection between the same line number in multiple files. + Instead use the `rspec path/to/spec.rb:23:46` form, which is terser + and makes more sense as it is scoped to a file. (Myron Marston) +* Remove `--default_path` as an alias for `--default-path`. (Jon Rowe) +* Remove deprecated `share_examples_for`. There's still + `shared_examples` and `shared_examples_for`. (Myron Marston) +* Rename `RSpec::Core::Configuration#warnings` to + `RSpec::Core::Configuration#warnings?` since it's a boolean flag. + (Myron Marston) +* RSpec's global state is no longer reset after a spec run. This gives + more flexibility to alternate runners to decide when and if they + want the state reset. Alternate runners are now responsible for + calling this (or doing a similar reset) if they are going to run + the spec suite multiple times in the same process. (Sam Phippen) +* Merge `RSpec::Core::CommandLine` (never formally declared public) + into `RSpec::Core::Runner`. (Myron Marston) +* Remove `color_enabled` as an alias of `color`. (Jon Rowe) +* Remove `backtrace_cleaner` as an alias of `backtrace_formatter`. (Jon Rowe) +* Remove `filename_pattern` as an alias of `pattern`. (Jon Rowe) +* Extract support for legacy formatters to `rspec-legacy_formatters`. (Jon Rowe) +* `RSpec::Configuration#formatters` now returns a dup to prevent mutation. (Jon Rowe) +* Replace `stdlib` as an available expectation framework with `test_unit` and + `minitest`. (Aaron Kromer) +* Remove backtrace formatting helpers from `BaseTextFormatter`. (Jon Rowe) +* Extract profiler support to `ProfileFormatter` and `ProfileNotification`. + Formatters should implement `dump_profile` if they wish to respond to `--profile`. + (Jon Rowe) +* Extract remaining formatter state to reporter and notifications. Introduce + `ExamplesNotification` to share information about examples that was previously + held in `BaseFormatter`. (Jon Rowe) + +Enhancements: + +* Add `config.default_formatter` attribute, which can be used to set a + formatter which will only be used if no other formatter is set + (e.g. via `--formatter`). (Myron Marston) +* Support legacy colour definitions in `LegacyFormatterAdaptor`. (Jon Rowe) +* Migrate `execution_result` (exposed by metadata) from a hash to a + first-class object with appropriate attributes. `status` is now + stored and returned as a symbol rather than a string. It retains + deprecated hash behavior for backwards compatibility. (Myron Marston) +* Provide console code helper for formatters. (Jon Rowe) +* Use raw ruby hashes for the metadata hashes rather than a subclass of + a hash. Computed metadata entries are now computed in advance rather + than being done lazily on first access. (Myron Marston) +* Add `:block` metadata entry to the example metadata, bringing + parity with `:block` in the example group metadata. (Myron Marston) +* Add `fspecify` and `fexample` as aliases of `specify` and `example` + with `:focus => true` metadata for parity with `fit`. (Myron Marston) +* Add legacy support for `colorize_summary`. (Jon Rowe) +* Restructure runner so it can be more easily customized in a subclass + for an alternate runner. (Ben Hoskings) +* Document `RSpec::Core::ConfigurationOptions` as an officially + supported public API. (Myron Marston) +* Add `--deprecation-out` CLI option which directs deprecation warnings + to the named file. (Myron Marston) +* Minitest 5 compatability for `expect_with :stdlib` (now available as + `expect_with :minitest`). (Xavier Shay) +* Reporter now notifies formatters of the load time of RSpec and your + specs via `StartNotification` and `SummaryNotification`. (Jon Rowe) +* Add `disable_monkey_patching!` config option that disables all monkey + patching from whatever pieces of RSpec you use. (Alexey Fedorov) +* Add `Pathname` support for setting all output streams. (Aaron Kromer) +* Add `config.define_derived_metadata`, which can be used to apply + additional metadata to all groups or examples that match a given + filter. (Myron Marston) +* Provide formatted and colorized backtraces via `FailedExampleNotification` + and send `PendingExampleFixedNotifications` when the error is due to a + passing spec you expect to fail. (Jon Rowe) +* Add `dump_profile` to formatter API to allow formatters to implement + support for `--profile`. (Jon Rowe) +* Allow colourising text via `ConsoleCodes` with RSpec 'states' + (e.g. `:success`, `:failure`) rather than direct colour codes. (Jon Rowe) +* Expose `fully_formatted` methods off the formatter notification objects + that make it easy for a custom formatter to produce formatted output + like rspec-core's. (Myron Marston) + +Bug Fixes: + +* Fix `spec_helper.rb` file generated by `rspec --init` so that the + recommended settings correctly use the documentation formatter + when running one file. (Myron Marston) +* Fix ordering problem where descriptions were generated after + tearing down mocks, which resulted in unexpected exceptions. + (Bradley Schaefer, Aaron Kromer, Andrey Savchenko) +* Allow a symbol to be used as an implicit subject (e.g. `describe + :foo`). (Myron Marston) +* Prevent creating an isolated context (i.e. using `RSpec.describe`) when + already inside a context. There is no reason to do this, and it could + potentially cause unexpected bugs. (Xavier Shay) +* Fix shared example group scoping so that when two shared example + groups share the same name at different levels of nested contexts, + the one in the nearest context is used. (Myron Marston) +* Fix `--warnings` option so that it enables warnings immediately so + that it applies to files loaded by `--require`. (Myron Marston) +* Issue a warning when you set `config.deprecation_stream` too late for + it to take effect because the reporter has already been setup. (Myron Marston) +* Add the full `RSpec::Core::Example` interface to the argument yielded + to `around` hooks. (Myron Marston) +* Line number always takes precendence when running specs with filters. + (Xavier Shay) +* Ensure :if and :unless metadata filters are treated as a special case + and are always in-effect. (Bradley Schaefer) +* Ensure the currently running installation of RSpec is used when + the rake task shells out to `rspec`, even if a newer version is also + installed. (Postmodern) +* Using a legacy formatter as default no longer causes an infinite loop. + (Xavier Shay) + +### 3.0.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.0.beta1...v3.0.0.beta2) + +Breaking Changes for 3.0.0: + +* Make `mock_with` option more strict. Strings are no longer supported + (e.g. `mock_with "mocha"`) -- use a symbol instead. Also, unrecognized + values will now result in an error rather than falling back to the + null mocking adapter. If you want to use the null mocking adapter, + use `mock_with :nothing` (as has been documented for a long time). + (Myron Marston) +* Remove support for overriding RSpec's built-in `:if` and `:unless` + filters. (Ashish Dixit) +* Custom formatters are now required to call + `RSpec::Core::Formatters.register(formatter_class, *notifications)` + where `notifications` is the list of events the formatter wishes to + be notified about. Notifications are handled by methods matching the + names on formatters. This allows us to add or remove notifications + without breaking existing formatters. (Jon Rowe) +* Change arguments passed to formatters. Rather than passing multiple + arguments (which limits are ability to add additional arguments as + doing so would break existing formatters), we now pass a notification + value object that exposes the same data via attributes. This will + allow us to add new bits of data to a notification event without + breaking existing formatters. (Jon Rowe) +* Remove support for deprecated `:alias` option for + `RSpec.configuration.add_setting`. (Myron Marston) +* Remove support for deprecated `RSpec.configuration.requires = [...]`. + (Myron Marston) +* Remove support for deprecated `--formatter` CLI option. (Myron Marston) +* Remove support for deprecated `--configure` CLI option. (Myron Marston) +* Remove support for deprecated `RSpec::Core::RakeTask#spec_opts=`. + (Myron Marston) +* An example group level `pending` block or `:pending` metadata now executes + the example and cause a failure if it passes, otherwise it will be pending if + it fails. The old "never run" behaviour is still used for `xexample`, `xit`, + and `xspecify`, or via a new `skip` method or `:skip` metadata option. + (Xavier Shay) +* After calling `pending` inside an example, the remainder of the example will + now be run. If it passes a failure is raised, otherwise the example is marked + pending. The old "never run" behaviour is provided a by a new `skip` method. + (Xavier Shay) +* Pending blocks inside an example have been removed as a feature with no + direct replacement. Use `skip` or `pending` without a block. (Xavier Shay) +* Pending statement is no longer allowed in `before(:all)` hooks. Use `skip` + instead. (Xavier Shay) +* Remove `show_failures_in_pending_blocks` configuration option. (Xavier Shay) +* Remove support for specifying the documentation formatter using + 's', 'n', 'spec' or 'nested'. (Jon Rowe) + +Enhancements: + +* Add example run time to JSON formatter output. (Karthik Kastury) +* Add more suggested settings to the files generated by + `rspec --init`. (Myron Marston) +* Add `config.alias_example_group_to`, which can be used to define a + new method that defines an example group with the provided metadata. + (Michi Huber) +* Add `xdescribe` and `xcontext` as shortcuts to skip an example group. + (Myron Marston) +* Add `fdescribe` and `fcontext` as shortcuts to focus an example group. + (Myron Marston) +* Don't autorun specs via `#at_exit` by default. `require 'rspec/autorun'` + is only needed when running specs via `ruby`, as it always has been. + Running specs via `rake` or `rspec` are both unaffected. (Ben Hoskings) +* Add `expose_dsl_globally` config option, defaulting to true. When disabled + it will remove the monkey patches rspec-core adds to `main` and `Module` + (e.g. `describe`, `shared_examples_for`, etc). (Jon Rowe) +* Expose RSpec DSL entry point methods (`describe`, + `shared_examples_for`, etc) on the `RSpec` constant. Intended for use + when `expose_dsl_globally` is set to `false`. (Jon Rowe) +* For consistency, expose all example group aliases (including + `context`) on the `RSpec` constant. If `expose_dsl_globally` is set to + `true`, also expose them on `main` and `Module`. Historically, only `describe` + was exposed. (Jon Rowe, Michi Huber) +* Add hook scope `:example` as an alias for `:each`, and `:context` as an alias + for `:all`. (John Feminella) + +Bug Fixes: + +* Fix failure (undefined method `path`) in end-of-run summary + when `raise_errors_for_deprecations!` is configured. (Myron Marston) +* Issue error when attempting to use `-i` or `--I` on command line, + too close to `-I` to be considered short hand for `--init`. (Jon Rowe) +* Prevent adding formatters to an output target if the same + formatter has already been added to that output. (Alex Peattie) +* Allow a matcher-generated example description to be used when + the example is pending. (Myron Marston) +* Ensure the configured `failure_exit_code` is used by the rake + task when there is a failure. (Jon Rowe) +* Restore behaviour whereby system exclusion filters take priority over working + directory (was broken in beta1). (Jon Rowe) +* Prevent RSpec mangling file names that have substrings containing `line_number` + or `default_path`. (Matijs van Zuijlen) + +### 3.0.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.1...v3.0.0.beta1) + +Breaking Changes for 3.0.0: + +* Remove explicit support for 1.8.6. (Jon Rowe) +* Remove `RSpec::Core::ExampleGroup#example` and + `RSpec::Core::ExampleGroup#running_example` methods. If you need + access to the example (e.g. to get its metadata), use a block arg + instead. (David Chelimsky) +* Remove `TextMateFormatter`, it has been moved to `rspec-tmbundle`. + (Aaron Kromer) +* Remove RCov integration. (Jon Rowe) +* Remove deprecated support for RSpec 1 constructs (Myron Marston): + * The `Spec` and `Rspec` constants (rather than `RSpec`). + * `Spec::Runner.configure` rather than `RSpec.configure`. + * `Rake::SpecTask` rather than `RSpec::Core::RakeTask`. +* Remove deprecated support for `share_as`. (Myron Marston) +* Remove `--debug` option (and corresponding option on + `RSpec::Core::Configuration`). Instead, use `-r` to + load whichever debugger gem you wish to use (e.g. `ruby-debug`, + `debugger`, or `pry`). (Myron Marston) +* Extract Autotest support to a seperate gem. (Jon Rowe) +* Raise an error when a `let` or `subject` declaration is + accessed in a `before(:all)` or `after(:all)` hook. (Myron Marston) +* Extract `its` support to a separate gem. (Peter Alfvin) +* Disallow use of a shared example group from sibling contexts, making them + fully isolated. 2.14 and 2.99 allowed this but printed a deprecation warning. + (Jon Rowe) +* Remove `RSpec::Core::Configuration#output` and + `RSpec::Core::Configuration#out` aliases of + `RSpec::Core::Configuration#output_stream`. (Myron Marston) +* Remove legacy ordering APIs deprecated in 2.99.0.beta1. (Myron + Marston) + +Enhancements: + +* Replace unmaintained syntax gem with coderay gem. (Xavier Shay) +* Times in profile output are now bold instead of `failure_color`. + (Matthew Boedicker) +* Add `--no-fail-fast` command line option. (Gonzalo Rodríguez-Baltanás Díaz) +* Runner now considers the local system ip address when running under Drb. + (Adrian CB) +* JsonFormatter now includes `--profile` information. (Alex / @MasterLambaster) +* Always treat symbols passed as metadata args as hash + keys with true values. RSpec 2 supported this with the + `treat_symbols_as_metadata_keys_with_true_values` but + now this behavior is always enabled. (Myron Marston) +* Add `--dry-run` option, which prints the formatter output + of your suite without running any examples or hooks. + (Thomas Stratmann, Myron Marston) +* Document the configuration options and default values in the `spec_helper.rb` + file that is generated by RSpec. (Parker Selbert) +* Give generated example group classes a friendly name derived + from the docstring, rather than something like "Nested_2". + (Myron Marston) +* Avoid affecting randomization of user code when shuffling + examples so that users can count on their own seeds + working. (Travis Herrick) +* Ordering is no longer a single global property of the test suite. + Each group can pick an ordering using `:order` metadata. (Andy + Lindeman, Sam Phippen, Myron Marston) +* Allow named custom ordering strategies to be registered, which can + then be used on individual example groups. (Andy Lindeman, Sam + Phippen, Myron Marston) + +Deprecations: + +* `treat_symbols_as_metadata_keys_with_true_values` is deprecated and no + longer has an affect now that the behavior it enabled is always + enabled. (Myron Marston) + +### 2.99.2 / 2014-08-19 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.1...v2.99.2) + +Enhancements: + +* Improve deprecation warning for RSpec 3 change in `describe ` + behavior. (Jon Rowe, #1667) + +### 2.99.1 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0...v2.99.1) + +Bug Fixes: + +* Add missing deprecation warning for when `RSpec::Core::Runner` is used + multiple times in the same process. In 2.x RSpec's global state was + automatically cleared between runs but in 3.0 you need to call `RSpec.reset` + manually in these situations. (Sam Phippen, #1587) +* Prevent deprecation being accidentally issues when doubles used with `be_` + matchers due to automatically generated descriptions. (Jon Rowe, #1573) +* Load `rspec/core` when loading `rspec/core/rake_task` to ensure we can + issue deprecations correctly. (Jon Rowe, #1612) + +### 2.99.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0.rc1...v2.99.0) + +Bug Fixes: + +* Fix `BaseTextFormatter` so that it does not re-close a closed output + stream. (Myron Marston) +* Use `RSpec::Configuration#backtrace_exclusion_patterns` rather than the + deprecated `RSpec::Configuration#backtrace_clean_patterns` when mocking + with rr. (David Dollar) + +### 2.99.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0.beta2...v2.99.0.rc1) + +Enhancements: + +* Add `--deprecation-out` CLI option which directs deprecation warnings + to the named file. (Myron Marston) +* Backport support for `skip` in metadata to skip execution of an example. + (Xavier Shay, #1472) +* Add `Pathname` support for setting all output streams. (Aaron Kromer) +* Add `test_unit` and `minitest` expectation frameworks. (Aaron Kromer) + +Deprecations: + +* Deprecate `RSpec::Core::Pending::PendingDeclaredInExample`, use + `SkipDeclaredInExample` instead. (Xavier Shay) +* Issue a deprecation when `described_class` is accessed from within + a nested `describe ` example group, since `described_class` + will return the innermost described class in RSpec 3 rather than the + outermost described class, as it behaved in RSpec 2. (Myron Marston) +* Deprecate `RSpec::Core::FilterManager::DEFAULT_EXCLUSIONS`, + `RSpec::Core::FilterManager::STANDALONE_FILTERS` and use of + `#empty_without_conditional_filters?` on those filters. (Sergey Pchelincev) +* Deprecate `RSpec::Core::Example#options` in favor of + `RSpec::Core::Example#metadata`. (Myron Marston) +* Issue warning when passing a symbol or hash to `describe` or `context` + as the first argument. In RSpec 2.x this would be treated as metadata + but in RSpec 3 it'll be treated as the described object. To continue + having it treated as metadata, pass a description before the symbol or + hash. (Myron Marston) +* Deprecate `RSpec::Core::BaseTextFormatter::VT100_COLORS` and + `RSpec::Core::BaseTextFormatter::VT100_COLOR_CODES` in favour + of `RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODES` and + `RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODE_VALUES`. + (Jon Rowe) +* Deprecate `RSpec::Core::ExampleGroup.display_name` in favor of + `RSpec::Core::ExampleGroup.description`. (Myron Marston) +* Deprecate `RSpec::Core::ExampleGroup.describes` in favor of + `RSpec::Core::ExampleGroup.described_class`. (Myron Marston) +* Deprecate `RSpec::Core::ExampleGroup.alias_example_to` in favor of + `RSpec::Core::Configuration#alias_example_to`. (Myron Marston) +* Deprecate `RSpec::Core::ExampleGroup.alias_it_behaves_like_to` in favor + of `RSpec::Core::Configuration#alias_it_behaves_like_to`. (Myron Marston) +* Deprecate `RSpec::Core::ExampleGroup.focused` in favor of + `RSpec::Core::ExampleGroup.focus`. (Myron Marston) +* Add deprecation warning for `config.filter_run :focused` since + example aliases `fit` and `focus` will no longer include + `:focused` metadata but will continue to include `:focus`. (Myron Marston) +* Deprecate filtering by `:line_number` (e.g. `--line-number` from the + CLI). Use location filtering instead. (Myron Marston) +* Deprecate `--default_path` as an alternative to `--default-path`. (Jon Rowe) +* Deprecate `RSpec::Core::Configuration#warnings` in favor of + `RSpec::Core::Configuration#warnings?`. (Myron Marston) +* Deprecate `share_examples_for` in favor of `shared_examples_for` or + just `shared_examples`. (Myron Marston) +* Deprecate `RSpec::Core::CommandLine` in favor of + `RSpec::Core::Runner`. (Myron Marston) +* Deprecate `#color_enabled`, `#color_enabled=` and `#color?` in favour of + `#color`, `#color=` and `#color_enabled? output`. (Jon Rowe) +* Deprecate `#filename_pattern` in favour of `#pattern`. (Jon Rowe) +* Deprecate `#backtrace_cleaner` in favour of `#backtrace_formatter`. (Jon Rowe) +* Deprecate mutating `RSpec::Configuration#formatters`. (Jon Rowe) +* Deprecate `stdlib` as an available expectation framework in favour of + `test_unit` and `minitest`. (Aaron Kromer) + +Bug Fixes: + +* Issue a warning when you set `config.deprecation_stream` too late for + it to take effect because the reporter has already been setup. (Myron Marston) +* `skip` with a block should not execute the block. (Xavier Shay) + +### 2.99.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0.beta1...v2.99.0.beta2) + +Enhancements: + +* Add `is_expected` for one-liners that read well with the + `expect`-based syntax. `is_expected` is simply defined as + `expect(subject)` and can be used in an expression like: + `it { is_expected.to read_well }`. (Myron Marston) +* Backport `skip` from RSpec 3, which acts like `pending` did in RSpec 2 + when not given a block, since the behavior of `pending` is changing in + RSpec 3. (Xavier Shay) + +Deprecations: + +* Deprecate inexact `mock_with` config options. RSpec 3 will only support + the exact symbols `:rspec`, `:mocha`, `:flexmock`, `:rr` or `:nothing` + (or any module that implements the adapter interface). RSpec 2 did + fuzzy matching but this will not be supported going forward. + (Myron Marston) +* Deprecate `show_failures_in_pending_blocks` config option. To achieve + the same behavior as the option enabled, you can use a custom + formatter instead. (Xavier Shay) +* Add a deprecation warning for the fact that the behavior of `pending` + is changing in RSpec 3 -- rather than skipping the example (as it did + in 2.x when no block was provided), it will run the example and mark + it as failed if no exception is raised. Use `skip` instead to preserve + the old behavior. (Xavier Shay) +* Deprecate 's', 'n', 'spec' and 'nested' as aliases for documentation + formatter. (Jon Rowe) +* Deprecate `RSpec::Core::Reporter#abort` in favor of + `RSpec::Core::Reporter#finish`. (Jon Rowe) + +Bug Fixes: + +* Fix failure (undefined method `path`) in end-of-run summary + when `raise_errors_for_deprecations!` is configured. (Myron Marston) +* Fix issue were overridding spec ordering from the command line wasn't + fully recognised interally. (Jon Rowe) + +### 2.99.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.7...v2.99.0.beta1) + +Enhancements + +* Block-based DSL methods that run in the context of an example + (`it`, `before(:each)`, `after(:each)`, `let` and `subject`) + now yield the example as a block argument. (David Chelimsky) +* Warn when the name of more than one example group is submitted to + `include_examples` and it's aliases. (David Chelimsky) +* Add `expose_current_running_example_as` config option for + use during the upgrade process when external gems use the + deprecated `RSpec::Core::ExampleGroup#example` and + `RSpec::Core::ExampleGroup#running_example` methods. (Myron Marston) +* Limit spamminess of deprecation messages. (Bradley Schaefer, Loren Segal) +* Add `config.raise_errors_for_deprecations!` option, which turns + deprecations warnings into errors to surface the full backtrace + of the call site. (Myron Marston) + +Deprecations + +* Deprecate `RSpec::Core::ExampleGroup#example` and + `RSpec::Core::ExampleGroup#running_example` methods. If you need + access to the example (e.g. to get its metadata), use a block argument + instead. (David Chelimsky) +* Deprecate use of `autotest/rspec2` in favour of `rspec-autotest`. (Jon Rowe) +* Deprecate RSpec's built-in debugger support. Use a CLI option like + `-rruby-debug` (for the ruby-debug gem) or `-rdebugger` (for the + debugger gem) instead. (Myron Marston) +* Deprecate `RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values = false`. + RSpec 3 will not support having this option set to `false`. (Myron Marston) +* Deprecate accessing a `let` or `subject` declaration in + a `after(:all)` hook. (Myron Marston, Jon Rowe) +* Deprecate built-in `its` usage in favor of `rspec-its` gem due to planned + removal in RSpec 3. (Peter Alfvin) +* Deprecate `RSpec::Core::PendingExampleFixedError` in favor of + `RSpec::Core::Pending::PendingExampleFixedError`. (Myron Marston) +* Deprecate `RSpec::Core::Configuration#out` and + `RSpec::Core::Configuration#output` in favor of + `RSpec::Core::Configuration#output_stream`. (Myron Marston) +* Deprecate legacy ordering APIs. + * You should use `register_ordering(:global)` instead of these: + * `RSpec::Core::Configuration#order_examples` + * `RSpec::Core::Configuration#order_groups` + * `RSpec::Core::Configuration#order_groups_and_examples` + * These are deprecated with no replacement because in RSpec 3 + ordering is a property of individual example groups rather than + just a global property of the entire test suite: + * `RSpec::Core::Configuration#order` + * `RSpec::Core::Configuration#randomize?` + * `--order default` is deprecated in favor of `--order defined` + (Myron Marston) + +### 2.14.8 / 2014-02-27 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.7...v2.14.8) + +Bug fixes: + +* Fix regression with the `textmateformatter` that prevented backtrace links + from being clickable. (Stefan Daschek) + +### 2.14.7 / 2013-10-29 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.6...v2.14.7) + +Bug fixes: + +* Fix regression in 2.14.6 that broke the Fivemat formatter. + It depended upon either + `example.execution_result[:exception].pending_fixed?` (which + was removed in 2.14.6 to fix an issue with frozen error objects) + or `RSpec::Core::PendingExampleFixedError` (which was renamed + to `RSpec::Core::Pending::PendingExampleFixedError` in 2.8. + This fix makes a constant alias for the old error name. + (Myron Marston) + +### 2.14.6 / 2013-10-15 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.5...v2.14.6) + +Bug fixes: + +* Format stringified numbers correctly when mathn library is loaded. + (Jay Hayes) +* Fix an issue that prevented the use of frozen error objects. (Lars + Gierth) + +### 2.14.5 / 2013-08-13 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.4...v2.14.5) + +Bug fixes: + +* Fix a `NoMethodError` that was being raised when there were no shared + examples or contexts declared and `RSpec.world.reset` is invoked. + (thepoho, Jon Rowe, Myron Marston) +* Fix a deprecation warning that was being incorrectly displayed when + `shared_examples` are declared at top level in a `module` scope. + (Jon Rowe) +* Fix after(:all) hooks so consecutive (same context) scopes will run even if + one raises an error. (Jon Rowe, Trejkaz) +* JsonFormatter no longer dies if `dump_profile` isn't defined (Alex / @MasterLambaster, Jon Rowe) + +### 2.14.4 / 2013-07-21 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.3...v2.14.4) + +Bug fixes + +* Fix regression in 2.14: ensure configured requires (via `-r` option) + are loaded before spec files are loaded. This allows the spec files + to programatically change the file pattern (Jon Rowe). +* Autoload `RSpec::Mocks` and `RSpec::Expectations` when referenced if + they are not already loaded (`RSpec::Matches` has been autoloaded + for a while). In the `rspec` gem, we changed it recently to stop + loading `rspec/mocks` and `rspec/expectations` by default, as some + users reported problems where they were intending to use mocha, + not rspec-mocks, but rspec-mocks was loaded and causing a conflict. + rspec-core loads mocks and expectations at the appropriate time, so + it seemed like a safe change -- but caused a problem for some authors + of libraries that integrate with RSpec. This fixes that problem. + (Myron Marston) +* Gracefully handle a command like `rspec --profile path/to/spec.rb`: + the `path/to/spec.rb` arg was being wrongly treated as the `profile` + integer arg, which got cast `0` using `to_i`, causing no profiled + examples to be printed. (Jon Rowe) + +### 2.14.3 / 2013-07-13 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.2...v2.14.3) + +Bug fixes + +* Fix deprecation notices issued from `RSpec::Core::RakeTask` so + that they work properly when all of rspec-core is not loaded. + (This was a regression in 2.14) (Jon Rowe) + +### 2.14.2 / 2013-07-09 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.1...v2.14.2) + +Bug fixes + +* Fix regression caused by 2.14.1 release: formatters that + report that they `respond_to?` a notification, but had + no corresponding method would raise an error when registered. + The new fix is to just implement `start` on the deprecation + formatter to fix the original JRuby/ruby-debug issue. + (Jon Rowe) + +### 2.14.1 / 2013-07-08 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.0...v2.14.1) + +Bug fixes + +* Address deprecation formatter failure when using `ruby-debug` on + JRuby: fix `RSpec::Core::Reporter` to not send a notification + when the formatter's implementation of the notification method + comes from `Kernel` (Alex Portnov, Jon Rowe). + +### 2.14.0 / 2013-07-06 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.14.0.rc1...v2.14.0) + +Enhancements + +* Apply focus to examples defined with `fit` (equivalent of + `it "description", focus: true`) (Michael de Silva) + +Bug fix + +* Ensure methods defined by `let` take precedence over others + when there is a name collision (e.g. from an included module). + (Jon Rowe, Andy Lindeman and Myron Marston) + +### 2.14.0.rc1 / 2013-05-27 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.13.1...v2.14.0.rc1) + +Enhancements + +* Improved Windows detection inside Git Bash, for better `--color` handling. +* Add profiling of the slowest example groups to `--profile` option. + The output is sorted by the slowest average example groups. +* Don't show slow examples if there's a failure and both `--fail-fast` + and `--profile` options are used (Paweł Gościcki). +* Rather than always adding `spec` to the load path, add the configured + `--default-path` to the load path (which defaults to `spec`). This + better supports folks who choose to put their specs in a different + directory (John Feminella). +* Add some logic to test time duration precision. Make it a + function of time, dropping precision as the time increases. (Aaron Kromer) +* Add new `backtrace_inclusion_patterns` config option. Backtrace lines + that match one of these patterns will _always_ be included in the + backtrace, even if they match an exclusion pattern, too (Sam Phippen). +* Support ERB trim mode using the `-` when parsing `.rspec` as ERB + (Gabor Garami). +* Give a better error message when let and subject are called without a block. + (Sam Phippen). +* List the precedence of `.rspec-local` in the configuration documentation + (Sam Phippen) +* Support `{a,b}` shell expansion syntax in `--pattern` option + (Konstantin Haase). +* Add cucumber documentation for --require command line option + (Bradley Schaefer) +* Expose configuration options via config: + * `config.libs` returns the libs configured to be added onto the load path + * `full_backtrace?` returns the state of the backtrace cleaner + * `debug?` returns true when the debugger is loaded + * `line_numbers` returns the line numbers we are filtering by (if any) + * `full_description` returns the RegExp used to filter descriptions + (Jon Rowe) +* Add setters for RSpec.world and RSpec.configuration (Alex Soulim) +* Configure ruby's warning behaviour with `--warnings` (Jon Rowe) +* Fix an obscure issue on old versions of `1.8.7` where `Time.dup` wouldn't + allow access to `Time.now` (Jon Rowe) +* Make `shared_examples_for` context aware, so that keys may be safely reused + in multiple contexts without colliding. (Jon Rowe) +* Add a configurable `deprecation_stream` (Jon Rowe) +* Publish deprecations through a formatter (David Chelimsky) + +Bug fixes + +* Make JSON formatter behave the same when it comes to `--profile` as + the text formatter (Paweł Gościcki). +* Fix named subjects so that if an inner group defines a method that + overrides the named method, `subject` still retains the originally + declared value (Myron Marston). +* Fix random ordering so that it does not cause `rand` in examples in + nested sibling contexts to return the same value (Max Shytikov). +* Use the new `backtrace_inclusion_patterns` config option to ensure + that folks who develop code in a directory matching one of the default + exclusion patterns (e.g. `gems`) still get the normal backtrace + filtering (Sam Phippen). +* Fix ordering of `before` hooks so that `before` hooks declared in + `RSpec.configure` run before `before` hooks declared in a shared + context (Michi Huber and Tejas Dinkar). +* Fix `Example#full_description` so that it gets filled in by the last + matcher description (as `Example#description` already did) when no + doc string has been provided (David Chelimsky). +* Fix the memoized methods (`let` and `subject`) leaking `define_method` + as a `public` method. (Thomas Holmes and Jon Rowe) (#873) +* Fix warnings coming from the test suite. (Pete Higgins) + +Deprecations + +* Deprecate `Configuration#backtrace_clean_patterns` in favor of + `Configuration#backtrace_exclusion_patterns` for greater consistency + and symmetry with new `backtrace_inclusion_patterns` config option + (Sam Phippen). +* Deprecate `Configuration#requires=` in favor of using ruby's + `require`. Requires specified by the command line can still be + accessed by the `Configuration#require` reader. (Bradley Schaefer) +* Deprecate calling `SharedExampleGroups` defined across sibling contexts + (Jon Rowe) + +### 2.13.1 / 2013-03-12 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.13.0...v2.13.1) + +Bug fixes + +* Use hook classes as proxies rather than extending hook blocks to support + lambdas for before/after/around hooks. (David Chelimsky) +* Fix regression in 2.13.0 that caused confusing behavior when overriding + a named subject with an unnamed subject in an inner group and then + referencing the outer group subject's name. The fix for this required + us to disallow using `super` in a named subject (which is confusing, + anyway -- named subjects create 2 methods, so which method on the + parent example group are you `super`ing to?) but `super` in an unnamed + subject continues to work (Myron Marston). +* Do not allow a referenced `let` or `subject` in `before(:all)` to cause + other `let` declarations to leak across examples (Myron Marston). +* Work around odd ruby 1.9 bug with `String#match` that was triggered + by passing it a regex from a `let` declaration. For more info, see + http://bugs.ruby-lang.org/issues/8059 (Aaron Kromer). +* Add missing `require 'set'` to `base_text_formatter.rb` (Tom + Anderson). + +Deprecations + +* Deprecate accessing `let` or `subject` declarations in `before(:all)`. + These were not intended to be called in a `before(:all)` hook, as + they exist to define state that is reset between each example, while + `before(:all)` exists to define state that is shared across examples + in an example group (Myron Marston). + +### 2.13.0 / 2013-02-23 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.12.2...v2.13.0) + +Enhancements + +* Allow `--profile` option to take a count argument that + determines the number of slow examples to dump + (Greggory Rothmeier). +* Add `subject!` that is the analog to `let!`. It defines an + explicit subject and sets a `before` hook that will invoke + the subject (Zubin Henner). +* Fix `let` and `subject` declaration so that `super` + and `return` can be used in them, just like in a normal + method. (Myron Marston) +* Allow output colors to be configured individually. + (Charlie Maffitt) +* Always dump slow examples when `--profile` option is given, + even when an example failed (Myron Marston). + +Bug fixes + +* Don't blow up when dumping error output for instances + of anonymous error classes (Myron Marston). +* Fix default backtrace filters so lines from projects + containing "gems" in the name are not filtered, but + lines from installed gems still are (Myron Marston). +* Fix autotest command so that is uses double quotes + rather than single quotes for windows compatibility + (Jonas Tingeborn). +* Fix `its` so that uses of `subject` in a `before` or `let` + declaration in the parent group continue to reference the + parent group's subject. (Olek Janiszewski) + +### 2.12.2 / 2012-12-13 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.12.1...v2.12.2) + +Bug fixes + +* Fix `RSpec::Core::RakeTask` so that it is compatible with rake 0.8.7 + on ruby 1.8.7. We had accidentally broke it in the 2.12 release + (Myron Marston). +* Fix `RSpec::Core::RakeTask` so it is tolerant of the `Rspec` constant + for backwards compatibility (Patrick Van Stee) + +### 2.12.1 / 2012-12-01 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.12.0...v2.12.1) + +Bug fixes + +* Specs are run even if another at\_exit hook calls `exit`. This allows + Test::Unit and RSpec to run together. (Suraj N. Kurapati) +* Fix full doc string concatenation so that it handles the case of a + method string (e.g. "#foo") being nested under a context string + (e.g. "when it is tuesday"), so that we get "when it is tuesday #foo" + rather than "when it is tuesday#foo". (Myron Marston) +* Restore public API I unintentionally broke in 2.12.0: + `RSpec::Core::Formatters::BaseFormatter#format_backtrce(backtrace, example)` + (Myron Marston). + +### 2.12.0 / 2012-11-12 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.11.1...v2.12.0) + +Enhancements + +* Add support for custom ordering strategies for groups and examples. + (Myron Marston) +* JSON Formatter (Alex Chaffee) +* Refactor rake task internals (Sam Phippen) +* Refactor HtmlFormatter (Pete Hodgson) +* Autotest supports a path to Ruby that contains spaces (dsisnero) +* Provide a helpful warning when a shared example group is redefined. + (Mark Burns). +* `--default_path` can be specified as `--default-line`. `--line_number` can be + specified as `--line-number`. Hyphens are more idiomatic command line argument + separators (Sam Phippen). +* A more useful error message is shown when an invalid command line option is + used (Jordi Polo). +* Add `format_docstrings { |str| }` config option. It can be used to + apply formatting rules to example group and example docstrings. + (Alex Tan) +* Add support for an `.rspec-local` options file. This is intended to + allow individual developers to set options in a git-ignored file that + override the common project options in `.rspec`. (Sam Phippen) +* Support for mocha 0.13.0. (Andy Lindeman) + +Bug fixes + +* Remove override of `ExampleGroup#ancestors`. This is a core ruby method that + RSpec shouldn't override. Instead, define `ExampleGroup#parent_groups`. (Myron + Marston) +* Limit monkey patching of shared example/context declaration methods + (`shared_examples_for`, etc.) to just the objects that need it rather than + every object in the system (Myron Marston). +* Fix Metadata#fetch to support computed values (Sam Goldman). +* Named subject can now be referred to from within subject block in a nested + group (tomykaira). +* Fix `fail_fast` so that it properly exits when an error occurs in a + `before(:all) hook` (Bradley Schaefer). +* Make the order spec files are loaded consistent, regardless of the + order of the files returned by the OS or the order passed at + the command line (Jo Liss and Sam Phippen). +* Ensure instance variables from `before(:all)` are always exposed + from `after(:all)`, even if an error occurs in `before(:all)` + (Sam Phippen). +* `rspec --init` no longer generates an incorrect warning about `--configure` + being deprecated (Sam Phippen). +* Fix pluralization of `1 seconds` (Odin Dutton) +* Fix ANSICON url (Jarmo Pertman) +* Use dup of Time so reporting isn't clobbered by examples that modify Time + without properly restoring it. (David Chelimsky) + +Deprecations + +* `share_as` is no longer needed. `shared_context` and/or + `RSpec::SharedContext` provide better mechanisms (Sam Phippen). +* Deprecate `RSpec.configuration` with a block (use `RSpec.configure`). + + +### 2.11.1 / 2012-07-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.11.0...v2.11.1) + +Bug fixes + +* Fix the way we autoload RSpec::Matchers so that custom matchers can be + defined before rspec-core has been configured to definitely use + rspec-expectations. (Myron Marston) +* Fix typo in --help message printed for -e option. (Jo Liss) +* Fix ruby warnings. (Myron Marston) +* Ignore mock expectation failures when the example has already failed. + Mock expectation failures have always been ignored in this situation, + but due to my changes in 27059bf1 it was printing a confusing message. + (Myron Marston). + +### 2.11.0 / 2012-07-07 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.10.1...v2.11.0) + +Enhancements + +* Support multiple `--example` options. (Daniel Doubrovkine @dblock) +* Named subject e.g. `subject(:article) { Article.new }` + * see [http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/](http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/) + for background. + * thanks to Bradley Schaefer for suggesting it and Avdi Grimm for almost + suggesting it. +* `config.mock_with` and `config.expect_with` yield custom config object to a + block if given + * aids decoupling from rspec-core's configuation +* `include_context` and `include_examples` support a block, which gets eval'd + in the current context (vs the nested context generated by `it_behaves_like`). +* Add `config.order = 'random'` to the `spec_helper.rb` generated by `rspec + --init`. +* Delay the loading of DRb (Myron Marston). +* Limit monkey patching of `describe` onto just the objects that need it rather + than every object in the system (Myron Marston). + +Bug fixes + +* Support alternative path separators. For example, on Windows, you can now do + this: `rspec spec\subdir`. (Jarmo Pertman @jarmo) +* When an example raises an error and an after or around hook does as + well, print out the hook error. Previously, the error was silenced and + the user got no feedback about what happened. (Myron Marston) +* `--require` and `-I` are merged among different configuration sources (Andy + Lindeman) +* Delegate to mocha methods instead of aliasing them in mocha adapter. + +### 2.10.1 / 2012-05-19 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.10.0...v2.10.1) + +Bug fixes + +* `RSpec.reset` properly reinits configuration and world +* Call `to_s` before `split` on exception messages that might not always be + Strings (slyphon) + +### 2.10.0 / 2012-05-03 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.9.0...v2.10.0) + +Enhancements + +* Add `prepend_before` and `append_after` hooks (preethiramdev) + * intended for extension libs + * restores rspec-1 behavior +* Reporting of profiled examples (moro) + * Report the total amount of time taken for the top slowest examples. + * Report what percentage the slowest examples took from the total runtime. + +Bug fixes + +* Properly parse `SPEC_OPTS` options. +* `example.description` returns the location of the example if there is no + explicit description or matcher-generated description. +* RDoc fixes (Grzegorz Świrski) +* Do not modify example ancestry when dumping errors (Michael Grosser) + +### 2.9.0 / 2012-03-17 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.8.0...v2.9.0) + +Enhancements + +* Support for "X minutes X seconds" spec run duration in formatter. (uzzz) +* Strip whitespace from group and example names in doc formatter. +* Removed spork-0.9 shim. If you're using spork-0.8.x, you'll need to upgrade + to 0.9.0. + +Bug fixes + +* Restore `--full_backtrace` option +* Ensure that values passed to `config.filter_run` are respected when running + over DRb (using spork). +* Ensure shared example groups are reset after a run (as example groups are). +* Remove `rescue false` from calls to filters represented as Procs +* Ensure `described_class` gets the closest constant (pyromaniac) +* In "autorun", don't run the specs in the `at_exit` hook if there was an + exception (most likely due to a SyntaxError). (sunaku) +* Don't extend groups with modules already used to extend ancestor groups. +* `its` correctly memoizes nil or false values (Yamada Masaki) + +### 2.8.0 / 2012-01-04 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.8.0.rc2...v2.8.0) + +Bug fixes + +* For metadata filtering, restore passing the entire array to the proc, rather + than each item in the array (weidenfreak) +* Ensure each spec file is loaded only once + * Fixes a bug that caused all the examples in a file to be run when + referenced twice with line numbers in a command, e.g. + * `rspec path/to/file:37 path/to/file:42` + +### 2.8.0.rc2 / 2011-12-19 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.8.0.rc1...v2.8.0.rc2) + +Enhancments + +* new `--init` command (Peter Schröder) + * generates `spec/spec_helper.rb` + * deletes obsolete files (on confirmation) + * merged with and deprecates `--configure` command, which generated + `.rspec` +* use `require_relative` when available (Ian Leitch) +* `include_context` and `include_examples` accept params (Calvin Bascom) +* print the time for every example in the html formatter (Richie Vos) +* several tasty refactoring niblets (Sasha) +* `it "does something", :x => [:foo,'bar',/baz/] (Ivan Neverov) + * supports matching n command line tag values with an example or group + +### 2.8.0.rc1 / 2011-11-06 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.7.1...v2.8.0.rc1) + +Enhancements + +* `--order` (Justin Ko) + * run examples in random order: `--order rand` + * specify the seed: `--order rand:123` +* `--seed SEED` + * equivalent of `--order rand:SEED` +* SharedContext supports `let` (David Chelimsky) +* Filter improvements (David Chelimsky) + * override opposing tags from the command line + * override RSpec.configure tags from the command line + * `--line_number 37` overrides all other filters + * `path/to/file.rb:37` overrides all other filters + * refactor: consolidate filter management in a FilterManger object +* Eliminate Ruby warnings (Matijs van Zuijlen) +* Make reporter.report an API (David Chelimsky) + * supports extension tools like interative_rspec + +Changes + +* change `config.color_enabled` (getter/setter/predicate) to `color` to align + with `--[no]-color` CLI option. + * `color_enabled` is still supported for now, but will likley be deprecated + in a 2.x release so we can remove it in 3.0. + +Bug fixes + +* Make sure the `bar` in `--tag foo:bar` makes it to DRb (Aaron Gibralter) +* Fix bug where full descriptions of groups nested 3 deep were repeated. +* Restore report of time to run to start after files are loaded. + * fixes bug where run times were cumalitive in spork + * fixes compatibility with time-series metrics +* Don't error out when `config.mock_with` or `expect_with` is re-specifying the + current config (Myron Marston) + +* Deprecations + * :alias option on `configuration.add_setting`. Use `:alias_with` on the + original setting declaration instead. + +### 2.7.1 / 2011-10-20 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.7.0...v2.7.1) + +Bug fixes + +* tell autotest the correct place to find the rspec executable + +### 2.7.0 / 2011-10-16 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.6.4...v2.7.0) + +NOTE: RSpec's release policy dictates that there should not be any backward +incompatible changes in minor releases, but we're making an exception to +release a change to how RSpec interacts with other command line tools. + +As of 2.7.0, you must explicity `require "rspec/autorun"` unless you use the +`rspec` command (which already does this for you). + +Enhancements + +* Add `example.exception` (David Chelimsky) +* `--default_path` command line option (Justin Ko) +* support multiple `--line_number` options (David J. Hamilton) + * also supports `path/to/file.rb:5:9` (runs examples on lines 5 and 9) +* Allow classes/modules to be used as shared example group identifiers (Arthur + Gunn) +* Friendly error message when shared context cannot be found (Sławosz + Sławiński) +* Clear formatters when resetting config (John Bintz) +* Add `xspecify` and xexample as temp-pending methods (David Chelimsky) +* Add `--no-drb` option (Iain Hecker) +* Provide more accurate run time by registering start time before code is + loaded (David Chelimsky) + * reverted in 2.8.0 +* Rake task default pattern finds specs in symlinked dirs (Kelly Felkins) +* Rake task no longer does anything to invoke bundler since Bundler already + handles it for us. Thanks to Andre Arko for the tip. +* Add `--failure-exit-code` option (Chris Griego) + +Bug fixes + +* Include `Rake::DSL` to remove deprecation warnings in Rake > 0.8.7 (Pivotal + Casebook) +* Only eval `let` block once even if it returns `nil` (Adam Meehan) +* Fix `--pattern` option (wasn't being recognized) (David Chelimsky) +* Only implicitly `require "rspec/autorun"` with the `rspec` command (David + Chelimsky) +* Ensure that rspec's `at_exit` defines the exit code (Daniel Doubrovkine) +* Show the correct snippet in the HTML and TextMate formatters (Brian Faherty) + +### 2.6.4 / 2011-06-06 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.6.3...v2.6.4) + +NOTE: RSpec's release policy dictates that there should not be new +functionality in patch releases, but this minor enhancement slipped in by +accident. As it doesn't add a new API, we decided to leave it in rather than +roll back this release. + +Enhancements + +* Add summary of commands to run individual failed examples. + +Bug fixes + +* Support exclusion filters in DRb. (Yann Lugrin) +* Fix --example escaping when run over DRb. (Elliot Winkler) +* Use standard ANSI codes for color formatting so colors work in a wider set of + color schemes. + +### 2.6.3 / 2011-05-24 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.6.2...v2.6.3) + +Bug fixes + +* Explicitly convert exit code to integer, avoiding TypeError when return + value of run is IO object proxied by `DRb::DRbObject` (Julian Scheid) +* Clarify behavior of `--example` command line option +* Build using a rubygems-1.6.2 to avoid downstream yaml parsing error + +### 2.6.2 / 2011-05-21 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.6.1...v2.6.2) + +Bug fixes + +* Warn rather than raise when HOME env var is not defined +* Properly merge command-line exclusions with default :if and :unless (joshcooper) + +### 2.6.1 / 2011-05-19 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.6.0...v2.6.1) + +Bug fixes + +* Don't extend nil when filters are nil +* `require 'rspec/autorun'` when running rcov. + +### 2.6.0 / 2011-05-12 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.5.1...v2.6.0) + +Enhancements + +* `shared_context` (Damian Nurzynski) + * extend groups matching specific metadata with: + * method definitions + * subject declarations + * let/let! declarations + * etc (anything you can do in a group) +* `its([:key])` works for any subject with #[]. (Peter Jaros) +* `treat_symbols_as_metadata_keys_with_true_values` (Myron Marston) +* Print a deprecation warning when you configure RSpec after defining an + example. All configuration should happen before any examples are defined. + (Myron Marston) +* Pass the exit status of a DRb run to the invoking process. This causes specs + run via DRb to not just return true or false. (Ilkka Laukkanen) +* Refactoring of `ConfigurationOptions#parse_options` (Rodrigo Rosenfeld Rosas) +* Report excluded filters in runner output (tip from andyl) +* Clean up messages for filters/tags. +* Restore --pattern/-P command line option from rspec-1 +* Support false as well as true in config.full_backtrace= (Andreas Tolf + Tolfsen) + +Bug fixes + +* Don't stumble over an exception without a message (Hans Hasselberg) +* Remove non-ascii characters from comments that were choking rcov (Geoffrey + Byers) +* Fixed backtrace so it doesn't include lines from before the autorun at_exit + hook (Myron Marston) +* Include RSpec::Matchers when first example group is defined, rather than just + before running the examples. This works around an obscure bug in ruby 1.9 + that can cause infinite recursion. (Myron Marston) +* Don't send `example_group_[started|finished]` to formatters for empty groups. +* Get specs passing on jruby (Sidu Ponnappa) +* Fix bug where mixing nested groups and outer-level examples gave + unpredictable :line_number behavior (Artur Małecki) +* Regexp.escape the argument to --example (tip from Elliot Winkler) +* Correctly pass/fail pending block with message expectations +* CommandLine returns exit status (0/1) instead of true/false +* Create path to formatter output file if it doesn't exist (marekj). + + +### 2.5.1 / 2011-02-06 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.5.0...v2.5.1) + +NOTE: this release breaks compatibility with rspec/autotest/bundler +integration, but does so in order to greatly simplify it. + +With this release, if you want the generated autotest command to include +'bundle exec', require Autotest's bundler plugin in a .autotest file in the +project's root directory or in your home directory: + + require "autotest/bundler" + +Now you can just type 'autotest' on the commmand line and it will work as you expect. + +If you don't want 'bundle exec', there is nothing you have to do. + +### 2.5.0 / 2011-02-05 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.4.0...v2.5.0) + +Enhancements + +* Autotest::Rspec2 parses command line args passed to autotest after '--' +* --skip-bundler option for autotest command +* Autotest regexp fixes (Jon Rowe) +* Add filters to html and textmate formatters (Daniel Quimper) +* Explicit passing of block (need for JRuby 1.6) (John Firebaugh) + +Bug fixes + +* fix dom IDs in HTML formatter (Brian Faherty) +* fix bug with --drb + formatters when not running in drb +* include --tag options in drb args (monocle) +* fix regression so now SPEC_OPTS take precedence over CLI options again (Roman + Chernyatchik) +* only call its(:attribute) once (failing example from Brian Dunn) +* fix bizarre bug where rspec would hang after String.alias :to_int :to_i + (Damian Nurzynski) + +Deprecations + +* implicit inclusion of 'bundle exec' when Gemfile present (use autotest's + bundler plugin instead) + +### 2.4.0 / 2011-01-02 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.3.1...v2.4.0) + +Enhancements + +* start the debugger on -d so the stack trace is visible when it stops + (Clifford Heath) +* apply hook filtering to examples as well as groups (Myron Marston) +* support multiple formatters, each with their own output +* show exception classes in failure messages unless they come from RSpec + matchers or message expectations +* before(:all) { pending } sets all examples to pending + +Bug fixes + +* fix bug due to change in behavior of reject in Ruby 1.9.3-dev (Shota + Fukumori) +* fix bug when running in jruby: be explicit about passing block to super (John + Firebaugh) +* rake task doesn't choke on paths with quotes (Janmejay Singh) +* restore --options option from rspec-1 +* require 'ostruct' to fix bug with its([key]) (Kim Burgestrand) +* --configure option generates .rspec file instead of autotest/discover.rb + +### 2.3.1 / 2010-12-16 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.3.0...v2.3.1) + +Bug fixes + +* send debugger warning message to $stdout if RSpec.configuration.error_stream + has not been defined yet. +* HTML Formatter _finally_ properly displays nested groups (Jarmo Pertman) +* eliminate some warnings when running RSpec's own suite (Jarmo Pertman) + +### 2.3.0 / 2010-12-12 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.2.1...v2.3.0) + +Enhancements + +* tell autotest to use "rspec2" if it sees a .rspec file in the project's root + directory + * replaces the need for ./autotest/discover.rb, which will not work with + all versions of ZenTest and/or autotest +* config.expect_with + * :rspec # => rspec/expectations + * :stdlib # => test/unit/assertions + * :rspec, :stdlib # => both + +Bug fixes + +* fix dev Gemfile to work on non-mac-os machines (Lake Denman) +* ensure explicit subject is only eval'd once (Laszlo Bacsi) + +### 2.2.1 / 2010-11-28 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.2.0...v2.2.1) + +Bug fixes +* alias_method instead of override Kernel#method_missing (John Wilger) +* changed --autotest to --tty in generated command (MIKAMI Yoshiyuki) +* revert change to debugger (had introduced conflict with Rails) + * also restored --debugger/-debug option + +### 2.2.0 / 2010-11-28 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.1.0...v2.2.0) + +Deprecations/changes + +* --debug/-d on command line is deprecated and now has no effect +* win32console is now ignored; Windows users must use ANSICON for color support + (Bosko Ivanisevic) + +Enhancements + +* When developing locally rspec-core now works with the rspec-dev setup or your + local gems +* Raise exception with helpful message when rspec-1 is loaded alongside rspec-2 + (Justin Ko) +* debugger statements _just work_ as long as ruby-debug is installed + * otherwise you get warned, but not fired +* Expose example.metadata in around hooks +* Performance improvments (much faster now) + +Bug fixes + +* Make sure --fail-fast makes it across drb +* Pass -Ilib:spec to rcov + +### 2.1.0 / 2010-11-07 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.0.1...v2.1.0) + +Enhancments + +* Add skip_bundler option to rake task to tell rake task to ignore the presence + of a Gemfile (jfelchner) +* Add gemfile option to rake task to tell rake task what Gemfile to look for + (defaults to 'Gemfile') +* Allow passing caller trace into Metadata to support extensions (Glenn + Vanderburg) +* Add deprecation warning for Spec::Runner.configure to aid upgrade from + RSpec-1 +* Add deprecated Spec::Rake::SpecTask to aid upgrade from RSpec-1 +* Add 'autospec' command with helpful message to aid upgrade from RSpec-1 +* Add support for filtering with tags on CLI (Lailson Bandeira) +* Add a helpful message about RUBYOPT when require fails in bin/rspec (slyphon) +* Add "-Ilib" to the default rcov options (Tianyi Cui) +* Make the expectation framework configurable (default rspec, of course) + (Justin Ko) +* Add 'pending' to be conditional (Myron Marston) +* Add explicit support for :if and :unless as metadata keys for conditional run + of examples (Myron Marston) +* Add --fail-fast command line option (Jeff Kreeftmeijer) + +Bug fixes + +* Eliminate stack overflow with "subject { self }" +* Require 'rspec/core' in the Raketask (ensures it required when running rcov) + +### 2.0.1 / 2010-10-18 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.0.0...v2.0.1) + +Bug fixes + +* Restore color when using spork + autotest +* Pending examples without docstrings render the correct message (Josep M. + Bach) +* Fixed bug where a failure in a spec file ending in anything but _spec.rb + would fail in a confusing way. +* Support backtrace lines from erb templates in html formatter (Alex Crichton) + +### 2.0.0 / 2010-10-10 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.0.0.rc...v2.0.0) + +RSpec-1 compatibility + +* Rake task uses ENV["SPEC"] as file list if present + +Bug fixes + +* Bug Fix: optparse --out foo.txt (Leonardo Bessa) +* Suppress color codes for non-tty output (except autotest) + +### 2.0.0.rc / 2010-10-05 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.0.0.beta.22...v2.0.0.rc) + +Enhancements + +* implicitly require unknown formatters so you don't have to require the file + explicitly on the commmand line (Michael Grosser) +* add --out/-o option to assign output target +* added fail_fast configuration option to abort on first failure +* support a Hash subject (its([:key]) { should == value }) (Josep M. Bach) + +Bug fixes + +* Explicitly require rspec version to fix broken rdoc task (Hans de Graaff) +* Ignore backtrace lines that come from other languages, like Java or + Javascript (Charles Lowell) +* Rake task now does what is expected when setting (or not setting) + fail_on_error and verbose +* Fix bug in which before/after(:all) hooks were running on excluded nested + groups (Myron Marston) +* Fix before(:all) error handling so that it fails examples in nested groups, + too (Myron Marston) + +### 2.0.0.beta.22 / 2010-09-12 + +[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.0.0.beta.20...v2.0.0.beta.22) + +Enhancements + +* removed at_exit hook +* CTRL-C stops the run (almost) immediately + * first it cleans things up by running the appropriate after(:all) and + after(:suite) hooks + * then it reports on any examples that have already run +* cleaned up rake task + * generate correct task under variety of conditions + * options are more consistent + * deprecated redundant options +* run 'bundle exec autotest' when Gemfile is present +* support ERB in .rspec options files (Justin Ko) +* depend on bundler for development tasks (Myron Marston) +* add example_group_finished to formatters and reporter (Roman Chernyatchik) + +Bug fixes + +* support paths with spaces when using autotest (Andreas Neuhaus) +* fix module_exec with ruby 1.8.6 (Myron Marston) +* remove context method from top-level + * was conflicting with irb, for example +* errors in before(:all) are now reported correctly (Chad Humphries) + +Removals + +* removed -o --options-file command line option + * use ./.rspec and ~/.rspec diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/License.txt b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/License.txt new file mode 100644 index 000000000..4bd202ec2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/License.txt @@ -0,0 +1,25 @@ +(The MIT License) + +Copyright (c) 2012 Chad Humphries, David Chelimsky, Myron Marston +Copyright (c) 2009 Chad Humphries, David Chelimsky +Copyright (c) 2006 David Chelimsky, The RSpec Development Team +Copyright (c) 2005 Steven Baker + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/README.md b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/README.md new file mode 100644 index 000000000..3cd7e7290 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/README.md @@ -0,0 +1,243 @@ +# rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.png?branch=master)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.png)](https://codeclimate.com/github/rspec/rspec-core) + +rspec-core provides the structure for writing executable examples of how your +code should behave, and an `rspec` command with tools to constrain which +examples get run and tailor the output. + +## install + + gem install rspec # for rspec-core, rspec-expectations, rspec-mocks + gem install rspec-core # for rspec-core only + rspec --help + +## basic structure + +RSpec uses the words "describe" and "it" so we can express concepts like a conversation: + + "Describe an order." + "It sums the prices of its line items." + +```ruby +RSpec.describe Order do + it "sums the prices of its line items" do + order = Order.new + order.add_entry(LineItem.new(:item => Item.new( + :price => Money.new(1.11, :USD) + ))) + order.add_entry(LineItem.new(:item => Item.new( + :price => Money.new(2.22, :USD), + :quantity => 2 + ))) + expect(order.total).to eq(Money.new(5.55, :USD)) + end +end +``` + +The `describe` method creates an [ExampleGroup](http://rubydoc.info/gems/rspec-core/RSpec/Core/ExampleGroup). Within the +block passed to `describe` you can declare examples using the `it` method. + +Under the hood, an example group is a class in which the block passed to +`describe` is evaluated. The blocks passed to `it` are evaluated in the +context of an _instance_ of that class. + +## nested groups + +You can also declare nested nested groups using the `describe` or `context` +methods: + +```ruby +RSpec.describe Order do + context "with no items" do + it "behaves one way" do + # ... + end + end + + context "with one item" do + it "behaves another way" do + # ... + end + end +end +``` + +## aliases + +You can declare example groups using either `describe` or `context`. +For a top level example group, `describe` and `context` are available +off of `RSpec`. For backwards compatibility, they are also available +off of the `main` object and `Module` unless you disable monkey +patching. + +You can declare examples within a group using any of `it`, `specify`, or +`example`. + +## shared examples and contexts + +Declare a shared example group using `shared_examples`, and then include it +in any group using `include_examples`. + +```ruby +RSpec.shared_examples "collections" do |collection_class| + it "is empty when first created" do + expect(collection_class.new).to be_empty + end +end + +RSpec.describe Array do + include_examples "collections", Array +end + +RSpec.describe Hash do + include_examples "collections", Hash +end +``` + +Nearly anything that can be declared within an example group can be declared +within a shared example group. This includes `before`, `after`, and `around` +hooks, `let` declarations, and nested groups/contexts. + +You can also use the names `shared_context` and `include_context`. These are +pretty much the same as `shared_examples` and `include_examples`, providing +more accurate naming when you share hooks, `let` declarations, helper methods, +etc, but no examples. + +## metadata + +rspec-core stores a metadata hash with every example and group, which +contains their descriptions, the locations at which they were +declared, etc, etc. This hash powers many of rspec-core's features, +including output formatters (which access descriptions and locations), +and filtering before and after hooks. + +Although you probably won't ever need this unless you are writing an +extension, you can access it from an example like this: + +```ruby +it "does something" do + expect(example.metadata[:description]).to eq("does something") +end +``` + +### `described_class` + +When a class is passed to `describe`, you can access it from an example +using the `described_class` method, which is a wrapper for +`example.metadata[:described_class]`. + +```ruby +RSpec.describe Widget do + example do + expect(described_class).to equal(Widget) + end +end +``` + +This is useful in extensions or shared example groups in which the specific +class is unknown. Taking the collections shared example group from above, we can +clean it up a bit using `described_class`: + +```ruby +RSpec.shared_examples "collections" do + it "is empty when first created" do + expect(described_class.new).to be_empty + end +end + +RSpec.describe Array do + include_examples "collections" +end + +RSpec.describe Hash do + include_examples "collections" +end +``` + +## the `rspec` command + +When you install the rspec-core gem, it installs the `rspec` executable, +which you'll use to run rspec. The `rspec` command comes with many useful +options. +Run `rspec --help` to see the complete list. + +## store command line options `.rspec` + +You can store command line options in a `.rspec` file in the project's root +directory, and the `rspec` command will read them as though you typed them on +the command line. + +## autotest integration + +rspec-core no longer ships with an Autotest extension, if you require Autotest +integration, please use the `rspec-autotest` gem and see [rspec/rspec-autotest](https://github.com/rspec/rspec-autotest) +for details + +## get started + +Start with a simple example of behavior you expect from your system. Do +this before you write any implementation code: + +```ruby +# in spec/calculator_spec.rb +RSpec.describe Calculator do + describe '#add' do + it 'returns the sum of its arguments' do + expect(Calculator.new.add(1, 2)).to eq(3) + end + end +end +``` + +Run this with the rspec command, and watch it fail: + +``` +$ rspec spec/calculator_spec.rb +./spec/calculator_spec.rb:1: uninitialized constant Calculator +``` + +Implement the simplest solution: + +```ruby +# in lib/calculator.rb +class Calculator + def add(a,b) + a + b + end +end +``` + +Be sure to require the implementation file in the spec: + +```ruby +# in spec/calculator_spec.rb +# - RSpec adds ./lib to the $LOAD_PATH +require "calculator" +``` + +Now run the spec again, and watch it pass: + +``` +$ rspec spec/calculator_spec.rb +. + +Finished in 0.000315 seconds +1 example, 0 failures +``` + +Use the `documentation` formatter to see the resulting spec: + +``` +$ rspec spec/calculator_spec.rb --format doc +Calculator + #add + returns the sum of its arguments + +Finished in 0.000379 seconds +1 example, 0 failures +``` + +## Also see + +* [http://github.com/rspec/rspec](http://github.com/rspec/rspec) +* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations) +* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks) diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/exe/rspec b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/exe/rspec new file mode 100755 index 000000000..7ee5fd89f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/exe/rspec @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require 'rspec/core' +RSpec::Core::Runner.invoke diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/autorun.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/autorun.rb new file mode 100644 index 000000000..18cc1eddb --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/autorun.rb @@ -0,0 +1,2 @@ +require 'rspec/core' +RSpec::Core::Runner.autorun diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core.rb new file mode 100644 index 000000000..528358740 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core.rb @@ -0,0 +1,169 @@ +# rubocop:disable Style/GlobalVars +$_rspec_core_load_started_at = Time.now +# rubocop:enable Style/GlobalVars + +require 'rbconfig' + +require "rspec/support" +RSpec::Support.require_rspec_support "caller_filter" + +RSpec::Support.define_optimized_require_for_rspec(:core) { |f| require_relative f } + +%w[ + version + warnings + + flat_map + filter_manager + dsl + notifications + reporter + + hooks + memoized_helpers + metadata + metadata_filter + pending + formatters + ordering + + world + configuration + option_parser + configuration_options + runner + example + shared_example_group + example_group +].each { |name| RSpec::Support.require_rspec_core name } + +# Namespace for all core RSpec code. +module RSpec + autoload :SharedContext, 'rspec/core/shared_context' + + extend RSpec::Core::Warnings + + # Used to ensure examples get reloaded between multiple runs in + # the same process. + # + # Users must invoke this if they want to have the configuration reset when + # they use runner multiple times within the same process. + def self.reset + @world = nil + @configuration = nil + end + + # Returns the global [Configuration](RSpec/Core/Configuration) object. While you + # _can_ use this method to access the configuration, the more common + # convention is to use [RSpec.configure](RSpec#configure-class_method). + # + # @example + # RSpec.configuration.drb_port = 1234 + # @see RSpec.configure + # @see Core::Configuration + def self.configuration + @configuration ||= begin + config = RSpec::Core::Configuration.new + config.expose_dsl_globally = true + config + end + end + + # Yields the global configuration to a block. + # @yield [Configuration] global configuration + # + # @example + # RSpec.configure do |config| + # config.add_formatter 'documentation' + # end + # @see Core::Configuration + def self.configure + yield configuration if block_given? + end + + # The example being executed. + # + # The primary audience for this method is library authors who need access + # to the example currently being executed and also want to support all + # versions of RSpec 2 and 3. + # + # @example + # + # RSpec.configure do |c| + # # context.example is deprecated, but RSpec.current_example is not + # # available until RSpec 3.0. + # fetch_current_example = RSpec.respond_to?(:current_example) ? + # proc { RSpec.current_example } : proc { |context| context.example } + # + # c.before(:example) do + # example = fetch_current_example.call(self) + # + # # ... + # end + # end + # + def self.current_example + thread_local_metadata[:current_example] + end + + # Set the current example being executed. + # @api private + def self.current_example=(example) + thread_local_metadata[:current_example] = example + end + + # @private + # A single thread local variable so we don't excessively pollute that + # namespace. + def self.thread_local_metadata + Thread.current[:_rspec] ||= {} + end + + # @private + # Internal container for global non-configuration data + def self.world + @world ||= RSpec::Core::World.new + end + + # Namespace for the rspec-core code. + module Core + # @private + # This avoids issues with reporting time caused by examples that + # change the value/meaning of Time.now without properly restoring + # it. + class Time + class << self + define_method(:now, &::Time.method(:now)) + end + end + + # @private path to executable file + def self.path_to_executable + @path_to_executable ||= File.expand_path('../../../exe/rspec', __FILE__) + end + end + + # @private + MODULES_TO_AUTOLOAD = { + :Matchers => "rspec/expectations", + :Expectations => "rspec/expectations", + :Mocks => "rspec/mocks" + } + + # @private + def self.const_missing(name) + # Load rspec-expectations when RSpec::Matchers is referenced. This allows + # people to define custom matchers (using `RSpec::Matchers.define`) before + # rspec-core has loaded rspec-expectations (since it delays the loading of + # it to allow users to configure a different assertion/expectation + # framework). `autoload` can't be used since it works with ruby's built-in + # require (e.g. for files that are available relative to a load path dir), + # but not with rubygems' extended require. + # + # As of rspec 2.14.1, we no longer require `rspec/mocks` and + # `rspec/expectations` when `rspec` is required, so we want + # to make them available as an autoload. + require MODULES_TO_AUTOLOAD.fetch(name) { return super } + ::RSpec.const_get(name) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backport_random.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backport_random.rb new file mode 100644 index 000000000..90046d54e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backport_random.rb @@ -0,0 +1,336 @@ +module RSpec + module Core + # @private + # + # Methods used internally by the backports. + # + # This code was (mostly) ported from the backports gem found at + # https://github.com/marcandre/backports which is subject to this license: + # + # ========================================================================= + # + # Copyright (c) 2009 Marc-Andre Lafortune + # + # Permission is hereby granted, free of charge, to any person obtaining + # a copy of this software and associated documentation files (the + # "Software"), to deal in the Software without restriction, including + # without limitation the rights to use, copy, modify, merge, publish, + # distribute, sublicense, and/or sell copies of the Software, and to + # permit persons to whom the Software is furnished to do so, subject to + # the following conditions: + # + # The above copyright notice and this permission notice shall be + # included in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + # + # ========================================================================= + # + # The goal is to provide a random number generator in Ruby versions that do + # not have one. This was added to support localization of random spec + # ordering. + # + # These were in multiple files in backports, but merged into one here. + module Backports + # Helper method to coerce a value into a specific class. + # Raises a TypeError if the coercion fails or the returned value + # is not of the right class. + # (from Rubinius) + def self.coerce_to(obj, cls, meth) + return obj if obj.kind_of?(cls) + + begin + ret = obj.__send__(meth) + rescue Exception => e + raise TypeError, "Coercion error: #{obj.inspect}.#{meth} => #{cls} failed:\n" \ + "(#{e.message})" + end + raise TypeError, "Coercion error: obj.#{meth} did NOT return a #{cls} (was #{ret.class})" unless ret.kind_of? cls + ret + end + + # @private + def self.coerce_to_int(obj) + coerce_to(obj, Integer, :to_int) + end + + # Used internally to make it easy to deal with optional arguments + # (from Rubinius) + Undefined = Object.new + + # @private + class Random + # @private + # An implementation of Mersenne Twister MT19937 in Ruby + class MT19937 + STATE_SIZE = 624 + LAST_STATE = STATE_SIZE - 1 + PAD_32_BITS = 0xffffffff + + # See seed= + def initialize(seed) + self.seed = seed + end + + LAST_31_BITS = 0x7fffffff + OFFSET = 397 + + # Generates a completely new state out of the previous one. + def next_state + STATE_SIZE.times do |i| + mix = @state[i] & 0x80000000 | @state[i+1 - STATE_SIZE] & 0x7fffffff + @state[i] = @state[i+OFFSET - STATE_SIZE] ^ (mix >> 1) + @state[i] ^= 0x9908b0df if mix.odd? + end + @last_read = -1 + end + + # Seed must be either an Integer (only the first 32 bits will be used) + # or an Array of Integers (of which only the first 32 bits will be used) + # + # No conversion or type checking is done at this level + def seed=(seed) + case seed + when Integer + @state = Array.new(STATE_SIZE) + @state[0] = seed & PAD_32_BITS + (1..LAST_STATE).each do |i| + @state[i] = (1812433253 * (@state[i-1] ^ @state[i-1]>>30) + i)& PAD_32_BITS + end + @last_read = LAST_STATE + when Array + self.seed = 19650218 + i=1 + j=0 + [STATE_SIZE, seed.size].max.times do + @state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1664525) + j + seed[j] & PAD_32_BITS + if (i+=1) >= STATE_SIZE + @state[0] = @state[-1] + i = 1 + end + j = 0 if (j+=1) >= seed.size + end + (STATE_SIZE-1).times do + @state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1566083941) - i & PAD_32_BITS + if (i+=1) >= STATE_SIZE + @state[0] = @state[-1] + i = 1 + end + end + @state[0] = 0x80000000 + else + raise ArgumentError, "Seed must be an Integer or an Array" + end + end + + # Returns a random Integer from the range 0 ... (1 << 32) + def random_32_bits + next_state if @last_read >= LAST_STATE + @last_read += 1 + y = @state[@last_read] + # Tempering + y ^= (y >> 11) + y ^= (y << 7) & 0x9d2c5680 + y ^= (y << 15) & 0xefc60000 + y ^= (y >> 18) + end + + # Supplement the MT19937 class with methods to do + # conversions the same way as MRI. + # No argument checking is done here either. + + FLOAT_FACTOR = 1.0/9007199254740992.0 + # generates a random number on [0,1) with 53-bit resolution + def random_float + ((random_32_bits >> 5) * 67108864.0 + (random_32_bits >> 6)) * FLOAT_FACTOR; + end + + # Returns an integer within 0...upto + def random_integer(upto) + n = upto - 1 + nb_full_32 = 0 + while n > PAD_32_BITS + n >>= 32 + nb_full_32 += 1 + end + mask = mask_32_bits(n) + begin + rand = random_32_bits & mask + nb_full_32.times do + rand <<= 32 + rand |= random_32_bits + end + end until rand < upto + rand + end + + def random_bytes(nb) + nb_32_bits = (nb + 3) / 4 + random = nb_32_bits.times.map { random_32_bits } + random.pack("L" * nb_32_bits)[0, nb] + end + + def state_as_bignum + b = 0 + @state.each_with_index do |val, i| + b |= val << (32 * i) + end + b + end + + def left # It's actually the number of words left + 1, as per MRI... + MT19937::STATE_SIZE - @last_read + end + + def marshal_dump + [state_as_bignum, left] + end + + def marshal_load(ary) + b, left = ary + @last_read = MT19937::STATE_SIZE - left + @state = Array.new(STATE_SIZE) + STATE_SIZE.times do |i| + @state[i] = b & PAD_32_BITS + b >>= 32 + end + end + + # Convert an Integer seed of arbitrary size to either a single 32 bit integer, or an Array of 32 bit integers + def self.convert_seed(seed) + seed = seed.abs + long_values = [] + begin + long_values << (seed & PAD_32_BITS) + seed >>= 32 + end until seed == 0 + + long_values.pop if long_values[-1] == 1 && long_values.size > 1 # Done to allow any kind of sequence of integers + + long_values.size > 1 ? long_values : long_values.first + end + + def self.[](seed) + new(convert_seed(seed)) + end + + private + + MASK_BY = [1,2,4,8,16] + def mask_32_bits(n) + MASK_BY.each do |shift| + n |= n >> shift + end + n + end + end + + # @private + # Implementation corresponding to the actual Random class of Ruby + # The actual random generator (mersenne twister) is in MT19937. + # Ruby specific conversions are handled in bits_and_bytes. + # The high level stuff (argument checking) is done here. + module Implementation + attr_reader :seed + + def initialize(seed = 0) + super() + seed_rand seed + end + + def seed_rand(new_seed = 0) + new_seed = Backports.coerce_to_int(new_seed) + @seed = nil unless defined?(@seed) + old, @seed = @seed, new_seed.nonzero? || Random.new_seed + @mt = MT19937[ @seed ] + old + end + + def rand(limit = Backports::Undefined) + case limit + when Backports::Undefined + @mt.random_float + when Float + limit * @mt.random_float unless limit <= 0 + when Range + _rand_range(limit) + else + limit = Backports.coerce_to_int(limit) + @mt.random_integer(limit) unless limit <= 0 + end || raise(ArgumentError, "invalid argument #{limit}") + end + + def bytes(nb) + nb = Backports.coerce_to_int(nb) + raise ArgumentError, "negative size" if nb < 0 + @mt.random_bytes(nb) + end + + def ==(other) + other.is_a?(Random) && + seed == other.seed && + left == other.send(:left) && + state == other.send(:state) + end + + def marshal_dump + @mt.marshal_dump << @seed + end + + def marshal_load(ary) + @seed = ary.pop + @mt = MT19937.allocate + @mt.marshal_load(ary) + end + + private + + def state + @mt.state_as_bignum + end + + def left + @mt.left + end + + def _rand_range(limit) + range = limit.end - limit.begin + if (!range.is_a?(Float)) && range.respond_to?(:to_int) && range = Backports.coerce_to_int(range) + range += 1 unless limit.exclude_end? + limit.begin + @mt.random_integer(range) unless range <= 0 + elsif range = Backports.coerce_to(range, Float, :to_f) + if range < 0 + nil + elsif limit.exclude_end? + limit.begin + @mt.random_float * range unless range <= 0 + else + # cheat a bit... this will reduce the nb of random bits + loop do + r = @mt.random_float * range * 1.0001 + break limit.begin + r unless r > range + end + end + end + end + end + + def self.new_seed + (2 ** 62) + Kernel.rand(2 ** 62) + end + end + + class Random + include Implementation + class << self + include Implementation + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backtrace_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backtrace_formatter.rb new file mode 100644 index 000000000..b1dff2f1c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/backtrace_formatter.rb @@ -0,0 +1,66 @@ +module RSpec + module Core + # @private + class BacktraceFormatter + # @private + attr_accessor :exclusion_patterns, :inclusion_patterns + + def initialize + @full_backtrace = false + + patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec ] + patterns << "org/jruby/" if RUBY_PLATFORM == 'java' + patterns.map! { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) } + + @exclusion_patterns = [Regexp.union(RSpec::CallerFilter::IGNORE_REGEX, *patterns)] + @inclusion_patterns = [] + + return unless matches?(@exclusion_patterns, File.join(Dir.getwd, "lib", "foo.rb:13")) + inclusion_patterns << Regexp.new(Dir.getwd) + end + + attr_writer :full_backtrace + + def full_backtrace? + @full_backtrace || exclusion_patterns.empty? + end + + def filter_gem(gem_name) + sep = File::SEPARATOR + exclusion_patterns << /#{sep}#{gem_name}(-[^#{sep}]+)?#{sep}/ + end + + def format_backtrace(backtrace, options={}) + return backtrace if options[:full_backtrace] + + backtrace.map { |l| backtrace_line(l) }.compact. + tap do |filtered| + if filtered.empty? + filtered.concat backtrace + filtered << "" + filtered << " Showing full backtrace because every line was filtered out." + filtered << " See docs for RSpec::Configuration#backtrace_exclusion_patterns and" + filtered << " RSpec::Configuration#backtrace_inclusion_patterns for more information." + end + end + end + + def backtrace_line(line) + Metadata.relative_path(line) unless exclude?(line) + rescue SecurityError + nil + end + + def exclude?(line) + return false if @full_backtrace + matches?(exclusion_patterns, line) && !matches?(inclusion_patterns, line) + end + + private + + def matches?(patterns, line) + patterns.any? { |p| line =~ p } + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb new file mode 100644 index 000000000..8bf9002c4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb @@ -0,0 +1,1440 @@ +RSpec::Support.require_rspec_core "backtrace_formatter" +RSpec::Support.require_rspec_core "ruby_project" +RSpec::Support.require_rspec_core "formatters/deprecation_formatter" + +module RSpec + module Core + # rubocop:disable Style/ClassLength + + # Stores runtime configuration information. + # + # Configuration options are loaded from `~/.rspec`, `.rspec`, + # `.rspec-local`, command line switches, and the `SPEC_OPTS` environment + # variable (listed in lowest to highest precedence; for example, an option + # in `~/.rspec` can be overridden by an option in `.rspec-local`). + # + # @example Standard settings + # RSpec.configure do |c| + # c.drb = true + # c.drb_port = 1234 + # c.default_path = 'behavior' + # end + # + # @example Hooks + # RSpec.configure do |c| + # c.before(:suite) { establish_connection } + # c.before(:example) { log_in_as :authorized } + # c.around(:example) { |ex| Database.transaction(&ex) } + # end + # + # @see RSpec.configure + # @see Hooks + class Configuration + include RSpec::Core::Hooks + + # @private + class MustBeConfiguredBeforeExampleGroupsError < StandardError; end + + # @private + def self.define_reader(name) + define_method(name) do + variable = instance_variable_defined?("@#{name}") ? instance_variable_get("@#{name}") : nil + value_for(name, variable) + end + end + + # @private + def self.define_aliases(name, alias_name) + alias_method alias_name, name + alias_method "#{alias_name}=", "#{name}=" + define_predicate_for alias_name + end + + # @private + def self.define_predicate_for(*names) + names.each { |name| alias_method "#{name}?", name } + end + + # @private + # + # Invoked by the `add_setting` instance method. Use that method on a + # `Configuration` instance rather than this class method. + def self.add_setting(name, opts={}) + raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default) + attr_writer name + add_read_only_setting name + + Array(opts[:alias_with]).each do |alias_name| + define_aliases(name, alias_name) + end + end + + # @private + # + # As `add_setting` but only add the reader + def self.add_read_only_setting(name, opts={}) + raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default) + define_reader name + define_predicate_for name + end + + # @macro [attach] add_setting + # @!attribute [rw] $1 + # @!method $1=(value) + # + # @macro [attach] define_reader + # @!attribute [r] $1 + + # @macro add_setting + # Path to use if no path is provided to the `rspec` command (default: + # `"spec"`). Allows you to just type `rspec` instead of `rspec spec` to + # run all the examples in the `spec` directory. + # + # Note: Other scripts invoking `rspec` indirectly will ignore this + # setting. + add_setting :default_path + + # @macro add_setting + # Run examples over DRb (default: `false`). RSpec doesn't supply the DRb + # server, but you can use tools like spork. + add_setting :drb + + # @macro add_setting + # The drb_port (default: nil). + add_setting :drb_port + + # @macro add_setting + # Default: `$stderr`. + add_setting :error_stream + + # Indicates if the DSL has been exposed off of modules and `main`. + # Default: true + def expose_dsl_globally? + Core::DSL.exposed_globally? + end + + # Use this to expose the core RSpec DSL via `Module` and the `main` + # object. It will be set automatically but you can override it to + # remove the DSL. + # Default: true + def expose_dsl_globally=(value) + if value + Core::DSL.expose_globally! + Core::SharedExampleGroup::TopLevelDSL.expose_globally! + else + Core::DSL.remove_globally! + Core::SharedExampleGroup::TopLevelDSL.remove_globally! + end + end + + # Determines where deprecation warnings are printed. + # Defaults to `$stderr`. + # @return [IO, String] IO to write to or filename to write to + define_reader :deprecation_stream + + # Determines where deprecation warnings are printed. + # @param value [IO, String] IO to write to or filename to write to + def deprecation_stream=(value) + if @reporter && !value.equal?(@deprecation_stream) + warn "RSpec's reporter has already been initialized with " \ + "#{deprecation_stream.inspect} as the deprecation stream, so your change to "\ + "`deprecation_stream` will be ignored. You should configure it earlier for " \ + "it to take effect, or use the `--deprecation-out` CLI option. " \ + "(Called from #{CallerFilter.first_non_rspec_line})" + else + @deprecation_stream = value + end + end + + # @macro add_setting + # Clean up and exit after the first failure (default: `false`). + add_setting :fail_fast + + # @macro add_setting + # Prints the formatter output of your suite without running any + # examples or hooks. + add_setting :dry_run + + # @macro add_setting + # The exit code to return if there are any failures (default: 1). + add_setting :failure_exit_code + + # @macro define_reader + # Indicates files configured to be required + define_reader :requires + + # @macro define_reader + # Returns dirs that have been prepended to the load path by the `-I` command line option + define_reader :libs + + # @macro add_setting + # Determines where RSpec will send its output. + # Default: `$stdout`. + define_reader :output_stream + + # Set the output stream for reporter + # @attr value [IO] value for output, defaults to $stdout + def output_stream=(value) + if @reporter && !value.equal?(@output_stream) + warn "RSpec's reporter has already been initialized with " \ + "#{output_stream.inspect} as the output stream, so your change to "\ + "`output_stream` will be ignored. You should configure it earlier for " \ + "it to take effect. (Called from #{CallerFilter.first_non_rspec_line})" + else + @output_stream = value + end + end + + # @macro define_reader + # Load files matching this pattern (default: `'**{,/*/**}/*_spec.rb'`) + define_reader :pattern + + # Set pattern to match files to load + # @attr value [String] the filename pattern to filter spec files by + def pattern=(value) + update_pattern_attr :pattern, value + end + + # @macro define_reader + # Exclude files matching this pattern + define_reader :exclude_pattern + + # Set pattern to match files to exclude + # @attr value [String] the filename pattern to exclude spec files by + def exclude_pattern=(value) + update_pattern_attr :exclude_pattern, value + end + + # @macro add_setting + # Report the times for the slowest examples (default: `false`). + # Use this to specify the number of examples to include in the profile. + add_setting :profile_examples + + # @macro add_setting + # Run all examples if none match the configured filters (default: `false`). + add_setting :run_all_when_everything_filtered + + # @macro add_setting + # Color to use to indicate success. + # @param color [Symbol] defaults to `:green` but can be set to one of the + # following: `[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :success_color + + # @macro add_setting + # Color to use to print pending examples. + # @param color [Symbol] defaults to `:yellow` but can be set to one of the + # following: `[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :pending_color + + # @macro add_setting + # Color to use to indicate failure. + # @param color [Symbol] defaults to `:red` but can be set to one of the + # following: `[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :failure_color + + # @macro add_setting + # The default output color. + # @param color [Symbol] defaults to `:white` but can be set to one of the + # following:`[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :default_color + + # @macro add_setting + # Color used when a pending example is fixed. + # @param color [Symbol] defaults to `:blue` but can be set to one of the + # following: `[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :fixed_color + + # @macro add_setting + # Color used to print details. + # @param color [Symbol] defaults to `:cyan` but can be set to one of the + # following: `[:black, :white, :red, :green, :yellow, + # :blue, :magenta, :cyan]` + add_setting :detail_color + + # Deprecated. This config option was added in RSpec 2 to pave the way + # for this being the default behavior in RSpec 3. Now this option is + # a no-op. + def treat_symbols_as_metadata_keys_with_true_values=(_value) + RSpec.deprecate("RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=", + :message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \ + "is deprecated, it is now set to true as default and setting it to false has no effect.") + end + + # Record the start time of the spec suite to measure load time + add_setting :start_time + + # @private + add_setting :tty + # @private + add_setting :include_or_extend_modules + # @private + attr_writer :files_to_run + # @private + add_setting :expecting_with_rspec + # @private + attr_accessor :filter_manager + # @private + attr_reader :backtrace_formatter, :ordering_manager + + def initialize + # rubocop:disable Style/GlobalVars + @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now + # rubocop:enable Style/GlobalVars + @expectation_frameworks = [] + @include_or_extend_modules = [] + @mock_framework = nil + @files_or_directories_to_run = [] + @color = false + @pattern = '**{,/*/**}/*_spec.rb' + @exclude_pattern = '' + @failure_exit_code = 1 + @spec_files_loaded = false + + @backtrace_formatter = BacktraceFormatter.new + + @default_path = 'spec' + @deprecation_stream = $stderr + @output_stream = $stdout + @reporter = nil + @reporter_buffer = nil + @filter_manager = FilterManager.new + @ordering_manager = Ordering::ConfigurationManager.new + @preferred_options = {} + @failure_color = :red + @success_color = :green + @pending_color = :yellow + @default_color = :white + @fixed_color = :blue + @detail_color = :cyan + @profile_examples = false + @requires = [] + @libs = [] + @derived_metadata_blocks = [] + end + + # @private + # + # Used to set higher priority option values from the command line. + def force(hash) + ordering_manager.force(hash) + @preferred_options.merge!(hash) + end + + # @private + def reset + @spec_files_loaded = false + @reporter = nil + @formatter_loader = nil + end + + # @overload add_setting(name) + # @overload add_setting(name, opts) + # @option opts [Symbol] :default + # + # set a default value for the generated getter and predicate methods: + # + # add_setting(:foo, :default => "default value") + # + # @option opts [Symbol] :alias_with + # + # Use `:alias_with` to alias the setter, getter, and predicate to another + # name, or names: + # + # add_setting(:foo, :alias_with => :bar) + # add_setting(:foo, :alias_with => [:bar, :baz]) + # + # Adds a custom setting to the RSpec.configuration object. + # + # RSpec.configuration.add_setting :foo + # + # Used internally and by extension frameworks like rspec-rails, so they + # can add config settings that are domain specific. For example: + # + # RSpec.configure do |c| + # c.add_setting :use_transactional_fixtures, + # :default => true, + # :alias_with => :use_transactional_examples + # end + # + # `add_setting` creates three methods on the configuration object, a + # setter, a getter, and a predicate: + # + # RSpec.configuration.foo=(value) + # RSpec.configuration.foo + # RSpec.configuration.foo? # returns true if foo returns anything but nil or false + def add_setting(name, opts={}) + default = opts.delete(:default) + (class << self; self; end).class_exec do + add_setting(name, opts) + end + __send__("#{name}=", default) if default + end + + # Returns the configured mock framework adapter module + def mock_framework + if @mock_framework.nil? + begin + mock_with :rspec + rescue LoadError + mock_with :nothing + end + end + @mock_framework + end + + # Delegates to mock_framework=(framework) + def mock_framework=(framework) + mock_with framework + end + + # Regexps used to exclude lines from backtraces. + # + # Excludes lines from ruby (and jruby) source, installed gems, anything + # in any "bin" directory, and any of the rspec libs (outside gem + # installs) by default. + # + # You can modify the list via the getter, or replace it with the setter. + # + # To override this behaviour and display a full backtrace, use + # `--backtrace`on the command line, in a `.rspec` file, or in the + # `rspec_options` attribute of RSpec's rake task. + def backtrace_exclusion_patterns + @backtrace_formatter.exclusion_patterns + end + + # Set regular expressions used to exclude lines in backtrace + # @param patterns [Regexp] set the backtrace exlusion pattern + def backtrace_exclusion_patterns=(patterns) + @backtrace_formatter.exclusion_patterns = patterns + end + + # Regexps used to include lines in backtraces. + # + # Defaults to [Regexp.new Dir.getwd]. + # + # Lines that match an exclusion _and_ an inclusion pattern + # will be included. + # + # You can modify the list via the getter, or replace it with the setter. + def backtrace_inclusion_patterns + @backtrace_formatter.inclusion_patterns + end + + # Set regular expressions used to include lines in backtrace + # @attr patterns [Regexp] set backtrace_formatter inclusion_patterns + def backtrace_inclusion_patterns=(patterns) + @backtrace_formatter.inclusion_patterns = patterns + end + + # Adds {#backtrace_exclusion_patterns} that will filter lines from + # the named gems from backtraces. + # + # @param gem_names [Array] Names of the gems to filter + # + # @example + # RSpec.configure do |config| + # config.filter_gems_from_backtrace "rack", "rake" + # end + # + # @note The patterns this adds will match the named gems in their common + # locations (e.g. system gems, vendored with bundler, installed as a + # :git dependency with bundler, etc) but is not guaranteed to work for + # all possible gem locations. For example, if you have the gem source + # in a directory with a completely unrelated name, and use bundler's + # :path option, this will not filter it. + def filter_gems_from_backtrace(*gem_names) + gem_names.each do |name| + @backtrace_formatter.filter_gem(name) + end + end + + # @private + MOCKING_ADAPTERS = { + :rspec => :RSpec, + :flexmock => :Flexmock, + :rr => :RR, + :mocha => :Mocha, + :nothing => :Null + } + + # Sets the mock framework adapter module. + # + # `framework` can be a Symbol or a Module. + # + # Given any of `:rspec`, `:mocha`, `:flexmock`, or `:rr`, configures the + # named framework. + # + # Given `:nothing`, configures no framework. Use this if you don't use + # any mocking framework to save a little bit of overhead. + # + # Given a Module, includes that module in every example group. The module + # should adhere to RSpec's mock framework adapter API: + # + # setup_mocks_for_rspec + # - called before each example + # + # verify_mocks_for_rspec + # - called after each example if the example hasn't yet failed. + # Framework should raise an exception when expectations fail + # + # teardown_mocks_for_rspec + # - called after verify_mocks_for_rspec (even if there are errors) + # + # If the module responds to `configuration` and `mock_with` receives a block, + # it will yield the configuration object to the block e.g. + # + # config.mock_with OtherMockFrameworkAdapter do |mod_config| + # mod_config.custom_setting = true + # end + def mock_with(framework) + framework_module = + if framework.is_a?(Module) + framework + else + const_name = MOCKING_ADAPTERS.fetch(framework) do + raise ArgumentError, + "Unknown mocking framework: #{framework.inspect}. " \ + "Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}" + end + + RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}" + RSpec::Core::MockingAdapters.const_get(const_name) + end + + new_name, old_name = [framework_module, @mock_framework].map do |mod| + mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed + end + + unless new_name == old_name + assert_no_example_groups_defined(:mock_framework) + end + + if block_given? + raise "#{framework_module} must respond to `configuration` so that mock_with can yield it." unless framework_module.respond_to?(:configuration) + yield framework_module.configuration + end + + @mock_framework = framework_module + end + + # Returns the configured expectation framework adapter module(s) + def expectation_frameworks + if @expectation_frameworks.empty? + begin + expect_with :rspec + rescue LoadError + expect_with Module.new + end + end + @expectation_frameworks + end + + # Delegates to expect_with(framework) + def expectation_framework=(framework) + expect_with(framework) + end + + # Sets the expectation framework module(s) to be included in each example + # group. + # + # `frameworks` can be `:rspec`, `:test_unit`, `:minitest`, a custom + # module, or any combination thereof: + # + # config.expect_with :rspec + # config.expect_with :test_unit + # config.expect_with :minitest + # config.expect_with :rspec, :minitest + # config.expect_with OtherExpectationFramework + # + # RSpec will translate `:rspec`, `:minitest`, and `:test_unit` into the + # appropriate modules. + # + # ## Configuration + # + # If the module responds to `configuration`, `expect_with` will + # yield the `configuration` object if given a block: + # + # config.expect_with OtherExpectationFramework do |custom_config| + # custom_config.custom_setting = true + # end + def expect_with(*frameworks) + modules = frameworks.map do |framework| + case framework + when Module + framework + when :rspec + require 'rspec/expectations' + self.expecting_with_rspec = true + ::RSpec::Matchers + when :test_unit + require 'rspec/core/test_unit_assertions_adapter' + ::RSpec::Core::TestUnitAssertionsAdapter + when :minitest + require 'rspec/core/minitest_assertions_adapter' + ::RSpec::Core::MinitestAssertionsAdapter + else + raise ArgumentError, "#{framework.inspect} is not supported" + end + end + + if (modules - @expectation_frameworks).any? + assert_no_example_groups_defined(:expect_with) + end + + if block_given? + raise "expect_with only accepts a block with a single argument. Call expect_with #{modules.length} times, once with each argument, instead." if modules.length > 1 + raise "#{modules.first} must respond to `configuration` so that expect_with can yield it." unless modules.first.respond_to?(:configuration) + yield modules.first.configuration + end + + @expectation_frameworks.push(*modules) + end + + # Check if full backtrace is enabled + # @return [Boolean] is full backtrace enabled + def full_backtrace? + @backtrace_formatter.full_backtrace? + end + + # Toggle full backtrace + # @attr true_or_false [Boolean] toggle full backtrace display + def full_backtrace=(true_or_false) + @backtrace_formatter.full_backtrace = true_or_false + end + + # Returns the configuration option for color, but should not + # be used to check if color is supported. + # + # @see color_enabled? + # @return [Boolean] + def color + value_for(:color, @color) + end + + # Check if color is enabled for a particular output + # @param output [IO] an output stream to use, defaults to the current + # `output_stream` + # @return [Boolean] + def color_enabled?(output=output_stream) + output_to_tty?(output) && color + end + + # Toggle output color + # @attr true_or_false [Boolean] toggle color enabled + def color=(true_or_false) + return unless true_or_false + + if RSpec.world.windows_os? && !ENV['ANSICON'] + RSpec.warning "You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows" + @color = false + else + @color = true + end + end + + # @private + def libs=(libs) + libs.map do |lib| + @libs.unshift lib + $LOAD_PATH.unshift lib + end + end + + # Run examples matching on `description` in all files to run. + # @param description [String, Regexp] the pattern to filter on + def full_description=(description) + filter_run :full_description => Regexp.union(*Array(description).map { |d| Regexp.new(d) }) + end + + # @return [Array] full description filter + def full_description + filter.fetch :full_description, nil + end + + # @overload add_formatter(formatter) + # + # Adds a formatter to the formatters collection. `formatter` can be a + # string representing any of the built-in formatters (see + # `built_in_formatter`), or a custom formatter class. + # + # ### Note + # + # For internal purposes, `add_formatter` also accepts the name of a class + # and paths to use for output streams, but you should consider that a + # private api that may change at any time without notice. + def add_formatter(formatter_to_use, *paths) + paths << output_stream if paths.empty? + formatter_loader.add formatter_to_use, *paths + end + alias_method :formatter=, :add_formatter + + # The formatter that will be used if no formatter has been set. + # Defaults to 'progress'. + def default_formatter + formatter_loader.default_formatter + end + + # Sets a fallback formatter to use if none other has been set. + # + # @example + # + # RSpec.configure do |rspec| + # rspec.default_formatter = 'doc' + # end + def default_formatter=(value) + formatter_loader.default_formatter = value + end + + # Returns a duplicate of the formatters currently loaded in + # the `FormatterLoader` for introspection. + # + # Note as this is a duplicate, any mutations will be disregarded. + # + # @return [Array] the formatters currently loaded + def formatters + formatter_loader.formatters.dup + end + + # @private + def formatter_loader + @formatter_loader ||= Formatters::Loader.new(Reporter.new(self)) + end + + # @private + # + # This buffer is used to capture all messages sent to the reporter during + # reporter initialization. It can then replay those messages after the + # formatter is correctly initialized. Otherwise, deprecation warnings + # during formatter initialization can cause an infinite loop. + class DeprecationReporterBuffer + def initialize + @calls = [] + end + + def deprecation(*args) + @calls << args + end + + def play_onto(reporter) + @calls.each do |args| + reporter.deprecation(*args) + end + end + end + + # @private + def reporter + # @reporter_buffer should only ever be set in this method to cover + # initialization of @reporter. + @reporter_buffer || @reporter ||= + begin + @reporter_buffer = DeprecationReporterBuffer.new + formatter_loader.setup_default output_stream, deprecation_stream + @reporter_buffer.play_onto(formatter_loader.reporter) + @reporter_buffer = nil + formatter_loader.reporter + end + end + + # @api private + # + # Defaults `profile_examples` to 10 examples when `@profile_examples` is `true`. + # + def profile_examples + profile = value_for(:profile_examples, @profile_examples) + if profile && !profile.is_a?(Integer) + 10 + else + profile + end + end + + # @private + def files_or_directories_to_run=(*files) + files = files.flatten + files << default_path if (command == 'rspec' || Runner.running_in_drb?) && default_path && files.empty? + @files_or_directories_to_run = files + @files_to_run = nil + end + + # The spec files RSpec will run + # @return [Array] specified files about to run + def files_to_run + @files_to_run ||= get_files_to_run(@files_or_directories_to_run) + end + + # Creates a method that delegates to `example` including the submitted + # `args`. Used internally to add variants of `example` like `pending`: + # @param name [String] example name alias + # @param args [Array, Hash] metadata for the generated example + # + # @note The specific example alias below (`pending`) is already + # defined for you. + # @note Use with caution. This extends the language used in your + # specs, but does not add any additional documentation. We use this + # in rspec to define methods like `focus` and `xit`, but we also add + # docs for those methods. + # + # @example + # RSpec.configure do |config| + # config.alias_example_to :pending, :pending => true + # end + # + # # This lets you do this: + # + # describe Thing do + # pending "does something" do + # thing = Thing.new + # end + # end + # + # # ... which is the equivalent of + # + # describe Thing do + # it "does something", :pending => true do + # thing = Thing.new + # end + # end + def alias_example_to(name, *args) + extra_options = Metadata.build_hash_from(args) + RSpec::Core::ExampleGroup.define_example_method(name, extra_options) + end + + # Creates a method that defines an example group with the provided + # metadata. Can be used to define example group/metadata shortcuts. + # + # @example + # RSpec.configure do |config| + # config.alias_example_group_to :describe_model, :type => :model + # end + # + # shared_context_for "model tests", :type => :model do + # # define common model test helper methods, `let` declarations, etc + # end + # + # # This lets you do this: + # + # RSpec.describe_model User do + # end + # + # # ... which is the equivalent of + # + # RSpec.describe User, :type => :model do + # end + # + # @note The defined aliased will also be added to the top level + # (e.g. `main` and from within modules) if + # `expose_dsl_globally` is set to true. + # @see #alias_example_to + # @see #expose_dsl_globally= + def alias_example_group_to(new_name, *args) + extra_options = Metadata.build_hash_from(args) + RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options) + end + + # Define an alias for it_should_behave_like that allows different + # language (like "it_has_behavior" or "it_behaves_like") to be + # employed when including shared examples. + # + # @example + # RSpec.configure do |config| + # config.alias_it_behaves_like_to(:it_has_behavior, 'has behavior:') + # end + # + # # allows the user to include a shared example group like: + # + # describe Entity do + # it_has_behavior 'sortability' do + # let(:sortable) { Entity.new } + # end + # end + # + # # which is reported in the output as: + # # Entity + # # has behavior: sortability + # # ...sortability examples here + # + # @note Use with caution. This extends the language used in your + # specs, but does not add any additional documentation. We use this + # in rspec to define `it_should_behave_like` (for backward + # compatibility), but we also add docs for that method. + def alias_it_behaves_like_to(new_name, report_label='') + RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label) + end + alias_method :alias_it_should_behave_like_to, :alias_it_behaves_like_to + + # Adds key/value pairs to the `inclusion_filter`. If `args` + # includes any symbols that are not part of the hash, each symbol + # is treated as a key in the hash with the value `true`. + # + # ### Note + # + # Filters set using this method can be overridden from the command line + # or config files (e.g. `.rspec`). + # + # @example + # # given this declaration + # describe "something", :foo => 'bar' do + # # ... + # end + # + # # any of the following will include that group + # config.filter_run_including :foo => 'bar' + # config.filter_run_including :foo => /^ba/ + # config.filter_run_including :foo => lambda {|v| v == 'bar'} + # config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'} + # + # # given a proc with an arity of 1, the lambda is passed the value related to the key, e.g. + # config.filter_run_including :foo => lambda {|v| v == 'bar'} + # + # # given a proc with an arity of 2, the lambda is passed the value related to the key, + # # and the metadata itself e.g. + # config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'} + # + # filter_run_including :foo # same as filter_run_including :foo => true + def filter_run_including(*args) + meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering) + filter_manager.include_with_low_priority meta + end + + alias_method :filter_run, :filter_run_including + + # Clears and reassigns the `inclusion_filter`. Set to `nil` if you don't + # want any inclusion filter at all. + # + # ### Warning + # + # This overrides any inclusion filters/tags set on the command line or in + # configuration files. + def inclusion_filter=(filter) + meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering) + filter_manager.include_only meta + end + + alias_method :filter=, :inclusion_filter= + + # Returns the `inclusion_filter`. If none has been set, returns an empty + # hash. + def inclusion_filter + filter_manager.inclusions + end + + alias_method :filter, :inclusion_filter + + # Adds key/value pairs to the `exclusion_filter`. If `args` + # includes any symbols that are not part of the hash, each symbol + # is treated as a key in the hash with the value `true`. + # + # ### Note + # + # Filters set using this method can be overridden from the command line + # or config files (e.g. `.rspec`). + # + # @example + # # given this declaration + # describe "something", :foo => 'bar' do + # # ... + # end + # + # # any of the following will exclude that group + # config.filter_run_excluding :foo => 'bar' + # config.filter_run_excluding :foo => /^ba/ + # config.filter_run_excluding :foo => lambda {|v| v == 'bar'} + # config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'} + # + # # given a proc with an arity of 1, the lambda is passed the value related to the key, e.g. + # config.filter_run_excluding :foo => lambda {|v| v == 'bar'} + # + # # given a proc with an arity of 2, the lambda is passed the value related to the key, + # # and the metadata itself e.g. + # config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'} + # + # filter_run_excluding :foo # same as filter_run_excluding :foo => true + def filter_run_excluding(*args) + meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering) + filter_manager.exclude_with_low_priority meta + end + + # Clears and reassigns the `exclusion_filter`. Set to `nil` if you don't + # want any exclusion filter at all. + # + # ### Warning + # + # This overrides any exclusion filters/tags set on the command line or in + # configuration files. + def exclusion_filter=(filter) + meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering) + filter_manager.exclude_only meta + end + + # Returns the `exclusion_filter`. If none has been set, returns an empty + # hash. + def exclusion_filter + filter_manager.exclusions + end + + # Tells RSpec to include `mod` in example groups. Methods defined in + # `mod` are exposed to examples (not example groups). Use `filters` to + # constrain the groups in which to include the module. + # + # @example + # + # module AuthenticationHelpers + # def login_as(user) + # # ... + # end + # end + # + # module UserHelpers + # def users(username) + # # ... + # end + # end + # + # RSpec.configure do |config| + # config.include(UserHelpers) # included in all modules + # config.include(AuthenticationHelpers, :type => :request) + # end + # + # describe "edit profile", :type => :request do + # it "can be viewed by owning user" do + # login_as users(:jdoe) + # get "/profiles/jdoe" + # assert_select ".username", :text => 'jdoe' + # end + # end + # + # @see #extend + def include(mod, *filters) + meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering) + include_or_extend_modules << [:include, mod, meta] + end + + # Tells RSpec to extend example groups with `mod`. Methods defined in + # `mod` are exposed to example groups (not examples). Use `filters` to + # constrain the groups to extend. + # + # Similar to `include`, but behavior is added to example groups, which + # are classes, rather than the examples, which are instances of those + # classes. + # + # @example + # + # module UiHelpers + # def run_in_browser + # # ... + # end + # end + # + # RSpec.configure do |config| + # config.extend(UiHelpers, :type => :request) + # end + # + # describe "edit profile", :type => :request do + # run_in_browser + # + # it "does stuff in the client" do + # # ... + # end + # end + # + # @see #include + def extend(mod, *filters) + meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering) + include_or_extend_modules << [:extend, mod, meta] + end + + # @private + # + # Used internally to extend a group with modules using `include` and/or + # `extend`. + def configure_group(group) + include_or_extend_modules.each do |include_or_extend, mod, filters| + next unless filters.empty? || group.any_apply?(filters) + __send__("safe_#{include_or_extend}", mod, group) + end + end + + # @private + def safe_include(mod, host) + host.__send__(:include, mod) unless host < mod + end + + # @private + def requires=(paths) + directories = ['lib', default_path].select { |p| File.directory? p } + RSpec::Core::RubyProject.add_to_load_path(*directories) + paths.each { |path| require path } + @requires += paths + end + + # @private + if RUBY_VERSION.to_f >= 1.9 + # @private + def safe_extend(mod, host) + host.extend(mod) unless host.singleton_class < mod + end + else + # @private + def safe_extend(mod, host) + host.extend(mod) unless (class << host; self; end).included_modules.include?(mod) + end + end + + # @private + def configure_mock_framework + RSpec::Core::ExampleGroup.__send__(:include, mock_framework) + conditionally_disable_mocks_monkey_patching + end + + # @private + def configure_expectation_framework + expectation_frameworks.each do |framework| + RSpec::Core::ExampleGroup.__send__(:include, framework) + end + conditionally_disable_expectations_monkey_patching + end + + # @private + def load_spec_files + files_to_run.uniq.each { |f| load File.expand_path(f) } + @spec_files_loaded = true + end + + # @private + DEFAULT_FORMATTER = lambda { |string| string } + + # Formats the docstring output using the block provided. + # + # @example + # # This will strip the descriptions of both examples and example groups. + # RSpec.configure do |config| + # config.format_docstrings { |s| s.strip } + # end + def format_docstrings(&block) + @format_docstrings_block = block_given? ? block : DEFAULT_FORMATTER + end + + # @private + def format_docstrings_block + @format_docstrings_block ||= DEFAULT_FORMATTER + end + + # @private + # @macro [attach] delegate_to_ordering_manager + # @!method $1 + def self.delegate_to_ordering_manager(*methods) + methods.each do |method| + define_method method do |*args, &block| + ordering_manager.__send__(method, *args, &block) + end + end + end + + # @macro delegate_to_ordering_manager + # + # Sets the seed value and sets the default global ordering to random. + delegate_to_ordering_manager :seed= + + # @macro delegate_to_ordering_manager + # Seed for random ordering (default: generated randomly each run). + # + # When you run specs with `--order random`, RSpec generates a random seed + # for the randomization and prints it to the `output_stream` (assuming + # you're using RSpec's built-in formatters). If you discover an ordering + # dependency (i.e. examples fail intermittently depending on order), set + # this (on Configuration or on the command line with `--seed`) to run + # using the same seed while you debug the issue. + # + # We recommend, actually, that you use the command line approach so you + # don't accidentally leave the seed encoded. + delegate_to_ordering_manager :seed + + # @macro delegate_to_ordering_manager + # + # Sets the default global order and, if order is `'rand:'`, also sets the seed. + delegate_to_ordering_manager :order= + + # @macro delegate_to_ordering_manager + # Registers a named ordering strategy that can later be + # used to order an example group's subgroups by adding + # `:order => ` metadata to the example group. + # + # @param name [Symbol] The name of the ordering. + # @yield Block that will order the given examples or example groups + # @yieldparam list [Array, Array] The examples or groups to order + # @yieldreturn [Array, Array] The re-ordered examples or groups + # + # @example + # RSpec.configure do |rspec| + # rspec.register_ordering :reverse do |list| + # list.reverse + # end + # end + # + # describe MyClass, :order => :reverse do + # # ... + # end + # + # @note Pass the symbol `:global` to set the ordering strategy that + # will be used to order the top-level example groups and any example + # groups that do not have declared `:order` metadata. + delegate_to_ordering_manager :register_ordering + + # @private + delegate_to_ordering_manager :seed_used?, :ordering_registry + + # Set Ruby warnings on or off + def warnings=(value) + $VERBOSE = !!value + end + + # @return [Boolean] Whether or not ruby warnings are enabled. + def warnings? + $VERBOSE + end + + # Exposes the current running example via the named + # helper method. RSpec 2.x exposed this via `example`, + # but in RSpec 3.0, the example is instead exposed via + # an arg yielded to `it`, `before`, `let`, etc. However, + # some extension gems (such as Capybara) depend on the + # RSpec 2.x's `example` method, so this config option + # can be used to maintain compatibility. + # + # @param method_name [Symbol] the name of the helper method + # + # @example + # + # RSpec.configure do |rspec| + # rspec.expose_current_running_example_as :example + # end + # + # describe MyClass do + # before do + # # `example` can be used here because of the above config. + # do_something if example.metadata[:type] == "foo" + # end + # end + def expose_current_running_example_as(method_name) + ExposeCurrentExample.module_exec do + extend RSpec::SharedContext + let(method_name) { |ex| ex } + end + + include ExposeCurrentExample + end + + # @private + module ExposeCurrentExample; end + + # Turns deprecation warnings into errors, in order to surface + # the full backtrace of the call site. This can be useful when + # you need more context to address a deprecation than the + # single-line call site normally provided. + # + # @example + # + # RSpec.configure do |rspec| + # rspec.raise_errors_for_deprecations! + # end + def raise_errors_for_deprecations! + self.deprecation_stream = Formatters::DeprecationFormatter::RaiseErrorStream.new + end + + # Enables zero monkey patching mode for RSpec. It removes monkey + # patching of the top-level DSL methods (`describe`, + # `shared_examples_for`, etc) onto `main` and `Module`, instead + # requiring you to prefix these methods with `RSpec.`. It enables + # expect-only syntax for rspec-mocks and rspec-expectations. It + # simply disables monkey patching on whatever pieces of rspec + # the user is using. + # + # @note It configures rspec-mocks and rspec-expectations only + # if the user is using those (either explicitly or implicitly + # by not setting `mock_with` or `expect_with` to anything else). + # + # @note If the user uses this options with `mock_with :mocha` + # (or similiar) they will still have monkey patching active + # in their test environment from mocha. + # + # @example + # + # # It disables all monkey patching + # RSpec.configure do |config| + # config.disable_monkey_patching! + # end + # + # # Is an equivalent to + # RSpec.configure do |config| + # config.expose_dsl_globally = false + # + # config.mock_with :rspec do |mocks| + # mocks.syntax = :expect + # mocks.patch_marshal_to_support_partial_doubles = false + # end + # + # config.mock_with :rspec do |expectations| + # expectations.syntax = :expect + # end + # end + def disable_monkey_patching! + self.expose_dsl_globally = false + self.disable_monkey_patching = true + conditionally_disable_mocks_monkey_patching + conditionally_disable_expectations_monkey_patching + end + + # @private + attr_accessor :disable_monkey_patching + + # Defines a callback that can assign derived metadata values. + # + # @param filters [Array, Hash] metadata filters that determine which example + # or group metadata hashes the callback will be triggered for. If none are given, + # the callback will be run against the metadata hashes of all groups and examples. + # @yieldparam metadata [Hash] original metadata hash from an example or group. Mutate this in + # your block as needed. + # + # @example + # RSpec.configure do |config| + # # Tag all groups and examples in the spec/unit directory with :type => :unit + # config.define_derived_metadata(:file_path => %r{/spec/unit/}) do |metadata| + # metadata[:type] = :unit + # end + # end + def define_derived_metadata(*filters, &block) + meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering) + @derived_metadata_blocks << [meta, block] + end + + # @private + def apply_derived_metadata_to(metadata) + @derived_metadata_blocks.each do |filter, block| + block.call(metadata) if filter.empty? || MetadataFilter.any_apply?(filter, metadata) + end + end + + private + + def get_files_to_run(paths) + FlatMap.flat_map(paths_to_check(paths)) do |path| + path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR + File.directory?(path) ? gather_directories(path) : extract_location(path) + end.sort.uniq + end + + def paths_to_check(paths) + return paths if pattern_might_load_specs_from_vendored_dirs? + paths + ['.'] + end + + def pattern_might_load_specs_from_vendored_dirs? + pattern.split(File::SEPARATOR).first.include?('**') + end + + def gather_directories(path) + include_files = get_matching_files(path, pattern) + exclude_files = get_matching_files(path, exclude_pattern) + (include_files - exclude_files).sort.uniq + end + + def get_matching_files(path, pattern) + Dir[file_glob_from(path, pattern)].map { |file| File.expand_path(file) } + end + + def file_glob_from(path, pattern) + stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}" + return stripped if pattern =~ /^(\.\/)?#{Regexp.escape path}/ || absolute_pattern?(pattern) + File.join(path, stripped) + end + + if RSpec::Support::OS.windows? + def absolute_pattern?(pattern) + pattern =~ /\A[A-Z]:\\/ || windows_absolute_network_path?(pattern) + end + + def windows_absolute_network_path?(pattern) + return false unless ::File::ALT_SEPARATOR + pattern.start_with?(::File::ALT_SEPARATOR + ::File::ALT_SEPARATOR) + end + else + def absolute_pattern?(pattern) + pattern.start_with?(File::Separator) + end + end + + def extract_location(path) + match = /^(.*?)((?:\:\d+)+)$/.match(path) + + if match + captures = match.captures + path, lines = captures[0], captures[1][1..-1].split(":").map { |n| n.to_i } + filter_manager.add_location path, lines + end + + return [] if path == default_path + path + end + + def command + $0.split(File::SEPARATOR).last + end + + def value_for(key, default=nil) + @preferred_options.key?(key) ? @preferred_options[key] : default + end + + def assert_no_example_groups_defined(config_option) + return unless RSpec.world.example_groups.any? + + raise MustBeConfiguredBeforeExampleGroupsError.new( + "RSpec's #{config_option} configuration option must be configured before " \ + "any example groups are defined, but you have already defined a group." + ) + end + + def output_to_tty?(output=output_stream) + tty? || (output.respond_to?(:tty?) && output.tty?) + end + + def conditionally_disable_mocks_monkey_patching + return unless disable_monkey_patching && rspec_mocks_loaded? + + RSpec::Mocks.configuration.tap do |config| + config.syntax = :expect + config.patch_marshal_to_support_partial_doubles = false + end + end + + def conditionally_disable_expectations_monkey_patching + return unless disable_monkey_patching && rspec_expectations_loaded? + + RSpec::Expectations.configuration.syntax = :expect + end + + def rspec_mocks_loaded? + defined?(RSpec::Mocks.configuration) + end + + def rspec_expectations_loaded? + defined?(RSpec::Expectations.configuration) + end + + def update_pattern_attr(name, value) + if @spec_files_loaded + RSpec.warning "Configuring `#{name}` to #{value} has no effect since RSpec has already loaded the spec files." + end + + instance_variable_set(:"@#{name}", value) + @files_to_run = nil + end + end + # rubocop:enable Style/ClassLength + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb new file mode 100644 index 000000000..d6c1c0ecd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb @@ -0,0 +1,173 @@ +require 'erb' +require 'shellwords' +require 'set' + +module RSpec + module Core + # Responsible for utilizing externally provided configuration options, + # whether via the command line, `.rspec`, `~/.rspec`, `.rspec-local` + # or a custom options file. + class ConfigurationOptions + # @param args [Array] command line arguments + def initialize(args) + @args = args.dup + organize_options + end + + # Updates the provided {Configuration} instance based on the provided + # external configuration options. + # + # @param config [Configuration] the configuration instance to update + def configure(config) + process_options_into config + configure_filter_manager config.filter_manager + load_formatters_into config + end + + # @api private + # Updates the provided {FilterManager} based on the filter options. + # @param filter_manager [FilterManager] instance to update + def configure_filter_manager(filter_manager) + @filter_manager_options.each do |command, value| + filter_manager.__send__ command, value + end + end + + # @return [Hash] the final merged options, drawn from all external sources + attr_reader :options + + private + + def organize_options + @filter_manager_options = [] + + @options = (file_options << command_line_options << env_options).each do |opts| + @filter_manager_options << [:include, opts.delete(:inclusion_filter)] if opts.key?(:inclusion_filter) + @filter_manager_options << [:exclude, opts.delete(:exclusion_filter)] if opts.key?(:exclusion_filter) + end + + @options = @options.inject(:libs => [], :requires => []) do |hash, opts| + hash.merge(opts) do |key, oldval, newval| + [:libs, :requires].include?(key) ? oldval + newval : newval + end + end + end + + UNFORCED_OPTIONS = [ + :requires, :profile, :drb, :libs, :files_or_directories_to_run, + :full_description, :full_backtrace, :tty + ].to_set + + UNPROCESSABLE_OPTIONS = [:formatters].to_set + + def force?(key) + !UNFORCED_OPTIONS.include?(key) + end + + def order(keys) + OPTIONS_ORDER.reverse.each do |key| + keys.unshift(key) if keys.delete(key) + end + keys + end + + OPTIONS_ORDER = [ + # It's important to set this before anything that might issue a + # deprecation (or otherwise access the reporter). + :deprecation_stream, + + # load paths depend on nothing, but must be set before `requires` + # to support load-path-relative requires. + :libs, + + # `files_or_directories_to_run` uses `default_path` so it must be + # set before it. + :default_path, + + # These must be set before `requires` to support checking `config.files_to_run` + # from within `spec_helper.rb` when a `-rspec_helper` option is used. + :files_or_directories_to_run, :pattern, :exclude_pattern, + + # In general, we want to require the specified files as early as possible. + # The `--require` option is specifically intended to allow early requires. + # For later requires, they can just put the require in their spec files, but + # `--require` provides a unique opportunity for users to instruct RSpec to + # load an extension file early for maximum flexibility. + :requires + ] + + def process_options_into(config) + opts = options.reject { |k, _| UNPROCESSABLE_OPTIONS.include? k } + + order(opts.keys).each do |key| + force?(key) ? config.force(key => opts[key]) : config.__send__("#{key}=", opts[key]) + end + end + + def load_formatters_into(config) + options[:formatters].each { |pair| config.add_formatter(*pair) } if options[:formatters] + end + + def file_options + custom_options_file ? [custom_options] : [global_options, project_options, local_options] + end + + def env_options + ENV["SPEC_OPTS"] ? Parser.parse(Shellwords.split(ENV["SPEC_OPTS"])) : {} + end + + def command_line_options + @command_line_options ||= Parser.parse(@args).merge :files_or_directories_to_run => @args + end + + def custom_options + options_from(custom_options_file) + end + + def local_options + @local_options ||= options_from(local_options_file) + end + + def project_options + @project_options ||= options_from(project_options_file) + end + + def global_options + @global_options ||= options_from(global_options_file) + end + + def options_from(path) + Parser.parse(args_from_options_file(path)) + end + + def args_from_options_file(path) + return [] unless path && File.exist?(path) + config_string = options_file_as_erb_string(path) + FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit) + end + + def options_file_as_erb_string(path) + ERB.new(File.read(path), nil, '-').result(binding) + end + + def custom_options_file + command_line_options[:custom_options_file] + end + + def project_options_file + ".rspec" + end + + def local_options_file + ".rspec-local" + end + + def global_options_file + File.join(File.expand_path("~"), ".rspec") + rescue ArgumentError + RSpec.warning "Unable to find ~/.rspec because the HOME environment variable is not set" + nil + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/drb.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/drb.rb new file mode 100644 index 000000000..55e639203 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/drb.rb @@ -0,0 +1,111 @@ +require 'drb/drb' + +module RSpec + module Core + # @private + class DRbRunner + def initialize(options, configuration=RSpec.configuration) + @options = options + @configuration = configuration + end + + def drb_port + @options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989 + end + + def run(err, out) + begin + DRb.start_service("druby://localhost:0") + rescue SocketError, Errno::EADDRNOTAVAIL + DRb.start_service("druby://:0") + end + spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}") + spec_server.run(drb_argv, err, out) + end + + def drb_argv + @drb_argv ||= begin + @options.configure_filter_manager(@configuration.filter_manager) + DRbOptions.new(@options.options, @configuration.filter_manager).options + end + end + end + + # @private + class DRbOptions + def initialize(submitted_options, filter_manager) + @submitted_options = submitted_options + @filter_manager = filter_manager + end + + def options + argv = [] + argv << "--color" if @submitted_options[:color] + argv << "--profile" if @submitted_options[:profile_examples] + argv << "--backtrace" if @submitted_options[:full_backtrace] + argv << "--tty" if @submitted_options[:tty] + argv << "--fail-fast" if @submitted_options[:fail_fast] + argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file] + argv << "--order" << @submitted_options[:order] if @submitted_options[:order] + + add_failure_exit_code(argv) + add_full_description(argv) + add_filter(argv, :inclusion, @filter_manager.inclusions) + add_filter(argv, :exclusion, @filter_manager.exclusions) + add_formatters(argv) + add_libs(argv) + add_requires(argv) + + argv + @submitted_options[:files_or_directories_to_run] + end + + def add_failure_exit_code(argv) + return unless @submitted_options[:failure_exit_code] + + argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s + end + + def add_full_description(argv) + return unless @submitted_options[:full_description] + + # The argument to --example is regexp-escaped before being stuffed + # into a regexp when received for the first time (see OptionParser). + # Hence, merely grabbing the source of this regexp will retain the + # backslashes, so we must remove them. + @submitted_options[:full_description].each do |description| + argv << "--example" << description.source.delete('\\') + end + end + + CONDITIONAL_FILTERS = [:if, :unless] + + def add_filter(argv, name, hash) + hash.each_pair do |k, v| + next if CONDITIONAL_FILTERS.include?(k) + tag = name == :inclusion ? k.to_s : "~#{k}" + tag << ":#{v}" if v.is_a?(String) + argv << "--tag" << tag + end unless hash.empty? + end + + def add_formatters(argv) + @submitted_options[:formatters].each do |pair| + argv << "--format" << pair[0] + argv << "--out" << pair[1] if pair[1] + end if @submitted_options[:formatters] + end + + def add_libs(argv) + @submitted_options[:libs].each do |path| + argv << "-I" << path + end if @submitted_options[:libs] + end + + def add_requires(argv) + @submitted_options[:requires].each do |path| + argv << "--require" << path + end if @submitted_options[:requires] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/dsl.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/dsl.rb new file mode 100644 index 000000000..bd78cc610 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/dsl.rb @@ -0,0 +1,93 @@ +module RSpec + module Core + # DSL defines methods to group examples, most notably `describe`, + # and exposes them as class methods of {RSpec}. They can also be + # exposed globally (on `main` and instances of `Module`) through + # the {Configuration} option `expose_dsl_globally`. + # + # By default the methods `describe`, `context` and `example_group` + # are exposed. These methods define a named context for one or + # more examples. The given block is evaluated in the context of + # a generated subclass of {RSpec::Core::ExampleGroup} + # + # ## Examples: + # + # RSpec.describe "something" do + # context "when something is a certain way" do + # it "does something" do + # # example code goes here + # end + # end + # end + # + # @see ExampleGroup + # @see ExampleGroup.example_group + module DSL + # @private + def self.example_group_aliases + @example_group_aliases ||= [] + end + + # @private + def self.exposed_globally? + @exposed_globally ||= false + end + + # @private + def self.expose_example_group_alias(name) + example_group_aliases << name + + (class << RSpec; self; end).__send__(:define_method, name) do |*args, &example_group_block| + RSpec.world.register RSpec::Core::ExampleGroup.__send__(name, *args, &example_group_block) + end + + expose_example_group_alias_globally(name) if exposed_globally? + end + + class << self + # @private + attr_accessor :top_level + end + + # Adds the describe method to Module and the top level binding + # @api private + def self.expose_globally! + return if exposed_globally? + + example_group_aliases.each do |method_name| + expose_example_group_alias_globally(method_name) + end + + @exposed_globally = true + end + + # Removes the describe method from Module and the top level binding + # @api private + def self.remove_globally! + return unless exposed_globally? + + example_group_aliases.each do |method_name| + change_global_dsl { undef_method method_name } + end + + @exposed_globally = false + end + + # @private + def self.expose_example_group_alias_globally(method_name) + change_global_dsl do + define_method(method_name) { |*a, &b| ::RSpec.__send__(method_name, *a, &b) } + end + end + + # @private + def self.change_global_dsl(&changes) + (class << top_level; self; end).class_exec(&changes) + Module.class_exec(&changes) + end + end + end +end + +# capture main without an eval +::RSpec::Core::DSL.top_level = self diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example.rb new file mode 100644 index 000000000..07cd962c2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example.rb @@ -0,0 +1,502 @@ +module RSpec + module Core + # Wrapper for an instance of a subclass of {ExampleGroup}. An instance of + # `RSpec::Core::Example` is returned by example definition methods + # such as {ExampleGroup.it it} and is yielded to the {ExampleGroup.it it}, + # {Hooks#before before}, {Hooks#after after}, {Hooks#around around}, + # {MemoizedHelpers::ClassMethods#let let} and + # {MemoizedHelpers::ClassMethods#subject subject} blocks. + # + # This allows us to provide rich metadata about each individual + # example without adding tons of methods directly to the ExampleGroup + # that users may inadvertantly redefine. + # + # Useful for configuring logging and/or taking some action based + # on the state of an example's metadata. + # + # @example + # + # RSpec.configure do |config| + # config.before do |example| + # log example.description + # end + # + # config.after do |example| + # log example.description + # end + # + # config.around do |example| + # log example.description + # example.run + # end + # end + # + # shared_examples "auditable" do + # it "does something" do + # log "#{example.full_description}: #{auditable.inspect}" + # auditable.should do_something + # end + # end + # + # @see ExampleGroup + # @note Example blocks are evaluated in the context of an instance + # of an `ExampleGroup`, not in the context of an instance of `Example`. + class Example + # @private + # + # Used to define methods that delegate to this example's metadata + def self.delegate_to_metadata(key) + define_method(key) { @metadata[key] } + end + + # @return [ExecutionResult] represents the result of running this example. + delegate_to_metadata :execution_result + # @return [String] the relative path to the file where this example was defined. + delegate_to_metadata :file_path + # @return [String] the full description (including the docstrings of + # all parent example groups). + delegate_to_metadata :full_description + # @return [String] the exact source location of this example in a form + # like `./path/to/spec.rb:17` + delegate_to_metadata :location + # @return [Boolean] flag that indicates that the example is not expected to pass. + # It will be run and will either have a pending result (if a failure occurs) + # or a failed result (if no failure occurs). + delegate_to_metadata :pending + # @return [Boolean] flag that will cause the example to not run. + # The {ExecutionResult} status will be `:pending`. + delegate_to_metadata :skip + + # Returns the string submitted to `example` or its aliases (e.g. + # `specify`, `it`, etc). If no string is submitted (e.g. `it { is_expected.to + # do_something }`) it returns the message generated by the matcher if + # there is one, otherwise returns a message including the location of the + # example. + def description + description = if metadata[:description].to_s.empty? + "example at #{location}" + else + metadata[:description] + end + + RSpec.configuration.format_docstrings_block.call(description) + end + + # @attr_reader + # + # Returns the first exception raised in the context of running this + # example (nil if no exception is raised) + attr_reader :exception + + # @attr_reader + # + # Returns the metadata object associated with this example. + attr_reader :metadata + + # @attr_reader + # @private + # + # Returns the example_group_instance that provides the context for + # running this example. + attr_reader :example_group_instance + + # @attr + # @private + attr_accessor :clock + + # Creates a new instance of Example. + # @param example_group_class [Class] the subclass of ExampleGroup in which this Example is declared + # @param description [String] the String passed to the `it` method (or alias) + # @param user_metadata [Hash] additional args passed to `it` to be used as metadata + # @param example_block [Proc] the block of code that represents the example + # @api private + def initialize(example_group_class, description, user_metadata, example_block=nil) + @example_group_class = example_group_class + @example_block = example_block + + @metadata = Metadata::ExampleHash.create( + @example_group_class.metadata, user_metadata, description, example_block + ) + + @example_group_instance = @exception = nil + @clock = RSpec::Core::Time + end + + # Returns the example group class that provides the context for running + # this example. + def example_group + @example_group_class + end + + alias_method :pending?, :pending + alias_method :skipped?, :skip + + # @api private + # instance_execs the block passed to the constructor in the context of + # the instance of {ExampleGroup}. + # @param example_group_instance the instance of an ExampleGroup subclass + def run(example_group_instance, reporter) + @example_group_instance = example_group_instance + RSpec.current_example = self + + start(reporter) + Pending.mark_pending!(self, pending) if pending? + + begin + if skipped? + Pending.mark_pending! self, skip + elsif !RSpec.configuration.dry_run? + with_around_example_hooks do + begin + run_before_example + @example_group_instance.instance_exec(self, &@example_block) + + if pending? + Pending.mark_fixed! self + + raise Pending::PendingExampleFixedError, + 'Expected example to fail since it is pending, but it passed.', + [location] + end + rescue Pending::SkipDeclaredInExample + # no-op, required metadata has already been set by the `skip` + # method. + rescue Exception => e + set_exception(e) + ensure + run_after_example + end + end + end + rescue Exception => e + set_exception(e) + ensure + @example_group_instance.instance_variables.each do |ivar| + @example_group_instance.instance_variable_set(ivar, nil) + end + @example_group_instance = nil + end + + finish(reporter) + ensure + RSpec.current_example = nil + end + + # Wraps both a `Proc` and an {Example} for use in {Hooks#around + # around} hooks. In around hooks we need to yield this special + # kind of object (rather than the raw {Example}) because when + # there are multiple `around` hooks we have to wrap them recursively. + # + # @example + # + # RSpec.configure do |c| + # c.around do |ex| # Procsy which wraps the example + # if ex.metadata[:key] == :some_value && some_global_condition + # raise "some message" + # end + # ex.run # run delegates to ex.call + # end + # end + # + # @note This class also exposes the instance methods of {Example}, + # proxying them through to the wrapped {Example} instance. + class Procsy + # The {Example} instance. + attr_reader :example + + Example.public_instance_methods(false).each do |name| + next if name.to_sym == :run || name.to_sym == :inspect + + define_method(name) { |*a, &b| @example.__send__(name, *a, &b) } + end + + Proc.public_instance_methods(false).each do |name| + next if name.to_sym == :call || name.to_sym == :inspect || name.to_sym == :to_proc + + define_method(name) { |*a, &b| @proc.__send__(name, *a, &b) } + end + + # Calls the proc and notes that the example has been executed. + def call(*args, &block) + @executed = true + @proc.call(*args, &block) + end + alias run call + + # Provides a wrapped proc that will update our `executed?` state when executed. + def to_proc + method(:call).to_proc + end + + def initialize(example, &block) + @example = example + @proc = block + @executed = false + end + + # @private + def wrap(&block) + self.class.new(example, &block) + end + + # Indicates whether or not the around hook has executed the example. + def executed? + @executed + end + + # @private + def inspect + @example.inspect.gsub('Example', 'ExampleProcsy') + end + end + + # @private + def any_apply?(filters) + MetadataFilter.any_apply?(filters, metadata) + end + + # @private + def all_apply?(filters) + MetadataFilter.all_apply?(filters, metadata) || @example_group_class.all_apply?(filters) + end + + # @private + def around_example_hooks + @around_example_hooks ||= example_group.hooks.around_example_hooks_for(self) + end + + # @private + # + # Used internally to set an exception in an after hook, which + # captures the exception but doesn't raise it. + def set_exception(exception, context=nil) + if pending? && !(Pending::PendingExampleFixedError === exception) + execution_result.pending_exception = exception + else + if @exception + # An error has already been set; we don't want to override it, + # but we also don't want silence the error, so let's print it. + msg = <<-EOS + + An error occurred #{context} + #{exception.class}: #{exception.message} + occurred at #{exception.backtrace.first} + + EOS + RSpec.configuration.reporter.message(msg) + end + + @exception ||= exception + end + end + + # @private + # + # Used internally to set an exception and fail without actually executing + # the example when an exception is raised in before(:context). + def fail_with_exception(reporter, exception) + start(reporter) + set_exception(exception) + finish(reporter) + end + + # @private + # + # Used internally to skip without actually executing the example when + # skip is used in before(:context) + def skip_with_exception(reporter, exception) + start(reporter) + Pending.mark_skipped! self, exception.argument + finish(reporter) + end + + # @private + def instance_exec_with_rescue(context, &block) + @example_group_instance.instance_exec(self, &block) + rescue Exception => e + set_exception(e, context) + end + + # @private + def instance_exec(*args, &block) + @example_group_instance.instance_exec(*args, &block) + end + + private + + def with_around_example_hooks(&block) + if around_example_hooks.empty? + yield + else + @example_group_class.hooks.run(:around, :example, self, Procsy.new(self, &block)) + end + rescue Exception => e + set_exception(e, "in an `around(:example)` hook") + end + + def start(reporter) + reporter.example_started(self) + execution_result.started_at = clock.now + end + + def finish(reporter) + pending_message = execution_result.pending_message + + if @exception + record_finished :failed + execution_result.exception = @exception + reporter.example_failed self + false + elsif pending_message + record_finished :pending + execution_result.pending_message = pending_message + reporter.example_pending self + true + else + record_finished :passed + reporter.example_passed self + true + end + end + + def record_finished(status) + execution_result.record_finished(status, clock.now) + end + + def run_before_example + @example_group_instance.setup_mocks_for_rspec + @example_group_class.hooks.run(:before, :example, self) + end + + def run_after_example + @example_group_class.hooks.run(:after, :example, self) + verify_mocks + assign_generated_description if RSpec.configuration.expecting_with_rspec? + rescue Exception => e + set_exception(e, "in an `after(:example)` hook") + ensure + @example_group_instance.teardown_mocks_for_rspec + end + + def verify_mocks + @example_group_instance.verify_mocks_for_rspec if mocks_need_verification? + rescue Exception => e + if pending? + execution_result.pending_fixed = false + @exception = nil + else + set_exception(e) + end + end + + def mocks_need_verification? + exception.nil? || execution_result.pending_fixed? + end + + def assign_generated_description + if metadata[:description].empty? && (description = RSpec::Matchers.generated_description) + metadata[:description] = description + metadata[:full_description] << description + end + rescue Exception => e + set_exception(e, "while assigning the example description") + ensure + RSpec::Matchers.clear_generated_description + end + + def skip_message + if String === skip + skip + else + Pending::NO_REASON_GIVEN + end + end + + # Represents the result of executing an example. + # Behaves like a hash for backwards compatibility. + class ExecutionResult + include HashImitatable + + # @return [Symbol] `:passed`, `:failed` or `:pending`. + attr_accessor :status + + # @return [Exception, nil] The failure, if there was one. + attr_accessor :exception + + # @return [Time] When the example started. + attr_accessor :started_at + + # @return [Time] When the example finished. + attr_accessor :finished_at + + # @return [Float] How long the example took in seconds. + attr_accessor :run_time + + # @return [String, nil] The reason the example was pending, + # or nil if the example was not pending. + attr_accessor :pending_message + + # @return [Exception, nil] The exception triggered while + # executing the pending example. If no exception was triggered + # it would no longer get a status of `:pending` unless it was + # tagged with `:skip`. + attr_accessor :pending_exception + + # @return [Boolean] For examples tagged with `:pending`, + # this indicates whether or not it now passes. + attr_accessor :pending_fixed + + alias pending_fixed? pending_fixed + + # @api private + # Records the finished status of the example. + def record_finished(status, finished_at) + self.status = status + self.finished_at = finished_at + self.run_time = (finished_at - started_at).to_f + end + + private + + # For backwards compatibility we present `status` as a string + # when presenting the legacy hash interface. + def hash_for_delegation + super.tap do |hash| + hash[:status] &&= status.to_s + end + end + + def set_value(name, value) + value &&= value.to_sym if name == :status + super(name, value) + end + + def get_value(name) + if name == :status + status.to_s if status + else + super + end + end + + def issue_deprecation(_method_name, *_args) + RSpec.deprecate("Treating `metadata[:execution_result]` as a hash", + :replacement => "the attributes methods to access the data") + end + end + end + + # @private + # Provides an execution context for before/after :suite hooks. + class SuiteHookContext < Example + def initialize + super(AnonymousExampleGroup, "", {}) + end + + # To ensure we don't silence errors... + def set_exception(exception, _context=nil) + raise exception + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb new file mode 100644 index 000000000..b6cc19e7d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb @@ -0,0 +1,606 @@ +RSpec::Support.require_rspec_support 'recursive_const_methods' + +module RSpec + module Core + # ExampleGroup and {Example} are the main structural elements of + # rspec-core. Consider this example: + # + # describe Thing do + # it "does something" do + # end + # end + # + # The object returned by `describe Thing` is a subclass of ExampleGroup. + # The object returned by `it "does something"` is an instance of Example, + # which serves as a wrapper for an instance of the ExampleGroup in which it + # is declared. + # + # Example group bodies (e.g. `describe` or `context` blocks) are evaluated + # in the context of a new subclass of ExampleGroup. Individual examples are + # evaluated in the context of an instance of the specific ExampleGroup subclass + # to which they belong. + # + # Besides the class methods defined here, there are other interesting macros + # defined in {Hooks}, {MemoizedHelpers::ClassMethods} and {SharedExampleGroup}. + # There are additional instance methods available to your examples defined in + # {MemoizedHelpers} and {Pending}. + class ExampleGroup + extend Hooks + + include MemoizedHelpers + extend MemoizedHelpers::ClassMethods + include Pending + extend SharedExampleGroup + + unless respond_to?(:define_singleton_method) + # @private + def self.define_singleton_method(*a, &b) + (class << self; self; end).__send__(:define_method, *a, &b) + end + end + + # @!group Metadata + + # The [Metadata](Metadata) object associated with this group. + # @see Metadata + def self.metadata + @metadata if defined?(@metadata) + end + + # @private + # @return [Metadata] belonging to the parent of a nested {ExampleGroup} + def self.superclass_metadata + @superclass_metadata ||= superclass.respond_to?(:metadata) ? superclass.metadata : nil + end + + # @private + def self.delegate_to_metadata(*names) + names.each do |name| + define_singleton_method(name) { metadata.fetch(name) } + end + end + + delegate_to_metadata :described_class, :file_path, :location + + # @return [String] the current example group description + def self.description + description = metadata[:description] + RSpec.configuration.format_docstrings_block.call(description) + end + + # Returns the class or module passed to the `describe` method (or alias). + # Returns nil if the subject is not a class or module. + # @example + # describe Thing do + # it "does something" do + # described_class == Thing + # end + # end + # + # + def described_class + self.class.described_class + end + + # @!endgroup + + # @!group Defining Examples + + # @private + # @macro [attach] define_example_method + # @!scope class + # @param name [String] + # @param extra_options [Hash] + # @param implementation [Block] + # @yield [Example] the example object + # @example + # $1 do + # end + # + # $1 "does something" do + # end + # + # $1 "does something", :with => 'additional metadata' do + # end + # + # $1 "does something" do |ex| + # # ex is the Example object that contains metadata about the example + # end + def self.define_example_method(name, extra_options={}) + define_singleton_method(name) do |*all_args, &block| + desc, *args = *all_args + + options = Metadata.build_hash_from(args) + options.update(:skip => RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block + options.update(extra_options) + + examples << RSpec::Core::Example.new(self, desc, options, block) + examples.last + end + end + + # Defines an example within a group. + define_example_method :example + # Defines an example within a group. + # This is the primary API to define a code example. + define_example_method :it + # Defines an example within a group. + # Useful for when your docstring does not read well off of `it`. + # @example + # RSpec.describe MyClass do + # specify "#do_something is deprecated" do + # # ... + # end + # end + define_example_method :specify + + # Shortcut to define an example with `:focus => true` + # @see example + define_example_method :focus, :focus => true + # Shortcut to define an example with `:focus => true` + # @see example + define_example_method :fexample, :focus => true + # Shortcut to define an example with `:focus => true` + # @see example + define_example_method :fit, :focus => true + # Shortcut to define an example with `:focus => true` + # @see example + define_example_method :fspecify, :focus => true + # Shortcut to define an example with `:skip => 'Temporarily skipped with xexample'` + # @see example + define_example_method :xexample, :skip => 'Temporarily skipped with xexample' + # Shortcut to define an example with `:skip => 'Temporarily skipped with xit'` + # @see example + define_example_method :xit, :skip => 'Temporarily skipped with xit' + # Shortcut to define an example with `:skip => 'Temporarily skipped with xspecify'` + # @see example + define_example_method :xspecify, :skip => 'Temporarily skipped with xspecify' + # Shortcut to define an example with `:skip => true` + # @see example + define_example_method :skip, :skip => true + # Shortcut to define an example with `:pending => true` + # @see example + define_example_method :pending, :pending => true + + # @!endgroup + + # @!group Defining Example Groups + + # @private + # @macro [attach] alias_example_group_to + # @!scope class + # @param name [String] The example group doc string + # @param metadata [Hash] Additional metadata to attach to the example group + # @yield The example group definition + # + # Generates a subclass of this example group which inherits + # everything except the examples themselves. + # + # @example + # + # RSpec.describe "something" do # << This describe method is defined in + # # << RSpec::Core::DSL, included in the + # # << global namespace (optional) + # before do + # do_something_before + # end + # + # let(:thing) { Thing.new } + # + # $1 "attribute (of something)" do + # # examples in the group get the before hook + # # declared above, and can access `thing` + # end + # end + # + # @see DSL#describe + def self.define_example_group_method(name, metadata={}) + define_singleton_method(name) do |*args, &example_group_block| + thread_data = RSpec.thread_local_metadata + top_level = self == ExampleGroup + + if top_level + if thread_data[:in_example_group] + raise "Creating an isolated context from within a context is " \ + "not allowed. Change `RSpec.#{name}` to `#{name}` or " \ + "move this to a top-level scope." + end + + thread_data[:in_example_group] = true + end + + begin + + description = args.shift + combined_metadata = metadata.dup + combined_metadata.merge!(args.pop) if args.last.is_a? Hash + args << combined_metadata + + subclass(self, description, args, &example_group_block).tap do |child| + children << child + end + + ensure + thread_data.delete(:in_example_group) if top_level + end + end + + RSpec::Core::DSL.expose_example_group_alias(name) + end + + define_example_group_method :example_group + + # An alias of `example_group`. Generally used when grouping + # examples by a thing you are describing (e.g. an object, class or method). + # @see example_group + define_example_group_method :describe + + # An alias of `example_group`. Generally used when grouping examples + # contextually (e.g. "with xyz", "when xyz" or "if xyz"). + # @see example_group + define_example_group_method :context + + # Shortcut to temporarily make an example group skipped. + # @see example_group + define_example_group_method :xdescribe, :skip => "Temporarily skipped with xdescribe" + + # Shortcut to temporarily make an example group skipped. + # @see example_group + define_example_group_method :xcontext, :skip => "Temporarily skipped with xcontext" + + # Shortcut to define an example group with `:focus => true`. + # @see example_group + define_example_group_method :fdescribe, :focus => true + + # Shortcut to define an example group with `:focus => true`. + # @see example_group + define_example_group_method :fcontext, :focus => true + + # @!endgroup + + # @!group Including Shared Example Groups + + # @private + # @macro [attach] define_nested_shared_group_method + # @!scope class + # + # @see SharedExampleGroup + def self.define_nested_shared_group_method(new_name, report_label="it should behave like") + define_singleton_method(new_name) do |name, *args, &customization_block| + # Pass :caller so the :location metadata is set properly... + # otherwise, it'll be set to the next line because that's + # the block's source_location. + group = example_group("#{report_label} #{name}", :caller => caller) do + find_and_eval_shared("examples", name, *args, &customization_block) + end + group.metadata[:shared_group_name] = name + group + end + end + + # Generates a nested example group and includes the shared content + # mapped to `name` in the nested group. + define_nested_shared_group_method :it_behaves_like, "behaves like" + # Generates a nested example group and includes the shared content + # mapped to `name` in the nested group. + define_nested_shared_group_method :it_should_behave_like + + # Includes shared content mapped to `name` directly in the group in which + # it is declared, as opposed to `it_behaves_like`, which creates a nested + # group. If given a block, that block is also eval'd in the current context. + # + # @see SharedExampleGroup + def self.include_context(name, *args, &block) + find_and_eval_shared("context", name, *args, &block) + end + + # Includes shared content mapped to `name` directly in the group in which + # it is declared, as opposed to `it_behaves_like`, which creates a nested + # group. If given a block, that block is also eval'd in the current context. + # + # @see SharedExampleGroup + def self.include_examples(name, *args, &block) + find_and_eval_shared("examples", name, *args, &block) + end + + # @private + def self.find_and_eval_shared(label, name, *args, &customization_block) + shared_block = RSpec.world.shared_example_group_registry.find(parent_groups, name) + + unless shared_block + raise ArgumentError, "Could not find shared #{label} #{name.inspect}" + end + + module_exec(*args, &shared_block) + module_exec(&customization_block) if customization_block + end + + # @!endgroup + + # @private + def self.subclass(parent, description, args, &example_group_block) + subclass = Class.new(parent) + subclass.set_it_up(description, *args, &example_group_block) + ExampleGroups.assign_const(subclass) + subclass.module_exec(&example_group_block) if example_group_block + + # The LetDefinitions module must be included _after_ other modules + # to ensure that it takes precedence when there are name collisions. + # Thus, we delay including it until after the example group block + # has been eval'd. + MemoizedHelpers.define_helpers_on(subclass) + + subclass + end + + # @private + def self.set_it_up(*args, &example_group_block) + # Ruby 1.9 has a bug that can lead to infinite recursion and a + # SystemStackError if you include a module in a superclass after + # including it in a subclass: https://gist.github.com/845896 + # To prevent this, we must include any modules in RSpec::Core::ExampleGroup + # before users create example groups and have a chance to include + # the same module in a subclass of RSpec::Core::ExampleGroup. + # So we need to configure example groups here. + ensure_example_groups_are_configured + + description = args.shift + user_metadata = Metadata.build_hash_from(args) + args.unshift(description) + + @metadata = Metadata::ExampleGroupHash.create( + superclass_metadata, user_metadata, *args, &example_group_block + ) + + hooks.register_globals(self, RSpec.configuration.hooks) + RSpec.world.configure_group(self) + end + + # @private + def self.examples + @examples ||= [] + end + + # @private + def self.filtered_examples + RSpec.world.filtered_examples[self] + end + + # @private + def self.descendant_filtered_examples + @descendant_filtered_examples ||= filtered_examples + children.inject([]) { |a, e| a + e.descendant_filtered_examples } + end + + # @private + def self.children + @children ||= [] + end + + # @private + def self.descendants + @_descendants ||= [self] + children.inject([]) { |a, e| a + e.descendants } + end + + ## @private + def self.parent_groups + @parent_groups ||= ancestors.select { |a| a < RSpec::Core::ExampleGroup } + end + + # @private + def self.top_level? + @top_level ||= superclass == ExampleGroup + end + + # @private + def self.ensure_example_groups_are_configured + unless defined?(@@example_groups_configured) + RSpec.configuration.configure_mock_framework + RSpec.configuration.configure_expectation_framework + # rubocop:disable Style/ClassVars + @@example_groups_configured = true + # rubocop:enable Style/ClassVars + end + end + + # @private + def self.before_context_ivars + @before_context_ivars ||= {} + end + + # @private + def self.store_before_context_ivars(example_group_instance) + return if example_group_instance.instance_variables.empty? + + example_group_instance.instance_variables.each do |ivar| + before_context_ivars[ivar] = example_group_instance.instance_variable_get(ivar) + end + end + + # @private + def self.run_before_context_hooks(example_group_instance) + return if descendant_filtered_examples.empty? + begin + set_ivars(example_group_instance, superclass.before_context_ivars) + + ContextHookMemoizedHash::Before.isolate_for_context_hook(example_group_instance) do + hooks.run(:before, :context, example_group_instance) + end + ensure + store_before_context_ivars(example_group_instance) + end + end + + # @private + def self.run_after_context_hooks(example_group_instance) + return if descendant_filtered_examples.empty? + set_ivars(example_group_instance, before_context_ivars) + + ContextHookMemoizedHash::After.isolate_for_context_hook(example_group_instance) do + hooks.run(:after, :context, example_group_instance) + end + end + + # Runs all the examples in this group + def self.run(reporter) + if RSpec.world.wants_to_quit + RSpec.world.clear_remaining_example_groups if top_level? + return + end + reporter.example_group_started(self) + + begin + run_before_context_hooks(new) + result_for_this_group = run_examples(reporter) + results_for_descendants = ordering_strategy.order(children).map { |child| child.run(reporter) }.all? + result_for_this_group && results_for_descendants + rescue Pending::SkipDeclaredInExample => ex + for_filtered_examples(reporter) { |example| example.skip_with_exception(reporter, ex) } + rescue Exception => ex + RSpec.world.wants_to_quit = true if fail_fast? + for_filtered_examples(reporter) { |example| example.fail_with_exception(reporter, ex) } + ensure + run_after_context_hooks(new) + before_context_ivars.clear + reporter.example_group_finished(self) + end + end + + # @private + def self.ordering_strategy + order = metadata.fetch(:order, :global) + registry = RSpec.configuration.ordering_registry + + registry.fetch(order) do + warn <<-WARNING.gsub(/^ +\|/, '') + |WARNING: Ignoring unknown ordering specified using `:order => #{order.inspect}` metadata. + | Falling back to configured global ordering. + | Unrecognized ordering specified at: #{location} + WARNING + + registry.fetch(:global) + end + end + + # @private + def self.run_examples(reporter) + ordering_strategy.order(filtered_examples).map do |example| + next if RSpec.world.wants_to_quit + instance = new + set_ivars(instance, before_context_ivars) + succeeded = example.run(instance, reporter) + RSpec.world.wants_to_quit = true if fail_fast? && !succeeded + succeeded + end.all? + end + + # @private + def self.for_filtered_examples(reporter, &block) + filtered_examples.each(&block) + + children.each do |child| + reporter.example_group_started(child) + child.for_filtered_examples(reporter, &block) + reporter.example_group_finished(child) + end + false + end + + # @private + def self.fail_fast? + RSpec.configuration.fail_fast? + end + + # @private + def self.any_apply?(filters) + MetadataFilter.any_apply?(filters, metadata) + end + + # @private + def self.all_apply?(filters) + MetadataFilter.all_apply?(filters, metadata) + end + + # @private + def self.declaration_line_numbers + @declaration_line_numbers ||= [metadata[:line_number]] + + examples.map { |e| e.metadata[:line_number] } + + children.inject([]) { |a, e| a + e.declaration_line_numbers } + end + + # @private + def self.top_level_description + parent_groups.last.description + end + + # @private + def self.set_ivars(instance, ivars) + ivars.each { |name, value| instance.instance_variable_set(name, value) } + end + end + + # @private + # Unnamed example group used by `SuiteHookContext`. + class AnonymousExampleGroup < ExampleGroup + def self.metadata + {} + end + end + end + + # @private + # + # Namespace for the example group subclasses generated by top-level `describe`. + module ExampleGroups + extend Support::RecursiveConstMethods + + def self.assign_const(group) + base_name = base_name_for(group) + const_scope = constant_scope_for(group) + name = disambiguate(base_name, const_scope) + + const_scope.const_set(name, group) + end + + def self.constant_scope_for(group) + const_scope = group.superclass + const_scope = self if const_scope == ::RSpec::Core::ExampleGroup + const_scope + end + + def self.base_name_for(group) + return "Anonymous" if group.description.empty? + + # convert to CamelCase + name = ' ' + group.description + name.gsub!(/[^0-9a-zA-Z]+([0-9a-zA-Z])/) { Regexp.last_match[1].upcase } + + name.lstrip! # Remove leading whitespace + name.gsub!(/\W/, '') # JRuby, RBX and others don't like non-ascii in const names + + # Ruby requires first const letter to be A-Z. Use `Nested` + # as necessary to enforce that. + name.gsub!(/\A([^A-Z]|\z)/, 'Nested\1') + + name + end + + if RUBY_VERSION == '1.9.2' + class << self + alias _base_name_for base_name_for + def base_name_for(group) + _base_name_for(group) + '_' + end + end + private_class_method :_base_name_for + end + + def self.disambiguate(name, const_scope) + return name unless const_defined_on?(const_scope, name) + + # Add a trailing number if needed to disambiguate from an existing constant. + name << "_2" + name.next! while const_defined_on?(const_scope, name) + name + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/filter_manager.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/filter_manager.rb new file mode 100644 index 000000000..406369b21 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/filter_manager.rb @@ -0,0 +1,259 @@ +module RSpec + module Core + # @private + # Manages the filtering of examples and groups by matching tags declared on + # the command line or options files, or filters declared via + # `RSpec.configure`, with hash key/values submitted within example group + # and/or example declarations. For example, given this declaration: + # + # describe Thing, :awesome => true do + # it "does something" do + # # ... + # end + # end + # + # That group (or any other with `:awesome => true`) would be filtered in + # with any of the following commands: + # + # rspec --tag awesome:true + # rspec --tag awesome + # rspec -t awesome:true + # rspec -t awesome + # + # Prefixing the tag names with `~` negates the tags, thus excluding this group with + # any of: + # + # rspec --tag ~awesome:true + # rspec --tag ~awesome + # rspec -t ~awesome:true + # rspec -t ~awesome + # + # ## Options files and command line overrides + # + # Tag declarations can be stored in `.rspec`, `~/.rspec`, or a custom + # options file. This is useful for storing defaults. For example, let's + # say you've got some slow specs that you want to suppress most of the + # time. You can tag them like this: + # + # describe Something, :slow => true do + # + # And then store this in `.rspec`: + # + # --tag ~slow:true + # + # Now when you run `rspec`, that group will be excluded. + # + # ## Overriding + # + # Of course, you probably want to run them sometimes, so you can override + # this tag on the command line like this: + # + # rspec --tag slow:true + # + # ## RSpec.configure + # + # You can also store default tags with `RSpec.configure`. We use `tag` on + # the command line (and in options files like `.rspec`), but for historical + # reasons we use the term `filter` in `RSpec.configure: + # + # RSpec.configure do |c| + # c.filter_run_including :foo => :bar + # c.filter_run_excluding :foo => :bar + # end + # + # These declarations can also be overridden from the command line. + # + # @see RSpec.configure + # @see Configuration#filter_run_including + # @see Configuration#filter_run_excluding + class FilterManager + attr_reader :exclusions, :inclusions + + def initialize + @exclusions, @inclusions = FilterRules.build + end + + # @api private + # + # @param file_path [String] + # @param line_numbers [Array] + def add_location(file_path, line_numbers) + # locations is a hash of expanded paths to arrays of line + # numbers to match against. e.g. + # { "path/to/file.rb" => [37, 42] } + locations = inclusions.delete(:locations) || Hash.new { |h, k| h[k] = [] } + locations[File.expand_path(file_path)].push(*line_numbers) + inclusions.add_location(locations) + end + + def empty? + inclusions.empty? && exclusions.empty? + end + + def prune(examples) + if inclusions.standalone? + base_exclusions = ExclusionRules.new + examples.select { |e| !base_exclusions.include_example?(e) && include?(e) } + else + examples.select { |e| !exclude?(e) && include?(e) } + end + end + + def exclude(*args) + exclusions.add(args.last) + end + + def exclude_only(*args) + exclusions.use_only(args.last) + end + + def exclude_with_low_priority(*args) + exclusions.add_with_low_priority(args.last) + end + + def exclude?(example) + exclusions.include_example?(example) + end + + def include(*args) + inclusions.add(args.last) + end + + def include_only(*args) + inclusions.use_only(args.last) + end + + def include_with_low_priority(*args) + inclusions.add_with_low_priority(args.last) + end + + def include?(example) + inclusions.include_example?(example) + end + end + + # @private + class FilterRules + PROC_HEX_NUMBER = /0x[0-9a-f]+@/ + PROJECT_DIR = File.expand_path('.') + + attr_accessor :opposite + attr_reader :rules + + def self.build + exclusions = ExclusionRules.new + inclusions = InclusionRules.new + exclusions.opposite = inclusions + inclusions.opposite = exclusions + [exclusions, inclusions] + end + + def initialize(*args, &block) + @rules = Hash.new(*args, &block) + end + + def add(updated) + @rules.merge!(updated).each_key { |k| opposite.delete(k) } + end + + def add_with_low_priority(updated) + updated = updated.merge(@rules) + opposite.each_pair { |k, v| updated.delete(k) if updated[k] == v } + @rules.replace(updated) + end + + def use_only(updated) + updated.each_key { |k| opposite.delete(k) } + @rules.replace(updated) + end + + def clear + @rules.clear + end + + def delete(key) + @rules.delete(key) + end + + def fetch(*args, &block) + @rules.fetch(*args, &block) + end + + def [](key) + @rules[key] + end + + def empty? + rules.empty? + end + + def each_pair(&block) + @rules.each_pair(&block) + end + + def description + rules.inspect.gsub(PROC_HEX_NUMBER, '').gsub(PROJECT_DIR, '.').gsub(' (lambda)', '') + end + end + + # @private + class InclusionRules < FilterRules + STANDALONE_FILTERS = [:locations, :full_description] + + def add_location(locations) + replace_filters(:locations => locations) + end + + def add(*args) + apply_standalone_filter(*args) || super + end + + def add_with_low_priority(*args) + apply_standalone_filter(*args) || super + end + + def use(*args) + apply_standalone_filter(*args) || super + end + + def include_example?(example) + @rules.empty? ? true : example.any_apply?(@rules) + end + + def standalone? + is_standalone_filter?(@rules) + end + + private + + def apply_standalone_filter(updated) + return true if standalone? + return nil unless is_standalone_filter?(updated) + + replace_filters(updated) + true + end + + def replace_filters(new_rules) + @rules.replace(new_rules) + opposite.clear + end + + def is_standalone_filter?(rules) + STANDALONE_FILTERS.any? { |key| rules.key?(key) } + end + end + + # @private + class ExclusionRules < FilterRules + CONDITIONAL_FILTERS = { + :if => lambda { |value| !value }, + :unless => lambda { |value| value } + }.freeze + + def include_example?(example) + example.any_apply?(@rules) || example.any_apply?(CONDITIONAL_FILTERS) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/flat_map.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/flat_map.rb new file mode 100644 index 000000000..cc4e5a4d3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/flat_map.rb @@ -0,0 +1,18 @@ +module RSpec + module Core + # @private + module FlatMap + if [].respond_to?(:flat_map) + def flat_map(array) + array.flat_map { |item| yield item } + end + else # for 1.8.7 + def flat_map(array) + array.map { |item| yield item }.flatten + end + end + + module_function :flat_map + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters.rb new file mode 100644 index 000000000..bc46a990e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters.rb @@ -0,0 +1,240 @@ +RSpec::Support.require_rspec_support "directory_maker" +# ## Built-in Formatters +# +# * progress (default) - prints dots for passing examples, `F` for failures, `*` for pending +# * documentation - prints the docstrings passed to `describe` and `it` methods (and their aliases) +# * html +# * json - useful for archiving data for subsequent analysis +# +# The progress formatter is the default, but you can choose any one or more of +# the other formatters by passing with the `--format` (or `-f` for short) +# command-line option, e.g. +# +# rspec --format documentation +# +# You can also send the output of multiple formatters to different streams, e.g. +# +# rspec --format documentation --format html --out results.html +# +# This example sends the output of the documentation formatter to `$stdout`, and +# the output of the html formatter to results.html. +# +# ## Custom Formatters +# +# You can tell RSpec to use a custom formatter by passing its path and name to +# the `rspec` commmand. For example, if you define MyCustomFormatter in +# path/to/my_custom_formatter.rb, you would type this command: +# +# rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter +# +# The reporter calls every formatter with this protocol: +# +# * To start +# * `start(StartNotification)` +# * Once per example group +# * `example_group_started(GroupNotification)` +# * Once per example +# * `example_started(ExampleNotification)` +# * One of these per example, depending on outcome +# * `example_passed(ExampleNotification)` +# * `example_failed(FailedExampleNotification)` +# * `example_pending(ExampleNotification)` +# * Optionally at any time +# * `message(MessageNotification)` +# * At the end of the suite +# * `stop(ExamplesNotification)` +# * `start_dump(NullNotification)` +# * `dump_pending(ExamplesNotification)` +# * `dump_failures(ExamplesNotification)` +# * `dump_summary(SummaryNotification)` +# * `seed(SeedNotification)` +# * `close(NullNotification)` +# +# Only the notifications to which you subscribe your formatter will be called +# on your formatter. To subscribe your formatter use: +# `RSpec::Core::Formatters#register` e.g. +# +# `RSpec::Core::Formatters.register FormatterClassName, :example_passed, :example_failed` +# +# We recommend you implement the methods yourself; for simplicity we provide the +# default formatter output via our notification objects but if you prefer you +# can subclass `RSpec::Core::Formatters::BaseTextFormatter` and override the +# methods you wish to enhance. +# +# @see RSpec::Core::Formatters::BaseTextFormatter +# @see RSpec::Core::Reporter +module RSpec::Core::Formatters + autoload :DocumentationFormatter, 'rspec/core/formatters/documentation_formatter' + autoload :HtmlFormatter, 'rspec/core/formatters/html_formatter' + autoload :ProgressFormatter, 'rspec/core/formatters/progress_formatter' + autoload :ProfileFormatter, 'rspec/core/formatters/profile_formatter' + autoload :JsonFormatter, 'rspec/core/formatters/json_formatter' + + # Register the formatter class + # @param formatter_class [Class] formatter class to register + # @param notifications [Symbol, ...] one or more notifications to be registered to the specified formatter + # + # @see RSpec::Core::Formatters::BaseFormatter + def self.register(formatter_class, *notifications) + Loader.formatters[formatter_class] = notifications + end + + # @api private + # + # `RSpec::Core::Formatters::Loader` is an internal class for + # managing formatters used by a particular configuration. It is + # not expected to be used directly, but only through the configuration + # interface. + class Loader + # @api private + # + # Internal formatters are stored here when loaded + def self.formatters + @formatters ||= {} + end + + # @api private + def initialize(reporter) + @formatters = [] + @reporter = reporter + self.default_formatter = 'progress' + end + + # @return [Array] the loaded formatters + attr_reader :formatters + + # @return [Reporter] the reporter + attr_reader :reporter + + # @return [String] the default formatter to setup, defaults to `progress` + attr_accessor :default_formatter + + # @private + def setup_default(output_stream, deprecation_stream) + add default_formatter, output_stream if @formatters.empty? + + unless @formatters.any? { |formatter| DeprecationFormatter === formatter } + add DeprecationFormatter, deprecation_stream, output_stream + end + + return unless RSpec.configuration.profile_examples? && !existing_formatter_implements?(:dump_profile) + + add RSpec::Core::Formatters::ProfileFormatter, output_stream + end + + # @private + def add(formatter_to_use, *paths) + formatter_class = find_formatter(formatter_to_use) + + args = paths.map { |p| p.respond_to?(:puts) ? p : file_at(p) } + + if !Loader.formatters[formatter_class].nil? + formatter = formatter_class.new(*args) + @reporter.register_listener formatter, *notifications_for(formatter_class) + elsif defined?(RSpec::LegacyFormatters) + formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args + @reporter.register_listener formatter, *formatter.notifications + else + line = ::RSpec::CallerFilter.first_non_rspec_line + if line + call_site = "Formatter added at: #{line}" + else + call_site = "The formatter was added via command line flag or your "\ + "`.rspec` file." + end + + RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ') + |The #{formatter_class} formatter uses the deprecated formatter + |interface not supported directly by RSpec 3. + | + |To continue to use this formatter you must install the + |`rspec-legacy_formatters` gem, which provides support + |for legacy formatters or upgrade the formatter to a + |compatible version. + | + |#{call_site} + WARNING + return + end + @formatters << formatter unless duplicate_formatter_exists?(formatter) + formatter + end + + private + + def find_formatter(formatter_to_use) + built_in_formatter(formatter_to_use) || + custom_formatter(formatter_to_use) || + (raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?.") + end + + def duplicate_formatter_exists?(new_formatter) + @formatters.any? do |formatter| + formatter.class === new_formatter && formatter.output == new_formatter.output + end + end + + def existing_formatter_implements?(notification) + @reporter.registered_listeners(notification).any? + end + + def built_in_formatter(key) + case key.to_s + when 'd', 'doc', 'documentation' + DocumentationFormatter + when 'h', 'html' + HtmlFormatter + when 'p', 'progress' + ProgressFormatter + when 'j', 'json' + JsonFormatter + end + end + + def notifications_for(formatter_class) + formatter_class.ancestors.inject(Set.new) do |notifications, klass| + notifications + Loader.formatters.fetch(klass) { Set.new } + end + end + + def custom_formatter(formatter_ref) + if Class === formatter_ref + formatter_ref + elsif string_const?(formatter_ref) + begin + formatter_ref.gsub(/^::/, '').split('::').inject(Object) { |a, e| a.const_get e } + rescue NameError + require(path_for(formatter_ref)) ? retry : raise + end + end + end + + def string_const?(str) + str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str + end + + def path_for(const_ref) + underscore_with_fix_for_non_standard_rspec_naming(const_ref) + end + + def underscore_with_fix_for_non_standard_rspec_naming(string) + underscore(string).sub(%r{(^|/)r_spec($|/)}, '\\1rspec\\2') + end + + # activesupport/lib/active_support/inflector/methods.rb, line 48 + def underscore(camel_cased_word) + word = camel_cased_word.to_s.dup + word.gsub!(/::/, '/') + word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') + word.tr!("-", "_") + word.downcase! + word + end + + def file_at(path) + RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(path)) + File.new(path, 'w') + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_formatter.rb new file mode 100644 index 000000000..55c52b110 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_formatter.rb @@ -0,0 +1,67 @@ +RSpec::Support.require_rspec_core "formatters/helpers" +require 'stringio' + +module RSpec + module Core + module Formatters + # RSpec's built-in formatters are all subclasses of RSpec::Core::Formatters::BaseTextFormatter. + # + # @see RSpec::Core::Formatters::BaseTextFormatter + # @see RSpec::Core::Reporter + # @see RSpec::Core::Formatters::Protocol + class BaseFormatter + # all formatters inheriting from this formatter will receive these notifications + Formatters.register self, :start, :example_group_started, :close + attr_accessor :example_group + attr_reader :output + + # @api public + # @param output [IO] the formatter output + # @see RSpec::Core::Formatters::Protocol#initialize + def initialize(output) + @output = output || StringIO.new + @example_group = nil + end + + # @api public + # + # @param notification [StartNotification] + # @see RSpec::Core::Formatters::Protocol#start + def start(notification) + start_sync_output + @example_count = notification.count + end + + # @api public + # + # @param notification [GroupNotification] containing example_group subclass of `RSpec::Core::ExampleGroup` + # @see RSpec::Core::Formatters::Protocol#example_group_started + def example_group_started(notification) + @example_group = notification.group + end + + # @api public + # + # @param notification [NullNotification] + # @see RSpec::Core::Formatters::Protocol#close + def close(_notification) + restore_sync_output + end + + private + + def start_sync_output + @old_sync, output.sync = output.sync, true if output_supports_sync + end + + def restore_sync_output + output.sync = @old_sync if output_supports_sync && !output.closed? + end + + def output_supports_sync + output.respond_to?(:sync=) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_text_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_text_formatter.rb new file mode 100644 index 000000000..6a858b1e4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/base_text_formatter.rb @@ -0,0 +1,76 @@ +RSpec::Support.require_rspec_core "formatters/base_formatter" +RSpec::Support.require_rspec_core "formatters/console_codes" + +module RSpec + module Core + module Formatters + # Base for all of RSpec's built-in formatters. See RSpec::Core::Formatters::BaseFormatter + # to learn more about all of the methods called by the reporter. + # + # @see RSpec::Core::Formatters::BaseFormatter + # @see RSpec::Core::Reporter + class BaseTextFormatter < BaseFormatter + Formatters.register self, + :message, :dump_summary, :dump_failures, :dump_pending, :seed + + # @method message + # @api public + # + # Used by the reporter to send messages to the output stream. + # + # @param notification [MessageNotification] containing message + def message(notification) + output.puts notification.message + end + + # @method dump_failures + # @api public + # + # Dumps detailed information about each example failure. + # + # @param notification [NullNotification] + def dump_failures(notification) + return if notification.failure_notifications.empty? + output.puts notification.fully_formatted_failed_examples + end + + # @method dump_summary + # @api public + # + # This method is invoked after the dumping of examples and failures. Each parameter + # is assigned to a corresponding attribute. + # + # @param summary [SummaryNotification] containing duration, example_count, + # failure_count and pending_count + def dump_summary(summary) + output.puts summary.fully_formatted + end + + # @private + def dump_pending(notification) + return if notification.pending_examples.empty? + output.puts notification.fully_formatted_pending_examples + end + + # @private + def seed(notification) + return unless notification.seed_used? + output.puts notification.fully_formatted + end + + # @api public + # + # Invoked at the very end, `close` allows the formatter to clean + # up resources, e.g. open streams, etc. + # + # @param notification [NullNotification] + def close(_notification) + return unless IO === output + return if output.closed? || output == $stdout + + output.close + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/console_codes.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/console_codes.rb new file mode 100644 index 000000000..9c2a11a7c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/console_codes.rb @@ -0,0 +1,64 @@ +module RSpec + module Core + module Formatters + # ConsoleCodes provides helpers for formatting console output + # with ANSI codes, e.g. color's and bold. + module ConsoleCodes + # @private + VT100_CODES = + { + :black => 30, + :red => 31, + :green => 32, + :yellow => 33, + :blue => 34, + :magenta => 35, + :cyan => 36, + :white => 37, + :bold => 1, + } + # @private + VT100_CODE_VALUES = VT100_CODES.invert + + module_function + + # Fetches the correct code for the supplied symbol, or checks + # that a code is valid. Defaults to white (37). + # + # @param code_or_symbol [Symbol, Fixnum] Symbol or code to check + # @return [Fixnum] a console code + def console_code_for(code_or_symbol) + if RSpec.configuration.respond_to?(:"#{code_or_symbol}_color") + console_code_for configuration_color(code_or_symbol) + elsif VT100_CODE_VALUES.key?(code_or_symbol) + code_or_symbol + else + VT100_CODES.fetch(code_or_symbol) do + console_code_for(:white) + end + end + end + + # Wraps a piece of text in ANSI codes with the supplied code. Will + # only apply the control code if `RSpec.configuration.color_enabled?` + # returns true. + # + # @param text [String] the text to wrap + # @param code_or_symbol [Symbol, Fixnum] the desired control code + # @return [String] the wrapped text + def wrap(text, code_or_symbol) + if RSpec.configuration.color_enabled? + "\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m" + else + text + end + end + + # @private + def configuration_color(code) + RSpec.configuration.__send__(:"#{code}_color") + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/deprecation_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/deprecation_formatter.rb new file mode 100644 index 000000000..231fee830 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/deprecation_formatter.rb @@ -0,0 +1,222 @@ +RSpec::Support.require_rspec_core "formatters/helpers" +require 'set' + +module RSpec + module Core + module Formatters + # @private + class DeprecationFormatter + Formatters.register self, :deprecation, :deprecation_summary + + attr_reader :count, :deprecation_stream, :summary_stream + + def initialize(deprecation_stream, summary_stream) + @deprecation_stream = deprecation_stream + @summary_stream = summary_stream + @seen_deprecations = Set.new + @count = 0 + end + alias :output :deprecation_stream + + def printer + @printer ||= case deprecation_stream + when File + ImmediatePrinter.new(FileStream.new(deprecation_stream), summary_stream, self) + when RaiseErrorStream + ImmediatePrinter.new(deprecation_stream, summary_stream, self) + else + DelayedPrinter.new(deprecation_stream, summary_stream, self) + end + end + + def deprecation(notification) + return if @seen_deprecations.include? notification + + @count += 1 + printer.print_deprecation_message notification + @seen_deprecations << notification + end + + def deprecation_summary(_notification) + printer.deprecation_summary + end + + def deprecation_message_for(data) + if data.message + SpecifiedDeprecationMessage.new(data) + else + GeneratedDeprecationMessage.new(data) + end + end + + RAISE_ERROR_CONFIG_NOTICE = <<-EOS.gsub(/^\s+\|/, '') + | + |If you need more of the backtrace for any of these deprecations to + |identify where to make the necessary changes, you can configure + |`config.raise_errors_for_deprecations!`, and it will turn the + |deprecation warnings into errors, giving you the full backtrace. + EOS + + DEPRECATION_STREAM_NOTICE = "Pass `--deprecation-out` or set " \ + "`config.deprecation_stream` to a file for full output." + + SpecifiedDeprecationMessage = Struct.new(:type) do + def initialize(data) + @message = data.message + super deprecation_type_for(data) + end + + def to_s + output_formatted @message + end + + def too_many_warnings_message + msg = "Too many similar deprecation messages reported, disregarding further reports. " + msg << DEPRECATION_STREAM_NOTICE + msg + end + + private + + def output_formatted(str) + return str unless str.lines.count > 1 + separator = "#{'-' * 80}" + "#{separator}\n#{str.chomp}\n#{separator}" + end + + def deprecation_type_for(data) + data.message.gsub(/(\w+\/)+\w+\.rb:\d+/, '') + end + end + + GeneratedDeprecationMessage = Struct.new(:type) do + def initialize(data) + @data = data + super data.deprecated + end + + def to_s + msg = "#{@data.deprecated} is deprecated." + msg << " Use #{@data.replacement} instead." if @data.replacement + msg << " Called from #{@data.call_site}." if @data.call_site + msg + end + + def too_many_warnings_message + msg = "Too many uses of deprecated '#{type}'. " + msg << DEPRECATION_STREAM_NOTICE + msg + end + end + + # @private + class ImmediatePrinter + attr_reader :deprecation_stream, :summary_stream, :deprecation_formatter + + def initialize(deprecation_stream, summary_stream, deprecation_formatter) + @deprecation_stream = deprecation_stream + + @summary_stream = summary_stream + @deprecation_formatter = deprecation_formatter + end + + def print_deprecation_message(data) + deprecation_message = deprecation_formatter.deprecation_message_for(data) + deprecation_stream.puts deprecation_message.to_s + end + + def deprecation_summary + return if deprecation_formatter.count.zero? + deprecation_stream.summarize(summary_stream, deprecation_formatter.count) + end + end + + # @private + class DelayedPrinter + TOO_MANY_USES_LIMIT = 4 + + attr_reader :deprecation_stream, :summary_stream, :deprecation_formatter + + def initialize(deprecation_stream, summary_stream, deprecation_formatter) + @deprecation_stream = deprecation_stream + @summary_stream = summary_stream + @deprecation_formatter = deprecation_formatter + @seen_deprecations = Hash.new { 0 } + @deprecation_messages = Hash.new { |h, k| h[k] = [] } + end + + def print_deprecation_message(data) + deprecation_message = deprecation_formatter.deprecation_message_for(data) + @seen_deprecations[deprecation_message] += 1 + + stash_deprecation_message(deprecation_message) + end + + def stash_deprecation_message(deprecation_message) + if @seen_deprecations[deprecation_message] < TOO_MANY_USES_LIMIT + @deprecation_messages[deprecation_message] << deprecation_message.to_s + elsif @seen_deprecations[deprecation_message] == TOO_MANY_USES_LIMIT + @deprecation_messages[deprecation_message] << deprecation_message.too_many_warnings_message + end + end + + def deprecation_summary + return unless @deprecation_messages.any? + + print_deferred_deprecation_warnings + deprecation_stream.puts RAISE_ERROR_CONFIG_NOTICE + + summary_stream.puts "\n#{Helpers.pluralize(deprecation_formatter.count, 'deprecation warning')} total" + end + + def print_deferred_deprecation_warnings + deprecation_stream.puts "\nDeprecation Warnings:\n\n" + @deprecation_messages.keys.sort_by(&:type).each do |deprecation| + messages = @deprecation_messages[deprecation] + messages.each { |msg| deprecation_stream.puts msg } + deprecation_stream.puts + end + end + end + + # @private + # Not really a stream, but is usable in place of one. + class RaiseErrorStream + def puts(message) + raise DeprecationError, message + end + + def summarize(summary_stream, deprecation_count) + summary_stream.puts "\n#{Helpers.pluralize(deprecation_count, 'deprecation')} found." + end + end + + # @private + # Wraps a File object and provides file-specific operations. + class FileStream + def initialize(file) + @file = file + + # In one of my test suites, I got lots of duplicate output in the + # deprecation file (e.g. 200 of the same deprecation, even though + # the `puts` below was only called 6 times). Setting `sync = true` + # fixes this (but we really have no idea why!). + @file.sync = true + end + + def puts(*args) + @file.puts(*args) + end + + def summarize(summary_stream, deprecation_count) + summary_stream.puts "\n#{Helpers.pluralize(deprecation_count, 'deprecation')} logged to #{@file.path}" + puts RAISE_ERROR_CONFIG_NOTICE + end + end + end + end + + # Deprecation Error + DeprecationError = Class.new(StandardError) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/documentation_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/documentation_formatter.rb new file mode 100644 index 000000000..5cf6e178e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/documentation_formatter.rb @@ -0,0 +1,68 @@ +RSpec::Support.require_rspec_core "formatters/base_text_formatter" + +module RSpec + module Core + module Formatters + # @private + class DocumentationFormatter < BaseTextFormatter + Formatters.register self, :example_group_started, :example_group_finished, + :example_passed, :example_pending, :example_failed + + def initialize(output) + super + @group_level = 0 + end + + def example_group_started(notification) + output.puts if @group_level == 0 + output.puts "#{current_indentation}#{notification.group.description.strip}" + + @group_level += 1 + end + + def example_group_finished(_notification) + @group_level -= 1 + end + + def example_passed(passed) + output.puts passed_output(passed.example) + end + + def example_pending(pending) + output.puts pending_output(pending.example, pending.example.execution_result.pending_message) + end + + def example_failed(failure) + output.puts failure_output(failure.example, failure.example.execution_result.exception) + end + + private + + def passed_output(example) + ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success) + end + + def pending_output(example, message) + ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} (PENDING: #{message})", :pending) + end + + def failure_output(example, _exception) + ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} (FAILED - #{next_failure_index})", :failure) + end + + def next_failure_index + @next_failure_index ||= 0 + @next_failure_index += 1 + end + + def current_indentation + ' ' * @group_level + end + + def example_group_chain + example_group.parent_groups.reverse + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/helpers.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/helpers.rb new file mode 100644 index 000000000..9eb867bda --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/helpers.rb @@ -0,0 +1,87 @@ +module RSpec + module Core + module Formatters + # Formatters helpers + module Helpers + # @private + SUB_SECOND_PRECISION = 5 + + # @private + DEFAULT_PRECISION = 2 + + # @api private + # + # Formats seconds into a human-readable string. + # + # @param duration [Float, Fixnum] in seconds + # @return [String] human-readable time + # + # @example + # format_duration(1) #=> "1 minute 1 second" + # format_duration(135.14) #=> "2 minutes 15.14 seconds" + def self.format_duration(duration) + precision = case + when duration < 1 then SUB_SECOND_PRECISION + when duration < 120 then DEFAULT_PRECISION + when duration < 300 then 1 + else 0 + end + + if duration > 60 + minutes = (duration.to_i / 60).to_i + seconds = duration - minutes * 60 + + "#{pluralize(minutes, 'minute')} #{pluralize(format_seconds(seconds, precision), 'second')}" + else + pluralize(format_seconds(duration, precision), 'second') + end + end + + # @api private + # + # Formats seconds to have 5 digits of precision with trailing zeros removed if the number + # is less than 1 or with 2 digits of precision if the number is greater than zero. + # + # @param float [Float] + # @return [String] formatted float + # + # @example + # format_seconds(0.000006) #=> "0.00001" + # format_seconds(0.020000) #=> "0.02" + # format_seconds(1.00000000001) #=> "1" + # + # The precision used is set in {Helpers::SUB_SECOND_PRECISION} and {Helpers::DEFAULT_PRECISION}. + # + # @see #strip_trailing_zeroes + def self.format_seconds(float, precision=nil) + precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION + formatted = "%.#{precision}f" % float + strip_trailing_zeroes(formatted) + end + + # @api private + # + # Remove trailing zeros from a string. + # + # @param string [String] string with trailing zeros + # @return [String] string with trailing zeros removed + def self.strip_trailing_zeroes(string) + stripped = string.sub(/[^1-9]+$/, '') + stripped.empty? ? "0" : stripped + end + private_class_method :strip_trailing_zeroes + + # @api private + # + # Pluralize a word based on a count. + # + # @param count [Fixnum] number of objects + # @param string [String] word to be pluralized + # @return [String] pluralized word + def self.pluralize(count, string) + "#{count} #{string}#{'s' unless count.to_f == 1}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_formatter.rb new file mode 100644 index 000000000..5eeb23c12 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_formatter.rb @@ -0,0 +1,149 @@ +RSpec::Support.require_rspec_core "formatters/base_text_formatter" +RSpec::Support.require_rspec_core "formatters/html_printer" + +module RSpec + module Core + module Formatters + # @private + class HtmlFormatter < BaseFormatter + Formatters.register self, :start, :example_group_started, :start_dump, + :example_started, :example_passed, :example_failed, + :example_pending, :dump_summary + + def initialize(output) + super(output) + @failed_examples = [] + @example_group_number = 0 + @example_number = 0 + @header_red = nil + @printer = HtmlPrinter.new(output) + end + + def start(notification) + super + @printer.print_html_start + @printer.flush + end + + def example_group_started(notification) + super + @example_group_red = false + @example_group_number += 1 + + @printer.print_example_group_end unless example_group_number == 1 + @printer.print_example_group_start(example_group_number, notification.group.description, notification.group.parent_groups.size) + @printer.flush + end + + def start_dump(_notification) + @printer.print_example_group_end + @printer.flush + end + + def example_started(_notification) + @example_number += 1 + end + + def example_passed(passed) + @printer.move_progress(percent_done) + @printer.print_example_passed(passed.example.description, passed.example.execution_result.run_time) + @printer.flush + end + + def example_failed(failure) + @failed_examples << failure.example + unless @header_red + @header_red = true + @printer.make_header_red + end + + unless @example_group_red + @example_group_red = true + @printer.make_example_group_header_red(example_group_number) + end + + @printer.move_progress(percent_done) + + example = failure.example + + exception = failure.exception + exception_details = if exception + { + :message => exception.message, + :backtrace => failure.formatted_backtrace.join("\n") + } + else + false + end + extra = extra_failure_content(failure) + + @printer.print_example_failed( + example.execution_result.pending_fixed, + example.description, + example.execution_result.run_time, + @failed_examples.size, + exception_details, + (extra == "") ? false : extra, + true + ) + @printer.flush + end + + def example_pending(pending) + example = pending.example + + @printer.make_header_yellow unless @header_red + @printer.make_example_group_header_yellow(example_group_number) unless @example_group_red + @printer.move_progress(percent_done) + @printer.print_example_pending(example.description, example.execution_result.pending_message) + @printer.flush + end + + def dump_summary(summary) + @printer.print_summary( + summary.duration, + summary.example_count, + summary.failure_count, + summary.pending_count + ) + @printer.flush + end + + private + + # If these methods are declared with attr_reader Ruby will issue a warning because they are private + # rubocop:disable Style/TrivialAccessors + + # The number of the currently running example_group + def example_group_number + @example_group_number + end + + # The number of the currently running example (a global counter) + def example_number + @example_number + end + # rubocop:enable Style/TrivialAccessors + + def percent_done + result = 100.0 + if @example_count > 0 + result = (((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0).to_f + end + result + end + + # Override this method if you wish to output extra HTML for a failed spec. For example, you + # could output links to images or other files produced during the specs. + # + def extra_failure_content(failure) + RSpec::Support.require_rspec_core "formatters/snippet_extractor" + backtrace = failure.exception.backtrace.map { |line| RSpec.configuration.backtrace_formatter.backtrace_line(line) } + backtrace.compact! + @snippet_extractor ||= SnippetExtractor.new + "
#{@snippet_extractor.snippet(backtrace)}
" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_printer.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_printer.rb new file mode 100644 index 000000000..13c380246 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/html_printer.rb @@ -0,0 +1,403 @@ +require 'erb' + +module RSpec + module Core + module Formatters + # @private + class HtmlPrinter + include ERB::Util # for the #h method + def initialize(output) + @output = output + end + + def print_html_start + @output.puts HTML_HEADER + @output.puts REPORT_HEADER + end + + def print_example_group_end + @output.puts " " + @output.puts "" + end + + def print_example_group_start(group_id, description, number_of_parents) + @output.puts "
" + @output.puts "
" + @output.puts "
#{h(description)}
" + end + + def print_example_passed(description, run_time) + formatted_run_time = "%.5f" % run_time + @output.puts "
#{h(description)}#{formatted_run_time}s
" + end + + # rubocop:disable Style/ParameterLists + def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content, escape_backtrace=false) + # rubocop:enable Style/ParameterLists + formatted_run_time = "%.5f" % run_time + + @output.puts "
" + @output.puts " #{h(description)}" + @output.puts " #{formatted_run_time}s" + @output.puts "
" + if exception + @output.puts "
#{h(exception[:message])}
" + if escape_backtrace + @output.puts "
#{h exception[:backtrace]}
" + else + @output.puts "
#{exception[:backtrace]}
" + end + end + @output.puts extra_content if extra_content + @output.puts "
" + @output.puts "
" + end + + def print_example_pending(description, pending_message) + @output.puts "
#{h(description)} (PENDING: #{h(pending_message)})
" + end + + def print_summary(duration, example_count, failure_count, pending_count) + totals = "#{example_count} example#{'s' unless example_count == 1}, " + totals << "#{failure_count} failure#{'s' unless failure_count == 1}" + totals << ", #{pending_count} pending" if pending_count > 0 + + formatted_duration = "%.5f" % duration + + @output.puts "" + @output.puts "" + @output.puts "
" + @output.puts "" + @output.puts "" + @output.puts "" + end + + def flush + @output.flush + end + + def move_progress(percent_done) + @output.puts " " + @output.flush + end + + def make_header_red + @output.puts " " + end + + def make_header_yellow + @output.puts " " + end + + def make_example_group_header_red(group_id) + @output.puts " " + @output.puts " " + end + + def make_example_group_header_yellow(group_id) + @output.puts " " + @output.puts " " + end + + private + + def indentation_style(number_of_parents) + "style=\"margin-left: #{(number_of_parents - 1) * 15}px;\"" + end + + REPORT_HEADER = <<-EOF +
+ +
+
+

RSpec Code Examples

+
+ +
+ + + +
+ +
+

 

+

 

+
+
+ + +
+EOF + + GLOBAL_SCRIPTS = <<-EOF + +function addClass(element_id, classname) { + document.getElementById(element_id).className += (" " + classname); +} + +function removeClass(element_id, classname) { + var elem = document.getElementById(element_id); + var classlist = elem.className.replace(classname,''); + elem.className = classlist; +} + +function moveProgressBar(percentDone) { + document.getElementById("rspec-header").style.width = percentDone +"%"; +} + +function makeRed(element_id) { + removeClass(element_id, 'passed'); + removeClass(element_id, 'not_implemented'); + addClass(element_id,'failed'); +} + +function makeYellow(element_id) { + var elem = document.getElementById(element_id); + if (elem.className.indexOf("failed") == -1) { // class doesn't includes failed + if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented + removeClass(element_id, 'passed'); + addClass(element_id,'not_implemented'); + } + } +} + +function apply_filters() { + var passed_filter = document.getElementById('passed_checkbox').checked; + var failed_filter = document.getElementById('failed_checkbox').checked; + var pending_filter = document.getElementById('pending_checkbox').checked; + + assign_display_style("example passed", passed_filter); + assign_display_style("example failed", failed_filter); + assign_display_style("example not_implemented", pending_filter); + + assign_display_style_for_group("example_group passed", passed_filter); + assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter); + assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter); +} + +function get_display_style(display_flag) { + var style_mode = 'none'; + if (display_flag == true) { + style_mode = 'block'; + } + return style_mode; +} + +function assign_display_style(classname, display_flag) { + var style_mode = get_display_style(display_flag); + var elems = document.getElementsByClassName(classname) + for (var i=0; i + + + RSpec results + + + + + + + + +EOF + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/json_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/json_formatter.rb new file mode 100644 index 000000000..080c10568 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/json_formatter.rb @@ -0,0 +1,94 @@ +RSpec::Support.require_rspec_core "formatters/base_formatter" +require 'json' + +module RSpec + module Core + module Formatters + # @private + class JsonFormatter < BaseFormatter + Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :close + + attr_reader :output_hash + + def initialize(output) + super + @output_hash = {} + end + + def message(notification) + (@output_hash[:messages] ||= []) << notification.message + end + + def dump_summary(summary) + @output_hash[:summary] = { + :duration => summary.duration, + :example_count => summary.example_count, + :failure_count => summary.failure_count, + :pending_count => summary.pending_count + } + @output_hash[:summary_line] = summary.totals_line + end + + def stop(notification) + @output_hash[:examples] = notification.examples.map do |example| + format_example(example).tap do |hash| + e = example.exception + if e + hash[:exception] = { + :class => e.class.name, + :message => e.message, + :backtrace => e.backtrace, + } + end + end + end + end + + def close(_notification) + output.write @output_hash.to_json + output.close if IO === output && output != $stdout + end + + def dump_profile(profile) + @output_hash[:profile] = {} + dump_profile_slowest_examples(profile) + dump_profile_slowest_example_groups(profile) + end + + # @api private + def dump_profile_slowest_examples(profile) + @output_hash[:profile] = {} + sorted_examples = profile.slowest_examples + @output_hash[:profile][:examples] = sorted_examples.map do |example| + format_example(example).tap do |hash| + hash[:run_time] = example.execution_result.run_time + end + end + @output_hash[:profile][:slowest] = profile.slow_duration + @output_hash[:profile][:total] = profile.duration + end + + # @api private + def dump_profile_slowest_example_groups(profile) + @output_hash[:profile] ||= {} + @output_hash[:profile][:groups] = profile.slowest_groups.map do |loc, hash| + hash.update(:location => loc) + end + end + + private + + def format_example(example) + { + :description => example.description, + :full_description => example.full_description, + :status => example.execution_result.status.to_s, + :file_path => example.metadata[:file_path], + :line_number => example.metadata[:line_number], + :run_time => example.execution_result.run_time + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/profile_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/profile_formatter.rb new file mode 100644 index 000000000..af57b44f8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/profile_formatter.rb @@ -0,0 +1,65 @@ +RSpec::Support.require_rspec_core "formatters/console_codes" + +module RSpec + module Core + module Formatters + # @api private + # Formatter for providing profile output + class ProfileFormatter + Formatters.register self, :dump_profile + + def initialize(output) + @output = output + end + + # @private + attr_reader :output + + # @method dump_profile + # @api public + # + # This method is invoked after the dumping the summary if profiling is + # enabled. + # + # @param profile [ProfileNotification] containing duration, slowest_examples + # and slowest_example_groups + def dump_profile(profile) + dump_profile_slowest_examples(profile) + dump_profile_slowest_example_groups(profile) + end + + private + + def dump_profile_slowest_examples(profile) + @output.puts "\nTop #{profile.slowest_examples.size} slowest examples (#{Helpers.format_seconds(profile.slow_duration)} seconds, #{profile.percentage}% of total time):\n" + + profile.slowest_examples.each do |example| + @output.puts " #{example.full_description}" + @output.puts " #{bold(Helpers.format_seconds(example.execution_result.run_time))} #{bold("seconds")} #{format_caller(example.location)}" + end + end + + def dump_profile_slowest_example_groups(profile) + return if profile.slowest_groups.empty? + + @output.puts "\nTop #{profile.slowest_groups.size} slowest example groups:" + profile.slowest_groups.each do |loc, hash| + average = "#{bold(Helpers.format_seconds(hash[:average]))} #{bold("seconds")} average" + total = "#{Helpers.format_seconds(hash[:total_time])} seconds" + count = Helpers.pluralize(hash[:count], "example") + @output.puts " #{hash[:description]}" + @output.puts " #{average} (#{total} / #{count}) #{loc}" + end + end + + def format_caller(caller_info) + RSpec.configuration.backtrace_formatter.backtrace_line(caller_info.to_s.split(':in `block').first) + end + + def bold(text) + ConsoleCodes.wrap(text, :bold) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/progress_formatter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/progress_formatter.rb new file mode 100644 index 000000000..f0978bc65 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/progress_formatter.rb @@ -0,0 +1,28 @@ +RSpec::Support.require_rspec_core "formatters/base_text_formatter" + +module RSpec + module Core + module Formatters + # @private + class ProgressFormatter < BaseTextFormatter + Formatters.register self, :example_passed, :example_pending, :example_failed, :start_dump + + def example_passed(_notification) + output.print ConsoleCodes.wrap('.', :success) + end + + def example_pending(_notification) + output.print ConsoleCodes.wrap('*', :pending) + end + + def example_failed(_notification) + output.print ConsoleCodes.wrap('F', :failure) + end + + def start_dump(_notification) + output.puts + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/protocol.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/protocol.rb new file mode 100644 index 000000000..69ac65dba --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/protocol.rb @@ -0,0 +1,163 @@ +module RSpec + module Core + module Formatters + # This class isn't loaded at runtime but serves to document all of the + # notifications implemented as part of the standard interface. The + # reporter will issue these during a normal test suite run, but a + # formatter will only receive those notifications it has registered + # itself to receive. To register a formatter call: + # + # `::RSpec::Core::Formatters.register class, :list, :of, :notifications` + # + # e.g. + # + # `::RSpec::Core::Formatters.register self, :start, :example_started` + # + # @see RSpec::Core::Formatters::BaseFormatter + # @see RSpec::Core::Formatters::BaseTextFormatter + # @see RSpec::Core::Reporter + class Protocol + # @method initialize + # @api public + # + # @param output [IO] the formatter output + + # @method start + # @api public + # @group Suite Notifications + # + # This method is invoked before any examples are run, right after + # they have all been collected. This can be useful for special + # formatters that need to provide progress on feedback (graphical ones). + # + # This will only be invoked once, and the next one to be invoked + # is {#example_group_started}. + # + # @param notification [StartNotification] + + # @method example_group_started + # @api public + # @group Group Notifications + # + # This method is invoked at the beginning of the execution of each example group. + # + # The next method to be invoked after this is {#example_passed}, + # {#example_pending}, or {#example_group_finished}. + # + # @param notification [GroupNotification] containing example_group subclass of `RSpec::Core::ExampleGroup` + + # @method example_group_finished + # @api public + # @group Group Notifications + # + # Invoked at the end of the execution of each example group. + # + # @param notification [GroupNotification] containing example_group subclass of `RSpec::Core::ExampleGroup` + + # @method example_started + # @api public + # @group Example Notifications + # + # Invoked at the beginning of the execution of each example. + # + # @param notification [ExampleNotification] containing example subclass of `RSpec::Core::Example` + + # @method example_passed + # @api public + # @group Example Notifications + # + # Invoked when an example passes. + # + # @param notification [ExampleNotification] containing example subclass of `RSpec::Core::Example` + + # @method example_pending + # @api public + # @group Example Notifications + # + # Invoked when an example is pending. + # + # @param notification [ExampleNotification] containing example subclass of `RSpec::Core::Example` + + # @method example_failed + # @api public + # @group Example Notifications + # + # Invoked when an example fails. + # + # @param notification [ExampleNotification] containing example subclass of `RSpec::Core::Example` + + # @method message + # @api public + # @group Suite Notifications + # + # Used by the reporter to send messages to the output stream. + # + # @param notification [MessageNotification] containing message + + # @method stop + # @api public + # @group Suite Notifications + # + # Invoked after all examples have executed, before dumping post-run reports. + # + # @param notification [NullNotification] + + # @method start_dump + # @api public + # @group Suite Notifications + # + # This method is invoked after all of the examples have executed. The next method + # to be invoked after this one is {#dump_failures} + # (BaseTextFormatter then calls {#dump_failure} once for each failed example.) + # + # @param notification [NullNotification] + + # @method dump_failures + # @api public + # @group Suite Notifications + # + # Dumps detailed information about each example failure. + # + # @param notification [NullNotification] + + # @method dump_summary + # @api public + # @group Suite Notifications + # + # This method is invoked after the dumping of examples and failures. Each parameter + # is assigned to a corresponding attribute. + # + # @param summary [SummaryNotification] containing duration, example_count, + # failure_count and pending_count + + # @method dump_profile + # @api public + # @group Suite Notifications + # + # This method is invoked after the dumping the summary if profiling is + # enabled. + # + # @param profile [ProfileNotification] containing duration, slowest_examples + # and slowest_example_groups + + # @method dump_pending + # @api public + # @group Suite Notifications + # + # Outputs a report of pending examples. This gets invoked + # after the summary if option is set to do so. + # + # @param notification [NullNotification] + + # @method close + # @api public + # @group Suite Notifications + # + # Invoked at the very end, `close` allows the formatter to clean + # up resources, e.g. open streams, etc. + # + # @param notification [NullNotification] + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/snippet_extractor.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/snippet_extractor.rb new file mode 100644 index 000000000..dea7ccaa5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/formatters/snippet_extractor.rb @@ -0,0 +1,104 @@ +module RSpec + module Core + module Formatters + # @api private + # + # Extracts code snippets by looking at the backtrace of the passed error and applies synax highlighting and line numbers using html. + class SnippetExtractor + # @private + class NullConverter + def convert(code) + %Q(#{code}\n# Install the coderay gem to get syntax highlighting) + end + end + + # @private + class CoderayConverter + def convert(code) + CodeRay.scan(code, :ruby).html(:line_numbers => false) + end + end + + begin + require 'coderay' + # rubocop:disable Style/ClassVars + @@converter = CoderayConverter.new + rescue LoadError + @@converter = NullConverter.new + end + # rubocop:enable Style/ClassVars + + # @api private + # + # Extract lines of code corresponding to a backtrace. + # + # @param backtrace [String] the backtrace from a test failure + # @return [String] highlighted code snippet indicating where the test failure occured + # + # @see #post_process + def snippet(backtrace) + raw_code, line = snippet_for(backtrace[0]) + highlighted = @@converter.convert(raw_code) + post_process(highlighted, line) + end + + # @api private + # + # Create a snippet from a line of code. + # + # @param error_line [String] file name with line number (i.e. 'foo_spec.rb:12') + # @return [String] lines around the target line within the file + # + # @see #lines_around + def snippet_for(error_line) + if error_line =~ /(.*):(\d+)/ + file = Regexp.last_match[1] + line = Regexp.last_match[2].to_i + [lines_around(file, line), line] + else + ["# Couldn't get snippet for #{error_line}", 1] + end + end + + # @api private + # + # Extract lines of code centered around a particular line within a source file. + # + # @param file [String] filename + # @param line [Fixnum] line number + # @return [String] lines around the target line within the file (2 above and 1 below). + def lines_around(file, line) + if File.file?(file) + lines = File.read(file).split("\n") + min = [0, line - 3].max + max = [line + 1, lines.length - 1].min + selected_lines = [] + selected_lines.join("\n") + lines[min..max].join("\n") + else + "# Couldn't get snippet for #{file}" + end + rescue SecurityError + "# Couldn't get snippet for #{file}" + end + + # @api private + # + # Adds line numbers to all lines and highlights the line where the failure occurred using html `span` tags. + # + # @param highlighted [String] syntax-highlighted snippet surrounding the offending line of code + # @param offending_line [Fixnum] line where failure occured + # @return [String] completed snippet + def post_process(highlighted, offending_line) + new_lines = [] + highlighted.split("\n").each_with_index do |line, i| + new_line = "#{offending_line + i - 2}#{line}" + new_line = "#{new_line}" if i == 2 + new_lines << new_line + end + new_lines.join("\n") + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb new file mode 100644 index 000000000..226b24ff4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb @@ -0,0 +1,591 @@ +module RSpec + module Core + # Provides `before`, `after` and `around` hooks as a means of + # supporting common setup and teardown. This module is extended + # onto {ExampleGroup}, making the methods available from any `describe` + # or `context` block and included in {Configuration}, making them + # available off of the configuration object to define global setup + # or teardown logic. + module Hooks + # @api public + # + # @overload before(&block) + # @overload before(scope, &block) + # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`) + # @overload before(scope, conditions, &block) + # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`) + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `before(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # @overload before(conditions, &block) + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `before(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # + # @see #after + # @see #around + # @see ExampleGroup + # @see SharedContext + # @see SharedExampleGroup + # @see Configuration + # + # Declare a block of code to be run before each example (using `:example`) + # or once before any example (using `:context`). These are usually declared + # directly in the {ExampleGroup} to which they apply, but they can also + # be shared across multiple groups. + # + # You can also use `before(:suite)` to run a block of code before any + # example groups are run. This should be declared in {RSpec.configure} + # + # Instance variables declared in `before(:example)` or `before(:context)` are + # accessible within each example. + # + # ### Order + # + # `before` hooks are stored in three scopes, which are run in order: + # `:suite`, `:context`, and `:example`. They can also be declared in several + # different places: `RSpec.configure`, a parent group, the current group. + # They are run in the following order: + # + # before(:suite) # declared in RSpec.configure + # before(:context) # declared in RSpec.configure + # before(:context) # declared in a parent group + # before(:context) # declared in the current group + # before(:example) # declared in RSpec.configure + # before(:example) # declared in a parent group + # before(:example) # declared in the current group + # + # If more than one `before` is declared within any one scope, they are run + # in the order in which they are declared. + # + # ### Conditions + # + # When you add a conditions hash to `before(:example)` or `before(:context)`, + # RSpec will only apply that hook to groups or examples that match the + # conditions. e.g. + # + # RSpec.configure do |config| + # config.before(:example, :authorized => true) do + # log_in_as :authorized_user + # end + # end + # + # describe Something, :authorized => true do + # # the before hook will run in before each example in this group + # end + # + # describe SomethingElse do + # it "does something", :authorized => true do + # # the before hook will run before this example + # end + # + # it "does something else" do + # # the hook will not run before this example + # end + # end + # + # ### Warning: `before(:suite, :with => :conditions)` + # + # The conditions hash is used to match against specific examples. Since + # `before(:suite)` is not run in relation to any specific example or + # group, conditions passed along with `:suite` are effectively ignored. + # + # ### Exceptions + # + # When an exception is raised in a `before` block, RSpec skips any + # subsequent `before` blocks and the example, but runs all of the + # `after(:example)` and `after(:context)` hooks. + # + # ### Warning: implicit before blocks + # + # `before` hooks can also be declared in shared contexts which get + # included implicitly either by you or by extension libraries. Since + # RSpec runs these in the order in which they are declared within each + # scope, load order matters, and can lead to confusing results when one + # before block depends on state that is prepared in another before block + # that gets run later. + # + # ### Warning: `before(:context)` + # + # It is very tempting to use `before(:context)` to speed things up, but we + # recommend that you avoid this as there are a number of gotchas, as well + # as things that simply don't work. + # + # #### context + # + # `before(:context)` is run in an example that is generated to provide group + # context for the block. + # + # #### instance variables + # + # Instance variables declared in `before(:context)` are shared across all the + # examples in the group. This means that each example can change the + # state of a shared object, resulting in an ordering dependency that can + # make it difficult to reason about failures. + # + # #### unsupported rspec constructs + # + # RSpec has several constructs that reset state between each example + # automatically. These are not intended for use from within `before(:context)`: + # + # * `let` declarations + # * `subject` declarations + # * Any mocking, stubbing or test double declaration + # + # ### other frameworks + # + # Mock object frameworks and database transaction managers (like + # ActiveRecord) are typically designed around the idea of setting up + # before an example, running that one example, and then tearing down. + # This means that mocks and stubs can (sometimes) be declared in + # `before(:context)`, but get torn down before the first real example is ever + # run. + # + # You _can_ create database-backed model objects in a `before(:context)` in + # rspec-rails, but it will not be wrapped in a transaction for you, so + # you are on your own to clean up in an `after(:context)` block. + # + # @example before(:example) declared in an {ExampleGroup} + # + # describe Thing do + # before(:example) do + # @thing = Thing.new + # end + # + # it "does something" do + # # here you can access @thing + # end + # end + # + # @example before(:context) declared in an {ExampleGroup} + # + # describe Parser do + # before(:context) do + # File.open(file_to_parse, 'w') do |f| + # f.write <<-CONTENT + # stuff in the file + # CONTENT + # end + # end + # + # it "parses the file" do + # Parser.parse(file_to_parse) + # end + # + # after(:context) do + # File.delete(file_to_parse) + # end + # end + # + # @note The `:example` and `:context` scopes are also available as + # `:each` and `:all`, respectively. Use whichever you prefer. + def before(*args, &block) + hooks.register :append, :before, *args, &block + end + + alias_method :append_before, :before + + # Adds `block` to the front of the list of `before` blocks in the same + # scope (`:example`, `:context`, or `:suite`). + # + # See {#before} for scoping semantics. + def prepend_before(*args, &block) + hooks.register :prepend, :before, *args, &block + end + + # @api public + # @overload after(&block) + # @overload after(scope, &block) + # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`) + # @overload after(scope, conditions, &block) + # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`) + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `after(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # @overload after(conditions, &block) + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `after(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # + # @see #before + # @see #around + # @see ExampleGroup + # @see SharedContext + # @see SharedExampleGroup + # @see Configuration + # + # Declare a block of code to be run after each example (using `:example`) or + # once after all examples n the context (using `:context`). See {#before} for + # more information about ordering. + # + # ### Exceptions + # + # `after` hooks are guaranteed to run even when there are exceptions in + # `before` hooks or examples. When an exception is raised in an after + # block, the exception is captured for later reporting, and subsequent + # `after` blocks are run. + # + # ### Order + # + # `after` hooks are stored in three scopes, which are run in order: + # `:example`, `:context`, and `:suite`. They can also be declared in several + # different places: `RSpec.configure`, a parent group, the current group. + # They are run in the following order: + # + # after(:example) # declared in the current group + # after(:example) # declared in a parent group + # after(:example) # declared in RSpec.configure + # after(:context) # declared in the current group + # after(:context) # declared in a parent group + # after(:context) # declared in RSpec.configure + # after(:suite) # declared in RSpec.configure + # + # This is the reverse of the order in which `before` hooks are run. + # Similarly, if more than one `after` is declared within any one scope, + # they are run in reverse order of that in which they are declared. + # + # @note The `:example` and `:context` scopes are also available as + # `:each` and `:all`, respectively. Use whichever you prefer. + def after(*args, &block) + hooks.register :prepend, :after, *args, &block + end + + alias_method :prepend_after, :after + + # Adds `block` to the back of the list of `after` blocks in the same + # scope (`:example`, `:context`, or `:suite`). + # + # See {#after} for scoping semantics. + def append_after(*args, &block) + hooks.register :append, :after, *args, &block + end + + # @api public + # @overload around(&block) + # @overload around(scope, &block) + # @param scope [Symbol] `:example` (defaults to `:example`) + # present for syntax parity with `before` and `after`, but + # `:example`/`:each` is the only supported value. + # @overload around(scope, conditions, &block) + # @param scope [Symbol] `:example` (defaults to `:example`) + # present for syntax parity with `before` and `after`, but + # `:example`/`:each` is the only supported value. + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `around(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # @overload around(conditions, &block) + # @param conditions [Hash] + # constrains this hook to examples matching these conditions e.g. + # `around(:example, :ui => true) { ... }` will only run with examples or + # groups declared with `:ui => true`. + # + # @yield [Example] the example to run + # + # @note the syntax of `around` is similar to that of `before` and `after` + # but the semantics are quite different. `before` and `after` hooks are + # run in the context of of the examples with which they are associated, + # whereas `around` hooks are actually responsible for running the + # examples. Consequently, `around` hooks do not have direct access to + # resources that are made available within the examples and their + # associated `before` and `after` hooks. + # + # @note `:example`/`:each` is the only supported scope. + # + # Declare a block of code, parts of which will be run before and parts + # after the example. It is your responsibility to run the example: + # + # around(:example) do |ex| + # # do some stuff before + # ex.run + # # do some stuff after + # end + # + # The yielded example aliases `run` with `call`, which lets you treat it + # like a `Proc`. This is especially handy when working with libaries + # that manage their own setup and teardown using a block or proc syntax, + # e.g. + # + # around(:example) {|ex| Database.transaction(&ex)} + # around(:example) {|ex| FakeFS(&ex)} + # + def around(*args, &block) + hooks.register :prepend, :around, *args, &block + end + + # @private + # Holds the various registered hooks. + def hooks + @hooks ||= HookCollections.new( + self, + :around => { :example => AroundHookCollection.new }, + :before => { :example => HookCollection.new, :context => HookCollection.new, :suite => HookCollection.new }, + :after => { :example => HookCollection.new, :context => HookCollection.new, :suite => HookCollection.new } + ) + end + + private + + # @private + class Hook + attr_reader :block, :options + + def initialize(block, options) + @block = block + @options = options + end + + def options_apply?(example_or_group) + example_or_group.all_apply?(options) + end + end + + # @private + class BeforeHook < Hook + def run(example) + example.instance_exec(example, &block) + end + end + + # @private + class AfterHook < Hook + def run(example) + example.instance_exec_with_rescue("in an after hook", &block) + end + end + + # @private + class AfterContextHook < Hook + def run(example) + example.instance_exec(example, &block) + rescue Exception => e + # TODO: come up with a better solution for this. + RSpec.configuration.reporter.message <<-EOS + +An error occurred in an `after(:context)` hook. + #{e.class}: #{e.message} + occurred at #{e.backtrace.first} + +EOS + end + end + + # @private + class AroundHook < Hook + def execute_with(example, procsy) + example.instance_exec(procsy, &block) + return if procsy.executed? + Pending.mark_skipped!(example, "#{hook_description} did not execute the example") + end + + if Proc.method_defined?(:source_location) + def hook_description + "around hook at #{Metadata.relative_path(block.source_location.join(':'))}" + end + else + def hook_description + "around hook" + end + end + end + + # @private + class BaseHookCollection + Array.public_instance_methods(false).each do |name| + define_method(name) { |*a, &b| hooks.__send__(name, *a, &b) } + end + + attr_reader :hooks + protected :hooks + + alias append push + alias prepend unshift + + def initialize(hooks=[]) + @hooks = hooks + end + end + + # @private + class HookCollection < BaseHookCollection + def for(example_or_group) + self.class. + new(hooks.select { |hook| hook.options_apply?(example_or_group) }). + with(example_or_group) + end + + def with(example) + @example = example + self + end + + def run + hooks.each { |h| h.run(@example) } + end + end + + # @private + class AroundHookCollection < BaseHookCollection + def for(example, initial_procsy=nil) + self.class.new(hooks.select { |hook| hook.options_apply?(example) }). + with(example, initial_procsy) + end + + def with(example, initial_procsy) + @example = example + @initial_procsy = initial_procsy + self + end + + def run + hooks.inject(@initial_procsy) do |procsy, around_hook| + procsy.wrap { around_hook.execute_with(@example, procsy) } + end.call + end + end + + # @private + class GroupHookCollection < BaseHookCollection + def for(group) + @group = group + self + end + + def run + hooks.shift.run(@group) until hooks.empty? + end + end + + # @private + class HookCollections + def initialize(owner, data) + @owner = owner + @data = data + end + + def [](key) + @data[key] + end + + def register_globals(host, globals) + process(host, globals, :before, :example) + process(host, globals, :after, :example) + process(host, globals, :around, :example) + + process(host, globals, :before, :context) + process(host, globals, :after, :context) + end + + def around_example_hooks_for(example, initial_procsy=nil) + AroundHookCollection.new(FlatMap.flat_map(@owner.parent_groups) do |a| + a.hooks[:around][:example] + end).for(example, initial_procsy) + end + + def register(prepend_or_append, hook, *args, &block) + scope, options = scope_and_options_from(*args) + self[hook][scope].__send__(prepend_or_append, HOOK_TYPES[hook][scope].new(block, options)) + end + + # @private + # + # Runs all of the blocks stored with the hook in the context of the + # example. If no example is provided, just calls the hook directly. + def run(hook, scope, example_or_group, initial_procsy=nil) + return if RSpec.configuration.dry_run? + find_hook(hook, scope, example_or_group, initial_procsy).run + end + + SCOPES = [:example, :context, :suite] + + SCOPE_ALIASES = { :each => :example, :all => :context } + + HOOK_TYPES = { + :before => Hash.new { BeforeHook }, + :after => Hash.new { AfterHook }, + :around => Hash.new { AroundHook } + } + + HOOK_TYPES[:after][:context] = AfterContextHook + + private + + def process(host, globals, position, scope) + globals[position][scope].each do |hook| + next unless scope == :example || hook.options_apply?(host) + next if host.parent_groups.any? { |a| a.hooks[position][scope].include?(hook) } + self[position][scope] << hook + end + end + + def scope_and_options_from(*args) + scope = extract_scope_from(args) + meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering) + return scope, meta + end + + def extract_scope_from(args) + if known_scope?(args.first) + normalized_scope_for(args.shift) + elsif args.any? { |a| a.is_a?(Symbol) } + error_message = "You must explicitly give a scope (#{SCOPES.join(", ")}) or scope alias (#{SCOPE_ALIASES.keys.join(", ")}) when using symbols as metadata for a hook." + raise ArgumentError.new error_message + else + :example + end + end + + # @api private + def known_scope?(scope) + SCOPES.include?(scope) || SCOPE_ALIASES.keys.include?(scope) + end + + # @api private + def normalized_scope_for(scope) + SCOPE_ALIASES[scope] || scope + end + + def find_hook(hook, scope, example_or_group, initial_procsy) + case [hook, scope] + when [:before, :context] + before_context_hooks_for(example_or_group) + when [:after, :context] + after_context_hooks_for(example_or_group) + when [:around, :example] + around_example_hooks_for(example_or_group, initial_procsy) + when [:before, :example] + before_example_hooks_for(example_or_group) + when [:after, :example] + after_example_hooks_for(example_or_group) + when [:before, :suite], [:after, :suite] + self[hook][:suite].with(example_or_group) + end + end + + def before_context_hooks_for(group) + GroupHookCollection.new(self[:before][:context]).for(group) + end + + def after_context_hooks_for(group) + GroupHookCollection.new(self[:after][:context]).for(group) + end + + def before_example_hooks_for(example) + HookCollection.new(FlatMap.flat_map(@owner.parent_groups.reverse) do |a| + a.hooks[:before][:example] + end).for(example) + end + + def after_example_hooks_for(example) + HookCollection.new(FlatMap.flat_map(@owner.parent_groups) do |a| + a.hooks[:after][:example] + end).for(example) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb new file mode 100644 index 000000000..035f76cce --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb @@ -0,0 +1,472 @@ +module RSpec + module Core + # This module is included in {ExampleGroup}, making the methods + # available to be called from within example blocks. + # + # @see ClassMethods + module MemoizedHelpers + # @note `subject` was contributed by Joe Ferris to support the one-liner + # syntax embraced by shoulda matchers: + # + # describe Widget do + # it { is_expected.to validate_presence_of(:name) } + # # or + # it { should validate_presence_of(:name) } + # end + # + # While the examples below demonstrate how to use `subject` + # explicitly in examples, we recommend that you define a method with + # an intention revealing name instead. + # + # @example + # + # # explicit declaration of subject + # describe Person do + # subject { Person.new(:birthdate => 19.years.ago) } + # it "should be eligible to vote" do + # subject.should be_eligible_to_vote + # # ^ ^ explicit reference to subject not recommended + # end + # end + # + # # implicit subject => { Person.new } + # describe Person do + # it "should be eligible to vote" do + # subject.should be_eligible_to_vote + # # ^ ^ explicit reference to subject not recommended + # end + # end + # + # # one-liner syntax - expectation is set on the subject + # describe Person do + # it { is_expected.to be_eligible_to_vote } + # # or + # it { should be_eligible_to_vote } + # end + # + # @note Because `subject` is designed to create state that is reset between + # each example, and `before(:context)` is designed to setup state that is + # shared across _all_ examples in an example group, `subject` is _not_ + # intended to be used in a `before(:context)` hook. + # + # @see #should + # @see #should_not + # @see #is_expected + def subject + __memoized.fetch(:subject) do + __memoized[:subject] = begin + described = described_class || self.class.metadata.fetch(:description_args).first + Class === described ? described.new : described + end + end + end + + # When `should` is called with no explicit receiver, the call is + # delegated to the object returned by `subject`. Combined with an + # implicit subject this supports very concise expressions. + # + # @example + # + # describe Person do + # it { should be_eligible_to_vote } + # end + # + # @see #subject + # @see #is_expected + # + # @note This only works if you are using rspec-expectations. + # @note If you are using RSpec's newer expect-based syntax you may + # want to use `is_expected.to` instead of `should`. + def should(matcher=nil, message=nil) + RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message) + end + + # Just like `should`, `should_not` delegates to the subject (implicit or + # explicit) of the example group. + # + # @example + # + # describe Person do + # it { should_not be_eligible_to_vote } + # end + # + # @see #subject + # @see #is_expected + # + # @note This only works if you are using rspec-expectations. + # @note If you are using RSpec's newer expect-based syntax you may + # want to use `is_expected.to_not` instead of `should_not`. + def should_not(matcher=nil, message=nil) + RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message) + end + + # Wraps the `subject` in `expect` to make it the target of an expectation. + # Designed to read nicely for one-liners. + # + # @example + # + # describe [1, 2, 3] do + # it { is_expected.to be_an Array } + # it { is_expected.not_to include 4 } + # end + # + # @see #subject + # @see #should + # @see #should_not + # + # @note This only works if you are using rspec-expectations. + def is_expected + expect(subject) + end + + private + + # @private + def __memoized + @__memoized ||= {} + end + + # Used internally to customize the behavior of the + # memoized hash when used in a `before(:context)` hook. + # + # @private + class ContextHookMemoizedHash + def self.isolate_for_context_hook(example_group_instance) + hash = self + + example_group_instance.instance_exec do + @__memoized = hash + + begin + yield + ensure + @__memoized = nil + end + end + end + + def self.fetch(key, &_block) + description = if key == :subject + "subject" + else + "let declaration `#{key}`" + end + + raise <<-EOS +#{description} accessed in #{article} #{hook_expression} hook at: + #{CallerFilter.first_non_rspec_line} + +`let` and `subject` declarations are not intended to be called +in #{article} #{hook_expression} hook, as they exist to define state that +is reset between each example, while #{hook_expression} exists to +#{hook_intention}. +EOS + end + + # @private + class Before < self + def self.hook_expression + "`before(:context)`" + end + + def self.article + "a" + end + + def self.hook_intention + "define state that is shared across examples in an example group" + end + end + + # @private + class After < self + def self.hook_expression + "`after(:context)`" + end + + def self.article + "an" + end + + def self.hook_intention + "cleanup state that is shared across examples in an example group" + end + end + end + + # This module is extended onto {ExampleGroup}, making the methods + # available to be called from within example group blocks. + # You can think of them as being analagous to class macros. + module ClassMethods + # Generates a method whose return value is memoized after the first + # call. Useful for reducing duplication between examples that assign + # values to the same local variable. + # + # @note `let` _can_ enhance readability when used sparingly (1,2, or + # maybe 3 declarations) in any given example group, but that can + # quickly degrade with overuse. YMMV. + # + # @note `let` uses an `||=` conditional that has the potential to + # behave in surprising ways in examples that spawn separate threads, + # though we have yet to see this in practice. You've been warned. + # + # @note Because `let` is designed to create state that is reset between + # each example, and `before(:context)` is designed to setup state that is + # shared across _all_ examples in an example group, `let` is _not_ + # intended to be used in a `before(:context)` hook. + # + # @example + # + # describe Thing do + # let(:thing) { Thing.new } + # + # it "does something" do + # # first invocation, executes block, memoizes and returns result + # thing.do_something + # + # # second invocation, returns the memoized value + # thing.should be_something + # end + # end + def let(name, &block) + # We have to pass the block directly to `define_method` to + # allow it to use method constructs like `super` and `return`. + raise "#let or #subject called without a block" if block.nil? + MemoizedHelpers.module_for(self).__send__(:define_method, name, &block) + + # Apply the memoization. The method has been defined in an ancestor + # module so we can use `super` here to get the value. + if block.arity == 1 + define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(RSpec.current_example, &nil) } } + else + define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(&nil) } } + end + end + + # Just like `let`, except the block is invoked by an implicit `before` + # hook. This serves a dual purpose of setting up state and providing a + # memoized reference to that state. + # + # @example + # + # class Thing + # def self.count + # @count ||= 0 + # end + # + # def self.count=(val) + # @count += val + # end + # + # def self.reset_count + # @count = 0 + # end + # + # def initialize + # self.class.count += 1 + # end + # end + # + # describe Thing do + # after(:example) { Thing.reset_count } + # + # context "using let" do + # let(:thing) { Thing.new } + # + # it "is not invoked implicitly" do + # Thing.count.should eq(0) + # end + # + # it "can be invoked explicitly" do + # thing + # Thing.count.should eq(1) + # end + # end + # + # context "using let!" do + # let!(:thing) { Thing.new } + # + # it "is invoked implicitly" do + # Thing.count.should eq(1) + # end + # + # it "returns memoized version on first invocation" do + # thing + # Thing.count.should eq(1) + # end + # end + # end + def let!(name, &block) + let(name, &block) + before { __send__(name) } + end + + # Declares a `subject` for an example group which can then be wrapped + # with `expect` using `is_expected` to make it the target of an expectation + # in a concise, one-line example. + # + # Given a `name`, defines a method with that name which returns the + # `subject`. This lets you declare the subject once and access it + # implicitly in one-liners and explicitly using an intention revealing + # name. + # + # When given a `name`, calling `super` in the block is not supported. + # + # @param name [String,Symbol] used to define an accessor with an + # intention revealing name + # @param block defines the value to be returned by `subject` in examples + # + # @example + # + # describe CheckingAccount, "with $50" do + # subject { CheckingAccount.new(Money.new(50, :USD)) } + # it { is_expected.to have_a_balance_of(Money.new(50, :USD)) } + # it { is_expected.not_to be_overdrawn } + # end + # + # describe CheckingAccount, "with a non-zero starting balance" do + # subject(:account) { CheckingAccount.new(Money.new(50, :USD)) } + # it { is_expected.not_to be_overdrawn } + # it "has a balance equal to the starting balance" do + # account.balance.should eq(Money.new(50, :USD)) + # end + # end + # + # @see MemoizedHelpers#should + # @see MemoizedHelpers#should_not + # @see MemoizedHelpers#is_expected + def subject(name=nil, &block) + if name + let(name, &block) + alias_method :subject, name + + self::NamedSubjectPreventSuper.__send__(:define_method, name) do + raise NotImplementedError, "`super` in named subjects is not supported" + end + else + let(:subject, &block) + end + end + + # Just like `subject`, except the block is invoked by an implicit `before` + # hook. This serves a dual purpose of setting up state and providing a + # memoized reference to that state. + # + # @example + # + # class Thing + # def self.count + # @count ||= 0 + # end + # + # def self.count=(val) + # @count += val + # end + # + # def self.reset_count + # @count = 0 + # end + # + # def initialize + # self.class.count += 1 + # end + # end + # + # describe Thing do + # after(:example) { Thing.reset_count } + # + # context "using subject" do + # subject { Thing.new } + # + # it "is not invoked implicitly" do + # Thing.count.should eq(0) + # end + # + # it "can be invoked explicitly" do + # subject + # Thing.count.should eq(1) + # end + # end + # + # context "using subject!" do + # subject!(:thing) { Thing.new } + # + # it "is invoked implicitly" do + # Thing.count.should eq(1) + # end + # + # it "returns memoized version on first invocation" do + # subject + # Thing.count.should eq(1) + # end + # end + # end + def subject!(name=nil, &block) + subject(name, &block) + before { subject } + end + end + + # @private + # + # Gets the LetDefinitions module. The module is mixed into + # the example group and is used to hold all let definitions. + # This is done so that the block passed to `let` can be + # forwarded directly on to `define_method`, so that all method + # constructs (including `super` and `return`) can be used in + # a `let` block. + # + # The memoization is provided by a method definition on the + # example group that supers to the LetDefinitions definition + # in order to get the value to memoize. + def self.module_for(example_group) + get_constant_or_yield(example_group, :LetDefinitions) do + mod = Module.new do + include Module.new { + example_group.const_set(:NamedSubjectPreventSuper, self) + } + end + + example_group.const_set(:LetDefinitions, mod) + mod + end + end + + # @private + def self.define_helpers_on(example_group) + example_group.__send__(:include, module_for(example_group)) + end + + if Module.method(:const_defined?).arity == 1 # for 1.8 + # @private + # + # Gets the named constant or yields. + # On 1.8, const_defined? / const_get do not take into + # account the inheritance hierarchy. + def self.get_constant_or_yield(example_group, name) + if example_group.const_defined?(name) + example_group.const_get(name) + else + yield + end + end + else + # @private + # + # Gets the named constant or yields. + # On 1.9, const_defined? / const_get take into account the + # the inheritance by default, and accept an argument to + # disable this behavior. It's important that we don't + # consider inheritance here; each example group level that + # uses a `let` should get its own `LetDefinitions` module. + def self.get_constant_or_yield(example_group, name) + if example_group.const_defined?(name, (check_ancestors = false)) + example_group.const_get(name, check_ancestors) + else + yield + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata.rb new file mode 100644 index 000000000..82025e7d9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata.rb @@ -0,0 +1,437 @@ +module RSpec + module Core + # Each ExampleGroup class and Example instance owns an instance of + # Metadata, which is Hash extended to support lazy evaluation of values + # associated with keys that may or may not be used by any example or group. + # + # In addition to metadata that is used internally, this also stores + # user-supplied metadata, e.g. + # + # describe Something, :type => :ui do + # it "does something", :slow => true do + # # ... + # end + # end + # + # `:type => :ui` is stored in the Metadata owned by the example group, and + # `:slow => true` is stored in the Metadata owned by the example. These can + # then be used to select which examples are run using the `--tag` option on + # the command line, or several methods on `Configuration` used to filter a + # run (e.g. `filter_run_including`, `filter_run_excluding`, etc). + # + # @see Example#metadata + # @see ExampleGroup.metadata + # @see FilterManager + # @see Configuration#filter_run_including + # @see Configuration#filter_run_excluding + module Metadata + # @api private + # + # @param line [String] current code line + # @return [String] relative path to line + def self.relative_path(line) + # Matches strings either at the beginning of the input or prefixed with a whitespace, + # containing the current path, either postfixed with the separator, or at the end of the string. + # Match groups are the character before and the character after the string if any. + # + # http://rubular.com/r/fT0gmX6VJX + # http://rubular.com/r/duOrD4i3wb + # http://rubular.com/r/sbAMHFrOx1 + # + + regex = /(\A|\s)#{File.expand_path('.')}(#{File::SEPARATOR}|\s|\Z)/ + + line = line.sub(regex, "\\1.\\2") + line = line.sub(/\A([^:]+:\d+)$/, '\\1') + return nil if line == '-e:1' + line + rescue SecurityError + nil + end + + # @private + # Used internally to build a hash from an args array. + # Symbols are converted into hash keys with a value of `true`. + # This is done to support simple tagging using a symbol, rather + # than needing to do `:symbol => true`. + def self.build_hash_from(args, warn_about_example_group_filtering=false) + hash = args.last.is_a?(Hash) ? args.pop : {} + + hash[args.pop] = true while args.last.is_a?(Symbol) + + if warn_about_example_group_filtering && hash.key?(:example_group) + RSpec.deprecate("Filtering by an `:example_group` subhash", + :replacement => "the subhash to filter directly") + end + + hash + end + + # @private + def self.backtrace_from(block) + return caller unless block.respond_to?(:source_location) + [block.source_location.join(':')] + end + + # @private + # Used internally to populate metadata hashes with computed keys + # managed by RSpec. + class HashPopulator + attr_reader :metadata, :user_metadata, :description_args, :block + + def initialize(metadata, user_metadata, description_args, block) + @metadata = metadata + @user_metadata = user_metadata + @description_args = description_args + @block = block + end + + def populate + ensure_valid_user_keys + + metadata[:execution_result] = Example::ExecutionResult.new + metadata[:block] = block + metadata[:description_args] = description_args + metadata[:description] = build_description_from(*metadata[:description_args]) + metadata[:full_description] = full_description + metadata[:described_class] = described_class + + populate_location_attributes + metadata.update(user_metadata) + RSpec.configuration.apply_derived_metadata_to(metadata) + end + + private + + def populate_location_attributes + backtrace = user_metadata.delete(:caller) + + file_path, line_number = if backtrace + file_path_and_line_number_from(backtrace) + elsif block.respond_to?(:source_location) + block.source_location + else + file_path_and_line_number_from(caller) + end + + file_path = Metadata.relative_path(file_path) + metadata[:file_path] = file_path + metadata[:line_number] = line_number.to_i + metadata[:location] = "#{file_path}:#{line_number}" + end + + def file_path_and_line_number_from(backtrace) + first_caller_from_outside_rspec = backtrace.find { |l| l !~ CallerFilter::LIB_REGEX } + first_caller_from_outside_rspec ||= backtrace.first + /(.+?):(\d+)(?:|:\d+)/.match(first_caller_from_outside_rspec).captures + end + + def description_separator(parent_part, child_part) + if parent_part.is_a?(Module) && child_part =~ /^(#|::|\.)/ + '' + else + ' ' + end + end + + def build_description_from(parent_description=nil, my_description=nil) + return parent_description.to_s unless my_description + separator = description_separator(parent_description, my_description) + parent_description.to_s + separator + my_description.to_s + end + + def ensure_valid_user_keys + RESERVED_KEYS.each do |key| + next unless user_metadata.key?(key) + raise <<-EOM.gsub(/^\s+\|/, '') + |#{"*" * 50} + |:#{key} is not allowed + | + |RSpec reserves some hash keys for its own internal use, + |including :#{key}, which is used on: + | + | #{CallerFilter.first_non_rspec_line}. + | + |Here are all of RSpec's reserved hash keys: + | + | #{RESERVED_KEYS.join("\n ")} + |#{"*" * 50} + EOM + end + end + end + + # @private + class ExampleHash < HashPopulator + def self.create(group_metadata, user_metadata, description, block) + example_metadata = group_metadata.dup + group_metadata = Hash.new(&ExampleGroupHash.backwards_compatibility_default_proc do |hash| + hash[:parent_example_group] + end) + group_metadata.update(example_metadata) + + example_metadata[:example_group] = group_metadata + example_metadata.delete(:parent_example_group) + + hash = new(example_metadata, user_metadata, [description].compact, block) + hash.populate + hash.metadata + end + + private + + def described_class + metadata[:example_group][:described_class] + end + + def full_description + build_description_from( + metadata[:example_group][:full_description], + metadata[:description] + ) + end + end + + # @private + class ExampleGroupHash < HashPopulator + def self.create(parent_group_metadata, user_metadata, *args, &block) + group_metadata = hash_with_backwards_compatibility_default_proc + + if parent_group_metadata + group_metadata.update(parent_group_metadata) + group_metadata[:parent_example_group] = parent_group_metadata + end + + hash = new(group_metadata, user_metadata, args, block) + hash.populate + hash.metadata + end + + def self.hash_with_backwards_compatibility_default_proc + Hash.new(&backwards_compatibility_default_proc { |hash| hash }) + end + + def self.backwards_compatibility_default_proc(&example_group_selector) + Proc.new do |hash, key| + case key + when :example_group + # We commonly get here when rspec-core is applying a previously configured + # filter rule, such as when a gem configures: + # + # RSpec.configure do |c| + # c.include MyGemHelpers, :example_group => { :file_path => /spec\/my_gem_specs/ } + # end + # + # It's confusing for a user to get a deprecation at this point in the code, so instead + # we issue a deprecation from the config APIs that take a metadata hash, and MetadataFilter + # sets this thread local to silence the warning here since it would be so confusing. + unless RSpec.thread_local_metadata[:silence_metadata_example_group_deprecations] + RSpec.deprecate("The `:example_group` key in an example group's metadata hash", + :replacement => "the example group's hash directly for the " \ + "computed keys and `:parent_example_group` to access the parent " \ + "example group metadata") + end + + group_hash = example_group_selector.call(hash) + LegacyExampleGroupHash.new(group_hash) if group_hash + when :example_group_block + RSpec.deprecate("`metadata[:example_group_block]`", + :replacement => "`metadata[:block]`") + hash[:block] + when :describes + RSpec.deprecate("`metadata[:describes]`", + :replacement => "`metadata[:described_class]`") + hash[:described_class] + end + end + end + + private + + def described_class + candidate = metadata[:description_args].first + return candidate unless NilClass === candidate || String === candidate + parent_group = metadata[:parent_example_group] + parent_group && parent_group[:described_class] + end + + def full_description + description = metadata[:description] + parent_example_group = metadata[:parent_example_group] + return description unless parent_example_group + + parent_description = parent_example_group[:full_description] + separator = description_separator(parent_example_group[:description_args].last, + metadata[:description_args].first) + + parent_description + separator + description + end + end + + # @private + RESERVED_KEYS = [ + :description, + :example_group, + :parent_example_group, + :execution_result, + :file_path, + :full_description, + :line_number, + :location, + :block + ] + end + + # Mixin that makes the including class imitate a hash for backwards + # compatibility. The including class should use `attr_accessor` to + # declare attributes. + # @private + module HashImitatable + def self.included(klass) + klass.extend ClassMethods + end + + def to_h + hash = extra_hash_attributes.dup + + self.class.hash_attribute_names.each do |name| + hash[name] = __send__(name) + end + + hash + end + + (Hash.public_instance_methods - Object.public_instance_methods).each do |method_name| + next if [:[], :[]=, :to_h].include?(method_name.to_sym) + + define_method(method_name) do |*args, &block| + issue_deprecation(method_name, *args) + + hash = hash_for_delegation + self.class.hash_attribute_names.each do |name| + hash.delete(name) unless instance_variable_defined?(:"@#{name}") + end + + hash.__send__(method_name, *args, &block).tap do + # apply mutations back to the object + hash.each do |name, value| + if directly_supports_attribute?(name) + set_value(name, value) + else + extra_hash_attributes[name] = value + end + end + end + end + end + + def [](key) + issue_deprecation(:[], key) + + if directly_supports_attribute?(key) + get_value(key) + else + extra_hash_attributes[key] + end + end + + def []=(key, value) + issue_deprecation(:[]=, key, value) + + if directly_supports_attribute?(key) + set_value(key, value) + else + extra_hash_attributes[key] = value + end + end + + private + + def extra_hash_attributes + @extra_hash_attributes ||= {} + end + + def directly_supports_attribute?(name) + self.class.hash_attribute_names.include?(name) + end + + def get_value(name) + __send__(name) + end + + def set_value(name, value) + __send__(:"#{name}=", value) + end + + def hash_for_delegation + to_h + end + + def issue_deprecation(_method_name, *_args) + # no-op by default: subclasses can override + end + + # @private + module ClassMethods + def hash_attribute_names + @hash_attribute_names ||= [] + end + + def attr_accessor(*names) + hash_attribute_names.concat(names) + super + end + end + end + + # @private + # Together with the example group metadata hash default block, + # provides backwards compatibility for the old `:example_group` + # key. In RSpec 2.x, the computed keys of a group's metadata + # were exposed from a nested subhash keyed by `[:example_group]`, and + # then the parent group's metadata was exposed by sub-subhash + # keyed by `[:example_group][:example_group]`. + # + # In RSpec 3, we reorganized this to that the computed keys are + # exposed directly of the group metadata hash (no nesting), and + # `:parent_example_group` returns the parent group's metadata. + # + # Maintaining backwards compatibility was difficult: we wanted + # `:example_group` to return an object that: + # + # * Exposes the top-level metadata keys that used to be nested + # under `:example_group`. + # * Supports mutation (rspec-rails, for example, assigns + # `metadata[:example_group][:described_class]` when you use + # anonymous controller specs) such that changes are written + # back to the top-level metadata hash. + # * Exposes the parent group metadata as `[:example_group][:example_group]`. + class LegacyExampleGroupHash + include HashImitatable + + def initialize(metadata) + @metadata = metadata + parent_group_metadata = metadata.fetch(:parent_example_group) { {} }[:example_group] + self[:example_group] = parent_group_metadata if parent_group_metadata + end + + def to_h + super.merge(@metadata) + end + + private + + def directly_supports_attribute?(name) + name != :example_group + end + + def get_value(name) + @metadata[name] + end + + def set_value(name, value) + @metadata[name] = value + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata_filter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata_filter.rb new file mode 100644 index 000000000..7c8cac6e3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/metadata_filter.rb @@ -0,0 +1,95 @@ +module RSpec + module Core + # Contains metadata filtering logic. This has been extracted from + # the metadata classes because it operates ON a metadata hash but + # does not manage any of the state in the hash. We're moving towards + # having metadata be a raw hash (not a custom subclass), so externalizing + # this filtering logic helps us move in that direction. + module MetadataFilter + class << self + # @private + def any_apply?(filters, metadata) + filters.any? { |k, v| filter_applies?(k, v, metadata) } + end + + # @private + def all_apply?(filters, metadata) + filters.all? { |k, v| filter_applies?(k, v, metadata) } + end + + # @private + def filter_applies?(key, value, metadata) + silence_metadata_example_group_deprecations do + return filter_applies_to_any_value?(key, value, metadata) if Array === metadata[key] && !(Proc === value) + return location_filter_applies?(value, metadata) if key == :locations + return filters_apply?(key, value, metadata) if Hash === value + + return false unless metadata.key?(key) + + case value + when Regexp + metadata[key] =~ value + when Proc + case value.arity + when 0 then value.call + when 2 then value.call(metadata[key], metadata) + else value.call(metadata[key]) + end + else + metadata[key].to_s == value.to_s + end + end + end + + private + + def filter_applies_to_any_value?(key, value, metadata) + metadata[key].any? { |v| filter_applies?(key, v, key => value) } + end + + def location_filter_applies?(locations, metadata) + # it ignores location filters for other files + line_number = example_group_declaration_line(locations, metadata) + line_number ? line_number_filter_applies?(line_number, metadata) : true + end + + def line_number_filter_applies?(line_numbers, metadata) + preceding_declaration_lines = line_numbers.map { |n| RSpec.world.preceding_declaration_line(n) } + !(relevant_line_numbers(metadata) & preceding_declaration_lines).empty? + end + + def relevant_line_numbers(metadata) + return [] unless metadata + [metadata[:line_number]].compact + (relevant_line_numbers(parent_of metadata)) + end + + def example_group_declaration_line(locations, metadata) + parent = parent_of(metadata) + return nil unless parent + locations[File.expand_path(parent[:file_path])] + end + + def filters_apply?(key, value, metadata) + subhash = metadata[key] + return false unless Hash === subhash || HashImitatable === subhash + value.all? { |k, v| filter_applies?(k, v, subhash) } + end + + def parent_of(metadata) + if metadata.key?(:example_group) + metadata[:example_group] + else + metadata[:parent_example_group] + end + end + + def silence_metadata_example_group_deprecations + RSpec.thread_local_metadata[:silence_metadata_example_group_deprecations] = true + yield + ensure + RSpec.thread_local_metadata.delete(:silence_metadata_example_group_deprecations) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/minitest_assertions_adapter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/minitest_assertions_adapter.rb new file mode 100644 index 000000000..3509f6d35 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/minitest_assertions_adapter.rb @@ -0,0 +1,28 @@ +begin + # Only the minitest 5.x gem includes the minitest.rb and assertions.rb files + require 'minitest' + require 'minitest/assertions' +rescue LoadError + # We must be using Ruby Core's MiniTest or the Minitest gem 4.x + require 'minitest/unit' + Minitest = MiniTest +end + +module RSpec + module Core + # @private + module MinitestAssertionsAdapter + include ::Minitest::Assertions + + # Minitest 5.x requires this accessor to be available. See + # https://github.com/seattlerb/minitest/blob/38f0a5fcbd9c37c3f80a3eaad4ba84d3fc9947a0/lib/minitest/assertions.rb#L8 + # + # It is not required for other extension libraries, and RSpec does not + # report or make this information available to formatters. + attr_writer :assertions + def assertions + @assertions ||= 0 + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/flexmock.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/flexmock.rb new file mode 100644 index 000000000..1202f866d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/flexmock.rb @@ -0,0 +1,31 @@ +# Created by Jim Weirich on 2007-04-10. +# Copyright (c) 2007. All rights reserved. + +require 'flexmock/rspec' + +module RSpec + module Core + module MockingAdapters + # @private + module Flexmock + include ::FlexMock::MockContainer + + def self.framework_name + :flexmock + end + + def setup_mocks_for_rspec + # No setup required + end + + def verify_mocks_for_rspec + flexmock_verify + end + + def teardown_mocks_for_rspec + flexmock_close + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/mocha.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/mocha.rb new file mode 100644 index 000000000..f2e56753d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/mocha.rb @@ -0,0 +1,57 @@ +# In order to support all versions of mocha, we have to jump through some +# hoops here. +# +# mocha >= '0.13.0': +# require 'mocha/api' is required +# require 'mocha/object' raises a LoadError b/c the file no longer exists +# mocha < '0.13.0', >= '0.9.7' +# require 'mocha/api' is required +# require 'mocha/object' is required +# mocha < '0.9.7': +# require 'mocha/api' raises a LoadError b/c the file does not yet exist +# require 'mocha/standalone' is required +# require 'mocha/object' is required +begin + require 'mocha/api' + + begin + require 'mocha/object' + rescue LoadError + # Mocha >= 0.13.0 no longer contains this file nor needs it to be loaded + end +rescue LoadError + require 'mocha/standalone' + require 'mocha/object' +end + +module RSpec + module Core + module MockingAdapters + # @private + module Mocha + def self.framework_name + :mocha + end + + # Mocha::Standalone was deprecated as of Mocha 0.9.7. + begin + include ::Mocha::API + rescue NameError + include ::Mocha::Standalone + end + + def setup_mocks_for_rspec + mocha_setup + end + + def verify_mocks_for_rspec + mocha_verify + end + + def teardown_mocks_for_rspec + mocha_teardown + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/null.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/null.rb new file mode 100644 index 000000000..442de9a70 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/null.rb @@ -0,0 +1,14 @@ +module RSpec + module Core + module MockingAdapters + # @private + module Null + def setup_mocks_for_rspec; end + + def verify_mocks_for_rspec; end + + def teardown_mocks_for_rspec; end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rr.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rr.rb new file mode 100644 index 000000000..d72651a62 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rr.rb @@ -0,0 +1,31 @@ +require 'rr' + +RSpec.configuration.backtrace_exclusion_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER) + +module RSpec + module Core + # @private + module MockingAdapters + # @private + module RR + def self.framework_name + :rr + end + + include ::RR::Extensions::InstanceMethods + + def setup_mocks_for_rspec + ::RR::Space.instance.reset + end + + def verify_mocks_for_rspec + ::RR::Space.instance.verify_doubles + end + + def teardown_mocks_for_rspec + ::RR::Space.instance.reset + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rspec.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rspec.rb new file mode 100644 index 000000000..bb3f0ae66 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/mocking_adapters/rspec.rb @@ -0,0 +1,32 @@ +require 'rspec/mocks' + +module RSpec + module Core + module MockingAdapters + # @private + module RSpec + include ::RSpec::Mocks::ExampleMethods + + def self.framework_name + :rspec + end + + def self.configuration + ::RSpec::Mocks.configuration + end + + def setup_mocks_for_rspec + ::RSpec::Mocks.setup + end + + def verify_mocks_for_rspec + ::RSpec::Mocks.verify + end + + def teardown_mocks_for_rspec + ::RSpec::Mocks.teardown + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/notifications.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/notifications.rb new file mode 100644 index 000000000..c98455591 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/notifications.rb @@ -0,0 +1,542 @@ +RSpec::Support.require_rspec_core "formatters/helpers" +RSpec::Support.require_rspec_support "encoded_string" + +module RSpec::Core + # Notifications are value objects passed to formatters to provide them + # with information about a particular event of interest. + module Notifications + # @private + module NullColorizer + module_function + def wrap(line, _code_or_symbol) + line + end + end + + # The `StartNotification` represents a notification sent by the reporter + # when the suite is started. It contains the expected amount of examples + # to be executed, and the load time of RSpec. + # + # @attr count [Fixnum] the number counted + # @attr load_time [Float] the number of seconds taken to boot RSpec + # and load the spec files + StartNotification = Struct.new(:count, :load_time) + + # The `ExampleNotification` represents notifications sent by the reporter + # which contain information about the current (or soon to be) example. + # It is used by formatters to access information about that example. + # + # @example + # def example_started(notification) + # puts "Hey I started #{notification.example.description}" + # end + # + # @attr example [RSpec::Core::Example] the current example + ExampleNotification = Struct.new(:example) do + # @private + def self.for(example) + if example.execution_result.pending_fixed? + PendingExampleFixedNotification.new(example) + elsif example.execution_result.status == :failed + FailedExampleNotification.new(example) + else + new(example) + end + end + private_class_method :new + end + + # The `ExamplesNotification` represents notifications sent by the reporter + # which contain information about the suites examples. + # + # @example + # def stop(notification) + # puts "Hey I ran #{notification.examples.size}" + # end + # + class ExamplesNotification + def initialize(reporter) + @reporter = reporter + end + + # @return [Array(RSpec::Core::Example)] list of examples + def examples + @reporter.examples + end + + # @return [Array(RSpec::Core::Example)] list of failed examples + def failed_examples + @reporter.failed_examples + end + + # @return [Array(RSpec::Core::Example)] list of pending examples + def pending_examples + @reporter.pending_examples + end + + # @return [Array(Rspec::Core::Notifications::ExampleNotification] + # returns examples as notifications + def notifications + @notifications ||= format_examples(examples) + end + + # @return [Array(Rspec::Core::Notifications::FailedExampleNotification] + # returns failed examples as notifications + def failure_notifications + @failed_notifications ||= format_examples(failed_examples) + end + + # @return [String] The list of failed examples, fully formatted in the way that + # RSpec's built-in formatters emit. + def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + formatted = "\nFailures:\n" + + failure_notifications.each_with_index do |failure, index| + formatted << failure.fully_formatted(index.next, colorizer) + end + + formatted + end + + # @return [String] The list of pending examples, fully formatted in the way that + # RSpec's built-in formatters emit. + def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + formatted = "\nPending:\n" + + pending_examples.each do |example| + formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location) + + formatted << + " #{colorizer.wrap(example.full_description, :pending)}\n" \ + " # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" \ + " # #{colorizer.wrap(formatted_caller, :detail)}\n" + end + + formatted + end + + private + + def format_examples(examples) + examples.map do |example| + ExampleNotification.for(example) + end + end + end + + # The `FailedExampleNotification` extends `ExampleNotification` with + # things useful for failed specs. + # + # @example + # def example_failed(notification) + # puts "Hey I failed :(" + # puts "Here's my stack trace" + # puts notification.exception.backtrace.join("\n") + # end + # + # @attr [RSpec::Core::Example] example the current example + # @see ExampleNotification + class FailedExampleNotification < ExampleNotification + public_class_method :new + + # @return [Exception] The example failure + def exception + example.execution_result.exception + end + + # @return [String] The example description + def description + example.full_description + end + + # Returns the message generated for this failure line by line. + # + # @return [Array(String)] The example failure message + def message_lines + add_shared_group_line(failure_lines, NullColorizer) + end + + # Returns the message generated for this failure colorized line by line. + # + # @param colorizer [#wrap] An object to colorize the message_lines by + # @return [Array(String)] The example failure message colorized + def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + add_shared_group_line(failure_lines, colorizer).map do |line| + colorizer.wrap line, RSpec.configuration.failure_color + end + end + + # Returns the failures formatted backtrace. + # + # @return [Array(String)] the examples backtrace lines + def formatted_backtrace + backtrace_formatter.format_backtrace(exception.backtrace, example.metadata) + end + + # Returns the failures colorized formatted backtrace. + # + # @param colorizer [#wrap] An object to colorize the message_lines by + # @return [Array(String)] the examples colorized backtrace lines + def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + formatted_backtrace.map do |backtrace_info| + colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color + end + end + + # @return [String] The failure information fully formatted in the way that + # RSpec's built-in formatters emit. + def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) + formatted = "\n #{failure_number}) #{description}\n" + + colorized_message_lines(colorizer).each do |line| + formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted)) + end + + colorized_formatted_backtrace(colorizer).each do |line| + formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted)) + end + + formatted + end + + private + + if String.method_defined?(:encoding) + def encoding_of(string) + string.encoding + end + else + def encoding_of(_string) + end + end + + def backtrace_formatter + RSpec.configuration.backtrace_formatter + end + + def exception_class_name + name = exception.class.name.to_s + name = "(anonymous error class)" if name == '' + name + end + + def failure_lines + @failure_lines ||= + begin + lines = ["Failure/Error: #{read_failed_line.strip}"] + lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/ + exception.message.to_s.split("\n").each do |line| + lines << " #{line}" if exception.message + end + lines + end + end + + def add_shared_group_line(lines, colorizer) + unless shared_group_line == "" + lines << colorizer.wrap(shared_group_line, RSpec.configuration.default_color) + end + lines + end + + def shared_group + @shared_group ||= group_and_parent_groups.find { |group| group.metadata[:shared_group_name] } + end + + def shared_group_line + @shared_group_line ||= + if shared_group + "Shared Example Group: \"#{shared_group.metadata[:shared_group_name]}\"" \ + " called from #{backtrace_formatter.backtrace_line(shared_group.location)}" + else + "" + end + end + + def group_and_parent_groups + example.example_group.parent_groups + [example.example_group] + end + + def read_failed_line + matching_line = find_failed_line + unless matching_line + return "Unable to find matching line from backtrace" + end + + file_path, line_number = matching_line.match(/(.+?):(\d+)(|:\d+)/)[1..2] + + if File.exist?(file_path) + File.readlines(file_path)[line_number.to_i - 1] || + "Unable to find matching line in #{file_path}" + else + "Unable to find #{file_path} to read failed line" + end + rescue SecurityError + "Unable to read failed line" + end + + def find_failed_line + path = File.expand_path(example.file_path) + exception.backtrace.find do |line| + match = line.match(/(.+?):(\d+)(|:\d+)/) + match && match[1].downcase == path.downcase + end + end + end + + # The `PendingExampleFixedNotification` extends `ExampleNotification` with + # things useful for specs that pass when they are expected to fail. + # + # @attr [RSpec::Core::Example] example the current example + # @see ExampleNotification + class PendingExampleFixedNotification < FailedExampleNotification + public_class_method :new + + # Returns the examples description + # + # @return [String] The example description + def description + "#{example.full_description} FIXED" + end + + # Returns the message generated for this failure line by line. + # + # @return [Array(String)] The example failure message + def message_lines + ["Expected pending '#{example.execution_result.pending_message}' to fail. No Error was raised."] + end + + # Returns the message generated for this failure colorized line by line. + # + # @param colorizer [#wrap] An object to colorize the message_lines by + # @return [Array(String)] The example failure message colorized + def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + message_lines.map { |line| colorizer.wrap(line, RSpec.configuration.fixed_color) } + end + end + + # The `GroupNotification` represents notifications sent by the reporter which + # contain information about the currently running (or soon to be) example group + # It is used by formatters to access information about that group. + # + # @example + # def example_group_started(notification) + # puts "Hey I started #{notification.group.description}" + # end + # @attr group [RSpec::Core::ExampleGroup] the current group + GroupNotification = Struct.new(:group) + + # The `MessageNotification` encapsulates generic messages that the reporter + # sends to formatters. + # + # @attr message [String] the message + MessageNotification = Struct.new(:message) + + # The `SeedNotification` holds the seed used to randomize examples and + # wether that seed has been used or not. + # + # @attr seed [Fixnum] the seed used to randomize ordering + # @attr used [Boolean] wether the seed has been used or not + SeedNotification = Struct.new(:seed, :used) do + # @api + # @return [Boolean] has the seed been used? + def seed_used? + !!used + end + private :used + + # @return [String] The seed information fully formatted in the way that + # RSpec's built-in formatters emit. + def fully_formatted + "\nRandomized with seed #{seed}\n\n" + end + end + + # The `SummaryNotification` holds information about the results of running + # a test suite. It is used by formatters to provide information at the end + # of the test run. + # + # @attr duration [Float] the time taken (in seconds) to run the suite + # @attr examples [Array(RSpec::Core::Example)] the examples run + # @attr failed_examples [Array(RSpec::Core::Example)] the failed examples + # @attr pending_examples [Array(RSpec::Core::Example)] the pending examples + # @attr load_time [Float] the number of seconds taken to boot RSpec + # and load the spec files + SummaryNotification = Struct.new(:duration, :examples, :failed_examples, :pending_examples, :load_time) do + + # @api + # @return [Fixnum] the number of examples run + def example_count + @example_count ||= examples.size + end + + # @api + # @return [Fixnum] the number of failed examples + def failure_count + @failure_count ||= failed_examples.size + end + + # @api + # @return [Fixnum] the number of pending examples + def pending_count + @pending_count ||= pending_examples.size + end + + # @api + # @return [String] A line summarising the result totals of the spec run. + def totals_line + summary = Formatters::Helpers.pluralize(example_count, "example") + summary << ", " << Formatters::Helpers.pluralize(failure_count, "failure") + summary << ", #{pending_count} pending" if pending_count > 0 + summary + end + + # @api public + # + # Wraps the results line with colors based on the configured + # colors for failure, pending, and success. Defaults to red, + # yellow, green accordingly. + # + # @param colorizer [#wrap] An object which supports wrapping text with + # specific colors. + # @return [String] A colorized results line. + def colorized_totals_line(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + if failure_count > 0 + colorizer.wrap(totals_line, RSpec.configuration.failure_color) + elsif pending_count > 0 + colorizer.wrap(totals_line, RSpec.configuration.pending_color) + else + colorizer.wrap(totals_line, RSpec.configuration.success_color) + end + end + + # @api public + # + # Formats failures into a rerunable command format. + # + # @param colorizer [#wrap] An object which supports wrapping text with + # specific colors. + # @return [String] A colorized summary line. + def colorized_rerun_commands(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + "\nFailed examples:\n\n" + + failed_examples.map do |example| + colorizer.wrap("rspec #{example.location}", RSpec.configuration.failure_color) + " " + + colorizer.wrap("# #{example.full_description}", RSpec.configuration.detail_color) + end.join("\n") + end + + # @return [String] a formatted version of the time it took to run the suite + def formatted_duration + Formatters::Helpers.format_duration(duration) + end + + # @return [String] a formatted version of the time it took to boot RSpec and + # load the spec files + def formatted_load_time + Formatters::Helpers.format_duration(load_time) + end + + # @return [String] The summary information fully formatted in the way that + # RSpec's built-in formatters emit. + def fully_formatted(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + formatted = "\nFinished in #{formatted_duration} " \ + "(files took #{formatted_load_time} to load)\n" \ + "#{colorized_totals_line(colorizer)}\n" + + unless failed_examples.empty? + formatted << colorized_rerun_commands(colorizer) << "\n" + end + + formatted + end + end + + # The `ProfileNotification` holds information about the results of running + # a test suite when profiling is enabled. It is used by formatters to provide + # information at the end of the test run for profiling information. + # + # @attr duration [Float] the time taken (in seconds) to run the suite + # @attr examples [Array(RSpec::Core::Example)] the examples run + # @attr number_of_examples [Fixnum] the number of examples to profile + ProfileNotification = Struct.new(:duration, :examples, :number_of_examples) do + + # @return [Array(RSpec::Core::Example)] the slowest examples + def slowest_examples + @slowest_examples ||= + examples.sort_by do |example| + -example.execution_result.run_time + end.first(number_of_examples) + end + + # @return [Float] the time taken (in seconds) to run the slowest examples + def slow_duration + @slow_duration ||= + slowest_examples.inject(0.0) do |i, e| + i + e.execution_result.run_time + end + end + + # @return [String] the percentage of total time taken + def percentage + @percentage ||= + begin + time_taken = slow_duration / duration + '%.1f' % ((time_taken.nan? ? 0.0 : time_taken) * 100) + end + end + + # @return [Array(RSpec::Core::Example)] the slowest example groups + def slowest_groups + @slowest_groups ||= calculate_slowest_groups + end + + private + + def calculate_slowest_groups + example_groups = {} + + examples.each do |example| + location = example.example_group.parent_groups.last.metadata[:location] + + location_hash = example_groups[location] ||= Hash.new(0) + location_hash[:total_time] += example.execution_result.run_time + location_hash[:count] += 1 + next if location_hash.key?(:description) + location_hash[:description] = example.example_group.top_level_description + end + + # stop if we've only one example group + return {} if example_groups.keys.length <= 1 + + example_groups.each_value do |hash| + hash[:average] = hash[:total_time].to_f / hash[:count] + end + + example_groups.sort_by { |_, hash| -hash[:average] }.first(number_of_examples) + end + end + + # The `DeprecationNotification` is issued by the reporter when a deprecated + # part of RSpec is encountered. It represents information about the deprecated + # call site. + # + # @attr message [String] A custom message about the deprecation + # @attr deprecated [String] A custom message about the deprecation (alias of message) + # @attr replacement [String] An optional replacement for the deprecation + # @attr call_site [String] An optional call site from which the deprecation was issued + DeprecationNotification = Struct.new(:deprecated, :message, :replacement, :call_site) do + private_class_method :new + + # @api + # Convenience way to initialize the notification + def self.from_hash(data) + new data[:deprecated], data[:message], data[:replacement], data[:call_site] + end + end + + # `NullNotification` represents a placeholder value for notifications that + # currently require no information, but we may wish to extend in future. + class NullNotification + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/option_parser.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/option_parser.rb new file mode 100644 index 000000000..7e406da01 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/option_parser.rb @@ -0,0 +1,222 @@ +# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html +require 'optparse' + +module RSpec::Core + # @private + class Parser + def self.parse(args) + new.parse(args) + end + + def parse(args) + return {} if args.empty? + + options = args.delete('--tty') ? { :tty => true } : {} + begin + parser(options).parse!(args) + rescue OptionParser::InvalidOption => e + abort "#{e.message}\n\nPlease use --help for a listing of valid options" + end + + options + end + + def parser(options) + OptionParser.new do |parser| + parser.banner = "Usage: rspec [options] [files or directories]\n\n" + + parser.on('-I PATH', 'Specify PATH to add to $LOAD_PATH (may be used more than once).') do |dir| + options[:libs] ||= [] + options[:libs] << dir + end + + parser.on('-r', '--require PATH', 'Require a file.') do |path| + options[:requires] ||= [] + options[:requires] << path + end + + parser.on('-O', '--options PATH', 'Specify the path to a custom options file.') do |path| + options[:custom_options_file] = path + end + + parser.on('--order TYPE[:SEED]', 'Run examples by the specified order type.', + ' [defined] examples and groups are run in the order they are defined', + ' [rand] randomize the order of groups and examples', + ' [random] alias for rand', + ' [random:SEED] e.g. --order random:123') do |o| + options[:order] = o + end + + parser.on('--seed SEED', Integer, 'Equivalent of --order rand:SEED.') do |seed| + options[:order] = "rand:#{seed}" + end + + parser.on('--fail-fast', 'Abort the run on first failure.') do |_o| + options[:fail_fast] = true + end + + parser.on('--no-fail-fast', 'Do not abort the run on first failure.') do |_o| + options[:fail_fast] = false + end + + parser.on('--failure-exit-code CODE', Integer, 'Override the exit code used when there are failing specs.') do |code| + options[:failure_exit_code] = code + end + + parser.on('--dry-run', 'Print the formatter output of your suite without', + ' running any examples or hooks') do |_o| + options[:dry_run] = true + end + + parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |o| + options[:drb] = o + end + + parser.on('--drb-port PORT', 'Port to connect to the DRb server.') do |o| + options[:drb_port] = o.to_i + end + + parser.on('--init', 'Initialize your project with RSpec.') do |_cmd| + RSpec::Support.require_rspec_core "project_initializer" + ProjectInitializer.new.run + exit + end + + parser.separator("\n **** Output ****\n\n") + + parser.on('-f', '--format FORMATTER', 'Choose a formatter.', + ' [p]rogress (default - dots)', + ' [d]ocumentation (group and example names)', + ' [h]tml', + ' [j]son', + ' custom formatter class name') do |o| + options[:formatters] ||= [] + options[:formatters] << [o] + end + + parser.on('-o', '--out FILE', + 'Write output to a file instead of $stdout. This option applies', + ' to the previously specified --format, or the default format', + ' if no format is specified.' + ) do |o| + options[:formatters] ||= [['progress']] + options[:formatters].last << o + end + + parser.on('--deprecation-out FILE', 'Write deprecation warnings to a file instead of $stderr.') do |file| + options[:deprecation_stream] = file + end + + parser.on('-b', '--backtrace', 'Enable full backtrace.') do |_o| + options[:full_backtrace] = true + end + + parser.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output.') do |o| + options[:color] = o + end + + parser.on('-p', '--[no-]profile [COUNT]', 'Enable profiling of examples and list the slowest examples (default: 10).') do |argument| + options[:profile_examples] = if argument.nil? + true + elsif argument == false + false + else + begin + Integer(argument) + rescue ArgumentError + RSpec.warning "Non integer specified as profile count, seperate " \ + "your path from options with -- e.g. " \ + "`rspec --profile -- #{argument}`", + :call_site => nil + true + end + end + end + + parser.on('-w', '--warnings', 'Enable ruby warnings') do + $VERBOSE = true + end + + parser.separator <<-FILTERING + + **** Filtering/tags **** + + In addition to the following options for selecting specific files, groups, + or examples, you can select a single example by appending the line number to + the filename: + + rspec path/to/a_spec.rb:37 + +FILTERING + + parser.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.rb").') do |o| + options[:pattern] = o + end + + parser.on('--exclude-pattern PATTERN', 'Load files except those matching pattern. Opposite effect of --pattern.') do |o| + options[:exclude_pattern] = o + end + + parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be", + " used more than once)") do |o| + (options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o)) + end + + parser.on('-t', '--tag TAG[:VALUE]', + 'Run examples with the specified tag, or exclude examples', + 'by adding ~ before the tag.', + ' - e.g. ~slow', + ' - TAG is always converted to a symbol') do |tag| + filter_type = tag =~ /^~/ ? :exclusion_filter : :inclusion_filter + + name, value = tag.gsub(/^(~@|~|@)/, '').split(':', 2) + name = name.to_sym + + options[filter_type] ||= {} + options[filter_type][name] = case value + when nil then true # The default value for tags is true + when 'true' then true + when 'false' then false + when 'nil' then nil + when /^:/ then value[1..-1].to_sym + when /^\d+$/ then Integer(value) + when /^\d+.\d+$/ then Float(value) + else + value + end + end + + parser.on('--default-path PATH', 'Set the default path where RSpec looks for examples (can', + ' be a path to a file or a directory).') do |path| + options[:default_path] = path + end + + parser.separator("\n **** Utility ****\n\n") + + parser.on('-v', '--version', 'Display the version.') do + puts RSpec::Core::Version::STRING + exit + end + + # these options would otherwise be confusing to users, so we forcibly prevent them from executing + # --I is too similar to -I + # -d was a shorthand for --debugger, which is removed, but now would trigger --default-path + invalid_options = %w[-d --I] + + parser.on_tail('-h', '--help', "You're looking at it.") do + # removing the blank invalid options from the output + puts parser.to_s.gsub(/^\s+(#{invalid_options.join('|')})\s*$\n/, '') + exit + end + + # this prevents usage of the invalid_options + invalid_options.each do |option| + parser.on(option) do + raise OptionParser::InvalidOption.new + end + end + + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ordering.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ordering.rb new file mode 100644 index 000000000..c274cdcd3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ordering.rb @@ -0,0 +1,155 @@ +module RSpec + module Core + if defined?(::Random) + # @private + RandomNumberGenerator = ::Random + else + RSpec::Support.require_rspec_core "backport_random" + # @private + RandomNumberGenerator = RSpec::Core::Backports::Random + end + + # @private + module Ordering + # @private + # The default global ordering (defined order). + class Identity + def order(items) + items + end + end + + # @private + # Orders items randomly. + class Random + def initialize(configuration) + @configuration = configuration + @used = false + end + + def used? + @used + end + + def order(items) + @used = true + rng = RandomNumberGenerator.new(@configuration.seed) + shuffle items, rng + end + + if RUBY_VERSION > '1.9.3' + def shuffle(list, rng) + list.shuffle(:random => rng) + end + else + def shuffle(list, rng) + shuffled = list.dup + shuffled.size.times do |i| + j = i + rng.rand(shuffled.size - i) + next if i == j + shuffled[i], shuffled[j] = shuffled[j], shuffled[i] + end + + shuffled + end + end + end + + # @private + # Orders items based on a custom block. + class Custom + def initialize(callable) + @callable = callable + end + + def order(list) + @callable.call(list) + end + end + + # @private + # Stores the different ordering strategies. + class Registry + def initialize(configuration) + @configuration = configuration + @strategies = {} + + register(:random, Random.new(configuration)) + + identity = Identity.new + register(:defined, identity) + + # The default global ordering is --defined. + register(:global, identity) + end + + def fetch(name, &fallback) + @strategies.fetch(name, &fallback) + end + + def register(sym, strategy) + @strategies[sym] = strategy + end + + def used_random_seed? + @strategies[:random].used? + end + end + + # @private + # Manages ordering configuration. + # + # @note This is not intended to be used externally. Use + # the APIs provided by `RSpec::Core::Configuration` instead. + class ConfigurationManager + attr_reader :seed, :ordering_registry + + def initialize + @ordering_registry = Registry.new(self) + @seed = rand(0xFFFF) + @seed_forced = false + @order_forced = false + end + + def seed_used? + ordering_registry.used_random_seed? + end + + def seed=(seed) + return if @seed_forced + register_ordering(:global, ordering_registry.fetch(:random)) + @seed = seed.to_i + end + + def order=(type) + order, seed = type.to_s.split(':') + @seed = seed.to_i if seed + + ordering_name = if order.include?('rand') + :random + elsif order == 'defined' + :defined + end + + register_ordering(:global, ordering_registry.fetch(ordering_name)) if ordering_name + end + + def force(hash) + if hash.key?(:seed) + self.seed = hash[:seed] + @seed_forced = true + @order_forced = true + elsif hash.key?(:order) + self.order = hash[:order] + @order_forced = true + end + end + + def register_ordering(name, strategy=Custom.new(Proc.new { |l| yield l })) + return if @order_forced && name == :global + ordering_registry.register(name, strategy) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/pending.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/pending.rb new file mode 100644 index 000000000..41639c0da --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/pending.rb @@ -0,0 +1,163 @@ +module RSpec + module Core + # Provides methods to mark examples as pending. These methods are available to be + # called from within any example or hook. + module Pending + # Raised in the middle of an example to indicate that it should be marked as skipped. + class SkipDeclaredInExample < StandardError + attr_reader :argument + + def initialize(argument) + @argument = argument + end + end + + # If Test::Unit is loaded, we'll use its error as baseclass, so that Test::Unit + # will report unmet RSpec expectations as failures rather than errors. + begin + class PendingExampleFixedError < Test::Unit::AssertionFailedError; end + rescue + class PendingExampleFixedError < StandardError; end + end + + # @private + NO_REASON_GIVEN = 'No reason given' + + # @private + NOT_YET_IMPLEMENTED = 'Not yet implemented' + + # @overload pending() + # @overload pending(message) + # + # Marks an example as pending. The rest of the example will still be + # executed, and if it passes the example will fail to indicate that the + # pending can be removed. + # + # @param message [String] optional message to add to the summary report. + # + # @example + # describe "an example" do + # # reported as "Pending: no reason given" + # it "is pending with no message" do + # pending + # raise "broken" + # end + # + # # reported as "Pending: something else getting finished" + # it "is pending with a custom message" do + # pending("something else getting finished") + # raise "broken" + # end + # end + # + # @note `before(:example)` hooks are eval'd when you use the `pending` + # method within an example. If you want to declare an example `pending` + # and bypass the `before` hooks as well, you can pass `:pending => true` + # to the `it` method: + # + # it "does something", :pending => true do + # # ... + # end + # + # or pass `:pending => "something else getting finished"` to add a + # message to the summary report: + # + # it "does something", :pending => "something else getting finished" do + # # ... + # end + def pending(message=nil) + current_example = RSpec.current_example + + if block_given? + raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '') + |The semantics of `RSpec::Core::Pending#pending` have changed in + |RSpec 3. In RSpec 2.x, it caused the example to be skipped. In + |RSpec 3, the rest of the example is still run but is expected to + |fail, and will be marked as a failure (rather than as pending) if + |the example passes. + | + |Passing a block within an example is now deprecated. Marking the + |example as pending provides the same behavior in RSpec 3 which was + |provided only by the block in RSpec 2.x. + | + |Move the code in the block provided to `pending` into the rest of + |the example body. + | + |Called from #{CallerFilter.first_non_rspec_line}. + | + EOS + elsif current_example + Pending.mark_pending! current_example, message + else + raise "`pending` may not be used outside of examples, such as in " \ + "before(:context). Maybe you want `skip`?" + end + end + + # @overload skip() + # @overload skip(message) + # + # Marks an example as pending and skips execution. + # + # @param message [String] optional message to add to the summary report. + # + # @example + # describe "an example" do + # # reported as "Pending: no reason given" + # it "is skipped with no message" do + # skip + # end + # + # # reported as "Pending: something else getting finished" + # it "is skipped with a custom message" do + # skip "something else getting finished" + # end + # end + def skip(message=nil) + current_example = RSpec.current_example + + Pending.mark_skipped!(current_example, message) if current_example + + raise SkipDeclaredInExample.new(message) + end + + # @private + # + # Mark example as skipped + # + # @param example [RSpec::Core::Example] the example to mark as skipped + # @param message_or_bool [Boolean, String] the message to use, or true + def self.mark_skipped!(example, message_or_bool) + Pending.mark_pending! example, message_or_bool + example.metadata[:skip] = true + end + + # @private + # + # Mark example as pending + # + # @param example [RSpec::Core::Example] the example to mark as pending + # @param message_or_bool [Boolean, String] the message to use, or true + def self.mark_pending!(example, message_or_bool) + message = if !message_or_bool || !(String === message_or_bool) + NO_REASON_GIVEN + else + message_or_bool + end + + example.metadata[:pending] = true + example.execution_result.pending_message = message + example.execution_result.pending_fixed = false + end + + # @private + # + # Mark example as fixed + # + # @param example [RSpec::Core::Example] the example to mark as fixed + def self.mark_fixed!(example) + example.execution_result.pending_fixed = true + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer.rb new file mode 100644 index 000000000..2a0a4168e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer.rb @@ -0,0 +1,48 @@ +RSpec::Support.require_rspec_support "directory_maker" + +module RSpec + module Core + # @private + # Generates conventional files for an rspec project + class ProjectInitializer + attr_reader :destination, :stream, :template_path + + DOT_RSPEC_FILE = '.rspec' + SPEC_HELPER_FILE = 'spec/spec_helper.rb' + + def initialize(opts={}) + @destination = opts.fetch(:destination, Dir.getwd) + @stream = opts.fetch(:report_stream, $stdout) + @template_path = opts.fetch(:template_path) do + File.expand_path("../project_initializer", __FILE__) + end + end + + def run + copy_template DOT_RSPEC_FILE + copy_template SPEC_HELPER_FILE + end + + private + + def copy_template(file) + destination_file = File.join(destination, file) + return report_exists(file) if File.exist?(destination_file) + + report_creating(file) + RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(destination_file)) + File.open(destination_file, 'w') do |f| + f.write File.read(File.join(template_path, file)) + end + end + + def report_exists(file) + stream.puts " exist #{file}" + end + + def report_creating(file) + stream.puts " create #{file}" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/.rspec b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/.rspec new file mode 100644 index 000000000..83e16f804 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/spec/spec_helper.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/spec/spec_helper.rb new file mode 100644 index 000000000..607474b24 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/project_initializer/spec/spec_helper.rb @@ -0,0 +1,89 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause this +# file to always be loaded, without a need to explicitly require it in any files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Limits the available syntax to the non-monkey patched syntax that is recommended. + # For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/rake_task.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/rake_task.rb new file mode 100644 index 000000000..80b04ae1e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/rake_task.rb @@ -0,0 +1,187 @@ +require 'rake' +require 'rake/tasklib' +require 'rbconfig' + +module RSpec + module Core + # Rspec rake task + # + # @see Rakefile + class RakeTask < ::Rake::TaskLib + include ::Rake::DSL if defined?(::Rake::DSL) + + # Default path to the rspec executable + DEFAULT_RSPEC_PATH = File.expand_path('../../../../exe/rspec', __FILE__) + + # Default pattern for spec files. + DEFAULT_PATTERN = 'spec/**{,/*/**}/*_spec.rb' + + # Name of task. + # + # default: + # :spec + attr_accessor :name + + # Files matching this pattern will be loaded. + # + # default: + # 'spec/**{,/*/**}/*_spec.rb' + attr_accessor :pattern + + # Files matching this pattern will be excluded. + # + # default: + # 'spec/**/*_spec.rb' + attr_accessor :exclude_pattern + + # Whether or not to fail Rake when an error occurs (typically when examples fail). + # + # default: + # true + attr_accessor :fail_on_error + + # A message to print to stderr when there are failures. + attr_accessor :failure_message + + # Use verbose output. If this is set to true, the task will print the + # executed spec command to stdout. + # + # default: + # true + attr_accessor :verbose + + # Command line options to pass to ruby. + # + # default: + # nil + attr_accessor :ruby_opts + + # Path to rspec + # + # default: + # 'rspec' + attr_accessor :rspec_path + + # Command line options to pass to rspec. + # + # default: + # nil + attr_accessor :rspec_opts + + def initialize(*args, &task_block) + @name = args.shift || :spec + @ruby_opts = nil + @rspec_opts = nil + @verbose = true + @fail_on_error = true + @rspec_path = DEFAULT_RSPEC_PATH + @pattern = DEFAULT_PATTERN + + define(args, &task_block) + end + + # @private + def run_task(verbose) + command = spec_command + + begin + puts command if verbose + success = system(command) + rescue + puts failure_message if failure_message + end + + return unless fail_on_error && !success + + $stderr.puts "#{command} failed" + exit $?.exitstatus + end + + private + + # @private + def define(args, &task_block) + desc "Run RSpec code examples" unless ::Rake.application.last_comment + + task name, *args do |_, task_args| + RakeFileUtils.__send__(:verbose, verbose) do + task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block + run_task verbose + end + end + end + + def file_inclusion_specification + if ENV['SPEC'] + FileList[ ENV['SPEC']].sort + elsif String === pattern && !File.exist?(pattern) + "--pattern #{escape pattern}" + else + # Before RSpec 3.1, we used `FileList` to get the list of matched files, and + # then pass that along to the `rspec` command. Starting with 3.1, we prefer to + # pass along the pattern as-is to the `rspec` command, for 3 reasons: + # + # * It's *much* less verbose to pass one `--pattern` option than a long list of files. + # * It ensures `task.pattern` and `--pattern` have the same behavior. + # * It fixes a bug, where `task.pattern = pattern_that_matches_no_files` would run + # *all* files because it would cause no pattern or file args to get passed to `rspec`, + # which causes all files to get run. + # + # However, `FileList` is *far* more flexible than the `--pattern` option. Specifically, it + # supports individual files and directories, as well as arrays of files, directories and globs, + # as well as other `FileList` objects. + # + # For backwards compatibility, we have to fall back to using FileList if the user has passed + # a `pattern` option that will not work with `--pattern`. + # + # TODO: consider deprecating support for this and removing it in RSpec 4. + FileList[pattern].sort.map { |file| escape file } + end + end + + # Manaully comparing because in 3.2 we have RSpec::Support::OS.windows? + # but in 3.1 we don't and requiring rspec/world would be weighty here. + if RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/ + def escape(shell_command) + "'#{shell_command.gsub("'", "\'")}'" + end + else + require 'shellwords' + + def escape(shell_command) + shell_command.shellescape + end + end + + def file_exclusion_specification + " --exclude-pattern #{escape exclude_pattern}" if exclude_pattern + end + + def spec_command + cmd_parts = [] + cmd_parts << RUBY + cmd_parts << ruby_opts + cmd_parts << rspec_load_path + cmd_parts << rspec_path + cmd_parts << file_inclusion_specification + cmd_parts << file_exclusion_specification + cmd_parts << rspec_opts + cmd_parts.flatten.reject(&blank).join(" ") + end + + def blank + lambda { |s| s.nil? || s == "" } + end + + def rspec_load_path + @rspec_load_path ||= begin + core_and_support = $LOAD_PATH.grep( + /#{File::SEPARATOR}rspec-(core|support)[^#{File::SEPARATOR}]*#{File::SEPARATOR}lib/ + ).uniq + + "-I#{core_and_support.map { |file| escape file }.join(File::PATH_SEPARATOR)}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/reporter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/reporter.rb new file mode 100644 index 000000000..8cb9c9aa6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/reporter.rb @@ -0,0 +1,149 @@ +module RSpec::Core + # A reporter will send notifications to listeners, usually formatters for the + # spec suite run. + class Reporter + def initialize(configuration) + @configuration = configuration + @listeners = Hash.new { |h, k| h[k] = Set.new } + @examples = [] + @failed_examples = [] + @pending_examples = [] + @duration = @start = @load_time = nil + end + + # @private + attr_reader :examples, :failed_examples, :pending_examples + + # Registers a listener to a list of notifications. The reporter will send notification of + # events to all registered listeners + # + # @param listener [Object] An obect that wishes to be notified of reporter events + # @param notifications [Array] Array of symbols represents the events a listener wishes to subscribe too + def register_listener(listener, *notifications) + notifications.each do |notification| + @listeners[notification.to_sym] << listener + end + true + end + + # @private + def registered_listeners(notification) + @listeners[notification].to_a + end + + # @api + # @overload report(count, &block) + # @overload report(count, &block) + # @param expected_example_count [Integer] the number of examples being run + # @yield [Block] block yields itself for further reporting. + # + # Initializes the report run and yields itself for further reporting. The + # block is required, so that the reporter can manage cleaning up after the + # run. + # + # @example + # + # reporter.report(group.examples.size) do |r| + # example_groups.map {|g| g.run(r) } + # end + # + def report(expected_example_count) + start(expected_example_count) + begin + yield self + ensure + finish + end + end + + # @private + def start(expected_example_count, time=RSpec::Core::Time.now) + @start = time + @load_time = (@start - @configuration.start_time).to_f + notify :start, Notifications::StartNotification.new(expected_example_count, @load_time) + end + + # @private + def message(message) + notify :message, Notifications::MessageNotification.new(message) + end + + # @private + def example_group_started(group) + notify :example_group_started, Notifications::GroupNotification.new(group) unless group.descendant_filtered_examples.empty? + end + + # @private + def example_group_finished(group) + notify :example_group_finished, Notifications::GroupNotification.new(group) unless group.descendant_filtered_examples.empty? + end + + # @private + def example_started(example) + @examples << example + notify :example_started, Notifications::ExampleNotification.for(example) + end + + # @private + def example_passed(example) + notify :example_passed, Notifications::ExampleNotification.for(example) + end + + # @private + def example_failed(example) + @failed_examples << example + notify :example_failed, Notifications::ExampleNotification.for(example) + end + + # @private + def example_pending(example) + @pending_examples << example + notify :example_pending, Notifications::ExampleNotification.for(example) + end + + # @private + def deprecation(hash) + notify :deprecation, Notifications::DeprecationNotification.from_hash(hash) + end + + # @private + def finish + stop + notify :start_dump, Notifications::NullNotification + notify :dump_pending, Notifications::ExamplesNotification.new(self) + notify :dump_failures, Notifications::ExamplesNotification.new(self) + notify :deprecation_summary, Notifications::NullNotification + notify :dump_summary, Notifications::SummaryNotification.new(@duration, @examples, @failed_examples, @pending_examples, @load_time) + unless mute_profile_output? + notify :dump_profile, Notifications::ProfileNotification.new(@duration, @examples, @configuration.profile_examples) + end + notify :seed, Notifications::SeedNotification.new(@configuration.seed, seed_used?) + ensure + notify :close, Notifications::NullNotification + end + + # @private + def stop + @duration = (RSpec::Core::Time.now - @start).to_f if @start + notify :stop, Notifications::ExamplesNotification.new(self) + end + + # @private + def notify(event, notification) + registered_listeners(event).each do |formatter| + formatter.__send__(event, notification) + end + end + + private + + def mute_profile_output? + # Don't print out profiled info if there are failures and `--fail-fast` is used, it just clutters the output + !@configuration.profile_examples? || (@configuration.fail_fast? && @failed_examples.size > 0) + end + + def seed_used? + @configuration.seed && @configuration.seed_used? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ruby_project.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ruby_project.rb new file mode 100644 index 000000000..2e9a23d2a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/ruby_project.rb @@ -0,0 +1,45 @@ +# This is borrowed (slightly modified) from Scott Taylor's +# project_path project: +# http://github.com/smtlaissezfaire/project_path + +require 'pathname' + +module RSpec + module Core + # @private + module RubyProject + def add_to_load_path(*dirs) + dirs.map { |dir| add_dir_to_load_path(File.join(root, dir)) } + end + + def add_dir_to_load_path(dir) + $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) + end + + def root + @project_root ||= determine_root + end + + def determine_root + find_first_parent_containing('spec') || '.' + end + + def find_first_parent_containing(dir) + ascend_until { |path| File.exist?(File.join(path, dir)) } + end + + def ascend_until + Pathname(File.expand_path('.')).ascend do |path| + return path if yield(path) + end + end + + module_function :add_to_load_path + module_function :add_dir_to_load_path + module_function :root + module_function :determine_root + module_function :find_first_parent_containing + module_function :ascend_until + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb new file mode 100644 index 000000000..5b495ae5a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb @@ -0,0 +1,158 @@ +module RSpec + module Core + # Provides the main entry point to run a suite of RSpec examples. + class Runner + # Register an `at_exit` hook that runs the suite when the process exits. + # + # @note This is not generally needed. The `rspec` command takes care + # of running examples for you without involving an `at_exit` + # hook. This is only needed if you are running specs using + # the `ruby` command, and even then, the normal way to invoke + # this is by requiring `rspec/autorun`. + def self.autorun + if autorun_disabled? + RSpec.deprecate("Requiring `rspec/autorun` when running RSpec via the `rspec` command") + return + elsif installed_at_exit? || running_in_drb? + return + end + + at_exit do + # Don't bother running any specs and just let the program terminate + # if we got here due to an unrescued exception (anything other than + # SystemExit, which is raised when somebody calls Kernel#exit). + next unless $!.nil? || $!.is_a?(SystemExit) + + # We got here because either the end of the program was reached or + # somebody called Kernel#exit. Run the specs and then override any + # existing exit status with RSpec's exit status if any specs failed. + invoke + end + @installed_at_exit = true + end + + # Runs the suite of specs and exits the process with an appropriate exit code. + def self.invoke + disable_autorun! + status = run(ARGV, $stderr, $stdout).to_i + exit(status) if status != 0 + end + + # Run a suite of RSpec examples. Does not exit. + # + # This is used internally by RSpec to run a suite, but is available + # for use by any other automation tool. + # + # If you want to run this multiple times in the same process, and you + # want files like `spec_helper.rb` to be reloaded, be sure to load `load` + # instead of `require`. + # + # @param args [Array] command-line-supported arguments + # @param err [IO] error stream + # @param out [IO] output stream + # @return [Fixnum] exit status code. 0 if all specs passed, + # or the configured failure exit code (1 by default) if specs + # failed. + def self.run(args, err=$stderr, out=$stdout) + trap_interrupt + options = ConfigurationOptions.new(args) + + if options.options[:drb] + require 'rspec/core/drb' + begin + DRbRunner.new(options).run(err, out) + rescue DRb::DRbConnError + err.puts "No DRb server is running. Running in local process instead ..." + new(options).run(err, out) + end + else + new(options).run(err, out) + end + end + + def initialize(options, configuration=RSpec.configuration, world=RSpec.world) + @options = options + @configuration = configuration + @world = world + end + + # Configures and runs a spec suite. + # + # @param err [IO] error stream + # @param out [IO] output stream + def run(err, out) + setup(err, out) + run_specs(@world.ordered_example_groups) + end + + # Wires together the various configuration objects and state holders. + # + # @param err [IO] error stream + # @param out [IO] output stream + def setup(err, out) + @configuration.error_stream = err + @configuration.output_stream = out if @configuration.output_stream == $stdout + @options.configure(@configuration) + @configuration.load_spec_files + @world.announce_filters + end + + # Runs the provided example groups. + # + # @param example_groups [Array] groups to run + # @return [Fixnum] exit status code. 0 if all specs passed, + # or the configured failure exit code (1 by default) if specs + # failed. + def run_specs(example_groups) + @configuration.reporter.report(@world.example_count(example_groups)) do |reporter| + begin + hook_context = SuiteHookContext.new + @configuration.hooks.run(:before, :suite, hook_context) + example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code + ensure + @configuration.hooks.run(:after, :suite, hook_context) + end + end + end + + # @private + def self.disable_autorun! + @autorun_disabled = true + end + + # @private + def self.autorun_disabled? + @autorun_disabled ||= false + end + + # @private + def self.installed_at_exit? + @installed_at_exit ||= false + end + + # @private + # rubocop:disable Lint/EnsureReturn + def self.running_in_drb? + if defined?(DRb) && DRb.current_server + require 'socket' + require 'uri' + local_ipv4 = IPSocket.getaddress(Socket.gethostname) + local_drb = ["127.0.0.1", "localhost", local_ipv4].any? { |addr| addr == URI(DRb.current_server.uri).host } + end + rescue DRb::DRbServerNotFound + ensure + return local_drb || false + end + # rubocop:enable Lint/EnsureReturn + + # @private + def self.trap_interrupt + trap('INT') do + exit!(1) if RSpec.world.wants_to_quit + RSpec.world.wants_to_quit = true + STDERR.puts "\nExiting... Interrupt again to exit immediately." + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_context.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_context.rb new file mode 100644 index 000000000..6de7f649d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_context.rb @@ -0,0 +1,55 @@ +module RSpec + module Core + # Exposes {ExampleGroup}-level methods to a module, so you can include that + # module in an {ExampleGroup}. + # + # @example + # + # module LoggedInAsAdmin + # extend RSpec::Core::SharedContext + # before(:example) do + # log_in_as :admin + # end + # end + # + # describe "admin section" do + # include LoggedInAsAdmin + # # ... + # end + module SharedContext + # @private + def included(group) + __shared_context_recordings.each do |recording| + recording.playback_onto(group) + end + end + + # @private + def __shared_context_recordings + @__shared_context_recordings ||= [] + end + + # @private + Recording = Struct.new(:method_name, :args, :block) do + def playback_onto(group) + group.__send__(method_name, *args, &block) + end + end + + # @private + def self.record(methods) + methods.each do |meth| + define_method(meth) do |*args, &block| + __shared_context_recordings << Recording.new(meth, args, block) + end + end + end + + # @private + record [:describe, :context] + Hooks.instance_methods(false) + + MemoizedHelpers::ClassMethods.instance_methods(false) + end + end + # @private + SharedContext = Core::SharedContext +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_example_group.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_example_group.rb new file mode 100644 index 000000000..f744f2420 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/shared_example_group.rb @@ -0,0 +1,182 @@ +module RSpec + module Core + # Shared example groups let you define common context and/or common + # examples that you wish to use in multiple example groups. + # + # When defined, the shared group block is stored for later evaluation. + # It can later be included in an example group either explicitly + # (using `include_examples`, `include_context` or `it_behaves_like`) + # or implicitly (via matching metadata). + # + # Named shared example groups are scoped based on where they are + # defined. Shared groups defined in an example group are available + # for inclusion in that example group or any child example groups, + # but not in any parent or sibling example groups. Shared example + # groups defined at the top level can be included from any example group. + module SharedExampleGroup + # @overload shared_examples(name, &block) + # @param name [String, Symbol, Module] identifer to use when looking up this shared group + # @param block The block to be eval'd + # @overload shared_examples(name, metadata, &block) + # @param name [String, Symbol, Module] identifer to use when looking up this shared group + # @param metadata [Array, Hash] metadata to attach to this group; any example group + # with matching metadata will automatically include this shared example group. + # @param block The block to be eval'd + # @overload shared_examples(metadata, &block) + # @param metadata [Array, Hash] metadata to attach to this group; any example group + # with matching metadata will automatically include this shared example group. + # @param block The block to be eval'd + # + # Stores the block for later use. The block will be evaluated + # in the context of an example group via `include_examples`, + # `include_context`, or `it_behaves_like`. + # + # @example + # shared_examples "auditable" do + # it "stores an audit record on save!" do + # expect { auditable.save! }.to change(Audit, :count).by(1) + # end + # end + # + # describe Account do + # it_behaves_like "auditable" do + # let(:auditable) { Account.new } + # end + # end + # + # @see ExampleGroup.it_behaves_like + # @see ExampleGroup.include_examples + # @see ExampleGroup.include_context + def shared_examples(name, *args, &block) + top_level = self == ExampleGroup + if top_level && RSpec.thread_local_metadata[:in_example_group] + raise "Creating isolated shared examples from within a context is " \ + "not allowed. Remove `RSpec.` prefix or move this to a " \ + "top-level scope." + end + + RSpec.world.shared_example_group_registry.add(self, name, *args, &block) + end + alias shared_context shared_examples + alias shared_examples_for shared_examples + + # @api private + # + # Shared examples top level DSL + module TopLevelDSL + # @private + def self.definitions + proc do + def shared_examples(name, *args, &block) + RSpec.world.shared_example_group_registry.add(:main, name, *args, &block) + end + alias shared_context shared_examples + alias shared_examples_for shared_examples + end + end + + # @private + def self.exposed_globally? + @exposed_globally ||= false + end + + # @api private + # + # Adds the top level DSL methods to Module and the top level binding + def self.expose_globally! + return if exposed_globally? + Core::DSL.change_global_dsl(&definitions) + @exposed_globally = true + end + + # @api private + # + # Removes the top level DSL methods to Module and the top level binding + def self.remove_globally! + return unless exposed_globally? + + Core::DSL.change_global_dsl do + undef shared_examples + undef shared_context + undef shared_examples_for + end + + @exposed_globally = false + end + end + + # @private + class Registry + def add(context, name, *metadata_args, &block) + ensure_block_has_source_location(block) { CallerFilter.first_non_rspec_line } + + if valid_name?(name) + warn_if_key_taken context, name, block + shared_example_groups[context][name] = block + else + metadata_args.unshift name + end + + return if metadata_args.empty? + + mod = Module.new + (class << mod; self; end).__send__(:define_method, :included) do |host| + host.class_exec(&block) + end + RSpec.configuration.include mod, *metadata_args + end + + def find(lookup_contexts, name) + lookup_contexts.each do |context| + found = shared_example_groups[context][name] + return found if found + end + + shared_example_groups[:main][name] + end + + private + + def shared_example_groups + @shared_example_groups ||= Hash.new { |hash, context| hash[context] = {} } + end + + def valid_name?(candidate) + case candidate + when String, Symbol, Module then true + else false + end + end + + def warn_if_key_taken(context, key, new_block) + existing_block = shared_example_groups[context][key] + + return unless existing_block + + RSpec.warn_with <<-WARNING.gsub(/^ +\|/, ''), :call_site => nil + |WARNING: Shared example group '#{key}' has been previously defined at: + | #{formatted_location existing_block} + |...and you are now defining it at: + | #{formatted_location new_block} + |The new definition will overwrite the original one. + WARNING + end + + def formatted_location(block) + block.source_location.join ":" + end + + if Proc.method_defined?(:source_location) + def ensure_block_has_source_location(_block); end + else # for 1.8.7 + def ensure_block_has_source_location(block) + source_location = yield.split(':') + block.extend Module.new { define_method(:source_location) { source_location } } + end + end + end + end + end + + instance_exec(&Core::SharedExampleGroup::TopLevelDSL.definitions) +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/test_unit_assertions_adapter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/test_unit_assertions_adapter.rb new file mode 100644 index 000000000..8fb09eb91 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/test_unit_assertions_adapter.rb @@ -0,0 +1,30 @@ +require 'test/unit/assertions' + +module RSpec + module Core + # @private + module TestUnitAssertionsAdapter + include ::Test::Unit::Assertions + + # If using test/unit from Ruby core with Ruby 1.9+, it includes + # MiniTest::Assertions by default. Note the upcasing of 'Test'. + # + # If the test/unit gem is being loaded, it will not include any minitest + # assertions. + # + # Only if Minitest 5.x is included / loaded do we need to worry about + # adding a shim for the new updates. Thus instead of checking on the + # RUBY_VERSION we need to check ancestors. + begin + # MiniTest is 4.x + # Minitest is 5.x + if ancestors.include?(::Minitest::Assertions) + require 'rspec/core/minitest_assertions_adapter' + include ::RSpec::Core::MinitestAssertionsAdapter + end + rescue NameError + # No-op. Minitest 5.x was not loaded + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/version.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/version.rb new file mode 100644 index 000000000..bced04e52 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/version.rb @@ -0,0 +1,9 @@ +module RSpec + module Core + # Version information for RSpec Core. + module Version + # Current version of RSpec Core, in semantic versioning format. + STRING = '3.1.7' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/warnings.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/warnings.rb new file mode 100644 index 000000000..ce324e62d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/warnings.rb @@ -0,0 +1,40 @@ +require "rspec/support/warnings" + +module RSpec + module Core + # @private + module Warnings + # @private + # + # Used internally to print deprecation warnings + def deprecate(deprecated, data={}) + RSpec.configuration.reporter.deprecation( + { + :deprecated => deprecated, + :call_site => CallerFilter.first_non_rspec_line + }.merge(data) + ) + end + + # @private + # + # Used internally to print deprecation warnings + def warn_deprecation(message, opts={}) + RSpec.configuration.reporter.deprecation opts.merge(:message => message) + end + + # @private + def warn_with(message, options={}) + if options[:use_spec_location_as_call_site] + message += "." unless message.end_with?(".") + + if RSpec.current_example + message += " Warning generated from spec at `#{RSpec.current_example.location}`." + end + end + + super(message, options) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/world.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/world.rb new file mode 100644 index 000000000..f45c533f8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.1.7/lib/rspec/core/world.rb @@ -0,0 +1,183 @@ +require 'rbconfig' + +module RSpec + module Core + # @api private + # + # Internal container for global non-configuration data + class World + include RSpec::Core::Hooks + + # @private + attr_reader :example_groups, :filtered_examples + + # Used internally to determine what to do when a SIGINT is received + attr_accessor :wants_to_quit + + def initialize(configuration=RSpec.configuration) + @configuration = configuration + @example_groups = [] + @filtered_examples = Hash.new do |hash, group| + hash[group] = begin + examples = group.examples.dup + examples = filter_manager.prune(examples) + examples.uniq! + examples + end + end + end + + # @private + # Used internally to clear remaining groups when fail_fast is set + def clear_remaining_example_groups + example_groups.clear + end + + # @private + def windows_os? + RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/ + end + + # @api private + # + # Apply ordering strategy from configuration to example groups + def ordered_example_groups + ordering_strategy = @configuration.ordering_registry.fetch(:global) + ordering_strategy.order(@example_groups) + end + + # @api private + # + # Reset world to 'scratch' before running suite + def reset + example_groups.clear + @shared_example_group_registry = nil + end + + # @private + def filter_manager + @configuration.filter_manager + end + + # @api private + # + # Register an example group + def register(example_group) + example_groups << example_group + example_group + end + + # @private + def shared_example_group_registry + @shared_example_group_registry ||= SharedExampleGroup::Registry.new + end + + # @private + def inclusion_filter + @configuration.inclusion_filter + end + + # @private + def exclusion_filter + @configuration.exclusion_filter + end + + # @private + def configure_group(group) + @configuration.configure_group(group) + end + + # @api private + # + # Get count of examples to be run + def example_count(groups=example_groups) + FlatMap.flat_map(groups) { |g| g.descendants }. + inject(0) { |a, e| a + e.filtered_examples.size } + end + + # @api private + # + # Find line number of previous declaration + def preceding_declaration_line(filter_line) + declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line| + line <= filter_line ? line : highest_prior_declaration_line + end + end + + # @private + def reporter + @configuration.reporter + end + + # @api private + # + # Notify reporter of filters + def announce_filters + filter_announcements = [] + + announce_inclusion_filter filter_announcements + announce_exclusion_filter filter_announcements + + unless filter_manager.empty? + if filter_announcements.length == 1 + reporter.message("Run options: #{filter_announcements[0]}") + else + reporter.message("Run options:\n #{filter_announcements.join("\n ")}") + end + end + + if @configuration.run_all_when_everything_filtered? && example_count.zero? + reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}") + filtered_examples.clear + inclusion_filter.clear + end + + return unless example_count.zero? + + example_groups.clear + if filter_manager.empty? + reporter.message("No examples found.") + elsif exclusion_filter.empty? + message = everything_filtered_message + if @configuration.run_all_when_everything_filtered? + message << "; ignoring #{inclusion_filter.description}" + end + reporter.message(message) + elsif inclusion_filter.empty? + reporter.message(everything_filtered_message) + end + end + + # @private + def everything_filtered_message + "\nAll examples were filtered out" + end + + # @api private + # + # Add inclusion filters to announcement message + def announce_inclusion_filter(announcements) + return if inclusion_filter.empty? + + announcements << "include #{inclusion_filter.description}" + end + + # @api private + # + # Add exclusion filters to announcement message + def announce_exclusion_filter(announcements) + return if exclusion_filter.empty? + + announcements << "exclude #{exclusion_filter.description}" + end + + private + + def declaration_line_numbers + @line_numbers ||= example_groups.inject([]) do |lines, g| + lines + g.declaration_line_numbers + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.document b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.document new file mode 100644 index 000000000..050e20457 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.document @@ -0,0 +1,5 @@ +lib/**/*.rb +- +README.md +License.txt +Changelog.md diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.yardopts b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.yardopts new file mode 100644 index 000000000..15f63ee32 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/.yardopts @@ -0,0 +1,6 @@ +--exclude features +--no-private +--markup markdown +- +Changelog.md +License.txt diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/Changelog.md b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/Changelog.md new file mode 100644 index 000000000..8c299ddf8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/Changelog.md @@ -0,0 +1,835 @@ +### 3.1.2 / 2014-09-26 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.1.1...v3.1.2) + +Bug Fixes: + +* Fix `define_negated_matcher` so that matchers that support fluent + interfaces continue to be negated after you use the chained method. + (Myron Marston, #656) +* Fix `define_negated_matcher` so that the matchers fail with an + appropriate failure message. (Myron Marston, #659) + +### 3.1.1 / 2014-09-15 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.1.0...v3.1.1) + +Bug Fixes: + +* Fix regression in `all` matcher in 3.1.0 that prevented it from + working on objects that are not `Enumerable` but do implement + `each_with_index` (such as an ActiveRecord proxy). (Jori Hardman, #647) + +### 3.1.0 / 2014-09-04 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.4...v3.1.0) + +Enhancements: + +* Add `have_attributes` matcher, that passes if actual's attribute + values match the expected attributes hash: + `Person = Struct.new(:name, :age)` + `person = Person.new("Bob", 32)` + `expect(person).to have_attributes(:name => "Bob", :age => 32)`. + (Adam Farhi, #571) +* Extended compound matcher support to block matchers, for cases like: + `expect { ... }.to change { x }.to(3).and change { y }.to(4)`. (Myron + Marston, #567) +* Include chained methods in custom matcher description and failure message + when new `include_chain_clauses_in_custom_matcher_descriptions` config + option is enabled. (Dan Oved, #600) +* Add `thrice` modifier to `yield_control` matcher as a synonym for + `exactly(3).times`. (Dennis Taylor, #615) +* Add `RSpec::Matchers.define_negated_matcher`, which defines a negated + version of the named matcher. (Adam Farhi, Myron Marston, #618) +* Document and support negation of `contain_exactly`/`match_array`. + (Jon Rowe, #626). + +Bug Fixes: + +* Rename private `LegacyMacherAdapter` constant to `LegacyMatcherAdapter` + to fix typo. (Abdelkader Boudih, #563) +* Fix `all` matcher so that it fails properly (rather than raising a + `NoMethodError`) when matched against a non-enumerable. (Hao Su, #622) + +### 3.0.4 / 2014-08-14 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.3...v3.0.4) + +Bug Fixes: + +* Fix `start_with` and `end_with` so that they work properly with + structs. (Myron Marston, #620) +* Fix failure message generation so that structs are printed properly + in failures. Previously failure messages would represent them as + an array. (Myron Marston, #620) +* Fix composable matcher support so that it does not wrongly treat + structs as arrays. (Myron Marston, #620) + +### 3.0.3 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.2...v3.0.3) + +Bug Fixes: + +* Fix issue with detection of generic operator matchers so they work + correctly when undefined. (Myron Marston, #597) +* Don't inadvertently define `BasicObject` in 1.8.7. (Chris Griego, #603) +* Fix `include` matcher so that it fails gracefully when matched against + an object that does not respond to `include?`. (Myron Marston, #607) + +### 3.0.2 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.1...v3.0.2) + +Bug Fixes: + +* Fix regression in `contain_exactly` (AKA `match_array`) that caused it + to wrongly pass when the expected array was empty. (Myron Marston, #581) +* Provide a better error message when you use the `change(obj, :msg)` + form of the change matcher but forget the message argument. (Alex + Sunderland, #585) +* Make the `contain_exactly` matcher work with arrays that contain hashes in + arbitrary ordering. (Sam Phippen, #578) + +### 3.0.1 / 2014-06-12 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.0...v3.0.1) + +Bug Fixes: + +* Add a missing `require` that would cause the `respond_to` matcher to + fail when used in a project where the rest of RSpec (e.g. core and + expecatations) weren't being used. (Myron Marston, #566) +* Structs are no longer treated as arrays when diffed. (Jon Rowe, #576) + +### 3.0.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.0.rc1...v3.0.0) + +No code changes. Just taking it out of pre-release. + +### 3.0.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.0.beta2...v3.0.0.rc1) + +Breaking Changes for 3.0.0: + +* Remove `matcher_execution_context` attribute from DSL-defined + custom matchers. (Myron Marston) +* Remove `RSpec::Matchers::Pretty#_pretty_print`. (Myron Marston) +* Remove `RSpec::Matchers::Pretty#expected_to_sentence`. (Myron Marston) +* Rename `RSpec::Matchers::Configuration` constant to + `RSpec::Expectations::Configuration`. (Myron Marston) +* Prevent `have_xyz` predicate matchers using private methods. + (Adrian Gonzalez) +* Block matchers must now implement `supports_block_expectations?`. + (Myron Marston) +* Stop supporting `require 'rspec-expectations'`. + Use `require 'rspec/expectations'` instead. (Myron Marston) + +Bug Fixes: + +* Fix `NoMethodError` triggered by beta2 when `YARD` was loaded in + the test environment. (Myron Marston) +* Fix `be_xyz` matcher to accept a `do...end` block. (Myron Marston) +* Fix composable matcher failure message generation logic + so that it does not blow up when given `$stdout` or `$stderr`. + (Myron Marston) +* Fix `change` matcher to work properly with `IO` objects. + (Myron Marston) +* Fix `exist` matcher so that it can be used in composed matcher + expressions involving objects that do not implement `exist?` or + `exists?`. (Daniel Fone) +* Fix composable matcher match logic so that it clones matchers + before using them in order to work properly with matchers + that use internal memoization based on a given `actual` value. + (Myron Marston) +* Fix `be_xyz` and `has_xyz` predicate matchers so that they can + be used in composed matcher expressions involving objects that + do not implement the predicate method. (Daniel Fone) + +Enhancements: + +* Document the remaining public APIs. rspec-expectations now has 100% of + the public API documented and will remain that way (as new undocumented + methods will fail the build). (Myron Marston) +* Improve the formatting of BigDecimal objects in `eq` matcher failure + messages. (Daniel Fone) +* Improve the failure message for `be_xyz` predicate matchers so + that it includes the `inspect` output of the receiver. + (Erik Michaels-Ober, Sam Phippen) +* Add `all` matcher, to allow you to specify that a given matcher + matches all elements in a collection: + `expect([1, 3, 5]).to all( be_odd )`. (Adam Farhi) +* Add boolean aliases (`&`/`|`) for compound operators (`and`/`or`). (Adam Farhi) +* Give users a clear error when they wrongly use a value matcher + in a block expectation expression (e.g. `expect { 3 }.to eq(3)`) + or vice versa. (Myron Marston) + +### 3.0.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.0.0.beta1...v3.0.0.beta2) + +Breaking Changes for 3.0.0: + +* Remove deprecated support for accessing the `RSpec` constant using + `Rspec` or `Spec`. (Myron Marston) +* Remove deprecated `RSpec::Expectations.differ=`. (Myron Marston) +* Remove support for deprecated `expect(...).should`. (Myron Marston) +* Explicitly disallow `expect { }.not_to change { }` with `by`, + `by_at_least`, `by_at_most` or `to`. These have never been supported + but did not raise explicit errors. (Myron Marston) +* Provide `===` rather than `==` as an alias of `matches?` for + all matchers. The semantics of `===` are closer to an RSpec + matcher than `==`. (Myron Marston) +* Remove deprecated `RSpec::Matchers::OperatorMatcher` constant. + (Myron Marston) +* Make `RSpec::Expectations::ExpectationNotMetError` subclass + `Exception` rather than `StandardError` so they can bypass + a bare `rescue` in end-user code (e.g. when an expectation is + set from within a rspec-mocks stub implementation). (Myron Marston) +* Remove Test::Unit and Minitest 4.x integration. (Myron Marston) + +Enhancements: + +* Simplify the failure message of the `be` matcher when matching against: + `true`, `false` and `nil`. (Sam Phippen) +* Update matcher protocol and custom matcher DSL to better align + with the newer `expect` syntax. If you want your matchers to + maintain compatibility with multiple versions of RSpec, you can + alias the new names to the old. (Myron Marston) + * `failure_message_for_should` => `failure_message` + * `failure_message_for_should_not` => `failure_message_when_negated` + * `match_for_should` => `match` + * `match_for_should_not` => `match_when_negated` +* Improve generated descriptions from `change` matcher. (Myron Marston) +* Add support for compound matcher expressions using `and` and `or`. + Simply chain them off of any existing matcher to create an expression + like `expect(alphabet).to start_with("a").and end_with("z")`. + (Eloy Espinaco) +* Add `contain_exactly` as a less ambiguous version of `match_array`. + Note that it expects the expected array to be splatted as + individual args: `expect(array).to contain_exactly(1, 2)` is + the same as `expect(array).to match_array([1, 2])`. (Myron Marston) +* Update `contain_exactly`/`match_array` so that it can match against + other non-array collections (such as a `Set`). (Myron Marston) +* Update built-in matchers so that they can accept matchers as arguments + to allow you to compose matchers in arbitrary ways. (Myron Marston) +* Add `RSpec::Matchers::Composable` mixin that can be used to make + a custom matcher composable as well. Note that custom matchers + defined via `RSpec::Matchers.define` already have this. (Myron + Marston) +* Define noun-phrase aliases for built-in matchers, which can be + used when creating composed matcher expressions that read better + and provide better failure messages. (Myron Marston) +* Add `RSpec::Matchers.alias_matcher` so users can define their own + matcher aliases. The `description` of the matcher will reflect the + alternate matcher name. (Myron Marston) +* Add explicit `be_between` matcher. `be_between` has worked for a + long time as a dynamic predicate matcher, but the failure message + was suboptimal. The new matcher provides a much better failure + message. (Erik Michaels-Ober) +* Enhance the `be_between` matcher to allow for `inclusive` or `exclusive` + comparison (e.g. inclusive of min/max or exclusive of min/max). + (Pedro Gimenez) +* Make failure message for `not_to be #{operator}` less confusing by + only saying it's confusing when comparison operators are used. + (Prathamesh Sonpatki) +* Improve failure message of `eq` matcher when `Time` or `DateTime` + objects are used so that the full sub-second precision is included. + (Thomas Holmes, Jeff Wallace) +* Add `output` matcher for expecting that a block outputs `to_stdout` + or `to_stderr`. (Luca Pette, Matthias Günther) +* Forward a provided block on to the `has_xyz?` method call when + the `have_xyz` matcher is used. (Damian Galarza) +* Provide integration with Minitest 5.x. Require + `rspec/expectations/minitest_integration` after loading minitest + to use rspec-expectations with minitest. (Myron Marston) + +Bug Fixes: + +* Fix wrong matcher descriptions with falsey expected value (yujinakayama) +* Fix `expect { }.not_to change { }.from(x)` so that the matcher only + passes if the starting value is `x`. (Tyler Rick, Myron Marston) +* Fix hash diffing, so that it colorizes properly and doesn't consider trailing + commas when performing the diff. (Jared Norman) +* Fix built-in matchers to fail normally rather than raising + `ArgumentError` when given an object of the wrong type to match + against, so that they work well in composite matcher expressions like + `expect([1.51, "foo"]).to include(a_string_matching(/foo/), a_value_within(0.1).of(1.5))`. + (Myron Marston) + +Deprecations: + +* Retain support for RSpec 2 matcher protocol (e.g. for matchers + in 3rd party extension gems like `shoulda`), but it will print + a deprecation warning. (Myron Marston) + +### 3.0.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.2...v3.0.0.beta1) + +Breaking Changes for 3.0.0: + +* Remove explicit support for 1.8.6. (Jon Rowe) +* Remove the deprecated `be_close` matcher, preferring `be_within` instead. + (Sam Phippen) +* Remove the deprecated `have`, `have_at_least` and `have_at_most` matchers. + You can continue using those matchers through https://github.com/rspec/rspec-collection_matchers, + or you can rewrite your expectations with something like + `expect(your_object.size).to eq(num)`. (Hugo Baraúna) +* Rename `be_true` and `be_false` to `be_truthy` and `be_falsey`. (Sam Phippen) +* Make `expect { }.to_not raise_error(SomeSpecificClass, message)`, + `expect { }.to_not raise_error(SomeSpecificClass)` and + `expect { }.to_not raise_error(message)` invalid, since they are prone + to hiding failures. Instead, use `expect { }.to_not raise_error` (with no + args). (Sam Phippen) +* Within `RSpec::Matchers.define` blocks, helper methods made available + either via `def self.helper` or `extend HelperModule` are no longer + available to the `match` block (or any of the others). Instead + `include` your helper module and define the helper method as an + instance method. (Myron Marston) +* Force upgrading Diff::LCS for encoding compatability with diffs. (Jon Rowe) + +Enhancements: + +* Support `do..end` style block with `raise_error` matcher. (Yuji Nakayama) +* Rewrote custom matcher DSL to simplify its implementation and solve a + few issues. (Myron Marston) +* Allow early `return` from within custom matcher DSL blocks. (Myron + Marston) +* The custom matcher DSL's `chain` can now accept a block. (Myron + Marston) +* Support setting an expectation on a `raise_error` matcher via a chained + `with_message` method call. (Sam Phippen) + +Bug Fixes: + +* Allow `include` and `match` matchers to be used from within a + DSL-defined custom matcher's `match` block. (Myron Marston) +* Correct encoding error message on diff failure (Jon Rowe) + +Deprecations: + + * Using the old `:should` syntax without explicitly configuring it is deprecated. + It will continue to work but will emit a deprecation warning in RSpec 3 if + you do not explicitly enable it. (Sam Phippen) + +### 2.99.2 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.1...v2.99.2) + +Bug Fixes: + +* Fix regression in `Expectations#method_handle_for` where proxy objects + with method delegated would wrongly not return a method handle. + (Jon Rowe, #594) +* Fix issue with detection of generic operator matchers so they work + correctly when undefined. (Myron Marston, #597) + +### 2.99.1 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0...v2.99.1) + +Bug Fixes: + +* Fix typo in custom matcher `expected` deprecation warning -- it's + `expected_as_array`, not `expected_array`. (Frederick Cheung, #562) + +### 2.99.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.rc1...v2.99.0) + +Enhancements: + +* Special case deprecation message for `errors_on` with `rspec-rails` to be more useful. + (Aaron Kromer) + +### 2.99.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.beta2...2.99.0.rc1) + +Deprecations: + +* Deprecate `matcher_execution_context` attribute on DSL-defined + custom matchers. (Myron Marston) +* Deprecate `RSpec::Matchers::Pretty#_pretty_print`. (Myron Marston) +* Deprecate `RSpec::Matchers::Pretty#expected_to_sentence`. (Myron Marston) +* Deprecate `RSpec::Matchers::Configuration` in favor of + `RSpec::Expectations::Configuration`. (Myron Marston) +* Deprecate `be_xyz` predicate matcher on an object that doesn't respond to + `xyz?` or `xyzs?`. (Daniel Fone) +* Deprecate `have_xyz` matcher on an object that doesn't respond to `has_xyz?`. + (Daniel Fone) +* Deprecate `have_xyz` matcher on an object that has a private method `has_xyz?`. + (Jon Rowe) +* Issue a deprecation warning when a block expectation expression is + used with a matcher that doesn't explicitly support block expectations + via `supports_block_expectations?`. (Myron Marston) +* Deprecate `require 'rspec-expectations'`. Use + `require 'rspec/expectations'` instead. (Myron Marston) + +### 2.99.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.beta1...v2.99.0.beta2) + +Deprecations: + +* Deprecate chaining `by`, `by_at_least`, `by_at_most` or `to` off of + `expect { }.not_to change { }`. The docs have always said these are + not supported for the negative form but now they explicitly raise + errors in RSpec 3. (Myron Marston) +* Change the semantics of `expect { }.not_to change { x }.from(y)`. + In RSpec 2.x, this expectation would only fail if `x` started with + the value of `y` and changed. If it started with a different value + and changed, it would pass. In RSpec 3, it will pass only if the + value starts at `y` and it does not change. (Myron Marston) +* Deprecate `matcher == value` as an alias for `matcher.matches?(value)`, + in favor of `matcher === value`. (Myron Marston) +* Deprecate `RSpec::Matchers::OperatorMatcher` in favor of + `RSpec::Matchers::BuiltIn::OperatorMatcher`. (Myron Marston) +* Deprecate auto-integration with Test::Unit and minitest. + Instead, include `RSpec::Matchers` in the appropriate test case + base class yourself. (Myron Marston) +* Deprecate treating `#expected` on a DSL-generated custom matcher + as an array when only 1 argument is passed to the matcher method. + In RSpec 3 it will be the single value in order to make diffs + work properly. (Jon Rowe) + +### 2.99.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.4...v2.99.0.beta1) + +Deprecations + +* Deprecate `have`, `have_at_least` and `have_at_most`. You can continue using those + matchers through https://github.com/rspec/rspec-collection_matchers, or + you can rewrite your expectations with something like + `expect(your_object.size).to eq(num)`. (Hugo Baraúna) +* Deprecate `be_xyz` predicate matcher when `xyz?` is a private method. + (Jon Rowe) +* Deprecate `be_true`/`be_false` in favour of `be_truthy`/`be_falsey` + (for Ruby's conditional semantics) or `be true`/`be false` + (for exact equality). (Sam Phippen) +* Deprecate calling helper methods from a custom matcher with the wrong + scope. (Myron Marston) + * `def self.foo` / `extend Helper` can be used to add macro methods + (e.g. methods that call the custom matcher DSL methods), but should + not be used to define helper methods called from within the DSL + blocks. + * `def foo` / `include Helper` is the opposite: it's for helper methods + callable from within a DSL block, but not for defining macros. + * RSpec 2.x allowed helper methods defined either way to be used for + either purpose, but RSpec 3.0 will not. + +### 2.14.5 / 2014-02-01 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.4...v2.14.5) + +Bug fixes + +* Fix wrong matcher descriptions with falsey expected value + (yujinakayama) + +### 2.14.4 / 2013-11-06 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.3...v2.14.4) + +Bug fixes + +* Make the `match` matcher produce a diff output. (Jon Rowe, Ben Moss) +* Choose encoding for diff's more intelligently, and when all else fails fall + back to default internal encoding with replacing characters. (Jon Rowe) + +### 2.14.3 / 2013-09-22 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.2...v2.14.3) + +Bug fixes + +* Fix operator matchers (`should` syntax) when `method` is redefined on target. + (Brandon Turner) +* Fix diffing of hashes with object based keys. (Jon Rowe) +* Fix operator matchers (`should` syntax) when operator is defined via + `method_missing` (Jon Rowe) + +### 2.14.2 / 2013-08-14 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.1...v2.14.2) + +Bug fixes + +* Fix `be_` matcher to not support operator chaining like the + `be` matcher does (e.g. `be == 5`). This led to some odd behaviors + since `be_ == anything` returned a `BeComparedTo` matcher + and was thus always truthy. This was a consequence of the implementation + (e.g. subclassing the basic `Be` matcher) and was not intended behavior. + (Myron Marston). +* Fix `change` matcher to compare using `==` in addition to `===`. This + is important for an expression like: + `expect {}.to change { a.class }.from(ClassA).to(ClassB)` because + `SomeClass === SomeClass` returns false. (Myron Marston) + +### 2.14.1 / 2013-08-08 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0...2.14.1) + +Bug fixes + +* Ensure diff output uses the same encoding as the encoding of + the string being diff'd to prevent `Encoding::UndefinedConversionError` + errors (Jon Rowe). + +### 2.14.0 / 2013-07-06 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0.rc1...v2.14.0) + +Bug fixes + +* Values that are not matchers use `#inspect`, rather than `#description` for + documentation output (Andy Lindeman, Sam Phippen). +* Make `expect(a).to be_within(x).percent_of(y)` work with negative y + (Katsuhiko Nishimra). +* Make the `be_predicate` matcher work as expected used with `expect{...}.to + change...` (Sam Phippen). + +### 2.14.0.rc1 / 2013-05-27 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.13.0...v2.14.0.rc1) + +Enhancements + +* Enhance `yield_control` so that you can specify an exact or relative + number of times: `expect { }.to yield_control.exactly(3).times`, + `expect { }.to yield_control.at_least(2).times`, etc (Bartek + Borkowski). +* Make the differ that is used when an expectation fails better handle arrays + by splitting each element of the array onto its own line. (Sam Phippen) +* Accept duck-typed strings that respond to `:to_str` as expectation messages. + (Toby Ovod-Everett) + +Bug fixes + +* Fix differ to not raise errors when dealing with differently-encoded + strings (Jon Rowe). +* Fix `expect(something).to be_within(x).percent_of(y)` where x and y are both + integers (Sam Phippen). +* Fix `have` matcher to handle the fact that on ruby 2.0, + `Enumerator#size` may return nil (Kenta Murata). +* Fix `expect { raise s }.to raise_error(s)` where s is an error instance + on ruby 2.0 (Sam Phippen). +* Fix `expect(object).to raise_error` passing. This now warns the user and + fails the spec (tomykaira). + +Deprecations + +* Deprecate `expect { }.not_to raise_error(SpecificErrorClass)` or + `expect { }.not_to raise_error("some specific message")`. Using + these was prone to hiding failures as they would allow _any other + error_ to pass. (Sam Phippen and David Chelimsky) + +### 2.13.0 / 2013-02-23 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.1...v2.13.0) + +Enhancements + +* Add support for percent deltas to `be_within` matcher: + `expect(value).to be_within(10).percent_of(expected)` + (Myron Marston). +* Add support to `include` matcher to allow it to be given a list + of matchers as the expecteds to match against (Luke Redpath). + +Bug fixes + +* Fix `change` matcher so that it dups strings in order to handle + mutated strings (Myron Marston). +* Fix `should be =~ /some regex/` / `expect(...).to be =~ /some regex/`. + Previously, these either failed with a confusing `undefined method + matches?' for false:FalseClass` error or were no-ops that didn't + actually verify anything (Myron Marston). +* Add compatibility for diff-lcs 1.2 and relax the version + constraint (Peter Goldstein). +* Fix DSL-generated matchers to allow multiple instances of the + same matcher in the same example to have different description + and failure messages based on the expected value (Myron Marston). +* Prevent `undefined method #split for Array` error when dumping + the diff of an array of multiline strings (Myron Marston). +* Don't blow up when comparing strings that are in an encoding + that is not ASCII compatible (Myron Marston). +* Remove confusing "Check the implementation of #==" message + printed for empty diffs (Myron Marston). + +### 2.12.1 / 2012-12-15 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.0...v2.12.1) + +Bug fixes + +* Improve the failure message for an expression like + `{}.should =~ {}`. (Myron Marston and Andy Lindeman) +* Provide a `match_regex` alias so that custom matchers + built using the matcher DSL can use it (since `match` + is a different method in that context). + (Steven Harman) + +### 2.12.0 / 2012-11-12 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.3...v2.12.0) + +Enhancements + +* Colorize diffs if the `--color` option is configured. (Alex Coplan) +* Include backtraces in unexpected errors handled by `raise_error` + matcher (Myron Marston) +* Print a warning when users accidentally pass a non-string argument + as an expectation message (Sam Phippen) +* `=~` and `match_array` matchers output a more useful error message when + the actual value is not an array (or an object that responds to `#to_ary`) + (Sam Phippen) + +Bug fixes + +* Fix `include` matcher so that `expect({}).to include(:a => nil)` + fails as it should (Sam Phippen). +* Fix `be_an_instance_of` matcher so that `Class#to_s` is used in the + description rather than `Class#inspect`, since some classes (like + `ActiveRecord::Base`) define a long, verbose `#inspect`. + (Tom Stuart) + +### 2.11.3 / 2012-09-04 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.2...v2.11.3) + +Bug fixes + +* Fix (and deprecate) `expect { }.should` syntax so that it works even + though it was never a documented or intended syntax. It worked as a + consequence of the implementation of `expect` in RSpec 2.10 and + earlier. (Myron Marston) +* Ensure #== is defined on built in matchers so that they can be composed. + For example: + + expect { + user.emailed! + }.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now) + +### 2.11.2 / 2012-07-25 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.1...v2.11.2) + +Bug fixes + +* Define `should` and `should_not` on `Object` rather than `BasicObject` + on MacRuby. On MacRuby, `BasicObject` is defined but is not the root + of the object hierarchy. (Gabriel Gilder) + +### 2.11.1 / 2012-07-08 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.0...v2.11.1) + +Bug fixes + +* Constrain `actual` in `be_within` matcher to values that respond to `-` instead + of requiring a specific type. + * `Time`, for example, is a legit alternative. + +### 2.11.0 / 2012-07-07 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.10.0...v2.11.0) + +Enhancements + +* Expand `expect` syntax so that it supports expections on bare values + in addition to blocks (Myron Marston). +* Add configuration options to control available expectation syntaxes + (Myron Marston): + * `RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :expect }` + * `RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :should }` + * `RSpec.configuration.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }` + * `RSpec.configuration.add_should_and_should_not_to Delegator` + +Bug fixes + +* Allow only `Numeric` values to be the "actual" in the `be_within` matcher. + This prevents confusing error messages. (Su Zhang @zhangsu) +* Define `should` and `should_not` on `BasicObject` rather than `Kernel` + on 1.9. This makes `should` and `should_not` work properly with + `BasicObject`-subclassed proxy objects like `Delegator`. (Myron + Marston) + +### 2.10.0 / 2012-05-03 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.1...v2.10.0) + +Enhancements + +* Add new `start_with` and `end_with` matchers (Jeremy Wadsack) +* Add new matchers for specifying yields (Myron Marston): + * `expect {...}.to yield_control` + * `expect {...}.to yield_with_args(1, 2, 3)` + * `expect {...}.to yield_with_no_args` + * `expect {...}.to yield_successive_args(1, 2, 3)` +* `match_unless_raises` takes multiple exception args + +Bug fixes + +* Fix `be_within` matcher to be inclusive of delta. +* Fix message-specific specs to pass on Rubinius (John Firebaugh) + +### 2.9.1 / 2012-04-03 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.0...v2.9.1) + +Bug fixes + +* Provide a helpful message if the diff between two objects is empty. +* Fix bug diffing single strings with multiline strings. +* Fix for error with using custom matchers inside other custom matchers + (mirasrael) +* Fix using execution context methods in nested DSL matchers (mirasrael) + +### 2.9.0 / 2012-03-17 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0...v2.9.0) + +Enhancements + +* Move built-in matcher classes to RSpec::Matchers::BuiltIn to reduce pollution + of RSpec::Matchers (which is included in every example). +* Autoload files with matcher classes to improve load time. + +Bug fixes + +* Align `respond_to?` and `method_missing` in DSL-defined matchers. +* Clear out user-defined instance variables between invocations of DSL-defined + matchers. +* Dup the instance of a DSL generated matcher so its state is not changed by + subsequent invocations. +* Treat expected args consistently across positive and negative expectations + (thanks to Ralf Kistner for the heads up) + +### 2.8.0 / 2012-01-04 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc2...v2.8.0) + +Enhancements + +* Better diff output for Hash (Philippe Creux) +* Eliminate Ruby warnings (Olek Janiszewski) + +### 2.8.0.rc2 / 2011-12-19 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc1...v2.8.0.rc2) + +No changes for this release. Just releasing with the other rspec gems. + +### 2.8.0.rc1 / 2011-11-06 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.7.0...v2.8.0.rc1) + +Enhancements + +* Use classes for the built-in matchers (they're faster). +* Eliminate Ruby warnings (Matijs van Zuijlen) + +### 2.7.0 / 2011-10-16 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.6.0...v2.7.0) + +Enhancements + +* `HaveMatcher` converts argument using `to_i` (Alex Bepple & Pat Maddox) +* Improved failure message for the `have_xxx` matcher (Myron Marston) +* `HaveMatcher` supports `count` (Matthew Bellantoni) +* Change matcher dups `Enumerable` before the action, supporting custom + `Enumerable` types like `CollectionProxy` in Rails (David Chelimsky) + +Bug fixes + +* Fix typo in `have(n).xyz` documentation (Jean Boussier) +* fix `safe_sort` for ruby 1.9.2 (`Kernel` now defines `<=>` for Object) (Peter + van Hardenberg) + +### 2.6.0 / 2011-05-12 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.5.0...v2.6.0) + +Enhancements + +* `change` matcher accepts regexps (Robert Davis) +* better descriptions for `have_xxx` matchers (Magnus Bergmark) +* `range.should cover(*values)` (Anders Furseth) + +Bug fixes + +* Removed non-ascii characters that were choking rcov (Geoffrey Byers) +* change matcher dups arrays and hashes so their before/after states can be + compared correctly. +* Fix the order of inclusion of RSpec::Matchers in Test::Unit::TestCase and + MiniTest::Unit::TestCase to prevent a SystemStackError (Myron Marston) + +### 2.5.0 / 2011-02-05 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.4.0...v2.5.0) + +Enhancements + +* `should exist` works with `exist?` or `exists?` (Myron Marston) +* `expect { ... }.not_to do_something` (in addition to `to_not`) + +Documentation + +* improved docs for raise_error matcher (James Almond) + +### 2.4.0 / 2011-01-02 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.3.0...v2.4.0) + +No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release. + +Enhancements + +* improved RDoc for change matcher (Jo Liss) + +### 2.3.0 / 2010-12-12 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.2.1...v2.3.0) + +Enhancements + +* diff strings when include matcher fails (Mike Sassak) + +### 2.2.0 / 2010-11-28 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.1.0...v2.2.0) + +### 2.1.0 / 2010-11-07 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.1...v2.1.0) + +Enhancements + +* `be_within(delta).of(expected)` matcher (Myron Marston) +* Lots of new Cucumber features (Myron Marston) +* Raise error if you try `should != expected` on Ruby-1.9 (Myron Marston) +* Improved failure messages from `throw_symbol` (Myron Marston) + +Bug fixes + +* Eliminate hard dependency on `RSpec::Core` (Myron Marston) +* `have_matcher` - use pluralize only when ActiveSupport inflections are indeed + defined (Josep M Bach) +* throw_symbol matcher no longer swallows exceptions (Myron Marston) +* fix matcher chaining to avoid name collisions (Myron Marston) + +### 2.0.0 / 2010-10-10 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.rc...v2.0.0) + +Enhancements + +* Add match_for_should_not method to matcher DSL (Myron Marston) + +Bug fixes + +* `respond_to` matcher works correctly with `should_not` with multiple methods + (Myron Marston) +* `include` matcher works correctly with `should_not` with multiple values + (Myron Marston) + +### 2.0.0.rc / 2010-10-05 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.22...v2.0.0.rc) + +Enhancements + +* `require 'rspec/expectations'` in a T::U or MiniUnit suite (Josep M. Bach) + +Bug fixes + +* change by 0 passes/fails correctly (Len Smith) +* Add description to satisfy matcher + +### 2.0.0.beta.22 / 2010-09-12 + +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.20...v2.0.0.beta.22) + +Enhancements + +* diffing improvements + * diff multiline strings + * don't diff single line strings + * don't diff numbers (silly) + * diff regexp + multiline string + +Bug fixes + * `should[_not]` change now handles boolean values correctly diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/License.txt b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/License.txt new file mode 100644 index 000000000..91cfc94f6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/License.txt @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2012 David Chelimsky, Myron Marston +Copyright (c) 2006 David Chelimsky, The RSpec Development Team +Copyright (c) 2005 Steven Baker + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/README.md b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/README.md new file mode 100644 index 000000000..cd47ab7ab --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/README.md @@ -0,0 +1,278 @@ +# RSpec Expectations [![Build Status](https://secure.travis-ci.org/rspec/rspec-expectations.png?branch=master)](http://travis-ci.org/rspec/rspec-expectations) [![Code Climate](https://codeclimate.com/github/rspec/rspec-expectations.png)](https://codeclimate.com/github/rspec/rspec-expectations) + +RSpec::Expectations lets you express expected outcomes on an object in an +example. + + expect(account.balance).to eq(Money.new(37.42, :USD)) + +## Install + +If you want to use rspec-expectations with rspec, just install the rspec gem +and RubyGems will also install rspec-expectations for you (along with +rspec-core and rspec-mocks): + + gem install rspec + +If you want to use rspec-expectations with another tool, like Test::Unit, +Minitest, or Cucumber, you can install it directly: + + gem install rspec-expectations + +## Basic usage + +Here's an example using rspec-core: + +```ruby +RSpec.describe Order do + it "sums the prices of the items in its line items" do + order = Order.new + order.add_entry(LineItem.new(:item => Item.new( + :price => Money.new(1.11, :USD) + ))) + order.add_entry(LineItem.new(:item => Item.new( + :price => Money.new(2.22, :USD), + :quantity => 2 + ))) + expect(order.total).to eq(Money.new(5.55, :USD)) + end +end +``` + +The `describe` and `it` methods come from rspec-core. The `Order`, `LineItem`, `Item` and `Money` classes would be from _your_ code. The last line of the example +expresses an expected outcome. If `order.total == Money.new(5.55, :USD)`, then +the example passes. If not, it fails with a message like: + + expected: # + got: # + +## Built-in matchers + +### Equivalence + +```ruby +expect(actual).to eq(expected) # passes if actual == expected +expect(actual).to eql(expected) # passes if actual.eql?(expected) +``` + +Note: The new `expect` syntax no longer supports the `==` matcher. + +### Identity + +```ruby +expect(actual).to be(expected) # passes if actual.equal?(expected) +expect(actual).to equal(expected) # passes if actual.equal?(expected) +``` + +### Comparisons + +```ruby +expect(actual).to be > expected +expect(actual).to be >= expected +expect(actual).to be <= expected +expect(actual).to be < expected +expect(actual).to be_within(delta).of(expected) +``` + +### Regular expressions + +```ruby +expect(actual).to match(/expression/) +``` + +Note: The new `expect` syntax no longer supports the `=~` matcher. + +### Types/classes + +```ruby +expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected +expect(actual).to be_a(expected) # passes if actual.is_a?(expected) +expect(actual).to be_an(expected) # an alias for be_a +expect(actual).to be_a_kind_of(expected) # another alias +``` + +### Truthiness + +```ruby +expect(actual).to be_truthy # passes if actual is truthy (not nil or false) +expect(actual).to be true # passes if actual == true +expect(actual).to be_falsy # passes if actual is falsy (nil or false) +expect(actual).to be false # passes if actual == false +expect(actual).to be_nil # passes if actual is nil +``` + +### Expecting errors + +```ruby +expect { ... }.to raise_error +expect { ... }.to raise_error(ErrorClass) +expect { ... }.to raise_error("message") +expect { ... }.to raise_error(ErrorClass, "message") +``` + +### Expecting throws + +```ruby +expect { ... }.to throw_symbol +expect { ... }.to throw_symbol(:symbol) +expect { ... }.to throw_symbol(:symbol, 'value') +``` + +### Yielding + +```ruby +expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args + +expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded + +expect { |b| 5.tap(&b) }.to yield_with_args(5) +expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) +expect { |b| "a string".tap(&b) }.to yield_with_args(/str/) + +expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3) +expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2]) +``` + +### Predicate matchers + +```ruby +expect(actual).to be_xxx # passes if actual.xxx? +expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg) +``` + +### Ranges (Ruby >= 1.9 only) + +```ruby +expect(1..10).to cover(3) +``` + +### Collection membership + +```ruby +expect(actual).to include(expected) +expect(actual).to start_with(expected) +expect(actual).to end_with(expected) + +expect(actual).to contain_exactly(individual, items) +# ...which is the same as: +expect(actual).to match_array(expected_array) +``` + +#### Examples + +```ruby +expect([1, 2, 3]).to include(1) +expect([1, 2, 3]).to include(1, 2) +expect([1, 2, 3]).to start_with(1) +expect([1, 2, 3]).to start_with(1, 2) +expect([1, 2, 3]).to end_with(3) +expect([1, 2, 3]).to end_with(2, 3) +expect({:a => 'b'}).to include(:a => 'b') +expect("this string").to include("is str") +expect("this string").to start_with("this") +expect("this string").to end_with("ring") +expect([1, 2, 3]).to contain_exactly(2, 3, 1) +expect([1, 2, 3]).to match_array([3, 2, 1]) +``` + +## `should` syntax + +In addition to the `expect` syntax, rspec-expectations continues to support the +`should` syntax: + +```ruby +actual.should eq expected +actual.should be > 3 +[1, 2, 3].should_not include 4 +``` + +See [detailed information on the `should` syntax and its usage.](https://github.com/rspec/rspec-expectations/blob/master/Should.md) + +## Compound Matcher Expressions + +You can also create compound matcher expressions using `and` or `or`: + +``` ruby +expect(alphabet).to start_with("a").and end_with("z") +expect(stoplight.color).to eq("red").or eq("green").or eq("yellow") +``` + +## Composing Matchers + +Many of the built-in matchers are designed to take matchers as +arguments, to allow you to flexibly specify only the essential +aspects of an object or data structure. In addition, all of the +built-in matchers have one or more aliases that provide better +phrasing for when they are used as arguments to another matcher. + +### Examples + +```ruby +expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) ) + +expect { s = "barn" }.to change { s } + .from( a_string_matching(/foo/) ) + .to( a_string_matching(/bar/) ) + +expect(["barn", 2.45]).to contain_exactly( + a_value_within(0.1).of(2.5), + a_string_starting_with("bar") +) + +expect(["barn", "food", 2.45]).to end_with( + a_string_matching("foo"), + a_value > 2 +) + +expect(["barn", 2.45]).to include( a_string_starting_with("bar") ) + +expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/)) + +hash = { + :a => { + :b => ["foo", 5], + :c => { :d => 2.05 } + } +} + +expect(hash).to match( + :a => { + :b => a_collection_containing_exactly( + a_string_starting_with("f"), + an_instance_of(Fixnum) + ), + :c => { :d => (a_value < 3) } + } +) + +expect { |probe| + [1, 2, 3].each(&probe) +}.to yield_successive_args( a_value < 2, 2, a_value > 2 ) +``` + +## Usage outside rspec-core + +You always need to load `rspec/expectations` even if you only want to use one part of the library: + +```ruby +require 'rspec/expectations' +``` + +Then simply include `RSpec::Matchers` in any class: + +```ruby +class MyClass + include RSpec::Matchers + + def do_something(arg) + expect(arg).to be > 0 + # do other stuff + end +end +``` + +## Also see + +* [http://github.com/rspec/rspec](http://github.com/rspec/rspec) +* [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core) +* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks) +* [http://github.com/rspec/rspec-collection_matchers](https://github.com/rspec/rspec-collection_matchers) diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations.rb new file mode 100644 index 000000000..834c8f77f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations.rb @@ -0,0 +1,68 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support "caller_filter" +RSpec::Support.require_rspec_support "warnings" + +require 'rspec/matchers' + +RSpec::Support.define_optimized_require_for_rspec(:expectations) { |f| require_relative(f) } + +%w[ + expectation_target + configuration + fail_with + handler + version +].each { |file| RSpec::Support.require_rspec_expectations(file) } + +module RSpec + # RSpec::Expectations provides a simple, readable API to express + # the expected outcomes in a code example. To express an expected + # outcome, wrap an object or block in `expect`, call `to` or `to_not` + # (aliased as `not_to`) and pass it a matcher object: + # + # expect(order.total).to eq(Money.new(5.55, :USD)) + # expect(list).to include(user) + # expect(message).not_to match(/foo/) + # expect { do_something }.to raise_error + # + # The last form (the block form) is needed to match against ruby constructs + # that are not objects, but can only be observed when executing a block + # of code. This includes raising errors, throwing symbols, yielding, + # and changing values. + # + # When `expect(...).to` is invoked with a matcher, it turns around + # and calls `matcher.matches?()`. For example, + # in the expression: + # + # expect(order.total).to eq(Money.new(5.55, :USD)) + # + # ...`eq(Money.new(5.55, :USD))` returns a matcher object, and it results + # in the equivalent of `eq.matches?(order.total)`. If `matches?` returns + # `true`, the expectation is met and execution continues. If `false`, then + # the spec fails with the message returned by `eq.failure_message`. + # + # Given the expression: + # + # expect(order.entries).not_to include(entry) + # + # ...the `not_to` method (also available as `to_not`) invokes the equivalent of + # `include.matches?(order.entries)`, but it interprets `false` as success, and + # `true` as a failure, using the message generated by + # `include.failure_message_when_negated`. + # + # rspec-expectations ships with a standard set of useful matchers, and writing + # your own matchers is quite simple. + # + # See [RSpec::Matchers](../RSpec/Matchers) for more information about the + # built-in matchers that ship with rspec-expectations, and how to write your + # own custom matchers. + module Expectations + # Exception raised when an expectation fails. + # + # @note We subclass Exception so that in a stub implementation if + # the user sets an expectation, it can't be caught in their + # code by a bare `rescue`. + # @api public + ExpectationNotMetError = Class.new(::Exception) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/configuration.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/configuration.rb new file mode 100644 index 000000000..c5156cd03 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/configuration.rb @@ -0,0 +1,147 @@ +RSpec::Support.require_rspec_expectations "syntax" + +module RSpec + module Expectations + # Provides configuration options for rspec-expectations. + # If you are using rspec-core, you can access this via a + # block passed to `RSpec::Core::Configuration#expect_with`. + # Otherwise, you can access it via RSpec::Expectations.configuration. + # + # @example + # RSpec.configure do |rspec| + # rspec.expect_with :rspec do |c| + # # c is the config object + # end + # end + # + # # or + # + # RSpec::Expectations.configuration + class Configuration + # Configures the supported syntax. + # @param [Array, Symbol] values the syntaxes to enable + # @example + # RSpec.configure do |rspec| + # rspec.expect_with :rspec do |c| + # c.syntax = :should + # # or + # c.syntax = :expect + # # or + # c.syntax = [:should, :expect] + # end + # end + def syntax=(values) + if Array(values).include?(:expect) + Expectations::Syntax.enable_expect + else + Expectations::Syntax.disable_expect + end + + if Array(values).include?(:should) + Expectations::Syntax.enable_should + else + Expectations::Syntax.disable_should + end + end + + # The list of configured syntaxes. + # @return [Array] the list of configured syntaxes. + # @example + # unless RSpec::Matchers.configuration.syntax.include?(:expect) + # raise "this RSpec extension gem requires the rspec-expectations `:expect` syntax" + # end + def syntax + syntaxes = [] + syntaxes << :should if Expectations::Syntax.should_enabled? + syntaxes << :expect if Expectations::Syntax.expect_enabled? + syntaxes + end + + if ::RSpec.respond_to?(:configuration) + def color? + ::RSpec.configuration.color_enabled? + end + else + # Indicates whether or not diffs should be colored. + # Delegates to rspec-core's color option if rspec-core + # is loaded; otherwise you can set it here. + attr_writer :color + + # Indicates whether or not diffs should be colored. + # Delegates to rspec-core's color option if rspec-core + # is loaded; otherwise you can set it here. + def color? + @color + end + end + + # Adds `should` and `should_not` to the given classes + # or modules. This can be used to ensure `should` works + # properly on things like proxy objects (particular + # `Delegator`-subclassed objects on 1.8). + # + # @param [Array] modules the list of classes or modules + # to add `should` and `should_not` to. + def add_should_and_should_not_to(*modules) + modules.each do |mod| + Expectations::Syntax.enable_should(mod) + end + end + + # Sets or gets the backtrace formatter. The backtrace formatter should + # implement `#format_backtrace(Array)`. This is used + # to format backtraces of errors handled by the `raise_error` + # matcher. + # + # If you are using rspec-core, rspec-core's backtrace formatting + # will be used (including respecting the presence or absence of + # the `--backtrace` option). + # + # @!attribute [rw] backtrace_formatter + attr_writer :backtrace_formatter + def backtrace_formatter + @backtrace_formatter ||= if defined?(::RSpec.configuration.backtrace_formatter) + ::RSpec.configuration.backtrace_formatter + else + NullBacktraceFormatter + end + end + + # Sets if custom matcher descriptions and failure messages + # should include clauses from methods defined using `chain`. + # @param value [Boolean] + attr_writer :include_chain_clauses_in_custom_matcher_descriptions + + # Indicates whether or not custom matcher descriptions and failure messages + # should include clauses from methods defined using `chain`. It is + # false by default for backwards compatibility. + def include_chain_clauses_in_custom_matcher_descriptions? + @include_chain_clauses_in_custom_matcher_descriptions ||= false + end + + # @private + def reset_syntaxes_to_default + self.syntax = [:should, :expect] + RSpec::Expectations::Syntax.warn_about_should! + end + + # @api private + # Null implementation of a backtrace formatter used by default + # when rspec-core is not loaded. Does no filtering. + NullBacktraceFormatter = Module.new do + def self.format_backtrace(backtrace) + backtrace + end + end + end + + # The configuration object. + # @return [RSpec::Expectations::Configuration] the configuration object + def self.configuration + @configuration ||= Configuration.new + end + + # set default syntax + configuration.reset_syntaxes_to_default + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/expectation_target.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/expectation_target.rb new file mode 100644 index 000000000..cc74c1977 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/expectation_target.rb @@ -0,0 +1,119 @@ +module RSpec + module Expectations + # Wraps the target of an expectation. + # + # @example + # expect(something) # => ExpectationTarget wrapping something + # expect { do_something } # => ExpectationTarget wrapping the block + # + # # used with `to` + # expect(actual).to eq(3) + # + # # with `not_to` + # expect(actual).not_to eq(3) + # + # @note `ExpectationTarget` is not intended to be instantiated + # directly by users. Use `expect` instead. + class ExpectationTarget + # @private + # Used as a sentinel value to be able to tell when the user + # did not pass an argument. We can't use `nil` for that because + # `nil` is a valid value to pass. + UndefinedValue = Module.new + + # @api private + def initialize(value) + @target = value + end + + # @private + def self.for(value, block) + if UndefinedValue.equal?(value) + unless block + raise ArgumentError, "You must pass either an argument or a block to `expect`." + end + BlockExpectationTarget.new(block) + elsif block + raise ArgumentError, "You cannot pass both an argument and a block to `expect`." + else + new(value) + end + end + + # Runs the given expectation, passing if `matcher` returns true. + # @example + # expect(value).to eq(5) + # expect { perform }.to raise_error + # @param [Matcher] + # matcher + # @param [String or Proc] message optional message to display when the expectation fails + # @return [Boolean] true if the expectation succeeds (else raises) + # @see RSpec::Matchers + def to(matcher=nil, message=nil, &block) + prevent_operator_matchers(:to) unless matcher + RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@target, matcher, message, &block) + end + + # Runs the given expectation, passing if `matcher` returns false. + # @example + # expect(value).not_to eq(5) + # @param [Matcher] + # matcher + # @param [String or Proc] message optional message to display when the expectation fails + # @return [Boolean] false if the negative expectation succeeds (else raises) + # @see RSpec::Matchers + def not_to(matcher=nil, message=nil, &block) + prevent_operator_matchers(:not_to) unless matcher + RSpec::Expectations::NegativeExpectationHandler.handle_matcher(@target, matcher, message, &block) + end + alias to_not not_to + + private + + def prevent_operator_matchers(verb) + raise ArgumentError, "The expect syntax does not support operator matchers, " \ + "so you must pass a matcher to `##{verb}`." + end + end + + # @private + # Validates the provided matcher to ensure it supports block + # expectations, in order to avoid user confusion when they + # use a block thinking the expectation will be on the return + # value of the block rather than the block itself. + class BlockExpectationTarget < ExpectationTarget + def to(matcher, message=nil, &block) + enforce_block_expectation(matcher) + super + end + + def not_to(matcher, message=nil, &block) + enforce_block_expectation(matcher) + super + end + alias to_not not_to + + private + + def enforce_block_expectation(matcher) + return if supports_block_expectations?(matcher) + + raise ExpectationNotMetError, "You must pass an argument rather than " \ + "a block to use the provided matcher (#{description_of matcher}), or " \ + "the matcher must implement `supports_block_expectations?`." + end + + def supports_block_expectations?(matcher) + matcher.supports_block_expectations? + rescue NoMethodError + false + end + + def description_of(matcher) + matcher.description + rescue NoMethodError + matcher.inspect + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/fail_with.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/fail_with.rb new file mode 100644 index 000000000..057c3091d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/fail_with.rb @@ -0,0 +1,34 @@ +RSpec::Support.require_rspec_support 'differ' + +module RSpec + module Expectations + class << self + # @private + def differ + RSpec::Support::Differ.new( + :object_preparer => lambda { |object| RSpec::Matchers::Composable.surface_descriptions_in(object) }, + :color => RSpec::Matchers.configuration.color? + ) + end + + # Raises an RSpec::Expectations::ExpectationNotMetError with message. + # @param [String] message + # @param [Object] expected + # @param [Object] actual + # + # Adds a diff to the failure message when `expected` and `actual` are + # both present. + def fail_with(message, expected=nil, actual=nil) + unless message + raise ArgumentError, "Failure message is nil. Does your matcher define the " \ + "appropriate failure_message[_when_negated] method to return a string?" + end + + diff = differ.diff(actual, expected) + message = "#{message}\nDiff:#{diff}" unless diff.empty? + + raise RSpec::Expectations::ExpectationNotMetError, message + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/handler.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/handler.rb new file mode 100644 index 000000000..389ed94f9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/handler.rb @@ -0,0 +1,167 @@ +module RSpec + module Expectations + # @private + module ExpectationHelper + def self.check_message(msg) + unless msg.nil? || msg.respond_to?(:to_str) || msg.respond_to?(:call) + ::Kernel.warn [ + "WARNING: ignoring the provided expectation message argument (", + msg.inspect, + ") since it is not a string or a proc." + ].join + end + end + + # Returns an RSpec-3+ compatible matcher, wrapping a legacy one + # in an adapter if necessary. + # + # @private + def self.modern_matcher_from(matcher) + LegacyMatcherAdapter::RSpec2.wrap(matcher) || + LegacyMatcherAdapter::RSpec1.wrap(matcher) || matcher + end + + def self.setup(handler, matcher, message) + check_message(message) + ::RSpec::Matchers.last_expectation_handler = handler + ::RSpec::Matchers.last_matcher = modern_matcher_from(matcher) + end + + def self.handle_failure(matcher, message, failure_message_method) + message = message.call if message.respond_to?(:call) + message ||= matcher.__send__(failure_message_method) + + if matcher.respond_to?(:diffable?) && matcher.diffable? + ::RSpec::Expectations.fail_with message, matcher.expected, matcher.actual + else + ::RSpec::Expectations.fail_with message + end + end + end + + # @private + class PositiveExpectationHandler + def self.handle_matcher(actual, initial_matcher, message=nil, &block) + matcher = ExpectationHelper.setup(self, initial_matcher, message) + + return ::RSpec::Matchers::BuiltIn::PositiveOperatorMatcher.new(actual) unless initial_matcher + matcher.matches?(actual, &block) || ExpectationHelper.handle_failure(matcher, message, :failure_message) + end + + def self.verb + "should" + end + + def self.should_method + :should + end + + def self.opposite_should_method + :should_not + end + end + + # @private + class NegativeExpectationHandler + def self.handle_matcher(actual, initial_matcher, message=nil, &block) + matcher = ExpectationHelper.setup(self, initial_matcher, message) + + return ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(actual) unless initial_matcher + !(does_not_match?(matcher, actual, &block) || ExpectationHelper.handle_failure(matcher, message, :failure_message_when_negated)) + end + + def self.does_not_match?(matcher, actual, &block) + if matcher.respond_to?(:does_not_match?) + matcher.does_not_match?(actual, &block) + else + !matcher.matches?(actual, &block) + end + end + + def self.verb + "should not" + end + + def self.should_method + :should_not + end + + def self.opposite_should_method + :should + end + end + + # Wraps a matcher written against one of the legacy protocols in + # order to present the current protocol. + # + # @private + class LegacyMatcherAdapter < Matchers::MatcherDelegator + def initialize(matcher) + super + ::RSpec.warn_deprecation(<<-EOS.gsub(/^\s+\|/, ''), :type => "legacy_matcher") + |#{matcher.class.name || matcher.inspect} implements a legacy RSpec matcher + |protocol. For the current protocol you should expose the failure messages + |via the `failure_message` and `failure_message_when_negated` methods. + |(Used from #{CallerFilter.first_non_rspec_line}) + EOS + end + + def self.wrap(matcher) + new(matcher) if interface_matches?(matcher) + end + + # Starting in RSpec 1.2 (and continuing through all 2.x releases), + # the failure message protocol was: + # * `failure_message_for_should` + # * `failure_message_for_should_not` + # @private + class RSpec2 < self + def failure_message + base_matcher.failure_message_for_should + end + + def failure_message_when_negated + base_matcher.failure_message_for_should_not + end + + def self.interface_matches?(matcher) + ( + !matcher.respond_to?(:failure_message) && + matcher.respond_to?(:failure_message_for_should) + ) || ( + !matcher.respond_to?(:failure_message_when_negated) && + matcher.respond_to?(:failure_message_for_should_not) + ) + end + end + + # Before RSpec 1.2, the failure message protocol was: + # * `failure_message` + # * `negative_failure_message` + # @private + class RSpec1 < self + def failure_message + base_matcher.failure_message + end + + def failure_message_when_negated + base_matcher.negative_failure_message + end + + # Note: `failure_message` is part of the RSpec 3 protocol + # (paired with `failure_message_when_negated`), so we don't check + # for `failure_message` here. + def self.interface_matches?(matcher) + !matcher.respond_to?(:failure_message_when_negated) && + matcher.respond_to?(:negative_failure_message) + end + end + end + + # RSpec 3.0 was released with the class name misspelled. For SemVer compatibility, + # we will provide this misspelled alias until 4.0. + # @deprecated Use LegacyMatcherAdapter instead. + # @private + LegacyMacherAdapter = LegacyMatcherAdapter + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/minitest_integration.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/minitest_integration.rb new file mode 100644 index 000000000..8b9926976 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/minitest_integration.rb @@ -0,0 +1,17 @@ +require 'rspec/expectations' + +Minitest::Test.class_eval do + include ::RSpec::Matchers + + def expect(*a, &b) + assert(true) # so each expectation gets counted in minitest's assertion stats + super + end +end + +module RSpec + module Expectations + remove_const :ExpectationNotMetError + ExpectationNotMetError = ::Minitest::Assertion + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/syntax.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/syntax.rb new file mode 100644 index 000000000..eaf07a248 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/syntax.rb @@ -0,0 +1,132 @@ +module RSpec + module Expectations + # @api private + # Provides methods for enabling and disabling the available + # syntaxes provided by rspec-expectations. + module Syntax + module_function + + # @api private + # Determines where we add `should` and `should_not`. + def default_should_host + @default_should_host ||= ::Object.ancestors.last + end + + # @api private + # Instructs rspec-expectations to warn on first usage of `should` or `should_not`. + # Enabled by default. This is largely here to facilitate testing. + def warn_about_should! + @warn_about_should = true + end + + # @api private + # Generates a deprecation warning for the given method if no warning + # has already been issued. + def warn_about_should_unless_configured(method_name) + return unless @warn_about_should + + RSpec.deprecate( + "Using `#{method_name}` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax", + :replacement => "the new `:expect` syntax or explicitly enable `:should`" + ) + + @warn_about_should = false + end + + # @api private + # Enables the `should` syntax. + def enable_should(syntax_host=default_should_host) + @warn_about_should = false if syntax_host == default_should_host + return if should_enabled?(syntax_host) + + syntax_host.module_exec do + def should(matcher=nil, message=nil, &block) + ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__) + ::RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block) + end + + def should_not(matcher=nil, message=nil, &block) + ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__) + ::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block) + end + end + end + + # @api private + # Disables the `should` syntax. + def disable_should(syntax_host=default_should_host) + return unless should_enabled?(syntax_host) + + syntax_host.module_exec do + undef should + undef should_not + end + end + + # @api private + # Enables the `expect` syntax. + def enable_expect(syntax_host=::RSpec::Matchers) + return if expect_enabled?(syntax_host) + + syntax_host.module_exec do + def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block) + ::RSpec::Expectations::ExpectationTarget.for(value, block) + end + end + end + + # @api private + # Disables the `expect` syntax. + def disable_expect(syntax_host=::RSpec::Matchers) + return unless expect_enabled?(syntax_host) + + syntax_host.module_exec do + undef expect + end + end + + # @api private + # Indicates whether or not the `should` syntax is enabled. + def should_enabled?(syntax_host=default_should_host) + syntax_host.method_defined?(:should) + end + + # @api private + # Indicates whether or not the `expect` syntax is enabled. + def expect_enabled?(syntax_host=::RSpec::Matchers) + syntax_host.method_defined?(:expect) + end + end + end +end + +if defined?(BasicObject) + # The legacy `:should` syntax adds the following methods directly to + # `BasicObject` so that they are available off of any object. Note, however, + # that this syntax does not always play nice with delegate/proxy objects. + # We recommend you use the non-monkeypatching `:expect` syntax instead. + class BasicObject + # @method should + # Passes if `matcher` returns true. Available on every `Object`. + # @example + # actual.should eq expected + # actual.should match /expression/ + # @param [Matcher] + # matcher + # @param [String] message optional message to display when the expectation fails + # @return [Boolean] true if the expectation succeeds (else raises) + # @note This is only available when you have enabled the `:should` syntax. + # @see RSpec::Matchers + + # @method should_not + # Passes if `matcher` returns false. Available on every `Object`. + # @example + # actual.should_not eq expected + # @param [Matcher] + # matcher + # @param [String] message optional message to display when the expectation fails + # @return [Boolean] false if the negative expectation succeeds (else raises) + # @note This is only available when you have enabled the `:should` syntax. + # @see RSpec::Matchers + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/version.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/version.rb new file mode 100644 index 000000000..38de4651d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/expectations/version.rb @@ -0,0 +1,8 @@ +module RSpec + module Expectations + # @private + module Version + STRING = '3.1.2' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers.rb new file mode 100644 index 000000000..fcf1aafd5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers.rb @@ -0,0 +1,967 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support 'matcher_definition' +RSpec::Support.define_optimized_require_for_rspec(:matchers) { |f| require_relative(f) } + +%w[ + pretty + composable + built_in + generated_descriptions + dsl + matcher_delegator + aliased_matcher +].each { |file| RSpec::Support.require_rspec_matchers(file) } + +# RSpec's top level namespace. All of rspec-expectations is contained +# in the `RSpec::Expectations` and `RSpec::Matchers` namespaces. +module RSpec + # RSpec::Matchers provides a number of useful matchers we use to define + # expectations. Any object that implements the [matcher protocol](Matchers/MatcherProtocol) + # can be used as a matcher. + # + # ## Predicates + # + # In addition to matchers that are defined explicitly, RSpec will create + # custom matchers on the fly for any arbitrary predicate, giving your specs a + # much more natural language feel. + # + # A Ruby predicate is a method that ends with a "?" and returns true or false. + # Common examples are `empty?`, `nil?`, and `instance_of?`. + # + # All you need to do is write `expect(..).to be_` followed by the predicate + # without the question mark, and RSpec will figure it out from there. + # For example: + # + # expect([]).to be_empty # => [].empty?() | passes + # expect([]).not_to be_empty # => [].empty?() | fails + # + # In addtion to prefixing the predicate matchers with "be_", you can also use "be_a_" + # and "be_an_", making your specs read much more naturally: + # + # expect("a string").to be_an_instance_of(String) # =>"a string".instance_of?(String) # passes + # + # expect(3).to be_a_kind_of(Fixnum) # => 3.kind_of?(Numeric) | passes + # expect(3).to be_a_kind_of(Numeric) # => 3.kind_of?(Numeric) | passes + # expect(3).to be_an_instance_of(Fixnum) # => 3.instance_of?(Fixnum) | passes + # expect(3).not_to be_an_instance_of(Numeric) # => 3.instance_of?(Numeric) | fails + # + # RSpec will also create custom matchers for predicates like `has_key?`. To + # use this feature, just state that the object should have_key(:key) and RSpec will + # call has_key?(:key) on the target. For example: + # + # expect(:a => "A").to have_key(:a) + # expect(:a => "A").to have_key(:b) # fails + # + # You can use this feature to invoke any predicate that begins with "has_", whether it is + # part of the Ruby libraries (like `Hash#has_key?`) or a method you wrote on your own class. + # + # Note that RSpec does not provide composable aliases for these dynamic predicate + # matchers. You can easily define your own aliases, though: + # + # RSpec::Matchers.alias_matcher :a_user_who_is_an_admin, :be_an_admin + # expect(user_list).to include(a_user_who_is_an_admin) + # + # ## Custom Matchers + # + # When you find that none of the stock matchers provide a natural feeling + # expectation, you can very easily write your own using RSpec's matcher DSL + # or writing one from scratch. + # + # ### Matcher DSL + # + # Imagine that you are writing a game in which players can be in various + # zones on a virtual board. To specify that bob should be in zone 4, you + # could say: + # + # expect(bob.current_zone).to eql(Zone.new("4")) + # + # But you might find it more expressive to say: + # + # expect(bob).to be_in_zone("4") + # + # and/or + # + # expect(bob).not_to be_in_zone("3") + # + # You can create such a matcher like so: + # + # RSpec::Matchers.define :be_in_zone do |zone| + # match do |player| + # player.in_zone?(zone) + # end + # end + # + # This will generate a be_in_zone method that returns a matcher + # with logical default messages for failures. You can override the failure + # messages and the generated description as follows: + # + # RSpec::Matchers.define :be_in_zone do |zone| + # match do |player| + # player.in_zone?(zone) + # end + # + # failure_message do |player| + # # generate and return the appropriate string. + # end + # + # failure_message_when_negated do |player| + # # generate and return the appropriate string. + # end + # + # description do + # # generate and return the appropriate string. + # end + # end + # + # Each of the message-generation methods has access to the block arguments + # passed to the create method (in this case, zone). The + # failure message methods (failure_message and + # failure_message_when_negated) are passed the actual value (the + # receiver of expect(..) or expect(..).not_to). + # + # ### Custom Matcher from scratch + # + # You could also write a custom matcher from scratch, as follows: + # + # class BeInZone + # def initialize(expected) + # @expected = expected + # end + # + # def matches?(target) + # @target = target + # @target.current_zone.eql?(Zone.new(@expected)) + # end + # + # def failure_message + # "expected #{@target.inspect} to be in Zone #{@expected}" + # end + # + # def failure_message_when_negated + # "expected #{@target.inspect} not to be in Zone #{@expected}" + # end + # end + # + # ... and a method like this: + # + # def be_in_zone(expected) + # BeInZone.new(expected) + # end + # + # And then expose the method to your specs. This is normally done + # by including the method and the class in a module, which is then + # included in your spec: + # + # module CustomGameMatchers + # class BeInZone + # # ... + # end + # + # def be_in_zone(expected) + # # ... + # end + # end + # + # describe "Player behaviour" do + # include CustomGameMatchers + # # ... + # end + # + # or you can include in globally in a spec_helper.rb file required + # from your spec file(s): + # + # RSpec::configure do |config| + # config.include(CustomGameMatchers) + # end + # + # ### Making custom matchers composable + # + # RSpec's built-in matchers are designed to be composed, in expressions like: + # + # expect(["barn", 2.45]).to contain_exactly( + # a_value_within(0.1).of(2.5), + # a_string_starting_with("bar") + # ) + # + # Custom matchers can easily participate in composed matcher expressions like these. + # Include {RSpec::Matchers::Composable} in your custom matcher to make it support + # being composed (matchers defined using the DSL have this included automatically). + # Within your matcher's `matches?` method (or the `match` block, if using the DSL), + # use `values_match?(expected, actual)` rather than `expected == actual`. + # Under the covers, `values_match?` is able to match arbitrary + # nested data structures containing a mix of both matchers and non-matcher objects. + # It uses `===` and `==` to perform the matching, considering the values to + # match if either returns `true`. The `Composable` mixin also provides some helper + # methods for surfacing the matcher descriptions within your matcher's description + # or failure messages. + # + # RSpec's built-in matchers each have a number of aliases that rephrase the matcher + # from a verb phrase (such as `be_within`) to a noun phrase (such as `a_value_within`), + # which reads better when the matcher is passed as an argument in a composed matcher + # expressions, and also uses the noun-phrase wording in the matcher's `description`, + # for readable failure messages. You can alias your custom matchers in similar fashion + # using {RSpec::Matchers.alias_matcher}. + module Matchers + # @method expect + # Supports `expect(actual).to matcher` syntax by wrapping `actual` in an + # `ExpectationTarget`. + # @example + # expect(actual).to eq(expected) + # expect(actual).not_to eq(expected) + # @return [ExpectationTarget] + # @see ExpectationTarget#to + # @see ExpectationTarget#not_to + + # Defines a matcher alias. The returned matcher's `description` will be overriden + # to reflect the phrasing of the new name, which will be used in failure messages + # when passed as an argument to another matcher in a composed matcher expression. + # + # @param new_name [Symbol] the new name for the matcher + # @param old_name [Symbol] the original name for the matcher + # @param options [Hash] options for the aliased matcher + # @option options [Class] :klass the ruby class to use as the decorator. (Not normally used). + # @yield [String] optional block that, when given is used to define the overriden + # description. The yielded arg is the original description. If no block is + # provided, a default description override is used based on the old and + # new names. + # + # @example + # + # RSpec::Matchers.alias_matcher :a_list_that_sums_to, :sum_to + # sum_to(3).description # => "sum to 3" + # a_list_that_sums_to(3).description # => "a list that sums to 3" + # + # @example + # + # RSpec::Matchers.alias_matcher :a_list_sorted_by, :be_sorted_by do |description| + # description.sub("be sorted by", "a list sorted by") + # end + # + # be_sorted_by(:age).description # => "be sorted by age" + # a_list_sorted_by(:age).description # => "a list sorted by age" + # + # @!macro [attach] alias_matcher + # @!parse + # alias $1 $2 + def self.alias_matcher(new_name, old_name, options={}, &description_override) + description_override ||= lambda do |old_desc| + old_desc.gsub(Pretty.split_words(old_name), Pretty.split_words(new_name)) + end + klass = options.fetch(:klass) { AliasedMatcher } + + define_method(new_name) do |*args, &block| + matcher = __send__(old_name, *args, &block) + klass.new(matcher, description_override) + end + end + + # Defines a negated matcher. The returned matcher's `description` and `failure_message` + # will be overriden to reflect the phrasing of the new name, and the match logic will + # be based on the original matcher but negated. + # + # @param negated_name [Symbol] the name for the negated matcher + # @param base_name [Symbol] the name of the original matcher that will be negated + # @yield [String] optional block that, when given is used to define the overriden + # description. The yielded arg is the original description. If no block is + # provided, a default description override is used based on the old and + # new names. + # + # @example + # + # RSpec::Matchers.define_negated_matcher :a_value_not_between, :a_value_between + # a_value_between(3, 5).description # => "a value between 3 and 5" + # a_value_not_between(3, 5).description # => "a value not between 3 and 5" + def self.define_negated_matcher(negated_name, base_name, &description_override) + alias_matcher(negated_name, base_name, :klass => AliasedNegatedMatcher, &description_override) + end + + # Passes if actual is truthy (anything but false or nil) + def be_truthy + BuiltIn::BeTruthy.new + end + alias_matcher :a_truthy_value, :be_truthy + + # Passes if actual is falsey (false or nil) + def be_falsey + BuiltIn::BeFalsey.new + end + alias_matcher :be_falsy, :be_falsey + alias_matcher :a_falsey_value, :be_falsey + alias_matcher :a_falsy_value, :be_falsey + + # Passes if actual is nil + def be_nil + BuiltIn::BeNil.new + end + alias_matcher :a_nil_value, :be_nil + + # @example + # expect(actual).to be_truthy + # expect(actual).to be_falsey + # expect(actual).to be_nil + # expect(actual).to be_[arbitrary_predicate](*args) + # expect(actual).not_to be_nil + # expect(actual).not_to be_[arbitrary_predicate](*args) + # + # Given true, false, or nil, will pass if actual value is true, false or + # nil (respectively). Given no args means the caller should satisfy an if + # condition (to be or not to be). + # + # Predicates are any Ruby method that ends in a "?" and returns true or + # false. Given be_ followed by arbitrary_predicate (without the "?"), + # RSpec will match convert that into a query against the target object. + # + # The arbitrary_predicate feature will handle any predicate prefixed with + # "be_an_" (e.g. be_an_instance_of), "be_a_" (e.g. be_a_kind_of) or "be_" + # (e.g. be_empty), letting you choose the prefix that best suits the + # predicate. + def be(*args) + args.empty? ? Matchers::BuiltIn::Be.new : equal(*args) + end + alias_matcher :a_value, :be, :klass => AliasedMatcherWithOperatorSupport + + # passes if target.kind_of?(klass) + def be_a(klass) + be_a_kind_of(klass) + end + alias_method :be_an, :be_a + + # Passes if actual.instance_of?(expected) + # + # @example + # + # expect(5).to be_an_instance_of(Fixnum) + # expect(5).not_to be_an_instance_of(Numeric) + # expect(5).not_to be_an_instance_of(Float) + def be_an_instance_of(expected) + BuiltIn::BeAnInstanceOf.new(expected) + end + alias_method :be_instance_of, :be_an_instance_of + alias_matcher :an_instance_of, :be_an_instance_of + + # Passes if actual.kind_of?(expected) + # + # @example + # + # expect(5).to be_a_kind_of(Fixnum) + # expect(5).to be_a_kind_of(Numeric) + # expect(5).not_to be_a_kind_of(Float) + def be_a_kind_of(expected) + BuiltIn::BeAKindOf.new(expected) + end + alias_method :be_kind_of, :be_a_kind_of + alias_matcher :a_kind_of, :be_a_kind_of + + # Passes if actual.between?(min, max). Works with any Comparable object, + # including String, Symbol, Time, or Numeric (Fixnum, Bignum, Integer, + # Float, Complex, and Rational). + # + # By default, `be_between` is inclusive (i.e. passes when given either the max or min value), + # but you can make it `exclusive` by chaining that off the matcher. + # + # @example + # + # expect(5).to be_between(1, 10) + # expect(11).not_to be_between(1, 10) + # expect(10).not_to be_between(1, 10).exclusive + def be_between(min, max) + BuiltIn::BeBetween.new(min, max) + end + alias_matcher :a_value_between, :be_between + + # Passes if actual == expected +/- delta + # + # @example + # + # expect(result).to be_within(0.5).of(3.0) + # expect(result).not_to be_within(0.5).of(3.0) + def be_within(delta) + BuiltIn::BeWithin.new(delta) + end + alias_matcher :a_value_within, :be_within + alias_matcher :within, :be_within + + # Applied to a proc, specifies that its execution will cause some value to + # change. + # + # @param [Object] receiver + # @param [Symbol] message the message to send the receiver + # + # You can either pass receiver and message, or a block, + # but not both. + # + # When passing a block, it must use the `{ ... }` format, not + # do/end, as `{ ... }` binds to the `change` method, whereas do/end + # would errantly bind to the `expect(..).to` or `expect(...).not_to` method. + # + # You can chain any of the following off of the end to specify details + # about the change: + # + # * `from` + # * `to` + # + # or any one of: + # + # * `by` + # * `by_at_least` + # * `by_at_most` + # + # @example + # + # expect { + # team.add_player(player) + # }.to change(roster, :count) + # + # expect { + # team.add_player(player) + # }.to change(roster, :count).by(1) + # + # expect { + # team.add_player(player) + # }.to change(roster, :count).by_at_least(1) + # + # expect { + # team.add_player(player) + # }.to change(roster, :count).by_at_most(1) + # + # string = "string" + # expect { + # string.reverse! + # }.to change { string }.from("string").to("gnirts") + # + # string = "string" + # expect { + # string + # }.not_to change { string }.from("string") + # + # expect { + # person.happy_birthday + # }.to change(person, :birthday).from(32).to(33) + # + # expect { + # employee.develop_great_new_social_networking_app + # }.to change(employee, :title).from("Mail Clerk").to("CEO") + # + # expect { + # doctor.leave_office + # }.to change(doctor, :sign).from(/is in/).to(/is out/) + # + # user = User.new(:type => "admin") + # expect { + # user.symbolize_type + # }.to change(user, :type).from(String).to(Symbol) + # + # == Notes + # + # Evaluates `receiver.message` or `block` before and after it + # evaluates the block passed to `expect`. + # + # `expect( ... ).not_to change` supports the form that specifies `from` + # (which specifies what you expect the starting, unchanged value to be) + # but does not support forms with subsequent calls to `by`, `by_at_least`, + # `by_at_most` or `to`. + def change(receiver=nil, message=nil, &block) + BuiltIn::Change.new(receiver, message, &block) + end + alias_matcher :a_block_changing, :change + alias_matcher :changing, :change + + # Passes if actual contains all of the expected regardless of order. + # This works for collections. Pass in multiple args and it will only + # pass if all args are found in collection. + # + # @note This is also available using the `=~` operator with `should`, + # but `=~` is not supported with `expect`. + # + # @example + # + # expect([1, 2, 3]).to contain_exactly(1, 2, 3) + # expect([1, 2, 3]).to contain_exactly(1, 3, 2) + # + # @see #match_array + def contain_exactly(*items) + BuiltIn::ContainExactly.new(items) + end + alias_matcher :a_collection_containing_exactly, :contain_exactly + alias_matcher :containing_exactly, :contain_exactly + + # Passes if actual covers expected. This works for + # Ranges. You can also pass in multiple args + # and it will only pass if all args are found in Range. + # + # @example + # expect(1..10).to cover(5) + # expect(1..10).to cover(4, 6) + # expect(1..10).to cover(4, 6, 11) # fails + # expect(1..10).not_to cover(11) + # expect(1..10).not_to cover(5) # fails + # + # ### Warning:: Ruby >= 1.9 only + def cover(*values) + BuiltIn::Cover.new(*values) + end + alias_matcher :a_range_covering, :cover + alias_matcher :covering, :cover + + # Matches if the actual value ends with the expected value(s). In the case + # of a string, matches against the last `expected.length` characters of the + # actual string. In the case of an array, matches against the last + # `expected.length` elements of the actual array. + # + # @example + # + # expect("this string").to end_with "string" + # expect([0, 1, 2, 3, 4]).to end_with 4 + # expect([0, 2, 3, 4, 4]).to end_with 3, 4 + def end_with(*expected) + BuiltIn::EndWith.new(*expected) + end + alias_matcher :a_collection_ending_with, :end_with + alias_matcher :a_string_ending_with, :end_with + alias_matcher :ending_with, :end_with + + # Passes if actual == expected. + # + # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more + # information about equality in Ruby. + # + # @example + # + # expect(5).to eq(5) + # expect(5).not_to eq(3) + def eq(expected) + BuiltIn::Eq.new(expected) + end + alias_matcher :an_object_eq_to, :eq + alias_matcher :eq_to, :eq + + # Passes if `actual.eql?(expected)` + # + # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more + # information about equality in Ruby. + # + # @example + # + # expect(5).to eql(5) + # expect(5).not_to eql(3) + def eql(expected) + BuiltIn::Eql.new(expected) + end + alias_matcher :an_object_eql_to, :eql + alias_matcher :eql_to, :eql + + # Passes if actual.equal?(expected) (object identity). + # + # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more + # information about equality in Ruby. + # + # @example + # + # expect(5).to equal(5) # Fixnums are equal + # expect("5").not_to equal("5") # Strings that look the same are not the same object + def equal(expected) + BuiltIn::Equal.new(expected) + end + alias_matcher :an_object_equal_to, :equal + alias_matcher :equal_to, :equal + + # Passes if `actual.exist?` or `actual.exists?` + # + # @example + # expect(File).to exist("path/to/file") + def exist(*args) + BuiltIn::Exist.new(*args) + end + alias_matcher :an_object_existing, :exist + alias_matcher :existing, :exist + + # Passes if actual's attribute values match the expected attributes hash. + # This works no matter how you define your attribute readers. + # + # @example + # + # Person = Struct.new(:name, :age) + # person = Person.new("Bob", 32) + # + # expect(person).to have_attributes(:name => "Bob", :age => 32) + # expect(person).to have_attributes(:name => a_string_starting_with("B"), :age => (a_value > 30) ) + # + # @note It will fail if actual doesn't respond to any of the expected attributes. + # + # @example + # + # expect(person).to have_attributes(:color => "red") + def have_attributes(expected) + BuiltIn::HaveAttributes.new(expected) + end + alias_matcher :an_object_having_attributes, :have_attributes + + # Passes if actual includes expected. This works for + # collections and Strings. You can also pass in multiple args + # and it will only pass if all args are found in collection. + # + # @example + # + # expect([1,2,3]).to include(3) + # expect([1,2,3]).to include(2,3) + # expect([1,2,3]).to include(2,3,4) # fails + # expect([1,2,3]).not_to include(4) + # expect("spread").to include("read") + # expect("spread").not_to include("red") + def include(*expected) + BuiltIn::Include.new(*expected) + end + alias_matcher :a_collection_including, :include + alias_matcher :a_string_including, :include + alias_matcher :a_hash_including, :include + alias_matcher :including, :include + + # Passes if actual all expected objects pass. This works for + # any enumerable object. + # + # @example + # + # expect([1, 3, 5]).to all be_odd + # expect([1, 3, 6]).to all be_odd # fails + # + # @note The negative form `not_to all` is not supported. Instead + # use `not_to include` or pass a negative form of a matcher + # as the argument (e.g. `all exclude(:foo)`). + # + # @note You can also use this with compound matchers as well. + # + # @example + # expect([1, 3, 5]).to all( be_odd.and be_an(Integer) ) + def all(expected) + BuiltIn::All.new(expected) + end + + # Given a `Regexp` or `String`, passes if `actual.match(pattern)` + # Given an arbitrary nested data structure (e.g. arrays and hashes), + # matches if `expected === actual` || `actual == expected` for each + # pair of elements. + # + # @example + # + # expect(email).to match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) + # expect(email).to match("@example.com") + # + # @example + # + # hash = { + # :a => { + # :b => ["foo", 5], + # :c => { :d => 2.05 } + # } + # } + # + # expect(hash).to match( + # :a => { + # :b => a_collection_containing_exactly( + # a_string_starting_with("f"), + # an_instance_of(Fixnum) + # ), + # :c => { :d => (a_value < 3) } + # } + # ) + # + # @note The `match_regex` alias is deprecated and is not recommended for use. + # It was added in 2.12.1 to facilitate its use from within custom + # matchers (due to how the custom matcher DSL was evaluated in 2.x, + # `match` could not be used there), but is no longer needed in 3.x. + def match(expected) + BuiltIn::Match.new(expected) + end + alias_matcher :match_regex, :match + alias_matcher :an_object_matching, :match + alias_matcher :a_string_matching, :match + alias_matcher :matching, :match + + # An alternate form of `contain_exactly` that accepts + # the expected contents as a single array arg rather + # that splatted out as individual items. + # + # @example + # + # expect(results).to contain_exactly(1, 2) + # # is identical to: + # expect(results).to match_array([1, 2]) + # + # @see #contain_exactly + def match_array(items) + contain_exactly(*items) + end + + # With no arg, passes if the block outputs `to_stdout` or `to_stderr`. + # With a string, passes if the blocks outputs that specific string `to_stdout` or `to_stderr`. + # With a regexp or matcher, passes if the blocks outputs a string `to_stdout` or `to_stderr` that matches. + # + # @example + # + # expect { print 'foo' }.to output.to_stdout + # expect { print 'foo' }.to output('foo').to_stdout + # expect { print 'foo' }.to output(/foo/).to_stdout + # + # expect { do_something }.to_not output.to_stdout + # + # expect { warn('foo') }.to output.to_stderr + # expect { warn('foo') }.to output('foo').to_stderr + # expect { warn('foo') }.to output(/foo/).to_stderr + # + # expect { do_something }.to_not output.to_stderr + # + # @note This matcher works by temporarily replacing `$stdout` or `$stderr`, + # so it's not able to intercept stream output that explicitly uses `STDOUT`/`STDERR` + # or that uses a reference to `$stdout`/`$stderr` that was stored before the + # matcher is used. + def output(expected=nil) + BuiltIn::Output.new(expected) + end + alias_matcher :a_block_outputting, :output + + # With no args, matches if any error is raised. + # With a named error, matches only if that specific error is raised. + # With a named error and messsage specified as a String, matches only if both match. + # With a named error and messsage specified as a Regexp, matches only if both match. + # Pass an optional block to perform extra verifications on the exception matched + # + # @example + # + # expect { do_something_risky }.to raise_error + # expect { do_something_risky }.to raise_error(PoorRiskDecisionError) + # expect { do_something_risky }.to raise_error(PoorRiskDecisionError) { |error| expect(error.data).to eq 42 } + # expect { do_something_risky }.to raise_error(PoorRiskDecisionError, "that was too risky") + # expect { do_something_risky }.to raise_error(PoorRiskDecisionError, /oo ri/) + # + # expect { do_something_risky }.not_to raise_error + def raise_error(error=Exception, message=nil, &block) + BuiltIn::RaiseError.new(error, message, &block) + end + alias_method :raise_exception, :raise_error + + alias_matcher :a_block_raising, :raise_error do |desc| + desc.sub("raise", "a block raising") + end + + alias_matcher :raising, :raise_error do |desc| + desc.sub("raise", "raising") + end + + # Matches if the target object responds to all of the names + # provided. Names can be Strings or Symbols. + # + # @example + # + # expect("string").to respond_to(:length) + # + def respond_to(*names) + BuiltIn::RespondTo.new(*names) + end + alias_matcher :an_object_responding_to, :respond_to + alias_matcher :responding_to, :respond_to + + # Passes if the submitted block returns true. Yields target to the + # block. + # + # Generally speaking, this should be thought of as a last resort when + # you can't find any other way to specify the behaviour you wish to + # specify. + # + # If you do find yourself in such a situation, you could always write + # a custom matcher, which would likely make your specs more expressive. + # + # @example + # + # expect(5).to satisfy { |n| n > 3 } + def satisfy(&block) + BuiltIn::Satisfy.new(&block) + end + alias_matcher :an_object_satisfying, :satisfy + alias_matcher :satisfying, :satisfy + + # Matches if the actual value starts with the expected value(s). In the + # case of a string, matches against the first `expected.length` characters + # of the actual string. In the case of an array, matches against the first + # `expected.length` elements of the actual array. + # + # @example + # + # expect("this string").to start_with "this s" + # expect([0, 1, 2, 3, 4]).to start_with 0 + # expect([0, 2, 3, 4, 4]).to start_with 0, 1 + def start_with(*expected) + BuiltIn::StartWith.new(*expected) + end + alias_matcher :a_collection_starting_with, :start_with + alias_matcher :a_string_starting_with, :start_with + alias_matcher :starting_with, :start_with + + # Given no argument, matches if a proc throws any Symbol. + # + # Given a Symbol, matches if the given proc throws the specified Symbol. + # + # Given a Symbol and an arg, matches if the given proc throws the + # specified Symbol with the specified arg. + # + # @example + # + # expect { do_something_risky }.to throw_symbol + # expect { do_something_risky }.to throw_symbol(:that_was_risky) + # expect { do_something_risky }.to throw_symbol(:that_was_risky, 'culprit') + # + # expect { do_something_risky }.not_to throw_symbol + # expect { do_something_risky }.not_to throw_symbol(:that_was_risky) + # expect { do_something_risky }.not_to throw_symbol(:that_was_risky, 'culprit') + def throw_symbol(expected_symbol=nil, expected_arg=nil) + BuiltIn::ThrowSymbol.new(expected_symbol, expected_arg) + end + + alias_matcher :a_block_throwing, :throw_symbol do |desc| + desc.sub("throw", "a block throwing") + end + + alias_matcher :throwing, :throw_symbol do |desc| + desc.sub("throw", "throwing") + end + + # Passes if the method called in the expect block yields, regardless + # of whether or not arguments are yielded. + # + # @example + # + # expect { |b| 5.tap(&b) }.to yield_control + # expect { |b| "a".to_sym(&b) }.not_to yield_control + # + # @note Your expect block must accept a parameter and pass it on to + # the method-under-test as a block. + # @note This matcher is not designed for use with methods that yield + # multiple times. + def yield_control + BuiltIn::YieldControl.new + end + alias_matcher :a_block_yielding_control, :yield_control + alias_matcher :yielding_control, :yield_control + + # Passes if the method called in the expect block yields with + # no arguments. Fails if it does not yield, or yields with arguments. + # + # @example + # + # expect { |b| User.transaction(&b) }.to yield_with_no_args + # expect { |b| 5.tap(&b) }.not_to yield_with_no_args # because it yields with `5` + # expect { |b| "a".to_sym(&b) }.not_to yield_with_no_args # because it does not yield + # + # @note Your expect block must accept a parameter and pass it on to + # the method-under-test as a block. + # @note This matcher is not designed for use with methods that yield + # multiple times. + def yield_with_no_args + BuiltIn::YieldWithNoArgs.new + end + alias_matcher :a_block_yielding_with_no_args, :yield_with_no_args + alias_matcher :yielding_with_no_args, :yield_with_no_args + + # Given no arguments, matches if the method called in the expect + # block yields with arguments (regardless of what they are or how + # many there are). + # + # Given arguments, matches if the method called in the expect block + # yields with arguments that match the given arguments. + # + # Argument matching is done using `===` (the case match operator) + # and `==`. If the expected and actual arguments match with either + # operator, the matcher will pass. + # + # @example + # + # expect { |b| 5.tap(&b) }.to yield_with_args # because #tap yields an arg + # expect { |b| 5.tap(&b) }.to yield_with_args(5) # because 5 == 5 + # expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) # because Fixnum === 5 + # expect { |b| File.open("f.txt", &b) }.to yield_with_args(/txt/) # because /txt/ === "f.txt" + # + # expect { |b| User.transaction(&b) }.not_to yield_with_args # because it yields no args + # expect { |b| 5.tap(&b) }.not_to yield_with_args(1, 2, 3) + # + # @note Your expect block must accept a parameter and pass it on to + # the method-under-test as a block. + # @note This matcher is not designed for use with methods that yield + # multiple times. + def yield_with_args(*args) + BuiltIn::YieldWithArgs.new(*args) + end + alias_matcher :a_block_yielding_with_args, :yield_with_args + alias_matcher :yielding_with_args, :yield_with_args + + # Designed for use with methods that repeatedly yield (such as + # iterators). Passes if the method called in the expect block yields + # multiple times with arguments matching those given. + # + # Argument matching is done using `===` (the case match operator) + # and `==`. If the expected and actual arguments match with either + # operator, the matcher will pass. + # + # @example + # + # expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3) + # expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2]) + # expect { |b| [1, 2, 3].each(&b) }.not_to yield_successive_args(1, 2) + # + # @note Your expect block must accept a parameter and pass it on to + # the method-under-test as a block. + def yield_successive_args(*args) + BuiltIn::YieldSuccessiveArgs.new(*args) + end + alias_matcher :a_block_yielding_successive_args, :yield_successive_args + alias_matcher :yielding_successive_args, :yield_successive_args + + # Delegates to {RSpec::Expectations.configuration}. + # This is here because rspec-core's `expect_with` option + # looks for a `configuration` method on the mixin + # (`RSpec::Matchers`) to yield to a block. + # @return [RSpec::Expectations::Configuration] the configuration object + def self.configuration + Expectations.configuration + end + + private + + BE_PREDICATE_REGEX = /^(be_(?:an?_)?)(.*)/ + HAS_REGEX = /^(?:have_)(.*)/ + + def method_missing(method, *args, &block) + case method.to_s + when BE_PREDICATE_REGEX + BuiltIn::BePredicate.new(method, *args, &block) + when HAS_REGEX + BuiltIn::Has.new(method, *args, &block) + else + super + end + end + + # @api private + def self.is_a_matcher?(obj) + return true if ::RSpec::Matchers::BuiltIn::BaseMatcher === obj + begin + return false if obj.respond_to?(:i_respond_to_everything_so_im_not_really_a_matcher) + rescue NoMethodError + # Some objects, like BasicObject, don't implemented standard + # reflection methods. + return false + end + return false unless obj.respond_to?(:matches?) + + obj.respond_to?(:failure_message) || + obj.respond_to?(:failure_message_for_should) # support legacy matchers + end + + ::RSpec::Support.register_matcher_definition do |obj| + is_a_matcher?(obj) + end + + # @api private + def self.is_a_describable_matcher?(obj) + is_a_matcher?(obj) && obj.respond_to?(:description) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/aliased_matcher.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/aliased_matcher.rb new file mode 100644 index 000000000..c384d2ac2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/aliased_matcher.rb @@ -0,0 +1,116 @@ +module RSpec + module Matchers + # Decorator that wraps a matcher and overrides `description` + # using the provided block in order to support an alias + # of a matcher. This is intended for use when composing + # matchers, so that you can use an expression like + # `include( a_value_within(0.1).of(3) )` rather than + # `include( be_within(0.1).of(3) )`, and have the corresponding + # description read naturally. + # + # @api private + class AliasedMatcher < MatcherDelegator + def initialize(base_matcher, description_block) + @description_block = description_block + super(base_matcher) + end + + # Forward messages on to the wrapped matcher. + # Since many matchers provide a fluent interface + # (e.g. `a_value_within(0.1).of(3)`), we need to wrap + # the returned value if it responds to `description`, + # so that our override can be applied when it is eventually + # used. + def method_missing(*) + return_val = super + return return_val unless RSpec::Matchers.is_a_matcher?(return_val) + self.class.new(return_val, @description_block) + end + + # Provides the description of the aliased matcher. Aliased matchers + # are designed to behave identically to the original matcher except + # for the description and failure messages. The description is different + # to reflect the aliased name. + # + # @api private + def description + @description_block.call(super) + end + + # Provides the failure_message of the aliased matcher. Aliased matchers + # are designed to behave identically to the original matcher except + # for the description and failure messages. The failure_message is different + # to reflect the aliased name. + # + # @api private + def failure_message + @description_block.call(super) + end + + # Provides the failure_message_when_negated of the aliased matcher. Aliased matchers + # are designed to behave identically to the original matcher except + # for the description and failure messages. The failure_message_when_negated is different + # to reflect the aliased name. + # + # @api private + def failure_message_when_negated + @description_block.call(super) + end + end + + # Decorator used for matchers that have special implementations of + # operators like `==` and `===`. + # @private + class AliasedMatcherWithOperatorSupport < AliasedMatcher + # We undef these so that they get delegated via `method_missing`. + undef == + undef === + end + + # @private + class AliasedNegatedMatcher < AliasedMatcher + def matches?(*args, &block) + if @base_matcher.respond_to?(:does_not_match?) + @base_matcher.does_not_match?(*args, &block) + else + !super + end + end + + def does_not_match?(*args, &block) + @base_matcher.matches?(*args, &block) + end + + def failure_message + optimal_failure_message(__method__, :failure_message_when_negated) + end + + def failure_message_when_negated + optimal_failure_message(__method__, :failure_message) + end + + private + + DefaultFailureMessages = BuiltIn::BaseMatcher::DefaultFailureMessages + + # For a matcher that uses the default failure messages, we prefer to + # use the override provided by the `description_block`, because it + # includes the phrasing that the user has expressed a preference for + # by going through the effort of defining a negated matcher. + # + # However, if the override didn't actually change anything, then we + # should return the opposite failure message instead -- the overriden + # message is going to be confusing if we return it as-is, as it represents + # the non-negated failure message for a negated match (or vice versa). + def optimal_failure_message(same, inverted) + if DefaultFailureMessages.has_default_failure_messages?(@base_matcher) + base_message = @base_matcher.__send__(same) + overriden = @description_block.call(base_message) + return overriden if overriden != base_message + end + + @base_matcher.__send__(inverted) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in.rb new file mode 100644 index 000000000..89b90db73 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in.rb @@ -0,0 +1,52 @@ +RSpec::Support.require_rspec_matchers "built_in/base_matcher" + +module RSpec + module Matchers + # Container module for all built-in matchers. The matcher classes are here + # (rather than directly under `RSpec::Matchers`) in order to prevent name + # collisions, since `RSpec::Matchers` gets included into the user's namespace. + # + # Autoloading is used to delay when the matcher classes get loaded, allowing + # rspec-matchers to boot faster, and avoiding loading matchers the user is + # not using. + module BuiltIn + autoload :BeAKindOf, 'rspec/matchers/built_in/be_kind_of' + autoload :BeAnInstanceOf, 'rspec/matchers/built_in/be_instance_of' + autoload :BeBetween, 'rspec/matchers/built_in/be_between' + autoload :Be, 'rspec/matchers/built_in/be' + autoload :BeComparedTo, 'rspec/matchers/built_in/be' + autoload :BeFalsey, 'rspec/matchers/built_in/be' + autoload :BeNil, 'rspec/matchers/built_in/be' + autoload :BePredicate, 'rspec/matchers/built_in/be' + autoload :BeTruthy, 'rspec/matchers/built_in/be' + autoload :BeWithin, 'rspec/matchers/built_in/be_within' + autoload :Change, 'rspec/matchers/built_in/change' + autoload :Compound, 'rspec/matchers/built_in/compound' + autoload :ContainExactly, 'rspec/matchers/built_in/contain_exactly' + autoload :Cover, 'rspec/matchers/built_in/cover' + autoload :EndWith, 'rspec/matchers/built_in/start_and_end_with' + autoload :Eq, 'rspec/matchers/built_in/eq' + autoload :Eql, 'rspec/matchers/built_in/eql' + autoload :Equal, 'rspec/matchers/built_in/equal' + autoload :Exist, 'rspec/matchers/built_in/exist' + autoload :Has, 'rspec/matchers/built_in/has' + autoload :HaveAttributes, 'rspec/matchers/built_in/have_attributes' + autoload :Include, 'rspec/matchers/built_in/include' + autoload :All, 'rspec/matchers/built_in/all' + autoload :Match, 'rspec/matchers/built_in/match' + autoload :NegativeOperatorMatcher, 'rspec/matchers/built_in/operators' + autoload :OperatorMatcher, 'rspec/matchers/built_in/operators' + autoload :Output, 'rspec/matchers/built_in/output' + autoload :PositiveOperatorMatcher, 'rspec/matchers/built_in/operators' + autoload :RaiseError, 'rspec/matchers/built_in/raise_error' + autoload :RespondTo, 'rspec/matchers/built_in/respond_to' + autoload :Satisfy, 'rspec/matchers/built_in/satisfy' + autoload :StartWith, 'rspec/matchers/built_in/start_and_end_with' + autoload :ThrowSymbol, 'rspec/matchers/built_in/throw_symbol' + autoload :YieldControl, 'rspec/matchers/built_in/yield' + autoload :YieldSuccessiveArgs, 'rspec/matchers/built_in/yield' + autoload :YieldWithArgs, 'rspec/matchers/built_in/yield' + autoload :YieldWithNoArgs, 'rspec/matchers/built_in/yield' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/all.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/all.rb new file mode 100644 index 000000000..0d8e36041 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/all.rb @@ -0,0 +1,85 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `all`. + # Not intended to be instantiated directly. + class All < BaseMatcher + # @private + attr_reader :matcher, :failed_objects + + def initialize(matcher) + @matcher = matcher + @failed_objects = {} + end + + # @private + def does_not_match?(_actual) + raise NotImplementedError, '`expect().not_to all( matcher )` is not supported.' + end + + # @api private + # @return [String] + def failure_message + unless iterable? + return "#{improve_hash_formatting(super)}, but was not iterable" + end + + all_messages = [improve_hash_formatting(super)] + failed_objects.each do |index, matcher_failure_message| + all_messages << failure_message_for_item(index, matcher_failure_message) + end + all_messages.join("\n\n") + end + + # @api private + # @return [String] + def description + improve_hash_formatting "all #{description_of matcher}" + end + + private + + def match(_expected, _actual) + return false unless iterable? + + index_failed_objects + failed_objects.empty? + end + + def index_failed_objects + actual.each_with_index do |actual_item, index| + cloned_matcher = matcher.clone + matches = cloned_matcher.matches?(actual_item) + failed_objects[index] = cloned_matcher.failure_message unless matches + end + end + + def failure_message_for_item(index, failure_message) + failure_message = indent_multiline_message(add_new_line_if_needed(failure_message)) + indent_multiline_message("object at index #{index} failed to match:#{failure_message}") + end + + def add_new_line_if_needed(message) + message.start_with?("\n") ? message : "\n#{message}" + end + + def indent_multiline_message(message) + message = message.sub(/\n+\z/, '') + message.lines.map do |line| + line =~ /\S/ ? ' ' + line : line + end.join + end + + def initialize_copy(other) + @matcher = @matcher.clone + super + end + + def iterable? + @actual.respond_to?(:each_with_index) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/base_matcher.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/base_matcher.rb new file mode 100644 index 000000000..0143a8a1a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/base_matcher.rb @@ -0,0 +1,132 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # + # Used _internally_ as a base class for matchers that ship with + # rspec-expectations and rspec-rails. + # + # ### Warning: + # + # This class is for internal use, and subject to change without notice. We + # strongly recommend that you do not base your custom matchers on this + # class. If/when this changes, we will announce it and remove this warning. + class BaseMatcher + include RSpec::Matchers::Pretty + include RSpec::Matchers::Composable + + # @api private + # Used to detect when no arg is passed to `initialize`. + # `nil` cannot be used because it's a valid value to pass. + UNDEFINED = Object.new.freeze + + # @private + attr_reader :actual, :expected, :rescued_exception + + def initialize(expected=UNDEFINED) + @expected = expected unless UNDEFINED.equal?(expected) + end + + # @api private + # Indicates if the match is successful. Delegates to `match`, which + # should be defined on a subclass. Takes care of consistently + # initializing the `actual` attribute. + def matches?(actual) + @actual = actual + match(expected, actual) + end + + # @api private + # Used to wrap a block of code that will indicate failure by + # raising one of the named exceptions. + # + # This is used by rspec-rails for some of its matchers that + # wrap rails' assertions. + def match_unless_raises(*exceptions) + exceptions.unshift Exception if exceptions.empty? + begin + yield + true + rescue *exceptions => @rescued_exception + false + end + end + + # @api private + # Generates a "pretty" description using the logic in {Pretty}. + # @return [String] + def description + return name_to_sentence unless defined?(@expected) + "#{name_to_sentence}#{to_sentence @expected}" + end + + # @api private + # Matchers are not diffable by default. Override this to make your + # subclass diffable. + def diffable? + false + end + + # @api private + # Most matchers are value matchers (i.e. meant to work with `expect(value)`) + # rather than block matchers (i.e. meant to work with `expect { }`), so + # this defaults to false. Block matchers must override this to return true. + def supports_block_expectations? + false + end + + # @api private + def expects_call_stack_jump? + false + end + + private + + def assert_ivars(*expected_ivars) + return unless (expected_ivars - present_ivars).any? + raise "#{self.class.name} needs to supply#{to_sentence expected_ivars}" + end + + if RUBY_VERSION.to_f < 1.9 + def present_ivars + instance_variables.map { |v| v.to_sym } + end + else + alias present_ivars instance_variables + end + + # @api private + # Provides default implementations of failure messages, based on the `description`. + module DefaultFailureMessages + # @api private + # Provides a good generic failure message. Based on `description`. + # When subclassing, if you are not satisfied with this failure message + # you often only need to override `description`. + # @return [String] + def failure_message + "expected #{actual.inspect} to #{description}" + end + + # @api private + # Provides a good generic negative failure message. Based on `description`. + # When subclassing, if you are not satisfied with this failure message + # you often only need to override `description`. + # @return [String] + def failure_message_when_negated + "expected #{actual.inspect} not to #{description}" + end + + # @private + def self.has_default_failure_messages?(matcher) + matcher.method(:failure_message).owner == self && + matcher.method(:failure_message_when_negated).owner == self + rescue NameError + false + end + end + + include DefaultFailureMessages + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be.rb new file mode 100644 index 000000000..5339af138 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be.rb @@ -0,0 +1,277 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `be_truthy`. + # Not intended to be instantiated directly. + class BeTruthy < BaseMatcher + # @api private + # @return [String] + def failure_message + "expected: truthy value\n got: #{actual.inspect}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected: falsey value\n got: #{actual.inspect}" + end + + private + + def match(_, actual) + !!actual + end + end + + # @api private + # Provides the implementation for `be_falsey`. + # Not intended to be instantiated directly. + class BeFalsey < BaseMatcher + # @api private + # @return [String] + def failure_message + "expected: falsey value\n got: #{actual.inspect}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected: truthy value\n got: #{actual.inspect}" + end + + private + + def match(_, actual) + !actual + end + end + + # @api private + # Provides the implementation for `be_nil`. + # Not intended to be instantiated directly. + class BeNil < BaseMatcher + # @api private + # @return [String] + def failure_message + "expected: nil\n got: #{actual.inspect}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected: not nil\n got: nil" + end + + private + + def match(_, actual) + actual.nil? + end + end + + # @private + module BeHelpers + private + + def args_to_s + @args.empty? ? "" : parenthesize(inspected_args.join(', ')) + end + + def parenthesize(string) + "(#{string})" + end + + def inspected_args + @args.map { |a| a.inspect } + end + + def expected_to_sentence + split_words(@expected) + end + + def args_to_sentence + to_sentence(@args) + end + end + + # @api private + # Provides the implementation for `be`. + # Not intended to be instantiated directly. + class Be < BaseMatcher + include BeHelpers + + def initialize(*args) + @args = args + end + + # @api private + # @return [String] + def failure_message + "expected #{@actual.inspect} to evaluate to true" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{@actual.inspect} to evaluate to false" + end + + [:==, :<, :<=, :>=, :>, :===, :=~].each do |operator| + define_method operator do |operand| + BeComparedTo.new(operand, operator) + end + end + + private + + def match(_, actual) + !!actual + end + end + + # @api private + # Provides the implementation of `be value`. + # Not intended to be instantiated directly. + class BeComparedTo < BaseMatcher + include BeHelpers + + def initialize(operand, operator) + @expected, @operator = operand, operator + @args = [] + end + + def matches?(actual) + @actual = actual + @actual.__send__ @operator, @expected + end + + # @api private + # @return [String] + def failure_message + "expected: #{@operator} #{@expected.inspect}\n got: #{@operator.to_s.gsub(/./, ' ')} #{@actual.inspect}" + end + + # @api private + # @return [String] + def failure_message_when_negated + message = "`expect(#{@actual.inspect}).not_to be #{@operator} #{@expected.inspect}`" + if [:<, :>, :<=, :>=].include?(@operator) + message + " not only FAILED, it is a bit confusing." + else + message + end + end + + # @api private + # @return [String] + def description + "be #{@operator} #{expected_to_sentence}#{args_to_sentence}" + end + end + + # @api private + # Provides the implementation of `be_`. + # Not intended to be instantiated directly. + class BePredicate < BaseMatcher + include BeHelpers + + def initialize(*args, &block) + @expected = parse_expected(args.shift) + @args = args + @block = block + end + + def matches?(actual, &block) + @actual = actual + @block ||= block + predicate_accessible? && predicate_matches? + end + + def does_not_match?(actual, &block) + @actual = actual + @block ||= block + predicate_accessible? && !predicate_matches? + end + + # @api private + # @return [String] + def failure_message + failure_message_expecting(true) + end + + # @api private + # @return [String] + def failure_message_when_negated + failure_message_expecting(false) + end + + # @api private + # @return [String] + def description + "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}" + end + + private + + def predicate_accessible? + !private_predicate? && predicate_exists? + end + + # support 1.8.7, evaluate once at load time for performance + if String === methods.first + def private_predicate? + @actual.private_methods.include? predicate.to_s + end + else + def private_predicate? + @actual.private_methods.include? predicate + end + end + + def predicate_exists? + actual.respond_to?(predicate) || actual.respond_to?(present_tense_predicate) + end + + def predicate_matches? + method_name = actual.respond_to?(predicate) ? predicate : present_tense_predicate + @predicate_matches = actual.__send__(method_name, *@args, &@block) + end + + def predicate + :"#{@expected}?" + end + + def present_tense_predicate + :"#{@expected}s?" + end + + def parse_expected(expected) + @prefix, expected = prefix_and_expected(expected) + expected + end + + def prefix_and_expected(symbol) + Matchers::BE_PREDICATE_REGEX.match(symbol.to_s).captures.compact + end + + def prefix_to_sentence + split_words(@prefix) + end + + def failure_message_expecting(value) + validity_message || + "expected `#{@actual.inspect}.#{predicate}#{args_to_s}` to return #{value}, got #{@predicate_matches.inspect}" + end + + def validity_message + if private_predicate? + "expected #{@actual} to respond to `#{predicate}` but `#{predicate}` is a private method" + elsif !predicate_exists? + "expected #{@actual} to respond to `#{predicate}`" + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_between.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_between.rb new file mode 100644 index 000000000..58c6219fc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_between.rb @@ -0,0 +1,77 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `be_between`. + # Not intended to be instantiated directly. + class BeBetween < BaseMatcher + def initialize(min, max) + @min, @max = min, max + inclusive + end + + # @api public + # Makes the between comparison inclusive. + # + # @example + # expect(3).to be_between(2, 3).inclusive + # + # @note The matcher is inclusive by default; this simply provides + # a way to be more explicit about it. + def inclusive + @less_than_operator = :<= + @greater_than_operator = :>= + @mode = :inclusive + self + end + + # @api public + # Makes the between comparison exclusive. + # + # @example + # expect(3).to be_between(2, 4).exclusive + def exclusive + @less_than_operator = :< + @greater_than_operator = :> + @mode = :exclusive + self + end + + # @api private + # @return [Boolean] + def matches?(actual) + @actual = actual + comparable? && compare + rescue ArgumentError + false + end + + # @api private + # @return [String] + def failure_message + "#{super}#{not_comparable_clause}" + end + + # @api private + # @return [String] + def description + "be between #{@min.inspect} and #{@max.inspect} (#{@mode})" + end + + private + + def comparable? + @actual.respond_to?(@less_than_operator) && @actual.respond_to?(@greater_than_operator) + end + + def not_comparable_clause + ", but it does not respond to `#{@less_than_operator}` and `#{@greater_than_operator}`" unless comparable? + end + + def compare + @actual.__send__(@greater_than_operator, @min) && @actual.__send__(@less_than_operator, @max) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_instance_of.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_instance_of.rb new file mode 100644 index 000000000..c6968f1ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_instance_of.rb @@ -0,0 +1,22 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `be_an_instance_of`. + # Not intended to be instantiated directly. + class BeAnInstanceOf < BaseMatcher + # @api private + # @return [String] + def description + "be an instance of #{expected}" + end + + private + + def match(expected, actual) + actual.instance_of? expected + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_kind_of.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_kind_of.rb new file mode 100644 index 000000000..eae9b26e9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_kind_of.rb @@ -0,0 +1,16 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `be_a_kind_of`. + # Not intended to be instantiated directly. + class BeAKindOf < BaseMatcher + private + + def match(expected, actual) + actual.kind_of? expected + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_within.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_within.rb new file mode 100644 index 000000000..9f225a07a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/be_within.rb @@ -0,0 +1,72 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `be_within`. + # Not intended to be instantiated directly. + class BeWithin < BaseMatcher + def initialize(delta) + @delta = delta + end + + # @api public + # Sets the expected value. + def of(expected) + @expected = expected + @tolerance = @delta + @unit = '' + self + end + + # @api public + # Sets the expected value, and makes the matcher do + # a percent comparison. + def percent_of(expected) + @expected = expected + @tolerance = @delta * @expected.abs / 100.0 + @unit = '%' + self + end + + # @private + def matches?(actual) + @actual = actual + raise needs_expected unless defined? @expected + numeric? && (@actual - @expected).abs <= @tolerance + end + + # @api private + # @return [String] + def failure_message + "expected #{@actual.inspect} to #{description}#{not_numeric_clause}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{@actual.inspect} not to #{description}" + end + + # @api private + # @return [String] + def description + "be within #{@delta}#{@unit} of #{@expected}" + end + + private + + def numeric? + @actual.respond_to?(:-) + end + + def needs_expected + ArgumentError.new "You must set an expected value using #of: be_within(#{@delta}).of(expected_value)" + end + + def not_numeric_clause + ", but it could not be treated as a numeric value" unless numeric? + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/change.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/change.rb new file mode 100644 index 000000000..7fff8a58f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/change.rb @@ -0,0 +1,337 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `change`. + # Not intended to be instantiated directly. + class Change < BaseMatcher + # @api public + # Specifies the delta of the expected change. + def by(expected_delta) + ChangeRelatively.new(@change_details, expected_delta, :by) do |actual_delta| + values_match?(expected_delta, actual_delta) + end + end + + # @api public + # Specifies a minimum delta of the expected change. + def by_at_least(minimum) + ChangeRelatively.new(@change_details, minimum, :by_at_least) do |actual_delta| + actual_delta >= minimum + end + end + + # @api public + # Specifies a maximum delta of the expected change. + def by_at_most(maximum) + ChangeRelatively.new(@change_details, maximum, :by_at_most) do |actual_delta| + actual_delta <= maximum + end + end + + # @api public + # Specifies the new value you expect. + def to(value) + ChangeToValue.new(@change_details, value) + end + + # @api public + # Specifies the original value. + def from(value) + ChangeFromValue.new(@change_details, value) + end + + # @private + def matches?(event_proc) + @event_proc = event_proc + return false unless Proc === event_proc + raise_block_syntax_error if block_given? + @change_details.perform_change(event_proc) + @change_details.changed? + end + + def does_not_match?(event_proc) + raise_block_syntax_error if block_given? + !matches?(event_proc) && Proc === event_proc + end + + # @api private + # @return [String] + def failure_message + "expected #{@change_details.message} to have changed, but #{positive_failure_reason}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{@change_details.message} not to have changed, but #{negative_failure_reason}" + end + + # @api private + # @return [String] + def description + "change #{@change_details.message}" + end + + # @private + def supports_block_expectations? + true + end + + private + + def initialize(receiver=nil, message=nil, &block) + @change_details = ChangeDetails.new(receiver, message, &block) + end + + def raise_block_syntax_error + raise SyntaxError, "The block passed to the `change` matcher must " \ + "use `{ ... }` instead of do/end" + end + + def positive_failure_reason + return "was not given a block" unless Proc === @event_proc + "is still #{description_of @change_details.actual_before}" + end + + def negative_failure_reason + return "was not given a block" unless Proc === @event_proc + "did change from #{description_of @change_details.actual_before} to #{description_of @change_details.actual_after}" + end + end + + # Used to specify a relative change. + # @api private + class ChangeRelatively < BaseMatcher + def initialize(change_details, expected_delta, relativity, &comparer) + @change_details = change_details + @expected_delta = expected_delta + @relativity = relativity + @comparer = comparer + end + + # @private + def failure_message + "expected #{@change_details.message} to have changed #{@relativity.to_s.gsub("_", " ")} #{description_of @expected_delta}, but #{failure_reason}" + end + + # @private + def matches?(event_proc) + @event_proc = event_proc + return false unless Proc === event_proc + @change_details.perform_change(event_proc) + @comparer.call(@change_details.actual_delta) + end + + # @private + def does_not_match?(_event_proc) + raise NotImplementedError, "`expect { }.not_to change { }.#{@relativity}()` is not supported" + end + + # @private + def description + "change #{@change_details.message} #{@relativity.to_s.gsub("_", " ")} #{description_of @expected_delta}" + end + + # @private + def supports_block_expectations? + true + end + + private + + def failure_reason + return "was not given a block" unless Proc === @event_proc + "was changed by #{description_of @change_details.actual_delta}" + end + end + + # @api private + # Base class for specifying a change from and/or to specific values. + class SpecificValuesChange < BaseMatcher + # @private + MATCH_ANYTHING = ::Object.ancestors.last + + def initialize(change_details, from, to) + @change_details = change_details + @expected_before = from + @expected_after = to + end + + # @private + def matches?(event_proc) + @event_proc = event_proc + return false unless Proc === event_proc + @change_details.perform_change(event_proc) + @change_details.changed? && matches_before? && matches_after? + end + + # @private + def description + "change #{@change_details.message} #{change_description}" + end + + # @private + def failure_message + return not_given_a_block_failure unless Proc === @event_proc + return before_value_failure unless matches_before? + return did_not_change_failure unless @change_details.changed? + after_value_failure + end + + # @private + def supports_block_expectations? + true + end + + private + + def matches_before? + values_match?(@expected_before, @change_details.actual_before) + end + + def matches_after? + values_match?(@expected_after, @change_details.actual_after) + end + + def before_value_failure + "expected #{@change_details.message} to have initially been #{description_of @expected_before}, but was #{description_of @change_details.actual_before}" + end + + def after_value_failure + "expected #{@change_details.message} to have changed to #{description_of @expected_after}, but is now #{description_of @change_details.actual_after}" + end + + def did_not_change_failure + "expected #{@change_details.message} to have changed #{change_description}, but did not change" + end + + def did_change_failure + "expected #{@change_details.message} not to have changed, but did change from #{description_of @change_details.actual_before} to #{description_of @change_details.actual_after}" + end + + def not_given_a_block_failure + "expected #{@change_details.message} to have changed #{change_description}, but was not given a block" + end + end + + # @api private + # Used to specify a change from a specific value + # (and, optionally, to a specific value). + class ChangeFromValue < SpecificValuesChange + def initialize(change_details, expected_before) + @description_suffix = nil + super(change_details, expected_before, MATCH_ANYTHING) + end + + # @api public + # Specifies the new value you expect. + def to(value) + @expected_after = value + @description_suffix = " to #{description_of value}" + self + end + + # @private + def does_not_match?(event_proc) + if @description_suffix + raise NotImplementedError, "`expect { }.not_to change { }.to()` is not supported" + end + + @event_proc = event_proc + return false unless Proc === event_proc + @change_details.perform_change(event_proc) + !@change_details.changed? && matches_before? + end + + # @private + def failure_message_when_negated + return not_given_a_block_failure unless Proc === @event_proc + return before_value_failure unless matches_before? + did_change_failure + end + + private + + def change_description + "from #{description_of @expected_before}#{@description_suffix}" + end + end + + # @api private + # Used to specify a change to a specific value + # (and, optionally, from a specific value). + class ChangeToValue < SpecificValuesChange + def initialize(change_details, expected_after) + @description_suffix = nil + super(change_details, MATCH_ANYTHING, expected_after) + end + + # @api public + # Specifies the original value. + def from(value) + @expected_before = value + @description_suffix = " from #{description_of value}" + self + end + + # @private + def does_not_match?(_event_proc) + raise NotImplementedError, "`expect { }.not_to change { }.to()` is not supported" + end + + private + + def change_description + "to #{description_of @expected_after}#{@description_suffix}" + end + end + + # @private + # Encapsulates the details of the before/after values. + class ChangeDetails + attr_reader :message, :actual_before, :actual_after + + def initialize(receiver=nil, message=nil, &block) + if receiver && !message + raise( + ArgumentError, + "`change` requires either an object and message " \ + "(`change(obj, :msg)`) or a block (`change { }`). " \ + "You passed an object but no message." + ) + end + @message = message ? "##{message}" : "result" + @value_proc = block || lambda { receiver.__send__(message) } + end + + def perform_change(event_proc) + @actual_before = evaluate_value_proc + event_proc.call + @actual_after = evaluate_value_proc + end + + def changed? + @actual_before != @actual_after + end + + def actual_delta + @actual_after - @actual_before + end + + private + + def evaluate_value_proc + case val = @value_proc.call + when IO # enumerable, but we don't want to dup it. + val + when Enumerable, String + val.dup + else + val + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/compound.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/compound.rb new file mode 100644 index 000000000..49ea8281a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/compound.rb @@ -0,0 +1,258 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Base class for `and` and `or` compound matchers. + class Compound < BaseMatcher + # @private + attr_reader :matcher_1, :matcher_2 + + def initialize(matcher_1, matcher_2) + @matcher_1 = matcher_1 + @matcher_2 = matcher_2 + end + + # @private + def does_not_match?(_actual) + raise NotImplementedError, "`expect(...).not_to matcher.#{conjunction} matcher` " \ + "is not supported, since it creates a bit of an ambiguity. Instead, define negated versions " \ + "of whatever matchers you wish to negate with `RSpec::Matchers.define_negated_matcher` and " \ + "use `expect(...).to matcher.#{conjunction} matcher`." + end + + # @api private + # @return [String] + def description + singleline_message(matcher_1.description, matcher_2.description) + end + + def supports_block_expectations? + matcher_supports_block_expectations?(matcher_1) && + matcher_supports_block_expectations?(matcher_2) + end + + def expects_call_stack_jump? + NestedEvaluator.matcher_expects_call_stack_jump?(matcher_1) || + NestedEvaluator.matcher_expects_call_stack_jump?(matcher_2) + end + + private + + def initialize_copy(other) + @matcher_1 = @matcher_1.clone + @matcher_2 = @matcher_2.clone + super + end + + def match(_expected, actual) + evaluator_klass = if supports_block_expectations? && Proc === actual + NestedEvaluator + else + SequentialEvaluator + end + + @evaluator = evaluator_klass.new(actual, matcher_1, matcher_2) + end + + def indent_multiline_message(message) + message.lines.map do |line| + line =~ /\S/ ? ' ' + line : line + end.join + end + + def compound_failure_message + message_1 = matcher_1.failure_message + message_2 = matcher_2.failure_message + + if multiline?(message_1) || multiline?(message_2) + multiline_message(message_1, message_2) + else + singleline_message(message_1, message_2) + end + end + + def multiline_message(message_1, message_2) + [ + indent_multiline_message(message_1.sub(/\n+\z/, '')), + "...#{conjunction}:", + indent_multiline_message(message_2.sub(/\A\n+/, '')) + ].join("\n\n") + end + + def multiline?(message) + message.lines.count > 1 + end + + def singleline_message(message_1, message_2) + [message_1, conjunction, message_2].join(' ') + end + + def matcher_1_matches? + @evaluator.matcher_matches?(matcher_1) + end + + def matcher_2_matches? + @evaluator.matcher_matches?(matcher_2) + end + + def matcher_supports_block_expectations?(matcher) + matcher.supports_block_expectations? + rescue NoMethodError + false + end + + # For value expectations, we can evaluate the matchers sequentially. + class SequentialEvaluator + def initialize(actual, *) + @actual = actual + end + + def matcher_matches?(matcher) + matcher.matches?(@actual) + end + end + + # Normally, we evaluate the matching sequentially. For an expression like + # `expect(x).to foo.and bar`, this becomes: + # + # expect(x).to foo + # expect(x).to bar + # + # For block expectations, we need to nest them instead, so that + # `expect { x }.to foo.and bar` becomes: + # + # expect { + # expect { x }.to foo + # }.to bar + # + # This is necessary so that the `expect` block is only executed once. + class NestedEvaluator + def initialize(actual, matcher_1, matcher_2) + @actual = actual + @matcher_1 = matcher_1 + @matcher_2 = matcher_2 + @match_results = {} + + inner, outer = order_block_matchers + + @match_results[outer] = outer.matches?(Proc.new do |*args| + @match_results[inner] = inner.matches?(inner_matcher_block(args)) + end) + end + + def matcher_matches?(matcher) + @match_results.fetch(matcher) + end + + private + + # Some block matchers (such as `yield_xyz`) pass args to the `expect` block. + # When such a matcher is used as the outer matcher, we need to forward the + # the args on to the `expect` block. + def inner_matcher_block(outer_args) + return @actual if outer_args.empty? + + Proc.new do |*inner_args| + unless inner_args.empty? + raise ArgumentError, "(#{@matcher_1.description}) and " \ + "(#{@matcher_2.description}) cannot be combined in a compound expectation " \ + "since both matchers pass arguments to the block." + end + + @actual.call(*outer_args) + end + end + + # For a matcher like `raise_error` or `throw_symbol`, where the block will jump + # up the call stack, we need to order things so that it is the inner matcher. + # For example, we need it to be this: + # + # expect { + # expect { + # x += 1 + # raise "boom" + # }.to raise_error("boom") + # }.to change { x }.by(1) + # + # ...rather than: + # + # expect { + # expect { + # x += 1 + # raise "boom" + # }.to change { x }.by(1) + # }.to raise_error("boom") + # + # In the latter case, the after-block logic in the `change` matcher would never + # get executed because the `raise "boom"` line would jump to the `rescue` in the + # `raise_error` logic, so only the former case will work properly. + # + # This method figures out which matcher should be the inner matcher and which + # should be the outer matcher. + def order_block_matchers + return @matcher_1, @matcher_2 unless self.class.matcher_expects_call_stack_jump?(@matcher_2) + return @matcher_2, @matcher_1 unless self.class.matcher_expects_call_stack_jump?(@matcher_1) + + raise ArgumentError, "(#{@matcher_1.description}) and " \ + "(#{@matcher_2.description}) cannot be combined in a compound expectation " \ + "because they both expect a call stack jump." + end + + def self.matcher_expects_call_stack_jump?(matcher) + matcher.expects_call_stack_jump? + rescue NoMethodError + false + end + end + + # @api public + # Matcher used to represent a compound `and` expectation. + class And < self + # @api private + # @return [String] + def failure_message + if matcher_1_matches? + matcher_2.failure_message + elsif matcher_2_matches? + matcher_1.failure_message + else + compound_failure_message + end + end + + private + + def match(*) + super + matcher_1_matches? && matcher_2_matches? + end + + def conjunction + "and" + end + end + + # @api public + # Matcher used to represent a compound `or` expectation. + class Or < self + # @api private + # @return [String] + def failure_message + compound_failure_message + end + + private + + def match(*) + super + matcher_1_matches? || matcher_2_matches? + end + + def conjunction + "or" + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/contain_exactly.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/contain_exactly.rb new file mode 100644 index 000000000..7b0a3cec6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/contain_exactly.rb @@ -0,0 +1,249 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `contain_exactly` and `match_array`. + # Not intended to be instantiated directly. + class ContainExactly < BaseMatcher + # @api private + # @return [String] + def failure_message + if Array === actual + message = "expected collection contained: #{safe_sort(surface_descriptions_in expected).inspect}\n" + message += "actual collection contained: #{safe_sort(actual).inspect}\n" + message += "the missing elements were: #{safe_sort(surface_descriptions_in missing_items).inspect}\n" unless missing_items.empty? + message += "the extra elements were: #{safe_sort(extra_items).inspect}\n" unless extra_items.empty? + message + else + "expected a collection that can be converted to an array with " \ + "`#to_ary` or `#to_a`, but got #{actual.inspect}" + end + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{actual.inspect} not to contain exactly#{to_sentence(surface_descriptions_in expected)}" + end + + # @api private + # @return [String] + def description + "contain exactly#{to_sentence(surface_descriptions_in expected)}" + end + + private + + def match(_expected, _actual) + return false unless convert_actual_to_an_array + match_when_sorted? || (extra_items.empty? && missing_items.empty?) + end + + # This cannot always work (e.g. when dealing with unsortable items, + # or matchers as expected items), but it's practically free compared to + # the slowness of the full matching algorithm, and in common cases this + # works, so it's worth a try. + def match_when_sorted? + values_match?(safe_sort(expected), safe_sort(actual)) + end + + def convert_actual_to_an_array + if actual.respond_to?(:to_ary) + @actual = actual.to_ary + elsif enumerable?(actual) && actual.respond_to?(:to_a) + @actual = actual.to_a + else + return false + end + end + + def safe_sort(array) + array.sort rescue array + end + + def missing_items + @missing_items ||= best_solution.unmatched_expected_indexes.map do |index| + expected[index] + end + end + + def extra_items + @extra_items ||= best_solution.unmatched_actual_indexes.map do |index| + actual[index] + end + end + + def best_solution + @best_solution ||= pairings_maximizer.find_best_solution + end + + def pairings_maximizer + @pairings_maximizer ||= begin + expected_matches = Hash[Array.new(expected.size) { |i| [i, []] }] + actual_matches = Hash[Array.new(actual.size) { |i| [i, []] }] + + expected.each_with_index do |e, ei| + actual.each_with_index do |a, ai| + next unless values_match?(e, a) + + expected_matches[ei] << ai + actual_matches[ai] << ei + end + end + + PairingsMaximizer.new(expected_matches, actual_matches) + end + end + + # Once we started supporting composing matchers, the algorithm for this matcher got + # much more complicated. Consider this expression: + # + # expect(["fool", "food"]).to contain_exactly(/foo/, /fool/) + # + # This should pass (because we can pair /fool/ with "fool" and /foo/ with "food"), but + # the original algorithm used by this matcher would pair the first elements it could + # (/foo/ with "fool"), which would leave /fool/ and "food" unmatched. When we have + # an expected element which is a matcher that matches a superset of actual items + # compared to another expected element matcher, we need to consider every possible pairing. + # + # This class is designed to maximize the number of actual/expected pairings -- or, + # conversely, to minimize the number of unpaired items. It's essentially a brute + # force solution, but with a few heuristics applied to reduce the size of the + # problem space: + # + # * Any items which match none of the items in the other list are immediately + # placed into the `unmatched_expected_indexes` or `unmatched_actual_indexes` array. + # The extra items and missing items in the matcher failure message are derived + # from these arrays. + # * Any items which reciprocally match only each other are paired up and not + # considered further. + # + # What's left is only the items which match multiple items from the other list + # (or vice versa). From here, it performs a brute-force depth-first search, + # looking for a solution which pairs all elements in both lists, or, barring that, + # that produces the fewest unmatched items. + # + # @private + class PairingsMaximizer + Solution = Struct.new(:unmatched_expected_indexes, :unmatched_actual_indexes, + :indeterminate_expected_indexes, :indeterminate_actual_indexes) do + def worse_than?(other) + unmatched_item_count > other.unmatched_item_count + end + + def candidate? + indeterminate_expected_indexes.empty? && + indeterminate_actual_indexes.empty? + end + + def ideal? + candidate? && ( + unmatched_expected_indexes.empty? || + unmatched_actual_indexes.empty? + ) + end + + def unmatched_item_count + unmatched_expected_indexes.count + unmatched_actual_indexes.count + end + + def +(derived_candidate_solution) + self.class.new( + unmatched_expected_indexes + derived_candidate_solution.unmatched_expected_indexes, + unmatched_actual_indexes + derived_candidate_solution.unmatched_actual_indexes, + # Ignore the indeterminate indexes: by the time we get here, + # we've dealt with all indeterminates. + [], [] + ) + end + end + + attr_reader :expected_to_actual_matched_indexes, :actual_to_expected_matched_indexes, :solution + + def initialize(expected_to_actual_matched_indexes, actual_to_expected_matched_indexes) + @expected_to_actual_matched_indexes = expected_to_actual_matched_indexes + @actual_to_expected_matched_indexes = actual_to_expected_matched_indexes + + unmatched_expected_indexes, indeterminate_expected_indexes = + categorize_indexes(expected_to_actual_matched_indexes, actual_to_expected_matched_indexes) + + unmatched_actual_indexes, indeterminate_actual_indexes = + categorize_indexes(actual_to_expected_matched_indexes, expected_to_actual_matched_indexes) + + @solution = Solution.new(unmatched_expected_indexes, unmatched_actual_indexes, + indeterminate_expected_indexes, indeterminate_actual_indexes) + end + + def find_best_solution + return solution if solution.candidate? + best_solution_so_far = NullSolution + + expected_index = solution.indeterminate_expected_indexes.first + actuals = expected_to_actual_matched_indexes[expected_index] + + actuals.each do |actual_index| + solution = best_solution_for_pairing(expected_index, actual_index) + return solution if solution.ideal? + best_solution_so_far = solution if best_solution_so_far.worse_than?(solution) + end + + best_solution_so_far + end + + private + + # @private + # Starting solution that is worse than any other real solution. + NullSolution = Class.new do + def self.worse_than?(_other) + true + end + end + + def categorize_indexes(indexes_to_categorize, other_indexes) + unmatched = [] + indeterminate = [] + + indexes_to_categorize.each_pair do |index, matches| + if matches.empty? + unmatched << index + elsif !reciprocal_single_match?(matches, index, other_indexes) + indeterminate << index + end + end + + return unmatched, indeterminate + end + + def reciprocal_single_match?(matches, index, other_list) + return false unless matches.one? + other_list[matches.first] == [index] + end + + def best_solution_for_pairing(expected_index, actual_index) + modified_expecteds = apply_pairing_to( + solution.indeterminate_expected_indexes, + expected_to_actual_matched_indexes, actual_index) + + modified_expecteds.delete(expected_index) + + modified_actuals = apply_pairing_to( + solution.indeterminate_actual_indexes, + actual_to_expected_matched_indexes, expected_index) + + modified_actuals.delete(actual_index) + + solution + self.class.new(modified_expecteds, modified_actuals).find_best_solution + end + + def apply_pairing_to(indeterminates, original_matches, other_list_index) + indeterminates.inject({}) do |accum, index| + accum[index] = original_matches[index] - [other_list_index] + accum + end + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/cover.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/cover.rb new file mode 100644 index 000000000..47474a2c8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/cover.rb @@ -0,0 +1,24 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `cover`. + # Not intended to be instantiated directly. + class Cover < BaseMatcher + def initialize(*expected) + @expected = expected + end + + def matches?(range) + @actual = range + @expected.all? { |e| range.cover?(e) } + end + + def does_not_match?(range) + @actual = range + expected.none? { |e| range.cover?(e) } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eq.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eq.rb new file mode 100644 index 000000000..67bc22a7a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eq.rb @@ -0,0 +1,75 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `eq`. + # Not intended to be instantiated directly. + class Eq < BaseMatcher + # @api private + # @return [String] + def failure_message + "\nexpected: #{format_object(expected)}\n got: #{format_object(actual)}\n\n(compared using ==)\n" + end + + # @api private + # @return [String] + def failure_message_when_negated + "\nexpected: value != #{format_object(expected)}\n got: #{format_object(actual)}\n\n(compared using ==)\n" + end + + # @api private + # @return [String] + def description + "#{name_to_sentence} #{@expected.inspect}" + end + + # @api private + # @return [Boolean] + def diffable? + true + end + + private + + def match(expected, actual) + actual == expected + end + + def format_object(object) + if Time === object + format_time(object) + elsif defined?(DateTime) && DateTime === object + format_date_time(object) + elsif defined?(BigDecimal) && BigDecimal === object + "#{object.to_s 'F'} (#{object.inspect})" + else + object.inspect + end + end + + TIME_FORMAT = "%Y-%m-%d %H:%M:%S" + + if Time.method_defined?(:nsec) + def format_time(time) + time.strftime("#{TIME_FORMAT}.#{"%09d" % time.nsec} %z") + end + else # for 1.8.7 + def format_time(time) + time.strftime("#{TIME_FORMAT}.#{"%06d" % time.usec} %z") + end + end + + DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z" + # ActiveSupport sometimes overrides inspect. If `ActiveSupport` is + # defined use a custom format string that includes more time precision. + def format_date_time(date_time) + if defined?(ActiveSupport) + date_time.strftime(DATE_TIME_FORMAT) + else + date_time.inspect + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eql.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eql.rb new file mode 100644 index 000000000..4aee572d8 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/eql.rb @@ -0,0 +1,34 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `eql`. + # Not intended to be instantiated directly. + class Eql < BaseMatcher + # @api private + # @return [String] + def failure_message + "\nexpected: #{expected.inspect}\n got: #{actual.inspect}\n\n(compared using eql?)\n" + end + + # @api private + # @return [String] + def failure_message_when_negated + "\nexpected: value != #{expected.inspect}\n got: #{actual.inspect}\n\n(compared using eql?)\n" + end + + # @api private + # @return [Boolean] + def diffable? + true + end + + private + + def match(expected, actual) + actual.eql? expected + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/equal.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/equal.rb new file mode 100644 index 000000000..e2e02d0fc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/equal.rb @@ -0,0 +1,81 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `equal`. + # Not intended to be instantiated directly. + class Equal < BaseMatcher + # @api private + # @return [String] + def failure_message + if expected_is_a_literal_singleton? + simple_failure_message + else + detailed_failure_message + end + end + + # @api private + # @return [String] + def failure_message_when_negated + <<-MESSAGE + +expected not #{inspect_object(actual)} + got #{inspect_object(expected)} + +Compared using equal?, which compares object identity. + +MESSAGE + end + + # @api private + # @return [Boolean] + def diffable? + !expected_is_a_literal_singleton? + end + + private + + def match(expected, actual) + actual.equal? expected + end + + LITERAL_SINGLETONS = [true, false, nil] + + def expected_is_a_literal_singleton? + LITERAL_SINGLETONS.include?(expected) + end + + def actual_inspected + if LITERAL_SINGLETONS.include?(actual) + actual.inspect + else + inspect_object(actual) + end + end + + def simple_failure_message + "\nexpected #{expected.inspect}\n got #{actual_inspected}\n" + end + + def detailed_failure_message + <<-MESSAGE + +expected #{inspect_object(expected)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity, +but expected and actual are not the same object. Use +`expect(actual).to eq(expected)` if you don't care about +object identity in this example. + +MESSAGE + end + + def inspect_object(o) + "#<#{o.class}:#{o.object_id}> => #{o.inspect}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/exist.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/exist.rb new file mode 100644 index 000000000..2884fab28 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/exist.rb @@ -0,0 +1,86 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `exist`. + # Not intended to be instantiated directly. + class Exist < BaseMatcher + def initialize(*expected) + @expected = expected + end + + # @api private + # @return [Boolean] + def matches?(actual) + @actual = actual + @test = ExistenceTest.new @actual, @expected + @test.valid_test? && @test.actual_exists? + end + + # @api private + # @return [Boolean] + def does_not_match?(actual) + @actual = actual + @test = ExistenceTest.new @actual, @expected + @test.valid_test? && !@test.actual_exists? + end + + # @api private + # @return [String] + def failure_message + "expected #{@actual.inspect} to exist#{@test.validity_message}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{@actual.inspect} not to exist#{@test.validity_message}" + end + + # @api private + # Simple class for memoizing actual/expected for this matcher + # and examining the match + class ExistenceTest < Struct.new(:actual, :expected) + # @api private + # @return [Boolean] + def valid_test? + uniq_truthy_values.size == 1 + end + + # @api private + # @return [Boolean] + def actual_exists? + existence_values.first + end + + # @api private + # @return [String] + def validity_message + case uniq_truthy_values.size + when 0 + " but it does not respond to either `exist?` or `exists?`" + when 2 + " but `exist?` and `exists?` returned different values:\n\n"\ + " exist?: #{existence_values.first}\n"\ + "exists?: #{existence_values.last}" + end + end + + private + + def uniq_truthy_values + @uniq_truthy_values ||= existence_values.map { |v| !!v }.uniq + end + + def existence_values + @existence_values ||= predicates.map { |p| actual.__send__(p, *expected) } + end + + def predicates + @predicates ||= [:exist?, :exists?].select { |p| actual.respond_to?(p) } + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/has.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/has.rb new file mode 100644 index 000000000..f37cfcfb1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/has.rb @@ -0,0 +1,101 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `has_`. + # Not intended to be instantiated directly. + class Has < BaseMatcher + def initialize(method_name, *args, &block) + @method_name, @args, @block = method_name, args, block + end + + # @private + def matches?(actual, &block) + @actual = actual + @block ||= block + predicate_accessible? && predicate_matches? + end + + # @private + def does_not_match?(actual, &block) + @actual = actual + @block ||= block + predicate_accessible? && !predicate_matches? + end + + # @api private + # @return [String] + def failure_message + validity_message || "expected ##{predicate}#{failure_message_args_description} to return true, got false" + end + + # @api private + # @return [String] + def failure_message_when_negated + validity_message || "expected ##{predicate}#{failure_message_args_description} to return false, got true" + end + + # @api private + # @return [String] + def description + [method_description, args_description].compact.join(' ') + end + + private + + def predicate_accessible? + !private_predicate? && predicate_exists? + end + + # support 1.8.7, evaluate once at load time for performance + if String === methods.first + def private_predicate? + @actual.private_methods.include? predicate.to_s + end + else + def private_predicate? + @actual.private_methods.include? predicate + end + end + + def predicate_exists? + @actual.respond_to? predicate + end + + def predicate_matches? + @actual.__send__(predicate, *@args, &@block) + end + + def predicate + # On 1.9, there appears to be a bug where String#match can return `false` + # rather than the match data object. Changing to Regex#match appears to + # work around this bug. For an example of this bug, see: + # https://travis-ci.org/rspec/rspec-expectations/jobs/27549635 + @predicate ||= :"has_#{Matchers::HAS_REGEX.match(@method_name.to_s).captures.first}?" + end + + def method_description + @method_name.to_s.gsub('_', ' ') + end + + def args_description + return nil if @args.empty? + @args.map { |arg| arg.inspect }.join(', ') + end + + def failure_message_args_description + desc = args_description + "(#{desc})" if desc + end + + def validity_message + if private_predicate? + "expected #{@actual} to respond to `#{predicate}` but `#{predicate}` is a private method" + elsif !predicate_exists? + "expected #{@actual} to respond to `#{predicate}`" + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/have_attributes.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/have_attributes.rb new file mode 100644 index 000000000..79102c4cf --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/have_attributes.rb @@ -0,0 +1,84 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `have_attributes`. + # Not intended to be instantiated directly. + class HaveAttributes < BaseMatcher + # @private + attr_reader :respond_to_failed + + def initialize(expected) + @expected = expected + @respond_to_failed = false + end + + # @api private + # @return [Boolean] + def matches?(actual) + @actual = actual + return false unless respond_to_attributes? + perform_match(:all?) + end + + # @api private + # @return [Boolean] + def does_not_match?(actual) + @actual = actual + return false unless respond_to_attributes? + perform_match(:none?) + end + + # @api private + # @return [String] + def description + described_items = surface_descriptions_in(expected) + improve_hash_formatting "have attributes #{described_items.inspect}" + end + + # @api private + # @return [String] + def failure_message + respond_to_failure_message_or { super } + end + + # @api private + # @return [String] + def failure_message_when_negated + respond_to_failure_message_or { super } + end + + private + + def perform_match(predicate) + expected.__send__(predicate) do |attribute_key, attribute_value| + actual_has_attribute?(attribute_key, attribute_value) + end + end + + def actual_has_attribute?(attribute_key, attribute_value) + actual_value = actual.__send__(attribute_key) + values_match?(attribute_value, actual_value) + end + + def respond_to_attributes? + matches = respond_to_matcher.matches?(actual) + @respond_to_failed = !matches + matches + end + + def respond_to_matcher + @respond_to_matcher ||= RespondTo.new(*expected.keys).with(0).arguments + end + + def respond_to_failure_message_or + if respond_to_failed + respond_to_matcher.failure_message + else + improve_hash_formatting(yield) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/include.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/include.rb new file mode 100644 index 000000000..86af7a399 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/include.rb @@ -0,0 +1,105 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `include`. + # Not intended to be instantiated directly. + class Include < BaseMatcher + def initialize(*expected) + @expected = expected + end + + # @api private + # @return [Boolean] + def matches?(actual) + @actual = actual + perform_match(:all?, :all?) + end + + # @api private + # @return [Boolean] + def does_not_match?(actual) + @actual = actual + perform_match(:none?, :any?) + end + + # @api private + # @return [String] + def description + described_items = surface_descriptions_in(expected) + improve_hash_formatting "include#{to_sentence(described_items)}" + end + + # @api private + # @return [String] + def failure_message + improve_hash_formatting(super) + invalid_type_message + end + + # @api private + # @return [String] + def failure_message_when_negated + improve_hash_formatting(super) + invalid_type_message + end + + # @api private + # @return [Boolean] + def diffable? + true + end + + private + + def invalid_type_message + return '' if actual.respond_to?(:include?) + ", but it does not respond to `include?`" + end + + def perform_match(predicate, hash_subset_predicate) + return false unless actual.respond_to?(:include?) + + expected.__send__(predicate) do |expected_item| + if comparing_hash_to_a_subset?(expected_item) + expected_item.__send__(hash_subset_predicate) do |(key, value)| + actual_hash_includes?(key, value) + end + elsif comparing_hash_keys?(expected_item) + actual_hash_has_key?(expected_item) + else + actual_collection_includes?(expected_item) + end + end + end + + def comparing_hash_to_a_subset?(expected_item) + actual.is_a?(Hash) && expected_item.is_a?(Hash) + end + + def actual_hash_includes?(expected_key, expected_value) + actual_value = actual.fetch(expected_key) { return false } + values_match?(expected_value, actual_value) + end + + def comparing_hash_keys?(expected_item) + actual.is_a?(Hash) && !expected_item.is_a?(Hash) + end + + def actual_hash_has_key?(expected_key) + # We check `key?` first for perf: + # `key?` is O(1), but `any?` is O(N). + actual.key?(expected_key) || + actual.keys.any? { |key| values_match?(expected_key, key) } + end + + def actual_collection_includes?(expected_item) + return true if actual.include?(expected_item) + + # String lacks an `any?` method... + return false unless actual.respond_to?(:any?) + + actual.any? { |value| values_match?(expected_item, value) } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/match.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/match.rb new file mode 100644 index 000000000..9e44e8dfe --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/match.rb @@ -0,0 +1,29 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `match`. + # Not intended to be instantiated directly. + class Match < BaseMatcher + # @api private + # @return [String] + def description + "match #{surface_descriptions_in(expected).inspect}" + end + + # @api private + # @return [Boolean] + def diffable? + true + end + + private + + def match(expected, actual) + return true if values_match?(expected, actual) + actual.match(expected) if actual.respond_to?(:match) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/operators.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/operators.rb new file mode 100644 index 000000000..eada4b55b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/operators.rb @@ -0,0 +1,119 @@ +require 'rspec/support' + +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for operator matchers. + # Not intended to be instantiated directly. + # Only available for use with `should`. + class OperatorMatcher + class << self + # @private + def registry + @registry ||= {} + end + + # @private + def register(klass, operator, matcher) + registry[klass] ||= {} + registry[klass][operator] = matcher + end + + # @private + def unregister(klass, operator) + registry[klass] && registry[klass].delete(operator) + end + + # @private + def get(klass, operator) + klass.ancestors.each do |ancestor| + matcher = registry[ancestor] && registry[ancestor][operator] + return matcher if matcher + end + + nil + end + end + + register Enumerable, '=~', BuiltIn::ContainExactly + + def initialize(actual) + @actual = actual + end + + # @private + def self.use_custom_matcher_or_delegate(operator) + define_method(operator) do |expected| + if !has_non_generic_implementation_of?(operator) && (matcher = OperatorMatcher.get(@actual.class, operator)) + @actual.__send__(::RSpec::Matchers.last_expectation_handler.should_method, matcher.new(expected)) + else + eval_match(@actual, operator, expected) + end + end + + negative_operator = operator.sub(/^=/, '!') + if negative_operator != operator && respond_to?(negative_operator) + define_method(negative_operator) do |_expected| + opposite_should = ::RSpec::Matchers.last_expectation_handler.opposite_should_method + raise "RSpec does not support `#{::RSpec::Matchers.last_expectation_handler.should_method} #{negative_operator} expected`. " \ + "Use `#{opposite_should} #{operator} expected` instead." + end + end + end + + ['==', '===', '=~', '>', '>=', '<', '<='].each do |operator| + use_custom_matcher_or_delegate operator + end + + # @private + def fail_with_message(message) + RSpec::Expectations.fail_with(message, @expected, @actual) + end + + # @api private + # @return [String] + def description + "#{@operator} #{@expected.inspect}" + end + + private + + def has_non_generic_implementation_of?(op) + Support.method_handle_for(@actual, op).owner != ::Kernel + rescue NameError + false + end + + def eval_match(actual, operator, expected) + ::RSpec::Matchers.last_matcher = self + @operator, @expected = operator, expected + __delegate_operator(actual, operator, expected) + end + end + + # @private + # Handles operator matcher for `should`. + class PositiveOperatorMatcher < OperatorMatcher + def __delegate_operator(actual, operator, expected) + if actual.__send__(operator, expected) + true + elsif ['==', '===', '=~'].include?(operator) + fail_with_message("expected: #{expected.inspect}\n got: #{actual.inspect} (using #{operator})") + else + fail_with_message("expected: #{operator} #{expected.inspect}\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}") + end + end + end + + # @private + # Handles operator matcher for `should_not`. + class NegativeOperatorMatcher < OperatorMatcher + def __delegate_operator(actual, operator, expected) + return false unless actual.__send__(operator, expected) + fail_with_message("expected not: #{operator} #{expected.inspect}\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}") + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/output.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/output.rb new file mode 100644 index 000000000..8bc78813f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/output.rb @@ -0,0 +1,152 @@ +require 'stringio' + +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `output`. + # Not intended to be instantiated directly. + class Output < BaseMatcher + def initialize(expected) + @expected = expected + @actual = "" + @block = nil + @stream_capturer = NullCapture + end + + def matches?(block) + @block = block + return false unless Proc === block + @actual = @stream_capturer.capture(block) + @expected ? values_match?(@expected, @actual) : captured? + end + + def does_not_match?(block) + !matches?(block) && Proc === block + end + + # @api public + # Tells the matcher to match against stdout. + def to_stdout + @stream_capturer = CaptureStdout + self + end + + # @api public + # Tells the matcher to match against stderr. + def to_stderr + @stream_capturer = CaptureStderr + self + end + + # @api private + # @return [String] + def failure_message + "expected block to #{description}, but #{positive_failure_reason}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected block to not #{description}, but #{negative_failure_reason}" + end + + # @api private + # @return [String] + def description + if @expected + "output #{description_of @expected} to #{@stream_capturer.name}" + else + "output to #{@stream_capturer.name}" + end + end + + # @api private + # @return [Boolean] + def diffable? + true + end + + # @api private + # Indicates this matcher matches against a block. + # @return [True] + def supports_block_expectations? + true + end + + private + + def captured? + @actual.length > 0 + end + + def positive_failure_reason + return "was not a block" unless Proc === @block + return "output #{actual_output_description}" if @expected + "did not" + end + + def negative_failure_reason + return "was not a block" unless Proc === @block + "output #{actual_output_description}" + end + + def actual_output_description + return "nothing" unless captured? + @actual.inspect + end + end + + # @private + module NullCapture + def self.name + "some stream" + end + + def self.capture(_block) + raise "You must chain `to_stdout` or `to_stderr` off of the `output(...)` matcher." + end + end + + # @private + module CaptureStdout + def self.name + 'stdout' + end + + def self.capture(block) + captured_stream = StringIO.new + + original_stream = $stdout + $stdout = captured_stream + + block.call + + captured_stream.string + ensure + $stdout = original_stream + end + end + + # @private + module CaptureStderr + def self.name + 'stderr' + end + + def self.capture(block) + captured_stream = StringIO.new + + original_stream = $stderr + $stderr = captured_stream + + block.call + + captured_stream.string + ensure + $stderr = original_stream + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/raise_error.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/raise_error.rb new file mode 100644 index 000000000..b8e2bc0ce --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/raise_error.rb @@ -0,0 +1,174 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `raise_error`. + # Not intended to be instantiated directly. + # rubocop:disable ClassLength + class RaiseError + include Composable + + def initialize(expected_error_or_message=Exception, expected_message=nil, &block) + @block = block + @actual_error = nil + case expected_error_or_message + when String, Regexp + @expected_error, @expected_message = Exception, expected_error_or_message + else + @expected_error, @expected_message = expected_error_or_message, expected_message + end + end + + # @api public + # Specifies the expected error message. + def with_message(expected_message) + raise_message_already_set if @expected_message + @expected_message = expected_message + self + end + + # rubocop:disable MethodLength + # @private + def matches?(given_proc, negative_expectation=false, &block) + @given_proc = given_proc + @block ||= block + @raised_expected_error = false + @with_expected_message = false + @eval_block = false + @eval_block_passed = false + + return false unless Proc === given_proc + + begin + given_proc.call + rescue Exception => @actual_error + if values_match?(@expected_error, @actual_error) + @raised_expected_error = true + @with_expected_message = verify_message + end + end + + unless negative_expectation + eval_block if @raised_expected_error && @with_expected_message && @block + end + + expectation_matched? + end + # rubocop:enable MethodLength + + # @private + def does_not_match?(given_proc) + prevent_invalid_expectations + !matches?(given_proc, :negative_expectation) && Proc === given_proc + end + + # @private + def supports_block_expectations? + true + end + + def expects_call_stack_jump? + true + end + + # @api private + # @return [String] + def failure_message + @eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected no #{expected_error}#{given_error}" + end + + # @api private + # @return [String] + def description + "raise #{expected_error}" + end + + private + + def expectation_matched? + error_and_message_match? && block_matches? + end + + def error_and_message_match? + @raised_expected_error && @with_expected_message + end + + def block_matches? + @eval_block ? @eval_block_passed : true + end + + def eval_block + @eval_block = true + begin + @block[@actual_error] + @eval_block_passed = true + rescue Exception => err + @actual_error = err + end + end + + def verify_message + return true if @expected_message.nil? + values_match?(@expected_message, @actual_error.message) + end + + def prevent_invalid_expectations + what_to_raise = if expecting_specific_exception? && @expected_message + "`expect { }.not_to raise_error(SpecificErrorClass, message)`" + elsif expecting_specific_exception? + "`expect { }.not_to raise_error(SpecificErrorClass)`" + elsif @expected_message + "`expect { }.not_to raise_error(message)`" + end + + return unless what_to_raise + + specific_class_error = ArgumentError.new("#{what_to_raise} is not valid, use `expect { }.not_to raise_error` (with no args) instead") + raise specific_class_error + end + + def expected_error + case @expected_message + when nil + description_of(@expected_error) + when Regexp + "#{@expected_error} with message matching #{@expected_message.inspect}" + else + "#{@expected_error} with #{description_of @expected_message}" + end + end + + def format_backtrace(backtrace) + formatter = Matchers.configuration.backtrace_formatter + formatter.format_backtrace(backtrace) + end + + def given_error + return " but was not given a block" unless Proc === @given_proc + return " but nothing was raised" unless @actual_error + + backtrace = format_backtrace(@actual_error.backtrace) + [ + ", got #{@actual_error.inspect} with backtrace:", + *backtrace + ].join("\n # ") + end + + def expecting_specific_exception? + @expected_error != Exception + end + + def raise_message_already_set + raise "`expect { }.to raise_error(message).with_message(message)` is not valid. The matcher only allows the expected message to be specified once" + end + end + # rubocop:enable ClassLength + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/respond_to.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/respond_to.rb new file mode 100644 index 000000000..85c116401 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/respond_to.rb @@ -0,0 +1,91 @@ +RSpec::Support.require_rspec_support "method_signature_verifier" + +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `respond_to`. + # Not intended to be instantiated directly. + class RespondTo < BaseMatcher + def initialize(*names) + @names = names + @expected_arity = nil + end + + # @api public + # Specifies the number of expected arguments. + # + # @example + # expect(obj).to respond_to(:message).with(3).arguments + def with(n) + @expected_arity = n + self + end + + # @api public + # No-op. Intended to be used as syntactic sugar when using `with`. + # + # @example + # expect(obj).to respond_to(:message).with(3).arguments + def argument + self + end + alias :arguments :argument + + # @private + def matches?(actual) + find_failing_method_names(actual, :reject).empty? + end + + # @private + def does_not_match?(actual) + find_failing_method_names(actual, :select).empty? + end + + # @api private + # @return [String] + def failure_message + "expected #{@actual.inspect} to respond to #{@failing_method_names.map { |name| name.inspect }.join(', ')}#{with_arity}" + end + + # @api private + # @return [String] + def failure_message_when_negated + failure_message.sub(/to respond to/, 'not to respond to') + end + + # @api private + # @return [String] + def description + "respond to #{pp_names}#{with_arity}" + end + + private + + def find_failing_method_names(actual, filter_method) + @actual = actual + @failing_method_names = @names.__send__(filter_method) do |name| + @actual.respond_to?(name) && matches_arity?(actual, name) + end + end + + def matches_arity?(actual, name) + return true unless @expected_arity + + signature = Support::MethodSignature.new(actual.method(name)) + Support::StrictSignatureVerifier.new(signature, Array.new(@expected_arity)).valid? + end + + def with_arity + return "" unless @expected_arity + " with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}" + end + + def pp_names + # Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here + @names.length == 1 ? "##{@names.first}" : @names.inspect + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/satisfy.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/satisfy.rb new file mode 100644 index 000000000..d79a58430 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/satisfy.rb @@ -0,0 +1,39 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `satisfy`. + # Not intended to be instantiated directly. + class Satisfy < BaseMatcher + def initialize(&block) + @block = block + end + + # @private + def matches?(actual, &block) + @block = block if block + @actual = actual + @block.call(actual) + end + + # @api private + # @return [String] + def failure_message + "expected #{@actual} to satisfy block" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{@actual} not to satisfy block" + end + + # @api private + # @return [String] + def description + "satisfy block" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/start_and_end_with.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/start_and_end_with.rb new file mode 100644 index 000000000..29fa8c412 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/start_and_end_with.rb @@ -0,0 +1,82 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Base class for the `end_with` and `start_with` matchers. + # Not intended to be instantiated directly. + class StartAndEndWith < BaseMatcher + def initialize(*expected) + @actual_does_not_have_ordered_elements = false + @expected = expected.length == 1 ? expected.first : expected + end + + # @api private + # @return [String] + def failure_message + super.tap do |msg| + if @actual_does_not_have_ordered_elements + msg << ", but it does not have ordered elements" + elsif !actual.respond_to?(:[]) + msg << ", but it cannot be indexed using #[]" + end + end + end + + # @api private + # @return [String] + def description + return super unless Hash === expected + "#{name_to_sentence} #{surface_descriptions_in(expected).inspect}" + end + + private + + def match(expected, actual) + return false unless actual.respond_to?(:[]) + + begin + return subset_matches? if !(Struct === expected) && expected.respond_to?(:length) + element_matches? + rescue ArgumentError + @actual_does_not_have_ordered_elements = true + return false + end + end + + def actual_is_unordered + ArgumentError.new("#{actual.inspect} does not have ordered elements") + end + end + + # @api private + # Provides the implementation for `start_with`. + # Not intended to be instantiated directly. + class StartWith < StartAndEndWith + private + + def subset_matches? + values_match?(expected, actual[0, expected.length]) + end + + def element_matches? + values_match?(expected, actual[0]) + end + end + + # @api private + # Provides the implementation for `end_with`. + # Not intended to be instantiated directly. + class EndWith < StartAndEndWith + private + + def subset_matches? + values_match?(expected, actual[-expected.length, expected.length]) + end + + def element_matches? + values_match?(expected, actual[-1]) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/throw_symbol.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/throw_symbol.rb new file mode 100644 index 000000000..5131842b2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/throw_symbol.rb @@ -0,0 +1,132 @@ +module RSpec + module Matchers + module BuiltIn + # @api private + # Provides the implementation for `throw_symbol`. + # Not intended to be instantiated directly. + class ThrowSymbol + include Composable + + def initialize(expected_symbol=nil, expected_arg=nil) + @expected_symbol = expected_symbol + @expected_arg = expected_arg + @caught_symbol = @caught_arg = nil + end + + # rubocop:disable MethodLength + # @private + def matches?(given_proc) + @block = given_proc + return false unless Proc === given_proc + + begin + if @expected_symbol.nil? + given_proc.call + else + @caught_arg = catch :proc_did_not_throw_anything do + catch @expected_symbol do + given_proc.call + throw :proc_did_not_throw_anything, :nothing_thrown + end + end + + if @caught_arg == :nothing_thrown + @caught_arg = nil + else + @caught_symbol = @expected_symbol + end + end + + # Ruby 1.8 uses NameError with `symbol' + # Ruby 1.9 uses ArgumentError with :symbol + rescue NameError, ArgumentError => e + unless (match_data = e.message.match(/uncaught throw (`|\:)([a-zA-Z0-9_]*)(')?/)) + other_exception = e + raise + end + @caught_symbol = match_data.captures[1].to_sym + rescue => other_exception + raise + ensure + # rubocop:disable EnsureReturn + unless other_exception + if @expected_symbol.nil? + return !!@caught_symbol + else + if @expected_arg.nil? + return @caught_symbol == @expected_symbol + else + return (@caught_symbol == @expected_symbol) && values_match?(@expected_arg, @caught_arg) + end + end + end + # rubocop:enable EnsureReturn + end + end + # rubocop:enable MethodLength + + def does_not_match?(given_proc) + !matches?(given_proc) && Proc === given_proc + end + + # @api private + # @return [String] + def failure_message + "expected #{expected} to be thrown, #{actual_result}" + end + + # @api private + # @return [String] + def failure_message_when_negated + "expected #{expected('no Symbol')}#{' not' if @expected_symbol} to be thrown, #{actual_result}" + end + + # @api private + # @return [String] + def description + "throw #{expected}" + end + + # @api private + # Indicates this matcher matches against a block. + # @return [True] + def supports_block_expectations? + true + end + + def expects_call_stack_jump? + true + end + + private + + def actual_result + return "but was not a block" unless Proc === @block + "got #{caught}" + end + + def expected(symbol_desc='a Symbol') + throw_description(@expected_symbol || symbol_desc, @expected_arg) + end + + def caught + throw_description(@caught_symbol || 'nothing', @caught_arg) + end + + def throw_description(symbol, arg) + symbol_description = symbol.is_a?(String) ? symbol : symbol.inspect + + arg_description = if arg + " with #{description_of arg}" + elsif @expected_arg && @caught_symbol == @expected_symbol + " with no argument" + else + "" + end + + symbol_description + arg_description + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/yield.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/yield.rb new file mode 100644 index 000000000..603ec9c63 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/built_in/yield.rb @@ -0,0 +1,420 @@ +RSpec::Support.require_rspec_support "method_signature_verifier" + +module RSpec + module Matchers + module BuiltIn + # @private + # Object that is yielded to `expect` when one of the + # yield matchers is used. Provides information about + # the yield behavior of the object-under-test. + class YieldProbe + def self.probe(block) + probe = new(block) + return probe unless probe.has_block? + probe.assert_valid_expect_block! + block.call(probe) + probe.assert_used! + probe + end + + attr_accessor :num_yields, :yielded_args + + def initialize(block) + @block = block + @used = false + self.num_yields, self.yielded_args = 0, [] + end + + def has_block? + Proc === @block + end + + def to_proc + @used = true + + probe = self + Proc.new do |*args| + probe.num_yields += 1 + probe.yielded_args << args + nil # to indicate the block does not return a meaningful value + end + end + + def single_yield_args + yielded_args.first + end + + def yielded_once?(matcher_name) + case num_yields + when 1 then true + when 0 then false + else + raise "The #{matcher_name} matcher is not designed to be used with a " \ + "method that yields multiple times. Use the yield_successive_args " \ + "matcher for that case." + end + end + + def successive_yield_args + yielded_args.map do |arg_array| + arg_array.size == 1 ? arg_array.first : arg_array + end + end + + def assert_used! + return if @used + raise "You must pass the argument yielded to your expect block on " \ + "to the method-under-test as a block. It acts as a probe that " \ + "allows the matcher to detect whether or not the method-under-test " \ + "yields, and, if so, how many times, and what the yielded arguments " \ + "are." + end + + if RUBY_VERSION.to_f > 1.8 + def assert_valid_expect_block! + block_signature = RSpec::Support::BlockSignature.new(@block) + return if RSpec::Support::StrictSignatureVerifier.new(block_signature, [self]).valid? + raise "Your expect block must accept an argument to be used with this " \ + "matcher. Pass the argument as a block on to the method you are testing." + end + else + # On 1.8.7, `lambda { }.arity` and `lambda { |*a| }.arity` both return -1, + # so we can't distinguish between accepting no args and an arg splat. + # It's OK to skip, this, though; it just provides a nice error message + # when the user forgets to accept an arg in their block. They'll still get + # the `assert_used!` error message from above, which is sufficient. + def assert_valid_expect_block! + # nothing to do + end + end + end + + # @api private + # Provides the implementation for `yield_control`. + # Not intended to be instantiated directly. + class YieldControl < BaseMatcher + def initialize + @expectation_type = nil + @expected_yields_count = nil + end + + # @api public + # Specifies that the method is expected to yield once. + def once + exactly(1) + self + end + + # @api public + # Specifies that the method is expected to yield twice. + def twice + exactly(2) + self + end + + # @api public + # Specifies that the method is expected to yield thrice. + def thrice + exactly(3) + self + end + + # @api public + # Specifies that the method is expected to yield the given number of times. + def exactly(number) + set_expected_yields_count(:==, number) + self + end + + # @api public + # Specifies the maximum number of times the method is expected to yield + def at_most(number) + set_expected_yields_count(:<=, number) + self + end + + # @api public + # Specifies the minimum number of times the method is expected to yield + def at_least(number) + set_expected_yields_count(:>=, number) + self + end + + # @api public + # No-op. Provides syntactic sugar. + def times + self + end + + # @private + def matches?(block) + @probe = YieldProbe.probe(block) + return false unless @probe.has_block? + + if @expectation_type + @probe.num_yields.__send__(@expectation_type, @expected_yields_count) + else + @probe.yielded_once?(:yield_control) + end + end + + # @private + def does_not_match?(block) + !matches?(block) && @probe.has_block? + end + + # @api private + # @return [String] + def failure_message + 'expected given block to yield control' + failure_reason + end + + # @api private + # @return [String] + def failure_message_when_negated + 'expected given block not to yield control' + failure_reason + end + + # @private + def supports_block_expectations? + true + end + + private + + def set_expected_yields_count(relativity, n) + @expectation_type = relativity + @expected_yields_count = case n + when Numeric then n + when :once then 1 + when :twice then 2 + when :thrice then 3 + end + end + + def failure_reason + return " but was not a block" unless @probe.has_block? + return '' unless @expected_yields_count + " #{human_readable_expecation_type}#{human_readable_count}" + end + + def human_readable_expecation_type + case @expectation_type + when :<= then 'at most ' + when :>= then 'at least ' + else '' + end + end + + def human_readable_count + case @expected_yields_count + when 1 then "once" + when 2 then "twice" + else "#{@expected_yields_count} times" + end + end + end + + # @api private + # Provides the implementation for `yield_with_no_args`. + # Not intended to be instantiated directly. + class YieldWithNoArgs < BaseMatcher + # @private + def matches?(block) + @probe = YieldProbe.probe(block) + return false unless @probe.has_block? + @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty? + end + + # @private + def does_not_match?(block) + !matches?(block) && @probe.has_block? + end + + # @private + def failure_message + "expected given block to yield with no arguments, but #{positive_failure_reason}" + end + + # @private + def failure_message_when_negated + "expected given block not to yield with no arguments, but #{negative_failure_reason}" + end + + # @private + def supports_block_expectations? + true + end + + private + + def positive_failure_reason + return "was not a block" unless @probe.has_block? + return "did not yield" if @probe.num_yields.zero? + "yielded with arguments: #{@probe.single_yield_args.inspect}" + end + + def negative_failure_reason + return "was not a block" unless @probe.has_block? + "did" + end + end + + # @api private + # Provides the implementation for `yield_with_args`. + # Not intended to be instantiated directly. + class YieldWithArgs < BaseMatcher + def initialize(*args) + @expected = args + end + + # @private + def matches?(block) + @probe = YieldProbe.probe(block) + return false unless @probe.has_block? + @actual = @probe.single_yield_args + @probe.yielded_once?(:yield_with_args) && args_match? + end + + # @private + def does_not_match?(block) + !matches?(block) && @probe.has_block? + end + + # @private + def failure_message + "expected given block to yield with arguments, but #{positive_failure_reason}" + end + + # @private + def failure_message_when_negated + "expected given block not to yield with arguments, but #{negative_failure_reason}" + end + + # @private + def description + desc = "yield with args" + desc << "(#{expected_arg_description})" unless @expected.empty? + desc + end + + # @private + def supports_block_expectations? + true + end + + private + + def positive_failure_reason + return "was not a block" unless @probe.has_block? + return "did not yield" if @probe.num_yields.zero? + @positive_args_failure + end + + def expected_arg_description + @expected.map { |e| description_of e }.join(", ") + end + + def negative_failure_reason + if !@probe.has_block? + "was not a block" + elsif all_args_match? + "yielded with expected arguments" \ + "\nexpected not: #{surface_descriptions_in(@expected).inspect}" + + "\n got: #{@actual.inspect}" + else + "did" + end + end + + def args_match? + if @expected.empty? # expect {...}.to yield_with_args + @positive_args_failure = "yielded with no arguments" if @actual.empty? + return !@actual.empty? + end + + unless (match = all_args_match?) + @positive_args_failure = "yielded with unexpected arguments" \ + "\nexpected: #{surface_descriptions_in(@expected).inspect}" + + "\n got: #{@actual.inspect}" + end + + match + end + + def all_args_match? + values_match?(@expected, @actual) + end + end + + # @api private + # Provides the implementation for `yield_successive_args`. + # Not intended to be instantiated directly. + class YieldSuccessiveArgs < BaseMatcher + def initialize(*args) + @expected = args + end + + # @private + def matches?(block) + @probe = YieldProbe.probe(block) + return false unless @probe.has_block? + @actual = @probe.successive_yield_args + args_match? + end + + def does_not_match?(block) + !matches?(block) && @probe.has_block? + end + + # @private + def failure_message + "expected given block to yield successively with arguments, but #{positive_failure_reason}" + end + + # @private + def failure_message_when_negated + "expected given block not to yield successively with arguments, but #{negative_failure_reason}" + end + + # @private + def description + desc = "yield successive args" + desc << "(#{expected_arg_description})" + desc + end + + # @private + def supports_block_expectations? + true + end + + private + + def args_match? + values_match?(@expected, @actual) + end + + def expected_arg_description + @expected.map { |e| description_of e }.join(", ") + end + + def positive_failure_reason + return "was not a block" unless @probe.has_block? + + "yielded with unexpected arguments" \ + "\nexpected: #{surface_descriptions_in(@expected).inspect}" \ + "\n got: #{@actual.inspect}" + end + + def negative_failure_reason + return "was not a block" unless @probe.has_block? + + "yielded with expected arguments" \ + "\nexpected not: #{surface_descriptions_in(@expected).inspect}" \ + "\n got: #{@actual.inspect}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/composable.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/composable.rb new file mode 100644 index 000000000..81e65e92b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/composable.rb @@ -0,0 +1,183 @@ +RSpec::Support.require_rspec_support "fuzzy_matcher" + +module RSpec + module Matchers + # Mixin designed to support the composable matcher features + # of RSpec 3+. Mix it into your custom matcher classes to + # allow them to be used in a composable fashion. + # + # @api public + module Composable + # Creates a compound `and` expectation. The matcher will + # only pass if both sub-matchers pass. + # This can be chained together to form an arbitrarily long + # chain of matchers. + # + # @example + # expect(alphabet).to start_with("a").and end_with("z") + # expect(alphabet).to start_with("a") & end_with("z") + # + # @note The negative form (`expect(...).not_to matcher.and other`) + # is not supported at this time. + def and(matcher) + BuiltIn::Compound::And.new self, matcher + end + alias & and + + # Creates a compound `or` expectation. The matcher will + # pass if either sub-matcher passes. + # This can be chained together to form an arbitrarily long + # chain of matchers. + # + # @example + # expect(stoplight.color).to eq("red").or eq("green").or eq("yellow") + # expect(stoplight.color).to eq("red") | eq("green") | eq("yellow") + # + # @note The negative form (`expect(...).not_to matcher.or other`) + # is not supported at this time. + def or(matcher) + BuiltIn::Compound::Or.new self, matcher + end + alias | or + + # Delegates to `#matches?`. Allows matchers to be used in composable + # fashion and also supports using matchers in case statements. + def ===(value) + matches?(value) + end + + private + + # This provides a generic way to fuzzy-match an expected value against + # an actual value. It understands nested data structures (e.g. hashes + # and arrays) and is able to match against a matcher being used as + # the expected value or within the expected value at any level of + # nesting. + # + # Within a custom matcher you are encouraged to use this whenever your + # matcher needs to match two values, unless it needs more precise semantics. + # For example, the `eq` matcher _does not_ use this as it is meant to + # use `==` (and only `==`) for matching. + # + # @param expected [Object] what is expected + # @param actual [Object] the actual value + # + # @!visibility public + def values_match?(expected, actual) + expected = with_matchers_cloned(expected) + Support::FuzzyMatcher.values_match?(expected, actual) + end + + # Returns the description of the given object in a way that is + # aware of composed matchers. If the object is a matcher with + # a `description` method, returns the description; otherwise + # returns `object.inspect`. + # + # You are encouraged to use this in your custom matcher's + # `description`, `failure_message` or + # `failure_message_when_negated` implementation if you are + # supporting matcher arguments. + # + # @!visibility public + def description_of(object) + return object.description if Matchers.is_a_describable_matcher?(object) + object.inspect + end + + # Transforms the given data structue (typically a hash or array) + # into a new data structure that, when `#inspect` is called on it, + # will provide descriptions of any contained matchers rather than + # the normal `#inspect` output. + # + # You are encouraged to use this in your custom matcher's + # `description`, `failure_message` or + # `failure_message_when_negated` implementation if you are + # supporting any arguments which may be a data structure + # containing matchers. + # + # @!visibility public + def surface_descriptions_in(item) + if Matchers.is_a_describable_matcher?(item) + DescribableItem.new(item) + elsif Hash === item + Hash[surface_descriptions_in(item.to_a)] + elsif Struct === item + item.inspect + elsif enumerable?(item) + begin + item.map { |subitem| surface_descriptions_in(subitem) } + rescue IOError # STDOUT is enumerable but `map` raises an error + item.inspect + end + else + item + end + end + + # @private + # Historically, a single matcher instance was only checked + # against a single value. Given that the matcher was only + # used once, it's been common to memoize some intermediate + # calculation that is derived from the `actual` value in + # order to reuse that intermediate result in the failure + # message. + # + # This can cause a problem when using such a matcher as an + # argument to another matcher in a composed matcher expression, + # since the matcher instance may be checked against multiple + # values and produce invalid results due to the memoization. + # + # To deal with this, we clone any matchers in `expected` via + # this method when using `values_match?`, so that any memoization + # does not "leak" between checks. + def with_matchers_cloned(object) + if Matchers.is_a_matcher?(object) + object.clone + elsif Hash === object + Hash[with_matchers_cloned(object.to_a)] + elsif Struct === object + object + elsif enumerable?(object) + begin + object.map { |subobject| with_matchers_cloned(subobject) } + rescue IOError # STDOUT is enumerable but `map` raises an error + object + end + else + object + end + end + + if String.ancestors.include?(Enumerable) # 1.8.7 + # Strings are not enumerable on 1.9, and on 1.8 they are an infinitely + # nested enumerable: since ruby lacks a character class, it yields + # 1-character strings, which are themselves enumerable, composed of a + # a single 1-character string, which is an enumerable, etc. + # + # @api private + def enumerable?(item) + return false if String === item + Enumerable === item + end + else + # @api private + def enumerable?(item) + Enumerable === item + end + end + module_function :surface_descriptions_in, :enumerable? + + # Wraps an item in order to surface its `description` via `inspect`. + # @api private + DescribableItem = Struct.new(:item) do + def inspect + "(#{item.description})" + end + + def pretty_print(pp) + pp.text "(#{item.description})" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/dsl.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/dsl.rb new file mode 100644 index 000000000..fd5d35566 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/dsl.rb @@ -0,0 +1,391 @@ +module RSpec + module Matchers + # Defines the custom matcher DSL. + module DSL + # Defines a custom matcher. + # @see RSpec::Matchers + def define(name, &declarations) + define_method name do |*expected| + RSpec::Matchers::DSL::Matcher.new(name, declarations, self, *expected) + end + end + alias_method :matcher, :define + + RSpec.configure { |c| c.extend self } if RSpec.respond_to?(:configure) + + # Contains the methods that are available from within the + # `RSpec::Matchers.define` DSL for creating custom matchers. + module Macros + # Stores the block that is used to determine whether this matcher passes + # or fails. The block should return a boolean value. When the matcher is + # passed to `expect(...).to` and the block returns `true`, then the expectation + # passes. Similarly, when the matcher is passed to `expect(...).not_to` and the + # block returns `false`, then the expectation passes. + # + # @example + # + # RSpec::Matchers.define :be_even do + # match do |actual| + # actual.even? + # end + # end + # + # expect(4).to be_even # passes + # expect(3).not_to be_even # passes + # expect(3).to be_even # fails + # expect(4).not_to be_even # fails + # + # @yield [Object] actual the actual value (i.e. the value wrapped by `expect`) + def match(&match_block) + define_user_override(:matches?, match_block) do |actual| + begin + @actual = actual + super(*actual_arg_for(match_block)) + rescue RSpec::Expectations::ExpectationNotMetError + false + end + end + end + + # Use this to define the block for a negative expectation (`expect(...).not_to`) + # when the positive and negative forms require different handling. This + # is rarely necessary, but can be helpful, for example, when specifying + # asynchronous processes that require different timeouts. + # + # @yield [Object] actual the actual value (i.e. the value wrapped by `expect`) + def match_when_negated(&match_block) + define_user_override(:does_not_match?, match_block) do |actual| + @actual = actual + super(*actual_arg_for(match_block)) + end + end + + # Use this instead of `match` when the block will raise an exception + # rather than returning false to indicate a failure. + # + # @example + # + # RSpec::Matchers.define :accept_as_valid do |candidate_address| + # match_unless_raises ValidationException do |validator| + # validator.validate(candidate_address) + # end + # end + # + # expect(email_validator).to accept_as_valid("person@company.com") + # + # @yield [Object] actual the actual object (i.e. the value wrapped by `expect`) + def match_unless_raises(expected_exception=Exception, &match_block) + define_user_override(:matches?, match_block) do |actual| + @actual = actual + begin + super(*actual_arg_for(match_block)) + rescue expected_exception => @rescued_exception + false + else + true + end + end + end + + # Customizes the failure messsage to use when this matcher is + # asked to positively match. Only use this when the message + # generated by default doesn't suit your needs. + # + # @example + # + # RSpec::Matchers.define :have_strength do |expected| + # match { your_match_logic } + # + # failure_message do |actual| + # "Expected strength of #{expected}, but had #{actual.strength}" + # end + # end + # + # @yield [Object] actual the actual object (i.e. the value wrapped by `expect`) + def failure_message(&definition) + define_user_override(__method__, definition) + end + + # Customize the failure messsage to use when this matcher is asked + # to negatively match. Only use this when the message generated by + # default doesn't suit your needs. + # + # @example + # + # RSpec::Matchers.define :have_strength do |expected| + # match { your_match_logic } + # + # failure_message_when_negated do |actual| + # "Expected not to have strength of #{expected}, but did" + # end + # end + # + # @yield [Object] actual the actual object (i.e. the value wrapped by `expect`) + def failure_message_when_negated(&definition) + define_user_override(__method__, definition) + end + + # Customize the description to use for one-liners. Only use this when + # the description generated by default doesn't suit your needs. + # + # @example + # + # RSpec::Matchers.define :qualify_for do |expected| + # match { your_match_logic } + # + # description do + # "qualify for #{expected}" + # end + # end + # + # @yield [Object] actual the actual object (i.e. the value wrapped by `expect`) + def description(&definition) + define_user_override(__method__, definition) + end + + # Tells the matcher to diff the actual and expected values in the failure + # message. + def diffable + define_method(:diffable?) { true } + end + + # Declares that the matcher can be used in a block expectation. + # Users will not be able to use your matcher in a block + # expectation without declaring this. + # (e.g. `expect { do_something }.to matcher`). + def supports_block_expectations + define_method(:supports_block_expectations?) { true } + end + + # Convenience for defining methods on this matcher to create a fluent + # interface. The trick about fluent interfaces is that each method must + # return self in order to chain methods together. `chain` handles that + # for you. If the method is invoked and the + # `include_chain_clauses_in_custom_matcher_descriptions` config option + # hash been enabled, the chained method name and args will be added to the + # default description and failure message. + # + # @example + # + # RSpec::Matchers.define :have_errors_on do |key| + # chain :with do |message| + # @message = message + # end + # + # match do |actual| + # actual.errors[key] == @message + # end + # end + # + # expect(minor).to have_errors_on(:age).with("Not old enough to participate") + def chain(name, &definition) + define_user_override(name, definition) do |*args, &block| + super(*args, &block) + @chained_method_clauses.push([name, args]) + self + end + end + + private + + # Does the following: + # + # - Defines the named method usign a user-provided block + # in @user_method_defs, which is included as an ancestor + # in the singleton class in which we eval the `define` block. + # - Defines an overriden definition for the same method + # usign the provided `our_def` block. + # - Provides a default `our_def` block for the common case + # of needing to call the user's definition with `@actual` + # as an arg, but only if their block's arity can handle it. + # + # This compiles the user block into an actual method, allowing + # them to use normal method constructs like `return` + # (e.g. for a early guard statement), while allowing us to define + # an override that can provide the wrapped handling + # (e.g. assigning `@actual`, rescueing errors, etc) and + # can `super` to the user's definition. + def define_user_override(method_name, user_def, &our_def) + @user_method_defs.__send__(:define_method, method_name, &user_def) + our_def ||= lambda { super(*actual_arg_for(user_def)) } + define_method(method_name, &our_def) + end + + # Defines deprecated macro methods from RSpec 2 for backwards compatibility. + # @deprecated Use the methods from {Macros} instead. + module Deprecated + # @deprecated Use {Macros#match} instead. + def match_for_should(&definition) + RSpec.deprecate("`match_for_should`", :replacement => "`match`") + match(&definition) + end + + # @deprecated Use {Macros#match_when_negated} instead. + def match_for_should_not(&definition) + RSpec.deprecate("`match_for_should_not`", :replacement => "`match_when_negated`") + match_when_negated(&definition) + end + + # @deprecated Use {Macros#failure_message} instead. + def failure_message_for_should(&definition) + RSpec.deprecate("`failure_message_for_should`", :replacement => "`failure_message`") + failure_message(&definition) + end + + # @deprecated Use {Macros#failure_message_when_negated} instead. + def failure_message_for_should_not(&definition) + RSpec.deprecate("`failure_message_for_should_not`", :replacement => "`failure_message_when_negated`") + failure_message_when_negated(&definition) + end + end + end + + # Defines default implementations of the matcher + # protocol methods for custom matchers. You can + # override any of these using the {RSpec::Matchers::DSL::Macros Macros} methods + # from within an `RSpec::Matchers.define` block. + module DefaultImplementations + include BuiltIn::BaseMatcher::DefaultFailureMessages + + # @api private + # Used internally by objects returns by `should` and `should_not`. + def diffable? + false + end + + # The default description. + def description + "#{name_to_sentence}#{to_sentence expected}#{chained_method_clause_sentences}" + end + + # Matchers do not support block expectations by default. You + # must opt-in. + def supports_block_expectations? + false + end + + # Most matchers do not expect call stack jumps. + def expects_call_stack_jump? + false + end + + private + + def chained_method_clause_sentences + return '' unless Expectations.configuration.include_chain_clauses_in_custom_matcher_descriptions? + + @chained_method_clauses.map do |(method_name, method_args)| + " #{split_words(method_name)}#{to_sentence(method_args)}" + end.join + end + end + + # The class used for custom matchers. The block passed to + # `RSpec::Matchers.define` will be evaluated in the context + # of the singleton class of an instance, and will have the + # {RSpec::Matchers::DSL::Macros Macros} methods available. + class Matcher + # Provides default implementations for the matcher protocol methods. + include DefaultImplementations + + # Allows expectation expressions to be used in the match block. + include RSpec::Matchers + + # Converts matcher name and expected args to an English expresion. + include RSpec::Matchers::Pretty + + # Supports the matcher composability features of RSpec 3+. + include Composable + + # Makes the macro methods available to an `RSpec::Matchers.define` block. + extend Macros + extend Macros::Deprecated + + # Exposes the value being matched against -- generally the object + # object wrapped by `expect`. + attr_reader :actual + + # Exposes the exception raised during the matching by `match_unless_raises`. + # Could be useful to extract details for a failure message. + attr_reader :rescued_exception + + # @api private + def initialize(name, declarations, matcher_execution_context, *expected) + @name = name + @actual = nil + @expected_as_array = expected + @matcher_execution_context = matcher_execution_context + @chained_method_clauses = [] + + class << self + # See `Macros#define_user_override` above, for an explanation. + include(@user_method_defs = Module.new) + self + end.class_exec(*expected, &declarations) + end + + # Provides the expected value. This will return an array if + # multiple arguments were passed to the matcher; otherwise it + # will return a single value. + # @see #expected_as_array + def expected + if expected_as_array.size == 1 + expected_as_array[0] + else + expected_as_array + end + end + + # Returns the expected value as an an array. This exists primarily + # to aid in upgrading from RSpec 2.x, since in RSpec 2, `expected` + # always returned an array. + # @see #expected + attr_reader :expected_as_array + + # Adds the name (rather than a cryptic hex number) + # so we can identify an instance of + # the matcher in error messages (e.g. for `NoMethodError`) + def inspect + "#<#{self.class.name} #{name}>" + end + + if RUBY_VERSION.to_f >= 1.9 + # Indicates that this matcher responds to messages + # from the `@matcher_execution_context` as well. + # Also, supports getting a method object for such methods. + def respond_to_missing?(method, include_private=false) + super || @matcher_execution_context.respond_to?(method, include_private) + end + else # for 1.8.7 + # Indicates that this matcher responds to messages + # from the `@matcher_execution_context` as well. + def respond_to?(method, include_private=false) + super || @matcher_execution_context.respond_to?(method, include_private) + end + end + + private + + def actual_arg_for(block) + block.arity.zero? ? [] : [@actual] + end + + # Takes care of forwarding unhandled messages to the + # `@matcher_execution_context` (typically the current + # running `RSpec::Core::Example`). This is needed by + # rspec-rails so that it can define matchers that wrap + # Rails' test helper methods, but it's also a useful + # feature in its own right. + def method_missing(method, *args, &block) + if @matcher_execution_context.respond_to?(method) + @matcher_execution_context.__send__ method, *args, &block + else + super(method, *args, &block) + end + end + end + end + end +end + +RSpec::Matchers.extend RSpec::Matchers::DSL diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/generated_descriptions.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/generated_descriptions.rb new file mode 100644 index 000000000..a17ce18a9 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/generated_descriptions.rb @@ -0,0 +1,42 @@ +module RSpec + module Matchers + class << self + # @private + attr_accessor :last_matcher, :last_expectation_handler + end + + # @api private + # Used by rspec-core to clear the state used to generate + # descriptions after an example. + def self.clear_generated_description + self.last_matcher = nil + self.last_expectation_handler = nil + end + + # @api private + # Generates an an example description based on the last expectation. + # Used by rspec-core's one-liner syntax. + def self.generated_description + return nil if last_expectation_handler.nil? + "#{last_expectation_handler.verb} #{last_description}" + end + + private + + def self.last_description + last_matcher.respond_to?(:description) ? last_matcher.description : <<-MESSAGE +When you call a matcher in an example without a String, like this: + +specify { expect(object).to matcher } + +or this: + +it { is_expected.to matcher } + +RSpec expects the matcher to have a #description method. You should either +add a String to the example this matcher is being used in, or give it a +description method. Then you won't have to suffer this lengthy warning again. +MESSAGE + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_delegator.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_delegator.rb new file mode 100644 index 000000000..9dd3b1847 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_delegator.rb @@ -0,0 +1,33 @@ +module RSpec + module Matchers + # Provides the necessary plumbing to wrap a matcher with a decorator. + # @private + class MatcherDelegator + include Composable + attr_reader :base_matcher + + def initialize(base_matcher) + @base_matcher = base_matcher + end + + def method_missing(*args, &block) + base_matcher.__send__(*args, &block) + end + + if ::RUBY_VERSION.to_f > 1.8 + def respond_to_missing?(name, include_all=false) + super || base_matcher.respond_to?(name, include_all) + end + else + def respond_to?(name, include_all=false) + super || base_matcher.respond_to?(name, include_all) + end + end + + def initialize_copy(other) + @base_matcher = @base_matcher.clone + super + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_protocol.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_protocol.rb new file mode 100644 index 000000000..a78ffc69d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/matcher_protocol.rb @@ -0,0 +1,99 @@ +module RSpec + module Matchers + # rspec-expectations can work with any matcher object that implements this protocol. + # + # @note This class is not loaded at runtime by rspec-expectations. It exists + # purely to provide documentation for the matcher protocol. + class MatcherProtocol + # @!group Required Methods + + # @method matches? + # @param actual [Object] The object being matched against. + # @yield For an expression like `expect(x).to matcher do...end`, the `do/end` + # block binds to `to`. It passes that block, if there is one, on to this method. + # @return [Boolean] true if this matcher matches the provided object. + + # @method failure_message + # This will only be called if {#matches?} returns false. + # @return [String] Explanation for the failure. + + # @!endgroup + + # @!group Optional Methods + + # @method does_not_match? + # In a negative expectation such as `expect(x).not_to foo`, RSpec will + # call `foo.does_not_match?(x)` if this method is defined. If it's not + # defined it will fall back to using `!foo.matches?(x)`. This allows you + # to provide custom logic for the negative case. + # + # @param actual [Object] The object being matched against. + # @yield For an expression like `expect(x).not_to matcher do...end`, the `do/end` + # block binds to `not_to`. It passes that block, if there is one, on to this method. + # @return [Boolean] true if this matcher does not match the provided object. + + # @method failure_message_when_negated + # This will only be called when a negative match fails. + # @return [String] Explanation for the failure. + # @note This method is listed as optional because matchers do not have to + # support negation. But if your matcher does support negation, this is a + # required method -- otherwise, you'll get a `NoMethodError`. + + # @method description + # The description is used for two things: + # + # * When using RSpec's one-liner syntax + # (e.g. `it { is_expected.to matcher }`), the description + # is used to generate the example's doc string since you + # have not provided one. + # * In a composed matcher expression, the description is used + # as part of the failure message (and description) of the outer + # matcher. + # + # @return [String] Description of the matcher. + + # @method supports_block_expectations? + # Indicates that this matcher can be used in a block expectation expression, + # such as `expect { foo }.to raise_error`. Generally speaking, this is + # only needed for matchers which operate on a side effect of a block, rather + # than on a particular object. + # @return [Boolean] true if this matcher can be used in block expressions. + # @note If not defined, RSpec assumes a value of `false` for this method. + + # @method expects_call_stack_jump? + # Indicates that when this matcher is used in a block expectation + # expression, it expects the block to use a ruby construct that causes + # a call stack jump (such as raising an error or throwing a symbol). + # + # This is used internally for compound block expressions, as matchers + # which expect call stack jumps must be treated with care to work properly. + # + # @return [Boolean] true if the matcher expects a call stack jump + # + # @note This method is very rarely used or needed. + # @note If not defined, RSpec assumes a value of `false` for this method. + + # @method diffable? + # @return [Boolean] true if `actual` and `expected` can be diffed. + # Indicates that this matcher provides `actual` and `expected` attributes, + # and that the values returned by these can be usefully diffed, which can + # be included in the output. + + # @method actual + # @return [String, Object] If an object (rather than a string) is provided, + # RSpec will use the `pp` library to convert it to multi-line output in + # order to diff. + # The actual value for the purposes of a diff. + # @note This method is required if `diffable?` returns true. + + # @method expected + # @return [String, Object] If an object (rather than a string) is provided, + # RSpec will use the `pp` library to convert it to multi-line output in + # order to diff. + # The expected value for the purposes of a diff. + # @note This method is required if `diffable?` returns true. + + # @!endgroup + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/pretty.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/pretty.rb new file mode 100644 index 000000000..87c3a2d92 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-expectations-3.1.2/lib/rspec/matchers/pretty.rb @@ -0,0 +1,77 @@ +module RSpec + module Matchers + # @api private + # Contains logic to facilitate converting ruby symbols and + # objects to english phrases. + module Pretty + # @api private + # Converts a symbol into an english expression. + def split_words(sym) + sym.to_s.gsub(/_/, ' ') + end + module_function :split_words + + # @api private + # Converts a collection of objects into an english expression. + def to_sentence(words) + return " #{words.inspect}" if !words || Struct === words + words = Array(words).map { |w| to_word(w) } + case words.length + when 0 + "" + when 1 + " #{words[0]}" + when 2 + " #{words[0]} and #{words[1]}" + else + " #{words[0...-1].join(', ')}, and #{words[-1]}" + end + end + + # @api private + # Converts the given item to string suitable for use in a list expression. + def to_word(item) + is_matcher_with_description?(item) ? item.description : item.inspect + end + + # @private + # Provides an English expression for the matcher name. + def name_to_sentence + split_words(name) + end + + # @api private + # Provides a name for the matcher. + def name + defined?(@name) ? @name : underscore(self.class.name.split("::").last) + end + + # @private + # Borrowed from ActiveSupport + def underscore(camel_cased_word) + word = camel_cased_word.to_s.dup + word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') + word.tr!("-", "_") + word.downcase! + word + end + + private + + def is_matcher_with_description?(object) + RSpec::Matchers.is_a_matcher?(object) && object.respond_to?(:description) + end + + # `{ :a => 5, :b => 2 }.inspect` produces: + # {:a=>5, :b=>2} + # ...but it looks much better as: + # {:a => 5, :b => 2} + # + # This is idempotent and safe to run on a string multiple times. + def improve_hash_formatting(inspect_string) + inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2') + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.document b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.document new file mode 100644 index 000000000..050e20457 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.document @@ -0,0 +1,5 @@ +lib/**/*.rb +- +README.md +License.txt +Changelog.md diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.yardopts b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.yardopts new file mode 100644 index 000000000..15f63ee32 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/.yardopts @@ -0,0 +1,6 @@ +--exclude features +--no-private +--markup markdown +- +Changelog.md +License.txt diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/Changelog.md b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/Changelog.md new file mode 100644 index 000000000..987e02a20 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/Changelog.md @@ -0,0 +1,817 @@ +### 3.1.3 / 2014-10-08 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.1.2...v3.1.3) + +Bug Fixes: + +* Correct received messages count when used with `have_received` matcher. + (Jon Rowe, #793) +* Provide a clear error message when you use `allow_any_instance_of(...)` or + `expect_any_instance_of(...)` with the `have_received` matcher (they are + not intended to be used together and previously caused an odd internal + failure in rspec-mocks). (Jon Rowe, #799). +* Fix verified double `with` verification so that it applies to method + stubs. (Myron Marston, #790) + +### 3.1.2 / 2014-09-26 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.1.1...v3.1.2) + +Bug Fixes: + +* Provide a clear error message when you use `allow(...)` with the + `have_received` matcher (they are not intended to be used together + and previously caused an odd internal failure in rspec-mocks). (Jon Rowe, #788). + +### 3.1.1 / 2014-09-18 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.1.0...v3.1.1) + +Bug Fixes: + +* Prevent included modules being detected as prepended modules on Ruby 2.0 + when using `any_instance_of(...)`. (Tony Novak, #781) + +### 3.1.0 / 2014-09-04 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.4...v3.1.0) + +Enhancements: + +* Add spying methods (`spy`, `ìnstance_spy`, `class_spy` and `object_spy`) + which create doubles as null objects for use with spying in testing. (Sam + Phippen, #671) +* `have_received` matcher will raise "does not implement" errors correctly when + used with verifying doubles and partial doubles. (Xavier Shay, #722) +* Allow matchers to be used in place of keyword arguments in `with` + expectations. (Xavier Shay, #726) +* Add `thrice` modifier to message expectation interface as a synonym + for `exactly(3).times`. (Dennis Taylor, #753) +* Add more `thrice` synonyms e.g. `.at_least(:thrice)`, `.at_most(:thrice)`, + `receive(...).thrice` and `have_received(...).thrice`. (Jon Rowe, #754) +* Add `and_wrap_original` modifier for partial doubles to mutate the + response from a method. (Jon Rowe, #762) + +Bugfixes: + +* Remove `any_number_of_times` from `any_instance` recorders that were + erroneously causing mention of the method in documentation. (Jon Rowe, #760) +* Prevent included modules being detected as prepended modules on Ruby 2.0. + (Eugene Kenny, #771) + +### 3.0.4 / 2014-08-14 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.3...v3.0.4) + +Bug Fixes: + +* Restore `kind_of(x)` to match using `arg.kind_of?(x)` (like RSpec 2) + rather than `x === arg`. (Jon Rowe, #750) + +### 3.0.3 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.2...v3.0.3) + +Bug Fixes: + +* `have_received` matcher will raise "does not implement" errors correctly when + used with verifying doubles and partial doubles. (Xavier Shay, #722) +* Make `double.as_null_object.dup` and `double.as_null_object.clone` + make the copies be null objects. (Myron Marston, #732) +* Don't inadvertently define `BasicObject` in 1.8.7. (Chris Griego, #739) + +### 3.0.2 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.1...v3.0.2) + +Bug Fixes: + +* Fix edge case that triggered "can't add a new key into hash during + iteration" during mock verification. (Sam Phippen, Myron Marston, #711) +* Fix verifying doubles so that when they accidentally leak into another + example, they provide the same clear error message that normal doubles + do. (Myron Marston, #718) +* Make `ordered` work with exact receive counts. (Sam Phippen, #713) + +### 3.0.1 / 2014-06-07 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0...v3.0.1) + +Bug Fixes: + +* Fix `receive_message_chain(...)` so that it supports `with` just like + `stub_chain` did. (Jon Rowe, #697) +* Fix regression in `expect_any_instance_of` so that it expects the + message on _any_ instance rather than on _every_ instance. + (Myron Marston, #699) + +### 3.0.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.rc1...v3.0.0) + +Bug Fixes: + +* Fix module prepend detection to work properly on ruby 2.0 for a case + where a module is extended onto itself. (Myron Marston) +* Fix `transfer_nested_constants` option so that transferred constants + get properly reset at the end of the example. (Myron Marston) +* Fix `config.transfer_nested_constants = true` so that you don't + erroneously get errors when stubbing a constant that is not a module + or a class. (Myron Marston) +* Fix regression that caused `double(:class => SomeClass)` to later + trigger infinite recursion. (Myron Marston) +* Fix bug in `have_received(...).with(...).ordered` where it was not + taking the args into account when checking the order. (Myron Marston) +* Fix bug in `have_received(...).ordered` where it was wrongly + considering stubs when checking the order. (Myron Marston) +* Message expectation matchers now show descriptions from argument + matchers when their expectations aren't met. (Jon Rowe) +* Display warning when encountering `TypeError` during instance method + staging on 2.0.0-p195, suffers from https://bugs.ruby-lang.org/issues/8686 + too. (Cezar Halmagean). + +### 3.0.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.beta2...v3.0.0.rc1) + +Breaking Changes for 3.0.0: + +* Remove `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston) +* Remove `RSpec::Mocks::ConstantStubber`. (Jon Rowe) +* Make monkey-patch of Marshal to support dumping of stubbed objects opt-in. + (Xavier Shay) + +Enhancements: + +* Instead of crashing when cleaning up stub methods on a frozen object, it now + issues a warning explaining that it's impossible to clean up the stubs. + (Justin Coyne and Sam Phippen) +* Add meaningful descriptions to `anything`, `duck_type` and `instance_of` argument + matchers. (Jon Rowe) + +Bug Fixes: + +* Fix regression introduced in 3.0.0.beta2 that caused + `double.as_null_object.to_str` to return the double rather + than a string. (Myron Marston) +* Fix bug in `expect(dbl).to receive_message_chain(:foo, :bar)` where it was + not setting an expectation for the last message in the chain. + (Jonathan del Strother) +* Allow verifying partial doubles to have private methods stubbed. (Xavier Shay) +* Fix bug with allowing/expecting messages on Class objects which have had + their singleton class prepended to. (Jon Rowe) +* Fix an issue with 1.8.7 not running implementation blocks on partial doubles. + (Maurício Linhares) +* Prevent `StackLevelTooDeep` errors when stubbing an `any_instance` method that's + accessed in `inspect` by providing our own inspect output. (Jon Rowe) +* Fix bug in `any_instance` logic that did not allow you to mock or stub + private methods if `verify_partial_doubles` was configured. (Oren Dobzinski) +* Include useful error message when trying to observe an unimplemented method + on an any instance. (Xavier Shay) +* Fix `and_call_original` to work properly when multiple classes in an + inheritance hierarchy have been stubbed with the same method. (Myron Marston) +* Fix `any_instance` so that it updates existing instances that have + already been stubbed. (Myron Marston) +* Fix verified doubles so that their class name is included in failure + messages. (Myron Marston) +* Fix `expect_any_instance_of` so that when the message is received + on an individual instance that has been directly stubbed, it still + satisfies the expectation. (Sam Phippen, Myron Marston) +* Explicitly disallow using `any_instance` to mock or stub a method + that is defined on a module prepended onto the class. This triggered + `SystemStackError` before and is very hard to support so we are not + supporting it at this time. (Myron Marston) + +### 3.0.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.beta1...v3.0.0.beta2) + +Breaking Changes for 3.0.0: + +* Rename `RSpec::Mocks::Mock` to `RSpec::Mocks::Double`. (Myron Marston) +* Change how to integrate rspec-mocks in other test frameworks. You now + need to include `RSpec::Mocks::ExampleMethods` in your test context. + (Myron Marston) +* Prevent RSpec mocks' doubles and partial doubles from being used outside of + the per-test lifecycle (e.g. from a `before(:all)` hook). (Sam Phippen) +* Remove the `host` argument of `RSpec::Mocks.setup`. Instead + `RSpec::Mocks::ExampleMethods` should be included directly in the scope where + RSpec's mocking capabilities are used. (Sam Phippen) +* Make test doubles raise errors if you attempt to use them after they + get reset, to help surface issues when you accidentally retain + references to test doubles and attempt to reuse them in another + example. (Myron Marston) +* Remove support for `and_return { value }` and `and_return` without arguments. (Yuji Nakayama) + +Enhancements: + +* Add `receive_message_chain` which provides the functionality of the old + `stub_chain` for the new allow/expect syntax. Use it like so: `allow(...).to + receive_message_chain(:foo, :bar, :bazz)`. (Sam Phippen). +* Change argument matchers to use `===` as their primary matching + protocol, since their semantics mirror that of a case or rescue statement + (which uses `===` for matching). (Myron Marston) +* Add `RSpec::Mocks.with_temporary_scope`, which allows you to create + temporary rspec-mocks scopes in arbitrary places (such as a + `before(:all)` hook). (Myron Marston) +* Support keyword arguments when checking arity with verifying doubles. + (Xavier Shay) + +Bug Fixes: + +* Fix regression in 3.0.0.beta1 that caused `double("string_name" => :value)` + to stop working. (Xavier Shay) +* Fix the way rspec-mocks and rspec-core interact so that if users + define a `let` with the same name as one of the methods + from `RSpec::Mocks::ArgumentMatchers`, the user's `let` takes + precedence. (Michi Huber, Myron Marston) +* Fix verified doubles so that their methods match the visibility + (public, protected or private) of the interface they verify + against. (Myron Marston) +* Fix verified null object doubles so that they do not wrongly + report that they respond to anything. They only respond to methods + available on the interface they verify against. (Myron Marston) +* Fix deprecation warning for use of old `:should` syntax w/o explicit + config so that it no longer is silenced by an extension gem such + as rspec-rails when it calls `config.add_stub_and_should_receive_to`. + (Sam Phippen) +* Fix `expect` syntax so that it does not wrongly emit a "You're + overriding a previous implementation for this stub" warning when + you are not actually doing that. (Myron Marston) +* Fix `any_instance.unstub` when used on sub classes for whom the super + class has had `any_instance.stub` invoked on. (Jon Rowe) +* Fix regression in `stub_chain`/`receive_message_chain` that caused + it to raise an `ArgumentError` when passing args to the stubbed + methods. (Sam Phippen) +* Correct stub of undefined parent modules all the way down when stubbing a + nested constant. (Xavier Shay) +* Raise `VerifyingDoubleNotDefinedError` when a constant is not defined for + a verifying class double. (Maurício Linhares) +* Remove `Double#to_str`, which caused confusing `raise some_double` + behavior. (Maurício Linhares) + +### 3.0.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.2...v3.0.0.beta1) + +Breaking Changes for 3.0.0: + +* Raise an explicit error if `should_not_receive(...).and_return` is used. (Sam + Phippen) +* Remove 1.8.6 workarounds. (Jon Rowe) +* Remove `stub!` and `unstub!`. (Sam Phippen) +* Remove `mock(name, methods)` and `stub(name, methods)`, leaving + `double(name, methods)` for creating test doubles. (Sam Phippen, Michi Huber) +* Remove `any_number_of_times` since `should_receive(:msg).any_number_of_times` + is really a stub in a mock's clothing. (Sam Phippen) +* Remove support for re-using the same null-object test double in multiple + examples. Test doubles are designed to only live for one example. + (Myron Marston) +* Make `at_least(0)` raise an error. (Sam Phippen) +* Remove support for `require 'spec/mocks'` which had been kept + in place for backwards compatibility with RSpec 1. (Myron Marston) +* Blocks provided to `with` are always used as implementation. (Xavier Shay) +* The config option (added in 2.99) to yield the receiver to + `any_instance` implementation blocks now defaults to "on". (Sam Phippen) + +Enhancements: + +* Allow the `have_received` matcher to use a block to set further expectations + on arguments. (Tim Cowlishaw) +* Provide `instance_double` and `class_double` to create verifying doubles, + ported from `rspec-fire`. (Xavier Shay) +* `as_null_object` on a verifying double only responds to defined methods. + (Xavier Shay) +* Provide `object_double` to create verified doubles of specific object + instances. (Xavier Shay) +* Provide `verify_partial_doubles` configuration that provides `object_double` + like verification behaviour on partial doubles. (Xavier Shay) +* Improved performance of double creation, particularly those with many + attributes. (Xavier Shay) +* Default value of `transfer_nested_constants` option for constant stubbing can + be configured. (Xavier Shay) +* Messages can be allowed or expected on in bulk via + `receive_messages(:message => :value)`. (Jon Rowe) +* `allow(Klass.any_instance)` and `expect(Klass.any_instance)` now print a + warning. This is usually a mistake, and users usually want + `allow_any_instance_of` or `expect_any_instance_of` instead. (Sam Phippen) +* `instance_double` and `class_double` raise `ArgumentError` if the underlying + module is loaded and the arity of the method being invoked does not match the + arity of the method as it is actually implemented. (Andy Lindeman) +* Spies can now check their invocation ordering is correct. (Jon Rowe) + +Deprecations: + +* Using the old `:should` syntax without explicitly configuring it + is deprecated. It will continue to work but will emit a deprecation + warning in RSpec 3 if you do not explicitly enable it. (Sam Phippen) + +Bug Fixes: + +* Fix `and_call_original` to handle a complex edge case involving + singleton class ancestors. (Marc-André Lafortune, Myron Marston) +* When generating an error message for unexpected arguments, + use `#inspect` rather than `#description` if `#description` + returns `nil` or `''` so that you still get a useful message. + (Nick DeLuca) + +### 2.99.2 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.1...v2.99.2) + +Enhancements: + +* Warn about upcoming change to `#===` matching and `DateTime#===` behaviour. + (Jon Rowe, #735) + +### 2.99.1 / 2014-06-12 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0...v2.99.1) + +Bug Fixes: + +* Fix bug that caused errors at the end of each example + when a `double.as_null_object` had been frozen. (Yuji Nakayama, #698) + +Deprecations: + +* Deprecate freezing a test double. (Yuji Nakayama, #698) + +### 2.99.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.rc1...v2.99.0) + +No changes. Just taking it out of pre-release. + +### 2.99.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta2...v2.99.0.rc1) + +Deprecations: + +* Deprecate `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston) +* Deprecate `RSpec::Mocks::ConstantStubber`. (Jon Rowe) +* Deprecate `Marshal.dump` monkey-patch without opt-in. (Xavier Shay) + +### 2.99.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2) + +Deprecations: + +* Deprecate `RSpec::Mocks::Mock` in favor of `RSpec::Mocks::Double`. + (Myron Marston) +* Deprecate the `host` argument of `RSpec::Mocks.setup`. Instead + `RSpec::Mocks::ExampleMethods` should be included directly in the scope where + RSpec's mocking capabilities are used. (Sam Phippen) +* Deprecate using any of rspec-mocks' features outside the per-test + lifecycle (e.g. from a `before(:all)` hook). (Myron Marston) +* Deprecate re-using a test double in another example. (Myron Marston) +* Deprecate `and_return { value }` and `and_return` without arguments. (Yuji Nakayama) + +### 2.99.0.beta1 / 2013-11-07 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.99.0.beta1) + +Deprecations + +* Expecting to use lambdas or other strong arity implementations for stub + methods with mis-matched arity is deprecated and support for them will be + removed in 3.0. Either provide the right amount of arguments or use a weak + arity implementation (methods with splats or procs). (Jon Rowe) +* Using the same test double instance in multiple examples is deprecated. Test + doubles are only meant to live for one example. The mocks and stubs have + always been reset between examples; however, in 2.x the `as_null_object` + state was not reset and some users relied on this to have a null object + double that is used for many examples. This behavior will be removed in 3.0. + (Myron Marston) +* Print a detailed warning when an `any_instance` implementation block is used + when the new `yield_receiver_to_any_instance_implementation_blocks` config + option is not explicitly set, as RSpec 3.0 will default to enabling this new + feature. (Sam Phippen) + +Enhancements: + +* Add a config option to yield the receiver to `any_instance` implementation + blocks. (Sam Phippen) + +### 2.14.6 / 2014-02-20 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.5...v2.14.6) + +Bug Fixes: + +* Ensure `any_instance` method stubs and expectations are torn down regardless of + expectation failures. (Sam Phippen) + +### 2.14.5 / 2014-02-01 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.14.5) + +Bug Fixes: + +* Fix regression that caused block implementations to not receive all + args on 1.8.7 if the block also receives a block, due to Proc#arity + reporting `1` no matter how many args the block receives if it + receives a block, too. (Myron Marston) + +### 2.14.4 / 2013-10-15 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.3...v2.14.4) + +Bug Fixes: + +* Fix issue where unstubing methods on "any instances" would not + remove stubs on existing instances (Jon Rowe) +* Fix issue with receive(:message) do ... end precedence preventing + the usage of modifications (`and_return` etc) (Jon Rowe) + +### 2.14.3 / 2013-08-08 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3) + +Bug Fixes: + +* Fix stubbing some instance methods for classes whose hierarchy includes + a prepended Module (Bradley Schaefer) + +### 2.14.2 / 2013-07-30 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2) + +Bug Fixes: + +* Fix `as_null_object` doubles so that they return `nil` from `to_ary` + (Jon Rowe). +* Fix regression in 2.14 that made `stub!` (with an implicit receiver) + return a test double rather than stub a method (Myron Marston). + +### 2.14.1 / 2013-07-07 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0...v2.14.1) + +Bug Fixes: + +* Restore `double.as_null_object` behavior from 2.13 and earlier: a + double's nullness persisted between examples in earlier examples. + While this is not an intended use case (test doubles are meant to live + for only one example), we don't want to break behavior users rely + on in a minor relase. This will be deprecated in 2.99 and removed + in 3.0. (Myron Marston) + +### 2.14.0 / 2013-07-06 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0) + +Enhancements: + +* Document test spies in the readme. (Adarsh Pandit) +* Add an `array_including` matcher. (Sam Phippen) +* Add a syntax-agnostic API for mocking or stubbing a method. This is + intended for use by libraries such as rspec-rails that need to mock + or stub a method, and work regardless of the syntax the user has + configured (Paul Annesley, Myron Marston and Sam Phippen). + +Bug Fixes: + +* Fix `double` so that it sets up passed stubs correctly regardless of + the configured syntax (Paul Annesley). +* Allow a block implementation to be used in combination with + `and_yield`, `and_raise`, `and_return` or `and_throw`. This got fixed + in 2.13.1 but failed to get merged into master for the 2.14.0.rc1 + release (Myron Marston). +* `Marshal.dump` does not unnecessarily duplicate objects when rspec-mocks has + not been fully initialized. This could cause errors when using `spork` or + similar preloading gems (Andy Lindeman). + +### 2.14.0.rc1 / 2013-05-27 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.14.0.rc1) + +Enhancements: + +* Refactor internals so that the mock proxy methods and state are held + outside of the mocked object rather than inside it. This paves the way + for future syntax enhancements and removes the need for some hacky + work arounds for `any_instance` dup'ing and `YAML` serialization, + among other things. Note that the code now relies upon `__id__` + returning a unique, consistent value for any object you want to + mock or stub (Myron Marston). +* Add support for test spies. This allows you to verify a message + was received afterwards using the `have_received` matcher. + Note that you must first stub the method or use a null double. + (Joe Ferris and Joël Quenneville) +* Make `at_least` and `at_most` style receive expectations print that they were + expecting at least or at most some number of calls, rather than just the + number of calls given in the expectation (Sam Phippen) +* Make `with` style receive expectations print the args they were expecting, and + the args that they got (Sam Phippen) +* Fix some warnings seen under ruby 2.0.0p0 (Sam Phippen). +* Add a new `:expect` syntax for message expectations + (Myron Marston and Sam Phippen). + +Bug fixes + +* Fix `any_instance` so that a frozen object can be `dup`'d when methods + have been stubbed on that type using `any_instance` (Jon Rowe). +* Fix `and_call_original` so that it properly raises an `ArgumentError` + when the wrong number of args are passed (Jon Rowe). +* Fix `double` on 1.9.2 so you can wrap them in an Array + using `Array(my_double)` (Jon Rowe). +* Fix `stub_const` and `hide_const` to handle constants that redefine `send` + (Sam Phippen). +* Fix `Marshal.dump` extension so that it correctly handles nil. + (Luke Imhoff, Jon Rowe) +* Fix isolation of `allow_message_expectations_on_nil` (Jon Rowe) +* Use inspect to format actual arguments on expectations in failure messages (#280, Ben Langfeld) +* Protect against improperly initialised test doubles (#293) (Joseph Shraibman and Jon Rowe) + +Deprecations + +* Deprecate `stub` and `mock` as aliases for `double`. `double` is the + best term for creating a test double, and it reduces confusion to + have only one term (Michi Huber). +* Deprecate `stub!` and `unstub!` in favor of `stub` and `unstub` + (Jon Rowe). +* Deprecate `at_least(0).times` and `any_number_of_times` (Michi Huber). + +### 2.13.1 / 2013-04-06 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.13.1) + +Bug fixes + +* Allow a block implementation to be used in combination with + `and_yield`, `and_raise`, `and_return` or `and_throw` (Myron Marston). + +### 2.13.0 / 2013-02-23 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.2...v2.13.0) + +Bug fixes + +* Fix bug that caused weird behavior when a method that had + previously been stubbed with multiple return values (e.g. + `obj.stub(:foo).and_return(1, 2)`) was later mocked with a + single return value (e.g. `obj.should_receive(:foo).once.and_return(1)`). + (Myron Marston) +* Fix bug related to a mock expectation for a method that already had + multiple stubs with different `with` constraints. Previously, the + first stub was used, even though it may not have matched the passed + args. The fix defers this decision until the message is received so + that the proper stub response can be chosen based on the passed + arguments (Myron Marston). +* Do not call `nil?` extra times on a mocked object, in case `nil?` + itself is expected a set number of times (Myron Marston). +* Fix `missing_default_stub_error` message so array args are handled + properly (Myron Marston). +* Explicitly disallow `any_instance.unstub!` (Ryan Jones). +* Fix `any_instance` stubbing so that it works with `Delegator` + subclasses (Myron Marston). +* Fix `and_call_original` so that it works with `Delegator` subclasses + (Myron Marston). +* Fix `any_instance.should_not_receive` when `any_instance.should_receive` + is used on the same class in the same example. Previously it would + wrongly report a failure even when the message was not received + (Myron Marston). + +### 2.12.2 / 2013-01-27 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.1...v.2.12.2) + +Bug fixes + +* Fix `and_call_original` to work properly for methods defined + on a module extended onto an object instance (Myron Marston). +* Fix `stub_const` with an undefined constnat name to work properly + with constant strings that are prefixed with `::` -- and edge case + I missed in the bug fix in the 2.12.1 release (Myron Marston). +* Ensure method visibility on a partial mock is restored after reseting + method stubs, even on a singleton module (created via `extend self`) + when the method visibility differs between the instance and singleton + versions (Andy Lindeman). + +### 2.12.1 / 2012-12-21 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.0...v2.12.1) + +Bug fixes + +* Fix `any_instance` to support `and_call_original`. + (Myron Marston) +* Properly restore stubbed aliased methods on rubies + that report the incorrect owner (Myron Marston and Andy Lindeman). +* Fix `hide_const` and `stub_const` with a defined constnat name to + work properly with constant strings that are prefixed with `::` (Myron Marston). + +### 2.12.0 / 2012-11-12 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.3...v2.12.0) + +Enhancements + +* `and_raise` can accept an exception class and message, more closely + matching `Kernel#raise` (e.g., `foo.stub(:bar).and_raise(RuntimeError, "message")`) + (Bas Vodde) +* Add `and_call_original`, which will delegate the message to the + original method (Myron Marston). + +Deprecations: + +* Add deprecation warning when using `and_return` with `should_not_receive` + (Neha Kumari) + +### 2.11.3 / 2012-09-19 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.2...v2.11.3) + +Bug fixes + +* Fix `:transfer_nested_constants` option of `stub_const` so that it + doesn't blow up when there are inherited constants. (Myron Marston) +* `any_instance` stubs can be used on classes that override `Object#method`. + (Andy Lindeman) +* Methods stubbed with `any_instance` are unstubbed after the test finishes. + (Andy Lindeman) +* Fix confusing error message when calling a mocked class method an + extra time with the wrong arguments (Myron Marston). + +### 2.11.2 / 2012-08-11 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.1...v2.11.2) + +Bug fixes + +* Don't modify `dup` on classes that don't support `dup` (David Chelimsky) +* Fix `any_instance` so that it works properly with methods defined on + a superclass. (Daniel Eguzkiza) +* Fix `stub_const` so that it works properly for nested constants that + share a name with a top-level constant (e.g. "MyGem::Hash"). (Myron + Marston) + +### 2.11.1 / 2012-07-09 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.0...v2.11.1) + +Bug fixes + +* Fix `should_receive` so that when it is called on an `as_null_object` + double with no implementation, and there is a previous explicit stub + for the same method, the explicit stub remains (rather than being + overriden with the null object implementation--`return self`). (Myron Marston) + +### 2.11.0 / 2012-07-07 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.1...v2.11.0) + +Enhancements + +* Expose ArgumentListMatcher as a formal API + * supports use by 3rd party mock frameworks like Surrogate +* Add `stub_const` API to stub constants for the duration of an + example (Myron Marston). + +Bug fixes + +* Fix regression of edge case behavior. `double.should_receive(:foo) { a }` + was causing a NoMethodError when `double.stub(:foo).and_return(a, b)` + had been setup before (Myron Marston). +* Infinite loop generated by using `any_instance` and `dup`. (Sidu Ponnappa @kaiwren) +* `double.should_receive(:foo).at_least(:once).and_return(a)` always returns a + even if `:foo` is already stubbed. +* Prevent infinite loop when interpolating a null double into a string + as an integer (`"%i" % double.as_null_object`). (Myron Marston) +* Fix `should_receive` so that null object behavior (e.g. returning + self) is preserved if no implementation is given (Myron Marston). +* Fix `and_raise` so that it raises `RuntimeError` rather than + `Exception` by default, just like ruby does. (Andrew Marshall) + +### 2.10.1 / 2012-05-05 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1) + +Bug fixes + +* fix regression of edge case behavior + (https://github.com/rspec/rspec-mocks/issues/132) + * fixed failure of `object.should_receive(:message).at_least(0).times.and_return value` + * fixed failure of `object.should_not_receive(:message).and_return value` + +### 2.10.0 / 2012-05-03 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0) + +Bug fixes + +* fail fast when an `exactly` or `at_most` expectation is exceeded + +### 2.9.0 / 2012-03-17 +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0...v2.9.0) + +Enhancements + +* Support order constraints across objects (preethiramdev) + +Bug fixes + +* Allow a `as_null_object` to be passed to `with` +* Pass proc to block passed to stub (Aubrey Rhodes) +* Initialize child message expectation args to match any args (#109 - + preethiramdev) + +### 2.8.0 / 2012-01-04 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc2...v2.8.0) + +No changes for this release. Just releasing with the other rspec gems. + +### 2.8.0.rc2 / 2011-12-19 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2) + +No changes for this release. Just releasing with the other rspec gems. + +### 2.8.0.rc1 / 2011-11-06 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.7.0...v2.8.0.rc1) + +Enhancements + +* Eliminate Ruby warnings (Matijs van Zuijlen) + +### 2.7.0 / 2011-10-16 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0) + +Enhancements + +* Use `__send__` rather than `send` (alextk) +* Add support for `any_instance.stub_chain` (Sidu Ponnappa) +* Add support for `any_instance` argument matching based on `with` (Sidu + Ponnappa and Andy Lindeman) + +Changes + +* Check for `failure_message_for_should` or `failure_message` instead of + `description` to detect a matcher (Tibor Claassen) + +Bug fixes + +* pass a hash to `any_instance.stub`. (Justin Ko) +* allow `to_ary` to be called without raising `NoMethodError` (Mikhail + Dieterle) +* `any_instance` properly restores private methods (Sidu Ponnappa) + +### 2.6.0 / 2011-05-12 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.5.0...v2.6.0) + +Enhancements + +* Add support for `any_instance.stub` and `any_instance.should_receive` (Sidu + Ponnappa and Andy Lindeman) + +Bug fixes + +* fix bug in which multiple chains with shared messages ending in hashes failed + to return the correct value + +### 2.5.0 / 2011-02-05 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.4.0...v2.5.0) + +Bug fixes + +* message expectation counts now work in combination with a stub (Damian + Nurzynski) +* fix failure message when message received with incorrect args (Josep M. + Bach) + +### 2.4.0 / 2011-01-02 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.3.0...v2.4.0) + +No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release. + +### 2.3.0 / 2010-12-12 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.2.0...v2.3.0) + +Bug fixes + +* Fix our Marshal extension so that it does not interfere with objects that + have their own `@mock_proxy` instance variable. (Myron Marston) + +### 2.2.0 / 2010-11-28 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0) + +Enhancements + +* Added "rspec/mocks/standalone" for exploring the rspec-mocks in irb. + +Bug fix + +* Eliminate warning on splat args without parens (Gioele Barabucci) +* Fix bug where `obj.should_receive(:foo).with(stub.as_null_object)` would pass + with a false positive. + +### 2.1.0 / 2010-11-07 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0) + +Bug fixes + +* Fix serialization of stubbed object (Josep M Bach) + +### 2.0.0 / 2010-10-10 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0) + +### 2.0.0.rc / 2010-10-05 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0.rc) + +Enhancements + +* support passing a block to an expectation block (Nicolas Braem) + * `obj.should_receive(:msg) {|&block| ... }` + +Bug fixes + +* Fix YAML serialization of stub (Myron Marston) +* Fix rdoc rake task (Hans de Graaff) + +### 2.0.0.beta.22 / 2010-09-12 + +[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.20...v2.0.0.beta.22) + +Bug fixes + +* fixed regression that broke `obj.stub_chain(:a, :b => :c)` +* fixed regression that broke `obj.stub_chain(:a, :b) { :c }` +* `respond_to?` always returns true when using `as_null_object` diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/License.txt b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/License.txt new file mode 100644 index 000000000..91cfc94f6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/License.txt @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2012 David Chelimsky, Myron Marston +Copyright (c) 2006 David Chelimsky, The RSpec Development Team +Copyright (c) 2005 Steven Baker + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/README.md b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/README.md new file mode 100644 index 000000000..8645df5c5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/README.md @@ -0,0 +1,397 @@ +# RSpec Mocks [![Build Status](https://secure.travis-ci.org/rspec/rspec-mocks.png?branch=master)](http://travis-ci.org/rspec/rspec-mocks) [![Code Climate](https://codeclimate.com/github/rspec/rspec-mocks.png)](https://codeclimate.com/github/rspec/rspec-mocks) +rspec-mocks is a test-double framework for rspec with support for method stubs, +fakes, and message expectations on generated test-doubles and real objects +alike. + +## Install + + gem install rspec # for rspec-core, rspec-expectations, rspec-mocks + gem install rspec-mocks # for rspec-mocks only + +## Test Doubles + +A test double is an object that stands in for another object in your system +during a code example. Use the `double` method, passing in an optional identifier, to create one: + +```ruby +book = double("book") +``` + +Most of the time you will want some confidence that your doubles resemble an +existing object in your system. Verifying doubles are provided for this +purpose. If the existing object is available, they will prevent you from adding +stubs and expectations for methods that do not exist or that have an invalid +number of parameters. + +```ruby +book = instance_double("Book", :pages => 250) +``` + +Verifying doubles have some clever tricks to enable you to both test in +isolation without your dependencies loaded while still being able to validate +them against real objects. More detail is available in [their +documentation](https://github.com/rspec/rspec-mocks/blob/master/features/verifying_doubles). + +## Method Stubs + +A method stub is an implementation that returns a pre-determined value. Method +stubs can be declared on test doubles or real objects using the same syntax. +rspec-mocks supports 3 forms for declaring method stubs: + +```ruby +allow(book).to receive(:title) { "The RSpec Book" } +allow(book).to receive(:title).and_return("The RSpec Book") +allow(book).to receive_messages( + :title => "The RSpec Book", + :subtitle => "Behaviour-Driven Development with RSpec, Cucumber, and Friends") +``` + +You can also use this shortcut, which creates a test double and declares a +method stub in one statement: + +```ruby +book = double("book", :title => "The RSpec Book") +``` + +The first argument is a name, which is used for documentation and appears in +failure messages. If you don't care about the name, you can leave it out, +making the combined instantiation/stub declaration very terse: + +```ruby +double(:foo => 'bar') +``` + +This is particularly nice when providing a list of test doubles to a method +that iterates through them: + +```ruby +order.calculate_total_price(double(:price => 1.99), double(:price => 2.99)) +``` + +## Consecutive return values + +When a stub might be invoked more than once, you can provide additional +arguments to `and_return`. The invocations cycle through the list. The last +value is returned for any subsequent invocations: + +```ruby +allow(die).to receive(:roll).and_return(1, 2, 3) +die.roll # => 1 +die.roll # => 2 +die.roll # => 3 +die.roll # => 3 +die.roll # => 3 +``` + +To return an array in a single invocation, declare an array: + +```ruby +allow(team).to receive(:players).and_return([double(:name => "David")]) +``` + +## Message Expectations + +A message expectation is an expectation that the test double will receive a +message some time before the example ends. If the message is received, the +expectation is satisfied. If not, the example fails. + +```ruby +validator = double("validator") +expect(validator).to receive(:validate) { "02134" } +zipcode = Zipcode.new("02134", validator) +zipcode.valid? +``` + +## Test Spies + +Verifies the given object received the expected message during the course of +the test. For a message to be verified, the given object must be setup to spy +on it, either by having it explicitly stubbed or by being a null object double +(e.g. `double(...).as_null_object`). Convenience methods are provided to easily +create null object doubles for this purpose: + +```ruby +spy("invitation") # => same as `double("invitation").as_null_object` +instance_spy("Invitation") # => same as `instance_double("Invitation").as_null_object` +class_spy("Invitation") # => same as `class_double("Invitation").as_null_object` +object_spy("Invitation") # => same as `object_double("Invitation").as_null_object` +``` + +Stubbing and verifying messages received in this way implements the Test Spy +pattern. + +```ruby +invitation = spy('invitation') + +user.accept_invitation(invitation) + +expect(invitation).to have_received(:accept) + +# You can also use other common message expectations. For example: +expect(invitation).to have_received(:accept).with(mailer) +expect(invitation).to have_received(:accept).twice +expect(invitation).to_not have_received(:accept).with(mailer) + +# One can specify a return value on the spy the same way one would a double. +invitation = spy('invitation', :accept => true) +expect(invitation).to have_received(:accept).with(mailer) +expect(invitation.accept).to eq(true) +``` + +## Nomenclature + +### Mock Objects and Test Stubs + +The names Mock Object and Test Stub suggest specialized Test Doubles. i.e. +a Test Stub is a Test Double that only supports method stubs, and a Mock +Object is a Test Double that supports message expectations and method +stubs. + +There is a lot of overlapping nomenclature here, and there are many +variations of these patterns (fakes, spies, etc). Keep in mind that most of +the time we're talking about method-level concepts that are variations of +method stubs and message expectations, and we're applying to them to _one_ +generic kind of object: a Test Double. + +### Test-Specific Extension + +a.k.a. Partial Double, a Test-Specific Extension is an extension of a +real object in a system that is instrumented with test-double like +behaviour in the context of a test. This technique is very common in Ruby +because we often see class objects acting as global namespaces for methods. +For example, in Rails: + +```ruby +person = double("person") +allow(Person).to receive(:find) { person } +``` + +In this case we're instrumenting Person to return the person object we've +defined whenever it receives the `find` message. We can also set a message +expectation so that the example fails if `find` is not called: + +```ruby +person = double("person") +expect(Person).to receive(:find) { person } +``` + +RSpec replaces the method we're stubbing or mocking with its own +test-double-like method. At the end of the example, RSpec verifies any message +expectations, and then restores the original methods. + +## Expecting Arguments + +```ruby +expect(double).to receive(:msg).with(*args) +expect(double).to_not receive(:msg).with(*args) +``` + +You can set multiple expectations for the same message if you need to: + +```ruby +expect(double).to receive(:msg).with("A", 1, 3) +expect(double).to receive(:msg).with("B", 2, 4) +``` + +## Argument Matchers + +Arguments that are passed to `with` are compared with actual arguments +received using ==. In cases in which you want to specify things about the +arguments rather than the arguments themselves, you can use any of the +matchers that ship with rspec-expectations. They don't all make syntactic +sense (they were primarily designed for use with RSpec::Expectations), but +you are free to create your own custom RSpec::Matchers. + +rspec-mocks also adds some keyword Symbols that you can use to +specify certain kinds of arguments: + +```ruby +expect(double).to receive(:msg).with(no_args()) +expect(double).to receive(:msg).with(any_args()) +expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can be any kind of Numeric +expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can be true or false +expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp +expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all +expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b") #2nd argument can be object that responds to #abs and #div +expect(double).to receive(:msg).with(hash_including(:a => 5)) # first arg is a hash with a: 5 as one of the key-values +expect(double).to receive(:msg).with(array_including(5)) # first arg is an array with 5 as one of the key-values +expect(double).to receive(:msg).with(hash_excluding(:a => 5)) # first arg is a hash without a: 5 as one of the key-values +``` + +## Receive Counts + +```ruby +expect(double).to receive(:msg).once +expect(double).to receive(:msg).twice +expect(double).to receive(:msg).exactly(n).times +expect(double).to receive(:msg).at_least(:once) +expect(double).to receive(:msg).at_least(:twice) +expect(double).to receive(:msg).at_least(n).times +expect(double).to receive(:msg).at_most(:once) +expect(double).to receive(:msg).at_most(:twice) +expect(double).to receive(:msg).at_most(n).times +``` + +## Ordering + +```ruby +expect(double).to receive(:msg).ordered +expect(double).to receive(:other_msg).ordered + # This will fail if the messages are received out of order +``` + +This can include the same message with different arguments: + +```ruby +expect(double).to receive(:msg).with("A", 1, 3).ordered +expect(double).to receive(:msg).with("B", 2, 4).ordered +``` + +## Setting Responses + +Whether you are setting a message expectation or a method stub, you can +tell the object precisely how to respond. The most generic way is to pass +a block to `receive`: + +```ruby +expect(double).to receive(:msg) { value } +``` + +When the double receives the `msg` message, it evaluates the block and returns +the result. + +```ruby +expect(double).to receive(:msg).and_return(value) +expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3) + # returns value1 the first time, value2 the second, etc +expect(double).to receive(:msg).and_raise(error) + # error can be an instantiated object or a class + # if it is a class, it must be instantiable with no args +expect(double).to receive(:msg).and_throw(:msg) +expect(double).to receive(:msg).and_yield(values, to, yield) +expect(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time) + # for methods that yield to a block multiple times +``` + +Any of these responses can be applied to a stub as well + +```ruby +allow(double).to receive(:msg).and_return(value) +allow(double).to receive(:msg).and_return(value1, value2, value3) +allow(double).to receive(:msg).and_raise(error) +allow(double).to receive(:msg).and_throw(:msg) +allow(double).to receive(:msg).and_yield(values, to, yield) +allow(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time) +``` + +## Arbitrary Handling + +Once in a while you'll find that the available expectations don't solve the +particular problem you are trying to solve. Imagine that you expect the message +to come with an Array argument that has a specific length, but you don't care +what is in it. You could do this: + +```ruby +expect(double).to receive(:msg) do |arg| + expect(arg.size).to eq 7 +end +``` + +If the method being stubbed itself takes a block, and you need to yield to it +in some special way, you can use this: + +```ruby +expect(double).to receive(:msg) do |&arg| + begin + arg.call + ensure + # cleanup + end +end +``` + +## Delegating to the Original Implementation + +When working with a partial mock object, you may occasionally +want to set a message expecation without interfering with how +the object responds to the message. You can use `and_call_original` +to achieve this: + +```ruby +expect(Person).to receive(:find).and_call_original +Person.find # => executes the original find method and returns the result +``` + +## Combining Expectation Details + +Combining the message name with specific arguments, receive counts and responses +you can get quite a bit of detail in your expectations: + +```ruby +expect(double).to receive(:<<).with("illegal value").once.and_raise(ArgumentError) +``` + +While this is a good thing when you really need it, you probably don't really +need it! Take care to specify only the things that matter to the behavior of +your code. + +## Stubbing and Hiding Constants + +See the [mutating constants +README](https://github.com/rspec/rspec-mocks/blob/master/features/mutating_constants/README.md) +for info on this feature. + +## Use `before(:example)`, not `before(:context)` + +Stubs in `before(:context)` are not supported. The reason is that all stubs and mocks get cleared out after each example, so any stub that is set in `before(:context)` would work in the first example that happens to run in that group, but not for any others. + +Instead of `before(:context)`, use `before(:example)`. + +## Settings mocks or stubs on any instance of a class + +rspec-mocks provides two methods, `allow_any_instance_of` and +`expect_any_instance_of`, that will allow you to stub or mock any instance +of a class. They are used in place of `allow` or `expect`: + +```ruby +allow_any_instance_of(Widget).to receive(:name).and_return("Wibble") +expect_any_instance_of(Widget).to receive(:name).and_return("Wobble") +``` + +These methods add the appropriate stub or expectation to all instances of +`Widget`. + +This feature is sometimes useful when working with legacy code, though in +general we discourage its use for a number of reasons: + +* The `rspec-mocks` API is designed for individual object instances, but this + feature operates on entire classes of objects. As a result there are some + sematically confusing edge cases. For example in + `expect_any_instance_of(Widget).to receive(:name).twice` it isn't clear + whether each specific instance is expected to receive `name` twice, or if two + receives total are expected. (It's the former.) +* Using this feature is often a design smell. It may be + that your test is trying to do too much or that the object under test is too + complex. +* It is the most complicated feature of `rspec-mocks`, and has historically + received the most bug reports. (None of the core team actively use it, + which doesn't help.) + + +## Further Reading + +There are many different viewpoints about the meaning of mocks and stubs. If +you are interested in learning more, here is some recommended reading: + +* Mock Objects: http://www.mockobjects.com/ +* Endo-Testing: http://stalatest.googlecode.com/svn/trunk/Literatur/mockobjects.pdf +* Mock Roles, Not Objects: http://jmock.org/oopsla2004.pdf +* Test Double: http://www.martinfowler.com/bliki/TestDouble.html +* Test Double Patterns: http://xunitpatterns.com/Test%20Double%20Patterns.html +* Mocks aren't stubs: http://www.martinfowler.com/articles/mocksArentStubs.html + +## Also see + +* [http://github.com/rspec/rspec](http://github.com/rspec/rspec) +* [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core) +* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations) diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks.rb new file mode 100644 index 000000000..17b2831bc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks.rb @@ -0,0 +1,126 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support 'caller_filter' +RSpec::Support.require_rspec_support 'warnings' +RSpec::Support.require_rspec_support 'ruby_features' + +RSpec::Support.define_optimized_require_for_rspec(:mocks) { |f| require_relative f } + +%w[ + instance_method_stasher + method_double + argument_matchers + example_methods + proxy + test_double + argument_list_matcher + message_expectation + order_group + error_generator + space + mutate_const + targets + syntax + configuration + verifying_double + version +].each { |name| RSpec::Support.require_rspec_mocks name } + +# Share the top-level RSpec namespace, because we are a core supported +# extension. +module RSpec + # Contains top-level utility methods. While this contains a few + # public methods, these are not generally meant to be called from + # a test or example. They exist primarily for integration with + # test frameworks (such as rspec-core). + module Mocks + # Performs per-test/example setup. This should be called before + # an test or example begins. + def self.setup + @space_stack << (@space = space.new_scope) + end + + # Verifies any message expectations that were set during the + # test or example. This should be called at the end of an example. + def self.verify + space.verify_all + end + + # Cleans up all test double state (including any methods that were + # redefined on partial doubles). This _must_ be called after + # each example, even if an error was raised during the example. + def self.teardown + space.reset_all + @space_stack.pop + @space = @space_stack.last || @root_space + end + + # Adds an allowance (stub) on `subject` + # + # @param subject the subject to which the message will be added + # @param message a symbol, representing the message that will be + # added. + # @param opts a hash of options, :expected_from is used to set the + # original call site + # @yield an optional implementation for the allowance + # + # @example Defines the implementation of `foo` on `bar`, using the passed block + # x = 0 + # RSpec::Mocks.allow_message(bar, :foo) { x += 1 } + def self.allow_message(subject, message, opts={}, &block) + space.proxy_for(subject).add_stub(message, opts, &block) + end + + # Sets a message expectation on `subject`. + # @param subject the subject on which the message will be expected + # @param message a symbol, representing the message that will be + # expected. + # @param opts a hash of options, :expected_from is used to set the + # original call site + # @yield an optional implementation for the expectation + # + # @example Expect the message `foo` to receive `bar`, then call it + # RSpec::Mocks.expect_message(bar, :foo) + # bar.foo + def self.expect_message(subject, message, opts={}, &block) + space.proxy_for(subject).add_message_expectation(message, opts, &block) + end + + # Call the passed block and verify mocks after it has executed. This allows + # mock usage in arbitrary places, such as a `before(:all)` hook. + def self.with_temporary_scope + setup + + begin + yield + verify + ensure + teardown + end + end + + class << self + # @private + attr_reader :space + end + @space_stack = [] + @root_space = @space = RSpec::Mocks::RootSpace.new + + # @private + IGNORED_BACKTRACE_LINE = 'this backtrace line is ignored' + + # To speed up boot time a bit, delay loading optional or rarely + # used features until their first use. + autoload :AnyInstance, "rspec/mocks/any_instance" + autoload :ExpectChain, "rspec/mocks/message_chain" + autoload :StubChain, "rspec/mocks/message_chain" + autoload :MarshalExtension, "rspec/mocks/marshal_extension" + + # Namespace for mock-related matchers. + module Matchers + autoload :HaveReceived, "rspec/mocks/matchers/have_received" + autoload :Receive, "rspec/mocks/matchers/receive" + autoload :ReceiveMessageChain, "rspec/mocks/matchers/receive_message_chain" + autoload :ReceiveMessages, "rspec/mocks/matchers/receive_messages" + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance.rb new file mode 100644 index 000000000..bc912d84b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance.rb @@ -0,0 +1,10 @@ +%w[ + any_instance/chain + any_instance/stub_chain + any_instance/stub_chain_chain + any_instance/expect_chain_chain + any_instance/expectation_chain + any_instance/message_chains + any_instance/recorder + any_instance/proxy +].each { |f| RSpec::Support.require_rspec_mocks(f) } diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/chain.rb new file mode 100644 index 000000000..ebc3e4f9e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/chain.rb @@ -0,0 +1,109 @@ +module RSpec + module Mocks + # @private + module AnyInstance + # @private + class Chain + def initialize(recorder, *args, &block) + @recorder = recorder + @expectation_args = args + @expectation_block = block + @argument_list_matcher = ArgumentListMatcher::MATCH_ALL + end + + # @private + # + # Provides convenience methods for recording customizations on message + # expectations. + module Customizations + # @macro [attach] record + # @method $1(*args, &block) + # Records the `$1` message for playback against an instance that + # invokes a method stubbed or mocked using `any_instance`. + # + # @see RSpec::Mocks::MessageExpectation#$1 + # + def self.record(method_name) + define_method(method_name) do |*args, &block| + record(method_name, *args, &block) + end + end + + record :and_return + record :and_raise + record :and_throw + record :and_yield + record :and_call_original + record :with + record :once + record :twice + record :thrice + record :exactly + record :times + record :never + record :at_least + record :at_most + end + + include Customizations + + # @private + def playback!(instance) + message_expectation = create_message_expectation_on(instance) + messages.inject(message_expectation) do |object, message| + object.__send__(*message.first, &message.last) + end + end + + # @private + def constrained_to_any_of?(*constraints) + constraints.any? do |constraint| + messages.any? do |message| + message.first.first == constraint + end + end + end + + # @private + def matches_args?(*args) + @argument_list_matcher.args_match?(*args) + end + + # @private + def expectation_fulfilled! + @expectation_fulfilled = true + end + + def never + ErrorGenerator.raise_double_negation_error("expect_any_instance_of(MyClass)") if negated? + super + end + + def with(*args, &block) + @argument_list_matcher = ArgumentListMatcher.new(*args) + super + end + + private + + def negated? + messages.any? { |(message, *_), _| message == :never } + end + + def messages + @messages ||= [] + end + + def last_message + messages.last.first.first unless messages.empty? + end + + def record(rspec_method_name, *args, &block) + verify_invocation_order(rspec_method_name, *args, &block) + messages << [args.unshift(rspec_method_name), block] + self + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expect_chain_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expect_chain_chain.rb new file mode 100644 index 000000000..0d134025f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expect_chain_chain.rb @@ -0,0 +1,35 @@ +module RSpec + module Mocks + module AnyInstance + # @private + class ExpectChainChain < StubChain + def initialize(*args) + super + @expectation_fulfilled = false + end + + def expectation_fulfilled? + @expectation_fulfilled + end + + def playback!(instance) + super.tap { @expectation_fulfilled = true } + end + + private + + def create_message_expectation_on(instance) + ::RSpec::Mocks::ExpectChain.expect_chain_on(instance, *@expectation_args, &@expectation_block) + end + + def invocation_order + @invocation_order ||= { + :and_return => [nil], + :and_raise => [nil], + :and_yield => [nil] + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expectation_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expectation_chain.rb new file mode 100644 index 000000000..02b55e8d6 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/expectation_chain.rb @@ -0,0 +1,48 @@ +module RSpec + module Mocks + module AnyInstance + # @private + class ExpectationChain < Chain + def expectation_fulfilled? + @expectation_fulfilled || constrained_to_any_of?(:never) + end + + def initialize(*args, &block) + @expectation_fulfilled = false + super + end + + private + + def verify_invocation_order(_rspec_method_name, *_args, &_block) + end + end + + # @private + class PositiveExpectationChain < ExpectationChain + private + + def create_message_expectation_on(instance) + proxy = ::RSpec::Mocks.space.proxy_for(instance) + method_name, opts = @expectation_args + opts = (opts || {}).merge(:expected_form => IGNORED_BACKTRACE_LINE) + + me = proxy.add_message_expectation(method_name, opts, &@expectation_block) + if RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks? + me.and_yield_receiver_to_implementation + end + + me + end + + def invocation_order + @invocation_order ||= { + :with => [nil], + :and_return => [:with, nil], + :and_raise => [:with, nil] + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/message_chains.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/message_chains.rb new file mode 100644 index 000000000..0ce39bc8d --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/message_chains.rb @@ -0,0 +1,85 @@ +module RSpec + module Mocks + module AnyInstance + # @private + class MessageChains + def initialize + @chains_by_method_name = Hash.new { |h, k| h[k] = [] } + end + + # @private + def [](method_name) + @chains_by_method_name[method_name] + end + + # @private + def add(method_name, chain) + @chains_by_method_name[method_name] << chain + chain + end + + # @private + def remove_stub_chains_for!(method_name) + @chains_by_method_name[method_name].reject! do |chain| + StubChain === chain + end + end + + # @private + def has_expectation?(method_name) + @chains_by_method_name[method_name].find do |chain| + ExpectationChain === chain + end + end + + # @private + def each_unfulfilled_expectation_matching(method_name, *args) + @chains_by_method_name[method_name].each do |chain| + yield chain if !chain.expectation_fulfilled? && chain.matches_args?(*args) + end + end + + # @private + def all_expectations_fulfilled? + @chains_by_method_name.all? do |_method_name, chains| + chains.all? { |chain| chain.expectation_fulfilled? } + end + end + + # @private + def unfulfilled_expectations + @chains_by_method_name.map do |method_name, chains| + method_name.to_s if ExpectationChain === chains.last unless chains.last.expectation_fulfilled? + end.compact + end + + # @private + def received_expected_message!(method_name) + @chains_by_method_name[method_name].each do |chain| + chain.expectation_fulfilled! + end + end + + # @private + def playback!(instance, method_name) + raise_if_second_instance_to_receive_message(instance) + @chains_by_method_name[method_name].each do |chain| + chain.playback!(instance) + end + end + + private + + def raise_if_second_instance_to_receive_message(instance) + @instance_with_expectation ||= instance if ExpectationChain === instance + return unless ExpectationChain === instance + return if @instance_with_expectation.equal?(instance) + + raise RSpec::Mocks::MockExpectationError, + "Exactly one instance should have received the following " \ + "message(s) but didn't: #{unfulfilled_expectations.sort.join(', ')}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/proxy.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/proxy.rb new file mode 100644 index 000000000..fc66d392a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/proxy.rb @@ -0,0 +1,116 @@ +module RSpec + module Mocks + module AnyInstance + # @private + # The `AnyInstance::Recorder` is responsible for redefining the klass's + # instance method in order to add any stubs/expectations the first time + # the method is called. It's not capable of updating a stub on an instance + # that's already been previously stubbed (either directly, or via + # `any_instance`). + # + # This proxy sits in front of the recorder and delegates both to it + # and to the `RSpec::Mocks::Proxy` for each already mocked or stubbed + # instance of the class, in order to propogates changes to the instances. + # + # Note that unlike `RSpec::Mocks::Proxy`, this proxy class is stateless + # and is not persisted in `RSpec::Mocks.space`. + # + # Proxying for the message expectation fluent interface (typically chained + # off of the return value of one of these methods) is provided by the + # `FluentInterfaceProxy` class below. + class Proxy + def initialize(recorder, target_proxies) + @recorder = recorder + @target_proxies = target_proxies + end + + def klass + @recorder.klass + end + + def stub(method_name_or_method_map, &block) + if Hash === method_name_or_method_map + method_name_or_method_map.each do |method_name, return_value| + stub(method_name).and_return(return_value) + end + else + perform_proxying(__method__, [method_name_or_method_map], block) do |proxy| + proxy.add_stub(method_name_or_method_map, &block) + end + end + end + + def unstub(method_name) + perform_proxying(__method__, [method_name], nil) do |proxy| + proxy.remove_stub_if_present(method_name) + end + end + + def stub_chain(*chain, &block) + perform_proxying(__method__, chain, block) do |proxy| + Mocks::StubChain.stub_chain_on(proxy.object, *chain, &block) + end + end + + def expect_chain(*chain, &block) + perform_proxying(__method__, chain, block) do |proxy| + Mocks::ExpectChain.expect_chain_on(proxy.object, *chain, &block) + end + end + + def should_receive(method_name, &block) + perform_proxying(__method__, [method_name], block) do |proxy| + # Yeah, this is a bit odd...but if we used `add_message_expectation` + # then it would act like `expect_every_instance_of(klass).to receive`. + # The any_instance recorder takes care of validating that an instance + # received the message. + proxy.add_stub(method_name, &block) + end + end + + def should_not_receive(method_name, &block) + perform_proxying(__method__, [method_name], block) do |proxy| + proxy.add_message_expectation(method_name, &block).never + end + end + + private + + def perform_proxying(method_name, args, block, &target_proxy_block) + recorder_value = @recorder.__send__(method_name, *args, &block) + proxy_values = @target_proxies.map(&target_proxy_block) + FluentInterfaceProxy.new([recorder_value] + proxy_values) + end + end + + # @private + # Delegates messages to each of the given targets in order to + # provide the fluent interface that is available off of message + # expectations when dealing with `any_instance`. + # + # `targets` will typically contain 1 of the `AnyInstance::Recorder` + # return values and N `MessageExpectation` instances (one per instance + # of the `any_instance` klass). + class FluentInterfaceProxy + def initialize(targets) + @targets = targets + end + + if RUBY_VERSION.to_f > 1.8 + def respond_to_missing?(method_name, include_private=false) + super || @targets.first.respond_to?(method_name, include_private) + end + else + def respond_to?(method_name, include_private=false) + super || @targets.first.respond_to?(method_name, include_private) + end + end + + def method_missing(*args, &block) + return_values = @targets.map { |t| t.__send__(*args, &block) } + FluentInterfaceProxy.new(return_values) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/recorder.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/recorder.rb new file mode 100644 index 000000000..271348b4a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/recorder.rb @@ -0,0 +1,267 @@ +module RSpec + module Mocks + module AnyInstance + # Given a class `TheClass`, `TheClass.any_instance` returns a `Recorder`, + # which records stubs and message expectations for later playback on + # instances of `TheClass`. + # + # Further constraints are stored in instances of [Chain](Chain). + # + # @see AnyInstance + # @see Chain + class Recorder + # @private + attr_reader :message_chains, :stubs, :klass + + def initialize(klass) + @message_chains = MessageChains.new + @stubs = Hash.new { |hash, key| hash[key] = [] } + @observed_methods = [] + @played_methods = {} + @klass = klass + @expectation_set = false + end + + # Initializes the recording a stub to be played back against any + # instance of this object that invokes the submitted method. + # + # @see Methods#stub + def stub(method_name, &block) + observe!(method_name) + message_chains.add(method_name, StubChain.new(self, method_name, &block)) + end + + # Initializes the recording a stub chain to be played back against any + # instance of this object that invokes the method matching the first + # argument. + # + # @see Methods#stub_chain + def stub_chain(*method_names_and_optional_return_values, &block) + normalize_chain(*method_names_and_optional_return_values) do |method_name, args| + observe!(method_name) + message_chains.add(method_name, StubChainChain.new(self, *args, &block)) + end + end + + # @private + def expect_chain(*method_names_and_optional_return_values, &block) + @expectation_set = true + normalize_chain(*method_names_and_optional_return_values) do |method_name, args| + observe!(method_name) + message_chains.add(method_name, ExpectChainChain.new(self, *args, &block)) + end + end + + # Initializes the recording a message expectation to be played back + # against any instance of this object that invokes the submitted + # method. + # + # @see Methods#should_receive + def should_receive(method_name, &block) + @expectation_set = true + observe!(method_name) + message_chains.add(method_name, PositiveExpectationChain.new(self, method_name, &block)) + end + + # The opposite of `should_receive` + # + # @see Methods#should_not_receive + def should_not_receive(method_name, &block) + should_receive(method_name, &block).never + end + + # Removes any previously recorded stubs, stub_chains or message + # expectations that use `method_name`. + # + # @see Methods#unstub + def unstub(method_name) + unless @observed_methods.include?(method_name.to_sym) + raise RSpec::Mocks::MockExpectationError, "The method `#{method_name}` was not stubbed or was already unstubbed" + end + message_chains.remove_stub_chains_for!(method_name) + stubs[method_name].clear + stop_observing!(method_name) unless message_chains.has_expectation?(method_name) + end + + # @api private + # + # Used internally to verify that message expectations have been + # fulfilled. + def verify + return unless @expectation_set + return if message_chains.all_expectations_fulfilled? + + raise RSpec::Mocks::MockExpectationError, + "Exactly one instance should have received the following " \ + "message(s) but didn't: #{message_chains.unfulfilled_expectations.sort.join(', ')}" + end + + # @private + def stop_all_observation! + @observed_methods.each { |method_name| restore_method!(method_name) } + end + + # @private + def playback!(instance, method_name) + RSpec::Mocks.space.ensure_registered(instance) + message_chains.playback!(instance, method_name) + @played_methods[method_name] = instance + received_expected_message!(method_name) if message_chains.has_expectation?(method_name) + end + + # @private + def instance_that_received(method_name) + @played_methods[method_name] + end + + # @private + def build_alias_method_name(method_name) + "__#{method_name}_without_any_instance__" + end + + # @private + def already_observing?(method_name) + @observed_methods.include?(method_name) || super_class_observing?(method_name) + end + + # @private + def notify_received_message(_object, message, args, _blk) + has_expectation = false + + message_chains.each_unfulfilled_expectation_matching(message, *args) do |expectation| + has_expectation = true + expectation.expectation_fulfilled! + end + + return unless has_expectation + + restore_method!(message) + mark_invoked!(message) + end + + protected + + def stop_observing!(method_name) + restore_method!(method_name) + @observed_methods.delete(method_name) + super_class_observers_for(method_name).each do |ancestor| + ::RSpec::Mocks.space. + any_instance_recorder_for(ancestor).stop_observing!(method_name) + end + end + + private + + def ancestor_is_an_observer?(method_name) + lambda do |ancestor| + unless ancestor == @klass + ::RSpec::Mocks.space. + any_instance_recorder_for(ancestor).already_observing?(method_name) + end + end + end + + def super_class_observers_for(method_name) + @klass.ancestors.select(&ancestor_is_an_observer?(method_name)) + end + + def super_class_observing?(method_name) + @klass.ancestors.any?(&ancestor_is_an_observer?(method_name)) + end + + def normalize_chain(*args) + args.shift.to_s.split('.').map { |s| s.to_sym }.reverse.each { |a| args.unshift a } + yield args.first, args + end + + def received_expected_message!(method_name) + message_chains.received_expected_message!(method_name) + restore_method!(method_name) + mark_invoked!(method_name) + end + + def restore_method!(method_name) + if public_protected_or_private_method_defined?(build_alias_method_name(method_name)) + restore_original_method!(method_name) + else + remove_dummy_method!(method_name) + end + end + + def restore_original_method!(method_name) + return unless @klass.instance_method(method_name).owner == @klass + + alias_method_name = build_alias_method_name(method_name) + @klass.class_exec do + remove_method method_name + alias_method method_name, alias_method_name + remove_method alias_method_name + end + end + + def remove_dummy_method!(method_name) + @klass.class_exec do + remove_method method_name + end + end + + def backup_method!(method_name) + alias_method_name = build_alias_method_name(method_name) + @klass.class_exec do + alias_method alias_method_name, method_name + end if public_protected_or_private_method_defined?(method_name) + end + + def public_protected_or_private_method_defined?(method_name) + MethodReference.method_defined_at_any_visibility?(@klass, method_name) + end + + def observe!(method_name) + allow_no_prepended_module_definition_of(method_name) + + if RSpec::Mocks.configuration.verify_partial_doubles? + unless public_protected_or_private_method_defined?(method_name) + raise MockExpectationError, + "#{@klass} does not implement ##{method_name}" + end + end + + stop_observing!(method_name) if already_observing?(method_name) + @observed_methods << method_name + backup_method!(method_name) + recorder = self + @klass.__send__(:define_method, method_name) do |*args, &blk| + recorder.playback!(self, method_name) + __send__(method_name, *args, &blk) + end + end + + def mark_invoked!(method_name) + backup_method!(method_name) + recorder = self + @klass.__send__(:define_method, method_name) do |*_args, &_blk| + invoked_instance = recorder.instance_that_received(method_name) + inspect = "#<#{self.class}:#{object_id} #{instance_variables.map { |name| "#{name}=#{instance_variable_get name}" }.join(', ')}>" + raise RSpec::Mocks::MockExpectationError, "The message '#{method_name}' was received by #{inspect} but has already been received by #{invoked_instance}" + end + end + + if Support::RubyFeatures.module_prepends_supported? + def allow_no_prepended_module_definition_of(method_name) + prepended_modules = RSpec::Mocks::Proxy.prepended_modules_of(@klass) + problem_mod = prepended_modules.find { |mod| mod.method_defined?(method_name) } + return unless problem_mod + + raise RSpec::Mocks::MockExpectationError, + "Using `any_instance` to stub a method (#{method_name}) that has been " \ + "defined on a prepended module (#{problem_mod}) is not supported." + end + else + def allow_no_prepended_module_definition_of(_method_name) + # nothing to do; prepends aren't supported on this version of ruby + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain.rb new file mode 100644 index 000000000..c4fa2e295 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain.rb @@ -0,0 +1,45 @@ +module RSpec + module Mocks + module AnyInstance + # @private + class StubChain < Chain + # @private + def expectation_fulfilled? + true + end + + private + + def create_message_expectation_on(instance) + proxy = ::RSpec::Mocks.space.proxy_for(instance) + method_name, opts = @expectation_args + opts = (opts || {}).merge(:expected_form => IGNORED_BACKTRACE_LINE) + + stub = proxy.add_stub(method_name, opts, &@expectation_block) + @recorder.stubs[stub.message] << stub + + if RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks? + stub.and_yield_receiver_to_implementation + end + + stub + end + + def invocation_order + @invocation_order ||= { + :with => [nil], + :and_return => [:with, nil], + :and_raise => [:with, nil], + :and_yield => [:with, nil], + :and_call_original => [:with, nil] + } + end + + def verify_invocation_order(rspec_method_name, *_args, &_block) + return if invocation_order[rspec_method_name].include?(last_message) + raise NoMethodError, "Undefined method #{rspec_method_name}" + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain_chain.rb new file mode 100644 index 000000000..c05696734 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/any_instance/stub_chain_chain.rb @@ -0,0 +1,27 @@ +module RSpec + module Mocks + module AnyInstance + # @private + class StubChainChain < StubChain + def initialize(*args) + super + @expectation_fulfilled = false + end + + private + + def create_message_expectation_on(instance) + ::RSpec::Mocks::StubChain.stub_chain_on(instance, *@expectation_args, &@expectation_block) + end + + def invocation_order + @invocation_order ||= { + :and_return => [nil], + :and_raise => [nil], + :and_yield => [nil] + } + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_list_matcher.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_list_matcher.rb new file mode 100644 index 000000000..a7d15ea5e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_list_matcher.rb @@ -0,0 +1,72 @@ +# We intentionally do not use the `RSpec::Support.require...` methods +# here so that this file can be loaded individually, as documented +# below. +require 'rspec/mocks/argument_matchers' +require 'rspec/support/fuzzy_matcher' + +module RSpec + module Mocks + # Wrapper for matching arguments against a list of expected values. Used by + # the `with` method on a `MessageExpectation`: + # + # expect(object).to receive(:message).with(:a, 'b', 3) + # object.message(:a, 'b', 3) + # + # Values passed to `with` can be literal values or argument matchers that + # match against the real objects .e.g. + # + # expect(object).to receive(:message).with(hash_including(:a => 'b')) + # + # Can also be used directly to match the contents of any `Array`. This + # enables 3rd party mocking libs to take advantage of rspec's argument + # matching without using the rest of rspec-mocks. + # + # require 'rspec/mocks/argument_list_matcher' + # include RSpec::Mocks::ArgumentMatchers + # + # arg_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(123, hash_including(:a => 'b')) + # arg_list_matcher.args_match?(123, :a => 'b') + # + # This class is immutable. + # + # @see ArgumentMatchers + class ArgumentListMatcher + # @private + attr_reader :expected_args + + # @api public + # @param [Array] expected_args a list of expected literals and/or argument matchers + # + # Initializes an `ArgumentListMatcher` with a collection of literal + # values and/or argument matchers. + # + # @see ArgumentMatchers + # @see #args_match? + def initialize(*expected_args) + @expected_args = expected_args + + @matchers = case expected_args.first + when ArgumentMatchers::AnyArgsMatcher then Array + when ArgumentMatchers::NoArgsMatcher then [] + else expected_args + end + end + + # @api public + # @param [Array] args + # + # Matches each element in the `expected_args` against the element in the same + # position of the arguments passed to `new`. + # + # @see #initialize + def args_match?(*args) + Support::FuzzyMatcher.values_match?(@matchers, args) + end + + # Value that will match all argument lists. + # + # @private + MATCH_ALL = new(ArgumentMatchers::AnyArgsMatcher.new) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_matchers.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_matchers.rb new file mode 100644 index 000000000..9194e2939 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/argument_matchers.rb @@ -0,0 +1,282 @@ +# This cannot take advantage of our relative requires, since this file is a +# dependency of `rspec/mocks/argument_list_matcher.rb`. See comment there for +# details. +require 'rspec/support/matcher_definition' + +module RSpec + module Mocks + # ArgumentMatchers are placeholders that you can include in message + # expectations to match arguments against a broader check than simple + # equality. + # + # With the exception of `any_args` and `no_args`, they all match against + # the arg in same position in the argument list. + # + # @see ArgumentListMatcher + module ArgumentMatchers + # Matches any args at all. Supports a more explicit variation of + # `expect(object).to receive(:message)` + # + # @example + # + # expect(object).to receive(:message).with(any_args) + def any_args + AnyArgsMatcher.new + end + + # Matches any argument at all. + # + # @example + # + # expect(object).to receive(:message).with(anything) + def anything + AnyArgMatcher.new + end + + # Matches no arguments. + # + # @example + # + # expect(object).to receive(:message).with(no_args) + def no_args + NoArgsMatcher.new + end + + # Matches if the actual argument responds to the specified messages. + # + # @example + # + # expect(object).to receive(:message).with(duck_type(:hello)) + # expect(object).to receive(:message).with(duck_type(:hello, :goodbye)) + def duck_type(*args) + DuckTypeMatcher.new(*args) + end + + # Matches a boolean value. + # + # @example + # + # expect(object).to receive(:message).with(boolean()) + def boolean + BooleanMatcher.new + end + + # Matches a hash that includes the specified key(s) or key/value pairs. + # Ignores any additional keys. + # + # @example + # + # expect(object).to receive(:message).with(hash_including(:key => val)) + # expect(object).to receive(:message).with(hash_including(:key)) + # expect(object).to receive(:message).with(hash_including(:key, :key2 => val2)) + def hash_including(*args) + HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args)) + end + + # Matches an array that includes the specified items at least once. + # Ignores duplicates and additional values + # + # @example + # + # expect(object).to receive(:message).with(array_including(1,2,3)) + # expect(object).to receive(:message).with(array_including([1,2,3])) + def array_including(*args) + actually_an_array = Array === args.first && args.count == 1 ? args.first : args + ArrayIncludingMatcher.new(actually_an_array) + end + + # Matches a hash that doesn't include the specified key(s) or key/value. + # + # @example + # + # expect(object).to receive(:message).with(hash_excluding(:key => val)) + # expect(object).to receive(:message).with(hash_excluding(:key)) + # expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2)) + def hash_excluding(*args) + HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args)) + end + + alias_method :hash_not_including, :hash_excluding + + # Matches if `arg.instance_of?(klass)` + # + # @example + # + # expect(object).to receive(:message).with(instance_of(Thing)) + def instance_of(klass) + InstanceOf.new(klass) + end + + alias_method :an_instance_of, :instance_of + + # Matches if `arg.kind_of?(klass)` + # @example + # + # expect(object).to receive(:message).with(kind_of(Thing)) + def kind_of(klass) + KindOf.new(klass) + end + + alias_method :a_kind_of, :kind_of + + # @private + def self.anythingize_lonely_keys(*args) + hash = args.last.class == Hash ? args.delete_at(-1) : {} + args.each { | arg | hash[arg] = AnyArgMatcher.new } + hash + end + + # @private + class AnyArgsMatcher + def description + "any args" + end + end + + # @private + class AnyArgMatcher + def ===(_other) + true + end + + def description + "anything" + end + end + + # @private + class NoArgsMatcher + def description + "no args" + end + end + + # @private + class BooleanMatcher + def ===(value) + true == value || false == value + end + + def description + "boolean" + end + end + + # @private + class BaseHashMatcher + def initialize(expected) + @expected = expected + end + + def ===(predicate, actual) + @expected.__send__(predicate) do |k, v| + actual.key?(k) && Support::FuzzyMatcher.values_match?(v, actual[k]) + end + rescue NoMethodError + false + end + + def description(name) + "#{name}(#{@expected.inspect.sub(/^\{/, "").sub(/\}$/, "")})" + end + end + + # @private + class HashIncludingMatcher < BaseHashMatcher + def ===(actual) + super(:all?, actual) + end + + def description + super("hash_including") + end + end + + # @private + class HashExcludingMatcher < BaseHashMatcher + def ===(actual) + super(:none?, actual) + end + + def description + super("hash_not_including") + end + end + + # @private + class ArrayIncludingMatcher + def initialize(expected) + @expected = expected + end + + def ===(actual) + Set.new(actual).superset?(Set.new(@expected)) + end + + def description + "array_including(#{@expected.join(", ")})" + end + end + + # @private + class DuckTypeMatcher + def initialize(*methods_to_respond_to) + @methods_to_respond_to = methods_to_respond_to + end + + def ===(value) + @methods_to_respond_to.all? { |message| value.respond_to?(message) } + end + + def description + "duck_type(#{@methods_to_respond_to.map(&:inspect).join(', ')})" + end + end + + # @private + class InstanceOf + def initialize(klass) + @klass = klass + end + + def ===(actual) + actual.instance_of?(@klass) + end + + def description + "an_instance_of(#{@klass.name})" + end + end + + # @private + class KindOf + def initialize(klass) + @klass = klass + end + + def ===(actual) + actual.kind_of?(@klass) + end + + def description + "kind of #{@klass.name}" + end + end + + matcher_namespace = name + '::' + ::RSpec::Support.register_matcher_definition do |object| + # This is the best we have for now. We should tag all of our matchers + # with a module or something so we can test for it directly. + # + # (Note Module#parent in ActiveSupport is defined in a similar way.) + begin + object.class.name.include?(matcher_namespace) + rescue NoMethodError + # Some objects, like BasicObject, don't implemented standard + # reflection methods. + false + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/configuration.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/configuration.rb new file mode 100644 index 000000000..6da1ce2e1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/configuration.rb @@ -0,0 +1,157 @@ +module RSpec + module Mocks + # Provides configuration options for rspec-mocks. + class Configuration + def initialize + @yield_receiver_to_any_instance_implementation_blocks = true + @verify_doubled_constant_names = false + @transfer_nested_constants = false + @verify_partial_doubles = false + end + + def yield_receiver_to_any_instance_implementation_blocks? + @yield_receiver_to_any_instance_implementation_blocks + end + + # Sets whether or not RSpec will yield the receiving instance of a + # message to blocks that are used for any_instance stub implementations. + # When set, the first yielded argument will be the receiving instance. + # Defaults to `true`. + # + # @example + # + # RSpec.configure do |rspec| + # rspec.mock_with :rspec do |mocks| + # mocks.yield_receiver_to_any_instance_implementation_blocks = false + # end + # end + attr_writer :yield_receiver_to_any_instance_implementation_blocks + + # Adds `stub` and `should_receive` to the given + # modules or classes. This is usually only necessary + # if you application uses some proxy classes that + # "strip themselves down" to a bare minimum set of + # methods and remove `stub` and `should_receive` in + # the process. + # + # @example + # + # RSpec.configure do |rspec| + # rspec.mock_with :rspec do |mocks| + # mocks.add_stub_and_should_receive_to Delegator + # end + # end + # + def add_stub_and_should_receive_to(*modules) + modules.each do |mod| + Syntax.enable_should(mod) + end + end + + # Provides the ability to set either `expect`, + # `should` or both syntaxes. RSpec uses `expect` + # syntax by default. This is needed if you want to + # explicitly enable `should` syntax and/or explicitly + # disable `expect` syntax. + # + # @example + # + # RSpec.configure do |rspec| + # rspec.mock_with :rspec do |mocks| + # mocks.syntax = [:expect, :should] + # end + # end + # + def syntax=(*values) + syntaxes = values.flatten + if syntaxes.include?(:expect) + Syntax.enable_expect + else + Syntax.disable_expect + end + + if syntaxes.include?(:should) + Syntax.enable_should + else + Syntax.disable_should + end + end + + # Returns an array with a list of syntaxes + # that are enabled. + # + # @example + # + # unless RSpec::Mocks.configuration.syntax.include?(:expect) + # raise "this RSpec extension gem requires the rspec-mocks `:expect` syntax" + # end + # + def syntax + syntaxes = [] + syntaxes << :should if Syntax.should_enabled? + syntaxes << :expect if Syntax.expect_enabled? + syntaxes + end + + def verify_doubled_constant_names? + !!@verify_doubled_constant_names + end + + # When this is set to true, an error will be raised when + # `instance_double` or `class_double` is given the name of an undefined + # constant. You probably only want to set this when running your entire + # test suite, with all production code loaded. Setting this for an + # isolated unit test will prevent you from being able to isolate it! + attr_writer :verify_doubled_constant_names + + def transfer_nested_constants? + !!@transfer_nested_constants + end + + # Sets the default for the `transfer_nested_constants` option when + # stubbing constants. + attr_writer :transfer_nested_constants + + # When set to true, partial mocks will be verified the same as object + # doubles. Any stubs will have their arguments checked against the original + # method, and methods that do not exist cannot be stubbed. + def verify_partial_doubles=(val) + @verify_partial_doubles = !!val + end + + def verify_partial_doubles? + @verify_partial_doubles + end + + # Monkey-patch `Marshal.dump` to enable dumping of mocked or stubbed + # objects. By default this will not work since RSpec mocks works by + # adding singleton methods that cannot be serialized. This patch removes + # these singleton methods before serialization. Setting to falsey removes + # the patch. + # + # This method is idempotent. + def patch_marshal_to_support_partial_doubles=(val) + if val + RSpec::Mocks::MarshalExtension.patch! + else + RSpec::Mocks::MarshalExtension.unpatch! + end + end + + # @api private + # Resets the configured syntax to the default. + def reset_syntaxes_to_default + self.syntax = [:should, :expect] + RSpec::Mocks::Syntax.warn_about_should! + end + end + + # Mocks specific configuration, as distinct from `RSpec.configuration` + # which is core RSpec configuration. + def self.configuration + @configuration ||= Configuration.new + end + + configuration.reset_syntaxes_to_default + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/error_generator.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/error_generator.rb new file mode 100644 index 000000000..b9260f33e --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/error_generator.rb @@ -0,0 +1,253 @@ +module RSpec + module Mocks + # Raised when a message expectation is not satisfied. + MockExpectationError = Class.new(Exception) + + # Raised when a test double is used after it has been torn + # down (typically at the end of an rspec-core example). + ExpiredTestDoubleError = Class.new(MockExpectationError) + + # Raised when doubles or partial doubles are used outside of the per-test lifecycle. + OutsideOfExampleError = Class.new(StandardError) + + # @private + UnsupportedMatcherError = Class.new(StandardError) + # @private + NegationUnsupportedError = Class.new(StandardError) + # @private + VerifyingDoubleNotDefinedError = Class.new(StandardError) + + # @private + class ErrorGenerator + attr_writer :opts + + def initialize(target, name) + @target = target + @name = name + end + + # @private + def opts + @opts ||= {} + end + + # @private + def raise_unexpected_message_error(message, *args) + __raise "#{intro} received unexpected message :#{message}#{arg_message(*args)}" + end + + # @private + def raise_unexpected_message_args_error(expectation, *args) + expected_args = format_args(*expectation.expected_args) + actual_args = format_received_args(*args) + __raise "#{intro} received #{expectation.message.inspect} with " \ + "unexpected arguments\n expected: #{expected_args}\n" \ + " got: #{actual_args}" + end + + # @private + def raise_missing_default_stub_error(expectation, *args) + expected_args = format_args(*expectation.expected_args) + actual_args = format_received_args(*args) + __raise "#{intro} received #{expectation.message.inspect} with " \ + "unexpected arguments\n expected: #{expected_args}\n" \ + " got: #{actual_args}\n Please stub a default value " \ + "first if message might be received with other args as well. \n" + end + + # @private + def raise_similar_message_args_error(expectation, *args_for_multiple_calls) + expected_args = format_args(*expectation.expected_args) + actual_args = args_for_multiple_calls.map { |a| format_received_args(*a) }.join(", ") + __raise "#{intro} received #{expectation.message.inspect} with " \ + "unexpected arguments\n expected: #{expected_args}\n" \ + " got: #{actual_args}" + end + + # rubocop:disable Style/ParameterLists + # @private + def raise_expectation_error(message, expected_received_count, argument_list_matcher, actual_received_count, expectation_count_type, *args) + expected_part = expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher) + received_part = received_part_of_expectation_error(actual_received_count, *args) + __raise "(#{intro}).#{message}#{format_args(*args)}\n #{expected_part}\n #{received_part}" + end + # rubocop:enable Style/ParameterLists + + # @private + def raise_unimplemented_error(doubled_module, method_name) + __raise "%s does not implement: %s" % [ + doubled_module.description, + method_name + ] + end + + # @private + def raise_non_public_error(method_name, visibility) + raise NoMethodError, "%s method `%s' called on %s" % [ + visibility, method_name, intro + ] + end + + # @private + def raise_invalid_arguments_error(verifier) + __raise verifier.error_message + end + + # @private + def raise_expired_test_double_error + raise ExpiredTestDoubleError, + "#{intro} was originally created in one example but has leaked into " \ + "another example and can no longer be used. rspec-mocks' doubles are " \ + "designed to only last for one example, and you need to create a new " \ + "one in each example you wish to use it for." + end + + # @private + def received_part_of_expectation_error(actual_received_count, *args) + "received: #{count_message(actual_received_count)}" + + actual_method_call_args_description(actual_received_count, args) + end + + # @private + def expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher) + "expected: #{count_message(expected_received_count, expectation_count_type)}" + + expected_method_call_args_description(argument_list_matcher.expected_args) + end + + # @private + def actual_method_call_args_description(count, args) + method_call_args_description(args) || + if count > 0 && args.length > 0 + " with arguments: #{args.inspect.gsub(/\A\[(.+)\]\z/, '(\1)')}" + else + "" + end + end + + # @private + def expected_method_call_args_description(args) + method_call_args_description(args) || + if args.length > 0 + " with arguments: #{format_args(*args)}" + else + "" + end + end + + # @private + def method_call_args_description(args) + case args.first + when ArgumentMatchers::AnyArgsMatcher then " with any arguments" + when ArgumentMatchers::NoArgsMatcher then " with no arguments" + end + end + + # @private + def describe_expectation(message, expected_received_count, _actual_received_count, *args) + "have received #{message}#{format_args(*args)} #{count_message(expected_received_count)}" + end + + # @private + def raise_out_of_order_error(message) + __raise "#{intro} received :#{message} out of order" + end + + # @private + def raise_block_failed_error(message, detail) + __raise "#{intro} received :#{message} but passed block failed with: #{detail}" + end + + # @private + def raise_missing_block_error(args_to_yield) + __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed" + end + + # @private + def raise_wrong_arity_error(args_to_yield, signature) + __raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with #{signature.description}" + end + + # @private + def raise_only_valid_on_a_partial_double(method) + __raise "#{intro} is a pure test double. `#{method}` is only " \ + "available on a partial double." + end + + # @private + def raise_expectation_on_unstubbed_method(method) + __raise "#{intro} expected to have received #{method}, but that " \ + "object is not a spy or method has not been stubbed." + end + + # @private + def raise_expectation_on_mocked_method(method) + __raise "#{intro} expected to have received #{method}, but that " \ + "method has been mocked instead of stubbed or spied." + end + + def self.raise_double_negation_error(wrapped_expression) + raise "Isn't life confusing enough? You've already set a " \ + "negative message expectation and now you are trying to " \ + "negate it again with `never`. What does an expression like " \ + "`#{wrapped_expression}.not_to receive(:msg).never` even mean?" + end + + private + + def intro + if @name + "Double #{@name.inspect}" + elsif TestDouble === @target + "Double" + elsif Class === @target + "<#{@target.inspect} (class)>" + elsif @target + @target + else + "nil" + end + end + + def __raise(message) + message = opts[:message] unless opts[:message].nil? + Kernel.raise(RSpec::Mocks::MockExpectationError, message) + end + + def arg_message(*args) + " with " + format_args(*args) + end + + def format_args(*args) + args.empty? ? "(no args)" : "(" + arg_list(*args) + ")" + end + + def arg_list(*args) + args.map { |arg| arg_has_valid_description(arg) ? arg.description : arg.inspect }.join(", ") + end + + def arg_has_valid_description(arg) + return false unless arg.respond_to?(:description) + + !arg.description.nil? && !arg.description.empty? + end + + def format_received_args(*args) + args.empty? ? "(no args)" : "(" + received_arg_list(*args) + ")" + end + + def received_arg_list(*args) + args.map(&:inspect).join(", ") + end + + def count_message(count, expectation_count_type=nil) + return "at least #{times(count.abs)}" if count < 0 || expectation_count_type == :at_least + return "at most #{times(count)}" if expectation_count_type == :at_most + times(count) + end + + def times(count) + "#{count} time#{count == 1 ? '' : 's'}" + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/example_methods.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/example_methods.rb new file mode 100644 index 000000000..d994b5cd5 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/example_methods.rb @@ -0,0 +1,379 @@ +RSpec::Support.require_rspec_mocks 'object_reference' + +module RSpec + module Mocks + # Contains methods intended to be used from within code examples. + # Mix this in to your test context (such as a test framework base class) + # to use rspec-mocks with your test framework. If you're using rspec-core, + # it'll take care of doing this for you. + module ExampleMethods + include RSpec::Mocks::ArgumentMatchers + + # @overload double() + # @overload double(name) + # @param name [String/Symbol] used to clarify intent + # @overload double(stubs) + # @param stubs (Hash) hash of message/return-value pairs + # @overload double(name, stubs) + # @param name [String/Symbol] used to clarify intent + # @param stubs (Hash) hash of message/return-value pairs + # @return (Double) + # + # Constructs an instance of [RSpec::Mocks::Double](RSpec::Mocks::Double) configured + # with an optional name, used for reporting in failure messages, and an optional + # hash of message/return-value pairs. + # + # @example + # + # book = double("book", :title => "The RSpec Book") + # book.title #=> "The RSpec Book" + # + # card = double("card", :suit => "Spades", :rank => "A") + # card.suit #=> "Spades" + # card.rank #=> "A" + # + def double(*args) + ExampleMethods.declare_double(Double, *args) + end + + # @overload instance_double(doubled_class) + # @param doubled_class [String, Class] + # @overload instance_double(doubled_class, stubs) + # @param doubled_class [String, Class] + # @param stubs [Hash] hash of message/return-value pairs + # @return InstanceVerifyingDouble + # + # Constructs a test double against a specific class. If the given class + # name has been loaded, only instance methods defined on the class are + # allowed to be stubbed. In all other ways it behaves like a + # [double](double). + def instance_double(doubled_class, *args) + ref = ObjectReference.for(doubled_class) + ExampleMethods.declare_verifying_double(InstanceVerifyingDouble, ref, *args) + end + + # @overload class_double(doubled_class) + # @param doubled_class [String, Module] + # @overload class_double(doubled_class, stubs) + # @param doubled_class [String, Module] + # @param stubs [Hash] hash of message/return-value pairs + # @return ClassVerifyingDouble + # + # Constructs a test double against a specific class. If the given class + # name has been loaded, only class methods defined on the class are + # allowed to be stubbed. In all other ways it behaves like a + # [double](double). + def class_double(doubled_class, *args) + ref = ObjectReference.for(doubled_class) + ExampleMethods.declare_verifying_double(ClassVerifyingDouble, ref, *args) + end + + # @overload object_double(object_or_name) + # @param object_or_name [String, Object] + # @overload object_double(object_or_name, stubs) + # @param object_or_name [String, Object] + # @param stubs [Hash] hash of message/return-value pairs + # @return ObjectVerifyingDouble + # + # Constructs a test double against a specific object. Only the methods + # the object responds to are allowed to be stubbed. If a String argument + # is provided, it is assumed to reference a constant object which is used + # for verification. In all other ways it behaves like a [double](double). + def object_double(object_or_name, *args) + ref = ObjectReference.for(object_or_name, :allow_direct_object_refs) + ExampleMethods.declare_verifying_double(ObjectVerifyingDouble, ref, *args) + end + + # @overload spy() + # @overload spy(name) + # @param name [String/Symbol] used to clarify intent + # @overload spy(stubs) + # @param stubs (Hash) hash of message/return-value pairs + # @overload spy(name, stubs) + # @param name [String/Symbol] used to clarify intent + # @param stubs (Hash) hash of message/return-value pairs + # @return (Double) + # + # Constructs a test double that is optimized for use with + # `have_received`. With a normal double one has to stub methods in order + # to be able to spy them. A spy automatically spies on all methods. + def spy(*args) + double(*args).as_null_object + end + + # @overload instance_spy(doubled_class) + # @param doubled_class [String, Class] + # @overload instance_spy(doubled_class, stubs) + # @param doubled_class [String, Class] + # @param stubs [Hash] hash of message/return-value pairs + # @return InstanceVerifyingDouble + # + # Constructs a test double that is optimized for use with `have_received` + # against a specific class. If the given class name has been loaded, only + # instance methods defined on the class are allowed to be stubbed. With + # a normal double one has to stub methods in order to be able to spy + # them. An instance_spy automatically spies on all instance methods to + # which the class responds. + def instance_spy(*args) + instance_double(*args).as_null_object + end + + # @overload object_spy(object_or_name) + # @param object_or_name [String, Object] + # @overload object_spy(object_or_name, stubs) + # @param object_or_name [String, Object] + # @param stubs [Hash] hash of message/return-value pairs + # @return ObjectVerifyingDouble + # + # Constructs a test double that is optimized for use with `have_received` + # against a specific object. Only instance methods defined on the object + # are allowed to be stubbed. With a normal double one has to stub + # methods in order to be able to spy them. An object_spy automatically + # spies on all methods to which the object responds. + def object_spy(*args) + object_double(*args).as_null_object + end + + # @overload class_spy(doubled_class) + # @param doubled_class [String, Module] + # @overload class_spy(doubled_class, stubs) + # @param doubled_class [String, Module] + # @param stubs [Hash] hash of message/return-value pairs + # @return ClassVerifyingDouble + # + # Constructs a test double that is optimized for use with `have_received` + # against a specific class. If the given class name has been loaded, + # only class methods defined on the class are allowed to be stubbed. + # With a normal double one has to stub methods in order to be able to spy + # them. An class_spy automatically spies on all class methods to which the + # class responds. + def class_spy(*args) + class_double(*args).as_null_object + end + + # Disables warning messages about expectations being set on nil. + # + # By default warning messages are issued when expectations are set on + # nil. This is to prevent false-positives and to catch potential bugs + # early on. + def allow_message_expectations_on_nil + RSpec::Mocks.space.proxy_for(nil).warn_about_expectations = false + end + + # Stubs the named constant with the given value. + # Like method stubs, the constant will be restored + # to its original value (or lack of one, if it was + # undefined) when the example completes. + # + # @param constant_name [String] The fully qualified name of the constant. The current + # constant scoping at the point of call is not considered. + # @param value [Object] The value to make the constant refer to. When the + # example completes, the constant will be restored to its prior state. + # @param options [Hash] Stubbing options. + # @option options :transfer_nested_constants [Boolean, Array] Determines + # what nested constants, if any, will be transferred from the original value + # of the constant to the new value of the constant. This only works if both + # the original and new values are modules (or classes). + # @return [Object] the stubbed value of the constant + # + # @example + # + # stub_const("MyClass", Class.new) # => Replaces (or defines) MyClass with a new class object. + # stub_const("SomeModel::PER_PAGE", 5) # => Sets SomeModel::PER_PAGE to 5. + # + # class CardDeck + # SUITS = [:Spades, :Diamonds, :Clubs, :Hearts] + # NUM_CARDS = 52 + # end + # + # stub_const("CardDeck", Class.new) + # CardDeck::SUITS # => uninitialized constant error + # CardDeck::NUM_CARDS # => uninitialized constant error + # + # stub_const("CardDeck", Class.new, :transfer_nested_constants => true) + # CardDeck::SUITS # => our suits array + # CardDeck::NUM_CARDS # => 52 + # + # stub_const("CardDeck", Class.new, :transfer_nested_constants => [:SUITS]) + # CardDeck::SUITS # => our suits array + # CardDeck::NUM_CARDS # => uninitialized constant error + def stub_const(constant_name, value, options={}) + ConstantMutator.stub(constant_name, value, options) + end + + # Hides the named constant with the given value. The constant will be + # undefined for the duration of the test. + # + # Like method stubs, the constant will be restored to its original value + # when the example completes. + # + # @param constant_name [String] The fully qualified name of the constant. + # The current constant scoping at the point of call is not considered. + # + # @example + # + # hide_const("MyClass") # => MyClass is now an undefined constant + def hide_const(constant_name) + ConstantMutator.hide(constant_name) + end + + # Verifies that the given object received the expected message during the + # course of the test. On a spy objects or as null object doubles this + # works for any method, on other objects the method must have + # been stubbed beforehand in order for messages to be verified. + # + # Stubbing and verifying messages received in this way implements the + # Test Spy pattern. + # + # @param method_name [Symbol] name of the method expected to have been + # called. + # + # @example + # + # invitation = double('invitation', accept: true) + # user.accept_invitation(invitation) + # expect(invitation).to have_received(:accept) + # + # # You can also use most message expectations: + # expect(invitation).to have_received(:accept).with(mailer).once + def have_received(method_name, &block) + Matchers::HaveReceived.new(method_name, &block) + end + + # @method expect + # Used to wrap an object in preparation for setting a mock expectation + # on it. + # + # @example + # + # expect(obj).to receive(:foo).with(5).and_return(:return_value) + # + # @note This method is usually provided by rspec-expectations. However, + # if you use rspec-mocks without rspec-expectations, there's a definition + # of it that is made available here. If you disable the `:expect` syntax + # this method will be undefined. + + # @method allow + # Used to wrap an object in preparation for stubbing a method + # on it. + # + # @example + # + # allow(dbl).to receive(:foo).with(5).and_return(:return_value) + # + # @note If you disable the `:expect` syntax this method will be undefined. + + # @method expect_any_instance_of + # Used to wrap a class in preparation for setting a mock expectation + # on instances of it. + # + # @example + # + # expect_any_instance_of(MyClass).to receive(:foo) + # + # @note If you disable the `:expect` syntax this method will be undefined. + + # @method allow_any_instance_of + # Used to wrap a class in preparation for stubbing a method + # on instances of it. + # + # @example + # + # allow_any_instance_of(MyClass).to receive(:foo) + # + # @note This is only available when you have enabled the `expect` syntax. + + # @method receive + # Used to specify a message that you expect or allow an object + # to receive. The object returned by `receive` supports the same + # fluent interface that `should_receive` and `stub` have always + # supported, allowing you to constrain the arguments or number of + # times, and configure how the object should respond to the message. + # + # @example + # + # expect(obj).to receive(:hello).with("world").exactly(3).times + # + # @note If you disable the `:expect` syntax this method will be undefined. + + # @method receive_messages + # Shorthand syntax used to setup message(s), and their return value(s), + # that you expect or allow an object to receive. The method takes a hash + # of messages and their respective return values. Unlike with `receive`, + # you cannot apply further customizations using a block or the fluent + # interface. + # + # @example + # + # allow(obj).to receive_messages(:speak => "Hello World") + # allow(obj).to receive_messages(:speak => "Hello", :meow => "Meow") + # + # @note If you disable the `:expect` syntax this method will be undefined. + + # @method receive_message_chain + # @overload receive_message_chain(method1, method2) + # @overload receive_message_chain("method1.method2") + # @overload receive_message_chain(method1, method_to_value_hash) + # + # stubs/mocks a chain of messages on an object or test double. + # + # ## Warning: + # + # Chains can be arbitrarily long, which makes it quite painless to + # violate the Law of Demeter in violent ways, so you should consider any + # use of `receive_message_chain` a code smell. Even though not all code smells + # indicate real problems (think fluent interfaces), `receive_message_chain` still + # results in brittle examples. For example, if you write + # `allow(foo).to receive_message_chain(:bar, :baz => 37)` in a spec and then the + # implementation calls `foo.baz.bar`, the stub will not work. + # + # @example + # + # allow(double).to receive_message_chain("foo.bar") { :baz } + # allow(double).to receive_message_chain(:foo, :bar => :baz) + # allow(double).to receive_message_chain(:foo, :bar) { :baz } + # + # # Given any of ^^ these three forms ^^: + # double.foo.bar # => :baz + # + # # Common use in Rails/ActiveRecord: + # allow(Article).to receive_message_chain("recent.published") { [Article.new] } + # + # @note If you disable the `:expect` syntax this method will be undefined. + + # @private + def self.included(klass) + klass.class_exec do + # This gets mixed in so that if `RSpec::Matchers` is included in + # `klass` later, it's definition of `expect` will take precedence. + include ExpectHost unless method_defined?(:expect) + end + end + + # @private + def self.declare_verifying_double(type, ref, *args) + if RSpec::Mocks.configuration.verify_doubled_constant_names? && + !ref.defined? + + raise VerifyingDoubleNotDefinedError, + "#{ref.description} is not a defined constant. " \ + "Perhaps you misspelt it? " \ + "Disable check with verify_doubled_constant_names configuration option." + end + + declare_double(type, ref, *args) + end + + # @private + def self.declare_double(type, *args) + args << {} unless Hash === args.last + type.new(*args) + end + + # This module exists to host the `expect` method for cases where + # rspec-mocks is used w/o rspec-expectations. + module ExpectHost + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/instance_method_stasher.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/instance_method_stasher.rb new file mode 100644 index 000000000..44145ca08 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/instance_method_stasher.rb @@ -0,0 +1,135 @@ +module RSpec + module Mocks + # @private + class InstanceMethodStasher + def initialize(object, method) + @object = object + @method = method + @klass = (class << object; self; end) + + @original_method = nil + @method_is_stashed = false + end + + attr_reader :original_method + + if RUBY_VERSION.to_f < 1.9 + # @private + def method_is_stashed? + @method_is_stashed + end + + # @private + def stash + return if !method_defined_directly_on_klass? || @method_is_stashed + + @klass.__send__(:alias_method, stashed_method_name, @method) + @method_is_stashed = true + end + + # @private + def stashed_method_name + "obfuscated_by_rspec_mocks__#{@method}" + end + private :stashed_method_name + + # @private + def restore + return unless @method_is_stashed + + if @klass.__send__(:method_defined?, @method) + @klass.__send__(:undef_method, @method) + end + @klass.__send__(:alias_method, @method, stashed_method_name) + @klass.__send__(:remove_method, stashed_method_name) + @method_is_stashed = false + end + else + + # @private + def method_is_stashed? + !!@original_method + end + + # @private + def stash + return unless method_defined_directly_on_klass? + @original_method ||= ::RSpec::Support.method_handle_for(@object, @method) + end + + # @private + def restore + return unless @original_method + + if @klass.__send__(:method_defined?, @method) + @klass.__send__(:undef_method, @method) + end + + handle_restoration_failures do + @klass.__send__(:define_method, @method, @original_method) + end + + @original_method = nil + end + end + + if RUBY_DESCRIPTION.include?('2.0.0p247') || RUBY_DESCRIPTION.include?('2.0.0p195') + # ruby 2.0.0-p247 and 2.0.0-p195 both have a bug that we can't work around :(. + # https://bugs.ruby-lang.org/issues/8686 + def handle_restoration_failures + yield + rescue TypeError + RSpec.warn_with( + "RSpec failed to properly restore a partial double (#{@object.inspect}) " \ + "to its original state due to a known bug in MRI 2.0.0-p195 & p247 " \ + "(https://bugs.ruby-lang.org/issues/8686). This object may remain " \ + "screwed up for the rest of this process. Please upgrade to 2.0.0-p353 or above.", + :call_site => nil, :use_spec_location_as_call_site => true + ) + end + else + def handle_restoration_failures + # No known reasons for restoration to fail on other rubies. + yield + end + end + + private + + # @private + def method_defined_directly_on_klass? + method_defined_on_klass? && method_owned_by_klass? + end + + # @private + def method_defined_on_klass?(klass=@klass) + MethodReference.method_defined_at_any_visibility?(klass, @method) + end + + def method_owned_by_klass? + owner = @klass.instance_method(@method).owner + + # On Ruby 2.0.0+ the owner of a method on a class which has been + # `prepend`ed may actually be an instance, e.g. + # `#`, rather than the expected `MyClass`. + owner = owner.class unless Module === owner + + # On some 1.9s (e.g. rubinius) aliased methods + # can report the wrong owner. Example: + # class MyClass + # class << self + # alias alternate_new new + # end + # end + # + # MyClass.owner(:alternate_new) returns `Class` when incorrect, + # but we need to consider the owner to be `MyClass` because + # it is not actually available on `Class` but is on `MyClass`. + # Hence, we verify that the owner actually has the method defined. + # If the given owner does not have the method defined, we assume + # that the method is actually owned by @klass. + owner == @klass || !(method_defined_on_klass?(owner)) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/marshal_extension.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/marshal_extension.rb new file mode 100644 index 000000000..cfa9c1a7b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/marshal_extension.rb @@ -0,0 +1,41 @@ +module RSpec + module Mocks + # Support for `patch_marshal_to_support_partial_doubles` configuration. + # + # @private + class MarshalExtension + def self.patch! + return if Marshal.respond_to?(:dump_with_rspec_mocks) + + Marshal.instance_eval do + class << self + def dump_with_rspec_mocks(object, *rest) + if !::RSpec::Mocks.space.registered?(object) || NilClass === object + dump_without_rspec_mocks(object, *rest) + else + dump_without_rspec_mocks(object.dup, *rest) + end + end + + alias_method :dump_without_rspec_mocks, :dump + undef_method :dump + alias_method :dump, :dump_with_rspec_mocks + end + end + end + + def self.unpatch! + return unless Marshal.respond_to?(:dump_with_rspec_mocks) + + Marshal.instance_eval do + class << self + undef_method :dump_with_rspec_mocks + undef_method :dump + alias_method :dump, :dump_without_rspec_mocks + undef_method :dump_without_rspec_mocks + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/expectation_customization.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/expectation_customization.rb new file mode 100644 index 000000000..81e642797 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/expectation_customization.rb @@ -0,0 +1,20 @@ +module RSpec + module Mocks + module Matchers + # @private + class ExpectationCustomization + attr_accessor :block + + def initialize(method_name, args, block) + @method_name = method_name + @args = args + @block = block + end + + def playback_onto(expectation) + expectation.__send__(@method_name, *@args, &@block) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/have_received.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/have_received.rb new file mode 100644 index 000000000..0534ab850 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/have_received.rb @@ -0,0 +1,121 @@ +module RSpec + module Mocks + module Matchers + # @private + class HaveReceived + COUNT_CONSTRAINTS = %w[exactly at_least at_most times once twice thrice] + ARGS_CONSTRAINTS = %w[with] + CONSTRAINTS = COUNT_CONSTRAINTS + ARGS_CONSTRAINTS + %w[ordered] + + def initialize(method_name, &block) + @method_name = method_name + @block = block + @constraints = [] + @subject = nil + end + + def name + "have_received" + end + + def matches?(subject, &block) + @block ||= block + @subject = subject + @expectation = expect + mock_proxy.ensure_implemented(@method_name) + + expected_messages_received_in_order? + end + + def does_not_match?(subject) + @subject = subject + ensure_count_unconstrained + @expectation = expect.never + mock_proxy.ensure_implemented(@method_name) + expected_messages_received_in_order? + end + + def failure_message + generate_failure_message + end + + def failure_message_when_negated + generate_failure_message + end + + def description + expect.description + end + + CONSTRAINTS.each do |expectation| + define_method expectation do |*args| + @constraints << [expectation, *args] + self + end + end + + def setup_allowance(_subject, &_block) + disallow("allow", " as it would have no effect") + end + + def setup_any_instance_allowance(_subject, &_block) + disallow("allow_any_instance_of") + end + + def setup_any_instance_expectation(_subject, &_block) + disallow("expect_any_instance_of") + end + + private + + def disallow(type, reason="") + raise RSpec::Mocks::MockExpectationError, + "Using #{type}(...) with the `have_received` " \ + "matcher is not supported#{reason}." + end + + def expect + @expectation ||= begin + expectation = mock_proxy.build_expectation(@method_name) + apply_constraints_to expectation + expectation + end + end + + def apply_constraints_to(expectation) + @constraints.each do |constraint| + expectation.send(*constraint) + end + end + + def ensure_count_unconstrained + return unless count_constraint + raise RSpec::Mocks::MockExpectationError, + "can't use #{count_constraint} when negative" + end + + def count_constraint + @constraints.map(&:first).find do |constraint| + COUNT_CONSTRAINTS.include?(constraint) + end + end + + def generate_failure_message + mock_proxy.check_for_unexpected_arguments(@expectation) + @expectation.generate_error + rescue RSpec::Mocks::MockExpectationError => error + error.message + end + + def expected_messages_received_in_order? + mock_proxy.replay_received_message_on @expectation, &@block + @expectation.expected_messages_received? && @expectation.ensure_expected_ordering_received! + end + + def mock_proxy + RSpec::Mocks.space.proxy_for(@subject) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive.rb new file mode 100644 index 000000000..91760c268 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive.rb @@ -0,0 +1,106 @@ +RSpec::Support.require_rspec_mocks 'matchers/expectation_customization' + +module RSpec + module Mocks + module Matchers + # @private + class Receive + def initialize(message, block) + @message = message + @block = block + @recorded_customizations = [] + end + + def name + "receive" + end + + def setup_expectation(subject, &block) + warn_if_any_instance("expect", subject) + setup_mock_proxy_method_substitute(subject, :add_message_expectation, block) + end + alias matches? setup_expectation + + def setup_negative_expectation(subject, &block) + # ensure `never` goes first for cases like `never.and_return(5)`, + # where `and_return` is meant to raise an error + @recorded_customizations.unshift ExpectationCustomization.new(:never, [], nil) + + warn_if_any_instance("expect", subject) + + setup_expectation(subject, &block) + end + alias does_not_match? setup_negative_expectation + + def setup_allowance(subject, &block) + warn_if_any_instance("allow", subject) + setup_mock_proxy_method_substitute(subject, :add_stub, block) + end + + def setup_any_instance_expectation(subject, &block) + setup_any_instance_method_substitute(subject, :should_receive, block) + end + + def setup_any_instance_negative_expectation(subject, &block) + setup_any_instance_method_substitute(subject, :should_not_receive, block) + end + + def setup_any_instance_allowance(subject, &block) + setup_any_instance_method_substitute(subject, :stub, block) + end + + MessageExpectation.public_instance_methods(false).each do |method| + next if method_defined?(method) + + define_method(method) do |*args, &block| + @recorded_customizations << ExpectationCustomization.new(method, args, block) + self + end + end + + private + + def warn_if_any_instance(expression, subject) + return unless AnyInstance::Proxy === subject + + RSpec.warning( + "`#{expression}(#{subject.klass}.any_instance).to` " \ + "is probably not what you meant, it does not operate on " \ + "any instance of `#{subject.klass}`. " \ + "Use `#{expression}_any_instance_of(#{subject.klass}).to` instead." + ) + end + + def setup_mock_proxy_method_substitute(subject, method, block) + proxy = ::RSpec::Mocks.space.proxy_for(subject) + setup_method_substitute(proxy, method, block) + end + + def setup_any_instance_method_substitute(subject, method, block) + proxy = ::RSpec::Mocks.space.any_instance_proxy_for(subject) + setup_method_substitute(proxy, method, block) + end + + def setup_method_substitute(host, method, block, *args) + args << @message.to_sym + block = move_block_to_last_customization(block) + + expectation = host.__send__(method, *args, &(@block || block)) + + @recorded_customizations.each do |customization| + customization.playback_onto(expectation) + end + expectation + end + + def move_block_to_last_customization(block) + last = @recorded_customizations.last + return block unless last + + last.block ||= block + nil + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_message_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_message_chain.rb new file mode 100644 index 000000000..268a54ded --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_message_chain.rb @@ -0,0 +1,66 @@ +RSpec::Support.require_rspec_mocks 'matchers/expectation_customization' + +module RSpec + module Mocks + module Matchers + # @private + class ReceiveMessageChain + def initialize(chain, &block) + @chain = chain + @block = block + @recorded_customizations = [] + end + + [:with, :and_return, :and_throw, :and_raise, :and_yield, :and_call_original].each do |msg| + define_method(msg) do |*args, &block| + @recorded_customizations << ExpectationCustomization.new(msg, args, block) + self + end + end + + def name + "receive_message_chain" + end + + def setup_allowance(subject, &block) + chain = StubChain.stub_chain_on(subject, *@chain, &(@block || block)) + replay_customizations(chain) + end + + def setup_any_instance_allowance(subject, &block) + proxy = ::RSpec::Mocks.space.any_instance_proxy_for(subject) + chain = proxy.stub_chain(*@chain, &(@block || block)) + replay_customizations(chain) + end + + def setup_any_instance_expectation(subject, &block) + proxy = ::RSpec::Mocks.space.any_instance_proxy_for(subject) + chain = proxy.expect_chain(*@chain, &(@block || block)) + replay_customizations(chain) + end + + def setup_expectation(subject, &block) + chain = ExpectChain.expect_chain_on(subject, *@chain, &(@block || block)) + replay_customizations(chain) + end + + def setup_negative_expectation(*_args) + raise NegationUnsupportedError, + "`expect(...).not_to receive_message_chain` is not supported " \ + "since it doesn't really make sense. What would it even mean?" + end + + alias matches? setup_expectation + alias does_not_match? setup_negative_expectation + + private + + def replay_customizations(chain) + @recorded_customizations.each do |customization| + customization.playback_onto(chain) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_messages.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_messages.rb new file mode 100644 index 000000000..96962882a --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/matchers/receive_messages.rb @@ -0,0 +1,71 @@ +module RSpec + module Mocks + module Matchers + # @private + class ReceiveMessages + def initialize(message_return_value_hash) + @message_return_value_hash = message_return_value_hash + @backtrace_line = CallerFilter.first_non_rspec_line + end + + def name + "receive_messages" + end + + def setup_expectation(subject) + warn_about_block if block_given? + each_message_on(proxy_on(subject)) do |host, message, return_value| + host.add_simple_expectation(message, return_value, @backtrace_line) + end + end + alias matches? setup_expectation + + def setup_negative_expectation(_subject) + raise NegationUnsupportedError, + "`expect(...).to_not receive_messages` is not supported since it " \ + "doesn't really make sense. What would it even mean?" + end + alias does_not_match? setup_negative_expectation + + def setup_allowance(subject) + warn_about_block if block_given? + each_message_on(proxy_on(subject)) do |host, message, return_value| + host.add_simple_stub(message, return_value) + end + end + + def setup_any_instance_expectation(subject) + warn_about_block if block_given? + each_message_on(any_instance_of(subject)) do |host, message, return_value| + host.should_receive(message).and_return(return_value) + end + end + + def setup_any_instance_allowance(subject) + warn_about_block if block_given? + any_instance_of(subject).stub(@message_return_value_hash) + end + + def warn_about_block + raise "Implementation blocks aren't supported with `receive_messages`" + end + + private + + def proxy_on(subject) + ::RSpec::Mocks.space.proxy_for(subject) + end + + def any_instance_of(subject) + ::RSpec::Mocks.space.any_instance_proxy_for(subject) + end + + def each_message_on(host) + @message_return_value_hash.each do |message, value| + yield host, message, value + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_chain.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_chain.rb new file mode 100644 index 000000000..4106cb2ec --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_chain.rb @@ -0,0 +1,91 @@ +module RSpec + module Mocks + # @private + class MessageChain + attr_reader :object, :chain, :block + + def initialize(object, *chain, &blk) + @object = object + @chain, @block = format_chain(*chain, &blk) + end + + # @api private + def setup_chain + if chain.length > 1 + if (matching_stub = find_matching_stub) + chain.shift + chain_on(matching_stub.invoke(nil), *chain, &@block) + elsif (matching_expectation = find_matching_expectation) + chain.shift + chain_on(matching_expectation.invoke_without_incrementing_received_count(nil), *chain, &@block) + else + next_in_chain = Double.new + expectation(object, chain.shift) { next_in_chain } + chain_on(next_in_chain, *chain, &@block) + end + else + expectation(object, chain.shift, &@block) + end + end + + private + + def expectation(_object, _message, &_return_block) + raise NotImplementedError + end + + def chain_on(object, *chain, &block) + initialize(object, *chain, &block) + setup_chain + end + + def format_chain(*chain, &blk) + if Hash === chain.last + hash = chain.pop + hash.each do |k, v| + chain << k + blk = Proc.new { v } + end + end + return chain.join('.').split('.'), blk + end + + def find_matching_stub + ::RSpec::Mocks.space.proxy_for(object). + __send__(:find_matching_method_stub, chain.first.to_sym) + end + + def find_matching_expectation + ::RSpec::Mocks.space.proxy_for(object). + __send__(:find_matching_expectation, chain.first.to_sym) + end + end + + # @private + class ExpectChain < MessageChain + # @api private + def self.expect_chain_on(object, *chain, &blk) + new(object, *chain, &blk).setup_chain + end + + private + + def expectation(object, message, &return_block) + ::RSpec::Mocks.expect_message(object, message, {}, &return_block) + end + end + + # @private + class StubChain < MessageChain + def self.stub_chain_on(object, *chain, &blk) + new(object, *chain, &blk).setup_chain + end + + private + + def expectation(object, message, &return_block) + ::RSpec::Mocks.allow_message(object, message, {}, &return_block) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_expectation.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_expectation.rb new file mode 100644 index 000000000..c34a3cbba --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/message_expectation.rb @@ -0,0 +1,694 @@ +module RSpec + module Mocks + # A message expectation that only allows concrete return values to be set + # for a message. While this same effect can be achieved using a standard + # MessageExpecation, this version is much faster and so can be used as an + # optimization. + # + # @private + class SimpleMessageExpectation + def initialize(message, response, error_generator, backtrace_line=nil) + @message, @response, @error_generator, @backtrace_line = message.to_sym, response, error_generator, backtrace_line + @received = false + end + + def invoke(*_) + @received = true + @response + end + + def matches?(message, *_) + @message == message.to_sym + end + + def called_max_times? + false + end + + def verify_messages_received + InsertOntoBacktrace.line(@backtrace_line) do + unless @received + @error_generator.raise_expectation_error(@message, 1, ArgumentListMatcher::MATCH_ALL, 0, nil) + end + end + end + end + + # @private + class MessageExpectation + # @private + attr_accessor :error_generator, :implementation + attr_reader :message + attr_reader :orig_object + attr_writer :expected_received_count, :expected_from, :argument_list_matcher + protected :expected_received_count=, :expected_from=, :error_generator, :error_generator=, :implementation= + + # rubocop:disable Style/ParameterLists + # @private + def initialize(error_generator, expectation_ordering, expected_from, method_double, + type=:expectation, opts={}, &implementation_block) + @error_generator = error_generator + @error_generator.opts = opts + @expected_from = expected_from + @method_double = method_double + @orig_object = @method_double.object + @message = @method_double.method_name + @actual_received_count = 0 + @expected_received_count = type == :expectation ? 1 : :any + @argument_list_matcher = ArgumentListMatcher::MATCH_ALL + @order_group = expectation_ordering + @order_group.register(self) unless type == :stub + @expectation_type = type + @ordered = false + @at_least = @at_most = @exactly = nil + @args_to_yield = [] + @failed_fast = nil + @eval_context = nil + @yield_receiver_to_implementation_block = false + + @implementation = Implementation.new + self.inner_implementation_action = implementation_block + end + # rubocop:enable Style/ParameterLists + + # @private + def expected_args + @argument_list_matcher.expected_args + end + + # @overload and_return(value) + # @overload and_return(first_value, second_value) + # + # Tells the object to return a value when it receives the message. Given + # more than one value, the first value is returned the first time the + # message is received, the second value is returned the next time, etc, + # etc. + # + # If the message is received more times than there are values, the last + # value is received for every subsequent call. + # + # @example + # + # allow(counter).to receive(:count).and_return(1) + # counter.count # => 1 + # counter.count # => 1 + # + # allow(counter).to receive(:count).and_return(1,2,3) + # counter.count # => 1 + # counter.count # => 2 + # counter.count # => 3 + # counter.count # => 3 + # counter.count # => 3 + # # etc + def and_return(first_value, *values) + if negative? + raise "`and_return` is not supported with negative message expectations" + end + + if block_given? + raise ArgumentError, "Implementation blocks aren't supported with `and_return`" + end + + values.unshift(first_value) + @expected_received_count = [@expected_received_count, values.size].max unless ignoring_args? || (@expected_received_count == 0 && @at_least) + self.terminal_implementation_action = AndReturnImplementation.new(values) + + nil + end + + def and_yield_receiver_to_implementation + @yield_receiver_to_implementation_block = true + self + end + + def yield_receiver_to_implementation_block? + @yield_receiver_to_implementation_block + end + + # Tells the object to delegate to the original unmodified method + # when it receives the message. + # + # @note This is only available on partial doubles. + # + # @example + # + # expect(counter).to receive(:increment).and_call_original + # original_count = counter.count + # counter.increment + # expect(counter.count).to eq(original_count + 1) + def and_call_original + and_wrap_original do |original, *args, &block| + original.call(*args, &block) + end + end + + # Decorates the stubbed method with the supplied block. The original + # unmodified method is passed to the block along with any method call + # arguments so you can delegate to it, whilst still being able to + # change what args are passed to it and/or change the return value. + # + # @note This is only available on partial doubles. + # + # @example + # + # expect(api).to receive(:large_list).and_wrap_original do |original_method, *args, &block| + # original_method.call(*args, &block).first(10) + # end + # + def and_wrap_original(&block) + if RSpec::Mocks::TestDouble === @method_double.object + @error_generator.raise_only_valid_on_a_partial_double(:and_call_original) + else + warn_about_stub_override if implementation.inner_action + @implementation = AndWrapOriginalImplementation.new(@method_double.original_method, block) + @yield_receiver_to_implementation_block = false + end + end + + # @overload and_raise + # @overload and_raise(ExceptionClass) + # @overload and_raise(ExceptionClass, message) + # @overload and_raise(exception_instance) + # + # Tells the object to raise an exception when the message is received. + # + # @note + # + # When you pass an exception class, the MessageExpectation will raise + # an instance of it, creating it with `exception` and passing `message` + # if specified. If the exception class initializer requires more than + # one parameters, you must pass in an instance and not the class, + # otherwise this method will raise an ArgumentError exception. + # + # @example + # + # allow(car).to receive(:go).and_raise + # allow(car).to receive(:go).and_raise(OutOfGas) + # allow(car).to receive(:go).and_raise(OutOfGas, "At least 2 oz of gas needed to drive") + # allow(car).to receive(:go).and_raise(OutOfGas.new(2, :oz)) + def and_raise(exception=RuntimeError, message=nil) + if exception.respond_to?(:exception) + exception = message ? exception.exception(message) : exception.exception + end + + self.terminal_implementation_action = Proc.new { raise exception } + nil + end + + # @overload and_throw(symbol) + # @overload and_throw(symbol, object) + # + # Tells the object to throw a symbol (with the object if that form is + # used) when the message is received. + # + # @example + # + # allow(car).to receive(:go).and_throw(:out_of_gas) + # allow(car).to receive(:go).and_throw(:out_of_gas, :level => 0.1) + def and_throw(*args) + self.terminal_implementation_action = Proc.new { throw(*args) } + nil + end + + # Tells the object to yield one or more args to a block when the message + # is received. + # + # @example + # + # stream.stub(:open).and_yield(StringIO.new) + def and_yield(*args, &block) + yield @eval_context = Object.new if block + @args_to_yield << args + self.initial_implementation_action = AndYieldImplementation.new(@args_to_yield, @eval_context, @error_generator) + self + end + + # @private + def matches?(message, *args) + @message == message && @argument_list_matcher.args_match?(*args) + end + + # @private + def safe_invoke(parent_stub, *args, &block) + invoke_incrementing_actual_calls_by(1, false, parent_stub, *args, &block) + end + + # @private + def invoke(parent_stub, *args, &block) + invoke_incrementing_actual_calls_by(1, true, parent_stub, *args, &block) + end + + # @private + def invoke_without_incrementing_received_count(parent_stub, *args, &block) + invoke_incrementing_actual_calls_by(0, true, parent_stub, *args, &block) + end + + # @private + def negative? + @expected_received_count == 0 && !@at_least + end + + # @private + def called_max_times? + @expected_received_count != :any && + !@at_least && + @expected_received_count > 0 && + @actual_received_count >= @expected_received_count + end + + # @private + def matches_name_but_not_args(message, *args) + @message == message && !@argument_list_matcher.args_match?(*args) + end + + # @private + def verify_messages_received + InsertOntoBacktrace.line(@expected_from) do + generate_error unless expected_messages_received? || failed_fast? + end + end + + # @private + def expected_messages_received? + ignoring_args? || matches_exact_count? || matches_at_least_count? || matches_at_most_count? + end + + def ensure_expected_ordering_received! + @order_group.verify_invocation_order(self) if @ordered + true + end + + # @private + def ignoring_args? + @expected_received_count == :any + end + + # @private + def matches_at_least_count? + @at_least && @actual_received_count >= @expected_received_count + end + + # @private + def matches_at_most_count? + @at_most && @actual_received_count <= @expected_received_count + end + + # @private + def matches_exact_count? + @expected_received_count == @actual_received_count + end + + # @private + def similar_messages + @similar_messages ||= [] + end + + # @private + def advise(*args) + similar_messages << args + end + + # @private + def generate_error + if similar_messages.empty? + @error_generator.raise_expectation_error(@message, @expected_received_count, @argument_list_matcher, @actual_received_count, expectation_count_type, *expected_args) + else + @error_generator.raise_similar_message_args_error(self, *@similar_messages) + end + end + + def expectation_count_type + return :at_least if @at_least + return :at_most if @at_most + nil + end + + # @private + def description + @error_generator.describe_expectation(@message, @expected_received_count, @actual_received_count, *expected_args) + end + + def raise_out_of_order_error + @error_generator.raise_out_of_order_error @message + end + + # Constrains a stub or message expectation to invocations with specific + # arguments. + # + # With a stub, if the message might be received with other args as well, + # you should stub a default value first, and then stub or mock the same + # message using `with` to constrain to specific arguments. + # + # A message expectation will fail if the message is received with different + # arguments. + # + # @example + # + # allow(cart).to receive(:add) { :failure } + # allow(cart).to receive(:add).with(Book.new(:isbn => 1934356379)) { :success } + # cart.add(Book.new(:isbn => 1234567890)) + # # => :failure + # cart.add(Book.new(:isbn => 1934356379)) + # # => :success + # + # expect(cart).to receive(:add).with(Book.new(:isbn => 1934356379)) { :success } + # cart.add(Book.new(:isbn => 1234567890)) + # # => failed expectation + # cart.add(Book.new(:isbn => 1934356379)) + # # => passes + def with(*args, &block) + if args.empty? + raise ArgumentError, + "`with` must have at least one argument. Use `no_args` matcher to set the expectation of receiving no arguments." + end + + self.inner_implementation_action = block + @argument_list_matcher = ArgumentListMatcher.new(*args) + self + end + + # Constrain a message expectation to be received a specific number of + # times. + # + # @example + # + # expect(dealer).to receive(:deal_card).exactly(10).times + def exactly(n, &block) + self.inner_implementation_action = block + set_expected_received_count :exactly, n + self + end + + # Constrain a message expectation to be received at least a specific + # number of times. + # + # @example + # + # expect(dealer).to receive(:deal_card).at_least(9).times + def at_least(n, &block) + set_expected_received_count :at_least, n + + if n == 0 + raise "at_least(0) has been removed, use allow(...).to receive(:message) instead" + end + + self.inner_implementation_action = block + + self + end + + # Constrain a message expectation to be received at most a specific + # number of times. + # + # @example + # + # expect(dealer).to receive(:deal_card).at_most(10).times + def at_most(n, &block) + self.inner_implementation_action = block + set_expected_received_count :at_most, n + self + end + + # Syntactic sugar for `exactly`, `at_least` and `at_most` + # + # @example + # + # expect(dealer).to receive(:deal_card).exactly(10).times + # expect(dealer).to receive(:deal_card).at_least(10).times + # expect(dealer).to receive(:deal_card).at_most(10).times + def times(&block) + self.inner_implementation_action = block + self + end + + # Expect a message not to be received at all. + # + # @example + # + # expect(car).to receive(:stop).never + def never + ErrorGenerator.raise_double_negation_error("expect(obj)") if negative? + @expected_received_count = 0 + self + end + + # Expect a message to be received exactly one time. + # + # @example + # + # expect(car).to receive(:go).once + def once(&block) + self.inner_implementation_action = block + set_expected_received_count :exactly, 1 + self + end + + # Expect a message to be received exactly two times. + # + # @example + # + # expect(car).to receive(:go).twice + def twice(&block) + self.inner_implementation_action = block + set_expected_received_count :exactly, 2 + self + end + + # Expect a message to be received exactly three times. + # + # @example + # + # expect(car).to receive(:go).thrice + def thrice(&block) + self.inner_implementation_action = block + set_expected_received_count :exactly, 3 + self + end + + # Expect messages to be received in a specific order. + # + # @example + # + # expect(api).to receive(:prepare).ordered + # expect(api).to receive(:run).ordered + # expect(api).to receive(:finish).ordered + def ordered(&block) + self.inner_implementation_action = block + additional_expected_calls.times do + @order_group.register(self) + end + @ordered = true + self + end + + # @private + def additional_expected_calls + return 0 if @expectation_type == :stub || !@exactly + @expected_received_count - 1 + end + + # @private + def ordered? + @ordered + end + + # @private + def negative_expectation_for?(message) + @message == message && negative? + end + + # @private + def actual_received_count_matters? + @at_least || @at_most || @exactly + end + + # @private + def increase_actual_received_count! + @actual_received_count += 1 + end + + private + + def invoke_incrementing_actual_calls_by(increment, allowed_to_fail, parent_stub, *args, &block) + args.unshift(orig_object) if yield_receiver_to_implementation_block? + + if negative? || (allowed_to_fail && (@exactly || @at_most) && (@actual_received_count == @expected_received_count)) + @actual_received_count += increment + @failed_fast = true + # args are the args we actually received, @argument_list_matcher is the + # list of args we were expecting + @error_generator.raise_expectation_error(@message, @expected_received_count, @argument_list_matcher, @actual_received_count, expectation_count_type, *args) + end + + @order_group.handle_order_constraint self + + begin + if implementation.present? + implementation.call(*args, &block) + elsif parent_stub + parent_stub.invoke(nil, *args, &block) + end + ensure + @actual_received_count += increment + end + end + + def failed_fast? + @failed_fast + end + + def set_expected_received_count(relativity, n) + @at_least = (relativity == :at_least) + @at_most = (relativity == :at_most) + @exactly = (relativity == :exactly) + @expected_received_count = case n + when Numeric then n + when :once then 1 + when :twice then 2 + when :thrice then 3 + end + end + + def initial_implementation_action=(action) + implementation.initial_action = action + end + + def inner_implementation_action=(action) + return unless action + warn_about_stub_override if implementation.inner_action + implementation.inner_action = action + end + + def terminal_implementation_action=(action) + implementation.terminal_action = action + end + + def warn_about_stub_override + RSpec.warning( + "You're overriding a previous stub implementation of `#{@message}`. " \ + "Called from #{CallerFilter.first_non_rspec_line}." + ) + end + end + + # Handles the implementation of an `and_yield` declaration. + # @private + class AndYieldImplementation + def initialize(args_to_yield, eval_context, error_generator) + @args_to_yield = args_to_yield + @eval_context = eval_context + @error_generator = error_generator + end + + def call(*_args_to_ignore, &block) + return if @args_to_yield.empty? && @eval_context.nil? + + @error_generator.raise_missing_block_error @args_to_yield unless block + value = nil + block_signature = Support::BlockSignature.new(block) + + @args_to_yield.each do |args| + unless Support::StrictSignatureVerifier.new(block_signature, args).valid? + @error_generator.raise_wrong_arity_error(args, block_signature) + end + + value = @eval_context ? @eval_context.instance_exec(*args, &block) : block.call(*args) + end + value + end + end + + # Handles the implementation of an `and_return` implementation. + # @private + class AndReturnImplementation + def initialize(values_to_return) + @values_to_return = values_to_return + end + + def call(*_args_to_ignore, &_block) + if @values_to_return.size > 1 + @values_to_return.shift + else + @values_to_return.first + end + end + end + + # Represents a configured implementation. Takes into account + # any number of sub-implementations. + # @private + class Implementation + attr_accessor :initial_action, :inner_action, :terminal_action + + def call(*args, &block) + actions.map do |action| + action.call(*args, &block) + end.last + end + + def present? + actions.any? + end + + private + + def actions + [initial_action, inner_action, terminal_action].compact + end + end + + # Represents an `and_call_original` implementation. + # @private + class AndWrapOriginalImplementation + def initialize(method, block) + @method = method + @block = block + end + + CannotModifyFurtherError = Class.new(StandardError) + + def initial_action=(_value) + raise cannot_modify_further_error + end + + def inner_action=(_value) + raise cannot_modify_further_error + end + + def terminal_action=(_value) + raise cannot_modify_further_error + end + + def present? + true + end + + def inner_action + true + end + + def call(*args, &block) + @block.call(@method, *args, &block) + end + + private + + def cannot_modify_further_error + CannotModifyFurtherError.new "This method has already been configured " \ + "to call the original implementation, and cannot be modified further." + end + end + + # Insert original locations into stacktraces + # + # @private + class InsertOntoBacktrace + def self.line(location) + yield + rescue RSpec::Mocks::MockExpectationError => error + error.backtrace.insert(0, location) + Kernel.raise error + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_double.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_double.rb new file mode 100644 index 000000000..34b84aafd --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_double.rb @@ -0,0 +1,260 @@ +module RSpec + module Mocks + # @private + class MethodDouble + # @private + attr_reader :method_name, :object, :expectations, :stubs + + # @private + def initialize(object, method_name, proxy) + @method_name = method_name + @object = object + @proxy = proxy + + @original_visibility = nil + @method_stasher = InstanceMethodStasher.new(object, method_name) + @method_is_proxied = false + @expectations = [] + @stubs = [] + end + + def original_method + # If original method is not present, uses the `method_missing` + # handler of the object. This accounts for cases where the user has not + # correctly defined `respond_to?`, and also 1.8 which does not provide + # method handles for missing methods even if `respond_to?` is correct. + @original_method ||= + @method_stasher.original_method || + @proxy.original_method_handle_for(method_name) || + Proc.new do |*args, &block| + @object.__send__(:method_missing, @method_name, *args, &block) + end + end + + alias_method :save_original_method!, :original_method + + # @private + def visibility + @proxy.visibility_for(@method_name) + end + + # @private + def object_singleton_class + class << @object; self; end + end + + # @private + def configure_method + @original_visibility = [visibility, method_name] + @method_stasher.stash unless @method_is_proxied + define_proxy_method + end + + # @private + def define_proxy_method + return if @method_is_proxied + + save_original_method! + definition_target.class_exec(self, method_name, visibility) do |method_double, method_name, visibility| + define_method(method_name) do |*args, &block| + method_double.proxy_method_invoked(self, *args, &block) + end + __send__(visibility, method_name) + end + + @method_is_proxied = true + end + + # The implementation of the proxied method. Subclasses may override this + # method to perform additional operations. + # + # @private + def proxy_method_invoked(_obj, *args, &block) + @proxy.message_received method_name, *args, &block + end + + # @private + def restore_original_method + return show_frozen_warning if object_singleton_class.frozen? + return unless @method_is_proxied + + definition_target.__send__(:remove_method, @method_name) + + @method_stasher.restore if @method_stasher.method_is_stashed? + restore_original_visibility + + @method_is_proxied = false + end + + # @private + def show_frozen_warning + RSpec.warn_with( + "WARNING: rspec-mocks was unable to restore the original `#{@method_name}` " \ + "method on #{@object.inspect} because it has been frozen. If you reuse this " \ + "object, `#{@method_name}` will continue to respond with its stub implementation.", + :call_site => nil, + :use_spec_location_as_call_site => true + ) + end + + # @private + def restore_original_visibility + return unless @original_visibility && + MethodReference.method_defined_at_any_visibility?(object_singleton_class, @method_name) + + object_singleton_class.__send__(*@original_visibility) + end + + # @private + def verify + expectations.each { |e| e.verify_messages_received } + end + + # @private + def reset + restore_original_method + clear + end + + # @private + def clear + expectations.clear + stubs.clear + end + + # The type of message expectation to create has been extracted to its own + # method so that subclasses can override it. + # + # @private + def message_expectation_class + MessageExpectation + end + + # @private + def add_expectation(error_generator, expectation_ordering, expected_from, opts, &implementation) + configure_method + expectation = message_expectation_class.new(error_generator, expectation_ordering, + expected_from, self, :expectation, opts, &implementation) + expectations << expectation + expectation + end + + # @private + def build_expectation(error_generator, expectation_ordering) + expected_from = IGNORED_BACKTRACE_LINE + message_expectation_class.new(error_generator, expectation_ordering, expected_from, self) + end + + # @private + def add_stub(error_generator, expectation_ordering, expected_from, opts={}, &implementation) + configure_method + stub = message_expectation_class.new(error_generator, expectation_ordering, expected_from, + self, :stub, opts, &implementation) + stubs.unshift stub + stub + end + + # A simple stub can only return a concrete value for a message, and + # cannot match on arguments. It is used as an optimization over + # `add_stub` / `add_expectation` where it is known in advance that this + # is all that will be required of a stub, such as when passing attributes + # to the `double` example method. They do not stash or restore existing method + # definitions. + # + # @private + def add_simple_stub(method_name, response) + setup_simple_method_double method_name, response, stubs + end + + # @private + def add_simple_expectation(method_name, response, error_generator, backtrace_line) + setup_simple_method_double method_name, response, expectations, error_generator, backtrace_line + end + + # @private + def setup_simple_method_double(method_name, response, collection, error_generator=nil, backtrace_line=nil) + define_proxy_method + + me = SimpleMessageExpectation.new(method_name, response, error_generator, backtrace_line) + collection.unshift me + me + end + + # @private + def add_default_stub(*args, &implementation) + return if stubs.any? + add_stub(*args, &implementation) + end + + # @private + def remove_stub + raise_method_not_stubbed_error if stubs.empty? + remove_stub_if_present + end + + # @private + def remove_stub_if_present + expectations.empty? ? reset : stubs.clear + end + + # @private + def raise_method_not_stubbed_error + raise MockExpectationError, "The method `#{method_name}` was not stubbed or was already unstubbed" + end + + # In Ruby 2.0.0 and above prepend will alter the method lookup chain. + # We use an object's singleton class to define method doubles upon, + # however if the object has had it's singleton class (as opposed to + # it's actual class) prepended too then the the method lookup chain + # will look in the prepended module first, **before** the singleton + # class. + # + # This code works around that by providing a mock definition target + # that is either the singleton class, or if necessary, a prepended module + # of our own. + # + if Support::RubyFeatures.module_prepends_supported? + + private + + # We subclass `Module` in order to be able to easily detect our prepended module. + RSpecPrependedModule = Class.new(Module) + + def definition_target + @definition_target ||= usable_rspec_prepended_module || object_singleton_class + end + + def usable_rspec_prepended_module + @proxy.prepended_modules_of_singleton_class.each do |mod| + # If we have one of our modules prepended before one of the user's + # modules that defines the method, use that, since our module's + # definition will take precedence. + return mod if RSpecPrependedModule === mod + + # If we hit a user module with the method defined first, + # we must create a new prepend module, even if one exists later, + # because ours will only take precedence if it comes first. + return new_rspec_prepended_module if mod.method_defined?(method_name) + end + + nil + end + + def new_rspec_prepended_module + RSpecPrependedModule.new.tap do |mod| + object_singleton_class.__send__ :prepend, mod + end + end + + else + + private + + def definition_target + object_singleton_class + end + + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_reference.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_reference.rb new file mode 100644 index 000000000..21896bf07 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/method_reference.rb @@ -0,0 +1,155 @@ +module RSpec + module Mocks + # Represents a method on an object that may or may not be defined. + # The method may be an instance method on a module or a method on + # any object. + # + # @private + class MethodReference + def initialize(object_reference, method_name) + @object_reference = object_reference + @method_name = method_name + end + + # A method is implemented if sending the message does not result in + # a `NoMethodError`. It might be dynamically implemented by + # `method_missing`. + def implemented? + @object_reference.when_loaded do |m| + method_implemented?(m) + end + end + + # Returns true if we definitively know that sending the method + # will result in a `NoMethodError`. + # + # This is not simply the inverse of `implemented?`: there are + # cases when we don't know if a method is implemented and + # both `implemented?` and `unimplemented?` will return false. + def unimplemented? + @object_reference.when_loaded do |_m| + return !implemented? + end + + # If it's not loaded, then it may be implemented but we can't check. + false + end + + # A method is defined if we are able to get a `Method` object for it. + # In that case, we can assert against metadata like the arity. + def defined? + @object_reference.when_loaded do |m| + method_defined?(m) + end + end + + def with_signature + return unless (original = original_method) + yield Support::MethodSignature.new(original) + end + + def visibility + @object_reference.when_loaded do |m| + return visibility_from(m) + end + + # When it's not loaded, assume it's public. We don't want to + # wrongly treat the method as private. + :public + end + + private + + def original_method + @object_reference.when_loaded do |m| + self.defined? && find_method(m) + end + end + + def self.instance_method_visibility_for(klass, method_name) + if klass.public_method_defined?(method_name) + :public + elsif klass.private_method_defined?(method_name) + :private + elsif klass.protected_method_defined?(method_name) + :protected + end + end + + class << self + alias method_defined_at_any_visibility? instance_method_visibility_for + end + + def self.method_visibility_for(object, method_name) + instance_method_visibility_for(class << object; self; end, method_name).tap do |vis| + # If the method is not defined on the class, `instance_method_visibility_for` + # returns `nil`. However, it may be handled dynamically by `method_missing`, + # so here we check `respond_to` (passing false to not check private methods). + # + # This only considers the public case, but I don't think it's possible to + # write `method_missing` in such a way that it handles a dynamic message + # with private or protected visibility. Ruby doesn't provide you with + # the caller info. + return :public if vis.nil? && object.respond_to?(method_name, false) + end + end + end + + # @private + class InstanceMethodReference < MethodReference + private + + def method_implemented?(mod) + MethodReference.method_defined_at_any_visibility?(mod, @method_name) + end + + # Ideally, we'd use `respond_to?` for `method_implemented?` but we need a + # reference to an instance to do that and we don't have one. Note that + # we may get false negatives: if the method is implemented via + # `method_missing`, we'll return `false` even though it meets our + # definition of "implemented". However, it's the best we can do. + alias method_defined? method_implemented? + + # works around the fact that repeated calls for method parameters will + # falsely return empty arrays on JRuby in certain circumstances, this + # is necessary here because we can't dup/clone UnboundMethods. + # + # This is necessary due to a bug in JRuby prior to 1.7.5 fixed in: + # https://github.com/jruby/jruby/commit/99a0613fe29935150d76a9a1ee4cf2b4f63f4a27 + if RUBY_PLATFORM == 'java' && JRUBY_VERSION.split('.')[-1].to_i < 5 + def find_method(mod) + mod.dup.instance_method(@method_name) + end + else + def find_method(mod) + mod.instance_method(@method_name) + end + end + + def visibility_from(mod) + MethodReference.instance_method_visibility_for(mod, @method_name) + end + end + + # @private + class ObjectMethodReference < MethodReference + private + + def method_implemented?(object) + object.respond_to?(@method_name, true) + end + + def method_defined?(object) + (class << object; self; end).method_defined?(@method_name) + end + + def find_method(object) + object.method(@method_name) + end + + def visibility_from(object) + MethodReference.method_visibility_for(object, @method_name) + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/mutate_const.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/mutate_const.rb new file mode 100644 index 000000000..cdbade080 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/mutate_const.rb @@ -0,0 +1,324 @@ +RSpec::Support.require_rspec_support 'recursive_const_methods' + +module RSpec + module Mocks + # Provides information about constants that may (or may not) + # have been mutated by rspec-mocks. + class Constant + extend Support::RecursiveConstMethods + + # @api private + def initialize(name) + @name = name + @previously_defined = false + @stubbed = false + @hidden = false + end + + # @return [String] The fully qualified name of the constant. + attr_reader :name + + # @return [Object, nil] The original value (e.g. before it + # was mutated by rspec-mocks) of the constant, or + # nil if the constant was not previously defined. + attr_accessor :original_value + + # @private + attr_writer :previously_defined, :stubbed, :hidden + + # @return [Boolean] Whether or not the constant was defined + # before the current example. + def previously_defined? + @previously_defined + end + + # @return [Boolean] Whether or not rspec-mocks has mutated + # (stubbed or hidden) this constant. + def mutated? + @stubbed || @hidden + end + + # @return [Boolean] Whether or not rspec-mocks has stubbed + # this constant. + def stubbed? + @stubbed + end + + # @return [Boolean] Whether or not rspec-mocks has hidden + # this constant. + def hidden? + @hidden + end + + # The default `to_s` isn't very useful, so a custom version is provided. + def to_s + "#<#{self.class.name} #{name}>" + end + alias inspect to_s + + # @private + def self.unmutated(name) + const = new(name) + const.previously_defined = recursive_const_defined?(name) + const.stubbed = false + const.hidden = false + const.original_value = recursive_const_get(name) if const.previously_defined? + + const + end + + # Queries rspec-mocks to find out information about the named constant. + # + # @param [String] name the name of the constant + # @return [Constant] an object contaning information about the named + # constant. + def self.original(name) + mutator = ::RSpec::Mocks.space.constant_mutator_for(name) + mutator ? mutator.to_constant : unmutated(name) + end + end + + # Provides a means to stub constants. + class ConstantMutator + extend Support::RecursiveConstMethods + + # Stubs a constant. + # + # @param (see ExampleMethods#stub_const) + # @option (see ExampleMethods#stub_const) + # @return (see ExampleMethods#stub_const) + # + # @see ExampleMethods#stub_const + # @note It's recommended that you use `stub_const` in your + # examples. This is an alternate public API that is provided + # so you can stub constants in other contexts (e.g. helper + # classes). + def self.stub(constant_name, value, options={}) + mutator = if recursive_const_defined?(constant_name, &raise_on_invalid_const) + DefinedConstantReplacer + else + UndefinedConstantSetter + end + + mutate(mutator.new(constant_name, value, options[:transfer_nested_constants])) + value + end + + # Hides a constant. + # + # @param (see ExampleMethods#hide_const) + # + # @see ExampleMethods#hide_const + # @note It's recommended that you use `hide_const` in your + # examples. This is an alternate public API that is provided + # so you can hide constants in other contexts (e.g. helper + # classes). + def self.hide(constant_name) + mutate(ConstantHider.new(constant_name, nil, {})) + nil + end + + # Contains common functionality used by all of the constant mutators. + # + # @private + class BaseMutator + include Support::RecursiveConstMethods + + attr_reader :original_value, :full_constant_name + + def initialize(full_constant_name, mutated_value, transfer_nested_constants) + @full_constant_name = normalize_const_name(full_constant_name) + @mutated_value = mutated_value + @transfer_nested_constants = transfer_nested_constants + @context_parts = @full_constant_name.split('::') + @const_name = @context_parts.pop + @reset_performed = false + end + + def to_constant + const = Constant.new(full_constant_name) + const.original_value = original_value + + const + end + + def idempotently_reset + reset unless @reset_performed + @reset_performed = true + end + end + + # Hides a defined constant for the duration of an example. + # + # @private + class ConstantHider < BaseMutator + def mutate + return unless (@defined = recursive_const_defined?(full_constant_name)) + @context = recursive_const_get(@context_parts.join('::')) + @original_value = get_const_defined_on(@context, @const_name) + + @context.__send__(:remove_const, @const_name) + end + + def to_constant + return Constant.unmutated(full_constant_name) unless @defined + + const = super + const.hidden = true + const.previously_defined = true + + const + end + + def reset + return unless @defined + @context.const_set(@const_name, @original_value) + end + end + + # Replaces a defined constant for the duration of an example. + # + # @private + class DefinedConstantReplacer < BaseMutator + def initialize(*args) + super + @constants_to_transfer = [] + end + + def mutate + @context = recursive_const_get(@context_parts.join('::')) + @original_value = get_const_defined_on(@context, @const_name) + + @constants_to_transfer = verify_constants_to_transfer! + + @context.__send__(:remove_const, @const_name) + @context.const_set(@const_name, @mutated_value) + + transfer_nested_constants + end + + def to_constant + const = super + const.stubbed = true + const.previously_defined = true + + const + end + + def reset + @constants_to_transfer.each do |const| + @mutated_value.__send__(:remove_const, const) + end + + @context.__send__(:remove_const, @const_name) + @context.const_set(@const_name, @original_value) + end + + def transfer_nested_constants + @constants_to_transfer.each do |const| + @mutated_value.const_set(const, get_const_defined_on(original_value, const)) + end + end + + def verify_constants_to_transfer! + return [] unless should_transfer_nested_constants? + + { @original_value => "the original value", @mutated_value => "the stubbed value" }.each do |value, description| + next if value.respond_to?(:constants) + + raise ArgumentError, + "Cannot transfer nested constants for #{@full_constant_name} " \ + "since #{description} is not a class or module and only classes " \ + "and modules support nested constants." + end + + if Array === @transfer_nested_constants + @transfer_nested_constants = @transfer_nested_constants.map(&:to_s) if RUBY_VERSION == '1.8.7' + undefined_constants = @transfer_nested_constants - constants_defined_on(@original_value) + + if undefined_constants.any? + available_constants = constants_defined_on(@original_value) - @transfer_nested_constants + raise ArgumentError, + "Cannot transfer nested constant(s) #{undefined_constants.join(' and ')} " \ + "for #{@full_constant_name} since they are not defined. Did you mean " \ + "#{available_constants.join(' or ')}?" + end + + @transfer_nested_constants + else + constants_defined_on(@original_value) + end + end + + def should_transfer_nested_constants? + return true if @transfer_nested_constants + return false unless RSpec::Mocks.configuration.transfer_nested_constants? + @original_value.respond_to?(:constants) && @mutated_value.respond_to?(:constants) + end + end + + # Sets an undefined constant for the duration of an example. + # + # @private + class UndefinedConstantSetter < BaseMutator + def mutate + @parent = @context_parts.inject(Object) do |klass, name| + if const_defined_on?(klass, name) + get_const_defined_on(klass, name) + else + ConstantMutator.stub(name_for(klass, name), Module.new) + end + end + + @parent.const_set(@const_name, @mutated_value) + end + + def to_constant + const = super + const.stubbed = true + const.previously_defined = false + + const + end + + def reset + @parent.__send__(:remove_const, @const_name) + end + + private + + def name_for(parent, name) + root = if parent == Object + '' + else + parent.name + end + root + '::' + name + end + end + + # Uses the mutator to mutate (stub or hide) a constant. Ensures that + # the mutator is correctly registered so it can be backed out at the end + # of the test. + # + # @private + def self.mutate(mutator) + ::RSpec::Mocks.space.register_constant_mutator(mutator) + mutator.mutate + end + + # Used internally by the constant stubbing to raise a helpful + # error when a constant like "A::B::C" is stubbed and A::B is + # not a module (and thus, it's impossible to define "A::B::C" + # since only modules can have nested constants). + # + # @api private + def self.raise_on_invalid_const + lambda do |const_name, failed_name| + raise "Cannot stub constant #{failed_name} on #{const_name} " \ + "since #{const_name} is not a module." + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/object_reference.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/object_reference.rb new file mode 100644 index 000000000..fce87d166 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/object_reference.rb @@ -0,0 +1,91 @@ +module RSpec + module Mocks + # @private + class ObjectReference + # Returns an appropriate Object or Module reference based + # on the given argument. + def self.for(object_module_or_name, allow_direct_object_refs=false) + case object_module_or_name + when Module then DirectModuleReference.new(object_module_or_name) + when String then NamedObjectReference.new(object_module_or_name) + else + if allow_direct_object_refs + DirectObjectReference.new(object_module_or_name) + else + raise ArgumentError, + "Module or String expected, got #{object_module_or_name.inspect}" + end + end + end + end + + # Used when an object is passed to `object_double`. + # Represents a reference to that object. + # + # @private + class DirectObjectReference + def initialize(object) + @object = object + end + + def description + @object.inspect + end + + def const_to_replace + raise ArgumentError, + "Can not perform constant replacement with an object." + end + + def defined? + true + end + + def when_loaded + yield @object + end + end + + # Used when a module is passed to `class_double` or `instance_double`. + # Represents a reference to that module. + # + # @private + class DirectModuleReference < DirectObjectReference + def const_to_replace + @object.name + end + alias description const_to_replace + end + + # Used when a string is passed to `class_double`, `instance_double` + # or `object_double`. + # Represents a reference to the object named (via a constant lookup) + # by the string. + # + # @private + class NamedObjectReference + def initialize(const_name) + @const_name = const_name + end + + def defined? + !!object + end + + def const_to_replace + @const_name + end + alias description const_to_replace + + def when_loaded(&_block) + yield object if object + end + + private + + def object + @object ||= Constant.original(@const_name).original_value + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/order_group.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/order_group.rb new file mode 100644 index 000000000..a9947995c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/order_group.rb @@ -0,0 +1,81 @@ +module RSpec + module Mocks + # @private + class OrderGroup + def initialize + @expectations = [] + @invocation_order = [] + @index = 0 + end + + # @private + def register(expectation) + @expectations << expectation + end + + def invoked(message) + @invocation_order << message + end + + # @private + def ready_for?(expectation) + remaining_expectations.find(&:ordered?) == expectation + end + + # @private + def consume + remaining_expectations.each_with_index do |expectation, index| + next unless expectation.ordered? + + @index += index + 1 + return expectation + end + nil + end + + # @private + def handle_order_constraint(expectation) + return unless expectation.ordered? && remaining_expectations.include?(expectation) + return consume if ready_for?(expectation) + expectation.raise_out_of_order_error + end + + def verify_invocation_order(expectation) + expectation.raise_out_of_order_error unless expectations_invoked_in_order? + true + end + + def clear + @index = 0 + @invocation_order.clear + @expectations.clear + end + + def empty? + @expectations.empty? + end + + private + + def remaining_expectations + @expectations[@index..-1] || [] + end + + def expectations_invoked_in_order? + invoked_expectations == expected_invocations + end + + def invoked_expectations + @expectations.select { |e| e.ordered? && @invocation_order.include?(e) } + end + + def expected_invocations + @invocation_order.map { |invocation| expectation_for(invocation) }.compact + end + + def expectation_for(message) + @expectations.find { |e| message == e } + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/proxy.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/proxy.rb new file mode 100644 index 000000000..b936a3a62 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/proxy.rb @@ -0,0 +1,431 @@ +module RSpec + module Mocks + # @private + class Proxy + SpecificMessage = Struct.new(:object, :message, :args) do + def ==(expectation) + expectation.orig_object == object && expectation.matches?(message, *args) + end + end + + # @private + def ensure_implemented(*_args) + # noop for basic proxies, see VerifyingProxy for behaviour. + end + + # @private + def initialize(object, order_group, name=nil, options={}) + @object = object + @order_group = order_group + @name = name + @error_generator = ErrorGenerator.new(object, name) + @messages_received = [] + @options = options + @null_object = false + @method_doubles = Hash.new { |h, k| h[k] = MethodDouble.new(@object, k, self) } + end + + # @private + attr_reader :object + + # @private + def null_object? + @null_object + end + + # @private + # Tells the object to ignore any messages that aren't explicitly set as + # stubs or message expectations. + def as_null_object + @null_object = true + @object + end + + # @private + def original_method_handle_for(_message) + nil + end + + # @private + def add_message_expectation(method_name, opts={}, &block) + location = opts.fetch(:expected_from) { CallerFilter.first_non_rspec_line } + meth_double = method_double_for(method_name) + + if null_object? && !block + meth_double.add_default_stub(@error_generator, @order_group, location, opts) do + @object + end + end + + meth_double.add_expectation @error_generator, @order_group, location, opts, &block + end + + # @private + def add_simple_expectation(method_name, response, location) + method_double_for(method_name).add_simple_expectation method_name, response, @error_generator, location + end + + # @private + def build_expectation(method_name) + meth_double = method_double_for(method_name) + + meth_double.build_expectation( + @error_generator, + @order_group + ) + end + + # @private + def replay_received_message_on(expectation, &block) + expected_method_name = expectation.message + meth_double = method_double_for(expected_method_name) + + if meth_double.expectations.any? + @error_generator.raise_expectation_on_mocked_method(expected_method_name) + end + + unless null_object? || meth_double.stubs.any? + @error_generator.raise_expectation_on_unstubbed_method(expected_method_name) + end + + @messages_received.each do |(actual_method_name, args, _)| + next unless expectation.matches?(actual_method_name, *args) + + expectation.safe_invoke(nil) + block.call(*args) if block + end + end + + # @private + def check_for_unexpected_arguments(expectation) + @messages_received.each do |(method_name, args, _)| + next unless expectation.matches_name_but_not_args(method_name, *args) + + raise_unexpected_message_args_error(expectation, *args) + end + end + + # @private + def add_stub(method_name, opts={}, &implementation) + location = opts.fetch(:expected_from) { CallerFilter.first_non_rspec_line } + method_double_for(method_name).add_stub @error_generator, @order_group, location, opts, &implementation + end + + # @private + def add_simple_stub(method_name, response) + method_double_for(method_name).add_simple_stub method_name, response + end + + # @private + def remove_stub(method_name) + method_double_for(method_name).remove_stub + end + + # @private + def remove_stub_if_present(method_name) + method_double_for(method_name).remove_stub_if_present + end + + # @private + def verify + @method_doubles.each_value { |d| d.verify } + end + + # @private + def reset + @messages_received.clear + end + + # @private + def received_message?(method_name, *args, &block) + @messages_received.any? { |array| array == [method_name, args, block] } + end + + # @private + def has_negative_expectation?(message) + method_double_for(message).expectations.find { |expectation| expectation.negative_expectation_for?(message) } + end + + # @private + def record_message_received(message, *args, &block) + @order_group.invoked SpecificMessage.new(object, message, args) + @messages_received << [message, args, block] + end + + # @private + def message_received(message, *args, &block) + record_message_received message, *args, &block + + expectation = find_matching_expectation(message, *args) + stub = find_matching_method_stub(message, *args) + + if (stub && expectation && expectation.called_max_times?) || (stub && !expectation) + expectation.increase_actual_received_count! if expectation && expectation.actual_received_count_matters? + if (expectation = find_almost_matching_expectation(message, *args)) + expectation.advise(*args) unless expectation.expected_messages_received? + end + stub.invoke(nil, *args, &block) + elsif expectation + expectation.invoke(stub, *args, &block) + elsif (expectation = find_almost_matching_expectation(message, *args)) + expectation.advise(*args) if null_object? unless expectation.expected_messages_received? + + if null_object? || !has_negative_expectation?(message) + raise_unexpected_message_args_error(expectation, *args) + end + elsif (stub = find_almost_matching_stub(message, *args)) + stub.advise(*args) + raise_missing_default_stub_error(stub, *args) + elsif Class === @object + @object.superclass.__send__(message, *args, &block) + else + @object.__send__(:method_missing, message, *args, &block) + end + end + + # @private + def raise_unexpected_message_error(method_name, *args) + @error_generator.raise_unexpected_message_error method_name, *args + end + + # @private + def raise_unexpected_message_args_error(expectation, *args) + @error_generator.raise_unexpected_message_args_error(expectation, *args) + end + + # @private + def raise_missing_default_stub_error(expectation, *args) + @error_generator.raise_missing_default_stub_error(expectation, *args) + end + + # @private + def visibility_for(_method_name) + # This is the default (for test doubles). Subclasses override this. + :public + end + + if Support::RubyFeatures.module_prepends_supported? + def self.prepended_modules_of(klass) + ancestors = klass.ancestors + + # `|| 0` is necessary for Ruby 2.0, where the singleton class + # is only in the ancestor list when there are prepended modules. + singleton_index = ancestors.index(klass) || 0 + + ancestors[0, singleton_index] + end + + def prepended_modules_of_singleton_class + @prepended_modules_of_singleton_class ||= RSpec::Mocks::Proxy.prepended_modules_of(@object.singleton_class) + end + end + + private + + def method_double_for(message) + @method_doubles[message.to_sym] + end + + def find_matching_expectation(method_name, *args) + find_best_matching_expectation_for(method_name) do |expectation| + expectation.matches?(method_name, *args) + end + end + + def find_almost_matching_expectation(method_name, *args) + find_best_matching_expectation_for(method_name) do |expectation| + expectation.matches_name_but_not_args(method_name, *args) + end + end + + def find_best_matching_expectation_for(method_name) + first_match = nil + + method_double_for(method_name).expectations.each do |expectation| + next unless yield expectation + return expectation unless expectation.called_max_times? + first_match ||= expectation + end + + first_match + end + + def find_matching_method_stub(method_name, *args) + method_double_for(method_name).stubs.find { |stub| stub.matches?(method_name, *args) } + end + + def find_almost_matching_stub(method_name, *args) + method_double_for(method_name).stubs.find { |stub| stub.matches_name_but_not_args(method_name, *args) } + end + end + + # @private + class TestDoubleProxy < Proxy + def reset + @method_doubles.clear + object.__disallow_further_usage! + super + end + end + + # @private + class PartialDoubleProxy < Proxy + def original_method_handle_for(message) + if any_instance_class_recorder_observing_method?(@object.class, message) + message = ::RSpec::Mocks.space. + any_instance_recorder_for(@object.class). + build_alias_method_name(message) + end + + ::RSpec::Support.method_handle_for(@object, message) + rescue NameError + nil + end + + # @private + def add_simple_expectation(method_name, response, location) + method_double_for(method_name).configure_method + super + end + + # @private + def add_simple_stub(method_name, response) + method_double_for(method_name).configure_method + super + end + + # @private + def visibility_for(method_name) + # We fall back to :public because by default we allow undefined methods + # to be stubbed, and when we do so, we make them public. + MethodReference.method_visibility_for(@object, method_name) || :public + end + + def reset + @method_doubles.each_value { |d| d.reset } + super + end + + def message_received(message, *args, &block) + RSpec::Mocks.space.any_instance_recorders_from_ancestry_of(object).each do |subscriber| + subscriber.notify_received_message(object, message, args, block) + end + super + end + + private + + def any_instance_class_recorder_observing_method?(klass, method_name) + only_return_existing = true + recorder = ::RSpec::Mocks.space.any_instance_recorder_for(klass, only_return_existing) + return true if recorder && recorder.already_observing?(method_name) + + superklass = klass.superclass + return false if superklass.nil? + any_instance_class_recorder_observing_method?(superklass, method_name) + end + end + + # @private + # When we mock or stub a method on a class, we have to treat it a bit different, + # because normally singleton method definitions only affect the object on which + # they are defined, but on classes they affect subclasses, too. As a result, + # we need some special handling to get the original method. + module PartialClassDoubleProxyMethods + def initialize(source_space, *args) + @source_space = source_space + super(*args) + end + + # Consider this situation: + # + # class A; end + # class B < A; end + # + # allow(A).to receive(:new) + # expect(B).to receive(:new).and_call_original + # + # When getting the original definition for `B.new`, we cannot rely purely on + # using `B.method(:new)` before our redefinition is defined on `B`, because + # `B.method(:new)` will return a method that will execute the stubbed version + # of the method on `A` since singleton methods on classes are in the lookup + # hierarchy. + # + # To do it properly, we need to find the original definition of `new` from `A` + # from _before_ `A` was stubbed, and we need to rebind it to `B` so that it will + # run with the proper `self`. + # + # That's what this method (together with `original_unbound_method_handle_from_ancestor_for`) + # does. + def original_method_handle_for(message) + unbound_method = superclass_proxy && + superclass_proxy.original_unbound_method_handle_from_ancestor_for(message.to_sym) + + return super unless unbound_method + unbound_method.bind(object) + end + + protected + + def original_unbound_method_handle_from_ancestor_for(message) + method_double = @method_doubles.fetch(message) do + # The fact that there is no method double for this message indicates + # that it has not been redefined by rspec-mocks. We need to continue + # looking up the ancestor chain. + return superclass_proxy && + superclass_proxy.original_unbound_method_handle_from_ancestor_for(message) + end + + method_double.original_method.unbind + end + + def superclass_proxy + return @superclass_proxy if defined?(@superclass_proxy) + + if (superclass = object.superclass) + @superclass_proxy = @source_space.proxy_for(superclass) + else + @superclass_proxy = nil + end + end + end + + # @private + class PartialClassDoubleProxy < PartialDoubleProxy + include PartialClassDoubleProxyMethods + end + + # @private + class ProxyForNil < PartialDoubleProxy + def initialize(order_group) + @warn_about_expectations = true + super(nil, order_group) + end + + attr_accessor :warn_about_expectations + alias warn_about_expectations? warn_about_expectations + + def add_message_expectation(method_name, opts={}, &block) + warn(method_name) if warn_about_expectations? + super + end + + def add_negative_message_expectation(location, method_name, &implementation) + warn(method_name) if warn_about_expectations? + super + end + + def add_stub(method_name, opts={}, &implementation) + warn(method_name) if warn_about_expectations? + super + end + + private + + def warn(method_name) + source = CallerFilter.first_non_rspec_line + Kernel.warn("An expectation of :#{method_name} was set on nil. Called from #{source}. Use allow_message_expectations_on_nil to disable warnings.") + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/space.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/space.rb new file mode 100644 index 000000000..2ed35ebc3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/space.rb @@ -0,0 +1,221 @@ +module RSpec + module Mocks + # @private + # Provides a default space implementation for outside + # the scope of an example. Called "root" because it serves + # as the root of the space stack. + class RootSpace + def proxy_for(*_args) + raise_lifecycle_message + end + + def any_instance_recorder_for(*_args) + raise_lifecycle_message + end + + def any_instance_proxy_for(*_args) + raise_lifecycle_message + end + + def register_constant_mutator(_mutator) + raise_lifecycle_message + end + + def any_instance_recorders_from_ancestry_of(_object) + raise_lifecycle_message + end + + def reset_all + end + + def verify_all + end + + def registered?(_object) + false + end + + def new_scope + Space.new + end + + private + + def raise_lifecycle_message + raise OutsideOfExampleError, + "The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported." + end + end + + # @private + class Space + attr_reader :proxies, :any_instance_recorders, :proxy_mutex, :any_instance_mutex + + def initialize + @proxies = {} + @any_instance_recorders = {} + @constant_mutators = [] + @expectation_ordering = OrderGroup.new + @proxy_mutex = new_mutex + @any_instance_mutex = new_mutex + end + + def new_scope + NestedSpace.new(self) + end + + def verify_all + proxies.values.each { |proxy| proxy.verify } + any_instance_recorders.each_value { |recorder| recorder.verify } + end + + def reset_all + proxies.each_value { |proxy| proxy.reset } + @constant_mutators.reverse.each { |mut| mut.idempotently_reset } + any_instance_recorders.each_value { |recorder| recorder.stop_all_observation! } + any_instance_recorders.clear + end + + def register_constant_mutator(mutator) + @constant_mutators << mutator + end + + def constant_mutator_for(name) + @constant_mutators.find { |m| m.full_constant_name == name } + end + + def any_instance_recorder_for(klass, only_return_existing=false) + any_instance_mutex.synchronize do + id = klass.__id__ + any_instance_recorders.fetch(id) do + return nil if only_return_existing + any_instance_recorder_not_found_for(id, klass) + end + end + end + + def any_instance_proxy_for(klass) + AnyInstance::Proxy.new(any_instance_recorder_for(klass), proxies_of(klass)) + end + + def proxies_of(klass) + proxies.values.select { |proxy| klass === proxy.object } + end + + def proxy_for(object) + proxy_mutex.synchronize do + id = id_for(object) + proxies.fetch(id) { proxy_not_found_for(id, object) } + end + end + + alias ensure_registered proxy_for + + def registered?(object) + proxies.key?(id_for object) + end + + def any_instance_recorders_from_ancestry_of(object) + # Optimization: `any_instance` is a feature we generally + # recommend not using, so we can often early exit here + # without doing an O(N) linear search over the number of + # ancestors in the object's class hierarchy. + return [] if any_instance_recorders.empty? + + # We access the ancestors through the singleton class, to avoid calling + # `class` in case `class` has been stubbed. + (class << object; ancestors; end).map do |klass| + any_instance_recorders[klass.__id__] + end.compact + end + + private + + # We don't want to depend on the stdlib ourselves, but if the user is + # using threads then a Mutex will be available to us. If not, we don't + # need to synchronize anyway. + def new_mutex + defined?(::Mutex) ? ::Mutex.new : FakeMutex + end + + # @private + module FakeMutex + def self.synchronize + yield + end + end + + def proxy_not_found_for(id, object) + proxies[id] = case object + when NilClass then ProxyForNil.new(@expectation_ordering) + when TestDouble then object.__build_mock_proxy_unless_expired(@expectation_ordering) + when Class + if RSpec::Mocks.configuration.verify_partial_doubles? + VerifyingPartialClassDoubleProxy.new(self, object, @expectation_ordering) + else + PartialClassDoubleProxy.new(self, object, @expectation_ordering) + end + else + if RSpec::Mocks.configuration.verify_partial_doubles? + VerifyingPartialDoubleProxy.new(object, @expectation_ordering) + else + PartialDoubleProxy.new(object, @expectation_ordering) + end + end + end + + def any_instance_recorder_not_found_for(id, klass) + any_instance_recorders[id] = AnyInstance::Recorder.new(klass) + end + + if defined?(::BasicObject) && !::BasicObject.method_defined?(:__id__) # for 1.9.2 + require 'securerandom' + + def id_for(object) + id = object.__id__ + + return id if object.equal?(::ObjectSpace._id2ref(id)) + # this suggests that object.__id__ is proxying through to some wrapped object + + object.instance_exec do + @__id_for_rspec_mocks_space ||= ::SecureRandom.uuid + end + end + else + def id_for(object) + object.__id__ + end + end + end + + # @private + class NestedSpace < Space + def initialize(parent) + @parent = parent + super() + end + + def proxies_of(klass) + super + @parent.proxies_of(klass) + end + + def constant_mutator_for(name) + super || @parent.constant_mutator_for(name) + end + + def registered?(object) + super || @parent.registered?(object) + end + + private + + def proxy_not_found_for(id, object) + @parent.proxies[id] || super + end + + def any_instance_recorder_not_found_for(id, klass) + @parent.any_instance_recorders[id] || super + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/standalone.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/standalone.rb new file mode 100644 index 000000000..c586712a1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/standalone.rb @@ -0,0 +1,3 @@ +require 'rspec/mocks' +include RSpec::Mocks::ExampleMethods +RSpec::Mocks.setup diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/syntax.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/syntax.rb new file mode 100644 index 000000000..a2a28b70f --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/syntax.rb @@ -0,0 +1,329 @@ +module RSpec + module Mocks + # @api private + # Provides methods for enabling and disabling the available syntaxes + # provided by rspec-mocks. + module Syntax + # @private + def self.warn_about_should! + @warn_about_should = true + end + + # @private + def self.warn_unless_should_configured(method_name , replacement="the new `:expect` syntax or explicitly enable `:should`") + if @warn_about_should + RSpec.deprecate( + "Using `#{method_name}` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax", + :replacement => replacement + ) + + @warn_about_should = false + end + end + + # @api private + # Enables the should syntax (`dbl.stub`, `dbl.should_receive`, etc). + def self.enable_should(syntax_host=default_should_syntax_host) + @warn_about_should = false if syntax_host == default_should_syntax_host + return if should_enabled?(syntax_host) + + syntax_host.class_exec do + def should_receive(message, opts={}, &block) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + ::RSpec::Mocks.expect_message(self, message, opts, &block) + end + + def should_not_receive(message, &block) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + ::RSpec::Mocks.expect_message(self, message, {}, &block).never + end + + def stub(message_or_hash, opts={}, &block) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + if ::Hash === message_or_hash + message_or_hash.each { |message, value| stub(message).and_return value } + else + ::RSpec::Mocks.allow_message(self, message_or_hash, opts, &block) + end + end + + def unstub(message) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__, "`allow(...).to_receive(...).and_call_original` or explicitly enable `:should`") + ::RSpec::Mocks.space.proxy_for(self).remove_stub(message) + end + + def stub_chain(*chain, &blk) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + ::RSpec::Mocks::StubChain.stub_chain_on(self, *chain, &blk) + end + + def as_null_object + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + @_null_object = true + ::RSpec::Mocks.space.proxy_for(self).as_null_object + end + + def null_object? + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + defined?(@_null_object) + end + + def received_message?(message, *args, &block) + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + ::RSpec::Mocks.space.proxy_for(self).received_message?(message, *args, &block) + end + + unless Class.respond_to? :any_instance + Class.class_exec do + def any_instance + ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__) + ::RSpec::Mocks.space.any_instance_proxy_for(self) + end + end + end + end + end + + # @api private + # Disables the should syntax (`dbl.stub`, `dbl.should_receive`, etc). + def self.disable_should(syntax_host=default_should_syntax_host) + return unless should_enabled?(syntax_host) + + syntax_host.class_exec do + undef should_receive + undef should_not_receive + undef stub + undef unstub + undef stub_chain + undef as_null_object + undef null_object? + undef received_message? + end + + Class.class_exec do + undef any_instance + end + end + + # @api private + # Enables the expect syntax (`expect(dbl).to receive`, `allow(dbl).to receive`, etc). + def self.enable_expect(syntax_host=::RSpec::Mocks::ExampleMethods) + return if expect_enabled?(syntax_host) + + syntax_host.class_exec do + def receive(method_name, &block) + Matchers::Receive.new(method_name, block) + end + + def receive_messages(message_return_value_hash) + matcher = Matchers::ReceiveMessages.new(message_return_value_hash) + matcher.warn_about_block if block_given? + matcher + end + + def receive_message_chain(*messages, &block) + Matchers::ReceiveMessageChain.new(messages, &block) + end + + def allow(target) + AllowanceTarget.new(target) + end + + def expect_any_instance_of(klass) + AnyInstanceExpectationTarget.new(klass) + end + + def allow_any_instance_of(klass) + AnyInstanceAllowanceTarget.new(klass) + end + end + + RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do + def expect(target) + ExpectationTarget.new(target) + end + end + end + + # @api private + # Disables the expect syntax (`expect(dbl).to receive`, `allow(dbl).to receive`, etc). + def self.disable_expect(syntax_host=::RSpec::Mocks::ExampleMethods) + return unless expect_enabled?(syntax_host) + + syntax_host.class_exec do + undef receive + undef receive_messages + undef receive_message_chain + undef allow + undef expect_any_instance_of + undef allow_any_instance_of + end + + RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do + undef expect + end + end + + # @api private + # Indicates whether or not the should syntax is enabled. + def self.should_enabled?(syntax_host=default_should_syntax_host) + syntax_host.method_defined?(:should_receive) + end + + # @api private + # Indicates whether or not the expect syntax is enabled. + def self.expect_enabled?(syntax_host=::RSpec::Mocks::ExampleMethods) + syntax_host.method_defined?(:allow) + end + + # @api private + # Determines where the methods like `should_receive`, and `stub` are added. + def self.default_should_syntax_host + # JRuby 1.7.4 introduces a regression whereby `defined?(::BasicObject) => nil` + # yet `BasicObject` still exists and patching onto ::Object breaks things + # e.g. SimpleDelegator expectations won't work + # + # See: https://github.com/jruby/jruby/issues/814 + if defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4' && RUBY_VERSION.to_f > 1.8 + return ::BasicObject + end + + # On 1.8.7, Object.ancestors.last == Kernel but + # things blow up if we include `RSpec::Mocks::Methods` + # into Kernel...not sure why. + return Object unless defined?(::BasicObject) + + # MacRuby has BasicObject but it's not the root class. + return Object unless Object.ancestors.last == ::BasicObject + + ::BasicObject + end + end + end +end + +if defined?(BasicObject) + # The legacy `:should` syntax adds the following methods directly to + # `BasicObject` so that they are available off of any object. Note, however, + # that this syntax does not always play nice with delegate/proxy objects. + # We recommend you use the non-monkeypatching `:expect` syntax instead. + # @see Class + class BasicObject + # @method should_receive + # Sets an expectation that this object should receive a message before + # the end of the example. + # + # @example + # + # logger = double('logger') + # thing_that_logs = ThingThatLogs.new(logger) + # logger.should_receive(:log) + # thing_that_logs.do_something_that_logs_a_message + # + # @note This is only available when you have enabled the `should` syntax. + # @see RSpec::Mocks::ExampleMethods#expect + + # @method should_not_receive + # Sets and expectation that this object should _not_ receive a message + # during this example. + # @see RSpec::Mocks::ExampleMethods#expect + + # @method stub + # Tells the object to respond to the message with the specified value. + # + # @example + # + # counter.stub(:count).and_return(37) + # counter.stub(:count => 37) + # counter.stub(:count) { 37 } + # + # @note This is only available when you have enabled the `should` syntax. + # @see RSpec::Mocks::ExampleMethods#allow + + # @method unstub + # Removes a stub. On a double, the object will no longer respond to + # `message`. On a real object, the original method (if it exists) is + # restored. + # + # This is rarely used, but can be useful when a stub is set up during a + # shared `before` hook for the common case, but you want to replace it + # for a special case. + # + # @note This is only available when you have enabled the `should` syntax. + + # @method stub_chain + # @overload stub_chain(method1, method2) + # @overload stub_chain("method1.method2") + # @overload stub_chain(method1, method_to_value_hash) + # + # Stubs a chain of methods. + # + # ## Warning: + # + # Chains can be arbitrarily long, which makes it quite painless to + # violate the Law of Demeter in violent ways, so you should consider any + # use of `stub_chain` a code smell. Even though not all code smells + # indicate real problems (think fluent interfaces), `stub_chain` still + # results in brittle examples. For example, if you write + # `foo.stub_chain(:bar, :baz => 37)` in a spec and then the + # implementation calls `foo.baz.bar`, the stub will not work. + # + # @example + # + # double.stub_chain("foo.bar") { :baz } + # double.stub_chain(:foo, :bar => :baz) + # double.stub_chain(:foo, :bar) { :baz } + # + # # Given any of ^^ these three forms ^^: + # double.foo.bar # => :baz + # + # # Common use in Rails/ActiveRecord: + # Article.stub_chain("recent.published") { [Article.new] } + # + # @note This is only available when you have enabled the `should` syntax. + # @see RSpec::Mocks::ExampleMethods#receive_message_chain + + # @method as_null_object + # Tells the object to respond to all messages. If specific stub values + # are declared, they'll work as expected. If not, the receiver is + # returned. + # + # @note This is only available when you have enabled the `should` syntax. + + # @method null_object? + # Returns true if this object has received `as_null_object` + # + # @note This is only available when you have enabled the `should` syntax. + end +end + +# The legacy `:should` syntax adds the `any_instance` to `Class`. +# We generally recommend you use the newer `:expect` syntax instead, +# which allows you to stub any instance of a class using +# `allow_any_instance_of(klass)` or mock any instance using +# `expect_any_instance_of(klass)`. +# @see BasicObject +class Class + # @method any_instance + # Used to set stubs and message expectations on any instance of a given + # class. Returns a [Recorder](Recorder), which records messages like + # `stub` and `should_receive` for later playback on instances of the + # class. + # + # @example + # + # Car.any_instance.should_receive(:go) + # race = Race.new + # race.cars << Car.new + # race.go # assuming this delegates to all of its cars + # # this example would pass + # + # Account.any_instance.stub(:balance) { Money.new(:USD, 25) } + # Account.new.balance # => Money.new(:USD, 25)) + # + # @return [Recorder] + # + # @note This is only available when you have enabled the `should` syntax. + # @see RSpec::Mocks::ExampleMethods#expect_any_instance_of + # @see RSpec::Mocks::ExampleMethods#allow_any_instance_of +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/targets.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/targets.rb new file mode 100644 index 000000000..43436ccd3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/targets.rb @@ -0,0 +1,97 @@ +module RSpec + module Mocks + # @private + class TargetBase + def initialize(target) + @target = target + end + + def self.delegate_to(matcher_method) + define_method(:to) do |matcher, &block| + unless matcher_allowed?(matcher) + raise_unsupported_matcher(:to, matcher) + end + define_matcher(matcher, matcher_method, &block) + end + end + + def self.delegate_not_to(matcher_method, options={}) + method_name = options.fetch(:from) + define_method(method_name) do |matcher, &block| + case matcher + when Matchers::Receive + define_matcher(matcher, matcher_method, &block) + when Matchers::ReceiveMessages, Matchers::ReceiveMessageChain + raise_negation_unsupported(method_name, matcher) + else + raise_unsupported_matcher(method_name, matcher) + end + end + end + + def self.disallow_negation(method_name) + define_method(method_name) do |matcher, *_args| + raise_negation_unsupported(method_name, matcher) + end + end + + private + + def matcher_allowed?(matcher) + matcher.class.name.start_with?("RSpec::Mocks::Matchers".freeze) + end + + def define_matcher(matcher, name, &block) + matcher.__send__(name, @target, &block) + end + + def raise_unsupported_matcher(method_name, matcher) + raise UnsupportedMatcherError, + "only the `receive` or `receive_messages` matchers are supported " \ + "with `#{expression}(...).#{method_name}`, but you have provided: #{matcher}" + end + + def raise_negation_unsupported(method_name, matcher) + raise NegationUnsupportedError, + "`#{expression}(...).#{method_name} #{matcher.name}` is not supported since it " \ + "doesn't really make sense. What would it even mean?" + end + + def expression + self.class::EXPRESSION + end + end + + # @private + class AllowanceTarget < TargetBase + EXPRESSION = :allow + delegate_to :setup_allowance + disallow_negation :not_to + disallow_negation :to_not + end + + # @private + class ExpectationTarget < TargetBase + EXPRESSION = :expect + delegate_to :setup_expectation + delegate_not_to :setup_negative_expectation, :from => :not_to + delegate_not_to :setup_negative_expectation, :from => :to_not + end + + # @private + class AnyInstanceAllowanceTarget < TargetBase + EXPRESSION = :allow_any_instance_of + delegate_to :setup_any_instance_allowance + disallow_negation :not_to + disallow_negation :to_not + end + + # @private + class AnyInstanceExpectationTarget < TargetBase + EXPRESSION = :expect_any_instance_of + delegate_to :setup_any_instance_expectation + delegate_not_to :setup_any_instance_negative_expectation, :from => :not_to + delegate_not_to :setup_any_instance_negative_expectation, :from => :to_not + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/test_double.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/test_double.rb new file mode 100644 index 000000000..3b2056ded --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/test_double.rb @@ -0,0 +1,135 @@ +module RSpec + module Mocks + # Implements the methods needed for a pure test double. RSpec::Mocks::Double + # includes this module, and it is provided for cases where you want a + # pure test double without subclassing RSpec::Mocks::Double. + module TestDouble + # Creates a new test double with a `name` (that will be used in error + # messages only) + def initialize(name=nil, stubs={}) + @__expired = false + if Hash === name && stubs.empty? + stubs = name + @name = nil + else + @name = name + end + assign_stubs(stubs) + end + + # Tells the object to respond to all messages. If specific stub values + # are declared, they'll work as expected. If not, the receiver is + # returned. + def as_null_object + __mock_proxy.as_null_object + end + + # Returns true if this object has received `as_null_object` + def null_object? + __mock_proxy.null_object? + end + + # This allows for comparing the mock to other objects that proxy such as + # ActiveRecords belongs_to proxy objects. By making the other object run + # the comparison, we're sure the call gets delegated to the proxy + # target. + def ==(other) + other == __mock_proxy + end + + # @private + def inspect + "#<#{self.class}:#{'0x%x' % object_id} @name=#{@name.inspect}>" + end + + # @private + def to_s + inspect.gsub('<', '[').gsub('>', ']') + end + + # @private + def respond_to?(message, incl_private=false) + __mock_proxy.null_object? ? true : super + end + + # @private + def __build_mock_proxy_unless_expired(order_group) + __raise_expired_error || __build_mock_proxy(order_group) + end + + # @private + def __disallow_further_usage! + @__expired = true + end + + # Override for default freeze implementation to prevent freezing of test + # doubles. + def freeze + RSpec.warn_with("WARNING: you attempted to freeze a test double. This is explicitly a no-op as freezing doubles can lead to undesired behaviour when resetting tests.") + end + + private + + def method_missing(message, *args, &block) + proxy = __mock_proxy + proxy.record_message_received(message, *args, &block) + + if proxy.null_object? + case message + when :to_int then return 0 + when :to_a, :to_ary then return nil + when :to_str then return to_s + else return self + end + end + + # Defined private and protected methods will still trigger `method_missing` + # when called publicly. We want ruby's method visibility error to get raised, + # so we simply delegate to `super` in that case. + # ...well, we would delegate to `super`, but there's a JRuby + # bug, so we raise our own visibility error instead: + # https://github.com/jruby/jruby/issues/1398 + visibility = proxy.visibility_for(message) + if visibility == :private || visibility == :protected + ErrorGenerator.new(self, @name).raise_non_public_error( + message, visibility + ) + end + + # Required wrapping doubles in an Array on Ruby 1.9.2 + raise NoMethodError if [:to_a, :to_ary].include? message + proxy.raise_unexpected_message_error(message, *args) + end + + def assign_stubs(stubs) + stubs.each_pair do |message, response| + __mock_proxy.add_simple_stub(message, response) + end + end + + def __mock_proxy + ::RSpec::Mocks.space.proxy_for(self) + end + + def __build_mock_proxy(order_group) + TestDoubleProxy.new(self, order_group, @name) + end + + def __raise_expired_error + return false unless @__expired + ErrorGenerator.new(self, @name).raise_expired_test_double_error + end + + def initialize_copy(other) + as_null_object if other.null_object? + super + end + end + + # A generic test double object. `double`, `instance_double` and friends + # return an instance of this. + class Double + include TestDouble + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_double.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_double.rb new file mode 100644 index 000000000..f975046b1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_double.rb @@ -0,0 +1,127 @@ +RSpec::Support.require_rspec_mocks 'verifying_proxy' +require 'stringio' + +module RSpec + module Mocks + # @private + module VerifyingDouble + def respond_to?(message, include_private=false) + return super unless null_object? + + method_ref = __mock_proxy.method_reference[message] + + case method_ref.visibility + when :public then true + when :private then include_private + when :protected then include_private || RUBY_VERSION.to_f < 2.0 + else !method_ref.unimplemented? + end + end + + def method_missing(message, *args, &block) + # Null object conditional is an optimization. If not a null object, + # validity of method expectations will have been checked at definition + # time. + if null_object? + if @__sending_message == message + __mock_proxy.ensure_implemented(message) + else + __mock_proxy.ensure_publicly_implemented(message, self) + end + end + + super + end + + # Redefining `__send__` causes ruby to issue a warning. + old, $stderr = $stderr, StringIO.new + def __send__(name, *args, &block) + @__sending_message = name + super + ensure + @__sending_message = nil + end + $stderr = old + + def send(name, *args, &block) + __send__(name, *args, &block) + end + + def initialize(*args) + super + @__sending_message = nil + end + end + + # A mock providing a custom proxy that can verify the validity of any + # method stubs or expectations against the public instance methods of the + # given class. + # + # @private + class InstanceVerifyingDouble + include TestDouble + include VerifyingDouble + + def initialize(doubled_module, *args) + @doubled_module = doubled_module + + super( + "#{doubled_module.description} (instance)", + *args + ) + end + + def __build_mock_proxy(order_group) + VerifyingProxy.new(self, order_group, @name, + @doubled_module, + InstanceMethodReference + ) + end + end + + # An awkward module necessary because we cannot otherwise have + # ClassVerifyingDouble inherit from Module and still share these methods. + # + # @private + module ObjectVerifyingDoubleMethods + include TestDouble + include VerifyingDouble + + def as_stubbed_const(options={}) + ConstantMutator.stub(@doubled_module.const_to_replace, self, options) + self + end + + private + + def initialize(doubled_module, *args) + @doubled_module = doubled_module + super(doubled_module.description, *args) + end + + def __build_mock_proxy(order_group) + VerifyingProxy.new(self, order_group, @name, + @doubled_module, + ObjectMethodReference + ) + end + end + + # Similar to an InstanceVerifyingDouble, except that it verifies against + # public methods of the given object. + # + # @private + class ObjectVerifyingDouble + include ObjectVerifyingDoubleMethods + end + + # Effectively the same as an ObjectVerifyingDouble (since a class is a type + # of object), except with Module in the inheritance chain so that + # transferring nested constants to work. + # + # @private + class ClassVerifyingDouble < Module + include ObjectVerifyingDoubleMethods + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_message_expecation.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_message_expecation.rb new file mode 100644 index 000000000..6acdf8090 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_message_expecation.rb @@ -0,0 +1,62 @@ +RSpec::Support.require_rspec_support 'method_signature_verifier' + +module RSpec + module Mocks + # A message expectation that knows about the real implementation of the + # message being expected, so that it can verify that any expectations + # have the valid arguments. + # @api private + class VerifyingMessageExpectation < MessageExpectation + # A level of indirection is used here rather than just passing in the + # method itself, since method look up is expensive and we only want to + # do it if actually needed. + # + # Conceptually the method reference makes more sense as a constructor + # argument since it should be immutable, but it is significantly more + # straight forward to build the object in pieces so for now it stays as + # an accessor. + attr_accessor :method_reference + + def initialize(*args) + super + end + + # @private + def with(*args, &block) + unless ArgumentMatchers::AnyArgsMatcher === args.first + expected_args = if ArgumentMatchers::NoArgsMatcher === args.first + [] + elsif args.length > 0 + args + else + # No arguments given, this will raise. + super + end + + validate_expected_arguments!(expected_args) + end + super + end + + private + + def validate_expected_arguments!(actual_args) + return if method_reference.nil? + + method_reference.with_signature do |signature| + verifier = Support::LooseSignatureVerifier.new( + signature, + actual_args + ) + + unless verifier.valid? + # Fail fast is required, otherwise the message expecation will fail + # as well ("expected method not called") and clobber this one. + @failed_fast = true + @error_generator.raise_invalid_arguments_error(verifier) + end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_proxy.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_proxy.rb new file mode 100644 index 000000000..9dd9fd207 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/verifying_proxy.rb @@ -0,0 +1,171 @@ +RSpec::Support.require_rspec_mocks 'verifying_message_expecation' +RSpec::Support.require_rspec_mocks 'method_reference' + +module RSpec + module Mocks + # @private + module VerifyingProxyMethods + def add_stub(method_name, opts={}, &implementation) + ensure_implemented(method_name) + super + end + + def add_simple_stub(method_name, *args) + ensure_implemented(method_name) + super + end + + def add_message_expectation(method_name, opts={}, &block) + ensure_implemented(method_name) + super + end + + def ensure_implemented(method_name) + return unless method_reference[method_name].unimplemented? + + @error_generator.raise_unimplemented_error( + @doubled_module, + method_name + ) + end + + def ensure_publicly_implemented(method_name, _object) + ensure_implemented(method_name) + visibility = method_reference[method_name].visibility + + return if visibility == :public + @error_generator.raise_non_public_error(method_name, visibility) + end + end + + # A verifying proxy mostly acts like a normal proxy, except that it + # contains extra logic to try and determine the validity of any expectation + # set on it. This includes whether or not methods have been defined and the + # validatiy of arguments on method calls. + # + # In all other ways this behaves like a normal proxy. It only adds the + # verification behaviour to specific methods then delegates to the parent + # implementation. + # + # These checks are only activated if the doubled class has already been + # loaded, otherwise they are disabled. This allows for testing in + # isolation. + # + # @private + class VerifyingProxy < TestDoubleProxy + include VerifyingProxyMethods + + def initialize(object, order_group, name, doubled_module, method_reference_class) + super(object, order_group, name) + @object = object + @doubled_module = doubled_module + @method_reference_class = method_reference_class + + # A custom method double is required to pass through a way to lookup + # methods to determine their parameters. This is only relevant if the doubled + # class is loaded. + @method_doubles = Hash.new do |h, k| + h[k] = VerifyingMethodDouble.new(@object, k, self, method_reference[k]) + end + end + + def method_reference + @method_reference ||= Hash.new do |h, k| + h[k] = @method_reference_class.new(@doubled_module, k) + end + end + + def visibility_for(method_name) + method_reference[method_name].visibility + end + end + + # @private + class VerifyingPartialDoubleProxy < PartialDoubleProxy + include VerifyingProxyMethods + + def initialize(object, expectation_ordering) + super(object, expectation_ordering) + @doubled_module = DirectObjectReference.new(object) + + # A custom method double is required to pass through a way to lookup + # methods to determine their parameters. + @method_doubles = Hash.new do |h, k| + h[k] = VerifyingExistingMethodDouble.new(object, k, self) + end + end + + def method_reference + @method_doubles + end + end + + # @private + class VerifyingPartialClassDoubleProxy < VerifyingPartialDoubleProxy + include PartialClassDoubleProxyMethods + end + + # @private + class VerifyingMethodDouble < MethodDouble + def initialize(object, method_name, proxy, method_reference) + super(object, method_name, proxy) + @method_reference = method_reference + end + + def message_expectation_class + VerifyingMessageExpectation + end + + def add_expectation(*args, &block) + # explict params necessary for 1.8.7 see #626 + super(*args, &block).tap { |x| x.method_reference = @method_reference } + end + + def add_stub(*args, &block) + # explict params necessary for 1.8.7 see #626 + super(*args, &block).tap { |x| x.method_reference = @method_reference } + end + + def proxy_method_invoked(obj, *args, &block) + validate_arguments!(args) + super + end + + private + + def validate_arguments!(actual_args) + @method_reference.with_signature do |signature| + verifier = Support::StrictSignatureVerifier.new(signature, actual_args) + raise ArgumentError, verifier.error_message unless verifier.valid? + end + end + end + + # A VerifyingMethodDouble fetches the method to verify against from the + # original object, using a MethodReference. This works for pure doubles, + # but when the original object is itself the one being modified we need to + # collapse the reference and the method double into a single object so that + # we can access the original pristine method definition. + # + # @private + class VerifyingExistingMethodDouble < VerifyingMethodDouble + def initialize(object, method_name, proxy) + super(object, method_name, proxy, self) + + @valid_method = object.respond_to?(method_name, true) + + # Trigger an eager find of the original method since if we find it any + # later we end up getting a stubbed method with incorrect arity. + save_original_method! + end + + def with_signature + yield Support::MethodSignature.new(original_method) + end + + def unimplemented? + !@valid_method + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/version.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/version.rb new file mode 100644 index 000000000..61fe95aa7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.1.3/lib/rspec/mocks/version.rb @@ -0,0 +1,9 @@ +module RSpec + module Mocks + # Version information for RSpec mocks. + module Version + # Version of RSpec mocks currently in use in SemVer format. + STRING = '3.1.3' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/Changelog.md b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/Changelog.md new file mode 100644 index 000000000..1ae8b88fc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/Changelog.md @@ -0,0 +1,77 @@ +### 3.1.2 / 2014-10-08 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.1...v3.1.2) + +Bug Fixes: + +* Fix method signature to not blow up with a `NoMethodError` on 1.8.7 when + verifying against an RSpec matcher. (Myron Marston, #116) + +### 3.1.1 / 2014-09-26 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.0...v3.1.1) + +Bug Fixes: + +* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and + `rails generate rspec:install`) so that it detects absolute paths + on Windows properly. (Scott Archer, #107, #108, #109) (Jon Rowe, #110) + +### 3.1.0 / 2014-09-04 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.4...v3.1.0) + +Bug Fixes: + +* Fix `FuzzyMatcher` so that it does not wrongly match a struct against + an array. (Myron Marston, #97) +* Prevent infinitely recursing `#flatten` methods from causing the differ + to hang. (Jon Rowe, #101) + +### 3.0.4 / 2014-08-14 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.3...v3.0.4) + +Bug Fixes: + +* Fix `FuzzyMatcher` so that it does not silence `ArgumentError` raised + from broken implementations of `==`. (Myron Marston, #94) + +### 3.0.3 / 2014-07-21 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.2...v3.0.3) + +Bug Fixes: + +* Fix regression in `Support#method_handle_for` where proxy objects + with method delegated would wrongly not return a method handle. + (Jon Rowe, #90) +* Properly detect Module#prepend support in Ruby 2.1+ (Ben Langfeld, #91) +* Fix `rspec/support/warnings.rb` so it can be loaded and used in + isolation. (Myron Marston, #93) + +### 3.0.2 / 2014-06-20 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.1...v3.0.2) + +* Revert `BlockSignature` change from 3.0.1 because of a ruby bug that + caused it to change the block's behavior (https://bugs.ruby-lang.org/issues/9967). + (Myron Marston, rspec-mocks#721) + +### 3.0.1 / 2014-06-19 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0...v3.0.1) + +* Fix `BlockSignature` so that it correctly differentiates between + required and optional block args. (Myron Marston, rspec-mocks#714) + +### 3.0.0 / 2014-06-01 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.rc1...v3.0.0) + +### 3.0.0.rc1 / 2014-05-18 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.beta2...v3.0.0.rc1) + +### 3.0.0.beta2 / 2014-02-17 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.beta1...v3.0.0.beta2) + +Bug Fixes: + +* Issue message when :replacement is passed to `RSpec.warn_with`. (Jon Rowe) + +### 3.0.0.beta1 / 2013-11-07 +[Full Changelog](https://github.com/rspec/rspec-support/compare/0dc12d1bdbbacc757a9989f8c09cd08ef3a4837e...v3.0.0.beta1) + +Initial release. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/LICENSE.txt b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/LICENSE.txt new file mode 100644 index 000000000..ecb71dfd4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2013 David Chelimsky, Myron Marston, Jon Rowe, Sam Phippen, Xavier Shay, Bradley Schaefer + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/README.md b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/README.md new file mode 100644 index 000000000..e1e294a2b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/README.md @@ -0,0 +1,17 @@ +# RSpec::Support + +`RSpec::Support` provides common functionality to `RSpec::Core`, +`RSpec::Expectations` and `RSpec::Mocks`. It is considered +suitable for internal use only at this time. + +## Installation / Usage + +Install one or more of the `RSpec` gems. + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support.rb new file mode 100644 index 000000000..d45ff8465 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support.rb @@ -0,0 +1,76 @@ +module RSpec + module Support + # @api private + # + # Defines a helper method that is optimized to require files from the + # named lib. The passed block MUST be `{ |f| require_relative f }` + # because for `require_relative` to work properly from within the named + # lib the line of code must be IN that lib. + # + # `require_relative` is preferred when available because it is always O(1), + # regardless of the number of dirs in $LOAD_PATH. `require`, on the other + # hand, does a linear O(N) search over the dirs in the $LOAD_PATH until + # it can resolve the file relative to one of the dirs. + def self.define_optimized_require_for_rspec(lib, &require_relative) + name = "require_rspec_#{lib}" + + if Kernel.respond_to?(:require_relative) + (class << self; self; end).__send__(:define_method, name) do |f| + require_relative.call("#{lib}/#{f}") + end + else + (class << self; self; end).__send__(:define_method, name) do |f| + require "rspec/#{lib}/#{f}" + end + end + end + + define_optimized_require_for_rspec(:support) { |f| require_relative(f) } + require_rspec_support "version" + require_rspec_support "ruby_features" + + # @api private + KERNEL_METHOD_METHOD = ::Kernel.instance_method(:method) + + # @api private + # + # Used internally to get a method handle for a particular object + # and method name. + # + # Includes handling for a few special cases: + # + # - Objects that redefine #method (e.g. an HTTPRequest struct) + # - BasicObject subclasses that mixin a Kernel dup (e.g. SimpleDelegator) + # - Objects that undefine method and delegate everything to another + # object (e.g. Mongoid association objects) + if RubyFeatures.supports_rebinding_module_methods? + def self.method_handle_for(object, method_name) + KERNEL_METHOD_METHOD.bind(object).call(method_name) + rescue NameError => original + begin + handle = object.method(method_name) + raise original unless handle.is_a? Method + handle + rescue Exception + raise original + end + end + else + def self.method_handle_for(object, method_name) + if ::Kernel === object + KERNEL_METHOD_METHOD.bind(object).call(method_name) + else + object.method(method_name) + end + rescue NameError => original + begin + handle = object.method(method_name) + raise original unless handle.is_a? Method + handle + rescue Exception + raise original + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/caller_filter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/caller_filter.rb new file mode 100644 index 000000000..fc091fbef --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/caller_filter.rb @@ -0,0 +1,63 @@ +module RSpec + # Consistent implementation for "cleaning" the caller method to strip out + # non-rspec lines. This enables errors to be reported at the call site in + # the code using the library, which is far more useful than the particular + # internal method that raised an error. + class CallerFilter + RSPEC_LIBS = %w[ + core + mocks + expectations + support + matchers + rails + ] + + ADDITIONAL_TOP_LEVEL_FILES = %w[ autorun ] + + LIB_REGEX = %r{/lib/rspec/(#{(RSPEC_LIBS + ADDITIONAL_TOP_LEVEL_FILES).join('|')})(\.rb|/)} + + # rubygems/core_ext/kernel_require.rb isn't actually part of rspec (obviously) but we want + # it ignored when we are looking for the first meaningful line of the backtrace outside + # of RSpec. It can show up in the backtrace as the immediate first caller + # when `CallerFilter.first_non_rspec_line` is called from the top level of a required + # file, but it depends on if rubygems is loaded or not. We don't want to have to deal + # with this complexity in our `RSpec.deprecate` calls, so we ignore it here. + IGNORE_REGEX = Regexp.union(LIB_REGEX, "rubygems/core_ext/kernel_require.rb") + + if RUBY_VERSION >= '2.0.0' + def self.first_non_rspec_line + # `caller` is an expensive method that scales linearly with the size of + # the stack. The performance hit for fetching it in chunks is small, + # and since the target line is probably near the top of the stack, the + # overall improvement of a chunked search like this is significant. + # + # See benchmarks/caller.rb for measurements. + + # Initial value here is mostly arbitrary, but is chosen to give good + # performance on the common case of creating a double. + increment = 5 + i = 1 + line = nil + + until line + stack = caller(i, increment) + raise "No non-lib lines in stack" unless stack + + line = stack.find { |l| l !~ IGNORE_REGEX } + + i += increment + increment *= 2 # The choice of two here is arbitrary. + end + + line + end + else + # Earlier rubies do not support the two argument form of `caller`. This + # fallback is logically the same, but slower. + def self.first_non_rspec_line + caller.find { |line| line !~ IGNORE_REGEX } + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/differ.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/differ.rb new file mode 100644 index 000000000..d59890a15 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/differ.rb @@ -0,0 +1,214 @@ +RSpec::Support.require_rspec_support 'encoded_string' +RSpec::Support.require_rspec_support 'hunk_generator' + +require 'pp' + +module RSpec + module Support + # rubocop:disable ClassLength + class Differ + def diff(actual, expected) + diff = "" + + if actual && expected + if all_strings?(actual, expected) + if any_multiline_strings?(actual, expected) + diff = diff_as_string(coerce_to_string(actual), coerce_to_string(expected)) + end + elsif no_procs?(actual, expected) && no_numbers?(actual, expected) + diff = diff_as_object(actual, expected) + end + end + + diff.to_s + end + + # rubocop:disable MethodLength + def diff_as_string(actual, expected) + @encoding = pick_encoding actual, expected + + @actual = EncodedString.new(actual, @encoding) + @expected = EncodedString.new(expected, @encoding) + + output = EncodedString.new("\n", @encoding) + + hunks.each_cons(2) do |prev_hunk, current_hunk| + begin + if current_hunk.overlaps?(prev_hunk) + add_old_hunk_to_hunk(current_hunk, prev_hunk) + else + add_to_output(output, prev_hunk.diff(format_type).to_s) + end + ensure + add_to_output(output, "\n") + end + end + + finalize_output(output, hunks.last.diff(format_type).to_s) if hunks.last + + color_diff output + rescue Encoding::CompatibilityError + handle_encoding_errors + end + # rubocop:enable MethodLength + + def diff_as_object(actual, expected) + actual_as_string = object_to_string(actual) + expected_as_string = object_to_string(expected) + diff_as_string(actual_as_string, expected_as_string) + end + + attr_reader :color + alias_method :color?, :color + + def initialize(opts={}) + @color = opts.fetch(:color, false) + @object_preparer = opts.fetch(:object_preparer, lambda { |string| string }) + end + + private + + def no_procs?(*args) + safely_flatten(args).none? { |a| Proc === a } + end + + def all_strings?(*args) + safely_flatten(args).all? { |a| String === a } + end + + def any_multiline_strings?(*args) + all_strings?(*args) && safely_flatten(args).any? { |a| multiline?(a) } + end + + def no_numbers?(*args) + safely_flatten(args).none? { |a| Numeric === a } + end + + def coerce_to_string(string_or_array) + return string_or_array unless Array === string_or_array + diffably_stringify(string_or_array).join("\n") + end + + def diffably_stringify(array) + array.map do |entry| + if Array === entry + entry.inspect + else + entry.to_s.gsub("\n", "\\n") + end + end + end + + if String.method_defined?(:encoding) + def multiline?(string) + string.include?("\n".encode(string.encoding)) + end + else + def multiline?(string) + string.include?("\n") + end + end + + def hunks + @hunks ||= HunkGenerator.new(@actual, @expected).hunks + end + + def finalize_output(output, final_line) + add_to_output(output, final_line) + add_to_output(output, "\n") + end + + def add_to_output(output, string) + output << string + end + + def add_old_hunk_to_hunk(hunk, oldhunk) + hunk.merge(oldhunk) + end + + def safely_flatten(array) + array = array.flatten(1) until (array == array.flatten(1)) + array + end + + def format_type + :unified + end + + def color(text, color_code) + "\e[#{color_code}m#{text}\e[0m" + end + + def red(text) + color(text, 31) + end + + def green(text) + color(text, 32) + end + + def blue(text) + color(text, 34) + end + + def normal(text) + color(text, 0) + end + + def color_diff(diff) + return diff unless color? + + diff.lines.map do |line| + case line[0].chr + when "+" + green line + when "-" + red line + when "@" + line[1].chr == "@" ? blue(line) : normal(line) + else + normal(line) + end + end.join + end + + def object_to_string(object) + object = @object_preparer.call(object) + case object + when Hash + object.keys.sort_by { |k| k.to_s }.map do |key| + pp_key = PP.singleline_pp(key, "") + pp_value = PP.singleline_pp(object[key], "") + + "#{pp_key} => #{pp_value}," + end.join("\n") + when String + object =~ /\n/ ? object : object.inspect + else + PP.pp(object, "") + end + end + + if String.method_defined?(:encoding) + def pick_encoding(source_a, source_b) + Encoding.compatible?(source_a, source_b) || Encoding.default_external + end + else + def pick_encoding(_source_a, _source_b) + end + end + + def handle_encoding_errors + if @actual.source_encoding != @expected.source_encoding + "Could not produce a diff because the encoding of the actual string " \ + "(#{@actual.source_encoding}) differs from the encoding of the expected " \ + "string (#{@expected.source_encoding})" + else + "Could not produce a diff because of the encoding of the string " \ + "(#{@expected.source_encoding})" + end + end + end + # rubocop:enable ClassLength + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/directory_maker.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/directory_maker.rb new file mode 100644 index 000000000..c4d5ad254 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/directory_maker.rb @@ -0,0 +1,61 @@ +RSpec::Support.require_rspec_support 'os' + +module RSpec + module Support + # @api private + # + # Replacement for fileutils#mkdir_p because we don't want to require parts + # of stdlib in RSpec. + class DirectoryMaker + # @api private + # + # Implements nested directory construction + def self.mkdir_p(path) + stack = generate_stack(path) + path.split(File::SEPARATOR).each do |part| + stack = generate_path(stack, part) + begin + Dir.mkdir(stack) unless directory_exists?(stack) + rescue Errno::ENOTDIR => e + raise Errno::EEXIST, e.message + end + end + end + + if OS.windows_file_path? + def self.generate_stack(path) + if path.start_with?(File::SEPARATOR) + File::SEPARATOR + elsif path[1] == ':' + '' + else + '.' + end + end + def self.generate_path(stack, part) + if stack == '' + part + elsif stack == File::SEPARATOR + File.join('', part) + else + File.join(stack, part) + end + end + else + def self.generate_stack(path) + path.start_with?(File::SEPARATOR) ? File::SEPARATOR : "." + end + def self.generate_path(stack, part) + File.join(stack, part) + end + end + + def self.directory_exists?(dirname) + File.exist?(dirname) && File.directory?(dirname) + end + private_class_method :directory_exists? + private_class_method :generate_stack + private_class_method :generate_path + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/encoded_string.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/encoded_string.rb new file mode 100644 index 000000000..4fa90fdd4 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/encoded_string.rb @@ -0,0 +1,69 @@ +module RSpec + module Support + # @private + class EncodedString + MRI_UNICODE_UNKOWN_CHARACTER = "\xEF\xBF\xBD" + + def initialize(string, encoding=nil) + @encoding = encoding + @source_encoding = detect_source_encoding(string) + @string = matching_encoding(string) + end + attr_reader :source_encoding + + delegated_methods = String.instance_methods.map(&:to_s) & %w[eql? lines == encoding empty?] + delegated_methods.each do |name| + define_method(name) { |*args, &block| @string.__send__(name, *args, &block) } + end + + def <<(string) + @string << matching_encoding(string) + end + + def split(regex_or_string) + @string.split(matching_encoding(regex_or_string)) + end + + def to_s + @string + end + alias :to_str :to_s + + if String.method_defined?(:encoding) + + private + + def matching_encoding(string) + string.encode(@encoding) + rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError + normalize_missing(string.encode(@encoding, :invalid => :replace, :undef => :replace)) + rescue Encoding::ConverterNotFoundError + normalize_missing(string.force_encoding(@encoding).encode(:invalid => :replace)) + end + + def normalize_missing(string) + if @encoding.to_s == "UTF-8" + string.gsub(MRI_UNICODE_UNKOWN_CHARACTER.force_encoding(@encoding), "?") + else + string + end + end + + def detect_source_encoding(string) + string.encoding + end + else + + private + + def matching_encoding(string) + string + end + + def detect_source_encoding(_string) + 'US-ASCII' + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/fuzzy_matcher.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/fuzzy_matcher.rb new file mode 100644 index 000000000..aa6e3f8a7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/fuzzy_matcher.rb @@ -0,0 +1,48 @@ +module RSpec + module Support + # Provides a means to fuzzy-match between two arbitrary objects. + # Understands array/hash nesting. Uses `===` or `==` to + # perform the matching. + module FuzzyMatcher + # @api private + def self.values_match?(expected, actual) + if Array === expected && Enumerable === actual && !(Struct === actual) + return arrays_match?(expected, actual.to_a) + elsif Hash === expected && Hash === actual + return hashes_match?(expected, actual) + elsif actual == expected + return true + end + + begin + expected === actual + rescue ArgumentError + # Some objects, like 0-arg lambdas on 1.9+, raise + # ArgumentError for `expected === actual`. + false + end + end + + # @private + def self.arrays_match?(expected_list, actual_list) + return false if expected_list.size != actual_list.size + + expected_list.zip(actual_list).all? do |expected, actual| + values_match?(expected, actual) + end + end + + # @private + def self.hashes_match?(expected_hash, actual_hash) + return false if expected_hash.size != actual_hash.size + + expected_hash.all? do |expected_key, expected_value| + actual_value = actual_hash.fetch(expected_key) { return false } + values_match?(expected_value, actual_value) + end + end + + private_class_method :arrays_match?, :hashes_match? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/hunk_generator.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/hunk_generator.rb new file mode 100644 index 000000000..382579e83 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/hunk_generator.rb @@ -0,0 +1,47 @@ +require 'diff/lcs' +require 'diff/lcs/hunk' + +module RSpec + module Support + # @private + class HunkGenerator + def initialize(actual, expected) + @actual = actual + @expected = expected + end + + def hunks + @file_length_difference = 0 + @hunks ||= diffs.map do |piece| + build_hunk(piece) + end + end + + private + + def diffs + Diff::LCS.diff(expected_lines, actual_lines) + end + + def expected_lines + @expected.split("\n").map! { |e| e.chomp } + end + + def actual_lines + @actual.split("\n").map! { |e| e.chomp } + end + + def build_hunk(piece) + Diff::LCS::Hunk.new( + expected_lines, actual_lines, piece, context_lines, @file_length_difference + ).tap do |h| + @file_length_difference = h.file_length_difference + end + end + + def context_lines + 3 + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/matcher_definition.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/matcher_definition.rb new file mode 100644 index 000000000..2637aabc3 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/matcher_definition.rb @@ -0,0 +1,31 @@ +module RSpec + module Support + # @private + def self.matcher_definitions + @matcher_definitions ||= [] + end + + # Used internally to break cyclic dependency between mocks, expectations, + # and support. We don't currently have a consistent implementation of our + # matchers, though we are considering changing that: + # https://github.com/rspec/rspec-mocks/issues/513 + # + # @private + def self.register_matcher_definition(&block) + matcher_definitions << block + end + + # Remove a previously registered matcher. Useful for cleaning up after + # yourself in specs. + # + # @private + def self.deregister_matcher_definition(&block) + matcher_definitions.delete(block) + end + + # @private + def self.is_a_matcher?(object) + matcher_definitions.any? { |md| md.call(object) } + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/method_signature_verifier.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/method_signature_verifier.rb new file mode 100644 index 000000000..38d635af2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/method_signature_verifier.rb @@ -0,0 +1,272 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support "ruby_features" +RSpec::Support.require_rspec_support "matcher_definition" + +module RSpec + module Support + # Extracts info about the number of arguments and allowed/required + # keyword args of a given method. + # + # @private + class MethodSignature + attr_reader :min_non_kw_args, :max_non_kw_args + + def initialize(method) + @method = method + classify_parameters + end + + def non_kw_args_arity_description + case max_non_kw_args + when min_non_kw_args then min_non_kw_args.to_s + when INFINITY then "#{min_non_kw_args} or more" + else "#{min_non_kw_args} to #{max_non_kw_args}" + end + end + + def valid_non_kw_args?(positional_arg_count) + min_non_kw_args <= positional_arg_count && + positional_arg_count <= max_non_kw_args + end + + if RubyFeatures.optional_and_splat_args_supported? + def description + @description ||= begin + parts = [] + + unless non_kw_args_arity_description == "0" + parts << "arity of #{non_kw_args_arity_description}" + end + + if @optional_kw_args.any? + parts << "optional keyword args (#{@optional_kw_args.map(&:inspect).join(", ")})" + end + + if @required_kw_args.any? + parts << "required keyword args (#{@required_kw_args.map(&:inspect).join(", ")})" + end + + parts << "any additional keyword args" if @allows_any_kw_args + + parts.join(" and ") + end + end + + def missing_kw_args_from(given_kw_args) + @required_kw_args - given_kw_args + end + + def invalid_kw_args_from(given_kw_args) + return [] if @allows_any_kw_args + given_kw_args - @allowed_kw_args + end + + def has_kw_args_in?(args) + Hash === args.last && could_contain_kw_args?(args) + end + + # Without considering what the last arg is, could it + # contain keyword arguments? + def could_contain_kw_args?(args) + return false if args.count <= min_non_kw_args + @allows_any_kw_args || @allowed_kw_args.any? + end + + def classify_parameters + optional_non_kw_args = @min_non_kw_args = 0 + @optional_kw_args, @required_kw_args = [], [] + @allows_any_kw_args = false + + @method.parameters.each do |(type, name)| + case type + # def foo(a:) + when :keyreq then @required_kw_args << name + # def foo(a: 1) + when :key then @optional_kw_args << name + # def foo(**kw_args) + when :keyrest then @allows_any_kw_args = true + # def foo(a) + when :req then @min_non_kw_args += 1 + # def foo(a = 1) + when :opt then optional_non_kw_args += 1 + # def foo(*a) + when :rest then optional_non_kw_args = INFINITY + end + end + + @max_non_kw_args = @min_non_kw_args + optional_non_kw_args + @allowed_kw_args = @required_kw_args + @optional_kw_args + end + else + def description + "arity of #{non_kw_args_arity_description}" + end + + def missing_kw_args_from(_given_kw_args) + [] + end + + def invalid_kw_args_from(_given_kw_args) + [] + end + + def has_kw_args_in?(_args) + false + end + + def could_contain_kw_args?(*) + false + end + + def classify_parameters + arity = @method.arity + if arity < 0 + # `~` inverts the one's complement and gives us the + # number of required args + @min_non_kw_args = ~arity + @max_non_kw_args = INFINITY + else + @min_non_kw_args = arity + @max_non_kw_args = arity + end + end + end + + INFINITY = 1 / 0.0 + end + + # Deals with the slightly different semantics of block arguments. + # For methods, arguments are required unless a default value is provided. + # For blocks, arguments are optional, even if no default value is provided. + # + # However, we want to treat block args as required since you virtually + # always want to pass a value for each received argument and our + # `and_yield` has treated block args as required for many years. + # + # @api private + class BlockSignature < MethodSignature + if RubyFeatures.optional_and_splat_args_supported? + def classify_parameters + super + @min_non_kw_args = @max_non_kw_args unless @max_non_kw_args == INFINITY + end + end + end + + # Abstract base class for signature verifiers. + # + # @api private + class MethodSignatureVerifier + attr_reader :non_kw_args, :kw_args + + def initialize(signature, args) + @signature = signature + @non_kw_args, @kw_args = split_args(*args) + end + + def valid? + missing_kw_args.empty? && + invalid_kw_args.empty? && + valid_non_kw_args? + end + + def error_message + if missing_kw_args.any? + "Missing required keyword arguments: %s" % [ + missing_kw_args.join(", ") + ] + elsif invalid_kw_args.any? + "Invalid keyword arguments provided: %s" % [ + invalid_kw_args.join(", ") + ] + elsif !valid_non_kw_args? + "Wrong number of arguments. Expected %s, got %s." % [ + @signature.non_kw_args_arity_description, + non_kw_args.length + ] + end + end + + private + + def valid_non_kw_args? + @signature.valid_non_kw_args?(non_kw_args.length) + end + + def missing_kw_args + @signature.missing_kw_args_from(kw_args) + end + + def invalid_kw_args + @signature.invalid_kw_args_from(kw_args) + end + + def split_args(*args) + kw_args = if @signature.has_kw_args_in?(args) + args.pop.keys + else + [] + end + + [args, kw_args] + end + end + + # Figures out wether a given method can accept various arguments. + # Surprisingly non-trivial. + # + # @private + StrictSignatureVerifier = MethodSignatureVerifier + + # Allows matchers to be used instead of providing keyword arguments. In + # practice, when this happens only the arity of the method is verified. + # + # @private + class LooseSignatureVerifier < MethodSignatureVerifier + private + + def split_args(*args) + if RSpec::Support.is_a_matcher?(args.last) && @signature.could_contain_kw_args?(args) + args.pop + @signature = SignatureWithKeywordArgumentsMatcher.new(@signature) + end + + super(*args) + end + + # If a matcher is used in a signature in place of keyword arguments, all + # keyword argument validation needs to be skipped since the matcher is + # opaque. + # + # Instead, keyword arguments will be validated when the method is called + # and they are actually known. + # + # @private + class SignatureWithKeywordArgumentsMatcher + def initialize(signature) + @signature = signature + end + + def missing_kw_args_from(_kw_args) + [] + end + + def invalid_kw_args_from(_kw_args) + [] + end + + def non_kw_args_arity_description + @signature.non_kw_args_arity_description + end + + def valid_non_kw_args?(*args) + @signature.valid_non_kw_args?(*args) + end + + def has_kw_args_in?(args) + @signature.has_kw_args_in?(args) + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/os.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/os.rb new file mode 100644 index 000000000..82f53f1cc --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/os.rb @@ -0,0 +1,18 @@ +module RSpec + module Support + # @api private + # + # Provides query methods for different OS or OS features. + module OS + def windows? + RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/ + end + module_function :windows? + + def windows_file_path? + ::File::ALT_SEPARATOR == '\\' + end + module_function :windows_file_path? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/recursive_const_methods.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/recursive_const_methods.rb new file mode 100644 index 000000000..f88abfea2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/recursive_const_methods.rb @@ -0,0 +1,76 @@ +module RSpec + module Support + # Provides recursive constant lookup methods useful for + # constant stubbing. + module RecursiveConstMethods + # We only want to consider constants that are defined directly on a + # particular module, and not include top-level/inherited constants. + # Unfortunately, the constant API changed between 1.8 and 1.9, so + # we need to conditionally define methods to ignore the top-level/inherited + # constants. + # + # Given: + # class A; B = 1; end + # class C < A; end + # + # On 1.8: + # - C.const_get("Hash") # => ::Hash + # - C.const_defined?("Hash") # => false + # - C.constants # => ["B"] + # - None of these methods accept the extra `inherit` argument + # On 1.9: + # - C.const_get("Hash") # => ::Hash + # - C.const_defined?("Hash") # => true + # - C.const_get("Hash", false) # => raises NameError + # - C.const_defined?("Hash", false) # => false + # - C.constants # => [:B] + # - C.constants(false) #=> [] + if Module.method(:const_defined?).arity == 1 + def const_defined_on?(mod, const_name) + mod.const_defined?(const_name) + end + + def get_const_defined_on(mod, const_name) + return mod.const_get(const_name) if const_defined_on?(mod, const_name) + + raise NameError, "uninitialized constant #{mod.name}::#{const_name}" + end + + def constants_defined_on(mod) + mod.constants.select { |c| const_defined_on?(mod, c) } + end + else + def const_defined_on?(mod, const_name) + mod.const_defined?(const_name, false) + end + + def get_const_defined_on(mod, const_name) + mod.const_get(const_name, false) + end + + def constants_defined_on(mod) + mod.constants(false) + end + end + + def recursive_const_get(const_name) + normalize_const_name(const_name).split('::').inject(Object) do |mod, name| + get_const_defined_on(mod, name) + end + end + + def recursive_const_defined?(const_name) + parts = normalize_const_name(const_name).split('::') + parts.inject([Object, '']) do |(mod, full_name), name| + yield(full_name, name) if block_given? && !(Module === mod) + return false unless const_defined_on?(mod, name) + [get_const_defined_on(mod, name), [mod, name].join('::')] + end + end + + def normalize_const_name(const_name) + const_name.sub(/\A::/, '') + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/ruby_features.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/ruby_features.rb new file mode 100644 index 000000000..dcfb2427b --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/ruby_features.rb @@ -0,0 +1,45 @@ +module RSpec + module Support + # @api private + # + # Provides query methods for different rubies + module Ruby + def jruby? + RUBY_PLATFORM == 'java' + end + module_function :jruby? + end + + # @api private + # + # Provides query methods for ruby features that differ among + # implementations. + module RubyFeatures + def optional_and_splat_args_supported? + Method.method_defined?(:parameters) + end + module_function :optional_and_splat_args_supported? + + def kw_args_supported? + RUBY_VERSION >= '2.0.0' && RUBY_ENGINE != 'rbx' && RUBY_ENGINE != 'jruby' + end + module_function :kw_args_supported? + + def required_kw_args_supported? + RUBY_VERSION >= '2.1.0' && RUBY_ENGINE != 'rbx' && RUBY_ENGINE != 'jruby' + end + module_function :required_kw_args_supported? + + def module_prepends_supported? + Module.method_defined?(:prepend) || Module.private_method_defined?(:prepend) + end + module_function :module_prepends_supported? + + def supports_rebinding_module_methods? + # RBX and JRuby don't yet support this. + RUBY_VERSION.to_i >= 2 && RUBY_ENGINE != 'rbx' && RUBY_ENGINE != 'jruby' + end + module_function :supports_rebinding_module_methods? + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec.rb new file mode 100644 index 000000000..2d4bbcbab --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec.rb @@ -0,0 +1,72 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support "spec/deprecation_helpers" +RSpec::Support.require_rspec_support "spec/with_isolated_stderr" +RSpec::Support.require_rspec_support "spec/stderr_splitter" +RSpec::Support.require_rspec_support "spec/formatting_support" +RSpec::Support.require_rspec_support "spec/with_isolated_directory" +RSpec::Support.require_rspec_support "ruby_features" + +warning_preventer = $stderr = RSpec::Support::StdErrSplitter.new($stderr) + +RSpec.configure do |c| + c.include RSpecHelpers + c.include RSpec::Support::WithIsolatedStdErr + c.include RSpec::Support::FormattingSupport + + unless defined?(Debugger) # debugger causes warnings when used + c.before do + warning_preventer.reset! + end + + c.after do |example| + warning_preventer.verify_example!(example) + end + end + + if c.files_to_run.one? + c.full_backtrace = true + c.default_formatter = 'doc' + end + + c.filter_run :focus + c.run_all_when_everything_filtered = true +end + +module RSpec + module Support + module Spec + def self.setup_simplecov(&block) + # Simplecov emits some ruby warnings when loaded, so silence them. + old_verbose, $VERBOSE = $VERBOSE, false + + return if ENV['NO_COVERAGE'] || RUBY_VERSION < '1.9.3' || RUBY_ENGINE != 'ruby' + + # Don't load it when we're running a single isolated + # test file rather than the whole suite. + return if RSpec.configuration.files_to_run.one? + + require 'simplecov' + start_simplecov(&block) + rescue LoadError + warn "Simplecov could not be loaded" + ensure + $VERBOSE = old_verbose + end + + def self.start_simplecov(&block) + SimpleCov.start do + add_filter "./bundle/" + add_filter "./tmp/" + add_filter do |source_file| + # Filter out `spec` directory except when it is under `lib` + # (as is the case in rspec-support) + source_file.filename.include?('/spec/') && !source_file.filename.include?('/lib/') + end + + instance_eval(&block) if block + end + end + private_class_method :start_simplecov + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb new file mode 100644 index 000000000..845308919 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb @@ -0,0 +1,60 @@ +module RSpecHelpers + def expect_no_deprecation + expect(RSpec.configuration.reporter).not_to receive(:deprecation) + end + + def expect_deprecation_with_call_site(file, line, snippet=//) + expect(RSpec.configuration.reporter).to receive(:deprecation) do |options| + expect(options[:call_site]).to include([file, line].join(':')) + expect(options[:deprecated]).to match(snippet) + end + end + + def expect_deprecation_without_call_site(snippet=//) + expect(RSpec.configuration.reporter).to receive(:deprecation) do |options| + expect(options[:call_site]).to eq nil + expect(options[:deprecated]).to match(snippet) + end + end + + def expect_warn_deprecation_with_call_site(file, line, snippet=//) + expect(RSpec.configuration.reporter).to receive(:deprecation) do |options| + message = options[:message] + expect(message).to match(snippet) + expect(message).to include([file, line].join(':')) + end + end + + def expect_warn_deprecation(snippet=//) + expect(RSpec.configuration.reporter).to receive(:deprecation) do |options| + message = options[:message] + expect(message).to match(snippet) + end + end + + def allow_deprecation + allow(RSpec.configuration.reporter).to receive(:deprecation) + end + + def expect_no_deprecations + expect(RSpec.configuration.reporter).not_to receive(:deprecation) + end + + def expect_warning_without_call_site(expected=//) + expect(::Kernel).to receive(:warn) do |message| + expect(message).to match expected + expect(message).to_not match(/Called from/) + end + end + + def expect_warning_with_call_site(file, line, expected=//) + expect(::Kernel).to receive(:warn) do |message| + expect(message).to match expected + expect(message).to match(/Called from #{file}:#{line}/) + end + end + + def allow_warning + allow(::Kernel).to receive(:warn) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/formatting_support.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/formatting_support.rb new file mode 100644 index 000000000..7e61cef49 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/formatting_support.rb @@ -0,0 +1,9 @@ +module RSpec + module Support + module FormattingSupport + def dedent(string) + string.gsub(/^\s+\|/, '').chomp + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/in_sub_process.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/in_sub_process.rb new file mode 100644 index 000000000..3c8383d40 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/in_sub_process.rb @@ -0,0 +1,43 @@ +module RSpec + module Support + module InSubProcess + if Process.respond_to?(:fork) && !(RUBY_PLATFORM == 'java' && RUBY_VERSION == '1.8.7') + # Useful as a way to isolate a global change to a subprocess. + + # rubocop:disable MethodLength + def in_sub_process + readme, writeme = IO.pipe + + pid = Process.fork do + exception = nil + begin + yield + rescue Exception => e + exception = e + end + + writeme.write Marshal.dump(exception) + + readme.close + writeme.close + exit! # prevent at_exit hooks from running (e.g. minitest) + end + + writeme.close + Process.waitpid(pid) + + exception = Marshal.load(readme.read) + readme.close + + raise exception if exception + end + else + def in_sub_process + skip "This spec requires forking to work properly, " \ + "and your platform does not support forking" + end + end + # rubocop:enable MethodLength + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/prevent_load_time_warnings.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/prevent_load_time_warnings.rb new file mode 100644 index 000000000..09999dad2 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/prevent_load_time_warnings.rb @@ -0,0 +1,44 @@ +require 'rspec/support/spec/shell_out' + +module RSpec + module Support + module WarningsPrevention + def files_to_require_for(lib) + slash = File::SEPARATOR + lib_path_re = /#{slash + lib}[^#{slash}]*#{slash}lib/ + load_path = $LOAD_PATH.grep(lib_path_re).first + files = Dir["#{load_path}/**/*.rb"] + extract_regex = /#{Regexp.escape(load_path) + File::SEPARATOR}(.+)\.rb$/ + + # We sort to ensure the files are loaded in a consistent order, regardless + # of OS. Otherwise, it could load in a different order on Travis than + # locally, and potentially trigger a "circular require considered harmful" + # warning or similar. + files.sort.map { |file| file[extract_regex, 1] } + end + end + end +end + +RSpec.shared_examples_for "a library that issues no warnings when loaded" do |lib, *preamble_stmnts| + include RSpec::Support::ShellOut + include RSpec::Support::WarningsPrevention + + it "issues no warnings when loaded", :slow do + # We want to explicitly load every file because each lib has some files that + # aren't automatically loaded, instead being delayed based on an autoload + # (such as for rspec-expectations' matchers) or based on a config option + # (e.g. `config.mock_with :rr` => 'rspec/core/mocking_adapters/rr'). + statements = preamble_stmnts + files_to_require_for(lib).map do |file| + "require '#{file}'" + end + + command = statements.join("; ") + + stdout, stderr, status = run_ruby_with_current_load_path(command, "-w") + + expect(stdout).to eq("") + expect(stderr).to eq("") + expect(status.exitstatus).to eq(0) + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/shell_out.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/shell_out.rb new file mode 100644 index 000000000..2808ff7ad --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/shell_out.rb @@ -0,0 +1,69 @@ +require 'open3' +require 'rake/file_utils' +require 'shellwords' + +module RSpec + module Support + module ShellOut + def with_env(vars) + original = ENV.to_hash + vars.each { |k, v| ENV[k] = v } + + begin + yield + ensure + ENV.replace(original) + end + end + + if Open3.respond_to?(:capture3) # 1.9+ + def shell_out(*command) + stdout, stderr, status = Open3.capture3(*command) + return stdout, filter(stderr), status + end + else # 1.8.7 + def shell_out(*command) + stdout = stderr = nil + + Open3.popen3(*command) do |_in, out, err| + stdout = out.read + stderr = err.read + end + + # popen3 doesn't provide the exit status so we fake it out. + status = instance_double(Process::Status, :exitstatus => 0) + return stdout, filter(stderr), status + end + end + + def run_ruby_with_current_load_path(ruby_command, *flags) + command = [ + FileUtils::RUBY, + "-I#{$LOAD_PATH.map(&:shellescape).join(File::PATH_SEPARATOR)}", + "-e", ruby_command, *flags + ] + + # Unset these env vars because `ruby -w` will issue warnings whenever + # they are set to non-default values. + with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, 'RUBY_GC_MALLOC_LIMIT' => nil, + 'RUBY_FREE_MIN' => nil do + shell_out(*command) + end + end + + private + + if Ruby.jruby? + def filter(output) + output.each_line.reject do |line| + line.include?("lib/ruby/shared/rubygems/defaults/jruby") + end.join($/) + end + else + def filter(output) + output + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/stderr_splitter.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/stderr_splitter.rb new file mode 100644 index 000000000..09bf6797c --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/stderr_splitter.rb @@ -0,0 +1,52 @@ +require 'stringio' + +module RSpec + module Support + class StdErrSplitter + def initialize(original) + @orig_stderr = original + @output_tracker = ::StringIO.new + end + + respond_to_name = (::RUBY_VERSION.to_f < 1.9) ? :respond_to? : :respond_to_missing? + define_method respond_to_name do |*args| + @orig_stderr.respond_to?(*args) || super + end + + def method_missing(name, *args, &block) + @output_tracker.__send__(name, *args, &block) + @orig_stderr.__send__(name, *args, &block) + end + + def ==(other) + @orig_stderr == other + end + + # To work around JRuby error: + # TypeError: $stderr must have write method, RSpec::StdErrSplitter given + def write(line) + return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG + + @orig_stderr.write(line) + @output_tracker.write(line) + end + + def has_output? + !output.empty? + end + + def reset! + @output_tracker = ::StringIO.new + end + + def verify_example!(example) + example.send(:fail, "Warnings were generated: #{output}") if has_output? + reset! + end + + def output + @output_tracker.string + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_directory.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_directory.rb new file mode 100644 index 000000000..c0a2bdada --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_directory.rb @@ -0,0 +1,9 @@ +require 'tmpdir' + +RSpec.shared_context "isolated directory", :isolated_directory => true do + around do |ex| + Dir.mktmpdir do |tmp_dir| + Dir.chdir(tmp_dir, &ex) + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_stderr.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_stderr.rb new file mode 100644 index 000000000..8884c2fbe --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/spec/with_isolated_stderr.rb @@ -0,0 +1,13 @@ +module RSpec + module Support + module WithIsolatedStdErr + def with_isolated_stderr + original = $stderr + $stderr = StringIO.new + yield + ensure + $stderr = original + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version.rb new file mode 100644 index 000000000..7a4301973 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version.rb @@ -0,0 +1,7 @@ +module RSpec + module Support + module Version + STRING = '3.1.2' + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version_checker.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version_checker.rb new file mode 100644 index 000000000..679211e93 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/version_checker.rb @@ -0,0 +1,53 @@ +module RSpec + module Support + LibraryVersionTooLowError = Class.new(StandardError) + + # @private + class VersionChecker + def initialize(library_name, library_version, min_patch_level) + @library_name, @library_version = library_name, library_version + @min_patch_level = min_patch_level + + @major, @minor, @patch = parse_version(library_version) + @min_major, @min_minor, @min_patch = parse_version(min_patch_level) + + @comparison_result = compare_version + end + + def check_version! + raise_too_low_error if too_low? + end + + private + + def too_low? + @comparison_result == :too_low + end + + def raise_too_low_error + raise LibraryVersionTooLowError, + "You are using #{@library_name} #{@library_version}. " \ + "RSpec requires version #{version_requirement}." + end + + def compare_version + case + when @major < @min_major then :too_low + when @major > @min_major then :ok + when @minor < @min_minor then :too_low + when @minor > @min_minor then :ok + when @patch < @min_patch then :too_low + else :ok + end + end + + def version_requirement + ">= #{@min_patch_level}" + end + + def parse_version(version) + version.split('.').map { |v| v.to_i } + end + end + end +end diff --git a/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/warnings.rb b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/warnings.rb new file mode 100644 index 000000000..1d0a63237 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/rspec-support-3.1.2/lib/rspec/support/warnings.rb @@ -0,0 +1,39 @@ +require 'rspec/support' +RSpec::Support.require_rspec_support "caller_filter" + +module RSpec + module Support + module Warnings + def deprecate(deprecated, options={}) + warn_with "DEPRECATION: #{deprecated} is deprecated.", options + end + + # @private + # + # Used internally to print deprecation warnings + # when rspec-core isn't loaded + def warn_deprecation(message, options={}) + warn_with "DEPRECATION: \n #{message}", options + end + + # @private + # + # Used internally to print warnings + def warning(text, options={}) + warn_with "WARNING: #{text}.", options + end + + # @private + # + # Used internally to print longer warnings + def warn_with(message, options={}) + call_site = options.fetch(:call_site) { CallerFilter.first_non_rspec_line } + message << " Use #{options[:replacement]} instead." if options[:replacement] + message << " Called from #{call_site}." if call_site + ::Kernel.warn message + end + end + end + + extend RSpec::Support::Warnings +end diff --git a/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.gitignore b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.gitignore new file mode 100644 index 000000000..e20dac6b1 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.gitignore @@ -0,0 +1,7 @@ +.rvmrc +.yardoc +doc +*.swp +*.gem +*.rbc +Gemfile.lock diff --git a/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.travis.yml b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.travis.yml new file mode 100644 index 000000000..6fba0ce16 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/.travis.yml @@ -0,0 +1,9 @@ +rvm: + - 1.9.3 + - 2.1 + - ruby-head + - jruby-19mode +notifications: + email: + on_success: change + on_failure: always diff --git a/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/CHANGES.md b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/CHANGES.md new file mode 100644 index 000000000..c500bebf7 --- /dev/null +++ b/vendor/bundle/ruby/2.3.0/gems/slop-3.6.0/CHANGES.md @@ -0,0 +1,309 @@ +3.6.0 (2014-06-18) +------------------ + +* Add example of rest arguments usage in the readme file #139 +* Default values on options are printed in the help message #134 + +3.5.0 (2014-03-12) +------------------ + +* Add support for `as: Regexp` #132 + +3.4.7 (2013-11-14) +------------------ + +* Ensure trash is cleared on every parse so you can parse multiple + times with the same instance (#130) + +3.4.5 (2013-05-14) +------------------ + +* Allow specifying long options starting with numbers (#110, Peter Zotov) +* Ensure short-options still consume trailing arguments, ie `-abc foo` + should assign `foo` to the option `c` if it expects an argument (#114). + +3.4.4 (2013-03-12) +------------------ + +* Disable the run callback when the help option is used and `-h` + or `--help` is passed. #106 +* Ensure default `--help` option exits by default (#107, Autumn Perrault). + +3.4.3 (2013-01-14) +------------------ + +* Ensure `parse!` removes commands and their options. + +3.4.2 (2013-01-14) +------------------ + +* Expose the Hash commands as public API. +* Deprecated `Slop.optspec`. +* Ensure help output prints to stdout, not stderr. + +3.4.1 (2013-01-13) +------------------ + +* Ensure options replace any existing duplicates +* Command config options now inherit config options from top level Slop. +* Command help output now adds command in usage string. + +3.4.0 (2013-01-12) +------------------ + +* Implement new command system (#95) +* Deprecate Slop::Commands +* Ensure 'no-foo' options are not inverted when parsing '--no-foo' (#86) +* Code refactoring and simplification (Kenichi Kamiya, #84, #85) + +3.3.3 (2012-08-29) +------------------ + +* Ensure autocreate arguments are not created as options (#77) +* Ensure options are not swallowed when using short options with argument + included (#74) + +3.3.2 (2012-06-26) +------------------ + +* Ensure multiple options are not executed unless they exist (#70) + +3.3.1 (2012-05-31) +------------------ + +* Stop multiple switches from trashing arguments (Conrad Irwin, #66) + +3.3.0 (2012-05-30) +------------------ + +* Fix `:as => :count` when using multiple switches. +* Ensure range typecast allows negative range values. +* Ignore nil objects send to #parse instead of choking. + +3.2.0 (2012-05-15) +------------------ + +* Ensure boolean options appear correctly in `to_hash` output. (#59) + +3.1.1 (2012-04-24) +------------------ + +* Ensure separators before any options are still being processed (#62) + +3.1.0 (2012-04-23) +------------------ + +* Allow options to be fetched via underscores instead of dashes + (as a fallback) (Eric Anderson, #51) +* Added `Slop#strict?` method. +* Added strict checks for Integer/Float type casting. (Amon Sha) +* Ensure separators are not replacing existing separators (#61) + +3.0.4 (2012-01-31) +------------------ + +* Ensure `option=argument` syntax does not consume following arguments (#55). + +3.0.3 (2012-01-30) +------------------ + +* Ensure options passed after option terminator do not raise an exception + (#54, Amon Sha) + +3.0.2 (2012-01-27) +------------------ + +* Ensure `--option=value` is being evaluated before multiple switches (#52) + +3.0.1 (2012-01-27) +------------------ + +* Ensure tests run green on 1.8.7 +* Ensure `:argument => :optional` works with `:option=` format. +* Ruby 1.8.7 compat fix (dont chain Enumerable methods!) (Eric Anderson) + +3.0.0 (2012-01-24) +------------------ + +* value_to_range returns an x..x range if the value looks like an integer. +* Lots of code refactoring +* Use TomDoc documentation +* Added `Slop::Commands` and removed existing command system +* Configuration options altered: + * `:optional` has been renamed to `:optional_argument` + * Added `:required` for mandatory options + * `:argument` now accepts an `:optional` symbol as well as boolean value +* Removed Slop instance methods: + * description=, description + * summary=, summary + * command + * on_empty + * on_noopts + * execute + * to_struct +* Added Slop instance methods: + * separator + * fetch_option + * add_callback + +2.4.3 (2012-01-16) +------------------ + +* Allow the `:as` option to accept an object responding to :call for + custom type conversions (#45) +* Ensure negative integers are not parsed as possible options (#46) + +2.4.2 (2011-12-18) +------------------ + +* Fix checking of required options (Dominik Honnef) + +2.4.1 (2011-12-08) +------------------ + +* Ensure optional arguments are returned correctly + +2.4.0 (2011-11-26) +------------------ + +* Avoid `define_method` for checking an options presence (and caching it) #37 +* Ensure the short option allows an appended `=` for accepting arguments +* Implement `respond_to?` + +2.3.1 (2011-11-11) +------------------ + +* Return `nil` for any options using casting which don't expect arguments (#33) +* Fix parenthesis warning on 1.8.7 (@shevegen) +* Ensure long argument is a string before attempting to use `#[]` method on it + +2.3.0 (2011-11-04) +------------------ + +* Allow flags to have suffixed `=` char for options which accept an argument + +2.2.0 (2011-11-02) +------------------ + +* Support `bup.options` style optspec parsing + * http://apenwarr.ca/log/?m=201111 + +* Allow `:as` to accept a `count` value (Conrad Irwin): + + `on :v, :verbose, :as => :count # -vv; opts[:verbose] #=> 2` + +2.1.0 (2011-08-03) +------------------ + +* Added `Slop#missing` for returning a list of missing options parsed +* Allow `Slop#present?` to accept multiple arguments +* Added `:all_accept_arguments` to Slop configuration options, this saves + having to specify that every option takes an argument +* Added `Slop#to_struct` for building new classes from options + +2.0.0 (2011-07-07) +------------------ + +* Deprecations: + * Removed `Slop::Options#to_hash` continue using `Slop#to_hash` directly. + This method also now returns symbols by default instead of strings. If + you want strings use `opts.to_hash(false)` + * `:multiple_switches` is now enabled by default, to parse `fbar` as the + option `f` with value `bar` you must disable `:multiple_switches` + * Removed `Slop::Options#to_help` and merged its contents into `Slop#help` + * Removed `lib/slop/options.rb` and merged `Slop::Options` into slop.rb + * Removed `lib/slop/option.rb` and merged `Slop::Option` into slop.rb + * These changes make Slop much easier to vendor in libraries +* `Slop::Option` now inherits from `Struct.new` +* Added Slop::Error subclassing from StandardError which all exception + classes should inherit from +* Added Slop::MissingOptionError and `:required` option to Slop::Option. + This exception is raised when a mandatory option is not used + +1.9.1 (2011-06-16) +------------------ + +* Ensure optional items with no arguments still return true when searching + for presence + +1.9.0 (2011-06-15) +------------------ + +* Add command completion and support for an error message when ambiguous + commands are used +* Add command aliases +* Fix: Ensure parsed elements are removed from original arguments when using + `:multiple_switches` +* Ensure anything after `--` is parsed as an argument and not option even + if prefixed with `/--?/` +* Performance improvements when making many calls to `Slop#option?` for + checking an options presence (Rob Gleeson) +* Ensure `execute` passes command arguments to the block +* Support for summary and description (Denis Defreyne) + +1.8.0 (2011-06-12) +------------------ + +* Added `execute` method to Slop for commands. This block will be invoked + when a specific command is used. The Slop object will be yielded to the + block +* Allow passing a class name to `on` to be used as an `:as` option. ie: + `on :people, 'Some people', Array` +* Get smart with parsing options optparse style: `on '--name NAME'` and + `on 'password [OPTIONAL]'` +* Feature: `:arguments` setting to enable argument passing for all options + +1.7.0 (2011-06-06) +------------------ + +* Feature: Autocreate (auto create options at parse time, making assumptions) +* Feature: When parsing options as arrays, push multiple arguments into a + single array + +1.6.1 (2011-06-01) +------------------ + +* Fix tests and using a temporary Array for ARGV, fixes RubyGems Test issues +* General cleanup of code + +1.6.0 (2011-05-18) +------------------ + +* Add `:ignore_case` to Slop options for case insensitive option matching +* Add `:on_noopts` for triggering an event when the arguments contain no + options +* Add `:unless` to Slop::Option for omitting execution of the Options block + when this object exists in the Array of items passed to Slop.new +* Bugfix: Do not parse negative integers as options. A valid option must + start with an alphabet character +* Bugfix: Allow a Range to accept a negative Integer at either end + +1.5.5 (2011-05-03) +------------------ + +* Bugfix: only attempt to extract options prefixed with `-` + +1.5.4 (2011-05-01) +------------------ + +* Bugfix: `parse!` should not remove items with the same value as items used + in option arguments. Fixes #22 (Utkarsh Kukreti) + +1.5.3 (2011-04-22) +------------------ + +* Bugfix: Use integers when fetching array indexes, not strings + +1.5.2 (2011-04-17) +------------------ + +* Bugfix: Ensure `ARGV` is empty when using the `on_empty` event + +1.5.0 (2011-04-15) +------------------ + +* Add `Slop#get` as alias to `Slop#[]` +* Add `Slop#present?` as alias for `Slop#