citero-jruby 1.2.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'citero-jruby/core_ext'
1
2
  module Citero
2
3
 
3
4
  # Java is required in this module.
@@ -23,7 +24,7 @@ module Citero
23
24
  #Defines the method and caches it to the class
24
25
  self.class.send(:define_method, meth) do
25
26
  # Splits the method and parameter. See formatize and directionize
26
- @csf::config()::getStringArray(meth.to_s).to_a
27
+ @csf::config()::getStringArray(meth.to_s.to_java_name).to_a
27
28
  end
28
29
  # calls the method
29
30
  send meth, *args, &block
@@ -44,13 +45,13 @@ module Citero
44
45
  # Private method. Checks to see if the method name is a valid key
45
46
  # for the configuration file.
46
47
  def matches? meth
47
- @csf::config()::containsKey(meth.to_s)
48
+ @csf::config()::containsKey(meth.to_s.to_java_name)
48
49
  end
49
50
  private :matches?
50
51
 
51
52
  # A list of keys that is available in this properties configuration
52
53
  def keys
53
- @keys ||= Array.new(@csf::config()::getKeys.collect {|key| key})
54
+ @keys ||= Array.new(@csf::config()::getKeys.collect {|key| key.to_ruby_name})
54
55
  end
55
56
  end
56
57
  end
@@ -4,6 +4,7 @@ module Citero
4
4
 
5
5
  # Import of an important java enum type
6
6
  java_import Java::EduNyuLibraryCitero::Formats
7
+ java_import Java::EduNyuLibraryCitero::CitationStyles
7
8
 
8
9
  # Calling the map method creates a new instance of the Base class, with splatter operator passed in
9
10
  def self.map *args
@@ -20,6 +21,11 @@ module Citero
20
21
  @from_formats ||= formats :isSourceFormat
21
22
  end
22
23
 
24
+ # List of available Citation Styles Citero can exports to as a module class method for quick checks.
25
+ def self.citation_styles
26
+ @citation_styles ||= CitationStyles::values.collect {|style| style.name.downcase}
27
+ end
28
+
23
29
  private
24
30
  def self.formats meth
25
31
  Formats::values.select {|format| format.send(meth) }.collect {|format| format.name.downcase}
@@ -111,7 +117,7 @@ module Citero
111
117
  # that can accept the formats, and checks to see if the formats are in a list
112
118
  # of formats as defined by the Java enum Format.
113
119
  def matches? meth
114
- directions.include? directionize(meth) and method("#{directionize(meth)}_formats").call.include? formatize(meth)
120
+ directions.include?(directionize(meth)) && (method("#{directionize(meth)}_formats").call.include?(formatize(meth)) || Citero.citation_styles.include?(formatize(meth)))
115
121
  end
116
122
  private :matches?
117
123
 
Binary file
@@ -0,0 +1,12 @@
1
+ String.class_eval do
2
+ def to_java_name
3
+ if self.include? '_'
4
+ self.gsub(/(_[a-z])/) { $1[1].capitalize }
5
+ else
6
+ self
7
+ end
8
+ end
9
+ def to_ruby_name
10
+ (self.gsub(/([A-Z])/) { "_"+$1 }).downcase
11
+ end
12
+ end
@@ -1,4 +1,4 @@
1
1
  module Citero
2
2
  # Citeros current version
3
- VERSION = "1.2.0"
3
+ VERSION = "2.1.0"
4
4
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: citero-jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 2.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - hab278
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -150,6 +150,7 @@ files:
150
150
  - lib/citero-jruby.rb
151
151
  - lib/citero-jruby/base.rb
152
152
  - lib/citero-jruby/citero.jar
153
+ - lib/citero-jruby/core_ext.rb
153
154
  - lib/citero-jruby/CSF.rb
154
155
  - lib/citero-jruby/version.rb
155
156
  - Rakefile