gir_ffi-tracker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,3 @@
1
+ load 'tasks/setup.rb'
2
+
3
+ task :default => 'test'
@@ -0,0 +1 @@
1
+ require 'gir_ffi-tracker'
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
@@ -0,0 +1,9 @@
1
+ begin
2
+ require "rdoc/task"
3
+
4
+ RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force") do |rdoc|
5
+ rdoc.main = "README.rdoc"
6
+ rdoc.rdoc_files.include "README.rdoc", "lib/**/*.rb"
7
+ end
8
+ rescue LoadError
9
+ end
data/tasks/setup.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rake/clean'
2
+
3
+ # Load the other rake files in the tasks folder
4
+ tasks_dir = File.expand_path(File.dirname(__FILE__))
5
+ rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
6
+ import(*rakefiles)
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
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new do |t|
5
+ t.files = ['lib/**/*.rb']
6
+ t.options = ['--private', '--protected', '--readme', 'README.rdoc']
7
+ end
8
+ rescue LoadError
9
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe "Upon load" do
4
+ describe "the Tracker module" do
5
+ it "should exist" do
6
+ Tracker
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+
6
+ require 'ffi-tracker'
7
+
@@ -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,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gir_ffi-tracker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matijs van Zuijlen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gir_ffi
16
+ requirement: &13684780 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *13684780
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &13684280 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.2
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *13684280
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &13683800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *13683800
47
+ description:
48
+ email:
49
+ - matijs@matijs.net
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files:
53
+ - README.rdoc
54
+ files:
55
+ - lib/ffi-tracker.rb
56
+ - test/test_helper.rb
57
+ - test/unit/tracker_sparql_cursor_test.rb
58
+ - test/integration/load_test.rb
59
+ - tasks/yardoc.rake
60
+ - tasks/rdoc.rake
61
+ - tasks/test.rake
62
+ - tasks/setup.rb
63
+ - tasks/notes.rake
64
+ - README.rdoc
65
+ - Rakefile
66
+ homepage: http://www.github.com/mvz/ffi-tracker
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --main
71
+ - README.rdoc
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.11
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: GirFFI-based binding to Tracker
92
+ test_files:
93
+ - test/integration/load_test.rb
94
+ - test/test_helper.rb
95
+ - test/unit/tracker_sparql_cursor_test.rb