workspace 1.0.0 → 1.0.1

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: '0820d45a42fc51c68fe25a77e024015511f6c817'
4
- data.tar.gz: c6fdef4a4e5b687e706fab4aeba2b0870c0e458d
3
+ metadata.gz: d1148c1880a945f55539467fe3a1eb6a15da253a
4
+ data.tar.gz: 93151cd507c31bf8b692cf79c20b477ccb52aadd
5
5
  SHA512:
6
- metadata.gz: fe590c87851b4d6d571cd06d028f82c110c4acb6a7c9e602754120a55067bb5d1abe5e209b3e06eb4607d77e4f7d9c18ceed7ba2d274eece5f0b1a6c52ead6bb
7
- data.tar.gz: b7eb61ba2f04148ef66d23d6517b2332c1b07237d19add8fc0cfc428949f073e84152c3be5b34e90f59b6a77ce2a2492fc410d3c1bf5d1f66f409adc1f1d7f59
6
+ metadata.gz: 1b8b8b79ba5208a1e01e9dcacb817b29bccf2b7b24f4ad537dd144289e8ff965d3b7b8a5c5303afb894a3b2d6295dae809f82ab7a0e228d70f30fcd363e4b3ee
7
+ data.tar.gz: 834680ebf3c0787ebbbc5f66d85a5279acd3bf2dd465b18a8fb023f33d2d06c8808125e3f532b3dbf6a634d5a4d0016358a6b17b54ea467256bbcc6efa8704b9
data/lib/workspace/dir.rb CHANGED
@@ -89,7 +89,7 @@ module Workspace
89
89
  entries = []
90
90
  ::Dir.chdir(to_s) do
91
91
  ::Dir[glob].each do |path|
92
- entry = dir(path)
92
+ entry = ::File.directory?(::File.join(to_s, path)) ? dir(path) : file(path)
93
93
  yield entry if block_given?
94
94
  entries.push(entry)
95
95
  end
@@ -1,3 +1,3 @@
1
1
  module Workspace
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
@@ -121,21 +121,10 @@ executables: []
121
121
  extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
- - ".circleci/config.yml"
125
- - ".gitignore"
126
- - ".rspec"
127
- - ".rubocop.yml"
128
- - Gemfile
129
- - README.md
130
124
  - lib/workspace.rb
131
125
  - lib/workspace/dir.rb
132
126
  - lib/workspace/file.rb
133
127
  - lib/workspace/version.rb
134
- - spec/spec_helper.rb
135
- - spec/workspace/dir_spec.rb
136
- - spec/workspace/file_spec.rb
137
- - spec/workspace_spec.rb
138
- - workspace.gemspec
139
128
  homepage: https://github.com/magloft/workspace
140
129
  licenses:
141
130
  - BSD-3-Clause
