lili 0.0 → 0.1
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.
- checksums.yaml +4 -4
 - data/bin/lili +49 -3
 - data/lib/lili.rb +32 -13
 - data/lib/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 825e18c500816a2d445dfb055260438524253108
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: eea5d057b10768685ba6029968faf06e3157c820
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 51596df41d135cc6c70f8cc9312675be5ee490f3b97bb17c7e40e061726dfe9aacf033ba4e320f78217de834c84c89f4d6438047c2049c3f4461ce6452172925
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 22cccb6757d4d6ba3d13b1f0c75420f3c91d546964ee90f5e21b1385877a988dd4149209ff8a26dbeb194f91b8d837d859a722b49ad6f4f9dd082dae73019bdc
         
     | 
    
        data/bin/lili
    CHANGED
    
    | 
         @@ -1,16 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'find'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'optparse'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
       7 
7 
     | 
    
         
             
            require 'lili'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
            IGNORE_FILENAME = '.lili-ignore'
         
     | 
| 
      
 10 
     | 
    
         
            +
            CONFIGURATION_FILENAME = '.lili-rc.yml'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       9 
12 
     | 
    
         
             
            def main
         
     | 
| 
       10 
13 
     | 
    
         
             
              ignores = DEFAULT_IGNORES
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
              filenames = ['.']
         
     | 
| 
       13 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
              configuration_flags = {}
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       14 
19 
     | 
    
         
             
              option = OptionParser.new do |option|
         
     | 
| 
       15 
20 
     | 
    
         
             
                option.banner = 'Usage: lili [options] [<files>]'
         
     | 
| 
       16 
21 
     | 
    
         | 
| 
         @@ -43,7 +48,48 @@ def main 
     | 
|
| 
       43 
48 
     | 
    
         
             
                end
         
     | 
| 
       44 
49 
     | 
    
         
             
              end
         
     | 
| 
       45 
50 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
               
     | 
| 
      
 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"))
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 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
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
       47 
93 
     | 
    
         
             
            end
         
     | 
| 
       48 
94 
     | 
    
         | 
| 
       49 
