lili 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lili +19 -54
  3. data/lib/lili.rb +58 -36
  4. data/lib/version.rb +1 -1
  5. metadata +23 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72e32f95d37ff463284e60641c74eb529926dc40
4
- data.tar.gz: 3b35f665b17d6b8ccb9be17a6c0032bf682d6d31
3
+ metadata.gz: a6717ed5f3b2aa12e73512500ed7fa6a61bf28da
4
+ data.tar.gz: 2e4a3e884289d9aec9458f0e7e23fdff400beb4c
5
5
  SHA512:
6
- metadata.gz: 727fdd8d218261f0ec1e73d906cf24ea84c5a30d641cb3af265c4ada6a51b08ee02ee38bde25e2e816b79503df4122e5ae076ea82a01bb6b0f083d0d1cb2b33b
7
- data.tar.gz: d21725172cf867e550546380863b8fb8ac1b8c2da3f38496cf88f3bfd3aab2dc0640014dd05bf3cfb6f2f04511378a245d79e405bf38797cba20abf7852a12d1
6
+ metadata.gz: 1d9f9892f4208ffbf6b7679d14531751bd39183d4d7f2f19ecf7ebb5ef4f4c044398f3562c5ef43c4d7c1c5cff02e706bb1ce8bbc1136b2737eecbcced042b02
7
+ data.tar.gz: 7eb988af1865e3deca078f947e3655fa3b0f08decf1653333a33399e45380d46979dd5251d722566ace4bde516840ce5668e2daeda86270d7d65f12750c653b1
data/bin/lili CHANGED
@@ -3,23 +3,19 @@
3
3
  require 'rubygems'
4
4
  require 'find'
5
5
  require 'optparse'
6
+ require 'dotsmack'
6
7
  require 'yaml'
7
8
  require 'lili'
8
9
 
9
- IGNORE_FILENAME = '.lili-ignore'
10
- CONFIGURATION_FILENAME = '.lili-rc.yml'
11
-
12
10
  def main
13
11
  ignores = DEFAULT_IGNORES
14
12
 
15
- filenames = ['.']
16
-
17
13
  configuration_flags = {}
18
14
 
19
15
  option = OptionParser.new do |option|
20
16
  option.banner = 'Usage: lili [options] [<files>]'
21
17
 
22
- option.on('-i', '--ignore pattern', 'Ignore file names matching Ruby regex pattern') do |pattern|
18
+ option.on('-i', '--ignore pattern', 'Ignore file pattern (fnmatch)') do |pattern|
23
19
  ignores << pattern
24
20
  end
25
21
 
@@ -36,59 +32,28 @@ def main
36
32
 
37
33
  option.parse!
38
34
 
39
- filenames = ARGV unless ARGV.empty?
40
-
41
- recursive_filenames = []
42
-
43
- filenames.each do |f|
44
- if File.directory? f
45
- recursive_filenames = recursive_filenames.concat(recursive_list(f, ignores))
35
+ filenames =
36
+ if ARGV == []
37
+ ['.']
46
38
  else
47
- recursive_filenames << f
39
+ ARGV
48
40
  end
49
- end
50
41
 
51
- configuration_dotfile = DEFAULT_CONFIGURATION
52
-
53
- recursive_filenames.each do |f|
54
- dir = File.expand_path("..", f)
55
-
56
- parent_of_home = File.expand_path("..", ENV["HOME"])
57
-
58
- while dir != parent_of_home
59
- ignore_file = dir + File::SEPARATOR + IGNORE_FILENAME
60
-
61
- if File.exist?(ignore_file) then
62
- ignores.concat(open(ignore_file).read.split("\n"))
42
+ dotsmack = Dotsmack::Smacker.new(
43
+ dotignore = '.lili-ignore',
44
+ additional_ignores = ignores,
45
+ dotconfig = '.lili-rc.yml'
46
+ )
47
+
48
+ dotsmack.enumerate(filenames).each do |filename, config|
49
+ config =
50
+ if config.nil?
51
+ DEFAULT_CONFIGURATION.merge(configuration_flags)
52
+ else
53
+ DEFAULT_CONFIGURATION.merge(YAML.load(config)).merge(configuration_flags)
63
54
  end
64
55
 
65
- dir = File.expand_path("..", dir)
66
- end
67
-
68
- if ignores.none? { |ignore| f =~ %r(#{ignore}) } then
69
- dir = File.expand_path("..", f)
70
-
71
- parent_of_home = File.expand_path("..", ENV["HOME"])
72
-
73
- while dir != parent_of_home
74
- config_file = dir + File::SEPARATOR + CONFIGURATION_FILENAME
75
-
76
- if File.exist?(config_file) then
77
- configuration_dotfile = DEFAULT_CONFIGURATION.merge(YAML.load_file(config_file))
78
- break
79
- else
80
- dir = File.expand_path("..", dir)
81
- end
82
- end
83
-
84
- # Hack to Reset configuration when changing directories
85
- configuration_dotfile = DEFAULT_CONFIGURATION unless File.exist?(dir + File::SEPARATOR + CONFIGURATION_FILENAME)
86
-
87
- # Command line flags override dotfile settings
88
- configuration = configuration_dotfile.merge(configuration_flags)
89
-
90
- check(f, configuration)
91
- end
56
+ check(filename, config)
92
57
  end
93
58
  end
94
59
 
@@ -1,31 +1,52 @@
1
- require 'rubygems'
2
1
  require 'ptools'
3
2
  require 'line-detector'
4
3
 
5
- require 'version'
4
+ require_relative 'version'
6
5
 
7
6
  DEFAULT_IGNORES = %w(
8
- tmp/
9
- \.hg/
10
- \.svn/
11
- \.git/
12
- \.gitignore
13
- node_modules/
14
- bower_components/
15
- target/
16
- \.vagrant/
17
- Gemfile\.lock
18
- \.exe
19
- \.bin
20
- \.cmo
21
- \.cmi
22
- \.pdf
23
- \.dot
24
- \.png
25
- \.jpg
26
- \.jpeg
27
- \.min.js
28
- -min\.js
7
+ tmp
8
+ .hg
9
+ .svn
10
+ .git
11
+ .gitignore
12
+ node_modules
13
+ bower_components
14
+ target
15
+ dist
16
+ .vagrant
17
+ Gemfile.lock
18
+ *.exe
19
+ *.bin
20
+ *.apk
21
+ *.ap_
22
+ res
23
+ *.dmg
24
+ *.pkg
25
+ *.app
26
+ *.xcodeproj
27
+ *.lproj
28
+ *.xcassets
29
+ *.pmdoc
30
+ *.dSYM
31
+ *.class
32
+ *.zip
33
+ *.jar
34
+ *.war
35
+ *.xpi
36
+ *.jad
37
+ *.cmo
38
+ *.cmi
39
+ *.pdf
40
+ *.dot
41
+ *.png
42
+ *.gif
43
+ *.jpg
44
+ *.jpeg
45
+ *.tiff
46
+ *.ico
47
+ *.svg
48
+ *.wav
49
+ *.mp3
29
50
  )
30
51
 
31
52
  #
@@ -33,9 +54,9 @@ DEFAULT_IGNORES = %w(
33
54
  # Only the earliest file pattern match's rule applies.
34
55
  #
35
56
  DEFAULT_RULES = [
36
- [/[\.-]min\./, [/^none$/, /^false$/]],
37
- [/\.(reg|bat|ps1|cs|fs|xaml|csproj|sln)$/, [/^crlf|none$/, /^true|false$/]],
38
- [/.*/, [/^lf|none$/, /^true$/]]
57
+ ['*[.-]min.*', [/^none$/, /^false$/]],
58
+ ['*.{reg,cmd,bat,ps1,cs,fs,vbs,xaml,csproj,sln,aip}', [/^crlf|none$/, /^true|false$/]],
59
+ ['*', [/^lf|none$/, /^true$/]]
39
60
  ]
40
61
 
41
62
  DEFAULT_CONFIGURATION = {
@@ -63,7 +84,9 @@ class ALineEnding
63
84
  end
64
85
 
65
86
  def violate?(rules)
66
- preferred = rules.select { |rule| filename =~ rule.first }.first[1]
87
+ preferred = rules.select do |rule|
88
+ Dotsmack::fnmatch?(rule.first, @filename)
89
+ end.first[1]
67
90
 
68
91
  preferred_line_ending = preferred[0]
69
92
  preferred_final_eol = preferred[1]
@@ -100,22 +123,21 @@ class ALineEnding
100
123
  end
101
124
  end
102
125
 
103
- def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
104
- Find.find(directory).reject do |f|
105
- File.directory?(f) ||
106
- ignores.any? { |ignore| f =~ /#{ignore}/ } ||
107
- File.binary?(f)
108
- end
109
- end
126
+ def self.check(filename, configuration = nil)
127
+ configuration =
128
+ if configuration.nil?
129
+ DEFAULT_CONFIGURATION
130
+ else
131
+ configuration
132
+ end
110
133
 
111
- def self.check(filename, configuration = DEFAULT_CONFIGURATION)
112
134
  rules = configuration['rules']
113
135
 
114
136
  if !File.zero?(filename)
115
137
  line_ending = ALineEnding.parse(
116
138
  filename,
117
139
  LineDetector.report_of_file(filename)
118
- )
140
+ )
119
141
 
120
142
  line_ending_difference = line_ending.violate?(rules)
121
143
 
@@ -2,5 +2,5 @@
2
2
  # LiLi
3
3
  #
4
4
  module LiLi
5
- VERSION = '0.2'
5
+ VERSION = '0.3'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lili
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Pennebaker
@@ -11,33 +11,47 @@ cert_chain: []
11
11
  date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ptools
14
+ name: line-detector
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: line-detector
28
+ name: dotsmack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '0.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0.4'
40
+ version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ptools
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -271,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
285
  requirements:
272
286
  - - '>='
273
287
  - !ruby/object:Gem::Version
274
- version: '0'
288
+ version: '2.0'
275
289
  required_rubygems_version: !ruby/object:Gem::Requirement
276
290
  requirements:
277
291
  - - '>='
@@ -279,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
293
  version: '0'
280
294
  requirements: []
281
295
  rubyforge_project:
282
- rubygems_version: 2.2.2
296
+ rubygems_version: 2.4.6
283
297
  signing_key:
284
298
  specification_version: 4
285
299
  summary: line ending linter