team_hub 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4df2f63bba276e6f1f8384bc73b23535a90c630
4
+ data.tar.gz: 7d509f467496347c158a4bcd54c75e551de893f6
5
+ SHA512:
6
+ metadata.gz: fdb16d6c49f90a8676593707f711b6b0f50b54101c5a6b907aa955dab3fbfc18b379582e7bd2c2f34a57216186bf1a4b09fc762d7406327eb51015513cd446ac
7
+ data.tar.gz: ad82faa6f3cf1f9a41be6a3ceda873ffd32bfffd4329d0fe3f820488d840bd0a9a4358dad6223ef56a88831d9d8c45431ed10de03673b889f4135dcc392469f7
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ ## team_hub Gem
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/team_hub.svg)](https://badge.fury.io/rb/team_hub)
4
+ [![Build Status](https://travis-ci.org/18F/team_hub.svg?branch=master)](https://travis-ci.org/18F/team_hub)
5
+ [![Code Climate](https://codeclimate.com/github/18F/team_hub/badges/gpa.svg)](https://codeclimate.com/github/18F/team_hub)
6
+ [![Test Coverage](https://codeclimate.com/github/18F/team_hub/badges/coverage.svg)](https://codeclimate.com/github/18F/team_hub)
7
+
8
+ Contains reusable components extracted from the [18F Hub
9
+ implementation](https://github.com/18F/hub) for creating a team Hub using
10
+ [Jekyll](http://jekyllrb.com/). See the [18F Public
11
+ Hub](https://18f.gsa.gov/hub/) for a running example.
12
+
13
+ Downloads and API docs are available on the [team_hub RubyGems
14
+ page](https://rubygems.org/gems/team_hub). API documentation is written
15
+ using [YARD markup](http://yardoc.org/).
16
+
17
+ Contributed by the 18F team, part of the United States General Services
18
+ Administration: https://18f.gsa.gov/
19
+
20
+ ### Motivation
21
+
22
+ The [18F Hub repository](https://github.com/18F/hub) aims to provide a
23
+ lightweight, easily-adaptable template for websites like the [18F Public
24
+ Hub](https://18f.gsa.gov/hub/), [to empower Instigators across the US federal
25
+ government and beyond to spread modern software development
26
+ practices](https://18f.gsa.gov/2014/12/23/hub/). Consequently, 18F will be
27
+ extracting more and more generic, reusable components into this gem, leaving
28
+ the plugins in the 18F Hub repository very lean and declarative, so that
29
+ others may more easily understand how to adapt the Hub template to their own
30
+ team's needs.
31
+
32
+ ### Installation
33
+
34
+ Add this line to your application's Gemfile:
35
+
36
+ ```ruby
37
+ gem 'team_hub'
38
+ ```
39
+
40
+ And then execute:
41
+ ```
42
+ $ bundle
43
+ ```
44
+
45
+ Or install it yourself as:
46
+ ```
47
+ $ gem install team_hub
48
+ ```
49
+
50
+ ### Usage
51
+
52
+ More documentation will be forthcoming as this gem is built up with features
53
+ extracted from the 18F Hub. For now, see the [18F Hub Plugins
54
+ directory](https://github.com/18F/hub/tree/master/_plugins) to see how parts
55
+ of `team_hub` are currently used, and to see hints of functionality that will
56
+ be added to `team_hub` in the near future.
57
+
58
+ ### Contributing
59
+
60
+ 1. Fork it ( https://github.com/18F/team_hub/fork )
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create a new Pull Request
65
+
66
+ Feel free to ping [@mbland](https://github.com/mbland) with any questions you
67
+ may have, especially if the current documentation should've addressed your
68
+ needs, but didn't.
69
+
70
+ ### Public domain
71
+
72
+ This project is in the worldwide [public domain](LICENSE.md). As stated in
73
+ [CONTRIBUTING](CONTRIBUTING.md):
74
+
75
+ > This project is in the public domain within the United States, and copyright
76
+ > and related rights in the work worldwide are waived through the
77
+ > [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
78
+ >
79
+ > All contributions to this project will be released under the CC0 dedication.
80
+ > By submitting a pull request, you are agreeing to comply with this waiver of
81
+ > copyright interest.
data/lib/team_hub.rb ADDED
@@ -0,0 +1,19 @@
1
+ # team_hub - Components for creating a team Hub using Jekyll
2
+ #
3
+ # Written in 2015 by Mike Bland (michael.bland@gsa.gov)
4
+ # on behalf of the 18F team, part of the US General Services Administration:
5
+ # https://18f.gsa.gov/
6
+ #
7
+ # To the extent possible under law, the author(s) have dedicated all copyright
8
+ # and related and neighboring rights to this software to the public domain
9
+ # worldwide. This software is distributed without any warranty.
10
+ #
11
+ # You should have received a copy of the CC0 Public Domain Dedication along
12
+ # with this software. If not, see
13
+ # <https://creativecommons.org/publicdomain/zero/1.0/>.
14
+ #
15
+ # @author Mike Bland (michael.bland@gsa.gov)
16
+
17
+ require 'team_hub/canonicalizer'
18
+ require 'team_hub/version'
19
+ require 'team_hub/page'
@@ -0,0 +1,28 @@
1
+ # team_hub - Components for creating a team Hub using Jekyll
2
+ #
3
+ # Written in 2015 by Mike Bland (michael.bland@gsa.gov)
4
+ # on behalf of the 18F team, part of the US General Services Administration:
5
+ # https://18f.gsa.gov/
6
+ #
7
+ # To the extent possible under law, the author(s) have dedicated all copyright
8
+ # and related and neighboring rights to this software to the public domain
9
+ # worldwide. This software is distributed without any warranty.
10
+ #
11
+ # You should have received a copy of the CC0 Public Domain Dedication along
12
+ # with this software. If not, see
13
+ # <https://creativecommons.org/publicdomain/zero/1.0/>.
14
+ #
15
+ # @author Mike Bland (michael.bland@gsa.gov)
16
+
17
+ module TeamHub
18
+
19
+ # Contains utility functions for canonicalizing names and the order of data.
20
+ class Canonicalizer
21
+
22
+ # Returns a canonicalized, URL-friendly substitute for an arbitrary string.
23
+ # +s+:: string to canonicalize
24
+ def self.canonicalize(s)
25
+ s.downcase.gsub(/\s+/, '-')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,129 @@
1
+ # team_hub - Components for creating a team Hub using Jekyll
2
+ #
3
+ # Written in 2015 by Mike Bland (michael.bland@gsa.gov)
4
+ # on behalf of the 18F team, part of the US General Services Administration:
5
+ # https://18f.gsa.gov/
6
+ #
7
+ # To the extent possible under law, the author(s) have dedicated all copyright
8
+ # and related and neighboring rights to this software to the public domain
9
+ # worldwide. This software is distributed without any warranty.
10
+ #
11
+ # You should have received a copy of the CC0 Public Domain Dedication along
12
+ # with this software. If not, see
13
+ # <https://creativecommons.org/publicdomain/zero/1.0/>.
14
+ #
15
+ # @author Mike Bland (michael.bland@gsa.gov)
16
+
17
+ require_relative 'canonicalizer'
18
+
19
+ require 'jekyll'
20
+
21
+ module TeamHub
22
+ # Hub-specfic Page object that standardizes how pages are generated.
23
+ #
24
+ # This Page object allows us to create target pages on the fly using
25
+ # ::Jekyll::Generator plugins. Just creating factory functions that invoke
26
+ # ::Jekyll::Page.new cause initialization failures, as
27
+ # ::Jekyll::Page::initialize will try to open the page specified by
28
+ # File.join(base, dir, filename) directly.
29
+ class Page < ::Jekyll::Page
30
+ private_class_method :new
31
+
32
+ # @param site [Jekyll::Site] Jekyll site object
33
+ # @param page_dir [String] directory containing the generated page
34
+ # @param filename [String] generated page file name
35
+ # @param layout [String] Jekyll page layout for the generated page
36
+ # @param title [String] page title
37
+ def initialize(site, page_dir, filename, layout, title)
38
+ @site = site
39
+ @base = site.source
40
+ @dir = page_dir
41
+ @name = filename
42
+
43
+ self.process(filename)
44
+ self.read_yaml(File.join(site.source, '_layouts'), layout)
45
+ title_format = site.config['generated_page_title_format'] || '%s'
46
+ self.data['title'] = title_format % title
47
+ end
48
+
49
+ # Creates a +TeamHub::Page+ object and adds it to +site.pages+.
50
+ #
51
+ # @param site [Jekyll::Site] Jekyll site object
52
+ # @param page_dir [String] directory containing the generated page
53
+ # @param filename [String] generated page file name
54
+ # @param layout [String] Jekyll page layout for the generated page
55
+ # @param title [String] page title
56
+ # @return [TeamHub::Page]
57
+ def self.generate(site, page_dir, filename, layout, title)
58
+ page = new(site, page_dir, filename, layout, title)
59
+ site.pages << page
60
+ page
61
+ end
62
+
63
+ # Generates a series of +TeamHub::Page+ objects for each item in
64
+ # +site.data[+collection_name], where the collection is a
65
+ # +Hash<String, Hash>+ or an +Array<Hash>, and adds them to +site.pages+.
66
+ #
67
+ # @param site [Jekyll::Site] Jekyll site object
68
+ # @param collection_name [String] key into site.data
69
+ # @param item_name [String] identifies the item page layout using the
70
+ # format "#{item_name}.html" and the property used to access item data
71
+ # within the layout (i.e. +page.item_name+)
72
+ # @param title_key [String] hash key of the item field used to generate
73
+ # the page title, i.e. item[title_key]
74
+ # @param primary_key [String] hash key corresponding to the unique
75
+ # identifier within each item, i.e. item[primary_key]; required if the
76
+ # collection is an Array
77
+ # @param collection_dir [String] if specified, the directory into which
78
+ # pages will be generated; otherwise +collection_name+ will be used as
79
+ # the directory name
80
+ # @param [String] if specified, a format string containing a '%s' field
81
+ # used to generate page titles from item[title_key]; otherwise
82
+ # item[title_key] will be used to generate the title directly
83
+ def self.generate_collection_item_pages(site, collection_name, item_name,
84
+ title_key, primary_key: nil, collection_dir: nil, title_format: '%s')
85
+ collection_dir = collection_name unless collection_dir
86
+ get_collection(site, collection_name, primary_key).each do |id, item|
87
+ page = generate(site, File.join(collection_dir, id),
88
+ 'index.html', "#{item_name}.html", title_format % item[title_key])
89
+ page.data[item_name] = item
90
+ end
91
+ end
92
+
93
+ # Raised by +get_collection+ if +site.data[+collection_name] is of the
94
+ # wrong type.
95
+ class CollectionTypeError < ::Exception
96
+ end
97
+
98
+ # Retrieves site.data[collection_name]. Converts an Array<Hash> into a
99
+ # Hash, and returns the empty hash if site.data[collection_name] does not
100
+ # exist.
101
+ #
102
+ # @param site [Jekyll::Site] Jekyll site object
103
+ # @param collection_name [String] key into site.data
104
+ # @param primary_key [String] hash key corresponding to the unique
105
+ # identifier within each item, i.e. item[primary_key]; required if the
106
+ # collection is an Array
107
+ # @return [Hash] a hash from item ID => item
108
+ # @raise [CollectionTypeError] if site.data[collection_name] isn't a Hash
109
+ # or an Array
110
+ def self.get_collection(site, collection_name, primary_key)
111
+ collection = site.data[collection_name] || {}
112
+
113
+ if collection.instance_of? ::Hash
114
+ collection
115
+ elsif collection.instance_of? ::Array
116
+ collection_hash = {}
117
+ collection.each do |item|
118
+ id = Canonicalizer.canonicalize(item[primary_key])
119
+ collection_hash[id] = item
120
+ end
121
+ collection_hash
122
+ else
123
+ raise CollectionTypeError.new("site.data[#{collection_name}] " +
124
+ "should be a Hash<String, Hash> or an Array<Hash>, " +
125
+ "but is of type #{collection.class}")
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,27 @@
1
+ # team_hub - Components for creating a team Hub using Jekyll
2
+ #
3
+ # Written in 2015 by Mike Bland (michael.bland@gsa.gov)
4
+ # on behalf of the 18F team, part of the US General Services Administration:
5
+ # https://18f.gsa.gov/
6
+ #
7
+ # To the extent possible under law, the author(s) have dedicated all copyright
8
+ # and related and neighboring rights to this software to the public domain
9
+ # worldwide. This software is distributed without any warranty.
10
+ #
11
+ # You should have received a copy of the CC0 Public Domain Dedication along
12
+ # with this software. If not, see
13
+ # <https://creativecommons.org/publicdomain/zero/1.0/>.
14
+ #
15
+ # @author Mike Bland (michael.bland@gsa.gov)
16
+ #
17
+ # ---
18
+ #
19
+ # This gem contains components from the 18F Hub that are reusable across Hub
20
+ # implementations. The 18F Public Hub is hosted at:
21
+ # https://18f.gsa.gov/hub/
22
+ # The 18F Hub repository is:
23
+ # https://github.com/18F/hub"
24
+
25
+ module TeamHub
26
+ VERSION = "0.0.1"
27
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: team_hub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Bland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hash-joiner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: weekly_snippets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: codeclimate-test-reporter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: |-
112
+ Contains resuable components extracted from the 18F Hub implementation for creating a team hub using Jekyll. See the 18F Public Hub for a running example:
113
+ https://18f.gsa.gov/hub/
114
+ The 18F Hub repository is:
115
+ https://github.com/18F/hub
116
+ email:
117
+ - michael.bland@gsa.gov
118
+ executables: []
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - README.md
123
+ - lib/team_hub.rb
124
+ - lib/team_hub/canonicalizer.rb
125
+ - lib/team_hub/page.rb
126
+ - lib/team_hub/version.rb
127
+ homepage: https://github.com/18F/team_hub
128
+ licenses:
129
+ - CC0
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.2.2
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Components for creating a team Hub using Jekyll
151
+ test_files: []
152
+ has_rdoc: