dblpbib 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f01d4f12edd5bf3d2710757b297ab42cb15f1d
4
- data.tar.gz: 385ef7e9ec050fbb2915168df7e0a829a763753b
3
+ metadata.gz: 1f2fc3c8c6c1ce8bc1b2ac7d3fff7faf1692b2ec
4
+ data.tar.gz: 2a2505420e97e7c148ad1be58079424da4ce863a
5
5
  SHA512:
6
- metadata.gz: 4c5f0343e9c8032d8f36790c31073c6c102d77ac6ca5646f136a0630ef8a399d3e0d0e0cb926640cf6ef9ac86f83a6bea2068213b054488c4068a00742ed44b5
7
- data.tar.gz: 814060d32e05cec0850d0c8e8aa1a2f7fd702b19ab933b728e8554592df02d922c515dab6a811194eee7503610ba5730507742e439897aecba954bcdc4f6d406
6
+ metadata.gz: f19341d7b2d3743d37ad983136fc9614b19e9afde241a11ae0cd9137a51bcf94ecbd562d3e0ff06e4e6b0b65c12907d13c652738a0e406cbd03090b1ade9c2e6
7
+ data.tar.gz: 1392b30cfec220967a26debb1c7c3e699608a15bc7cf54a6dc64bdcaed219c0c0d264cdf8aade66247e8e70d846553a6b71fe6a444cef4b0654c339afb8d0a7b
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- .idea
10
+ .idea
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ # Plain wrong :)
2
+ Layout/Tab:
3
+ Enabled: false
4
+ Layout/IndentationWidth:
5
+ Width: 1
6
+
7
+ # Just annoying
8
+ Metrics/AbcSize:
9
+ Enabled: false
10
+ Metrics/AbcSize:
11
+ Enabled: false
12
+ Metrics/BlockLength:
13
+ Enabled: false
14
+ Metrics/MethodLength:
15
+ Enabled: false
16
+
17
+ # Multiline regexes
18
+ Style/RegexpLiteral:
19
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
4
+ - 2.1
5
+ - 2.4.1
6
+ before_install: gem install bundler
7
+ install: bundle install --jobs=3 --retry=3
8
+ script:
9
+ - rubocop
10
+ - rake
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "dblpbib"
3
+ require 'bundler/setup'
4
+ require 'dblpbib'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
10
+ # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/dblpbib.gemspec CHANGED
@@ -1,29 +1,34 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
+
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'dblpbib/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "dblpbib"
8
- spec.version = Dblpbib::VERSION
9
- spec.authors = ["PJK"]
10
- spec.email = ["me@pavelkalvoda.com"]
7
+ spec.name = 'dblpbib'
8
+ spec.version = Dblpbib::VERSION
9
+ spec.authors = ['PJK']
10
+ spec.email = ['me@pavelkalvoda.com']
11
11
 
12
- spec.summary = Dblpbib::DESCRIPTION
13
- spec.description = %q{Automatically create bibliographies for BibTeX DBLP references. This utility is meant to be invoked during LaTeX build. It scans the documents for DBLP references and compiles a cached .bib file. Correctly handles crosslinking. Entries can be overridden. Other bibliography sources can still be included.}
14
- spec.homepage = "https://github.com/PJK/dblpbib"
15
- spec.license = "MIT"
12
+ spec.summary = Dblpbib::DESCRIPTION
13
+ spec.description = 'Automatically create bibliographies for BibTeX DBLP
14
+ references. This utility is meant to be invoked during LaTeX build. It scans
15
+ the documents for DBLP references and compiles a cached .bib file. Correctly
16
+ handles crosslinking. Entries can be overridden. Other bibliography sources
17
+ can still be included.'
18
+ spec.homepage = 'https://github.com/PJK/dblpbib'
19
+ spec.license = 'MIT'
16
20
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
23
27
 
24
- spec.add_development_dependency "bundler", "~> 1.13"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency 'bundler', '~> 1.16'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3'
31
+ spec.add_development_dependency 'rubocop', '~> 0.57'
27
32
 
28
- spec.add_dependency "commander"
33
+ spec.add_dependency 'commander'
29
34
  end
data/exe/dblpbib CHANGED
@@ -8,12 +8,21 @@ require 'open-uri'
8
8
 
9
9
  require 'dblpbib/version'
10
10
 
11
+ # Top-level CLI app
11
12
  class DBLPCLI
12
13
  include Commander::Methods
13
14
 
14
15
  def shared_options(command)
15
- command.option '--cache CACHE_DIR', String, 'Cache directory. Single .bib entries are stored here'
16
- command.option '--output OUTPUT.bib', String, 'Output bibliography. "dblp.bib" by default'
16
+ command.option(
17
+ '--cache CACHE_DIR',
18
+ String,
19
+ 'Cache directory. Single .bib entries are stored here'
20
+ )
21
+ command.option(
22
+ '--output OUTPUT.bib',
23
+ String,
24
+ 'Output bibliography. \'dblp.bib\' by default'
25
+ )
17
26
  end
18
27
 
19
28
  def default_options(options)
@@ -21,18 +30,6 @@ class DBLPCLI
21
30
  options.default output: 'dblp.bib'
22
31
  end
23
32
 
