rea 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.
Files changed (48) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/Gemfile +16 -0
  3. data/Gemfile.lock +48 -0
  4. data/LICENCE.md +22 -0
  5. data/Manifest.txt +15 -0
  6. data/README.md +7 -0
  7. data/Rakefile +23 -0
  8. data/bin/rea +8 -0
  9. data/lib/rea-dblp/rea/dblp.rb +59 -0
  10. data/lib/rea-dblp/rea/dblp/entry_parser.rb +48 -0
  11. data/lib/rea-dblp/rea/dblp/grab.rb +14 -0
  12. data/lib/rea-dblp/rea/dblp/parser.rb +36 -0
  13. data/lib/rea-dblp/rea/dblp/query_result_parser.rb +38 -0
  14. data/lib/rea-dblp/rea/dblp/search.rb +18 -0
  15. data/lib/rea.rb +28 -0
  16. data/lib/rea/command.rb +62 -0
  17. data/lib/rea/command/search.rb +52 -0
  18. data/lib/rea/command/utils.rb +31 -0
  19. data/lib/rea/errors.rb +62 -0
  20. data/lib/rea/loader.rb +8 -0
  21. data/lib/rea/version.rb +14 -0
  22. data/lib/rea/work_key.rb +33 -0
  23. data/rea.gemspec +192 -0
  24. data/rea.noespec +33 -0
  25. data/spec/rea-dblp/fixtures/entries/Damas2005.xml +17 -0
  26. data/spec/rea-dblp/fixtures/entries/Damas2009.xml +16 -0
  27. data/spec/rea-dblp/fixtures/entries/Erroneous.xml +1 -0
  28. data/spec/rea-dblp/fixtures/entries/QueryEntry.xml +15 -0
  29. data/spec/rea-dblp/fixtures/entries/Unrecognized.xml +3 -0
  30. data/spec/rea-dblp/fixtures/query_results/Erroneous.xml +1 -0
  31. data/spec/rea-dblp/fixtures/query_results/QueryResult.xml +25 -0
  32. data/spec/rea-dblp/fixtures/query_results/Unrecognized.xml +3 -0
  33. data/spec/rea-dblp/test_entry_parser.rb +72 -0
  34. data/spec/rea-dblp/test_grab.rb +18 -0
  35. data/spec/rea-dblp/test_query_result_parser.rb +38 -0
  36. data/spec/rea-dblp/test_search.rb +18 -0
  37. data/spec/spec_helper.rb +12 -0
  38. data/spec/test_rea.rb +12 -0
  39. data/spec/work_key/test_parse.rb +28 -0
  40. data/spec/work_key/test_to_ruby_literal.rb +20 -0
  41. data/spec/work_key/test_to_s.rb +12 -0
  42. data/tasks/debug_mail.rake +75 -0
  43. data/tasks/debug_mail.txt +13 -0
  44. data/tasks/gem.rake +68 -0
  45. data/tasks/spec_test.rake +71 -0
  46. data/tasks/unit_test.rake +76 -0
  47. data/tasks/yard.rake +51 -0
  48. metadata +215 -0
