extension_lister 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de536631a50c572018aeed24f4e9769a91f82539
4
+ data.tar.gz: e72b756db8203460ef554770e652479ffaa75273
5
+ SHA512:
6
+ metadata.gz: f8daafe01eaacc0f7e8fd6c06d025b6e6f38f88799c7eb6702c2031b8087790c7f1defcb83fe588fc93ff328d3ca28c34c3ebc591a9975319aa5e87167969809
7
+ data.tar.gz: 85737064de7fd62ee7917febaa0669f5d006b4c93dac5a1d97322bca4a9518c456a6dbfc54211d78049d830cc82035afda58e3dd2235be97f1087eacd6c01895
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ # Custom generated files
19
+ .ruby-version
data/.rubocop.yml ADDED
@@ -0,0 +1,96 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+ AllCops:
3
+ Include:
4
+ - Gemfile
5
+ - Rakefile
6
+ - bin/*
7
+ - extension_lister.gemspec
8
+ - lib/**/*.rb
9
+ - test/**/*.rb
10
+ # Avoid long parameter lists
11
+ ParameterLists:
12
+ Max: 5
13
+ CountKeywordArgs: true
14
+
15
+ MethodLength:
16
+ CountComments: false
17
+ Max: 15
18
+
19
+ # Avoid more than `Max` levels of nesting.
20
+ BlockNesting:
21
+ Max: 4
22
+
23
+ # Align with the style guide.
24
+ CollectionMethods:
25
+ PreferredMethods:
26
+ collect: 'map'
27
+ inject: 'reduce'
28
+ find: 'detect'
29
+ find_all: 'select'
30
+
31
+ # Do not force public/protected/private keyword to be indented at the same
32
+ # level as the def keyword. My personal preference is to outdent these keywords
33
+ # because I think when scanning code it makes it easier to identify the
34
+ # sections of code and visually separate them. When the keyword is at the same
35
+ # level I think it sort of blends in with the def keywords and makes it harder
36
+ # to scan the code and see where the sections are.
37
+ AccessModifierIndentation:
38
+ Enabled: false
39
+
40
+ # Limit line length
41
+ LineLength:
42
+ Enabled: false
43
+
44
+ # Disable documentation checking until a class needs to be documented once
45
+ Documentation:
46
+ Enabled: false
47
+
48
+ # Enforce Ruby 1.8-compatible hash syntax
49
+ HashSyntax:
50
+ Enabled: true
51
+
52
+ # No spaces inside hash literals
53
+ SpaceInsideHashLiteralBraces:
54
+ EnforcedStyle: no_space
55
+
56
+ # Allow dots at the end of lines
57
+ DotPosition:
58
+ Enabled: false
59
+
60
+ # Don't require magic comment at the top of every file
61
+ Encoding:
62
+ Enabled: false
63
+
64
+ # Enforce outdenting of access modifiers (i.e. public, private, protected)
65
+ AccessModifierIndentation:
66
+ EnforcedStyle: outdent
67
+
68
+ EmptyLinesAroundAccessModifier:
69
+ Enabled: true
70
+
71
+ # Align ends correctly
72
+ EndAlignment:
73
+ AlignWith: variable
74
+
75
+ # Indentation of when/else
76
+ CaseIndentation:
77
+ IndentWhenRelativeTo: end
78
+ IndentOneStep: false
79
+
80
+ DoubleNegation:
81
+ Enabled: false
82
+
83
+ PercentLiteralDelimiters:
84
+ PreferredDelimiters:
85
+ '%': ()
86
+ '%i': ()
87
+ '%q': ()
88
+ '%Q': ()
89
+ '%r': '{}'
90
+ '%s': ()
91
+ '%w': '[]'
92
+ '%W': '[]'
93
+ '%x': ()
94
+
95
+ StringLiterals:
96
+ EnforcedStyle: double_quotes
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ # see: http://rubydoc.info/gems/yard/file/README.md
2
+ --no-private --protected lib/**/*.rb - README.md LICENSE.txt
data/CHANGELOGS.md ADDED
@@ -0,0 +1,5 @@
1
+ ### Changelogs
2
+
3
+ #### 0.1.0
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in valid_filename.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ guard 'minitest' do
4
+ watch(%r|^test/(.*)\/?test_(.*)\.rb|)
5
+ watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
6
+ watch(%r|^test/test_helper\.rb|) { "test" }
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Burin Choomnuan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ ## ExtensionLister
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/extension_lister.svg)][gem]
4
+ [![Dependency Status](https://gemnasium.com/agilecreativity/extension_lister.png)][gemnasium]
5
+ [![Code Climate](https://codeclimate.com/github/agilecreativity/extension_lister.png)][codeclimate]
6
+
7
+ [gem]: http://badge.fury.io/rb/extension_lister
8
+ [gemnasium]: https://gemnasium.com/agilecreativity/extension_lister
9
+ [codeclimate]: https://codeclimate.com/github/agilecreativity/extension_lister
10
+
11
+ ### Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'extension_lister'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install extension_lister
24
+
25
+ ### Usage
26
+
27
+ - List all extension from a current directory (recursively)
28
+
29
+ ```
30
+ extension_lister
31
+ ```
32
+
33
+ - List all extension from a given directory
34
+
35
+ ```
36
+ extension_lister -b ~/Downloads
37
+ ```
38
+
39
+ ### Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ [thor]: https://github.com/erikhuda/thor
48
+ [minitest]: https://github.com/seattlerb/minitest
49
+ [guard]: https://github.com/guard/guard
50
+ [yard]: https://github.com/lsegal/yard
51
+ [pry]: https://github.com/pry/pry
52
+ [rubocop]: https://github.com/bbatsov/rubocop
53
+ [grit]: https://github.com/mojombo/grit
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ project_name = 'extension_lister'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "lib/#{project_name}"
7
+ t.test_files = FileList["test/lib/#{project_name}/test_*.rb"]
8
+ t.verbose = true
9
+ end
10
+
11
+ task default: [:test, :rubocop]
12
+ task :pry do
13
+ require 'pry'
14
+ require 'awesome_print'
15
+ require_relative 'lib/extension_lister'
16
+ include ExtensionLister
17
+ ARGV.clear
18
+ Pry.start
19
+ end
20
+
21
+ require 'rubocop/rake_task'
22
+ desc 'Run RuboCop on the lib directory'
23
+ RuboCop::RakeTask.new(:rubocop) do |task|
24
+ task.patterns = ['lib/**/*.rb']
25
+ # only show the files with failures
26
+ task.formatters = ['files']
27
+ # don't abort rake on failure
28
+ task.fail_on_error = false
29
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/extension_lister'
3
+ include ExtensionLister
4
+ if ARGV.empty?
5
+ ExtensionLister::CLI.start %w[list --base-dir .]
6
+ else
7
+ ExtensionLister::CLI.start(%w[list].concat(ARGV))
8
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'extension_lister/version'
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'extension_lister'
7
+ spec.version = ExtensionLister::VERSION
8
+ spec.authors = ['Burin Choomnuan']
9
+ spec.email = ['agilecreativity@gmail.com']
10
+ spec.summary = %q{List unique file extensions from any given directory recursively}
11
+ spec.description = %q{List unique file extensions from any starting directory recursively}
12
+ spec.homepage = 'https://github.com/agilecreativity/extension_lister'
13
+ spec.license = 'MIT'
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+ spec.add_runtime_dependency 'thor', '~> 0.19'
19
+ spec.add_development_dependency 'awesome_print', '~> 1.2'
20
+ spec.add_development_dependency 'bundler', '~> 1.5'
21
+ spec.add_development_dependency 'gem-ctags', '~> 1.0'
22
+ spec.add_development_dependency 'guard', '~> 2.6'
23
+ spec.add_development_dependency 'guard-minitest', '~> 2.2'
24
+ spec.add_development_dependency 'minitest', '~> 5.3'
25
+ spec.add_development_dependency 'minitest-spec-context', '~> 0.0.3'
26
+ spec.add_development_dependency 'pry', '~> 0.9'
27
+ spec.add_development_dependency 'rake', '~> 10.1'
28
+ spec.add_development_dependency 'rubocop', '~> 0.23'
29
+ spec.add_development_dependency 'yard', '~> 0.8'
30
+ end
@@ -0,0 +1,31 @@
1
+ require 'thor'
2
+ module ExtensionLister
3
+ class CLI < Thor
4
+ desc 'list', 'List all unique extensions'
5
+ method_option "base_dir",
6
+ aliases: "-b",
7
+ desc: "Base directory",
8
+ default: File.expand_path(".")
9
+
10
+ method_option 'version',
11
+ aliases: '-v',
12
+ desc: 'Display version number'
13
+ def list
14
+ opts = options.symbolize_keys
15
+ if opts[:version]
16
+ puts "You are using ExtensionLister version #{ExtensionLister::VERSION}"
17
+ exit
18
+ end
19
+ puts list_extensions(opts[:base_dir])
20
+ end
21
+
22
+ private
23
+
24
+ def list_extensions(base_dir = ".")
25
+ extensions = Dir.glob(File.join(File.expand_path(base_dir), "**/*")).reduce([]) do |exts, file|
26
+ exts << File.extname(file)
27
+ end
28
+ extensions.sort.uniq.delete_if { |e| e == "" }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ class Hash
2
+ # File activesupport/lib/active_support/core_ext/hash/keys.rb
3
+ #
4
+ # hash = { name: 'Rob', age: '28' }
5
+ # hash.transform_keys{ |key| key.to_s.upcase }
6
+ # => { "NAME" => "Rob", "AGE" => "28" }
7
+ def transform_keys
8
+ result = {}
9
+ each_key do |key|
10
+ result[yield(key)] = self[key]
11
+ end
12
+ result
13
+ end
14
+
15
+ def transform_keys!(&block)
16
+ keys.each do |key|
17
+ value = delete(key)
18
+ self[yield(key)] = value.is_a?(Hash) ? value.transform_keys!(&block) : value
19
+ end
20
+ self
21
+ end
22
+
23
+ # hash = { 'name' => 'Rob', 'age' => '28' }
24
+ # hash.symbolize_keys
25
+ # => { name: "Rob", age: "28" }
26
+ def symbolize_keys
27
+ transform_keys { |key| key.to_sym rescue key }
28
+ end
29
+
30
+ # File activesupport/lib/active_support/core_ext/hash/keys.rb, line 135
31
+ def symbolize_keys!
32
+ transform_keys! { |key| key.to_sym rescue key }
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module ExtensionLister
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ require_relative 'extension_lister/version'
2
+ require_relative 'extension_lister/cli'
3
+ require_relative 'extension_lister/core_ext/hash/keys'
4
+ include ExtensionLister
@@ -0,0 +1,8 @@
1
+ require_relative '../../test_helper'
2
+ describe ExtensionLister do
3
+ context '#dummy_test' do
4
+ it 'passes the simple test' do
5
+ 'test string'.wont_be_nil
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
4
+ require 'minitest-spec-context'
5
+ require 'pry'
6
+ require 'awesome_print'
7
+ require_relative '../lib/extension_lister'
8
+ include ExtensionLister
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: extension_lister
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Burin Choomnuan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gem-ctags
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-spec-context
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.3
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.9'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.9'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '10.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '10.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.23'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.23'
167
+ - !ruby/object:Gem::Dependency
168
+ name: yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.8'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.8'
181
+ description: List unique file extensions from any starting directory recursively
182
+ email:
183
+ - agilecreativity@gmail.com
184
+ executables:
185
+ - extension_lister
186
+ extensions: []
187
+ extra_rdoc_files: []
188
+ files:
189
+ - ".gitignore"
190
+ - ".rubocop.yml"
191
+ - ".yardopts"
192
+ - CHANGELOGS.md
193
+ - Gemfile
194
+ - Guardfile
195
+ - LICENSE
196
+ - README.md
197
+ - Rakefile
198
+ - bin/extension_lister
199
+ - extension_lister.gemspec
200
+ - lib/extension_lister.rb
201
+ - lib/extension_lister/cli.rb
202
+ - lib/extension_lister/core_ext/hash/keys.rb
203
+ - lib/extension_lister/version.rb
204
+ - test/lib/extension_lister/test_extension_lister.rb
205
+ - test/test_helper.rb
206
+ homepage: https://github.com/agilecreativity/extension_lister
207
+ licenses:
208
+ - MIT
209
+ metadata: {}
210
+ post_install_message:
211
+ rdoc_options: []
212
+ require_paths:
213
+ - lib
214
+ required_ruby_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ requirements: []
225
+ rubyforge_project:
226
+ rubygems_version: 2.2.2
227
+ signing_key:
228
+ specification_version: 4
229
+ summary: List unique file extensions from any given directory recursively
230
+ test_files:
231
+ - test/lib/extension_lister/test_extension_lister.rb
232
+ - test/test_helper.rb
233
+ has_rdoc: