osx-copy-tags 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +29 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/copy-tags +29 -0
- data/lib/osx-copy-tags/copy_tags.rb +88 -0
- data/lib/osx-copy-tags/version.rb +3 -0
- data/lib/osx-copy-tags.rb +17 -0
- data/osx-copy-tags.gemspec +26 -0
- data/spec/tagcopy_spec.rb +13 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66c3f36db65206c5edd937635960a389fb45fa6a
|
4
|
+
data.tar.gz: cfad7b8cd4a5e566d27ee9a7f333ef9134c380ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3297b46cfe430c37fcd1027348bc9784508972f348dc8aea8d07297359830461f318590a94432947cd6e7d731d4e5e54f13e3792e0bf79aa2c483e02cc0afa4a
|
7
|
+
data.tar.gz: 4341f5ddf9f9c334d9fb25efef2a966bb744ab242071aa33685b5e4572b2824da37155b959eb40edbcfa6afa0178a0a515404362224d20db7f41062ce464d3d5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
osx-copy-tags (0.0.1)
|
5
|
+
colored
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
colored (1.2)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
rake (10.1.1)
|
13
|
+
rspec (2.14.1)
|
14
|
+
rspec-core (~> 2.14.0)
|
15
|
+
rspec-expectations (~> 2.14.0)
|
16
|
+
rspec-mocks (~> 2.14.0)
|
17
|
+
rspec-core (2.14.7)
|
18
|
+
rspec-expectations (2.14.4)
|
19
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
+
rspec-mocks (2.14.4)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
bundler (~> 1.5)
|
27
|
+
osx-copy-tags!
|
28
|
+
rake
|
29
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Fabian Renner MPBold
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Osx::Copy::Tags
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'osx-copy-tags'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install osx-copy-tags
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/osx-copy-tags/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/copy-tags
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'osx-copy-tags'
|
4
|
+
|
5
|
+
if ARGV.count != 2
|
6
|
+
answer = <<-EOM
|
7
|
+
usage: copy-tags [sourcefolder] [targetfolder]
|
8
|
+
EOM
|
9
|
+
|
10
|
+
# Dir.foreach(ARGV[0]) do |file|
|
11
|
+
|
12
|
+
# fullpath = ARGV[0]+"/"+file
|
13
|
+
|
14
|
+
# next if file.chr == "."
|
15
|
+
|
16
|
+
|
17
|
+
# system "tag -r #{fullpath}"
|
18
|
+
|
19
|
+
# puts fullpath
|
20
|
+
# end
|
21
|
+
|
22
|
+
if ARGV.count != 0
|
23
|
+
puts "You haven't given the correct argument number!\n".red
|
24
|
+
end
|
25
|
+
|
26
|
+
puts answer
|
27
|
+
else
|
28
|
+
CopyTags::Command.run(ARGV)
|
29
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#this class has all the logic to copy tags from one folder to another (files in it)
|
2
|
+
|
3
|
+
module CopyTags
|
4
|
+
class Copier
|
5
|
+
|
6
|
+
#attr_reader :source_folder, :target_folder
|
7
|
+
|
8
|
+
def initialize(source_folder, target_folder)
|
9
|
+
@source_folder = File.expand_path(source_folder)
|
10
|
+
@target_folder = File.expand_path(target_folder)
|
11
|
+
end
|
12
|
+
|
13
|
+
def copyTags
|
14
|
+
if !self.class.checkTagsTool
|
15
|
+
puts "Missing commandline tool 'tag'. Please install using instruction from http://github.com/jdberry/tag"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
if !checkFoldersValidity
|
20
|
+
puts "One of the 2 given folders is not a valid directory".red
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
puts = "...starting copying tags from #{@source_folder} to #{@target_folder}"
|
27
|
+
|
28
|
+
copy
|
29
|
+
end
|
30
|
+
|
31
|
+
def checkFoldersValidity
|
32
|
+
if !File.directory?(@source_folder)
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
if !File.directory?(@target_folder)
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
return true
|
39
|
+
end
|
40
|
+
|
41
|
+
def copy
|
42
|
+
@fileCount = 0
|
43
|
+
@errors = 0
|
44
|
+
|
45
|
+
Dir.foreach(@source_folder) do |file|
|
46
|
+
next if file.chr == "."
|
47
|
+
|
48
|
+
#search matching file in notag folder
|
49
|
+
sourceFilePath = @source_folder+"/#{file}"
|
50
|
+
targetFilePath = @target_folder+"/#{file}"
|
51
|
+
|
52
|
+
tagString = `tag #{sourceFilePath} --no-name`.delete!("\n")
|
53
|
+
if tagString.include? " "
|
54
|
+
tagString[" "] = "\\ "
|
55
|
+
end
|
56
|
+
|
57
|
+
matching = File.exists?(targetFilePath)
|
58
|
+
|
59
|
+
puts tagString.yellow
|
60
|
+
|
61
|
+
# #if file is found
|
62
|
+
if matching
|
63
|
+
puts "file #{sourceFilePath} matched at target directory".green
|
64
|
+
@fileCount = @fileCount+1
|
65
|
+
|
66
|
+
execString = "tag -s #{tagString} #{targetFilePath}"
|
67
|
+
puts execString
|
68
|
+
puts
|
69
|
+
done = system(execString)
|
70
|
+
|
71
|
+
if !done
|
72
|
+
puts "Could not transfer tags for file: #{file}".red
|
73
|
+
@errors = @errors+1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
puts
|
79
|
+
puts "+++ #{@fileCount} files matched criterium".green
|
80
|
+
puts "+++ #{@errors} errors".red
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.checkTagsTool
|
85
|
+
system('tag')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#entrence point for command line tool
|
2
|
+
|
3
|
+
require 'osx-copy-tags/copy_tags'
|
4
|
+
require 'colored'
|
5
|
+
|
6
|
+
module CopyTags
|
7
|
+
class Command
|
8
|
+
def initialize(argv)
|
9
|
+
puts argv
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.run(argv)
|
13
|
+
copier = CopyTags::Copier.new(argv[0],argv[1])
|
14
|
+
copier.copyTags
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'osx-copy-tags/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "osx-copy-tags"
|
8
|
+
spec.version = OsxCopyTags::VERSION
|
9
|
+
spec.authors = ["Fabian Renner"]
|
10
|
+
spec.email = ["rennerfabian@icloud.com"]
|
11
|
+
spec.summary = "Copying tags from files of one to another folder"
|
12
|
+
spec.description = "This gem copies the tags of name-matching files from one directory to another. Directories are given als commandline arguments."
|
13
|
+
spec.homepage = ""
|
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_dependency "colored"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'osx-copy-tags'
|
2
|
+
|
3
|
+
describe CopyTags::Copier do
|
4
|
+
it "path is /Users/rennerfabian/Documents and Dropbox equiv" do
|
5
|
+
CopyTags::Copier.new('~/Documents','~/Dropbox').copyTags.should eql("... starting copying tags from /Users/rennerfabian/Documents to /Users/rennerfabian/Dropbox")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe CopyTags::Copier do
|
10
|
+
it "check if tag commandline tool exists" do
|
11
|
+
CopyTags::Copier.checkTagsTool.should eql(true)
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osx-copy-tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabian Renner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colored
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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: rspec
|
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
|
+
description: This gem copies the tags of name-matching files from one directory to
|
70
|
+
another. Directories are given als commandline arguments.
|
71
|
+
email:
|
72
|
+
- rennerfabian@icloud.com
|
73
|
+
executables:
|
74
|
+
- copy-tags
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/copy-tags
|
85
|
+
- lib/osx-copy-tags.rb
|
86
|
+
- lib/osx-copy-tags/copy_tags.rb
|
87
|
+
- lib/osx-copy-tags/version.rb
|
88
|
+
- osx-copy-tags.gemspec
|
89
|
+
- spec/tagcopy_spec.rb
|
90
|
+
homepage: ''
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.1.11
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Copying tags from files of one to another folder
|
114
|
+
test_files:
|
115
|
+
- spec/tagcopy_spec.rb
|