spotlight 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.log
20
+ *.o
21
+ Makefile
22
+
23
+ ## MAC OS
24
+ .DS_Store
25
+
26
+ ## EMACS
27
+ *~
28
+ \#*
29
+ .\#*
30
+
31
+ ## VIM
32
+ *.swp
33
+
34
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mac-event-monitor.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env rake
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require "bundler/gem_tasks"
5
+
6
+ ext_names = %w/md_query_native md_item_native/
7
+ ext_names.each do |ext_name|
8
+ CLEAN.include Dir.glob("ext/#{ext_name}/*{.o,.log}")
9
+ CLEAN.include "ext/#{ext_name}/Makefile"
10
+ CLOBBER.include "ext/#{ext_name}/#{ext_name}.bundle"
11
+ CLOBBER.include "lib/#{ext_name}.bundle"
12
+
13
+ file "lib/#{ext_name}.bundle" =>
14
+ Dir.glob("ext/#{ext_name}/*{.rb,.m}") do
15
+ Dir.chdir("ext/#{ext_name}") do
16
+ ruby "extconf.rb"
17
+ sh "make"
18
+ end
19
+ cp "ext/#{ext_name}/#{ext_name}.bundle", "lib/"
20
+ end
21
+
22
+ task :spec => "lib/#{ext_name}.bundle"
23
+ end
24
+
25
+ require 'rspec/core'
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:spec) do |spec|
28
+ spec.pattern = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ task :default => :spec
@@ -172,7 +172,7 @@ static VALUE cMDItemNative_attribute_names(int argc, VALUE *argv, VALUE self)
172
172
  if(cfAttributeNames != NULL) {
173
173
  numAttributes = (int)CFArrayGetCount(cfAttributeNames);
174
174
  for(i = 0; i < numAttributes; i ++) {
175
- rb_ary_push(result, CFString2RString((CFStringRef)CFArrayGetValueAtIndex(cfAttributeNames, i)));
175
+ rb_ary_push(result, rb_str_intern(CFString2RString((CFStringRef)CFArrayGetValueAtIndex(cfAttributeNames, i))));
176
176
  }
177
177
  }
178
178
 
@@ -9,3 +9,15 @@
9
9
  VALUE createInstanceFromMDItem(MDItemRef item);
10
10
 
11
11
  #endif
12
+
13
+ #ifndef RUBY_19
14
+ #ifndef RFLOAT_VALUE
15
+ #define RFLOAT_VALUE(v) (RFLOAT(v)->value)
16
+ #endif
17
+ #ifndef RARRAY_LEN
18
+ #define RARRAY_LEN(v) (RARRAY(v)->len)
19
+ #endif
20
+ #ifndef RARRAY_PTR
21
+ #define RARRAY_PTR(v) (RARRAY(v)->ptr)
22
+ #endif
23
+ #endif
@@ -40,10 +40,11 @@ static VALUE cMDQueryNative_new(int argc, VALUE *argv, VALUE klass)
40
40
  {
41
41
  VALUE queryString;
42
42
  VALUE obj;
43
+ struct QueryObject *q;
43
44
 
44
45
  rb_scan_args(argc, argv, "1", &queryString);
45
46
 
46
- struct QueryObject *q = malloc(sizeof(struct QueryObject));
47
+ q = malloc(sizeof(struct QueryObject));
47
48
  q->queryString = CString2CFString(StringValuePtr(queryString));
48
49
  q->query = MDQueryCreate(kCFAllocatorDefault, q->queryString, NULL, NULL);
49
50
  obj = Data_Wrap_Struct(klass, 0, cMDQueryNative_free, q);
@@ -59,15 +60,15 @@ static VALUE cMDQueryNative_set_search_scopes(int argc, VALUE *argv, VALUE self)
59
60
  int i;
60
61
 
61
62
  rb_scan_args(argc, argv, "1", &scopes);
62
- itemsList = (CFStringRef *)malloc(sizeof(CFStringRef) * (RARRAY(scopes)->len));
63
+ itemsList = (CFStringRef *)malloc(sizeof(CFStringRef) * (RARRAY_LEN(scopes)));
63
64
 
64
- for(i = 0; i < RARRAY(scopes)->len; i ++) {
65
- itemsList[i] = (CFStringRef)CString2CFString(StringValuePtr(RARRAY(scopes)->ptr[i]));
65
+ for(i = 0; i < RARRAY_LEN(scopes); i ++) {
66
+ itemsList[i] = (CFStringRef)CString2CFString(StringValuePtr(RARRAY_PTR(scopes)[i]));
66
67
  }
67
68
 
68
69
  scopesList = CFArrayCreate(kCFAllocatorDefault,
69
70
  (const void**)itemsList,
70
- RARRAY(scopes)->len,
71
+ RARRAY_LEN(scopes),
71
72
  NULL);
72
73
  MDQuerySetSearchScope(getQuery(self), scopesList, 0);
73
74
 
@@ -19,9 +19,9 @@ module Spotlight
19
19
  end
20
20
 
21
21
  def execute
22
- @md_query = MDQueryNative.new(query_string)
23
- @md_query.set_search_scopes(@scopes)
24
- @md_query.execute
22
+ md_query = MDQueryNative.new(query_string)
23
+ md_query.set_search_scopes(scopes)
24
+ md_query.execute
25
25
  end
26
26
 
27
27
  def to_saved_search(filename)
@@ -0,0 +1,95 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CompatibleVersion</key>
6
+ <integer>1</integer>
7
+ <key>RawQuery</key>
8
+ <string>((true) &amp;&amp; (true)) &amp;&amp; ((* = "test*"cdw || kMDItemTextContent = "test*"cdw))</string>
9
+ <key>RawQueryDict</key>
10
+ <dict>
11
+ <key>FinderFilesOnly</key>
12
+ <true/>
13
+ <key>RawQuery</key>
14
+ <string>((true) &amp;&amp; (true)) &amp;&amp; ((* = "test*"cdw || kMDItemTextContent = "test*"cdw))</string>
15
+ <key>SearchScopes</key>
16
+ <array>
17
+ <string>kMDQueryScopeComputer</string>
18
+ </array>
19
+ <key>UserFilesOnly</key>
20
+ <true/>
21
+ </dict>
22
+ <key>SearchCriteria</key>
23
+ <dict>
24
+ <key>AnyAttributeContains</key>
25
+ <string>test</string>
26
+ <key>CurrentFolderPath</key>
27
+ <array>
28
+ <string>/Users/youpy</string>
29
+ </array>
30
+ <key>FXCriteriaSlices</key>
31
+ <array>
32
+ <dict>
33
+ <key>criteria</key>
34
+ <array>
35
+ <string>com_apple_UserSearchStringAttribute</string>
36
+ <integer>104</integer>
37
+ </array>
38
+ <key>displayValues</key>
39
+ <array>
40
+ <string>Items matching text</string>
41
+ <string>test</string>
42
+ </array>
43
+ <key>rowType</key>
44
+ <integer>0</integer>
45
+ <key>subrows</key>
46
+ <array/>
47
+ </dict>
48
+ <dict>
49
+ <key>criteria</key>
50
+ <array>
51
+ <string>kMDItemKind</string>
52
+ <integer>300</integer>
53
+ <integer>400</integer>
54
+ </array>
55
+ <key>displayValues</key>
56
+ <array>
57
+ <string>Kind</string>
58
+ <string>is</string>
59
+ <string>any</string>
60
+ </array>
61
+ <key>rowType</key>
62
+ <integer>0</integer>
63
+ <key>subrows</key>
64
+ <array/>
65
+ </dict>
66
+ </array>
67
+ <key>FXScope</key>
68
+ <integer>1396925814</integer>
69
+ <key>FXScopeArrayOfPaths</key>
70
+ <array>
71
+ <string>kMDQueryScopeComputer</string>
72
+ </array>
73
+ </dict>
74
+ <key>ViewOptions</key>
75
+ <dict>
76
+ <key>SidebarWidth</key>
77
+ <integer>242</integer>
78
+ <key>ToolbarVisible</key>
79
+ <true/>
80
+ <key>ViewStyle</key>
81
+ <string>icnv</string>
82
+ <key>WindowBounds</key>
83
+ <dict>
84
+ <key>bottom</key>
85
+ <integer>0</integer>
86
+ <key>left</key>
87
+ <integer>0</integer>
88
+ <key>right</key>
89
+ <integer>0</integer>
90
+ <key>top</key>
91
+ <integer>0</integer>
92
+ </dict>
93
+ </dict>
94
+ </dict>
95
+ </plist>
@@ -26,6 +26,6 @@ describe Spotlight::MDItemNative do
26
26
  it "should get attribute names" do
27
27
  attribute_names = @item.attribute_names
28
28
  attribute_names.should be_an_instance_of(Array)
29
- attribute_names.should be_include('kMDItemKind')
29
+ attribute_names.should be_include(:kMDItemKind)
30
30
  end
31
31
  end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,19 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'rubygems'
3
4
  require 'spotlight'
4
- require 'spec'
5
- require 'spec/autorun'
6
5
 
7
- system('mdimport ' + File.dirname(__FILE__))
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
9
+ # loaded once.
10
+ #
11
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
8
16
 
9
- Spec::Runner.configure do |config|
10
17
  def fixture(filename)
11
18
  File.dirname(__FILE__) + '/fixtures/' + filename
12
19
  end
@@ -41,6 +41,6 @@ describe Spotlight::Query do
41
41
 
42
42
  it "should execute query with empty scope" do
43
43
  result = @query.execute
44
- result.should_not be_empty
44
+ result.should_not be_empty
45
45
  end
46
46
  end
data/spotlight.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #require File.expand_path(__FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["youpy"]
6
+ gem.email = ["youpy@buycheapviagraonlinenow.com"]
7
+ gem.description = %q{Library to use Spotlight from Ruby}
8
+ gem.summary = %q{Library to use Spotlight from Ruby}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "spotlight"
15
+ gem.extensions = ["ext/md_item_native/extconf.rb", "ext/md_query_native/extconf.rb"]
16
+ gem.require_paths = ["lib"]
17
+ gem.version = '0.0.6'
18
+
19
+ gem.add_dependency('plist')
20
+
21
+ gem.add_development_dependency('rake')
22
+ gem.add_development_dependency('rspec', ['~> 2.8.0'])
23
+ gem.add_development_dependency('spotlight')
24
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 6
10
+ version: 0.0.6
5
11
  platform: ruby
6
12
  authors:
7
13
  - youpy
@@ -9,87 +15,134 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-19 00:00:00 +09:00
13
- default_executable:
18
+ date: 2012-11-16 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
20
23
  requirements:
21
24
  - - ">="
22
25
  - !ruby/object:Gem::Version
23
- version: 1.2.9
24
- version:
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ prerelease: false
31
+ type: :runtime
32
+ name: plist
33
+ requirement: *id001
25
34
  - !ruby/object:Gem::Dependency
26
- name: rake-compiler
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
30
37
  requirements:
31
38
  - - ">="
32
39
  - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
33
43
  version: "0"
34
- version:
44
+ prerelease: false
45
+ type: :development
46
+ name: rake
47
+ requirement: *id002
35
48
  - !ruby/object:Gem::Dependency
36
- name: plist
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ hash: 47
55
+ segments:
56
+ - 2
57
+ - 8
58
+ - 0
59
+ version: 2.8.0
60
+ prerelease: false
37
61
  type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
62
+ name: rspec
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
40
67
  requirements:
41
68
  - - ">="
42
69
  - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
43
73
  version: "0"
44
- version:
74
+ prerelease: false
75
+ type: :development
76
+ name: spotlight
77
+ requirement: *id004
45
78
  description: Library to use Spotlight from Ruby
46
- email: youpy@buycheapviagraonlinenow.com
79
+ email:
80
+ - youpy@buycheapviagraonlinenow.com
47
81
  executables: []
48
82
 
49
83
  extensions:
50
84
  - ext/md_item_native/extconf.rb
51
85
  - ext/md_query_native/extconf.rb
52
- extra_rdoc_files:
86
+ extra_rdoc_files: []
87
+
88
+ files:
89
+ - .document
90
+ - .gitignore
91
+ - Gemfile
53
92
  - LICENSE
54
93
  - README.rdoc
55
- files:
94
+ - Rakefile
95
+ - ext/md_item_native/extconf.rb
56
96
  - ext/md_item_native/md_item_native.c
57
97
  - ext/md_item_native/md_item_native.h
98
+ - ext/md_query_native/extconf.rb
58
99
  - ext/md_query_native/md_query_native.c
59
100
  - lib/spotlight.rb
60
101
  - lib/spotlight/query.rb
61
- - LICENSE
62
- - README.rdoc
63
- has_rdoc: true
64
- homepage: http://github.com/youpy/ruby-spotlight
102
+ - spec/fixtures/test.savedSearch
103
+ - spec/md_item_native_spec.rb
104
+ - spec/md_query_native_spec.rb
105
+ - spec/spec.opts
106
+ - spec/spec_helper.rb
107
+ - spec/spotlight_query_spec.rb
108
+ - spotlight.gemspec
109
+ homepage: ""
65
110
  licenses: []
66
111
 
67
112
  post_install_message:
68
- rdoc_options:
69
- - --charset=UTF-8
113
+ rdoc_options: []
114
+
70
115
  require_paths:
71
116
  - lib
72
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
73
119
  requirements:
74
120
  - - ">="
75
121
  - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
76
125
  version: "0"
77
- version:
78
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
79
128
  requirements:
80
129
  - - ">="
81
130
  - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
82
134
  version: "0"
83
- version:
84
135
  requirements: []
85
136
 
86
137
  rubyforge_project:
87
- rubygems_version: 1.3.5
138
+ rubygems_version: 1.8.24
88
139
  signing_key:
89
140
  specification_version: 3
90
- summary: Spotlight for Ruby
141
+ summary: Library to use Spotlight from Ruby
91
142
  test_files:
143
+ - spec/fixtures/test.savedSearch
92
144
  - spec/md_item_native_spec.rb
93
145
  - spec/md_query_native_spec.rb
146
+ - spec/spec.opts
94
147
  - spec/spec_helper.rb
95
148
  - spec/spotlight_query_spec.rb