jekyll-scholar 3.0.1 → 3.0.2

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: 6c8ccd2ac58af0bf1f408e492607526d4ecd8b5a
4
- data.tar.gz: 6172bf565989e36b457cc3de16437a53fa02ecae
3
+ metadata.gz: 34743acb71968a7f175a125ac5926b505ad582ec
4
+ data.tar.gz: 03b992fb8717bfcfb5b73a6ea1fa1ba090fe261a
5
5
  SHA512:
6
- metadata.gz: bc5af627007cab164c6ea82c4628904b4819b6b55a08d1ac49723a9b5e1b895ac199e287b76535a67a5d78800188e697870d0a5fd3f01b521f43c7444c06749f
7
- data.tar.gz: 568c21dd446843dfa6753713599b9bfd973a885b5f09fc1292cd2b3756e493bfdfa6add069f97889f648d7e103362adf0b60d6d7ef9153d5c304f05a4ae7af45
6
+ metadata.gz: b572dfd70c40978104bfb83254ffe46df35b79de2fb8a56ee8319fa9551b461c577682320cd11023cc25795f021d338e8e6554b384a00696efd506fc3d54d62b
7
+ data.tar.gz: e3d8c10e49a05b3b2082ecde221d5bccf53e142275ffb3c5ce18cd07a1bc3da6091b14bb244672116915cee5d970fc8524e5238cf139e8c6557ad15bbf6a6935
@@ -67,3 +67,86 @@ Feature: Sorting BibTeX Bibliographies
67
67
  And the "_site/scholar.html" file should exist
68
68
  Then "2008" should come before "2007" in "_site/scholar.html"
69
69
 
70
+ @tags @sorting @cited_only
71
+ Scenario: Sort By Year Cited Only
72
+ Given I have a scholar configuration with:
73
+ | key | value |
74
+ | sort_by | year |
75
+ And I have a "_bibliography" directory
76
+ And I have a file "_bibliography/references.bib":
77
+ """
78
+ @book{ruby1,
79
+ title = {The Ruby Programming Language},
80
+ author = {Flanagan, David and Matsumoto, Yukihiro},
81
+ year = {2008},
82
+ publisher = {O'Reilly Media}
83
+ }
84
+ @book{ruby2,
85
+ title = {Ruby Not Cited},
86
+ author = {Flanagan, David and Matsumoto, Yukihiro},
87
+ year = {2007},
88
+ publisher = {O'Reilly Media}
89
+ }
90
+ @book{smalltalk,
91
+ title = {Smalltalk Best Practice Patterns},
92
+ author = {Kent Beck},
93
+ year = {1996},
94
+ publisher = {Prentice Hall}
95
+ }
96
+ """
97
+ And I have a page "scholar.html":
98
+ """
99
+ ---
100
+ ---
101
+ {% cite ruby1 %}
102
+ {% cite smalltalk %}
103
+ {% bibliography --cited %}
104
+ """
105
+ When I run jekyll
106
+ Then the _site directory should exist
107
+ And the "_site/scholar.html" file should exist
108
+ Then "Smalltalk" should come before "Ruby Programming" in "_site/scholar.html"
109
+ And I should not see "<i>Ruby Not Cited</i>" in "_site/scholar.html"
110
+
111
+ @tags @sorting @cited_only
112
+ Scenario: Reverse Sort Order Cited Only
113
+ Given I have a scholar configuration with:
114
+ | key | value |
115
+ | sort_by | year |
116
+ | order | descending |
117
+ And I have a "_bibliography" directory
118
+ And I have a file "_bibliography/references.bib":
119
+ """
120
+ @book{ruby1,
121
+ title = {The Ruby Programming Language},
122
+ author = {Flanagan, David and Matsumoto, Yukihiro},
123
+ year = {2008},
124
+ publisher = {O'Reilly Media}
125
+ }
126
+ @book{ruby2,
127
+ title = {Ruby Not Cited},
128
+ author = {Flanagan, David and Matsumoto, Yukihiro},
129
+ year = {2007},
130
+ publisher = {O'Reilly Media}
131
+ }
132
+ @book{smalltalk,
133
+ title = {Smalltalk Best Practice Patterns},
134
+ author = {Kent Beck},
135
+ year = {1996},
136
+ publisher = {Prentice Hall}
137
+ }
138
+ """
139
+ And I have a page "scholar.html":
140
+ """
141
+ ---
142
+ ---
143
+ {% cite ruby1 %}
144
+ {% cite smalltalk %}
145
+ {% bibliography --cited %}
146
+ """
147
+ When I run jekyll
148
+ Then the _site directory should exist
149
+ And the "_site/scholar.html" file should exist
150
+ Then "Ruby Programming" should come before "Smalltalk" in "_site/scholar.html"
151
+ And I should not see "<i>Ruby Not Cited</i>" in "_site/scholar.html"
152
+
@@ -17,11 +17,9 @@ module Jekyll
17
17
 
18
18
  references = entries
19
19
 
20
- if cited_only?
21
- references = cited_references.uniq.map do |key|
22
- references.detect { |e| e.key == key }
23
- end
24
- end
20
+ references.select! do |e|
21
+ cited_references.include? e.key
22
+ end if cited_only?
25
23
 
26
24
  bibliography = references.each_with_index.map { |entry, index|
27
25
  reference = bibliography_tag(entry, index + 1)
@@ -116,14 +116,15 @@ module Jekyll
116
116
  end
117
117
 
118
118
  def entries
119
- b = bibliography[query || config['query']]
119
+ sort bibliography[query || config['query']]
120
+ end
120
121
 
121
- unless config['sort_by'] == 'none'
122
- b = b.sort_by { |e| e[config['sort_by']].to_s }
123
- b.reverse! if config['order'] =~ /^(desc|reverse)/i
124
- end
122
+ def sort(unsorted)
123
+ return unsorted if config['sort_by'] == 'none'
125
124
 
126
- b
125
+ sorted = unsorted.sort_by { |e| e[config['sort_by']].to_s }
126
+ sorted.reverse! if config['order'] =~ /^(desc|reverse)/i
127
+ sorted
127
128
  end
128
129
 
129
130
  def repository?
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '3.0.1'.freeze
3
+ VERSION = '3.0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-scholar
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll