openmeta.rb 1.3.2 → 2.0.0

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
  SHA512:
3
- data.tar.gz: 9209f5e1021db9d1223a0c725c50bdd6b1b0bf8636ef6843f756fad4fc930ce4ab3c23b75ef30b80c6ba133eceeeee093f0e0314f6810d9038e8147ad06d15fd
4
- metadata.gz: 8c489230b0f0e4d3cc86f44d7c5f0cbcb46f28672dc5c4e6c2da96e04b689a2dc631454f34215df2a2270221c4b8faafe4f9abd469702defc84a86d460c067d0
3
+ metadata.gz: d3cbb967f94078ab1c98eb9573913ae74ad47f27f30b17889a9a5a93f5fa3d4eb61071f5c388a6f4b1865140b3780d5ff3ee23c2053047198cd2162d660ecc21
4
+ data.tar.gz: 0cb6ad96a3963b615cc6cb5b2df092ddfe567288a323f36e97c73ce9728cbc2049a4c3aad0b2a3e97952b8259e1779a88069ff6596d216680cf8a1192c512ac8
5
5
  SHA1:
6
- data.tar.gz: e1f8b8523dcf22c33b4e24b6e1ed0c76952d7f41
7
- metadata.gz: 95a114abb8668fe3a971e3ee349d462992ad442d
6
+ metadata.gz: 8485e0d7a2165ec2dceec75eff4826048974ff92
7
+ data.tar.gz: d0b52db16d76e20620676a06d4e397eb31d8c12b
Binary file
Binary file
@@ -0,0 +1 @@
1
+ system
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # -*- ruby -*-
2
+
3
+ source "https://rubygems.org/"
4
+
5
+ gemspec
6
+
7
+ # vim: syntax=ruby
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ openmeta.rb (1.3.3.20130503185054)
5
+ filetype (~> 0.3.0)
6
+ thor (~> 0.18.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.0.9)
12
+ diff-lcs (1.2.4)
13
+ ffi (1.8.1)
14
+ filetype (0.3.0)
15
+ formatador (0.2.4)
16
+ growl (1.0.3)
17
+ guard (1.8.0)
18
+ formatador (>= 0.2.4)
19
+ listen (>= 1.0.0)
20
+ lumberjack (>= 1.0.2)
21
+ pry (>= 0.9.10)
22
+ thor (>= 0.14.6)
23
+ guard-rspec (2.6.0)
24
+ guard (>= 1.8)
25
+ rspec (~> 2.13)
26
+ hoe (3.6.0)
27
+ rake (>= 0.8, < 11.0)
28
+ hoe-bundler (1.2.0)
29
+ hoe (>= 2.2.0)
30
+ hoe-gemspec (1.0.0)
31
+ hoe (>= 2.2.0)
32
+ hoe-git (1.5.0)
33
+ hoe (>= 2.2.0)
34
+ hoe-version (1.2.0)
35
+ json (1.7.7)
36
+ listen (1.0.3)
37
+ rb-fsevent (>= 0.9.3)
38
+ rb-inotify (>= 0.9)
39
+ rb-kqueue (>= 0.2)
40
+ lumberjack (1.0.3)
41
+ method_source (0.8.1)
42
+ pry (0.9.12.1)
43
+ coderay (~> 1.0.5)
44
+ method_source (~> 0.8)
45
+ slop (~> 3.4)
46
+ rake (10.0.4)
47
+ rb-fsevent (0.9.3)
48
+ rb-inotify (0.9.0)
49
+ ffi (>= 0.5.0)
50
+ rb-kqueue (0.2.0)
51
+ ffi (>= 0.5.0)
52
+ rdoc (4.0.1)
53
+ json (~> 1.4)
54
+ rspec (2.13.0)
55
+ rspec-core (~> 2.13.0)
56
+ rspec-expectations (~> 2.13.0)
57
+ rspec-mocks (~> 2.13.0)
58
+ rspec-core (2.13.1)
59
+ rspec-expectations (2.13.0)
60
+ diff-lcs (>= 1.1.3, < 2.0)
61
+ rspec-mocks (2.13.1)
62
+ slop (3.4.4)
63
+ terminal-notifier-guard (1.5.3)
64
+ thor (0.18.1)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ growl
71
+ guard
72
+ guard-rspec
73
+ hoe
74
+ hoe-bundler
75
+ hoe-gemspec
76
+ hoe-git
77
+ hoe-version
78
+ openmeta.rb!
79
+ rake (>= 10.0.0)
80
+ rdoc (~> 4.0)
81
+ rspec (>= 2.13)
82
+ terminal-notifier-guard
@@ -1,3 +1,7 @@
1
+ .gemtest
2
+ .ruby-version
3
+ Gemfile
4
+ Gemfile.lock
1
5
  Guardfile
2
6
  History.txt
3
7
  Manifest.txt
@@ -17,7 +21,10 @@ lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/Info.plist
17
21
  lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/en.lproj/InfoPlist.strings
18
22
  lib/openmeta/framework/OpenMeta.framework/Versions/Current
19
23
  lib/openmeta/friendly_errors.rb
24
+ lib/openmeta/macruby.rb
25
+ lib/openmeta/rubycocoa.rb
20
26
  lib/openmeta/ui.rb
21
27
  lib/openmeta/version.rb
28
+ openmeta.rb.gemspec
22
29
  spec/openmeta_spec.rb
23
30
  spec/spec_helper.rb
data/README.md CHANGED
@@ -8,11 +8,12 @@
8
8
 
9
9
  ## DESCRIPTION:
10
10
 
11
- openMeta in Ruby (MacRuby, more exactly!). This gem ports [openmeta]( http://code.google.com/p/openmeta/ ) api to macruby using framework.
11
+ openMeta in Ruby (support mac system native ruby 1.8, and MacRuby). This gem ports [openmeta]( http://code.google.com/p/openmeta/ ) api to ruby using framework.
12
12
 
13
13
 
14
14
  ## INSTALLATION:
15
15
 
16
+ * `[sudo] gem install openmeta.rb`
16
17
  * `[sudo] macgem install openmeta.rb`
17
18
 
18
19
 
@@ -58,7 +59,9 @@ openMeta in Ruby (MacRuby, more exactly!). This gem ports [openmeta]( http://cod
58
59
 
59
60
  ### 1. Macruby Slow Startup
60
61
 
61
- This is a [known commnon issue of macruby]( https://github.com/MacRuby/MacRuby/wiki/Common-Issues ).
62
+ A. Version 2.0+ support native mac ruby 1.8. Use system ruby instead.
63
+
64
+ B. This is a [known commnon issue of macruby]( https://github.com/MacRuby/MacRuby/wiki/Common-Issues ).
62
65
  One thing recommended is to add `VM_OPT_LEVEL=0` in front of the command line like
63
66
 
64
67
  ```bash
@@ -67,6 +70,7 @@ alias tag='VM_OPT_LEVEL=0 /usr/local/bin/tag'
67
70
 
68
71
  In my environment, the startup time for the `tag` command is about 1 second.
69
72
 
73
+
70
74
  ## DEVELOPERS:
71
75
 
72
76
  After checking out the source, run:
data/Rakefile CHANGED
@@ -14,7 +14,8 @@ Hoe.spec 'openmeta.rb' do
14
14
  developer('Zhao Cai', 'caizhaoff@gmail.com')
15
15
  license 'GPL-3'
16
16
 
17
- extra_deps << ['thor', '~> 0.17.0']
17
+ extra_deps << ['thor', '~> 0.18.0']
18
+ extra_deps << ['filetype', '~> 0.3.0']
18
19
 
19
20
 
20
21
 
data/bin/tag CHANGED
@@ -1,4 +1,8 @@
1
- #!/usr/bin/env macruby
1
+ #!/usr/bin/ruby
2
+
3
+ # Trap interrupts to quit cleanly. See
4
+ # https://twitter.com/mitchellh/status/283014103189053442
5
+ Signal.trap("INT") { exit 1 }
2
6
 
3
7
  ($LOAD_PATH << File.expand_path("../../lib", __FILE__)).uniq!
4
8
  require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
@@ -1,151 +1,18 @@
1
- #!/usr/bin/env macruby
1
+ #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- def is_macruby?
5
- begin
6
- MACRUBY_VERSION
7
- return true
8
- rescue
9
- return false
10
- end
11
- end
4
+ ($LOAD_PATH << File.expand_path("../openmeta/framework", __FILE__)).uniq!
12
5
 
13
- if is_macruby?
14
- ($LOAD_PATH << File.expand_path("../openmeta/framework", __FILE__)).uniq!
6
+ if defined? MACRUBY_VERSION
15
7
  framework "OpenMeta"
8
+ require 'openmeta/macruby'
9
+ elsif RUBY_VERSION < "1.9"
10
+
11
+ require 'osx/cocoa'
12
+ OSX::require_framework 'OpenMeta'
13
+ require 'rubygems'
14
+ require 'openmeta/rubycocoa'
16
15
  else
17
- raise NotImplementedError, "[Openmeta] only work with macruby"
18
- end
19
-
20
- require 'openmeta/version'
21
- require 'openmeta/ui'
22
- module Openmeta
23
- class OpenmetaError < RuntimeError
24
- def self.status_code(code)
25
- define_method(:status_code) { code }
26
- end
27
- end
28
-
29
- class ObjCError < OpenmetaError; status_code(1) ; end
30
- class RangeError < OpenmetaError; status_code(2) ; end
31
- class NoMethodError < OpenmetaError; status_code(13) ; end
32
- class PathError < OpenmetaError; status_code(14) ; end
33
- class DslError < OpenmetaError; status_code(15) ; end
34
-
35
-
36
- class << self
37
- attr_writer :ui, :error
38
-
39
- def ui
40
- @ui ||= UI.new
41
- end
42
-
43
- def error
44
- @error ||= error = Pointer.new(:id)
45
- end
46
-
47
- # **note** returned array are frozen
48
- def get_tags(path)
49
- tags = OpenMeta.getUserTags(File.expand_path(path), error:error)
50
- if error.value
51
- raise Openmeta::ObjCError, error.value.inspect
52
- end
53
- tags
54
- end
55
-
56
- def set_tags(new_tags, path)
57
- path = File.expand_path(path)
58
-
59
- existing_tags = OpenMeta.getUserTags(path, error:error)
60
- if error.value
61
- raise Openmeta::ObjCError, error.value.inspect
62
- end
63
-
64
- if e = OpenMeta.setUserTags(new_tags, path:path)
65
- raise Openmeta::ObjCError, e.inspect
66
- end
67
-
68
- OpenMetaPrefs.updatePrefsRecentTags(existing_tags, newTags:new_tags)
69
- end
70
-
71
- def add_tags(new_tags, to_files)
72
- to_files = fu_list(to_files)
73
-
74
- to_files.each { |file|
75
- existing_tags = get_tags(file)
76
-
77
- if e = OpenMeta.addUserTags(new_tags, path:file)
78
- raise Openmeta::ObjCError, e.inspect
79
- end
80
-
81
- OpenMetaPrefs.updatePrefsRecentTags(existing_tags, newTags:new_tags)
82
- }
83
- end
84
-
85
- def remove_tags(tags, from_files)
86
- from_files = fu_list(from_files)
87
-
88
- return if tags.empty?
89
-
90
- from_files.each { |file|
91
- existing_tags = get_tags(file) # frozen array
92
- next if existing_tags.nil? or existing_tags.empty?
93
-
94
- set_tags(existing_tags - tags, file)
95
- }
96
- end
97
-
98
- def get_rating(path)
99
- rating = OpenMeta.getRating(File.expand_path(path), error:error)
100
- if error.value
101
- raise Openmeta::ObjCError, error.value.inspect
102
- end
103
- rating
104
- end
105
-
106
- def set_rating(rating, path)
107
- e = OpenMeta.setRating(rating, path:File.expand_path(path))
108
- if e
109
- raise Openmeta::ObjCError, e.inspect
110
- end
111
- end
112
-
113
- def clone(from_file, to_files)
114
-
115
- unless File.exist?(from_file)
116
- raise Openmeta::PathError, "#{from_file} does not exist!"
117
- end
118
-
119
- tags = get_tags(from_file)
120
- rating = get_rating(from_file)
121
-
122
- to_files = fu_list(to_files)
123
- to_files.each { |file|
124
- set_tags(tags, file) unless (tags == nil or tags.empty?)
125
- set_rating(rating, file) unless rating == 0.0
126
- }
127
- end
128
-
129
- def clear(files)
130
- files = fu_list(files)
131
- files.each { |file|
132
- set_tags([], file)
133
- set_rating(0.0, file)
134
- }
135
- end
136
-
137
-
138
- def recent_tags
139
- OpenMetaPrefs.recentTags
140
- end
141
-
142
- private
143
-
144
- def fu_list(arg) #:nodoc:
145
- [arg].flatten.map {|path| File.path(path) }
146
- end
147
-
148
- end
149
-
16
+ raise NotImplementedError, "(openmeta.rb) only work with macruby or system ruby"
150
17
  end
151
18
 
@@ -7,9 +7,8 @@ module Openmeta
7
7
 
8
8
  def initialize(*)
9
9
  super
10
- the_shell = (options["no-color"] || (not STDOUT.tty?) ? Thor::Shell::Basic.new : shell)
11
- Openmeta.ui = UI::Shell.new(the_shell)
12
- Openmeta.ui.debug! if options["verbose"]
10
+ Openmeta.ui = UI::Shell.new(options)
11
+ Openmeta.ui.level = "debug" if options["verbose"]
13
12
  end
14
13
 
15
14
  desc "recent", "print recent tags"
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env macruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'openmeta/version'
5
+ require 'openmeta/ui'
6
+ module Openmeta
7
+ class OpenmetaError < RuntimeError
8
+ def self.status_code(code)
9
+ define_method(:status_code) { code }
10
+ end
11
+ end
12
+
13
+ class ObjCError < OpenmetaError; status_code(1) ; end
14
+ class RangeError < OpenmetaError; status_code(2) ; end
15
+ class NoMethodError < OpenmetaError; status_code(13) ; end
16
+ class PathError < OpenmetaError; status_code(14) ; end
17
+ class DslError < OpenmetaError; status_code(15) ; end
18
+
19
+
20
+ class << self
21
+ attr_writer :ui, :error
22
+
23
+ def ui
24
+ @ui ||= UI.new
25
+ end
26
+
27
+ def error
28
+ @error ||= Pointer.new(:id)
29
+ end
30
+
31
+ # **note** returned array are frozen
32
+ def get_tags(path)
33
+ tags = OpenMeta.getUserTags(File.expand_path(path), error:error)
34
+ if error.value
35
+ raise Openmeta::ObjCError, error.value.inspect
36
+ end
37
+ tags
38
+ end
39
+
40
+ def set_tags(new_tags, path)
41
+ path = File.expand_path(path)
42
+
43
+ existing_tags = OpenMeta.getUserTags(path, error:error)
44
+ if error.value
45
+ raise Openmeta::ObjCError, error.value.inspect
46
+ end
47
+
48
+ if e = OpenMeta.setUserTags(new_tags, path:path)
49
+ raise Openmeta::ObjCError, e.inspect
50
+ end
51
+
52
+ OpenMetaPrefs.updatePrefsRecentTags(existing_tags, newTags:new_tags)
53
+ end
54
+
55
+ def add_tags(new_tags, to_files)
56
+ to_files = fu_list(to_files)
57
+
58
+ to_files.each { |file|
59
+ existing_tags = get_tags(file)
60
+
61
+ if e = OpenMeta.addUserTags(new_tags, path:file)
62
+ raise Openmeta::ObjCError, e.inspect
63
+ end
64
+
65
+ OpenMetaPrefs.updatePrefsRecentTags(existing_tags, newTags:new_tags)
66
+ }
67
+ end
68
+
69
+ def remove_tags(tags, from_files)
70
+ from_files = fu_list(from_files)
71
+
72
+ return if tags.empty?
73
+
74
+ from_files.each { |file|
75
+ existing_tags = get_tags(file) # frozen array
76
+ next if existing_tags.nil? or existing_tags.empty?
77
+
78
+ set_tags(existing_tags - tags, file)
79
+ }
80
+ end
81
+
82
+ def get_rating(path)
83
+ rating = OpenMeta.getRating(File.expand_path(path), error:error)
84
+ if error.value
85
+ raise Openmeta::ObjCError, error.value.inspect
86
+ end
87
+ rating
88
+ end
89
+
90
+ def set_rating(rating, path)
91
+ e = OpenMeta.setRating(rating, path:File.expand_path(path))
92
+ if e
93
+ raise Openmeta::ObjCError, e.inspect
94
+ end
95
+ end
96
+
97
+ def clone(from_file, to_files)
98
+
99
+ unless File.exist?(from_file)
100
+ raise Openmeta::PathError, "#{from_file} does not exist!"
101
+ end
102
+
103
+ tags = get_tags(from_file)
104
+ rating = get_rating(from_file)
105
+
106
+ to_files = fu_list(to_files)
107
+ to_files.each { |file|
108
+ set_tags(tags, file) unless (tags == nil or tags.empty?)
109
+ set_rating(rating, file) unless rating == 0.0
110
+ }
111
+ end
112
+
113
+ def clear(files)
114
+ files = fu_list(files)
115
+ files.each { |file|
116
+ set_tags([], file)
117
+ set_rating(0.0, file)
118
+ }
119
+ end
120
+
121
+
122
+ def recent_tags
123
+ OpenMetaPrefs.recentTags
124
+ end
125
+
126
+ private
127
+
128
+ def fu_list(arg) #:nodoc:
129
+ [arg].flatten.map {|path| File.expand_path(path) }
130
+ end
131
+
132
+ end
133
+
134
+ end
135
+
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'openmeta/version'
5
+ require 'openmeta/ui'
6
+ module Openmeta
7
+ class OpenmetaError < RuntimeError
8
+ def self.status_code(code)
9
+ define_method(:status_code) { code }
10
+ end
11
+ end
12
+
13
+ class ObjCError < OpenmetaError; status_code(1) ; end
14
+ class RangeError < OpenmetaError; status_code(2) ; end
15
+ class NoMethodError < OpenmetaError; status_code(13) ; end
16
+ class PathError < OpenmetaError; status_code(14) ; end
17
+ class DslError < OpenmetaError; status_code(15) ; end
18
+
19
+
20
+ class << self
21
+ attr_writer :ui, :error
22
+
23
+ def ui
24
+ @ui ||= UI.new
25
+ end
26
+
27
+ def error
28
+ @error ||= OSX::NSError.new
29
+ end
30
+
31
+ # **note** returned array are frozen
32
+ def get_tags(path)
33
+ path = File.expand_path(path)
34
+ unless File.exist?(path)
35
+ raise Openmeta::ObjCError, "#{path} does not exist!"
36
+ end
37
+ OSX::OpenMeta.getUserTags_error_(path, error)
38
+ end
39
+
40
+ def set_tags(new_tags, path)
41
+ path = File.expand_path(path)
42
+
43
+ unless File.exist?(path)
44
+ raise Openmeta::ObjCError, "#{path} does not exist!"
45
+ end
46
+ existing_tags = OSX::OpenMeta.getUserTags_error_(path, error)
47
+
48
+ if e = OSX::OpenMeta.setUserTags_path_(new_tags, path)
49
+ raise Openmeta::ObjCError, e.inspect
50
+ end
51
+
52
+ OSX::OpenMetaPrefs.updatePrefsRecentTags_newTags_(existing_tags, new_tags)
53
+ end
54
+
55
+ def add_tags(new_tags, to_files)
56
+ to_files = fu_list(to_files)
57
+
58
+ to_files.each { |file|
59
+ existing_tags = get_tags(file)
60
+
61
+ if e = OSX::OpenMeta.addUserTags_path_(new_tags, file)
62
+ raise Openmeta::ObjCError, e.inspect
63
+ end
64
+
65
+ OSX::OpenMetaPrefs.updatePrefsRecentTags_newTags_(existing_tags, new_tags)
66
+ }
67
+ end
68
+
69
+ def remove_tags(tags, from_files)
70
+ from_files = fu_list(from_files)
71
+
72
+ return if tags.empty?
73
+
74
+ from_files.each { |file|
75
+ existing_tags = get_tags(file) # frozen array
76
+ next if existing_tags.nil? or existing_tags.empty?
77
+
78
+ set_tags(existing_tags - tags, file)
79
+ }
80
+ end
81
+
82
+ def get_rating(path)
83
+ path = File.expand_path(path)
84
+ unless File.exist?(path)
85
+ raise Openmeta::ObjCError, "#{path} does not exist!"
86
+ end
87
+
88
+ OSX::OpenMeta.getRating_error_(path, error)
89
+ end
90
+
91
+ def set_rating(rating, path)
92
+ e = OSX::OpenMeta.setRating_path_(rating, File.expand_path(path))
93
+ if e
94
+ raise Openmeta::ObjCError, e.inspect
95
+ end
96
+ end
97
+
98
+ def clone(from_file, to_files)
99
+
100
+ unless File.exist?(from_file)
101
+ raise Openmeta::PathError, "#{from_file} does not exist!"
102
+ end
103
+
104
+ tags = get_tags(from_file)
105
+ rating = get_rating(from_file)
106
+
107
+ to_files = fu_list(to_files)
108
+ to_files.each { |file|
109
+ set_tags(tags, file) unless (tags == nil or tags.empty?)
110
+ set_rating(rating, file) unless rating == 0.0
111
+ }
112
+ end
113
+
114
+ def clear(files)
115
+ files = fu_list(files)
116
+ files.each { |file|
117
+ set_tags([], file)
118
+ set_rating(0.0, file)
119
+ }
120
+ end
121
+
122
+
123
+ def recent_tags
124
+ OSX::OpenMetaPrefs.recentTags
125
+ end
126
+
127
+ private
128
+
129
+ def fu_list(arg) #:nodoc:
130
+ [arg].flatten.map {|path| File.expand_path(path) }
131
+ end
132
+
133
+ end
134
+
135
+ end
136
+
@@ -6,6 +6,9 @@ module Openmeta
6
6
  def debug(message, newline = nil)
7
7
  end
8
8
 
9
+ def trace(message, newline = nil)
10
+ end
11
+
9
12
  def error(message, newline = nil)
10
13
  end
11
14
 
@@ -19,55 +22,106 @@ module Openmeta
19
22
  false
20
23
  end
21
24
 
25
+ def ask(message)
26
+ end
27
+
22
28
  class Shell < UI
29
+ LEVELS = %w(silent error warn confirm info debug)
30
+
23
31
  attr_writer :shell
24
32
 
25
- def initialize(shell)
26
- @shell = shell
27
- @quiet = false
28
- @debug = ENV['DEBUG']
33
+ def initialize(options = {})
34
+ if options["no-color"] || !STDOUT.tty?
35
+ Thor::Base.shell = Thor::Shell::Basic
36
+ end
37
+ @shell = Thor::Base.shell.new
38
+ @level = ENV['DEBUG'] ? "debug" : "info"
29
39
  end
30
40
 
31
41
  def info(msg, newline = nil)
32
- tell_me(msg, nil, newline) if !@quiet
42
+ tell_me(msg, nil, newline) if level("info")
33
43
  end
34
44
 
35
45
  def confirm(msg, newline = nil)
36
- tell_me(msg, :green, newline) if !@quiet
46
+ tell_me(msg, :green, newline) if level("confirm")
37
47
  end
38
48
 
39
49
  def warn(msg, newline = nil)
40
- tell_me(msg, :yellow, newline)
50
+ tell_me(msg, :yellow, newline) if level("warn")
41
51
  end
42
52
 
43
53
  def error(msg, newline = nil)
44
- tell_me(msg, :red, newline)
54
+ tell_me(msg, :red, newline) if level("error")
45
55
  end
46
56
 
47
- def be_quiet!
48
- @quiet = true
57
+ def debug(msg, newline = nil)
58
+ tell_me(msg, nil, newline) if level("debug")
49
59
  end
50
60
 
51
61
  def debug?
52
62
  # needs to be false instead of nil to be newline param to other methods
53
- !!@debug && !@quiet
63
+ level("debug")
54
64
  end
55
65
 
56
- def debug!
57
- @debug = true
66
+ def quiet?
67
+ LEVELS.index(@level) <= LEVELS.index("warn")
58
68
  end
59
69
 
60
- def debug(msg, newline = nil)
61
- tell_me(msg, nil, newline) if debug?
70
+ def ask(msg)
71
+ @shell.ask(msg)
72
+ end
73
+
74
+ def level=(level)
75
+ raise ArgumentError unless LEVELS.include?(level.to_s)
76
+ @level = level
77
+ end
78
+
79
+ def level(name = nil)
80
+ name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
81
+ end
82
+
83
+ def trace(e, newline = nil)
84
+ msg = ["#{e.class}: #{e.message}", *e.backtrace].join("\n")
85
+ if debug?
86
+ tell_me(msg, nil, newline)
87
+ elsif @trace
88
+ STDERR.puts "#{msg}#{newline}"
89
+ end
90
+ end
91
+
92
+ def silence
93
+ old_level, @level = @level, "silent"
94
+ yield
95
+ ensure
96
+ @level = old_level
62
97
  end
63
98
 
64
99
  private
100
+
65
101
  # valimism
66
102
  def tell_me(msg, color = nil, newline = nil)
67
- newline.nil? ? @shell.say(msg, color) : @shell.say(msg, color, newline)
103
+ msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap]
104
+ if newline.nil?
105
+ @shell.say(msg, color)
106
+ else
107
+ @shell.say(msg, color, newline)
108
+ end
109
+ end
110
+
111
+ def strip_leading_spaces(text)
112
+ spaces = text[/\A\s+/, 0]
113
+ spaces ? text.gsub(/#{spaces}/, '') : text
114
+ end
115
+
116
+ def word_wrap(text, line_width = @shell.terminal_width)
117
+ strip_leading_spaces(text).split("\n").collect do |line|
118
+ line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
119
+ end * "\n"
68
120
  end
69
121
  end
70
122
 
71
123
  end
72
124
  end
73
125
 
126
+
127
+
@@ -1,4 +1,4 @@
1
1
  module Openmeta
2
- VERSION = '1.3.2'
2
+ VERSION = '2.0.0'
3
3
  end
4
4
 
@@ -0,0 +1,75 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "openmeta.rb"
5
+ s.version = "1.3.3.20130503185054"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Zhao Cai"]
9
+ s.cert_chain = ["/Users/zhaocai/.gem/gem-public_cert.pem"]
10
+ s.date = "2013-05-03"
11
+ s.description = "openMeta in Ruby (MacRuby, more exactly!). This gem ports [openmeta]( http://code.google.com/p/openmeta/ ) api to macruby using framework."
12
+ s.email = ["caizhaoff@gmail.com"]
13
+ s.executables = ["tag"]
14
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.md"]
15
+ s.files = ["Guardfile", "History.txt", "Manifest.txt", "README.md", "Rakefile", "bin/tag", "lib/openmeta.rb", "lib/openmeta/cli.rb", "lib/openmeta/framework/OpenMeta.framework/Headers", "lib/openmeta/framework/OpenMeta.framework/OpenMeta", "lib/openmeta/framework/OpenMeta.framework/Resources", "lib/openmeta/framework/OpenMeta.framework/Versions/A/Headers/OpenMeta.h", "lib/openmeta/framework/OpenMeta.framework/Versions/A/Headers/OpenMetaBackup.h", "lib/openmeta/framework/OpenMeta.framework/Versions/A/Headers/OpenMetaPrefs.h", "lib/openmeta/framework/OpenMeta.framework/Versions/A/OpenMeta", "lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/Info.plist", "lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/en.lproj/InfoPlist.strings", "lib/openmeta/framework/OpenMeta.framework/Versions/Current", "lib/openmeta/friendly_errors.rb", "lib/openmeta/ui.rb", "lib/openmeta/version.rb", "spec/openmeta_spec.rb", "spec/spec_helper.rb", ".gemtest"]
16
+ s.homepage = "http://zhaocai.github.com/openmeta.rb"
17
+ s.licenses = ["GPL-3"]
18
+ s.rdoc_options = ["--main", "README.md"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = "openmeta.rb"
21
+ s.rubygems_version = "2.0.3"
22
+ s.signing_key = "/Users/zhaocai/.gem/gem-private_key.pem"
23
+ s.summary = "openMeta in Ruby (MacRuby, more exactly!)"
24
+
25
+ if s.respond_to? :specification_version then
26
+ s.specification_version = 4
27
+
28
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<thor>, ["~> 0.18.0"])
30
+ s.add_runtime_dependency(%q<filetype>, ["~> 0.3.0"])
31
+ s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
32
+ s.add_development_dependency(%q<rspec>, [">= 2.13"])
33
+ s.add_development_dependency(%q<rake>, [">= 10.0.0"])
34
+ s.add_development_dependency(%q<hoe>, [">= 0"])
35
+ s.add_development_dependency(%q<hoe-gemspec>, [">= 0"])
36
+ s.add_development_dependency(%q<hoe-git>, [">= 0"])
37
+ s.add_development_dependency(%q<hoe-version>, [">= 0"])
38
+ s.add_development_dependency(%q<hoe-bundler>, [">= 0"])
39
+ s.add_development_dependency(%q<guard>, [">= 0"])
40
+ s.add_development_dependency(%q<guard-rspec>, [">= 0"])
41
+ s.add_development_dependency(%q<terminal-notifier-guard>, [">= 0"])
42
+ s.add_development_dependency(%q<growl>, [">= 0"])
43
+ else
44
+ s.add_dependency(%q<thor>, ["~> 0.18.0"])
45
+ s.add_dependency(%q<filetype>, ["~> 0.3.0"])
46
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
47
+ s.add_dependency(%q<rspec>, [">= 2.13"])
48
+ s.add_dependency(%q<rake>, [">= 10.0.0"])
49
+ s.add_dependency(%q<hoe>, [">= 0"])
50
+ s.add_dependency(%q<hoe-gemspec>, [">= 0"])
51
+ s.add_dependency(%q<hoe-git>, [">= 0"])
52
+ s.add_dependency(%q<hoe-version>, [">= 0"])
53
+ s.add_dependency(%q<hoe-bundler>, [">= 0"])
54
+ s.add_dependency(%q<guard>, [">= 0"])
55
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
56
+ s.add_dependency(%q<terminal-notifier-guard>, [">= 0"])
57
+ s.add_dependency(%q<growl>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thor>, ["~> 0.18.0"])
61
+ s.add_dependency(%q<filetype>, ["~> 0.3.0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
63
+ s.add_dependency(%q<rspec>, [">= 2.13"])
64
+ s.add_dependency(%q<rake>, [">= 10.0.0"])
65
+ s.add_dependency(%q<hoe>, [">= 0"])
66
+ s.add_dependency(%q<hoe-gemspec>, [">= 0"])
67
+ s.add_dependency(%q<hoe-git>, [">= 0"])
68
+ s.add_dependency(%q<hoe-version>, [">= 0"])
69
+ s.add_dependency(%q<hoe-bundler>, [">= 0"])
70
+ s.add_dependency(%q<guard>, [">= 0"])
71
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
72
+ s.add_dependency(%q<terminal-notifier-guard>, [">= 0"])
73
+ s.add_dependency(%q<growl>, [">= 0"])
74
+ end
75
+ end
@@ -11,7 +11,7 @@ describe "Openmeta" do
11
11
  FileUtils .touch @testfiles
12
12
  end
13
13
 
14
- it "should return raise ArgumentError if file does not exist" do
14
+ it "should return raise Openmeta::ObjcError if file does not exist" do
15
15
  expect { Openmeta.get_tags("/path/to/nowhere") }.to raise_error(Openmeta::ObjCError)
16
16
  end
17
17
 
metadata CHANGED
@@ -1,15 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openmeta.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhao Cai
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAljYWl6
14
+ aGFvZmYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
15
+ bTAeFw0xMzA0MTYxMzAxMzlaFw0xNDA0MTYxMzAxMzlaMEAxEjAQBgNVBAMMCWNh
16
+ aXpoYW9mZjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
17
+ Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu2zqh0u+TbhY5kNf
18
+ Z4OI5AZnXyIE6xVjO7mpp5t5qS+6m8iPIwWYhVTzFm/TDHX1jJ1Dauy7/iXA5m+i
19
+ xAKAOmCiL2j1VudVz+qBKPwiPAG3O0gtLWsxX5J5BwMimakOmDTGmXAEJCCYNjs8
20
+ 9hdJzcGLydTpQU3RuAn2RE+Y7Rzwm3RAW/hMs5PDdx/3XtksHlQ54is4zob0aCOs
21
+ hJ9TYLpaKvtZCixX0YyiIuAl07BI4sYyXNNWzk+tHf5RlJ3d/oXR/XxLI6xH2v+h
22
+ RMsQVqF9UKGANhc8yhrcL7YnG6G8v8fkdJFKa2ZuBSIqYKCLl4ATcXD6tTF+THTf
23
+ oVxAGQIDAQABo3kwdzAJBgNVHRMEAjAAMB0GA1UdDgQWBBSCk5kEqlkwgrdYCHRk
24
+ wy0ZQt1eeTAeBgNVHREEFzAVgRNjYWl6aGFvZmZAZ21haWwuY29tMAsGA1UdDwQE
25
+ AwIEsDAeBgNVHRIEFzAVgRNjYWl6aGFvZmZAZ21haWwuY29tMA0GCSqGSIb3DQEB
26
+ BQUAA4IBAQCle3HlwCgKX19WNYY2EcJYilQCZJPtl/Gj1EbefaX3paMym6yO4FB9
27
+ i2yP1WTVB4N8OrS0z24b6mo5jKgplyTU6w9D+yI5WKbN4C7XCbBLeNGVlD9yK8CA
28
+ zc+igDfc63grzUR5Xj7PPxef4owUdz+XDG+mmmv6wNyXSzQUtFyZ8ucVL1vk5ihP
29
+ vZU7EDLfcHe3xiTYkarBtblwtSj6PHtYn/1v8ztYHhGKvW3wTTiplNwnW4Sx2Wfa
30
+ eIuFwYbmfyt5/ObUtmp3BlaIStTiX9TBWeuTx6Zq6q6wDzcudbDRd+jLa2XG2AGB
31
+ S6w/KYMnbhUxfyEU1MX10sJv87WIrtgF
32
+ -----END CERTIFICATE-----
11
33
 
12
- date: 2013-04-02 00:00:00 Z
34
+ date: 2013-05-04 00:00:00 Z
13
35
  dependencies:
14
36
  - !ruby/object:Gem::Dependency
15
37
  name: thor
@@ -18,115 +40,125 @@ dependencies:
18
40
  requirements:
19
41
  - - ~>
20
42
  - !ruby/object:Gem::Version
21
- version: 0.17.0
43
+ version: 0.18.0
22
44
  type: :runtime
23
45
  version_requirements: *id001
24
46
  - !ruby/object:Gem::Dependency
25
- name: rdoc
47
+ name: filetype
26
48
  prerelease: false
27
49
  requirement: &id002 !ruby/object:Gem::Requirement
28
50
  requirements:
29
51
  - - ~>
30
52
  - !ruby/object:Gem::Version
31
- version: "3.10"
32
- type: :development
53
+ version: 0.3.0
54
+ type: :runtime
33
55
  version_requirements: *id002
34
56
  - !ruby/object:Gem::Dependency
35
- name: rspec
57
+ name: rdoc
36
58
  prerelease: false
37
59
  requirement: &id003 !ruby/object:Gem::Requirement
38
60
  requirements:
39
- - - ">="
61
+ - - ~>
40
62
  - !ruby/object:Gem::Version
41
- version: "2.13"
63
+ version: "4.0"
42
64
  type: :development
43
65
  version_requirements: *id003
44
66
  - !ruby/object:Gem::Dependency
45
- name: rake
67
+ name: rspec
46
68
  prerelease: false
47
69
  requirement: &id004 !ruby/object:Gem::Requirement
48
70
  requirements:
49
71
  - - ">="
50
72
  - !ruby/object:Gem::Version
51
- version: 10.0.0
73
+ version: "2.13"
52
74
  type: :development
53
75
  version_requirements: *id004
54
76
  - !ruby/object:Gem::Dependency
55
- name: hoe
77
+ name: rake
56
78
  prerelease: false
57
79
  requirement: &id005 !ruby/object:Gem::Requirement
58
80
  requirements:
59
- - &id006
60
- - ">="
81
+ - - ">="
61
82
  - !ruby/object:Gem::Version
62
- version: "0"
83
+ version: 10.0.0
63
84
  type: :development
64
85
  version_requirements: *id005
65
86
  - !ruby/object:Gem::Dependency
66
- name: hoe-gemspec
87
+ name: hoe
67
88
  prerelease: false
68
- requirement: &id007 !ruby/object:Gem::Requirement
89
+ requirement: &id006 !ruby/object:Gem::Requirement
69
90
  requirements:
70
- - *id006
91
+ - &id007
92
+ - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
71
95
  type: :development
72
- version_requirements: *id007
96
+ version_requirements: *id006
73
97
  - !ruby/object:Gem::Dependency
74
- name: hoe-git
98
+ name: hoe-gemspec
75
99
  prerelease: false
76
100
  requirement: &id008 !ruby/object:Gem::Requirement
77
101
  requirements:
78
- - *id006
102
+ - *id007
79
103
  type: :development
80
104
  version_requirements: *id008
81
105
  - !ruby/object:Gem::Dependency
82
- name: hoe-version
106
+ name: hoe-git
83
107
  prerelease: false
84
108
  requirement: &id009 !ruby/object:Gem::Requirement
85
109
  requirements:
86
- - *id006
110
+ - *id007
87
111
  type: :development
88
112
  version_requirements: *id009
89
113
  - !ruby/object:Gem::Dependency
90
- name: hoe-bundler
114
+ name: hoe-version
91
115
  prerelease: false
92
116
  requirement: &id010 !ruby/object:Gem::Requirement
93
117
  requirements:
94
- - *id006
118
+ - *id007
95
119
  type: :development
96
120
  version_requirements: *id010
97
121
  - !ruby/object:Gem::Dependency
98
- name: guard
122
+ name: hoe-bundler
99
123
  prerelease: false
100
124
  requirement: &id011 !ruby/object:Gem::Requirement
101
125
  requirements:
102
- - *id006
126
+ - *id007
103
127
  type: :development
104
128
  version_requirements: *id011
105
129
  - !ruby/object:Gem::Dependency
106
- name: guard-rspec
130
+ name: guard
107
131
  prerelease: false
108
132
  requirement: &id012 !ruby/object:Gem::Requirement
109
133
  requirements:
110
- - *id006
134
+ - *id007
111
135
  type: :development
112
136
  version_requirements: *id012
113
137
  - !ruby/object:Gem::Dependency
114
- name: terminal-notifier-guard
138
+ name: guard-rspec
115
139
  prerelease: false
116
140
  requirement: &id013 !ruby/object:Gem::Requirement
117
141
  requirements:
118
- - *id006
142
+ - *id007
119
143
  type: :development
120
144
  version_requirements: *id013
121
145
  - !ruby/object:Gem::Dependency
122
- name: growl
146
+ name: terminal-notifier-guard
123
147
  prerelease: false
124
148
  requirement: &id014 !ruby/object:Gem::Requirement
125
149
  requirements:
126
- - *id006
150
+ - *id007
127
151
  type: :development
128
152
  version_requirements: *id014
129
- description: openMeta in Ruby (MacRuby, more exactly!). This gem ports [openmeta]( http://code.google.com/p/openmeta/ ) api to macruby using framework.
153
+ - !ruby/object:Gem::Dependency
154
+ name: growl
155
+ prerelease: false
156
+ requirement: &id015 !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - *id007
159
+ type: :development
160
+ version_requirements: *id015
161
+ description: openMeta in Ruby (support mac system native ruby 1.8, and MacRuby). This gem ports [openmeta]( http://code.google.com/p/openmeta/ ) api to ruby using framework.
130
162
  email:
131
163
  - caizhaoff@gmail.com
132
164
  executables:
@@ -136,7 +168,12 @@ extensions: []
136
168
  extra_rdoc_files:
137
169
  - History.txt
138
170
  - Manifest.txt
171
+ - README.md
139
172
  files:
173
+ - .gemtest
174
+ - .ruby-version
175
+ - Gemfile
176
+ - Gemfile.lock
140
177
  - Guardfile
141
178
  - History.txt
142
179
  - Manifest.txt
@@ -153,11 +190,13 @@ files:
153
190
  - lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/Info.plist
154
191
  - lib/openmeta/framework/OpenMeta.framework/Versions/A/Resources/en.lproj/InfoPlist.strings
155
192
  - lib/openmeta/friendly_errors.rb
193
+ - lib/openmeta/macruby.rb
194
+ - lib/openmeta/rubycocoa.rb
156
195
  - lib/openmeta/ui.rb
157
196
  - lib/openmeta/version.rb
197
+ - openmeta.rb.gemspec
158
198
  - spec/openmeta_spec.rb
159
199
  - spec/spec_helper.rb
160
- - .gemtest
161
200
  homepage: http://zhaocai.github.com/openmeta.rb
162
201
  licenses:
163
202
  - GPL-3
@@ -171,16 +210,16 @@ require_paths:
171
210
  - lib
172
211
  required_ruby_version: !ruby/object:Gem::Requirement
173
212
  requirements:
174
- - *id006
213
+ - *id007
175
214
  required_rubygems_version: !ruby/object:Gem::Requirement
176
215
  requirements:
177
- - *id006
216
+ - *id007
178
217
  requirements: []
179
218
 
180
219
  rubyforge_project: openmeta.rb
181
220
  rubygems_version: 2.0.3
182
221
  signing_key:
183
222
  specification_version: 4
184
- summary: openMeta in Ruby (MacRuby, more exactly!)
223
+ summary: openMeta in Ruby (support mac system native ruby 1.8, and MacRuby)
185
224
  test_files: []
186
225
 
@@ -0,0 +1,2 @@
1
+ gf������>TjA�&��K��k�I�#�;�z�7G���Ov��*�����ω�k{�i�d����;�`ԟдsVp�& ��9������W=~hB.�$��q;� o�*Vh]��lR��fxg�dhș��i�'B����3�s�T{d9J灓Ś��d�gҥ;]��{c%Q� *��rqx��*8�X�Y]S#�:�M脽��{�s�@�,-�yո��z�K�o
2
+ I���0l{cb�(� A9