cite-me 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/cite-me.rb +95 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb2608aad02e64c802dbdbd2e8fd4e06ac016ad5
|
4
|
+
data.tar.gz: ef17f1660e7d163dd02d9654e82b735ffe6fd028
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 093e988bfbc48c54fae40c489d6eca2870fbca78cc0111a66772e67703a130472602eea8fe7183e3acb4459cca54012f3c04f29fcb5cfe4cd945931d787114a4
|
7
|
+
data.tar.gz: b2eb36dae473a35a3db07e5deb59490cf4e47fd75232e1622714bdec64e86ed94c806114f4340904143e3c5fa8ad6711672b6ee64e565d86d2d78b20e4dcec43
|
data/lib/cite-me.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
class Cite_Me
|
2
|
+
def initialize()
|
3
|
+
end
|
4
|
+
|
5
|
+
def generate_citation(options)
|
6
|
+
case options[:type]
|
7
|
+
when 'book'
|
8
|
+
mla_book_generate_citation(options)
|
9
|
+
when 'magazine'
|
10
|
+
mla_magazine_generate_citation(options)
|
11
|
+
when 'web'
|
12
|
+
mla_web_generate_citation(options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def mla_book_generate_citation(options)
|
19
|
+
clean_options = clean_hash(options)
|
20
|
+
output = ''
|
21
|
+
output << authors(clean_options[:authors])
|
22
|
+
output << "<i>" + clean_options[:title] + "</i>. " if clean_options[:title]
|
23
|
+
output << clean_options[:city_of_publication] + ": " if clean_options[:city_of_publication]
|
24
|
+
output << clean_options[:publisher] + ", " if clean_options[:publisher]
|
25
|
+
output << year_of_publication(clean_options[:year_of_publication])
|
26
|
+
output << clean_options[:medium] + "." if clean_options[:medium]
|
27
|
+
|
28
|
+
output
|
29
|
+
end
|
30
|
+
|
31
|
+
def mla_magazine_generate_citation(options)
|
32
|
+
clean_options = clean_hash(options)
|
33
|
+
output = ''
|
34
|
+
output << authors(clean_options[:authors])
|
35
|
+
output << %{"#{clean_options[:title_of_article]}." }
|
36
|
+
output << "<i>" + clean_options[:title_of_periodical] + "</i> "
|
37
|
+
output << clean_options[:publication_date] + ": "
|
38
|
+
output << clean_options[:pages] + ". "
|
39
|
+
output << clean_options[:medium] + "."
|
40
|
+
|
41
|
+
output
|
42
|
+
end
|
43
|
+
|
44
|
+
def mla_web_generate_citation(options)
|
45
|
+
clean_options = clean_hash(options)
|
46
|
+
output = ''
|
47
|
+
output << authors(clean_options[:authors])
|
48
|
+
output << "<i>" + clean_options[:name_of_site] + "</i>. "
|
49
|
+
output << clean_options[:name_of_organization] + ", "
|
50
|
+
output << clean_options[:date_of_creation] + ". "
|
51
|
+
output << 'Web. '
|
52
|
+
output << clean_options[:date_of_access] + "."
|
53
|
+
|
54
|
+
output
|
55
|
+
end
|
56
|
+
|
57
|
+
def authors(option)
|
58
|
+
author_string = ''
|
59
|
+
option.each_with_index do |author, index|
|
60
|
+
if author =~ /,/
|
61
|
+
author_string += author
|
62
|
+
author_string += index == option.length - 1 ? ". " : "and , "
|
63
|
+
else
|
64
|
+
# John A. Doe
|
65
|
+
name = author.split(" ")
|
66
|
+
middle_initial = author.scan(/ \w\. /)
|
67
|
+
author_string += name.last + ", " + name.first + middle_initial.first.to_s
|
68
|
+
# add a period if it's the last entry and NOT a name with a middle initial
|
69
|
+
author_string += index == option.length - 1 ? ". " : "and , " if middle_initial.empty?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
author_string
|
73
|
+
end
|
74
|
+
|
75
|
+
def year_of_publication(option)
|
76
|
+
if option
|
77
|
+
option.to_s + ". "
|
78
|
+
else
|
79
|
+
'n.d. '
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def clean_hash(options)
|
84
|
+
clean_options = {}
|
85
|
+
options.map do |key, value|
|
86
|
+
if value == ''
|
87
|
+
clean_options[key] = nil
|
88
|
+
else
|
89
|
+
clean_options[key] = value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
clean_options
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cite-me
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provide information about a source and recieve properly MLA formatted
|
14
|
+
citations (suitable for a bibliography).
|
15
|
+
email: jacob.wesley.smith@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/cite-me.rb
|
21
|
+
homepage: http://rubygems.org/gems/cite-me
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.1.11
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Create MLA citations
|
45
|
+
test_files: []
|