Top Level Namespace

Defined Under Namespace

Modules: LiLi Classes: ALineEnding

Constant Summary collapse

DEFAULT_IGNORES =
%w(
  tmp
  .hg
  .svn
  .git
  .gitignore
  node_modules
  bower_components
  target
  dist
  .vagrant
  Gemfile.lock
  *.exe
  *.bin
  *.apk
  *.ap_
  res
  *.gem
  *.dmg
  *.pkg
  *.app
  *.xcodeproj
  *.lproj
  *.xcassets
  *.pmdoc
  *.dSYM
  *.class
  *.zip
  *.jar
  *.war
  *.xpi
  *.jad
  *.cmo
  *.cmi
  *.pdf
  *.dot
  *.png
  *.gif
  *.jpg
  *.jpeg
  *.tiff
  *.ico
  *.svg
  *.wav
  *.mp3
)
DEFAULT_RULES =

Note that order is significant; Only the earliest file pattern match’s rule applies.

[
  ['*[.-]min.*', [/^none$/, /^false$/]],
  ['*.{reg,cmd,bat,ps1,cs,fs,vbs,xaml,csproj,sln,aip}', [/^crlf|none$/, /^true|false$/]],
  ['*', [/^lf|none$/, /^true$/]]
]
DEFAULT_CONFIGURATION =
{
  'rules' => DEFAULT_RULES
}
NO_SUCH_FILE =

Warning for files that do not exist

'does not exist'

Class Method Summary collapse

Class Method Details

.check(filename, configuration = nil) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/lili.rb', line 127

def self.check(filename, configuration = nil)
  configuration =
    if configuration.nil?
      DEFAULT_CONFIGURATION
    else
      configuration
    end

  rules = configuration['rules']

  if !File.zero?(filename)
    line_ending = ALineEnding.parse(
      filename,
      LineDetector.report_of_file(filename)
    )

    line_ending_difference = line_ending.violate?(rules)

    puts line_ending.to_s(line_ending_difference) if line_ending_difference
  end
end