24
- def get_keys(file)
25
- IO.read(file)
26
- .gsub(/(?<!\\)%.*$/, '')
27
- .scan(/\\cite(\[[^\]]+\])?\{([^\}]+)\}/)
28
- .map(&:pop)
29
- .flat_map { |keyset| keyset.split(',') }
30
- .map(&:strip)
31
- .uniq
32
- .keep_if { |key| key.start_with?('DBLP:') }
33
- .map { |key| key.sub('DBLP:', '') }
34
- end
35
-
36
33
  def bib_path(cache, key)
37
34
  File.join(cache, key + '.bib')
38
35
  end
@@ -51,25 +48,29 @@ class DBLPCLI
51
48
  default_options(options)
52
49
  FileUtils.mkdir_p(options.cache)
53
50
 
54
- keys = get_keys(args[0])
51
+ keys = Dblpbib.scan_keys(IO.read(args[0]))
55
52
 
56
53
  keys.each do |key|
57
54
  path = bib_path(options.cache, key)
58
55
 
59
- unless File.exist?(path)
60
- puts "Fetching #{key}"
56
+ next if File.exist?(path)
61
57
 
62
- FileUtils.mkdir_p(File.dirname(path))
58
+ puts "Fetching #{key}"
59
+ FileUtils.mkdir_p(File.dirname(path))
63
60
 
64
- begin
65
- File.write(path, open("http://dblp.uni-trier.de/rec/bib1/#{key}.bib").read)
66
- rescue OpenURI::HTTPError => e
67
- puts "Failed to fetch key #{key} (#{e}) -- perhaps it is misspelled or doesn't exist?"
68
- exit 1
69
- end
70
-
71
- # TODO: crossrefs! When I got here I actually realized the 'standard' output is perfectly OK for most situations...
61
+ begin
62
+ File.write(
63
+ path,
64
+ open("http://dblp.uni-trier.de/rec/bib1/#{key}.bib").read
65
+ )
66
+ rescue OpenURI::HTTPError => e
67
+ puts "Failed to fetch key #{key} (#{e}) -- " \
68
+ "perhaps it is misspelled or doesn't exist?"
69
+ exit 1
72
70
  end
71
+
72
+ # TODO: crossrefs! When I got here I actually realized the 'standard'
73
+ # output is perfectly OK for most situations...
73
74
  end
74
75
 
75
76
  File.open(options.output, 'w') do |output|
@@ -90,4 +91,4 @@ class DBLPCLI
90
91
  end
91
92
  end
92
93
 
93
- DBLPCLI.new.run
94
+ DBLPCLI.new.run
data/lib/dblpbib.rb CHANGED
@@ -1,5 +1,24 @@
1
- require "dblpbib/version"
1
+ require 'dblpbib/version'
2
2
 
3
+ # Bits of logic
3
4
  module Dblpbib
4
- # Your code goes here...
5
+ def self.scan_keys(document)
6
+ # TODO: Extract the allowed command names, possible make them configurable
7
+ document
8
+ .gsub(/(?<!\\)%.*$/, '')
9
+ .scan(%r{
10
+ # Command
11
+ \\(text|auto)?cite(|(al)?[pt]\*?|year(par|\*)?|par\*?|author\*?|text|)
12
+ # Optionally options
13
+ (\[[^\]]+\])?
14
+ # Parameters
15
+ \{([^\}]+)\}
16
+ }x)
17
+ .map(&:pop)
18
+ .flat_map { |keyset| keyset.split(',') }
19
+ .map(&:strip)
20
+ .keep_if { |key| key.start_with?('DBLP:') }
21
+ .map { |key| key.sub('DBLP:', '') }
22
+ .uniq
23
+ end
5
24
  end
@@ -1,4 +1,5 @@
1
1
  module Dblpbib
2
- VERSION = "0.1.6"
3
- DESCRIPTION = %q{Automatically create bibliographies for BibTeX DBLP references.}
2
+ VERSION = '0.2.0'.freeze
3
+ DESCRIPTION = 'Automatically create bibliographies for ' \
4
+ 'BibTeX DBLP references.'.freeze
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblpbib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PJK
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '1.16'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.57'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.57'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: commander
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,10 +80,12 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: Automatically create bibliographies for BibTeX DBLP references. This
70
- utility is meant to be invoked during LaTeX build. It scans the documents for DBLP
71
- references and compiles a cached .bib file. Correctly handles crosslinking. Entries
72
- can be overridden. Other bibliography sources can still be included.
83
+ description: |-
84
+ Automatically create bibliographies for BibTeX DBLP
85
+ references. This utility is meant to be invoked during LaTeX build. It scans
86
+ the documents for DBLP references and compiles a cached .bib file. Correctly
87
+ handles crosslinking. Entries can be overridden. Other bibliography sources
88
+ can still be included.
73
89
  email:
74
90
  - me@pavelkalvoda.com
75
91
  executables:
@@ -78,8 +94,8 @@ extensions: []
78
94
  extra_rdoc_files: []
79
95
  files:
80
96
  - ".gitignore"
81
- - ".idea/vcs.xml"
82
97
  - ".rspec"
98
+ - ".rubocop.yml"
83
99
  - ".travis.yml"
84
100
  - Gemfile
85
101
  - LICENSE.txt