diff --git a/Gemfile b/Gemfile index f139bb6..eb0890b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in koine-file_system.gemspec +# Specify your gem's dependencies in koine-filesystem.gemspec gemspec gem 'coveralls', '~> 0.8.23' diff --git a/README.md b/README.md index eff9dd6..9c60631 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Koine::FileSystem +# Koine::Filesystem This will [hopefully] be a file system abstraction as good as the [PHP League's Flysystem](https://github.com/thephpleague/flysystem). @@ -11,7 +11,7 @@ This will [hopefully] be a file system abstraction as good as the [PHP League's Add this line to your application's Gemfile: ```ruby -gem 'koine-file_system' +gem 'koine-filesystem' ``` And then execute: @@ -20,7 +20,7 @@ And then execute: Or install it yourself as: - $ gem install koine-file_system + $ gem install koine-filesystem ## Usage @@ -43,4 +43,4 @@ The gem is available as open source under the terms of the [MIT License](https:/ ## Code of Conduct -Everyone interacting in the Koine::FileSystem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mjacobus/koine-file_system/blob/master/CODE_OF_CONDUCT.md). +Everyone interacting in the Koine::Filesystem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mjacobus/koine-file_system/blob/master/CODE_OF_CONDUCT.md). diff --git a/bin/console b/bin/console index 8915695..e785cfb 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "koine/file_system" +require "koine/filesystem" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. diff --git a/koine-file_system.gemspec b/koine-filesystem.gemspec similarity index 89% rename from koine-file_system.gemspec rename to koine-filesystem.gemspec index 8eb63e4..1478e38 100644 --- a/koine-file_system.gemspec +++ b/koine-filesystem.gemspec @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative 'lib/koine/file_system/version' +require_relative 'lib/koine/filesystem/version' Gem::Specification.new do |spec| - spec.name = 'koine-file_system' - spec.version = Koine::FileSystem::VERSION + spec.name = 'koine-filesystem' + spec.version = Koine::Filesystem::VERSION spec.authors = ['Marcelo Jacobus'] spec.email = ['marcelo.jacobus@gmail.com'] diff --git a/lib/koine/file_system.rb b/lib/koine/file_system.rb deleted file mode 100644 index 07fa38a..0000000 --- a/lib/koine/file_system.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require 'koine/file_system/version' -require 'koine/file_system/file_system' -require 'koine/file_system/path_sanitizer' -require 'koine/file_system/adapters/base' -require 'koine/file_system/adapters/local' - -module Koine - module FileSystem - class Error < StandardError; end - class FileNotFound < Error; end - end -end diff --git a/lib/koine/filesystem.rb b/lib/koine/filesystem.rb new file mode 100644 index 0000000..0427902 --- /dev/null +++ b/lib/koine/filesystem.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'koine/filesystem/version' +require 'koine/filesystem/filesystem' +require 'koine/filesystem/path_sanitizer' +require 'koine/filesystem/adapters/base' +require 'koine/filesystem/adapters/local' + +module Koine + module Filesystem + class Error < StandardError; end + class FileNotFound < Error; end + end +end diff --git a/lib/koine/file_system/adapters/base.rb b/lib/koine/filesystem/adapters/base.rb similarity index 99% rename from lib/koine/file_system/adapters/base.rb rename to lib/koine/filesystem/adapters/base.rb index 0534368..ae00cd3 100644 --- a/lib/koine/file_system/adapters/base.rb +++ b/lib/koine/filesystem/adapters/base.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Koine - module FileSystem + module Filesystem module Adapters # rubocop:disable Lint/UnusedMethodArgument class Base diff --git a/lib/koine/file_system/adapters/local.rb b/lib/koine/filesystem/adapters/local.rb similarity index 99% rename from lib/koine/file_system/adapters/local.rb rename to lib/koine/filesystem/adapters/local.rb index 7d97ccb..1089cab 100644 --- a/lib/koine/file_system/adapters/local.rb +++ b/lib/koine/filesystem/adapters/local.rb @@ -3,7 +3,7 @@ require 'fileutils' module Koine - module FileSystem + module Filesystem module Adapters # rubocop:disable Lint/UnusedMethodArgument class Local < Base diff --git a/lib/koine/file_system/file_system.rb b/lib/koine/filesystem/filesystem.rb similarity index 97% rename from lib/koine/file_system/file_system.rb rename to lib/koine/filesystem/filesystem.rb index 02c37a2..63af93f 100644 --- a/lib/koine/file_system/file_system.rb +++ b/lib/koine/filesystem/filesystem.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true module Koine - module FileSystem + module Filesystem # Inspired on # https://flysystem.thephpleague.com/v1/docs/usage/filesystem-api/ - class FileSystem + class Filesystem def initialize(adapter) @adapter = adapter end diff --git a/lib/koine/file_system/path_sanitizer.rb b/lib/koine/filesystem/path_sanitizer.rb similarity index 90% rename from lib/koine/file_system/path_sanitizer.rb rename to lib/koine/filesystem/path_sanitizer.rb index 6730172..56de5e0 100644 --- a/lib/koine/file_system/path_sanitizer.rb +++ b/lib/koine/filesystem/path_sanitizer.rb @@ -3,7 +3,7 @@ require 'fileutils' module Koine - module FileSystem + module Filesystem class PathSanitizer def sanitize(path) path.to_s.gsub('/../', '/').gsub(%r{\.?\./}, '') diff --git a/lib/koine/file_system/version.rb b/lib/koine/filesystem/version.rb similarity index 79% rename from lib/koine/file_system/version.rb rename to lib/koine/filesystem/version.rb index be7ce49..1034f81 100644 --- a/lib/koine/file_system/version.rb +++ b/lib/koine/filesystem/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Koine - module FileSystem + module Filesystem VERSION = '0.1.0' end end diff --git a/spec/koine/file_system/adapters/base_spec.rb b/spec/koine/filesystem/adapters/base_spec.rb similarity index 97% rename from spec/koine/file_system/adapters/base_spec.rb rename to spec/koine/filesystem/adapters/base_spec.rb index d44c10a..e4def9d 100644 --- a/spec/koine/file_system/adapters/base_spec.rb +++ b/spec/koine/filesystem/adapters/base_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Koine::FileSystem::Adapters::Base do +RSpec.describe Koine::Filesystem::Adapters::Base do subject(:adapter) { described_class.new } let(:path) { 'foo' } diff --git a/spec/koine/file_system/adapters/local_spec.rb b/spec/koine/filesystem/adapters/local_spec.rb similarity index 97% rename from spec/koine/file_system/adapters/local_spec.rb rename to spec/koine/filesystem/adapters/local_spec.rb index 7ad4a98..0ef4e2e 100644 --- a/spec/koine/file_system/adapters/local_spec.rb +++ b/spec/koine/filesystem/adapters/local_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'digest' -RSpec.describe Koine::FileSystem::Adapters::Local do +RSpec.describe Koine::Filesystem::Adapters::Local do let(:adapter) { described_class.new(root: FIXTURES_PATH) } before do @@ -15,7 +15,7 @@ expect do adapter.read('unexisting') end.to raise_error( - Koine::FileSystem::FileNotFound, + Koine::Filesystem::FileNotFound, 'File not found: unexisting' ) end @@ -186,7 +186,7 @@ map = result.map { |r| [r[:path], r[:timestamp].class.to_s] }.sort expected = [ - ['folder1', 'Time'], + %w[folder1 Time], ['sample.png', 'Time'], ['sample.txt', 'Time'] ].sort diff --git a/spec/koine/file_system/file_system_spec.rb b/spec/koine/filesystem/filesystem_spec.rb similarity index 98% rename from spec/koine/file_system/file_system_spec.rb rename to spec/koine/filesystem/filesystem_spec.rb index 18f745f..b10a6ff 100644 --- a/spec/koine/file_system/file_system_spec.rb +++ b/spec/koine/filesystem/filesystem_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Koine::FileSystem::FileSystem do +RSpec.describe Koine::Filesystem::Filesystem do subject(:fs) { described_class.new(adapter) } let(:adapter) { instance_double(described_class) } diff --git a/spec/koine/file_system/path_sanitizer_spec.rb b/spec/koine/filesystem/path_sanitizer_spec.rb similarity index 87% rename from spec/koine/file_system/path_sanitizer_spec.rb rename to spec/koine/filesystem/path_sanitizer_spec.rb index aabaad4..d0cf2b9 100644 --- a/spec/koine/file_system/path_sanitizer_spec.rb +++ b/spec/koine/filesystem/path_sanitizer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Koine::FileSystem::PathSanitizer do +RSpec.describe Koine::Filesystem::PathSanitizer do subject(:sanitizer) { described_class.new } describe '#sanitize' do diff --git a/spec/koine/file_system_spec.rb b/spec/koine/filesystem_spec.rb similarity index 51% rename from spec/koine/file_system_spec.rb rename to spec/koine/filesystem_spec.rb index f01d5b2..e076f67 100644 --- a/spec/koine/file_system_spec.rb +++ b/spec/koine/filesystem_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe Koine::FileSystem do +RSpec.describe Koine::Filesystem do it 'has a version number' do - expect(Koine::FileSystem::VERSION).not_to be nil + expect(Koine::Filesystem::VERSION).not_to be nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 20c4086..4da5545 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ end end -require 'koine/file_system' +require 'koine/filesystem' require 'rspec' FIXTURES_PATH = File.expand_path('fixtures', __dir__)