osx_trash 0.5.1

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
+ SHA256:
3
+ metadata.gz: 59bc158d56aa22c35b5a8165576e294bf7a9c9a5f26e3748b3ff5db59d290899
4
+ data.tar.gz: 8db783982be116ffd9ff93508892f48c4d43327680c6d0efff0e1bba50e153ec
5
+ SHA512:
6
+ metadata.gz: a53dbfe1d7872d995da87806887e48b469f33f124145d4a58bb39ae6756a4bf7a6709d388257c641ff08a880b19295c5fe6f440fb706eb0fd32634b6ddc3496d
7
+ data.tar.gz: 969e1d579eb625534ba8969620bf6ba6625396fbfe23d18abce7cdd8603f8a7f413a8d04fe1902b2d53ea366bb13002c923f5f9c88e4df5af8f88a91980032b3
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ tags
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at zak@newalexandria.org. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in osx_trash.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 ZJ
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.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OSX Trash
2
+
3
+ Ruby class and CLI app for moving files to the OSX Trash
4
+
5
+ ## Summary
6
+
7
+ The OSX Trash gem will take a filepath containing paths to files that should be moved to the OSX trash. The list can be a little noisy, with things that will go away with `strip`. When instantiatin the class, you can pass a hash of file: with the pathname, or paths: with an array. }
8
+
9
+ This gem relies on Applescript (`osax`), which all Apple computers should have.
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ OSX.trash file:path_to_file_list
15
+ ```
16
+
17
+ When running locally, `send_to_trash` may move files that are in a watched folder, such as by Dropbox or Google Filestream. These programs may raise a Finder dialog to confirm moving them. You will have to click "OK" for each one. This may cause problems on remote / headless systems. Please file an issue with bug report, or a PR. Thanks.
18
+
19
+
20
+ ## Development
21
+
22
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+
24
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/NewAlexandria/osx_trash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
33
+
34
+ ## Code of Conduct
35
+
36
+ Everyone interacting in the OsxTrash project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/NewAlexandria/osx_trash/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/trash ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "osx_trash"
4
+
5
+ file = case ARGV[1]
6
+
7
+ OSX.trash paths: [file]
data/bin/trash_all ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "osx_trash"
4
+
5
+ file = case ARGV[1]
6
+
7
+ OSX.trash file: [file]
8
+
@@ -0,0 +1,3 @@
1
+ module OsxTrash
2
+ VERSION = "0.5.1"
3
+ end
data/lib/osx_trash.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'osx_trash/version'
2
+
3
+ module OSX
4
+
5
+ class << self
6
+ def trash(opt={})
7
+ return nil if init_validate(opt)
8
+
9
+ @paths = source_paths(opt)
10
+ send_to_trash
11
+ end
12
+
13
+ attr_reader :path, :results, :errors
14
+
15
+ private
16
+
17
+ def init_validate(opt)
18
+ valid = opt.is_a?(Hash) && (opt[:file] || opt[:paths])
19
+ unless valid
20
+ raise TypeError.new "input must be hash with file: or paths:"
21
+ end
22
+ valid
23
+ end
24
+
25
+ def source_paths(opt)
26
+ paths = opt[:paths] || File.readlines(opt[:file])
27
+ clean_input(paths)
28
+ end
29
+
30
+ # osax is expensive - clean inputs of non-existant files first.
31
+ def clean_input(paths)
32
+ paths
33
+ .map(&:strip)
34
+ .reject(&:empty?)
35
+ .select{|f| File.exist? f }
36
+ end
37
+
38
+
39
+ def send_to_trash
40
+ @results = @paths.map do |f|
41
+ IO.popen("osascript 2>&2", "w") do |stdin|
42
+ stdin.puts %Q{tell app "Finder" to move the POSIX file "#{f}" to trash}
43
+ end
44
+ [$?.to_json, f]
45
+ end
46
+
47
+ gather_errors
48
+ @results
49
+ end
50
+
51
+ def gather_errors
52
+ @errors = @results.select {|fs| fs.first.match("exit 1") }
53
+ end
54
+ end
55
+ end
data/osx_trash.gemspec ADDED
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "osx_trash/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "osx_trash"
8
+ spec.version = OsxTrash::VERSION
9
+ spec.authors = ["Zachary Jones"]
10
+ spec.email = ["zak@newalexandria.org"]
11
+
12
+ spec.summary = %q{Ruby class and CLI app for moving files to the OSX Trash}
13
+ spec.description = %q{The OSX Trash gem will take a filepath containing paths to files that should be moved to the OSX trash. The list can be a little noisy, with things that will go away with `strip`. When instantiatin the class, you can pass a hash of file: with the pathname, or paths: with an array. }
14
+ spec.homepage = "https://github.com/NewAlexandria/osx_trash"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/NewAlexandria/osx_trash"
24
+ spec.metadata["changelog_uri"] = "https://github.com/NewAlexandria/osx_trash/commits/master"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: osx_trash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ platform: ruby
6
+ authors:
7
+ - Zachary Jones
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-16 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: 'The OSX Trash gem will take a filepath containing paths to files that
42
+ should be moved to the OSX trash. The list can be a little noisy, with things that
43
+ will go away with `strip`. When instantiatin the class, you can pass a hash of file:
44
+ with the pathname, or paths: with an array. '
45
+ email:
46
+ - zak@newalexandria.org
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - CODE_OF_CONDUCT.md
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/trash
58
+ - bin/trash_all
59
+ - lib/osx_trash.rb
60
+ - lib/osx_trash/version.rb
61
+ - osx_trash.gemspec
62
+ homepage: https://github.com/NewAlexandria/osx_trash
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ allowed_push_host: https://rubygems.org
67
+ homepage_uri: https://github.com/NewAlexandria/osx_trash
68
+ source_code_uri: https://github.com/NewAlexandria/osx_trash
69
+ changelog_uri: https://github.com/NewAlexandria/osx_trash/commits/master
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.7.6
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Ruby class and CLI app for moving files to the OSX Trash
90
+ test_files: []