resource_clean 0.1.0

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
+ SHA1:
3
+ metadata.gz: 3e83ea3c4c187c23aee8f4c628022656e6b41b0b
4
+ data.tar.gz: 5bf2508d7c5d6313f8e798bd645f7651bf7ff458
5
+ SHA512:
6
+ metadata.gz: f005d6d754978be66363983f293a3b72fd67728e6b59a239b2ef636333db60b7b7b80a28fb35f6e4bad62725bb04219fd5fd2fa060f047116ff96fe132efb645
7
+ data.tar.gz: 21b4d1edd3b592128706ab99b69fd27e1780c2ec54f4c893d8acae5efb21d230b0480dae8e3479609b2aba6f79fedf756ee2a900936d1abc3f7bcbb2a1655b17
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in resource_clean.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 midnightSuyama
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.
@@ -0,0 +1,45 @@
1
+ # ResourceClean
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/resource_clean.png)](http://badge.fury.io/rb/resource_clean)
4
+ [![Dependency Status](https://gemnasium.com/midnightSuyama/resource_clean.png)](https://gemnasium.com/midnightSuyama/resource_clean)
5
+ [![Build Status](https://travis-ci.org/midnightSuyama/resource_clean.png?branch=master)](https://travis-ci.org/midnightSuyama/resource_clean)
6
+
7
+ Delete resource file and xattr
8
+
9
+ * .AppleDouble
10
+ * .DS_Store
11
+ * .fseventsd
12
+ * .Spotlight-V100
13
+ * .TemporaryItems
14
+ * .Trashes
15
+ * .VolumeIcon.icns
16
+ * Desktop.ini
17
+ * Thumbs.db
18
+
19
+ and, "._" prefix file
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ gem 'resource_clean'
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install resource_clean
34
+
35
+ ## Usage
36
+
37
+ $ resource_clean [directory]
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/midnightSuyama/resource_clean/fork )
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 a new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'resource_clean'
4
+ require 'resource_clean/version'
5
+ require 'optparse'
6
+
7
+ OptionParser.new do |opt|
8
+ Version = ResourceClean::VERSION
9
+ opt.banner = "Usage: #{File.basename($0)} [directory]"
10
+ opt.parse!
11
+
12
+ if ARGV.empty?
13
+ puts opt.help
14
+ exit
15
+ end
16
+ end
17
+
18
+ ResourceClean.run(ARGV.first)
@@ -0,0 +1,38 @@
1
+ require 'find'
2
+ require 'fileutils'
3
+ require 'ffi-xattr'
4
+
5
+ module ResourceClean
6
+ class << self
7
+
8
+ DELETE_FILES = %w(
9
+ .AppleDouble
10
+ .DS_Store
11
+ .fseventsd
12
+ .Spotlight-V100
13
+ .TemporaryItems
14
+ .Trashes
15
+ .VolumeIcon.icns
16
+ Desktop.ini
17
+ Thumbs.db
18
+ )
19
+
20
+ def run(path)
21
+ Find.find path do |entry|
22
+ name = File.basename entry
23
+ if DELETE_FILES.index {|item| item.casecmp(name) == 0 } || name =~ /^\._/
24
+ FileUtils.remove_entry entry
25
+ puts "Delete file: #{entry}"
26
+ else
27
+ xattr = Xattr.new entry
28
+ list = xattr.list
29
+ unless list.empty?
30
+ list.each {|key| xattr.remove key }
31
+ puts "Delete xattr: #{entry}\n #{list}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module ResourceClean
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'resource_clean/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "resource_clean"
8
+ spec.version = ResourceClean::VERSION
9
+ spec.authors = ["midnightSuyama"]
10
+ spec.email = ["midnightSuyama@gmail.com"]
11
+ spec.summary = "Delete resource file and xattr"
12
+ spec.description = "Delete resource file and xattr"
13
+ spec.homepage = "https://github.com/midnightSuyama/resource_clean"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+
26
+ spec.add_runtime_dependency "ffi-xattr"
27
+ end
@@ -0,0 +1 @@
1
+ ResourceClean
@@ -0,0 +1 @@
1
+ ResourceClean
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe ResourceClean do
5
+ before :all do
6
+ Dir.mkdir 'tmp' unless File.exists? 'tmp'
7
+ Dir.chdir 'tmp'
8
+ end
9
+
10
+ after :all do
11
+ Dir.chdir '..'
12
+ FileUtils.rm_r 'tmp'
13
+ end
14
+
15
+ context 'when run' do
16
+
17
+ DELETE_FILES = %w(
18
+ .AppleDouble
19
+ .DS_Store
20
+ .fseventsd
21
+ .Spotlight-V100
22
+ .TemporaryItems
23
+ .Trashes
24
+ .VolumeIcon.icns
25
+ Desktop.ini
26
+ Thumbs.db
27
+ )
28
+
29
+ before :all do
30
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/fixtures/resource", '.'
31
+ @path = "#{Dir.pwd}/resource"
32
+ begin
33
+ $stdout = StringIO.new
34
+ ResourceClean.run(@path)
35
+ ensure
36
+ $stdout = STDOUT
37
+ end
38
+ end
39
+
40
+ it 'should not exist' do
41
+ Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).each do |entry|
42
+ name = File.basename entry
43
+ return false if DELETE_FILES.index {|item| item.casecmp(name) == 0 } || name =~ /^\._/
44
+ end
45
+ true
46
+ end
47
+
48
+ it 'should clear xattr' do
49
+ Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).each do |entry|
50
+ xattr = Xattr.new entry
51
+ return false unless xattr.list.empty?
52
+ end
53
+ true
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+ require 'resource_clean'
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resource_clean
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - midnightSuyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ffi-xattr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Delete resource file and xattr
84
+ email:
85
+ - midnightSuyama@gmail.com
86
+ executables:
87
+ - resource_clean
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/resource_clean
99
+ - lib/resource_clean.rb
100
+ - lib/resource_clean/version.rb
101
+ - resource_clean.gemspec
102
+ - spec/fixtures/resource/._directory/file
103
+ - spec/fixtures/resource/file
104
+ - spec/resource_clean_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/midnightSuyama/resource_clean
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
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: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Delete resource file and xattr
130
+ test_files:
131
+ - spec/fixtures/resource/._directory/file
132
+ - spec/fixtures/resource/file
133
+ - spec/resource_clean_spec.rb
134
+ - spec/spec_helper.rb