Skip to content

Commit

Permalink
Enable and support Ruby 2.3+ frozen_string_literals
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Aug 11, 2016
1 parent a37c3cb commit 49d885f
Show file tree
Hide file tree
Showing 384 changed files with 440 additions and 56 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ Style/NestedTernaryOperator:
Enabled: false
Style/MutableConstant:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/WhenThen:
Enabled: false
Style/StringLiterals:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

group :development do
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require File.dirname(__FILE__) + '/lib/yard'
require File.dirname(__FILE__) + '/lib/yard/rubygems/specification'
require 'rbconfig'
Expand Down
1 change: 1 addition & 0 deletions benchmarks/builtins_vs_eval.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'benchmark'
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

Expand Down
1 change: 1 addition & 0 deletions benchmarks/concat_vs_join.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"

STR1 = "Hello"
Expand Down
1 change: 1 addition & 0 deletions benchmarks/erb_vs_erubis.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems'
require 'erubis'
require 'erubis/tiny'
Expand Down
1 change: 1 addition & 0 deletions benchmarks/format_args.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"
require 'lib/yard'

Expand Down
1 change: 1 addition & 0 deletions benchmarks/generation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

Expand Down
1 change: 1 addition & 0 deletions benchmarks/marshal_vs_dbm.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'benchmark'
require 'dbm'

Expand Down
1 change: 1 addition & 0 deletions benchmarks/parsing.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"
require 'yard'
require 'logger'
Expand Down
1 change: 1 addition & 0 deletions benchmarks/pathname_vs_string.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'pathname'
require "benchmark"
require File.dirname(__FILE__) + '/../lib/yard'
Expand Down
1 change: 1 addition & 0 deletions benchmarks/rdoc_vs_yardoc.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"

files = Dir.glob(File.dirname(__FILE__) + '/../lib/**/*.rb').join(" ")
Expand Down
1 change: 1 addition & 0 deletions benchmarks/registry_store_types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'benchmark'
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

Expand Down
1 change: 1 addition & 0 deletions benchmarks/ri_vs_yri.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"

TIMES = 10
Expand Down
1 change: 1 addition & 0 deletions benchmarks/ripper_parser.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
# frozen_string_literal: true
require 'benchmark'
require File.dirname(__FILE__) + '/../lib/yard'

Expand Down
1 change: 1 addition & 0 deletions benchmarks/splat_vs_flatten.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"

# To prove that flattening a small list is not significantly slower than
Expand Down
1 change: 1 addition & 0 deletions benchmarks/template_erb.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

Expand Down
1 change: 1 addition & 0 deletions benchmarks/template_format.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

Expand Down
1 change: 1 addition & 0 deletions benchmarks/template_profile.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems'
require 'ruby-prof'
# require 'benchmark'
Expand Down
1 change: 1 addition & 0 deletions benchmarks/yri_cache.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require File.dirname(__FILE__) + "/../lib/yard"
require "benchmark"
include YARD::CLI
Expand Down
1 change: 1 addition & 0 deletions bin/yard
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# We do all this work just to find the proper load path
path = __FILE__
Expand Down
1 change: 1 addition & 0 deletions bin/yardoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# We do all this work just to find the proper load path
path = __FILE__
Expand Down
1 change: 1 addition & 0 deletions bin/yri
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# We do all this work just to find the proper load path
path = __FILE__
Expand Down
1 change: 1 addition & 0 deletions docs/templates/default/fulldoc/html/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
def generate_tag_list
@list_title = "Tag List"
@list_type = "tag"
Expand Down
1 change: 1 addition & 0 deletions docs/templates/default/layout/html/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
def init
super
sections.place(:tag_list).after_any(:files)
Expand Down
1 change: 1 addition & 0 deletions docs/templates/default/yard_tags/html/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
def init
sections :list, [T('docstring')]
end
Expand Down
1 change: 1 addition & 0 deletions docs/templates/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
include YARD
include Templates

Expand Down
1 change: 1 addition & 0 deletions lib/rubygems_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
if defined?(Gem::VERSION) && Gem::VERSION >= "2.0."
require File.expand_path(File.dirname(__FILE__) + '/yard/rubygems/hook')
else
Expand Down
1 change: 1 addition & 0 deletions lib/yard.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
# The root path for YARD source libraries
ROOT = File.expand_path(File.dirname(__FILE__))
Expand Down
1 change: 1 addition & 0 deletions lib/yard/autoload.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# @private
def __p(path) File.join(YARD::ROOT, 'yard', *path.split('/')); end

Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'optparse'

