citeproc 1.0.0.pre1 → 1.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -33,6 +33,13 @@ end
33
33
  require 'cucumber/rake/task'
34
34
  Cucumber::Rake::Task.new(:cucumber)
35
35
 
36
+ task :release do |t|
37
+ system "gem build citeproc.gemspec"
38
+ system "git tag #{CiteProc::VERSION}"
39
+ system "git push --tags"
40
+ system "gem push citeproc-#{CiteProc::VERSION}.gem"
41
+ end
42
+
36
43
  task :default => :spec
37
44
 
38
45
  require 'yard'
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.date = Time.now.strftime('%Y-%m-%d')
24
24
 
25
25
  s.add_runtime_dependency('multi_json', '~>1.3.5')
26
- s.add_runtime_dependency('namae', '~>0.1')
26
+ s.add_runtime_dependency('namae', '~>0.3')
27
27
 
28
28
  s.add_development_dependency 'cucumber', '~>1.2'
29
29
  s.add_development_dependency 'rspec', '~>2.7'
@@ -5,18 +5,18 @@ module CiteProc
5
5
  # have a valid {#id} attribute used to retrieve the correpsonding {Item}
6
6
  # containing the actual bibliographic data.
7
7
  class CitationItem
8
-
8
+
9
9
  include Attributes
10
-
10
+
11
11
  @labels = [
12
12
  :book, :chapter, :column, :figure, :folio, :issue, :line, :note, :opus,
13
13
  :page, :paragraph, :part, :section, :'sub-verbo', :verse, :volume
14
14
  ].freeze
15
-
15
+
16
16
  class << self
17
- attr_reader :labels
17
+ attr_reader :labels
18
18
  end
19
-
19
+
20
20
  # @!attribute id
21
21
  # @return [Symbol,String] the id of the corresponding resource
22
22
 
@@ -33,14 +33,14 @@ module CiteProc
33
33
  # @!attribute suppress_author
34
34
  # @return [Boolean] whether or not author names will not be included
35
35
  # in the citation output for this cite
36
-
36
+
37
37
  # @!attribute author_only
38
38
  # This optional parameter provides a means for certain demanding styles
39
39
  # that require the processor output to be divided between the main text
40
40
  # and a footnote.
41
41
  # @return [Boolean] whether or not only the author name will be included
42
42
  # in the citation output for this cite
43
-
43
+
44
44
  # @!attribute prefix
45
45
  # @return [String] a string to print before cites produced for this item
46
46
 
@@ -50,7 +50,7 @@ module CiteProc
50
50
  attr_predicates :id, :locator, :label, :'suppress-author',
51
51
  :'author-only', :prefix, :suffix
52
52
 
53
- # Attributes added by processor
53
+ # Attributes added by processor
54
54
  attr_predicates :sortkeys, :postion, :'first-reference-note-number',
55
55
  :'near-note', :unsorted
56
56
 
@@ -70,19 +70,19 @@ module CiteProc
70
70
  end
71
71
 
72
72
  end
73
-
74
-
75
-
76
-
73
+
74
+
75
+
76
+
77
77
  class CitationData
78
-
78
+
79
79
  extend Forwardable
80
80
  include Enumerable
81
-
81
+
82
82
  @defaults = {
83
83
  :footnote => 0
84
84
  }.freeze
85
-
85
+
86
86
  @rb2cp = {
87
87
  :id => 'citationID',
88
88
  :items => 'citationItems',
@@ -90,22 +90,22 @@ module CiteProc
90
90
  :footnote => 'noteIndex',
91
91
  :options => 'properties'
92
92
  }
93
-
93
+
94
94
  @cp2rb = @rb2cp.invert.freeze
95
95
  @rb2cp.freeze
96
-
96
+
97
97
  class << self
98
98
  attr_reader :defaults, :cp2rb, :rb2cp
99
99
  end
100
-
100
+
101
101
  attr_accessor :id
102
-
102
+
103
103
  attr_reader :items, :options, :sorted_items
104
-
104
+
105
105
  alias properties options
106
-
106
+
107
107
  def_delegators :@items, :length, :empty?, :[]
108
-
108
+
109
109
  # Some delegators should return self
110
110
  [:push, :<<, :unshift, :concat].each do |m|
111
111
  define_method(m) do |*arguments|
@@ -113,13 +113,13 @@ module CiteProc
113
113
  self
114
114
  end
115
115
  end
116
-
116
+
117
117
  def initialize(attributes = nil, options = {})
118
118
  @options = CitationData.defaults.merge(options)
119
119
  @items, @sorted_items = [], []
120
120
  merge(attributes)
121
121
  end
122
-
122
+
123
123
  def initialize_copy(other)
124
124
  @options = other.options.dup
125
125
  @items = other.items.map(&:dup)
@@ -129,7 +129,7 @@ module CiteProc
129
129
 