95 
     | 
    
         
             
            begin
         
     | 
    
        data/lib/lili.rb
    CHANGED
    
    | 
         @@ -8,7 +8,6 @@ DEFAULT_IGNORES = %w( 
     | 
|
| 
       8 
8 
     | 
    
         
             
              \.hg/
         
     | 
| 
       9 
9 
     | 
    
         
             
              \.svn/
         
     | 
| 
       10 
10 
     | 
    
         
             
              \.git/
         
     | 
| 
       11 
     | 
    
         
            -
              \.git
         
     | 
| 
       12 
11 
     | 
    
         
             
              \.gitignore
         
     | 
| 
       13 
12 
     | 
    
         
             
              node_modules/
         
     | 
| 
       14 
13 
     | 
    
         
             
              \.vagrant/
         
     | 
| 
         @@ -28,12 +27,17 @@ DEFAULT_IGNORES = %w( 
     | 
|
| 
       28 
27 
     | 
    
         
             
            # Only the earliest file pattern match's rule applies.
         
     | 
| 
       29 
28 
     | 
    
         
             
            #
         
     | 
| 
       30 
29 
     | 
    
         
             
            DEFAULT_RULES = [
         
     | 
| 
       31 
     | 
    
         
            -
              [/[\.-]min\./, /^none$/],
         
     | 
| 
       32 
     | 
    
         
            -
              [/\.reg$/, /^crlf$/],
         
     | 
| 
       33 
     | 
    
         
            -
              [/\.bat$/, /^crlf$/],
         
     | 
| 
       34 
     | 
    
         
            -
              [ 
     | 
| 
      
 30 
     | 
    
         
            +
              [/[\.-]min\./, [/^none$/, /^false$/]],
         
     | 
| 
      
 31 
     | 
    
         
            +
              [/\.reg$/, [/^crlf|none$/, /^false$/]],
         
     | 
| 
      
 32 
     | 
    
         
            +
              [/\.bat$/, [/^crlf|none$/, /^false$/]],
         
     | 
| 
      
 33 
     | 
    
         
            +
              [/\.ps1$/, [/^crlf|none$/, /^false$/]],
         
     | 
| 
      
 34 
     | 
    
         
            +
              [/.*/, [/^lf|none$/, /^true$/]]
         
     | 
| 
       35 
35 
     | 
    
         
             
            ]
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
      
 37 
     | 
    
         
            +
            DEFAULT_CONFIGURATION = {
         
     | 
| 
      
 38 
     | 
    
         
            +
              'rules' => DEFAULT_RULES
         
     | 
| 
      
 39 
     | 
    
         
            +
            }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       37 
41 
     | 
    
         
             
            # Warning for files that do not exist
         
     | 
| 
       38 
42 
     | 
    
         
             
            NO_SUCH_FILE = 'does not exist'
         
     | 
| 
       39 
43 
     | 
    
         | 
| 
         @@ -42,22 +46,35 @@ NO_SUCH_FILE = 'does not exist' 
     | 
|
| 
       42 
46 
     | 
    
         
             
            # Distinct from Ruby's built-in Encoding class.
         
     | 
| 
       43 
47 
     | 
    
         
             
            #
         
     | 
| 
       44 
48 
     | 
    
         
             
            class ALineEnding
         
     | 
| 
       45 
     | 
    
         
            -
              attr_accessor :filename, :line_ending
         
     | 
| 
      
 49 
     | 
    
         
            +
              attr_accessor :filename, :line_ending, :final_eol
         
     | 
| 
       46 
50 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
              def self.parse(filename,  
     | 
| 
       48 
     | 
    
         
            -
                ALineEnding.new(filename, line_ending.to_s)
         
     | 
| 
      
 51 
     | 
    
         
            +
              def self.parse(filename, report)
         
     | 
| 
      
 52 
     | 
    
         
            +
                ALineEnding.new(filename, report.line_ending.to_s, report.final_eol.to_s)
         
     | 
| 
       49 
53 
     | 
    
         
             
              end
         
     | 
| 
       50 
54 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
              def initialize(filename, line_ending)
         
     | 
| 
      
 55 
     | 
    
         
            +
              def initialize(filename, line_ending, final_eol)
         
     | 
| 
       52 
56 
     | 
    
         
             
                @filename = filename
         
     | 
| 
       53 
57 
     | 
    
         
             
                @line_ending = line_ending
         
     | 
| 
      
 58 
     | 
    
         
            +
                @final_eol = final_eol
         
     | 
| 
       54 
59 
     | 
    
         
             
              end
         
     | 
| 
       55 
60 
     | 
    
         | 
| 
       56 
61 
     | 
    
         
             
              def violate?(rules)
         
     | 
| 
       57 
62 
     | 
    
         
             
                preferred = rules.select { |rule| filename =~ rule.first }.first[1]
         
     | 
| 
       58 
63 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                 
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
                preferred_line_ending = preferred[0]
         
     | 
| 
      
 65 
     | 
    
         
            +
                preferred_final_eol = preferred[1]
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                if ! (@line_ending =~ preferred_line_ending)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  [@line_ending, preferred_line_ending]
         
     | 
| 
      
 69 
     | 
    
         
            +
                elsif ! (@final_eol =~ preferred_final_eol)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  [
         
     | 
| 
      
 71 
     | 
    
         
            +
                    if !final_eol
         
     | 
| 
      
 72 
     | 
    
         
            +
                      'with final eol'
         
     | 
| 
      
 73 
     | 
    
         
            +
                    else
         
     | 
| 
      
 74 
     | 
    
         
            +
                      'without final eol'
         
     | 
| 
      
 75 
     | 
    
         
            +
                    end,
         
     | 
| 
      
 76 
     | 
    
         
            +
                    preferred_final_eol
         
     | 
| 
      
 77 
     | 
    
         
            +
                  ]
         
     | 
| 
       61 
78 
     | 
    
         
             
                else
         
     | 
| 
       62 
79 
     | 
    
         
             
                  false
         
     | 
| 
       63 
80 
     | 
    
         
             
                end
         
     | 
| 
         @@ -87,11 +104,13 @@ def self.recursive_list(directory, ignores = DEFAULT_IGNORES) 
     | 
|
| 
       87 
104 
     | 
    
         
             
              end
         
     | 
| 
       88 
105 
     | 
    
         
             
            end
         
     | 
| 
       89 
106 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
            def self.check(filename,  
     | 
| 
      
 107 
     | 
    
         
            +
            def self.check(filename, configuration = DEFAULT_CONFIGURATION)
         
     | 
| 
      
 108 
     | 
    
         
            +
              rules = configuration['rules']
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
       91 
110 
     | 
    
         
             
              if !File.zero?(filename)
         
     | 
| 
       92 
111 
     | 
    
         
             
                line_ending = ALineEnding.parse(
         
     | 
| 
       93 
112 
     | 
    
         
             
                  filename,
         
     | 
| 
       94 
     | 
    
         
            -
                  LineDetector. 
     | 
| 
      
 113 
     | 
    
         
            +
                  LineDetector.report_of_file(filename)
         
     | 
| 
       95 
114 
     | 
    
         
             
                  )
         
     | 
| 
       96 
115 
     | 
    
         | 
| 
       97 
116 
     | 
    
         
             
                line_ending_difference = line_ending.violate?(rules)
         
     | 
    
        data/lib/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: '0.1'
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Pennebaker
         
     | 
| 
         @@ -30,14 +30,14 @@ dependencies: 
     | 
|
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - ~>
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '0. 
     | 
| 
      
 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. 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0.3'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |