fc 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e7b88105401854043cd1c4a76da52e2ba332065ed00ef9f4a660d33feff32d34
4
+ data.tar.gz: 5c5758f2fb01f64b3f9f3d2a1e1cf2ac9b7a6557701dc1a261d83c8a00acaffb
5
+ SHA512:
6
+ metadata.gz: 2e9a67aa38e2e50f2971a898184c3e649a31234920601d9c0caa08fd2e2c2209945a6e32c3b0415f02618202ccac3759c4a65accf8b1cd4eaed9277bd85a4ac7
7
+ data.tar.gz: 43f8a319c2ef28b5c068e155413b65378eba1ef673e3b556534f494615755f634a817cd4e7ed2766ea9cd78f1ed2c636ef3e8f162810cd755be00efba3a2dba3
@@ -0,0 +1,5 @@
1
+ continue
2
+ fc
3
+ continue
4
+ Dir.each_child(path) do |f| puts f end
5
+ Dir.each_child(path)
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,20 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Metrics/MethodLength:
11
+ Max: 20
12
+
13
+ Layout/MultilineMethodCallIndentation:
14
+ EnforcedStyle: indented
15
+
16
+ Metrics/BlockLength:
17
+ ExcludedMethods: ['describe', 'context']
18
+
19
+ RSpec/MultipleExpectations:
20
+ Max: 2
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in fc.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fc (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.1)
10
+ byebug (11.1.3)
11
+ coderay (1.1.3)
12
+ diff-lcs (1.4.4)
13
+ method_source (1.0.0)
14
+ parallel (1.19.2)
15
+ parser (2.7.1.5)
16
+ ast (~> 2.4.1)
17
+ pry (0.13.1)
18
+ coderay (~> 1.1)
19
+ method_source (~> 1.0)
20
+ rainbow (3.0.0)
21
+ rake (12.3.3)
22
+ regexp_parser (1.8.1)
23
+ rexml (3.2.4)
24
+ rspec (3.9.0)
25
+ rspec-core (~> 3.9.0)
26
+ rspec-expectations (~> 3.9.0)
27
+ rspec-mocks (~> 3.9.0)
28
+ rspec-core (3.9.2)
29
+ rspec-support (~> 3.9.3)
30
+ rspec-expectations (3.9.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-mocks (3.9.1)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-support (3.9.3)
37
+ rubocop (0.92.0)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.7.1.5)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.7)
42
+ rexml
43
+ rubocop-ast (>= 0.5.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 1.4.0, < 2.0)
46
+ rubocop-ast (0.7.1)
47
+ parser (>= 2.7.1.5)
48
+ rubocop-rspec (1.43.2)
49
+ rubocop (~> 0.87)
50
+ ruby-progressbar (1.10.1)
51
+ ruby_jard (0.3.1)
52
+ byebug (>= 9.1, < 12.0)
53
+ pry (~> 0.13.0)
54
+ tty-screen (~> 0.8.1)
55
+ tty-screen (0.8.1)
56
+ unicode-display_width (1.7.0)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ fc!
63
+ rake (~> 12.0)
64
+ rspec (~> 3.9)
65
+ rubocop (~> 0.92.0)
66
+ rubocop-rspec (~> 1.43, >= 1.43.2)
67
+ ruby_jard (~> 0.3.1)
68
+
69
+ BUNDLED WITH
70
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 alexneverpo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ # FC
2
+
3
+ A simple file catalog helper.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fc'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fc
20
+
21
+ ## Usage
22
+
23
+ TODO
24
+
25
+ ## License
26
+
27
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.requires << 'rubocop-rspec'
8
+
9
+ t.libs << 'test'
10
+ t.libs << 'lib'
11
+ t.test_files = FileList['test/**/*_test.rb']
12
+ end
13
+
14
+ task default: :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'fc'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/fc/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'fc'
7
+ spec.version = FC::VERSION
8
+ spec.authors = ['alexneverpo']
9
+ spec.email = ['alexneverpo@outlook.com']
10
+
11
+ spec.summary = 'A simple file catalog helper.'
12
+ spec.description = 'Simple but fast.'
13
+ spec.homepage = 'https://github.com/alexneverpo/fc'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'rspec', '~> 3.9'
33
+ spec.add_development_dependency 'rubocop', '~> 0.92.0'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.43', '>= 1.43.2'
35
+ spec.add_development_dependency 'ruby_jard', '~> 0.3.1'
36
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ class FC
6
+ module Error
7
+ class DirectoryDoesNotExist < StandardError; end
8
+ class FileDoesNotExist < StandardError; end
9
+ end
10
+
11
+ class File
12
+ attr_reader :path
13
+
14
+ def initialize(filepath)
15
+ raise Error::FileDoesNotExist unless ::File.file?(filepath)
16
+
17
+ @path = filepath
18
+ end
19
+
20
+ def name
21
+ @name ||= ::File.basename(path)
22
+ end
23
+
24
+ def ext
25
+ @ext ||= ::File.extname(path).delete!('.')
26
+ end
27
+ end
28
+
29
+ attr_reader :path, :files
30
+
31
+ extend Forwardable
32
+
33
+ def_delegators :@files, :size, :empty?, :first, :last, :clear
34
+
35
+ def initialize(dir_path, files: [])
36
+ raise Error::DirectoryDoesNotExist unless ::File.directory?(dir_path)
37
+
38
+ @path = dir_path
39
+ @files = files
40
+ end
41
+
42
+ def filter(recursive: false)
43
+ clear
44
+ return self unless block_given?
45
+
46
+ index(recursive: recursive) { |file| @files << file if yield(file) }
47
+ self
48
+ end
49
+
50
+ def index(recursive: false, &block)
51
+ indexed_files = []
52
+ Dir.each_child(path) do |filename|
53
+ filepath = ::File.join(path, filename)
54
+ if ::File.file?(filepath)
55
+ tmp = FC::File.new(filepath)
56
+ indexed_files << tmp
57
+ block.call(tmp)
58
+ elsif recursive
59
+ tmp_array = FC
60
+ .new(filepath)
61
+ .index(recursive: recursive, &block)
62
+ indexed_files.concat(tmp_array)
63
+ end
64
+ end
65
+ indexed_files
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FC
4
+ VERSION = '0.1.1'
5
+ end
@@ -0,0 +1,10 @@
1
+
2
+ #!/usr/bin/env bash
3
+
4
+ GIT_DIR=$(git rev-parse --git-dir)
5
+
6
+ echo "Installing hooks..."
7
+ # this command creates symlink to our pre-commit script
8
+ ln -s ../../scripts/pre_commit.bash $GIT_DIR/hooks/pre-commit
9
+ # ln -s ../../scripts/pre_push.bash $GIT_DIR/hooks/pre-push
10
+ echo "Done!"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Running pre-commit hook"
4
+ ./scripts/run_rubocop.bash
5
+
6
+ # $? stores exit value of the last command
7
+ if [ $? -ne 0 ]; then
8
+ echo "Code must be clean before commiting"
9
+ exit 1
10
+ fi
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ cd "${0%/*}/.."
6
+
7
+ echo "Running rubocop with auto-correct"
8
+ bundle exec rubocop -A
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - alexneverpo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.92.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.92.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.43'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.43.2
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.43'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.43.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: ruby_jard
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.3.1
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.3.1
75
+ description: Simple but fast.
76
+ email:
77
+ - alexneverpo@outlook.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".byebug_history"
83
+ - ".gitignore"
84
+ - ".rspec"
85
+ - ".rubocop.yml"
86
+ - ".travis.yml"
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - bin/console
93
+ - bin/setup
94
+ - example/a.txt
95
+ - example/b.txt
96
+ - example/folder/c.txt
97
+ - example/folder/d.json
98
+ - fc.gemspec
99
+ - lib/fc.rb
100
+ - lib/fc/version.rb
101
+ - scripts/install_hooks.bash
102
+ - scripts/pre_commit.bash
103
+ - scripts/run_rubocop.bash
104
+ homepage: https://github.com/alexneverpo/fc
105
+ licenses:
106
+ - MIT
107
+ metadata:
108
+ homepage_uri: https://github.com/alexneverpo/fc
109
+ source_code_uri: https://github.com/alexneverpo/fc
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 2.3.0
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubygems_version: 3.1.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: A simple file catalog helper.
129
+ test_files: []