130
130
  def merge(other)
131
131
  return self if other.nil?
132
-
132
+
133
133
  case other
134
134
  when String, /^\s*\{/
135
135
  other = MulitJson.decode(other, :symbolize_keys => true)
@@ -144,10 +144,10 @@ module CiteProc
144
144
  end
145
145
 
146
146
  other = convert_from_citeproc(other)
147
-
147
+
148
148
  items.concat(Array(other.delete(:items)).map { |i| CitationItem.create!(i) })
149
149
  sorted_items.concat(Array(other.delete(:sorted_items)))
150
-
150
+
151
151
  properties = other.delete(:options)
152
152
  options.merge!(convert_from_citeproc(Hash[properties])) unless properties.nil?
153
153
 
@@ -155,9 +155,9 @@ module CiteProc
155
155
 
156
156
  self
157
157
  end
158
-
158
+
159
159
  alias update merge
160
-
160
+
161
161
  def each
162
162
  if block_given?
163
163
  items.each(&Proc.new)
@@ -174,46 +174,46 @@ module CiteProc
174
174
  def index
175
175
  options[:footnote]
176
176
  end
177
-
177
+
178
178
  def footnote?
179
179
  options[:footnote] > 0
180
180
  end
181
-
181
+
182
182
  def to_citeproc
183
183
  cp = {}
184
-
184
+
185
185
  cp[CitationData.rb2cp[:items]] = items.map(&:to_citeproc)
186
186
  cp[CitationData.rb2cp[:options]] = { CitationData.rb2cp[:footnote] => index }
187
-
187
+
188
188
  cp[CitationData.rb2cp[:id]] = id if processed?
189
-
189
+
190
190
  cp
191
191
  end
192
-
192
+
193
193
  def to_json
194
194
  MultiJson.encode(to_citeproc)
195
195
  end
196
-
196
+
197
197
  alias to_s to_json
198
-
198
+
199
199
  # @return [String] a human-readable representation of the citation data
200
200
  def inspect
201
201
  "#<CiteProc::CitationData items=[#{length}]>"
202
202
  end
203
-
203
+
204
204
  private
205
-
205
+
206
206
  def convert_from_citeproc(hash)
207
207
  hash = hash.symbolize_keys
208
-
208
+
209
209
  CitationData.cp2rb.each do |cp, rb|
210
210
  cp = cp.to_sym
211
211
  hash[rb] = hash.delete(cp) if hash.has_key?(cp)
212
212
  end
213
-
213
+
214
214
  hash
215
215
  end
216
-
216
+
217
217
  end
218
-
218
+
219
219
  end
@@ -82,6 +82,22 @@ module CiteProc
82
82
  @attributes = other.attributes.deep_copy
83
83
  end
84
84
 
85
+ # @param name [Symbol] the name of the variable
86
+ #
87
+ # @param options [Hash]
88
+ # @option options [:short] :form (nil) when given, the variable's
89
+ # short form will be returned if available.
90
+ #
91
+ # @return [Variable, nil] the matching variable
92
+ def variable(name, options = {})
93
+ if options.key?(:form) && options[:form].to_sym == :short
94
+ var = attributes["#{name}-short"]
95
+ return var unless var.nil?
96
+ end
97
+
98
+ attributes[name]
99
+ end
100
+
85
101
  # Calls a block once for each field in the item, passing the field's
86
102
  # name-value pair as parameters.
87
103
  #
@@ -1,3 +1,3 @@
1
1
  module CiteProc
2
- VERSION = '1.0.0.pre1'.freeze
2
+ VERSION = '1.0.0.pre2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre1
4
+ version: 1.0.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70221817636060 !ruby/object:Gem::Requirement
16
+ requirement: &70261116434580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 1.3.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70221817636060
24
+ version_requirements: *70261116434580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: namae
27
- requirement: &70221817635560 !ruby/object:Gem::Requirement
27
+ requirement: &70261116433900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0.1'
32
+ version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70221817635560
35
+ version_requirements: *70261116433900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &70221817635100 !ruby/object:Gem::Requirement
38
+ requirement: &70261116433180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.2'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70221817635100
46
+ version_requirements: *70261116433180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70221817634600 !ruby/object:Gem::Requirement
49
+ requirement: &70261116448700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.7'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70221817634600
57
+ version_requirements: *70261116448700
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70221817634140 !ruby/object:Gem::Requirement
60
+ requirement: &70261116448200 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0.9'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70221817634140
68
+ version_requirements: *70261116448200
69
69
  description: ! "\n A cite processor interface for Citation Style Language (CSL)
70
70
  styles.\n "
71
71
  email:
@@ -134,6 +134,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  - - ! '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
+ segments:
138
+ - 0
139
+ hash: -1866054154081185825
137
140
  required_rubygems_version: !ruby/object:Gem::Requirement
138
141
  none: false
139
142
  requirements: