sitelink_generator 0.3.0
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/CONTRIBUTING.md +17 -0
- data/LICENSE.md +11 -0
- data/README.md +44 -0
- data/lib/sitelink_generator.rb +18 -0
- data/lib/sitelink_generator/base.rb +14 -0
- data/lib/sitelink_generator/generators/sec_edgar.rb +50 -0
- data/lib/sitelink_generator/i18n.rb +2 -0
- data/lib/sitelink_generator/locales/sec_edgar/en.yml +5 -0
- data/lib/sitelink_generator/locales/sec_edgar/es.yml +5 -0
- data/lib/sitelink_generator/version.rb +3 -0
- data/sitelink_generator.gemspec +22 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5521c022606698bd5ee3a8b59c43ef6219aaefed
|
4
|
+
data.tar.gz: dabf4fea0abbfbe3bfc3d8c7ce4e9fe9680bfbad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ac721f4c5d557d33cb7e779344ec22f753a818e751ba322798136268a803e4b6e9575bf232dbdd1f4f8ef5b2bdfa9b1423b155496ee161a66e7441bfe2cdceb
|
7
|
+
data.tar.gz: afed1d460eb83be4f14771b35117b66940b583cb86678cd5e753a1125a356334d3595a49b7af718a21d3af59af09faae647cccfd4ddd633d43e285e8de5f909e
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
## Submitting a Pull Request
|
4
|
+
1. [Fork the repository.][fork]
|
5
|
+
2. [Create a topic branch.][branch]
|
6
|
+
3. Add specs for your unimplemented generator or bug fix.
|
7
|
+
4. Run `bundle exec rake`. If your specs pass, return to step 3.
|
8
|
+
5. Implement your generator or bug fix.
|
9
|
+
6. Run `bundle exec rake`. If your specs fail, return to step 5.
|
10
|
+
7. Run `open coverage/index.html`. If your changes are not completely covered
|
11
|
+
by your tests, return to step 3.
|
12
|
+
8. Add, commit, and push your changes.
|
13
|
+
9. [Submit a pull request.][pr]
|
14
|
+
|
15
|
+
[fork]: http://help.github.com/fork-a-repo/
|
16
|
+
[branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
|
17
|
+
[pr]: http://help.github.com/send-pull-requests/
|
data/LICENSE.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## License
|
2
|
+
|
3
|
+
This project constitutes a work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105.
|
4
|
+
|
5
|
+
The project utilizes code licensed under the terms of the GNU General Public License and therefore is licensed under GPL v2 or later.
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
10
|
+
|
11
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Sitelink Generator
|
2
|
+
|
3
|
+
[DigitalGov Search](http://search.digitalgov.gov) powers the search box on 1,500 government websites.
|
4
|
+
|
5
|
+
This sitelink generator "decorates" organic web results to provide additional, value-added links to help searchers find what they're looking for.
|
6
|
+
|
7
|
+
See the sample results page below that shows sitelink-generated links for EDGAR filings for a search on *apple* on SEC.gov.
|
8
|
+
|
9
|
+

|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add sitelink_generator to your `Gemfile` and `bundle install`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'sitelink_generator'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Available Generators
|
20
|
+
|
21
|
+
[Available generators](lib/sitelink_generator/generators/) include:
|
22
|
+
|
23
|
+
* [SecEdgar](lib/sitelink_generator/generators/sec_edgar.rb)
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'sitelink_generator'
|
29
|
+
|
30
|
+
url = 'http://www.sec.gov/Archives/edgar/data/1577552/000119312514184994/d709111df1.htm'
|
31
|
+
SitelinkGenerator::SecEdgar.generate url
|
32
|
+
#=> [{:title=>"Full Filing",
|
33
|
+
# :url=>"http://www.sec.gov/Archives/edgar/data/1577552/0001193125-14-184994-index.htm"},
|
34
|
+
# {:title=>"Most Recent Filings for this Company",
|
35
|
+
# :url=>"http://www.sec.gov/cgi-bin/browse-edgar?CIK=1577552&Find=Search&action=getcompany&owner=exclude"}]
|
36
|
+
```
|
37
|
+
|
38
|
+
## Supported Ruby Versions
|
39
|
+
|
40
|
+
* Ruby 2.1
|
41
|
+
|
42
|
+
## Feedback
|
43
|
+
|
44
|
+
If you think you found a bug in SitelinkGenerator, you can [submit an issue](https://github.com/GSA/sitelink_generator/issues/new).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
require 'i18n'
|
4
|
+
|
5
|
+
require_relative 'sitelink_generator/base'
|
6
|
+
require_relative 'sitelink_generator/i18n'
|
7
|
+
require_relative 'sitelink_generator/version'
|
8
|
+
|
9
|
+
module SitelinkGenerator
|
10
|
+
GENERATORS = Dir["#{File.dirname(__FILE__)}/sitelink_generator/generators/*.rb"].sort.collect do |path|
|
11
|
+
generator_file_name = File.basename(path, '.rb')
|
12
|
+
|
13
|
+
require_relative "sitelink_generator/generators/#{generator_file_name}"
|
14
|
+
"SitelinkGenerator::#{generator_file_name.camelize}".constantize
|
15
|
+
end.freeze
|
16
|
+
|
17
|
+
GENERATOR_HASH = Hash[GENERATORS.collect { |g| [g.name, g] }].freeze
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'active_support/core_ext/class/attribute'
|
3
|
+
|
4
|
+
module SitelinkGenerator
|
5
|
+
module Base
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class_eval do
|
10
|
+
class_attribute :url_prefix, instance_writer: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'active_support/core_ext/object/to_query'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module SitelinkGenerator
|
5
|
+
class SecEdgar
|
6
|
+
include SitelinkGenerator::Base
|
7
|
+
|
8
|
+
self.url_prefix = 'www.sec.gov/Archives/edgar/data/'.freeze
|
9
|
+
|
10
|
+
MATCHING_URL_REGEX = %r{^(?!.*-index\.htm$)https?://(www\.)?sec\.gov/Archives/edgar/data/\d+/\d+\/.+$}i
|
11
|
+
|
12
|
+
DEFAULT_BROWSE_EDGAR_PARAMS = {
|
13
|
+
Find: 'Search',
|
14
|
+
action: 'getcompany',
|
15
|
+
owner: 'exclude'
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
def self.generate(url)
|
19
|
+
return [] unless url =~ MATCHING_URL_REGEX
|
20
|
+
|
21
|
+
path_as_array = URI.parse(url).path.split('/')
|
22
|
+
return [] unless path_as_array.length == 7
|
23
|
+
|
24
|
+
[generate_full_filing_url(path_as_array),
|
25
|
+
generate_browse_edgar_url(path_as_array)]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.generate_browse_edgar_url(path_as_array)
|
29
|
+
title = I18n.t(:'sitelink_generator.sec_edgar.most_recent_filings')
|
30
|
+
|
31
|
+
cik = path_as_array[4]
|
32
|
+
url_params = DEFAULT_BROWSE_EDGAR_PARAMS.merge(CIK: cik)
|
33
|
+
url = "http://www.sec.gov/cgi-bin/browse-edgar?#{url_params.to_param}"
|
34
|
+
|
35
|
+
{ title: title, url: url }
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.generate_full_filing_url(path_as_array)
|
39
|
+
cik = path_as_array[4]
|
40
|
+
cik_part_1 = path_as_array[5].slice(0, 10)
|
41
|
+
cik_part_2 = path_as_array[5].slice(10, 2)
|
42
|
+
cik_part_3 = path_as_array[5].slice(12..-1)
|
43
|
+
|
44
|
+
full_filing_path = "#{cik}/#{cik_part_1}-#{cik_part_2}-#{cik_part_3}-index.htm"
|
45
|
+
url = "http://www.sec.gov/Archives/edgar/data/#{full_filing_path}"
|
46
|
+
|
47
|
+
{ title: I18n.t('sitelink_generator.sec_edgar.full_filing'), url: url }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'sitelink_generator/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.add_dependency 'i18n', '~> 0.6'
|
7
|
+
s.add_dependency 'activesupport', '~> 3.2'
|
8
|
+
s.add_development_dependency 'bundler', '~> 1.0'
|
9
|
+
s.authors = ['DigitalGov Search']
|
10
|
+
s.date = '2014-10-29'
|
11
|
+
s.description = 'A DigitalGov Search sitelink generator'
|
12
|
+
s.email = 'search@support.digitalgov.gov'
|
13
|
+
s.files = %w(CONTRIBUTING.md LICENSE.md README.md sitelink_generator.gemspec)
|
14
|
+
s.files += Dir['lib/**/*.rb']
|
15
|
+
s.files += Dir['lib/**/*.yml']
|
16
|
+
s.homepage = 'http://search.digitalgov.gov'
|
17
|
+
s.license = 'MIT'
|
18
|
+
s.name = 'sitelink_generator'
|
19
|
+
s.required_ruby_version = '~> 2.1'
|
20
|
+
s.summary = 'sitelink generator for DigitalGov Search'
|
21
|
+
s.version = SitelinkGenerator::VERSION
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sitelink_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- DigitalGov Search
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: i18n
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
description: A DigitalGov Search sitelink generator
|
56
|
+
email: search@support.digitalgov.gov
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- CONTRIBUTING.md
|
62
|
+
- LICENSE.md
|
63
|
+
- README.md
|
64
|
+
- lib/sitelink_generator.rb
|
65
|
+
- lib/sitelink_generator/base.rb
|
66
|
+
- lib/sitelink_generator/generators/sec_edgar.rb
|
67
|
+
- lib/sitelink_generator/i18n.rb
|
68
|
+
- lib/sitelink_generator/locales/sec_edgar/en.yml
|
69
|
+
- lib/sitelink_generator/locales/sec_edgar/es.yml
|
70
|
+
- lib/sitelink_generator/version.rb
|
71
|
+
- sitelink_generator.gemspec
|
72
|
+
homepage: http://search.digitalgov.gov
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '2.1'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: sitelink generator for DigitalGov Search
|
96
|
+
test_files: []
|