ffi-tracker 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.
- data/README.rdoc +22 -0
- data/Rakefile +3 -0
- data/lib/ffi-tracker.rb +15 -0
- data/tasks/notes.rake +121 -0
- data/tasks/rdoc.rake +6 -0
- data/tasks/setup.rb +6 -0
- data/tasks/test.rake +25 -0
- data/tasks/yardoc.rake +6 -0
- data/test/integration/load_test.rb +9 -0
- data/test/test_helper.rb +7 -0
- data/test/unit/tracker_sparql_cursor_test.rb +13 -0
- metadata +111 -0
data/README.rdoc
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= ffi-tracker
|
2
|
+
|
3
|
+
by Matijs van Zuijlen
|
4
|
+
|
5
|
+
http://www.github.com/mvz/ffi-tracker
|
6
|
+
|
7
|
+
== Description
|
8
|
+
|
9
|
+
Ruby bindings for Tracker using GirFFI.
|
10
|
+
|
11
|
+
== Features
|
12
|
+
|
13
|
+
* Auto-generated bindings using GObject introspection.
|
14
|
+
* Adds overrides for introspection data bugs.
|
15
|
+
|
16
|
+
== License
|
17
|
+
|
18
|
+
Copyright (c) 2011 Matijs van Zuijlen
|
19
|
+
|
20
|
+
ffi-tracker is free software, distributed under the terms of the GNU Lesser
|
21
|
+
General Public License, version 2.1 or later. See the file COPYING.LIB for
|
22
|
+
more information.
|
data/Rakefile
ADDED
data/lib/ffi-tracker.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'gir_ffi'
|
2
|
+
|
3
|
+
GirFFI.setup :Tracker
|
4
|
+
|
5
|
+
module Tracker
|
6
|
+
SparqlCursor.class_eval do
|
7
|
+
def get_string_with_hidden_length column
|
8
|
+
result, length = *get_string_without_hidden_length(column)
|
9
|
+
result
|
10
|
+
end
|
11
|
+
|
12
|
+
alias get_string_without_hidden_length get_string
|
13
|
+
alias get_string get_string_with_hidden_length
|
14
|
+
end
|
15
|
+
end
|
data/tasks/notes.rake
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# The following code is copied straight from Bones 2.5.1
|
2
|
+
#
|
3
|
+
|
4
|
+
module Bones
|
5
|
+
|
6
|
+
# A helper class used to find and display any annotations in a collection of
|
7
|
+
# project files.
|
8
|
+
#
|
9
|
+
class AnnotationExtractor
|
10
|
+
|
11
|
+
class Annotation < Struct.new(:line, :tag, :text)
|
12
|
+
# Returns a string representation of the annotation. If the
|
13
|
+
# <tt>:tag</tt> parameter is given as +true+, then the annotation tag
|
14
|
+
# will be included in the string.
|
15
|
+
#
|
16
|
+
def to_s( opts = {} )
|
17
|
+
s = "[%3d] " % line
|
18
|
+
s << "[#{tag}] " if opts[:tag]
|
19
|
+
s << text
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Enumerate all the annoations for the given _project_ and _tag_. This
|
24
|
+
# will search for all athe annotations and display them on standard
|
25
|
+
# output.
|
26
|
+
#
|
27
|
+
def self.enumerate tag, id = nil, opts = {}
|
28
|
+
extractor = new(tag, id)
|
29
|
+
extractor.display(extractor.find, opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_reader :tag, :id
|
33
|
+
|
34
|
+
# Creates a new annotation extractor configured to use the _project_ open
|
35
|
+
# strcut and to search for the given _tag_ (which can be more than one tag
|
36
|
+
# via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
|
37
|
+
#
|
38
|
+
def initialize tag, id
|
39
|
+
@tag = tag
|
40
|
+
@id = @id_rgxp = nil
|
41
|
+
|
42
|
+
unless id.nil? or id.empty?
|
43
|
+
@id = id
|
44
|
+
@id_rgxp = Regexp.new(Regexp.escape(id), Regexp::IGNORECASE)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Iterate over all the files in the project and extract annotations from
|
49
|
+
# the those files. Returns the results as a hash for display.
|
50
|
+
#
|
51
|
+
def find
|
52
|
+
results = {}
|
53
|
+
rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
|
54
|
+
|
55
|
+
files = Dir.glob("lib/**/*.rb")
|
56
|
+
files += Dir.glob("test/**/*.rb")
|
57
|
+
files.each do |fn|
|
58
|
+
results.update(extract_annotations_from(fn, rgxp))
|
59
|
+
end
|
60
|
+
|
61
|
+
results
|
62
|
+
end
|
63
|
+
|
64
|
+
# Extract any annotations from the given _file_ using the regular
|
65
|
+
# expression _pattern_ provided.
|
66
|
+
#
|
67
|
+
def extract_annotations_from( file, pattern )
|
68
|
+
lineno = 0
|
69
|
+
result = File.readlines(file).inject([]) do |list, line|
|
70
|
+
lineno += 1
|
71
|
+
next list unless m = pattern.match(line)
|
72
|
+
next list << Annotation.new(lineno, m[1], m[2]) unless id
|
73
|
+
|
74
|
+
text = m[2]
|
75
|
+
if text =~ @id_rgxp
|
76
|
+
list << Annotation.new(lineno, m[1], text)
|
77
|
+
end
|
78
|
+
list
|
79
|
+
end
|
80
|
+
result.empty? ? {} : { file => result }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the results of the annotation extraction to the screen. If the
|
84
|
+
# <tt>:tags</tt> option is set to +true+, then the annotation tag will be
|
85
|
+
# displayed.
|
86
|
+
#
|
87
|
+
def display( results, opts = {} )
|
88
|
+
results.keys.sort.each do |file|
|
89
|
+
puts "#{file}:"
|
90
|
+
results[file].each do |note|
|
91
|
+
puts " * #{note.to_s(opts)}"
|
92
|
+
end
|
93
|
+
puts
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end # class AnnotationExtractor
|
98
|
+
end # module Bones
|
99
|
+
|
100
|
+
note_tags = ["TODO", "FIXME", "OPTIMIZE"]
|
101
|
+
|
102
|
+
desc "Enumerate all annotations"
|
103
|
+
task :notes do |t|
|
104
|
+
id = if t.application.top_level_tasks.length > 1
|
105
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
106
|
+
end
|
107
|
+
Bones::AnnotationExtractor.enumerate(
|
108
|
+
note_tags.join('|'), id, :tag => true)
|
109
|
+
end
|
110
|
+
|
111
|
+
namespace :notes do
|
112
|
+
note_tags.each do |tag|
|
113
|
+
desc "Enumerate all #{tag} annotations"
|
114
|
+
task tag.downcase.to_sym do |t|
|
115
|
+
id = if t.application.top_level_tasks.length > 1
|
116
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
117
|
+
end
|
118
|
+
Bones::AnnotationExtractor.enumerate(tag, id)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/tasks/rdoc.rake
ADDED
data/tasks/setup.rb
ADDED
data/tasks/test.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
namespace :test do
|
4
|
+
|
5
|
+
Rake::TestTask.new(:unit) do |t|
|
6
|
+
t.libs = ['lib']
|
7
|
+
t.test_files = FileList['test/unit/*_test.rb']
|
8
|
+
t.ruby_opts += ["-w"]
|
9
|
+
end
|
10
|
+
|
11
|
+
Rake::TestTask.new(:integration) do |t|
|
12
|
+
t.libs = ['lib']
|
13
|
+
t.test_files = FileList['test/integration/*_test.rb']
|
14
|
+
t.ruby_opts += ["-w"]
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run rcov for the entire test suite'
|
18
|
+
task :coverage do
|
19
|
+
rm_f "coverage"
|
20
|
+
system "rcov", "-Ilib", "--exclude", "\.gem\/,\/gems\/", *FileList['test/**/*_test.rb']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Run unit and integration tests'
|
25
|
+
task :test => ['test:unit', 'test:integration']
|
data/tasks/yardoc.rake
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tracker::SparqlCursor do
|
4
|
+
describe "#get_string" do
|
5
|
+
it "returns just the string value" do
|
6
|
+
conn = Tracker::SparqlConnection.get_direct nil
|
7
|
+
cursor = conn.query "SELECT ?url WHERE { ?x a nie:InformationElement; nie:url ?url. }", nil
|
8
|
+
|
9
|
+
cursor.next nil
|
10
|
+
assert_instance_of String, cursor.get_string(0)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffi-tracker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Matijs van Zuijlen
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: gir_ffi
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- 11
|
33
|
+
version: 0.0.11
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: minitest
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 11
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 0
|
48
|
+
- 2
|
49
|
+
version: 2.0.2
|
50
|
+
type: :development
|
51
|
+
version_requirements: *id002
|
52
|
+
description:
|
53
|
+
email:
|
54
|
+
- matijs@matijs.net
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.rdoc
|
61
|
+
files:
|
62
|
+
- lib/ffi-tracker.rb
|
63
|
+
- test/test_helper.rb
|
64
|
+
- test/unit/tracker_sparql_cursor_test.rb
|
65
|
+
- test/integration/load_test.rb
|
66
|
+
- tasks/yardoc.rake
|
67
|
+
- tasks/rdoc.rake
|
68
|
+
- tasks/test.rake
|
69
|
+
- tasks/setup.rb
|
70
|
+
- tasks/notes.rake
|
71
|
+
- README.rdoc
|
72
|
+
- Rakefile
|
73
|
+
homepage: http://www.github.com/mvz/ffi-tracker
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --main
|
79
|
+
- README.rdoc
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.7.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: FFI-based binding to Tracker, using the GObject Introspection Repository
|
107
|
+
test_files:
|
108
|
+
- test/integration/load_test.rb
|
109
|
+
- test/test_helper.rb
|
110
|
+
- test/unit/tracker_sparql_cursor_test.rb
|
111
|
+
has_rdoc:
|