data/.circleci/config.yml DELETED
@@ -1,11 +0,0 @@
1
- version: 2
2
- jobs:
3
- build:
4
- docker:
5
- - image: circleci/ruby:2.4.1-node-browsers
6
- steps:
7
- - checkout
8
- - run: bundle install --jobs=4 --retry=3
9
- - run: bundle exec rubocop
10
- - run: bundle exec rspec
11
- working_directory: ~/repo
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- /coverage
2
- /modules
3
- /Gemfile.lock
4
- /workspace-*.gem
data/.rspec DELETED
@@ -1,8 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- RSpec::Core::RakeTask.new(:spec)
4
-
5
- --default-path ./
6
- --require ./spec/spec_helper
7
- --color
8
- --format d
data/.rubocop.yml DELETED
@@ -1,193 +0,0 @@
1
- Style/SymbolArray:
2
- Enabled: true
3
- EnforcedStyle: brackets
4
-
5
- # kind_of? is a good way to check a type
6
- Style/ClassCheck:
7
- EnforcedStyle: kind_of?
8
-
9
- # It's better to be more explicit about the type
10
- Style/BracesAroundHashParameters:
11
- Enabled: false
12
-
13
- Style/TernaryParentheses:
14
- Enabled: true
15
- EnforcedStyle: require_parentheses_when_complex
16
-
17
- # specs sometimes have useless assignments, which is fine
18
- Lint/UselessAssignment:
19
- Exclude:
20
- - '**/spec/**/*'
21
-
22
- # We could potentially enable the 2 below:
23
- Layout/IndentHash:
24
- Enabled: false
25
-
26
- Layout/AlignHash:
27
- Enabled: false
28
-
29
- # HoundCI doesn't like this rule
30
- Layout/DotPosition:
31
- Enabled: false
32
-
33
- # We allow !! as it's an easy way to convert ot boolean
34
- Style/DoubleNegation:
35
- Enabled: false
36
-
37
- Style/NumericPredicate:
38
- Enabled: false
39
-
40
- # Sometimes we allow a rescue block that doesn't contain code
41
- Lint/HandleExceptions:
42
- Enabled: false
43
-
44
- # Cop supports --auto-correct.
45
- Lint/UnusedBlockArgument:
46
- Enabled: false
47
-
48
- # Needed for $verbose
49
- Style/GlobalVars:
50
- Enabled: false
51
-
52
- # We want to allow class Fastlane::Class
53
- Style/ClassAndModuleChildren:
54
- Enabled: false
55
-
56
- # $? Exit
57
- Style/SpecialGlobalVars:
58
- Enabled: false
59
-
60
- Metrics/AbcSize:
61
- Enabled: false
62
-
63
- Metrics/MethodLength:
64
- Enabled: false
65
-
66
- Metrics/ModuleLength:
67
- Enabled: true
68
- Max: 110
69
-
70
- Metrics/CyclomaticComplexity:
71
- Enabled: false
72
-
73
- Metrics/BlockNesting:
74
- Max: 4
75
-
76
- Metrics/BlockLength:
77
- Enabled: false
78
-
79
- # The %w might be confusing for new users
80
- Style/WordArray:
81
- MinSize: 19
82
-
83
- # raise and fail are both okay
84
- Style/SignalException:
85
- Enabled: false
86
-
87
- # Better too much 'return' than one missing
88
- Style/RedundantReturn:
89
- Enabled: false
90
-
91
- # Having if in the same line might not always be good
92
- Style/IfUnlessModifier:
93
- Enabled: false
94
-
95
- # and and or is okay
96
- Style/AndOr:
97
- Enabled: false
98
-
99
- # Configuration parameters: CountComments.
100
- Metrics/ClassLength:
101
- Max: 400
102
-
103
- # Configuration parameters: AllowURI, URISchemes.
104
- Metrics/LineLength:
105
- Enabled: false
106
- Max: 370
107
-
108
- # Configuration parameters: CountKeywordArgs.
109
- Metrics/ParameterLists:
110
- Max: 17
111
-
112
- Metrics/PerceivedComplexity:
113
- Max: 25
114
-
115
- # Sometimes it's easier to read without guards
116
- Style/GuardClause:
117
- Enabled: false
118
-
119
- # We allow both " and '
120
- Style/StringLiterals:
121
- Enabled: false
122
-
123
- # something = if something_else
124
- # that's confusing
125
- Style/ConditionalAssignment:
126
- Enabled: false
127
-
128
- # Better to have too much self than missing a self
129
- Style/RedundantSelf:
130
- Enabled: false
131
-
132
- # e.g.
133
- # def self.is_supported?(platform)
134
- # we may never use `platform`
135
- Lint/UnusedMethodArgument:
136
- Enabled: false
137
-
138
- # the let(:key) { ... }
139
- Lint/ParenthesesAsGroupedExpression:
140
- Exclude:
141
- - '**/spec/**/*'
142
-
143
- # This would reject is_ in front of methods
144
- # We use `is_supported?` everywhere already
145
- Style/PredicateName:
146
- Enabled: false
147
-
148
- # We allow the $
149
- Style/PerlBackrefs:
150
- Enabled: false
151
-
152
- # Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb
153
- Layout/SpaceAroundOperators:
154
- Exclude:
155
- - '**/spec/actions_specs/xcodebuild_spec.rb'
156
-
157
- # We're not there yet
158
- Style/Documentation:
159
- Enabled: false
160
-
161
- # Added after upgrade to 0.38.0
162
- Style/MutableConstant:
163
- Enabled: false
164
-
165
- # length > 0 is good
166
- Style/ZeroLengthPredicate:
167
- Enabled: false
168
-
169
- # Adds complexity
170
- Style/IfInsideElse:
171
- Enabled: false
172
-
173
- Style/RescueModifier:
174
- Enabled: false
175
-
176
- Style/VariableNumber:
177
- Enabled: false
178
-
179
- Style/ClassVars:
180
- Enabled: false
181
-
182
- Style/FrozenStringLiteralComment:
183
- Enabled: false
184
-
185
- AllCops:
186
- Exclude:
187
- - './vendor/**/*'
188
- - './db/**/*'
189
- - './tmp/**/*'
190
- - './log/**/*'
191
- - './public/**/*'
192
- - './bin/**/*'
193
- - './Gemfile'
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec
data/README.md DELETED
@@ -1,50 +0,0 @@
1
- # Workspace for Ruby
2
-
3
- > Simplified Files and Directories handling
4
-
5
- [![CircleCI](https://circleci.com/gh/MagLoft/workspace/tree/master.svg?style=svg)](https://circleci.com/gh/MagLoft/workspace/tree/master)
6
-
7
- ## Description
8
-
9
- Workspace makes it a breeze to work with files and directories.
10
-
11
- ## Synopsis
12
-
13
- Workspace::Dir and Workspace::File are abstractions of the ruby Dir and File classes (although not extending them).
14
-
15
- When working with files and folders, these abstractions can significantly help with keeping your code simple, consistent and easy to read.
16
-
17
- ```ruby
18
- require "workspace"
19
-
20
- root = Workspace.dir # initializes a workspace in the current directory
21
- root = Workspace.tmpdir # initializes a new workspace in a temporary directory
22
-
23
- root.file("file.txt").write("hello world") # creates the file "file.txt" with contents "hello world"
24
- root.dir("dir").file("file.txt").create # both the file "file.txt" and its parent directory "dir"
25
-
26
- root.dir("dir").exists? # => true
27
- root.dir("dir").delete # deletes the physical file, but keeps the Workspace::Dir
28
- root.dir("dir").exists? # => false
29
-
30
- file = root.dir("dir1").file("file.txt")
31
- file.relative_path(root.dir("dir2")) # => "../dir1/file.txt"
32
-
33
- root.dir("build").clean # delete and re-create directory
34
-
35
- root.files # [file1, file2, file3...]
36
- root.directories # [dir1, dir2, dir3...]
37
- root.children("**/*.rb") # [...] recursive matched files with .rb extension
38
- ```
39
-
40
- ## Installation
41
-
42
- # install globally
43
- gem install workspace
44
-
45
- # install using bundler / Gemfile
46
- gem "workspace"
47
-
48
- ## License
49
-
50
- workspace is available under an MIT-style license.
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'simplecov'
2
- require 'simplecov-console'
3
- SimpleCov.formatter = SimpleCov::Formatter::Console
4
- SimpleCov.start
5
-
6
- require "lib/workspace"
7
- RSpec.configure do |config|
8
- end
@@ -1,120 +0,0 @@
1
- describe Workspace::Dir do
2
- let(:root) { Workspace.tmpdir("workspace-spec") }
3
- let(:root_with_contents) do
4
- result = Workspace.tmpdir("workspace-spec")
5
- result.dir("folder1").create
6
- result.dir("folder2").create
7
- result.dir("folder2").file("file1.txt").write("file1")
8
- result.dir("folder2").file("file2.txt").write("file2")
9
- result.file("file1.txt").write("file1")
10
- result.file("file2.txt").write("file2")
11
- result
12
- end
13
-
14
- it "casts to string" do
15
- expect(root.to_s).to match("workspace-spec")
16
- end
17
-
18
- it "returns a relative path" do
19
- path = root.dir("subdir1").relative_path(root.dir("subdir2"))
20
- expect(path).to eq("../subdir1")
21
- expect(root.dir("subdir1").relative_path).to eq("subdir1")
22
- end
23
-
24
- it "returns an absolute path" do
25
- expect(root.absolute_path).to match("workspace-spec")
26
- end
27
-
28
- it "returns a name" do
29
- expect(root.dir("source").name).to eq("source")
30
- end
31
-
32
- it "creates a sub-directory" do
33
- source = root.dir("source").create
34
- expect(source.exists?).to be_truthy
35
- end
36
-
37
- it "checks for existance" do
38
- source = root.dir("source")
39
- expect(source.exists?).to be_falsy
40
- source.create
41
- expect(source.exists?).to be_truthy
42
- source.delete
43
- expect(source.exists?).to be_falsy
44
- end
45
-
46
- it "checks if a folder is empty" do
47
- source = root.dir("source").create
48
- expect(source.empty?).to be_truthy
49
- source.file("foobar.txt").write("helloworld")
50
- expect(source.empty?).to be_falsy
51
- end
52
-
53
- it "copies to another folder" do
54
- source = root.dir("source").create
55
- target = root.dir("target")
56
- source.copy(target)
57
- expect(target.exists?).to be_truthy
58
- end
59
-
60
- it "moves to another folder" do
61
- source = root.dir("source").create
62
- target = root.dir("target")
63
- source.move(target)
64
- expect(target.exists?).to be_truthy
65
- expect(source.exists?).to be_falsy
66
- end
67
-
68
- it "deletes a folder" do
69
- source = root.dir("source").create
70
- expect(source.exists?).to be_truthy
71
- source.delete
72
- expect(source.exists?).to be_falsy
73
- end
74
-
75
- it "cleans a folder" do
76
- source = root.dir("source").create
77
- source.file("foobar.txt").write("helloworld")
78
- expect(source.empty?).to be_falsy
79
- source.clean
80
- expect(source.empty?).to be_truthy
81
- end
82
-
83
- it "instantiates a file" do
84
- expect(root.file("sample")).to be_a Workspace::File
85
- end
86
-
87
- it "instantiates a directory" do
88
- expect(root.dir("sample")).to be_a Workspace::Dir
89
- end
90
-
91
- it "returns the root dir" do
92
- expect(root.dir("sample").dir("sample").root_dir).to eq(root)
93
- end
94
-
95
- it "returns the parent dir" do
96
- expect(root.dir("sample").parent_dir).to eq(root)
97
- end
98
-
99
- it "returns a list of children" do
100
- expect(root_with_contents.children.count).to eq 4
101
- expect(root_with_contents.children("*/").count).to eq 2
102
- expect(root_with_contents.children("*.txt").count).to eq 2
103
- expect(root_with_contents.children("**/*.txt").count).to eq 4
104
- end
105
-
106
- it "traverses through children" do
107
- expect { |b| root_with_contents.children("*", &b) }.to yield_control.exactly(4).times
108
- expect { |b| root_with_contents.children("*/", &b) }.to yield_control.exactly(2).times
109
- expect { |b| root_with_contents.children("*.txt", &b) }.to yield_control.exactly(2).times
110
- expect { |b| root_with_contents.children("**/*.txt", &b) }.to yield_control.exactly(4).times
111
- end
112
-
113
- it "traverses through files" do
114
- expect { |b| root_with_contents.files(&b) }.to yield_control.exactly(2).times
115
- end
116
-
117
- it "traverses through directories" do
118
- expect { |b| root_with_contents.directories(&b) }.to yield_control.exactly(2).times
119
- end
120
- end
@@ -1,97 +0,0 @@
1
- describe Workspace::File do
2
- let(:root) { Workspace.tmpdir("workspace-spec") }
3
- let(:file) { root.file("sample.txt").write("hello world") }
4
-
5
- it "casts to string" do
6
- expect(file.to_s).to match("sample.txt$")
7
- end
8
-
9
- it "returns a name" do
10
- expect(file.name).to eq("sample.txt")
11
- end
12
-
13
- it "returns an basename" do
14
- expect(file.basename).to eq("sample")
15
- end
16
-
17
- it "returns an extension" do
18
- expect(file.extension).to eq("txt")
19
- end
20
-
21
- it "returns an mimetype" do
22
- expect(file.mimetype).to eq("text/plain")
23
- end
24
-
25
- it "returns a relative path" do
26
- relative_dir = root.dir("subdir").create
27
- expect(file.relative_path(relative_dir)).to eq("../sample.txt")
28
- file2 = relative_dir.file("sample.txt")
29
- expect(file2.relative_path).to eq("subdir/sample.txt")
30
- end
31
-
32
- it "returns an absolute path" do
33
- expect(file.absolute_path).to match("workspace-spec")
34
- end
35
-
36
- it "returns its directory" do
37
- expect(file.dir).to eq(root)
38
- end
39
-
40
- it "checks for existance" do
41
- source = root.file("foobar.txt")
42
- expect(source.exists?).to be_falsy
43
- source.write("sample")
44
- expect(source.exists?).to be_truthy
45
- end
46
-
47
- it "reads a file" do
48
- expect(file.read).to eq("hello world")
49
- end
50
-
51
- it "reads a json file" do
52
- json_data = { "foo" => "bar" }
53
- json_file = root.file("sample.json").write(JSON.dump(json_data))
54
- expect(json_file.read_json).to eq(json_data)
55
- end
56
-
57
- it "sets contents without writing" do
58
- file.set("hello bar")
59
- expect(file.read).to eq("hello bar")
60
- expect(root.file("sample.txt").read).to eq("hello world")
61
- end
62
-
63
- it "replaces contents" do
64
- file.replace("world", "bar")
65
- expect(file.read).to eq("hello bar")
66
- end
67
-
68
- it "writes a file" do
69
- file.write("hello bar")
70
- expect(file.read).to eq("hello bar")
71
- end
72
-
73
- it "copies a file" do
74
- result = root.file("result.txt")
75
- file.copy(result)
76
- expect(result.exists?).to be_truthy
77
- expect(file.read).to eq(result.read)
78
- end
79
-
80
- it "renames to another name" do
81
- file.rename("foobar.txt")
82
- expect(root.file("foobar.txt").exists?).to be_truthy
83
- expect(root.file("foobar.txt").read).to eq("hello world")
84
- end
85
-
86
- it "moves a file to another file" do
87
- target_file = root.file("foobar.txt")
88
- file.move(target_file)
89
- expect(target_file.exists?).to be_truthy
90
- expect(target_file.read).to eq("hello world")
91
- end
92
-
93
- it "deletes a file" do
94
- file.delete
95
- expect(file.exists?).to be_falsy
96
- end
97
- end
@@ -1,24 +0,0 @@
1
- describe Workspace do
2
- it "creates a Workspace::Dir" do
3
- expect(Workspace.dir(".")).to be_a Workspace::Dir
4
- end
5
-
6
- it "creates a temporary Workspace::Dir for a block" do
7
- Workspace.tmpdir do |dir|
8
- expect(dir).to be_a Workspace::Dir
9
- end
10
- end
11
-
12
- it "creates a temporary Workspace::Dir without a block" do
13
- dir = Workspace.tmpdir("sample")
14
- expect(dir).to be_a Workspace::Dir
15
- expect(dir.name).to match(/^sample/)
16
- expect(dir.exists?).to be_truthy
17
- dir.delete
18
- expect(dir.exists?).to be_falsy
19
- end
20
-
21
- it "creates a Workspace::File" do
22
- expect(Workspace.file("sample.txt")).to be_a Workspace::File
23
- end
24
- end
data/workspace.gemspec DELETED
@@ -1,27 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'workspace/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "workspace"
7
- s.version = Workspace::VERSION
8
- s.licenses = ["BSD-3-Clause"]
9
- s.platform = Gem::Platform::RUBY
10
- s.authors = ["Tobias Strebitzer"]
11
- s.email = ["tobias.strebitzer@magloft.com"]
12
- s.homepage = "https://github.com/magloft/workspace"
13
- s.summary = "Simplified Files and Directories handling"
14
- s.description = "Workspace makes it a breeze to work with files and directories"
15
- s.required_ruby_version = '~> 2.0'
16
- s.required_rubygems_version = '~> 2.4'
17
- s.add_dependency "bundler", '>= 1.3.0', '< 2.0'
18
- s.add_runtime_dependency "mime-types", "~> 3.1"
19
- s.add_development_dependency "rspec", "~> 3.6"
20
- s.add_development_dependency "pry", "~> 0.10"
21
- s.add_development_dependency "rubocop", "~> 0.49"
22
- s.add_development_dependency "simplecov", "~> 0.10"
23
- s.add_development_dependency "simplecov-console", "~> 0.4"
24
- s.files = `git ls-files`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
- s.require_path = 'lib'
27
- end