module YARD
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/command_parser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# This class parses a command name out of the +yard+ CLI command and calls
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# CLI command to view or edit configuration options
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/diff.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'tmpdir'
require 'fileutils'
require 'open-uri'
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/display.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# Display one object
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/gems.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# @since 0.6.0
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/graph.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# Options to pass to the {Graph} CLI.
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/help.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# Handles help for commands
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/i18n.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "pathname"

module YARD
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# Lists all constant and method names in the codebase. Uses {Yardoc} --list.
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/markup_types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# Lists all markup types
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# A local documentation server
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/stats.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CLI
# @since 0.6.0
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/yardoc.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'digest/sha1'
require 'fileutils'

Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/yardopts_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'optparse'

module YARD
Expand Down
1 change: 1 addition & 0 deletions lib/yard/cli/yri.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rbconfig'

module YARD
Expand Down
3 changes: 2 additions & 1 deletion lib/yard/code_objects/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CodeObjects
# A list of code objects. This array acts like a set (no unique items)
Expand Down Expand Up @@ -580,7 +581,7 @@ def copyable_attributes
# @param [String] source the source code to format
# @return [String] formatted source
def format_source(source)
source.chomp!
source = source.chomp
last = source.split(/\r?\n/).last
indent = last ? last[/^([ \t]*)/, 1].length : 0
source.gsub(/^[ \t]{#{indent}}/, '')
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/class_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator NSEP, :class

Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/class_variable_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator NSEP, :class_variable

Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/constant_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator NSEP, :constant

Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/extended_method_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
# Represents an instance method of a module that was mixed into the class
# scope of another namespace.
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/extra_file_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
# An ExtraFileObject represents an extra documentation file (README or other
# file). It is not strictly a CodeObject (does not inherit from `Base`) although
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/macro_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'ostruct'

module YARD
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/method_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator CSEP, :method
register_separator ISEP, :method
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/module_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator NSEP, :module

Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/namespace_mapper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CodeObjects
# This module controls registration and accessing of namespace separators
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/namespace_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD::CodeObjects
register_separator NSEP, :namespace
default_separator NSEP
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/proxy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CodeObjects
# A special type of +NoMethodError+ when raised from a {Proxy}
Expand Down
1 change: 1 addition & 0 deletions lib/yard/code_objects/root_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
module CodeObjects
# Represents the root namespace object (the invisible Ruby module that
Expand Down
1 change: 1 addition & 0 deletions lib/yard/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
# This class maintains all system-wide configuration for YARD and handles
# the loading of plugins. To access options call {options}, and to load
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/array.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Array
# Places values before or after another object (by value) in
# an array. This is used in tandem with the before and after
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'fileutils'

class File
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
class << self
def create(*args)
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/insertion.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# The Insertion class inserts a value before or after another
# value in a list.
#
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/module.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Module
# Returns the class name of a full module namespace path
#
Expand Down
9 changes: 5 additions & 4 deletions lib/yard/core_ext/string.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# frozen_string_literal: true
class String
# Splits text into tokens the way a shell would, handling quoted
# text as a single token. Use '\"' and "\'" to escape quotes and
# '\\' to escape a backslash.
#
# @return [Array] an array representing the tokens
def shell_split
out = [""]
out = [String.new("")]
state = :none
escape_next = false
quote = ""
quote = String.new("")
strip.split(//).each do |char|
case state
when :none, :space
case char
when /\s/
out << "" unless state == :space
out << String.new("") unless state == :space
state = :space
escape_next = false
when "\\"
Expand All @@ -30,7 +31,7 @@ def shell_split
escape_next = false
else
state = char
quote = ""
quote = String.new("")
end
else
state = :none
Expand Down
1 change: 1 addition & 0 deletions lib/yard/core_ext/symbol_hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# A subclass of Hash where all keys are converted into Symbols, and
# optionally, all String values are converted into Symbols.
class SymbolHash < Hash
Expand Down
1 change: 1 addition & 0 deletions lib/yard/docstring.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module YARD
# A documentation string, or "docstring" for short, encapsulates the
# comments and metadata, or "tags", of an object. Meta-data is expressed
Expand Down
Loading

0 comments on commit 49d885f

Please sign in to comment.