bivy 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +21 -0
  2. data/History +16 -0
  3. data/LICENSE +29 -0
  4. data/README.rdoc +37 -0
  5. data/Rakefile +43 -0
  6. data/TODO +12 -0
  7. data/VERSION +1 -0
  8. data/bin/bivy.rb +56 -0
  9. data/bin/pubmed_to_bivy.rb +78 -0
  10. data/doc/config.yaml +13 -0
  11. data/doc/src/default.css +126 -0
  12. data/doc/src/default.template +38 -0
  13. data/doc/src/tutorial/basic_flow.page +71 -0
  14. data/doc/src/tutorial/index.page +8 -0
  15. data/doc/src/tutorial/new_formats_and_media.page +83 -0
  16. data/jrn_abbrev/abbr_html.tgz +0 -0
  17. data/jrn_abbrev/abbr_to_journal.yaml +676 -0
  18. data/jrn_abbrev/download_abbrevs.rb +20 -0
  19. data/jrn_abbrev/for_ruby_class.rb +686 -0
  20. data/jrn_abbrev/html_to_yaml.rb +50 -0
  21. data/lib/bibliography.rb +144 -0
  22. data/lib/bivy.rb +4 -0
  23. data/lib/citation.rb +194 -0
  24. data/lib/format.rb +120 -0
  25. data/lib/format/acs.rb +88 -0
  26. data/lib/format/bioinformatics.rb +33 -0
  27. data/lib/format/bmc.rb +38 -0
  28. data/lib/format/jtp.rb +30 -0
  29. data/lib/format/mla.rb +50 -0
  30. data/lib/formatter.rb +276 -0
  31. data/lib/journal.rb +6 -0
  32. data/lib/journal/iso_to_full.yaml +1320 -0
  33. data/lib/journal/medline_to_full.yaml +7 -0
  34. data/lib/journal/medline_to_iso.yaml +45 -0
  35. data/lib/media.rb +88 -0
  36. data/lib/media/html.rb +65 -0
  37. data/lib/ooffice.rb +39 -0
  38. data/lib/pubmed.rb +209 -0
  39. data/lib/rtf.rb +217 -0
  40. data/old_stuff/old_list2refs.rb +103 -0
  41. data/old_stuff/pubmed2html.rb +119 -0
  42. data/old_stuff/pubmed_bib_write.rb +92 -0
  43. data/old_stuff/xml.tmp.xml +115 -0
  44. data/scripts/merge_bibs.rb +70 -0
  45. data/spec/bibliography_spec.rb +127 -0
  46. data/spec/citation_positions.odt +0 -0
  47. data/spec/formatter_spec.rb +14 -0
  48. data/spec/formatter_spec/cits_after.xml +2 -0
  49. data/spec/formatter_spec/cits_before.xml +2 -0
  50. data/spec/formatter_spec/content.xml +2 -0
  51. data/spec/ooffice_spec.rb +27 -0
  52. data/spec/pubmed_spec.rb +26 -0
  53. data/spec/spec_helper.rb +7 -0
  54. data/spec/testfiles/doc1.odt +0 -0
  55. metadata +136 -0
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/History ADDED
@@ -0,0 +1,16 @@
1
+ ==0.0.5 / 2010-11-01
2
+
3
+ * all tests to specs
4
+ * works with 1.9.2
5
+
6
+ == 0.0.4 / 2010-03-15
7
+
8
+ * switched repo to jeweler
9
+
10
+ == 0.0.3
11
+
12
+ * basic functionality in place (wrote 122 reference/132 citation document with article, article_to_be_submitted, and webpage using it)
13
+ * easier introduction of new formats
14
+ * deal with missing journals in a better manner
15
+
16
+
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2006, The University of Texas at Austin("U.T. Austin"). All
2
+ rights reserved.
3
+
4
+ Software by John T. Prince under the direction of Edward M. Marcotte.
5
+
6
+ By using this software the USER indicates that he or she has read, understood
7
+ and will comply with the following:
8
+
9
+ U. T. Austin hereby grants USER permission to use, copy, modify, merge,
10
+ publish, distribute, sublicense, and/or sell copies of this software and its
11
+ documentation for any purpose and without fee, provided that a full copy of
12
+ this notice is included with the software and its documentation.
13
+
14
+ Title to copyright this software and its associated documentation shall at all
15
+ times remain with U. T. Austin. No right is granted to use in advertising,
16
+ publicity or otherwise any trademark, service mark, or the name of U. T.
17
+ Austin.
18
+
19
+ This software and any associated documentation are provided "as is," and U. T.
20
+ AUSTIN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING
21
+ THOSE OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT USE OF
22
+ THE SOFTWARE, MODIFICATIONS, OR ASSOCIATED DOCUMENTATION WILL NOT INFRINGE ANY
23
+ PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF A
24
+ THIRD PARTY. U. T. Austin, The University of Texas System, its Regents,
25
+ officers, and employees shall not be liable under any circumstances for any
26
+ direct, indirect, special, incidental, or consequential damages with respect
27
+ to any claim by USER or any third party on account of or arising from the use,
28
+ or inability to use, this software or its associated documentation, even if U.
29
+ T. Austin has been advised of the possibility of those damages.
data/README.rdoc ADDED
@@ -0,0 +1,37 @@
1
+ = bivy
2
+
3
+ bivy - (*b*ibliography *i*n *v*im and *y*aml) is a lightweight alternative to
4
+ bibliographic management systems. bivy aims to provides simple tools to
5
+ create a bibliography in whatever format you need, all from bibliographies
6
+ stored in a yaml file (the bivy file).
7
+
8
+ == History
9
+
10
+ I wanted a simple bibliography generator for use on any platform that worked
11
+ well with OpenOffice. Having tried my hand a few times at it, I think I
12
+ finally have a light footprint system that is easy to setup and gets the job
13
+ done.
14
+
15
+ Bivy sacks are a lightweight alternative to a tent. (I'm sure you see the
16
+ parallel) Also, you don't really *have to* use vim, it just worked for the
17
+ acronymn and it *is* really handy for editing your yaml file.
18
+
19
+ == Features
20
+
21
+ * yaml based bibliography files
22
+ * lookup of bibliographic information from a pubmed ID
23
+ * formatting of citations in a document based on identifiers
24
+ * modular creation of bibliographies in any format or output
25
+ * easy addition of new formats or outputs
26
+ * simple modification of OpenOffice documents
27
+
28
+ == Current Focus
29
+
30
+ * Simple OpenOffice support: 1) replaces citations with correct citation
31
+ number 2) outputs bibliography in html that can be directly imported into
32
+ document.
33
+ * PubMed support (downloads xml from web and adds to bivy file)
34
+
35
+ == Copyright
36
+
37
+ See LICENSE for details. (MIT-ish license)
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "bivy"
9
+ gem.summary = %Q{roll your own citation manager (if you like that sort of thing)}
10
+ gem.description = %Q{uses a simple YAML format to store bibliographies. Then modifies citations in openoffice and outputs a bibliography (in different forms) for inclusion in the document}
11
+ gem.email = "jtprince@gmail.com"
12
+ gem.homepage = "http://github.com/jtprince/bivy"
13
+ gem.authors = ["John Prince"]
14
+ gem.add_development_dependency "spec-more", ">= 0"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+
18
+ # test
19
+ Rake::TestTask.new(:spec) do |spec|
20
+ spec.libs << 'lib' << 'spec'
21
+ spec.pattern = 'spec/**/*_spec.rb'
22
+ spec.verbose = true
23
+ end
24
+
25
+ #require 'rcov/rcovtask'
26
+ #Rcov::RcovTask.new do |spec|
27
+ # spec.libs << 'spec'
28
+ # spec.pattern = 'spec/**/*_spec.rb'
29
+ # spec.verbose = true
30
+ #end
31
+
32
+ task :spec => :check_dependencies
33
+
34
+ task :default => :spec
35
+
36
+ Rake::RDocTask.new do |rdoc|
37
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
38
+
39
+ rdoc.rdoc_dir = 'rdoc'
40
+ rdoc.title = "bivy #{version}"
41
+ rdoc.rdoc_files.include('README*')
42
+ rdoc.rdoc_files.include('lib/**/*.rb')
43
+ end
data/TODO ADDED
@@ -0,0 +1,12 @@
1
+
2
+
3
+ high-priority:
4
+ redo citation to reference (in lib and docs)
5
+ need even better system for missing journals
6
+ more complete tests, convert to rspec
7
+ add some major styles
8
+ add 'book'
9
+ document 'author' and how it operates
10
+
11
+ low-priority:
12
+ citations in different formats than just numbering
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.5
data/bin/bivy.rb ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ require 'optparse'
4
+
5
+ require 'formatter'
6
+ require 'bibliography'
7
+ require 'format'
8
+ require 'media'
9
+
10
+ $format_type = :jtp
11
+ $citation = nil
12
+ $yaml = nil
13
+ $cit_order = nil
14
+ opts = OptionParser.new do |op|
15
+ op.banner = "usage: #{File.basename(__FILE__)} <bibliography>.yaml <file>.odt"
16
+ op.separator "outputs: <file>.cit.odt <file>.bib.html"
17
+ op.on("-f", "--format <type>", "type = jtp|acs|mla|bioinformatics|bmc") {|v| $format_type = v.to_sym }
18
+ op.on("--cit-pos <position>", "position = before|after the punctuation") {|v| $citation = v }
19
+ op.on("--yaml <file>", "outputs bib used to file") {|v| $yaml = v }
20
+ op.on("--cit-order <file>", "outputs initial appearance of citations IDs") {|v| $cit_order = v }
21
+ end
22
+
23
+ opts.parse!
24
+
25
+ if ARGV.size != 2
26
+ puts opts
27
+ exit
28
+ end
29
+
30
+ format_obj = Format.new(Media.new(:html), $format_type)
31
+
32
+ bib = ARGV.shift
33
+ odt = ARGV.shift
34
+
35
+ options = {}
36
+ if $format_type == :mla or $format_type == :bioinformatics
37
+ options[:bib] = :mla
38
+ elsif $format_type == :bmc
39
+ options[:bracket] = true
40
+ end
41
+ if $citation
42
+ options[:cit_pos] = $citation.to_sym
43
+ end
44
+
45
+ outfile = odt.sub(/\.odt$/, '.bib.html')
46
+ bib_object = Formatter.new.create_bibliography(odt, bib, options)
47
+ if $cit_order
48
+ File.open($cit_order, 'w') {|out| out.print( bib_object.citations.map {|c| c.ident }.join("\n") ) }
49
+ end
50
+
51
+ string = bib_object.write(format_obj)
52
+ File.open(outfile, 'w') {|fh| fh.print string }
53
+ if $yaml
54
+ bib_object.to_yaml($yaml)
55
+ end
56
+
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'optparse'
4
+ require 'ostruct'
5
+
6
+ require 'pubmed'
7
+ require 'citation'
8
+ require 'bibliography'
9
+
10
+ bib_re = /bib\.ya?ml$/i
11
+ attemped_bib = Dir["*"].select {|v| v =~ bib_re }.first
12
+
13
+ opt = OpenStruct.new
14
+ opt.bib =
15
+ if attemped_bib.nil?
16
+ "bib.yml"
17
+ else
18
+ attemped_bib
19
+ end
20
+
21
+
22
+ opts = OptionParser.new do |op|
23
+ op.banner = "usage: #{File.basename(__FILE__)} [OPTIONS] pubmed_id ..."
24
+ op.separator ""
25
+ op.separator " appends citations to #{opt.bib} and outputs lines of identifiers"
26
+ op.on("-b", "--bib", "filename of the bibliography (using: #{opt.bib})",
27
+ "if == STDOUT, then prints to STDOUT") {|v| opt.bib = v }
28
+ op.on("-i", "--id Array", Array, "give a unique identifier") {|v| opt.identifier = v}
29
+ op.on("-q", "--quotes Array", Array, "direct or parenthetical") {|v| opt.quotes = v}
30
+ op.separator " * Arrays are parallel to id's"
31
+ end
32
+
33
+ opts.parse!
34
+
35
+ if ARGV.size < 1
36
+ puts opts
37
+ exit
38
+ end
39
+
40
+ pmids = ARGV.to_a
41
+
42
+ opt.stdout = true if opt.bib == 'STDOUT'
43
+
44
+ cits = pmids.to_a.map do |pmid|
45
+ pm = PubMed.new(pmid)
46
+ if opt.identifier
47
+ uniq_id = opt.identifier.shift
48
+ pm.ident = uniq_id
49
+ end
50
+ pm
51
+ end
52
+
53
+ if opt.stdout
54
+ puts Bibliography.new(cits).to_yaml
55
+ else
56
+ bib = Bibliography.from_yaml(opt.bib)
57
+ clashing = bib.add( *cits )
58
+ if clashing == nil
59
+ sub_clashing = []
60
+ else
61
+ sub_clashing = clashing
62
+ end
63
+ added = cits - sub_clashing
64
+ added.each do |ad|
65
+ puts "#[#{ad.ident}]"
66
+ end
67
+ if clashing
68
+ puts "ID#{((clashing.size > 1) ? 's' : '')} already taken! (see '-i' flag):\n"
69
+ clashing.each do |clash|
70
+ if bib.citations.any? {|cit| ((cit.respond_to?(:pmid)) and (clash.pmid == cit.pmid)) }
71
+ puts "#{clash.pmid}: '#{clash.ident}' (pmid already present!)"
72
+ else
73
+ puts "#{clash.pmid}: '#{clash.ident}'"
74
+ end
75
+ end
76
+ end
77
+ bib.to_yaml(opt.bib)
78
+ end
data/doc/config.yaml ADDED
@@ -0,0 +1,13 @@
1
+ # Configuration file for webgen
2
+ # Used to set the parameters of the plugins
3
+ FileCopyHandler:
4
+ paths:
5
+ - "**/*.css"
6
+ - "**/*.jpg"
7
+ - "**/*.png"
8
+ - "**/*.gif"
9
+ - "**/*.js"
10
+ - "**/*.html"
11
+ PageFileHandler:
12
+ defaultPageMetaData:
13
+ blocks: [{name: content, format: markdown}]
@@ -0,0 +1,126 @@
1
+
2
+ h1 {
3
+ font-size: 20px;
4
+ font-family: sans-serif;
5
+ font-style: italic;
6
+ background-color: #555;
7
+ color: white;
8
+ padding: 4px;
9
+ margin-right: 0%;
10
+ }
11
+ h2 {
12
+ font-family: sans-serif;
13
+ border-bottom: 1px solid #CCC;
14
+ color: #B00707;
15
+ font-size: 16px;
16
+ }
17
+ pre {
18
+ font-family: monospace;
19
+ color: #222;
20
+ background-color: #DDD;
21
+ /*border: 1px solid #BBB; */
22
+ padding: 4px;
23
+ padding-left: 8px;
24
+ margin-right: 10px;
25
+ margin-left: 25px;
26
+ font-size: 9pt;
27
+
28
+ }
29
+
30
+ #all { background-color: #CCCCCC; }
31
+
32
+ #header {
33
+ border-bottom: 1px solid black;
34
+ padding: 1ex;
35
+ background-color: white; /* #888888 */
36
+ }
37
+ #header h1 {
38
+ background-color: white;
39
+ color: #B00707;
40
+ text-decoration: none;
41
+ margin: 0ex;
42
+ font-size: 200%;
43
+ font-style: normal;
44
+ font-weight: bold;
45
+ }
46
+
47
+
48
+ , #headerbar { border-bottom: 1px solid black; }
49
+ #footer { border-top: 1px solid black; }
50
+
51
+ #body {
52
+ font-size: 90%;
53
+ margin-left: 220px;
54
+ margin-right: 20px;
55
+ padding: 10px;
56
+ }
57
+
58
+ a {text-decoration:none; }
59
+ a:link {color:#6E3ABC; }
60
+ a:visited {color: #3E1A9C;}
61
+ a:hover {color: #00AA00; background-color: #EEEEEE;}
62
+ a:focus {color: #333333;}
63
+ a:active {color: #009900;}
64
+
65
+
66
+ #menu {
67
+ float: left;
68
+ width: 200px;
69
+ padding: 20px 0px 0px 2px;
70
+ }
71
+
72
+ .bar {
73
+ clear: both;
74
+ padding: 3px;
75
+ text-align: center;
76
+ font-size: 90%;
77
+ background-color: #AAAAAA;
78
+ }
79
+
80
+ .left, .right {
81
+ padding: 0px 1em;
82
+ }
83
+
84
+ .left {
85
+ float: left;
86
+ text-align: left;
87
+ }
88
+
89
+ .right {
90
+ float: right;
91
+ text-align: right;
92
+ }
93
+
94
+ /* styling the menu */
95
+
96
+ #menu a {
97
+ text-decoration: none;
98
+ font-weight: bold;
99
+ font-size: 130%;
100
+ font-family: sans-serif;
101
+ }
102
+
103
+ #menu a:hover {
104
+ /* text-decoration: underline; */
105
+ }
106
+
107
+ #menu .webgen-menuitem-selected {
108
+ border-left: 3px solid black;
109
+ }
110
+
111
+ #menu ul {
112
+ list-style-type: none;
113
+ padding: 0px;
114
+ margin-left: 10px;
115
+ }
116
+
117
+ #menu li > ul {
118
+ font-size: 95%;
119
+ }
120
+
121
+ #menu li {
122
+ margin: 0.0em 0px;
123
+ padding: 2px 0px;
124
+ padding-left: 5px;
125
+ /* border-left: 3px solid #CCCCCC; */
126
+ }