colorls 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee46843601bfbf8dcda5a4cf90aec6208053193b
4
- data.tar.gz: efb20ac3426e5a0c4ebb0104ca1902559e41cda9
3
+ metadata.gz: bf8682c25dbecfcc9ceaac1d2c7f795327e9d463
4
+ data.tar.gz: 17073384fc2d7c650e745c33690de0a967e011b0
5
5
  SHA512:
6
- metadata.gz: 62cded3301273f822645fd013b63b71e6350d0599f7f4f521b7bfeb0c57fc6a292c698163d832f00949b9f91066889e810cb1fe7a0db85cce223e2871aca7331
7
- data.tar.gz: 4e79f2693b6272e4bd86f7c7190b5e226674d1126736f4e35eeafd55e48800cb505e28b8657d44339b6e44465f51d7541bdadc6fdf437f73d405f1db3f6f2342
6
+ metadata.gz: dd9f01a4a4366534770b5285e020e32e749392889a12442ac05904c4f6ab76b5913c8518bdd816bec2e2398796258e2225e71ed9a7f1685ca62892e2e82a768c
7
+ data.tar.gz: 863c44d9919e67f56552f8cdb5825ac41edb05902236737dfd8e3f711b9eeaed44e2e84940610ee718b71619aac5aeca1d58cb15057ab57763c0cf58c9c76d61
@@ -45,7 +45,7 @@ Metrics/ModuleLength:
45
45
  Max: 200
46
46
 
47
47
  Metrics/ClassLength:
48
- Max: 200
48
+ Max: 250
49
49
 
50
50
  Metrics/ParameterLists:
51
51
  Max: 10
@@ -91,4 +91,4 @@ Metrics/CyclomaticComplexity:
91
91
  # TODO -----------------------------------------------------------------
92
92
 
93
93
  Style/Documentation:
94
- Enabled: false
94
+ Enabled: false
@@ -19,7 +19,10 @@ script:
19
19
  - colorls -sf
20
20
  - colorls -1
21
21
  - colorls -r
22
+ - colorls -l
23
+ - colorls README.md
24
+ - colorls *
22
25
 
23
26
  install:
24
27
  - gem install bundler
25
- - bundle install
28
+ - bundle install
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at athityakumar@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Color LS
2
2
 
3
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](http://forthebadge.com)
4
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)
5
+
3
6
  [![Gem Version](https://badge.fury.io/rb/colorls.svg)](https://badge.fury.io/rb/colorls)
4
7
  [![Build Status](https://travis-ci.org/athityakumar/colorls.svg?branch=master)](https://travis-ci.org/athityakumar/colorls)
5
8
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=shields)](http://makeapullrequest.com)
@@ -9,6 +12,8 @@ A Ruby script that colorizes the `ls` output with color and icons. Here are the
9
12
 
10
13
  ![Example #1](readme/usage1.png)
11
14
 
15
+ *If you're interested in knowing the powerlevel9k configuration to get this prompt, have a look at [this gist](https://gist.github.com/athityakumar/1bd5e9e24cd2a1891565573a893993eb).*
16
+
12
17
  # Table of contents
13
18
 
14
19
  - [Usage](#usage)
@@ -70,6 +75,8 @@ A Ruby script that colorizes the `ls` output with color and icons. Here are the
70
75
 
71
76
  4. Start using `colorls` :tada:
72
77
 
78
+ 5. Have a look at [Recommended configurations](#recommended-configurations).
79
+
73
80
  # Recommended configurations
74
81
 
75
82
  [(Back to top)](#table-of-contents)
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'colorize'
25
25
  spec.add_runtime_dependency 'facets'
26
26
  spec.add_runtime_dependency 'ruby-terminfo'
27
+ spec.add_runtime_dependency 'filesize'
27
28
 
28
29
  spec.add_development_dependency 'bundler', '~> 1.15'
29
30
  spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'rspec'
31
32
  spec.add_development_dependency 'rubocop'
33
+ spec.add_development_dependency 'diffy'
32
34
  end
@@ -2,6 +2,8 @@ require 'colorize'
2
2
  require 'yaml'
3
3
  require 'facets'
4
4
  require 'terminfo'
5
+ require 'etc'
6
+ require 'filesize'
5
7
 
6
8
  require 'colorls/core'
7
9
  require 'colorls/flags'
@@ -1,7 +1,7 @@
1
1
  module ColorLS
2
2
  class Core
3
3
  def initialize(input=nil, all: false, report: false, sort: false, show: false,
4
- one_per_line: false)
4
+ one_per_line: false, long: false)
5
5
  @input = input || Dir.pwd
6
6
  @count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
7
7
  @all = all
@@ -9,6 +9,7 @@ module ColorLS
9
9
  @sort = sort
10
10
  @show = show
11
11
  @one_per_line = one_per_line
12
+ @long = long
12
13
  @screen_width = ::TermInfo.screen_size.last
13
14
 
14
15
  init_contents
@@ -17,11 +18,15 @@ module ColorLS
17
18
  end
18
19
 
19
20
  def ls
20
- @contents = chunkify
21
- @max_widths = @contents.transpose.map { |c| c.map(&:length).max }
22
- @contents.each { |chunk| ls_line(chunk) }
23
- print "\n"
24
- display_report if @report
21
+ if @contents.empty?
22
+ print "Nothing to show here\n".colorize(:yellow)
23
+ else
24
+ @contents = chunkify
25
+ @max_widths = @contents.transpose.map { |c| c.map(&:length).max }
26
+ @contents.each { |chunk| ls_line(chunk) }
27
+ print "\n"
28
+ display_report if @report
29
+ end
25
30
 
26
31
  true
27
32
  end
@@ -29,13 +34,43 @@ module ColorLS
29
34
  private
30
35
 
31
36
  def init_contents
32
- @contents = Dir.entries(@input) - %w[. ..]
37
+ @contents = if Dir.exist?(@input)
38
+ Dir.entries(@input) - %w[. ..]
39
+ else
40
+ [@input]
41
+ end
33
42
 
34
43
  @contents.keep_if { |x| !x.start_with? '.' } unless @all
35
44
  filter_contents if @show
36
45
  sort_contents if @sort
37
46
 
38
47
  @total_content_length = @contents.length
48
+
49
+ return unless @long
50
+ init_user_lengths
51
+ init_group_lengths
52
+ end
53
+
54
+ def init_user_lengths
55
+ @userlength = @contents.map do |c|
56
+ begin
57
+ user = Etc.getpwuid(File.stat("#{@input}/#{c}").uid).name
58
+ rescue ArgumentError
59
+ user = File.stat("#{@input}/#{c}").uid
60
+ end
61
+ user.to_s.length
62
+ end.max
63
+ end
64
+
65
+ def init_group_lengths
66
+ @grouplength = @contents.map do |c|
67
+ begin
68
+ group = Etc.getgrgid(File.stat("#{@input}/#{c}").gid).name
69
+ rescue ArgumentError
70
+ group = File.stat("#{@input}/#{c}").gid
71
+ end
72
+ group.to_s.length
73
+ end.max
39
74
  end
40
75
 
41
76
  def filter_contents
@@ -80,7 +115,7 @@ module ColorLS
80
115
  end
81
116
 
82
117
  def chunkify
83
- return @contents.zip if @one_per_line
118
+ return @contents.zip if @one_per_line || @long
84
119
 
85
120
  chunk_size = @contents.count
86
121
 
@@ -116,12 +151,64 @@ module ColorLS
116
151
  .colorize(:white)
117
152
  end
118
153
 
154
+ def mode_info(stat)
155
+ mode = ''
156
+ stat.mode.to_s(2).rjust(16, '0')[-9..-1].each_char.with_index do |c, i|
157
+ if c == '0'
158
+ mode += '-'.colorize(:gray)
159
+ else
160
+ case (i % 3)
161
+ when 0 then mode += 'r'.colorize(:yellow)
162
+ when 1 then mode += 'w'.colorize(:magenta)
163
+ when 2 then mode += 'x'.colorize(:cyan)
164
+ end
165
+ end
166
+ end
167
+ mode
168
+ end
169
+
170
+ def user_info(stat)
171
+ begin
172
+ user = Etc.getpwuid(stat.uid).name
173
+ rescue ArgumentError
174
+ user = stat.uid
175
+ end
176
+ user = user.to_s.ljust(@userlength, ' ')
177
+ user.colorize(:green) if user == Etc.getlogin
178
+ end
179
+
180
+ def group_info(stat)
181
+ begin
182
+ group = Etc.getgrgid(stat.gid).name
183
+ rescue ArgumentError
184
+ group = stat.gid
185
+ end
186
+ group.to_s.ljust(@grouplength, ' ')
187
+ end
188
+
189
+ def size_info(stat)
190
+ size = Filesize.from("#{stat.size} B").pretty.split(' ')
191
+ "#{size[0][0..-4].rjust(3,' ')} #{size[1].ljust(3,' ')}"
192
+ end
193
+
194
+ def mtime_info(stat)
195
+ mtime = stat.mtime.asctime
196
+ mtime = mtime.colorize(:yellow) if Time.now - stat.mtime < 24 * 60 * 60
197
+ mtime = mtime.colorize(:green) if Time.now - stat.mtime < 60 * 60
198
+ mtime
199
+ end
200
+
201
+ def long_info(content)
202
+ stat = File.stat("#{@input}/#{content}")
203
+ "#{mode_info(stat)} #{user_info(stat)} #{group_info(stat)} #{size_info(stat)} #{mtime_info(stat)} "
204
+ end
205
+
119
206
  def fetch_string(content, key, color, increment)
120
207
  @count[increment] += 1
121
208
  value = increment == :folders ? @folders[key] : @files[key]
122
209
  logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }
123
210
 
124
- "#{logo} #{content}".colorize(color)
211
+ "#{@long ? long_info(content) : ''} #{logo.colorize(color)} #{content.colorize(color)}"
125
212
  end
126
213
 
127
214
  def load_from_yaml(filename, aliase=false)
@@ -153,6 +240,10 @@ module ColorLS
153
240
  return [key, :blue, :folders]
154
241
  end
155
242
 
243
+ key = content.downcase.to_sym
244
+
245
+ return [key, :green, :recognized_files] if @file_keys.include?(key)
246
+
156
247
  key = content.split('.').last.downcase.to_sym
157
248
 
158
249
  return %i[file yellow unrecognized_files] unless @all_files.include?(key)
@@ -7,7 +7,8 @@ module ColorLS
7
7
  sort: fetch_sort_opts,
8
8
  all: flag_given?(%w[-a --all]),
9
9
  report: flag_given?(%w[-r --report]),
10
- one_per_line: flag_given?(%w[-1])
10
+ one_per_line: flag_given?(%w[-1]),
11
+ long: flag_given?(%w[-l --long])
11
12
  }
12
13
 
13
14
  return if @opts[:show].nil? || @opts[:sort].nil?
@@ -19,7 +20,7 @@ module ColorLS
19
20
  return Core.new(@opts).ls if @args.empty?
20
21
 
21
22
  @args.each do |path|
22
- next STDERR.puts "\n Specified directory '#{path}' doesn't exist.".colorize(:red) unless Dir.exist?(path)
23
+ next STDERR.puts "\n Specified path '#{path}' doesn't exist.".colorize(:red) unless File.exist?(path)
23
24
  Core.new(path, @opts).ls
24
25
  end
25
26
  end
@@ -1,3 +1,3 @@
1
1
  module ColorLS
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
@@ -25,13 +25,13 @@ png: image
25
25
  svg: image
26
26
  jar: java
27
27
  properties: json
28
+ license: md
28
29
  markdown: md
29
30
  mkd: md
30
31
  rdoc: md
31
32
  readme: md
32
- license: md
33
- pptx: ppt
34
33
  gslides: ppt
34
+ pptx: ppt
35
35
  pyc: py
36
36
  rdata: r
37
37
  rds: r
@@ -42,15 +42,15 @@ lock: rb
42
42
  procfile: rb
43
43
  rakefile: rb
44
44
  rspec: rb
45
- rspec_status: rb
46
45
  rspec_parallel: rb
46
+ rspec_status: rb
47
47
  ru: rb
48
48
  bash: shell
49
- bashrc: shell
50
49
  bash_history: shell
51
50
  bash_profile: shell
52
- sh: shell
51
+ bashrc: shell
53
52
  fish: shell
53
+ sh: shell
54
54
  zsh: shell
55
55
  zsh-theme: shell
56
56
  zshrc: shell
@@ -1,60 +1,63 @@
1
- ai: "\ue7b4"
2
- android: "\ue70e"
3
- apple: "\uf179"
4
- audio: "\uf001"
5
- avro: "\ue60b"
6
- c: "\ue61e"
7
- clj: "\ue768"
8
- coffee: "\uf0f4"
9
- conf: "\ue615"
10
- cpp: "\ue61d"
11
- css: "\ue749"
12
- d: "\ue7af"
13
- dart: "\ue798"
14
- db: "\uf1c0"
15
- diff: "\uf440"
16
- doc: "\uf1c2"
17
- ebook: "\ue28b"
18
- erl: "\ue7b1"
19
- file: "\uf15b"
20
- font: "\uf031"
21
- gform: "\uf298"
22
- git: "\uf1d3"
23
- go: "\ue626"
24
- hs: "\ue777"
25
- html: "\uf13b"
26
- image: "\uf1c5"
27
- iml: "\ue7b5"
28
- java: "\ue204"
29
- js: "\ue74e"
30
- json: "\ue60b"
31
- less: "\ue758"
32
- lua: "\ue620"
33
- md: "\uf48a"
34
- mustache: "\ue60f"
35
- npmignore: "\ue71e"
36
- pdf: "\uf1c1"
37
- php: "\ue73d"
38
- pl: "\ue769"
39
- ppt: "\uf1c4"
40
- psd: "\ue7b8"
41
- py: "\ue606"
42
- r: "\uf25d"
43
- rb: "\ue21e"
44
- rdb: "\ue76d"
45
- rss: "\uf09e"
46
- scala: "\ue737"
47
- shell: "\uf489"
48
- sqlite3: "\ue7c4"
49
- styl: "\ue600"
50
- tex: "\ue600"
51
- ts: "\ue628"
52
- twig: "\ue61c"
53
- txt: "\uf15c"
54
- video: "\uf03d"
55
- vim: "\ue62b"
56
- windows: "\uf17a"
57
- xls: "\uf1c3"
58
- xml: "\ue619"
59
- yml: "\uf481"
60
- zip: "\uf410"
1
+ ai: "\ue7b4"
2
+ android: "\ue70e"
3
+ apple: "\uf179"
4
+ audio: "\uf001"
5
+ avro: "\ue60b"
6
+ c: "\ue61e"
7
+ clj: "\ue768"
8
+ coffee: "\uf0f4"
9
+ conf: "\ue615"
10
+ cpp: "\ue61d"
11
+ css: "\ue749"
12
+ d: "\ue7af"
13
+ dart: "\ue798"
14
+ db: "\uf1c0"
15
+ diff: "\uf440"
16
+ doc: "\uf1c2"
17
+ ebook: "\ue28b"
18
+ epub: "\ue28a"
19
+ erl: "\ue7b1"
20
+ file: "\uf15b"
21
+ font: "\uf031"
22
+ gform: "\uf298"
23
+ git: "\uf1d3"
24
+ go: "\ue626"
25
+ gruntfile.js: "\ue74c"
26
+ hs: "\ue777"
27
+ html: "\uf13b"
28
+ image: "\uf1c5"
29
+ iml: "\ue7b5"
30
+ java: "\ue204"
31
+ js: "\ue74e"
32
+ json: "\ue60b"
33
+ less: "\ue758"
34
+ log: "\uf18d"
35
+ lua: "\ue620"
36
+ md: "\uf48a"
37
+ mustache: "\ue60f"
38
+ npmignore: "\ue71e"
39
+ pdf: "\uf1c1"
40
+ php: "\ue73d"
41
+ pl: "\ue769"
42
+ ppt: "\uf1c4"
43
+ psd: "\ue7b8"
44
+ py: "\ue606"
45
+ r: "\uf25d"
46
+ rb: "\ue21e"
47
+ rdb: "\ue76d"
48
+ rss: "\uf09e"
49
+ scala: "\ue737"
50
+ shell: "\uf489"
51
+ sqlite3: "\ue7c4"
52
+ styl: "\ue600"
53
+ tex: "\ue600"
54
+ ts: "\ue628"
55
+ twig: "\ue61c"
56
+ txt: "\uf15c"
57
+ video: "\uf03d"
58
+ vim: "\ue62b"
59
+ windows: "\uf17a"
60
+ xls: "\uf1c3"
61
+ xml: "\ue619"
62
+ yml: "\uf481"
63
+ zip: "\uf410"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Athitya Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: filesize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: diffy
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description:
112
140
  email:
113
141
  - athityakumar@gmail.com
@@ -119,6 +147,7 @@ files:
119
147
  - ".gitignore"
120
148
  - ".rubocop.yml"
121
149
  - ".travis.yml"
150
+ - CODE_OF_CONDUCT.md
122
151
  - CONTRIBUTING.md
123
152
  - Gemfile
124
153
  - LICENSE.md