@@ -0,0 +1,52 @@
1
+ module Rea
2
+ class Command
3
+ #
4
+ # Search publications on the online libraries
5
+ #
6
+ # SYNOPSIS
7
+ # #{command_name} [options] ARG
8
+ #
9
+ # OPTIONS
10
+ # #{summarized_options}
11
+ #
12
+ class Search < Quickl::Command(__FILE__, __LINE__)
13
+ include Utils
14
+
15
+ # Install options
16
+ options do |opt|
17
+ @provider = Rea::providers.first
18
+ @mainarg = :title
19
+ @query = {}
20
+ Rea::providers.each do |p|
21
+ opt.on("--#{p.shortcut}", "Search on #{p.url}"){
22
+ @provider = p
23
+ }
24
+ end
25
+ opt.on("--title=[TITLE]", "Specify the publication title"){|title|
26
+ if title
27
+ @query[:title] = title
28
+ else
29
+ @mainarg = :title
30
+ end
31
+ }
32
+ @keep = nil
33
+ opt.on("--show=a,b,c",
34
+ "Only show a, b, and c attributes", Array) do |list|
35
+ @keep = list.map(&:to_sym)
36
+ end
37
+ end
38
+
39
+ def run(*args)
40
+ puts pretty(super, @keep)
41
+ end
42
+
43
+ # Run the command
44
+ def execute(args)
45
+ raise Quickl::Help if args.size > 1
46
+ @query[@mainarg] = args.first if args.size == 1
47
+ @provider.search(@query)
48
+ end
49
+
50
+ end # class Search
51
+ end # class Command
52
+ end # module Rea
@@ -0,0 +1,31 @@
1
+ module Rea
2
+ class Command
3
+ module Utils
4
+
5
+ DEFAULT_INFO = {
6
+ :title => "[Unknown title]",
7
+ :authors => ["[Unknown author]"],
8
+ :year => "[Unknown year]",
9
+ :key => "[Unknown key]",
10
+ :source => "[Unknown source]",
11
+ }
12
+
13
+ def pretty(rel, keep = nil)
14
+ keep ||= [:code, :key, :author, :title, :year, :source]
15
+ Relation(rel).
16
+ defaults(DEFAULT_INFO).
17
+ extend(:authors => lambda{
18
+ authors.empty? ? ["[Unknown author]"] : authors
19
+ }).
20
+ extend(
21
+ :code => lambda{ authors.first.split(/\s/).last + year.to_s },
22
+ :title => lambda{ title[0..50] },
23
+ :author => lambda{ authors.first }
24
+ ).project(keep)
25
+ rescue
26
+ Relation(rel).project(keep)
27
+ end
28
+
29
+ end # module Utils
30
+ end # class Command
31
+ end # module Rea
@@ -0,0 +1,62 @@
1
+ module Rea
2
+
3
+ class Error < StandardError
4
+ attr_reader :cause
5
+ def initialize(msg, cause = $!)
6
+ super(msg)
7
+ @cause = cause
8
+ end
9
+ end
10
+
11
+ class SystemError < Error
12
+ end
13
+ class ParseFormatError < SystemError; end
14
+ class NotImplementedError < SystemError; end
15
+
16
+ class DomainError < Error
17
+ end
18
+ class ParseError < DomainError; end
19
+ class NotFoundError < DomainError; end
20
+ class ThirdPartyError < DomainError; end
21
+ class UsageError < DomainError; end
22
+
23
+ module ErrorUtils
24
+
25
+ def error_message(msg, source = nil, cause = $!)
26
+ msg = msg.dup
27
+ msg << " #{source}" if source
28
+ msg << ", #{cause.message}" if cause
29
+ msg
30
+ end
31
+
32
+ def parse_error!(source)
33
+ msg = error_message("Error while parsing", source)
34
+ raise Rea::ParseError, msg
35
+ end
36
+
37
+ def third_party_error!(source)
38
+ msg = error_message("Error with third party service", source)
39
+ raise Rea::ThirdPartyError, msg
40
+ end
41
+
42
+ def not_found_error!(source)
43
+ msg = error_message("Unable to find", source)
44
+ raise Rea::NotFoundError, msg
45
+ end
46
+
47
+ def parse_format_error!(source)
48
+ msg = error_message("Unexpected parsing error (#{source})")
49
+ raise Rea::ParseFormatError, msg
50
+ end
51
+
52
+ def not_implemented_error!(msg)
53
+ raise Rea::NotImplementedError, msg
54
+ end
55
+
56
+ def unexpected_error!(source)
57
+ msg = error_message("Unexpected error (#{source})")
58
+ raise Rea::SystemError, msg
59
+ end
60
+
61
+ end
62
+ end # module Rea
@@ -0,0 +1,8 @@
1
+ require "http"
2
+ require "nokogiri"
3
+ require "quickl"
4
+ require "pdf/toolkit"
5
+ require "epath"
6
+ require "alf"
7
+ require "unicode"
8
+ require "bibtex"
@@ -0,0 +1,14 @@
1
+ module Rea
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ TINY = 1
7
+
8
+ def self.to_s
9
+ [ MAJOR, MINOR, TINY ].join('.')
10
+ end
11
+
12
+ end
13
+ VERSION = Version.to_s
14
+ end
@@ -0,0 +1,33 @@
1
+ module Rea
2
+ class WorkKey
3
+
4
+ attr_reader :provider
5
+ attr_reader :identifier
6
+
7
+ def initialize(provider, identifier)
8
+ @provider, @identifier = provider, identifier
9
+ end
10
+
11
+ def self.parse(str)
12
+ return str if str.is_a?(WorkKey)
13
+ unless str.strip =~ /^([a-z]+):\/\/(.+)$/
14
+ raise ArgumentError, "Invalid work key #{str}"
15
+ end
16
+ WorkKey.new($1, $2)
17
+ end
18
+
19
+ def ==(other)
20
+ other.is_a?(WorkKey) and other.to_s == to_s
21
+ end
22
+ alias :eql? :==
23
+
24
+ def to_s
25
+ "#{provider}://#{identifier}"
26
+ end
27
+
28
+ def to_ruby_literal
29
+ "Rea::WorkKey(#{to_s.inspect})"
30
+ end
31
+
32
+ end # class WorkKey
33
+ end # module Rea
@@ -0,0 +1,192 @@
1
+ # We require your library, mainly to have access to the VERSION number.
2
+ # Feel free to set $version manually.
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require "rea/version"
5
+ $version = Rea::Version.to_s
6
+
7
+ #
8
+ # This is your Gem specification. Default values are provided so that your library
9
+ # should be correctly packaged given what you have described in the .noespec file.
10
+ #
11
+ Gem::Specification.new do |s|
12
+
13
+ ################################################################### ABOUT YOUR GEM
14
+
15
+ # Gem name (required)
16
+ s.name = "rea"
17
+
18
+ # Gem version (required)
19
+ s.version = $version
20
+
21
+ # A short summary of this gem
22
+ #
23
+ # This is displayed in `gem list -d`.
24
+ s.summary = "Research Exploring Assistant"
25
+
26
+ # A long description of this gem (required)
27
+ #
28
+ # The description should be more detailed than the summary. For example,
29
+ # you might wish to copy the entire README into the description.
30
+ s.description = "Helper to build a mental map of a research topic."
31
+
32
+ # The URL of this gem home page (optional)
33
+ s.homepage = "https://github.com/blambeau/rea"
34
+
35
+ # Gem publication date (required but auto)
36
+ #
37
+ # Today is automatically used by default, uncomment only if
38
+ # you know what you do!
39
+ #
40
+ # s.date = Time.now.strftime('%Y-%m-%d')
41
+
42
+ # The license(s) for the library. Each license must be a short name, no
43
+ # more than 64 characters.
44
+ #
45
+ # s.licences = %w{}
46
+
47
+ # The rubyforge project this gem lives under (optional)
48
+ #
49
+ # s.rubyforge_project = nil
50
+
51
+ ################################################################### ABOUT THE AUTHORS
52
+
53
+ # The list of author names who wrote this gem.
54
+ #
55
+ # If you are providing multiple authors and multiple emails they should be
56
+ # in the same order.
57
+ #
58
+ s.authors = ["Bernard Lambeau"]
59
+
60
+ # Contact emails for this gem
61
+ #
62
+ # If you are providing multiple authors and multiple emails they should be
63
+ # in the same order.
64
+ #
65
+ # NOTE: Somewhat strangly this attribute is always singular!
66
+ # Don't replace by s.emails = ...
67
+ s.email = ["blambeau@gmail.com"]
68
+
69
+ ################################################################### PATHS, FILES, BINARIES
70
+
71
+ # Paths in the gem to add to $LOAD_PATH when this gem is
72
+ # activated (required).
73
+ #
74
+ # The default 'lib' is typically sufficient.
75
+ s.require_paths = ["lib"]
76
+
77
+ # Files included in this gem.
78
+ #
79
+ # By default, we take all files included in the Manifest.txt file on root
80
+ # of the project. Entries of the manifest are interpreted as Dir[...]
81
+ # patterns so that lazy people may use wilcards like lib/**/*
82
+ #
83
+ here = File.expand_path(File.dirname(__FILE__))
84
+ s.files = File.readlines(File.join(here, 'Manifest.txt')).
85
+ inject([]){|files, pattern| files + Dir[File.join(here, pattern.strip)]}.
86
+ collect{|x| x[(1+here.size)..-1]}
87
+
88
+ # Test files included in this gem.
89
+ #
90
+ s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
91
+
92
+ # The path in the gem for executable scripts (optional)
93
+ #
94
+ s.bindir = "bin"
95
+
96
+ # Executables included in the gem.
97
+ #
98
+ s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
99
+
100
+ ################################################################### REQUIREMENTS & INSTALL
101
+ # Remember the gem version requirements operators and schemes:
102
+ # = Equals version
103
+ # != Not equal to version
104
+ # > Greater than version
105
+ # < Less than version
106
+ # >= Greater than or equal to
107
+ # <= Less than or equal to
108
+ # ~> Approximately greater than
109
+ #
110
+ # Don't forget to have a look at http://lmgtfy.com/?q=Ruby+Versioning+Policies
111
+ # for setting your gem version.
112
+ #
113
+ # For your requirements to other gems, remember that
114
+ # ">= 2.2.0" (optimistic: specify minimal version)
115
+ # ">= 2.2.0", "< 3.0" (pessimistic: not greater than the next major)
116
+ # "~> 2.2" (shortcut for ">= 2.2.0", "< 3.0")
117
+ # "~> 2.2.0" (shortcut for ">= 2.2.0", "< 2.3.0")
118
+ #
119
+
120
+ #
121
+ # One call to add_dependency('gem_name', 'gem version requirement') for each
122
+ # runtime dependency. These gems will be installed with your gem.
123
+ # One call to add_development_dependency('gem_name', 'gem version requirement')
124
+ # for each development dependency. These gems are required for developers
125
+ #
126
+ s.add_development_dependency("rake", "~> 0.9.2")
127
+ s.add_development_dependency("rspec", "~> 2.8.0")
128
+ s.add_dependency("http", "~> 0.1.0")
129
+ s.add_dependency("nokogiri", "~> 1.5")
130
+ s.add_dependency("quickl", "~> 0.4.2")
131
+ s.add_dependency("pdf-toolkit", "= 1.0.0.rc1")
132
+ s.add_dependency("epath", "~> 0.0.1")
133
+ s.add_dependency("alf", "~> 0.12.0")
134
+ s.add_dependency("bibtex-ruby", "~> 2.0")
135
+
136
+ # The version of ruby required by this gem
137
+ #
138
+ # Uncomment and set this if your gem requires specific ruby versions.
139
+ #
140
+ # s.required_ruby_version = ">= 0"
141
+
142
+ # The RubyGems version required by this gem
143
+ #
144
+ # s.required_rubygems_version = ">= 0"
145
+
146
+ # The platform this gem runs on. See Gem::Platform for details.
147
+ #
148
+ # s.platform = nil
149
+
150
+ # Extensions to build when installing the gem.
151
+ #
152
+ # Valid types of extensions are extconf.rb files, configure scripts
153
+ # and rakefiles or mkrf_conf files.
154
+ #
155
+ s.extensions = []
156
+
157
+ # External (to RubyGems) requirements that must be met for this gem to work.
158
+ # It’s simply information for the user.
159
+ #
160
+ s.requirements = nil
161
+
162
+ # A message that gets displayed after the gem is installed
163
+ #
164
+ # Uncomment and set this if you want to say something to the user
165
+ # after gem installation
166
+ #
167
+ s.post_install_message = nil
168
+
169
+ ################################################################### SECURITY
170
+
171
+ # The key used to sign this gem. See Gem::Security for details.
172
+ #
173
+ # s.signing_key = nil
174
+
175
+ # The certificate chain used to sign this gem. See Gem::Security for
176
+ # details.
177
+ #
178
+ # s.cert_chain = []
179
+
180
+ ################################################################### RDOC
181
+
182
+ # An ARGV style array of options to RDoc
183
+ #
184
+ # See 'rdoc --help' about this
185
+ #
186
+ s.rdoc_options = []
187
+
188
+ # Extra files to add to RDoc such as README
189
+ #
190
+ s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
191
+
192
+ end
@@ -0,0 +1,33 @@
1
+ template-info:
2
+ name: "ruby"
3
+ version: 1.7.0
4
+ links:
5
+ source: https://github.com/blambeau/noe
6
+ manifest:
7
+ lib/__lower__/loader.rb:
8
+ safe-override: false
9
+ variables:
10
+ lower:
11
+ rea
12
+ upper:
13
+ Rea
14
+ version:
15
+ 0.0.1
16
+ summary: |-
17
+ Research Exploring Assistant
18
+ description: |-
19
+ Helper to build a mental map of a research topic.
20
+ authors:
21
+ - {name: Bernard Lambeau, email: blambeau@gmail.com}
22
+ links:
23
+ - https://github.com/blambeau/rea
24
+ dependencies:
25
+ - {name: http, version: "~> 0.1.0", groups: [runtime]}
26
+ - {name: nokogiri, version: "~> 1.5", groups: [runtime]}
27
+ - {name: quickl, version: "~> 0.4.2", groups: [runtime]}
28
+ - {name: pdf-toolkit, version: "= 1.0.0.rc1", groups: [runtime]}
29
+ - {name: epath, version: "~> 0.0.1", groups: [runtime]}
30
+ - {name: alf, version: "~> 0.12.0", groups: [runtime]}
31
+ - {name: bibtex-ruby, version: "~> 2.0", groups: [runtime]}
32
+ - {name: rake, version: "~> 0.9.2", groups: [development]}
33
+ - {name: rspec, version: "~> 2.8.0", groups: [development]}
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0"?>
2
+ <dblp>
3
+ <article key="journals/tse/DamasLDL05" mdate="2006-08-22">
4
+ <author>Christophe Damas</author>
5
+ <author>Bernard Lambeau</author>
6
+ <author>Pierre Dupont</author>
7
+ <author>Axel van Lamsweerde</author>
8
+ <title>Generating Annotated Behavior Models from End-User Scenarios.</title>
9
+ <pages>1056-1073</pages>
10
+ <year>2005</year>
11
+ <volume>31</volume>
12
+ <journal>IEEE Trans. Software Eng.</journal>
13
+ <number>12</number>
14
+ <ee>http://doi.ieeecomputersociety.org/10.1109/TSE.2005.138</ee>
15
+ <url>db/journals/tse/tse31.html#DamasLDL05</url>
16
+ </article>
17
+ </dblp>