aweplug 1.0.0.a9 → 1.0.0.a10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/aweplug.gemspec +3 -1
- data/lib/aweplug/extensions/asciidoc_example.rb +59 -10
- data/lib/aweplug/extensions/kramdown_quickstart.rb +60 -7
- data/lib/aweplug/handlers/synthetic_handler.rb +33 -2
- data/lib/aweplug/helpers/{git_commit_metadata.rb → git_metadata.rb} +14 -1
- data/lib/aweplug/helpers/kramdown_metadata.rb +17 -0
- data/lib/aweplug/helpers/searchisko.rb +49 -0
- data/lib/aweplug/helpers/vimeo.rb +127 -0
- data/lib/aweplug/version.rb +1 -1
- data/lib/aweplug.rb +1 -0
- metadata +49 -42
- data/lib/aweplug/extensions/identities.rb +0 -187
- data/lib/aweplug/extensions/identity/confluence.rb +0 -107
- data/lib/aweplug/extensions/identity/github.rb +0 -230
- data/lib/aweplug/extensions/identity/gravatar.rb +0 -117
- data/lib/aweplug/extensions/identity/jbosscommunity.rb +0 -35
- data/spec/aweplug/extensions/identity/collector_spec.rb +0 -24
- data/spec/aweplug/extensions/identity/github_spec.rb +0 -7
- data/spec/aweplug/extensions/identity/storage_spec.rb +0 -24
- data/spec/support/aweplug/extensions/identity/crawler_examples.rb +0 -13
metadata
CHANGED
@@ -1,68 +1,94 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aweplug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
5
|
-
prerelease: 6
|
4
|
+
version: 1.0.0.a10
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- LightGuard
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: octokit
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.24.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.24.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: faraday
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.8.7
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.9.0
|
38
37
|
type: :runtime
|
39
38
|
prerelease: false
|
40
39
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - '>='
|
44
42
|
- !ruby/object:Gem::Version
|
45
43
|
version: 0.8.7
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.9.0
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: faraday_middleware
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.9.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
57
|
requirements:
|
59
|
-
- -
|
58
|
+
- - '>='
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: 0.9.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: curb
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.8.5
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.8.5
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: oauth
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.3.6
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.3.6
|
62
89
|
- !ruby/object:Gem::Dependency
|
63
90
|
name: guard-rspec
|
64
91
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
92
|
requirements:
|
67
93
|
- - ~>
|
68
94
|
- !ruby/object:Gem::Version
|
@@ -70,7 +96,6 @@ dependencies:
|
|
70
96
|
type: :development
|
71
97
|
prerelease: false
|
72
98
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
99
|
requirements:
|
75
100
|
- - ~>
|
76
101
|
- !ruby/object:Gem::Version
|
@@ -78,7 +103,6 @@ dependencies:
|
|
78
103
|
- !ruby/object:Gem::Dependency
|
79
104
|
name: rake
|
80
105
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
106
|
requirements:
|
83
107
|
- - ~>
|
84
108
|
- !ruby/object:Gem::Version
|
@@ -86,7 +110,6 @@ dependencies:
|
|
86
110
|
type: :development
|
87
111
|
prerelease: false
|
88
112
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
113
|
requirements:
|
91
114
|
- - ~>
|
92
115
|
- !ruby/object:Gem::Version
|
@@ -94,7 +117,6 @@ dependencies:
|
|
94
117
|
- !ruby/object:Gem::Dependency
|
95
118
|
name: pry
|
96
119
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
120
|
requirements:
|
99
121
|
- - ~>
|
100
122
|
- !ruby/object:Gem::Version
|
@@ -102,7 +124,6 @@ dependencies:
|
|
102
124
|
type: :development
|
103
125
|
prerelease: false
|
104
126
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
127
|
requirements:
|
107
128
|
- - ~>
|
108
129
|
- !ruby/object:Gem::Version
|
@@ -125,55 +146,41 @@ files:
|
|
125
146
|
- aweplug.gemspec
|
126
147
|
- lib/aweplug.rb
|
127
148
|
- lib/aweplug/extensions/asciidoc_example.rb
|
128
|
-
- lib/aweplug/extensions/identities.rb
|
129
|
-
- lib/aweplug/extensions/identity/confluence.rb
|
130
|
-
- lib/aweplug/extensions/identity/github.rb
|
131
|
-
- lib/aweplug/extensions/identity/gravatar.rb
|
132
|
-
- lib/aweplug/extensions/identity/jbosscommunity.rb
|
133
149
|
- lib/aweplug/extensions/kramdown_quickstart.rb
|
134
150
|
- lib/aweplug/extensions/sections.rb
|
135
151
|
- lib/aweplug/handlers/synthetic_handler.rb
|
136
152
|
- lib/aweplug/helpers/.gitkeep
|
137
|
-
- lib/aweplug/helpers/
|
153
|
+
- lib/aweplug/helpers/git_metadata.rb
|
138
154
|
- lib/aweplug/helpers/kramdown_metadata.rb
|
139
155
|
- lib/aweplug/helpers/searchisko.rb
|
156
|
+
- lib/aweplug/helpers/vimeo.rb
|
140
157
|
- lib/aweplug/transformers/.gitkeep
|
141
158
|
- lib/aweplug/version.rb
|
142
|
-
- spec/aweplug/extensions/identity/collector_spec.rb
|
143
|
-
- spec/aweplug/extensions/identity/github_spec.rb
|
144
|
-
- spec/aweplug/extensions/identity/storage_spec.rb
|
145
159
|
- spec/spec_helper.rb
|
146
|
-
- spec/support/aweplug/extensions/identity/crawler_examples.rb
|
147
160
|
homepage: https://github.com/awestruct/aweplug
|
148
161
|
licenses: []
|
162
|
+
metadata: {}
|
149
163
|
post_install_message:
|
150
164
|
rdoc_options: []
|
151
165
|
require_paths:
|
152
166
|
- lib
|
153
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
168
|
requirements:
|
156
|
-
- -
|
169
|
+
- - '>='
|
157
170
|
- !ruby/object:Gem::Version
|
158
171
|
version: '0'
|
159
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
-
none: false
|
161
173
|
requirements:
|
162
|
-
- -
|
174
|
+
- - '>'
|
163
175
|
- !ruby/object:Gem::Version
|
164
176
|
version: 1.3.1
|
165
177
|
requirements: []
|
166
178
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.
|
179
|
+
rubygems_version: 2.1.10
|
168
180
|
signing_key:
|
169
|
-
specification_version:
|
181
|
+
specification_version: 4
|
170
182
|
summary: This set of Awestruct extensions includes helpful tools, extensions and
|
171
183
|
helpers for building a website using Awestruct. It includes extensions for accessing
|
172
184
|
Github, JIRA, managing identities and others.
|
173
185
|
test_files:
|
174
|
-
- spec/aweplug/extensions/identity/collector_spec.rb
|
175
|
-
- spec/aweplug/extensions/identity/github_spec.rb
|
176
|
-
- spec/aweplug/extensions/identity/storage_spec.rb
|
177
186
|
- spec/spec_helper.rb
|
178
|
-
- spec/support/aweplug/extensions/identity/crawler_examples.rb
|
179
|
-
has_rdoc:
|
@@ -1,187 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'aweplug/extensions/restclient_extensions'
|
3
|
-
require 'aweplug/extensions/identity/github'
|
4
|
-
require 'aweplug/extensions/identity/gravatar'
|
5
|
-
require 'aweplug/extensions/identity/confluence'
|
6
|
-
require 'aweplug/extensions/identity/jbosscommunity'
|
7
|
-
|
8
|
-
module Aweplug
|
9
|
-
module Extensions
|
10
|
-
module Identities
|
11
|
-
# QUESTION should we call this Initializer or Loader instead?
|
12
|
-
class Storage
|
13
|
-
def initialize(opts = {})
|
14
|
-
@use_data_cache = opts[:use_data_cache] || true
|
15
|
-
end
|
16
|
-
|
17
|
-
# Internal: Awestruct calls this method during site generation.
|
18
|
-
# Iterates through all the different identity in the site and finds
|
19
|
-
# information about them.
|
20
|
-
#
|
21
|
-
# site - This must be the site object provided by awestruct
|
22
|
-
#
|
23
|
-
# Returns nothing
|
24
|
-
def execute(site)
|
25
|
-
data_file = File.join(site.tmp_dir, 'datacache', 'identity.yml')
|
26
|
-
loaded = false
|
27
|
-
identities = []
|
28
|
-
if @use_data_cache and File.exist? data_file
|
29
|
-
identities = YAML.load_file data_file
|
30
|
-
loaded = true
|
31
|
-
else
|
32
|
-
if site.identities
|
33
|
-
identities = site.identities.map { |i| OpenStruct.new i }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
identities.extend(Locators)
|
37
|
-
identities.loaded = loaded
|
38
|
-
site.identities = identities
|
39
|
-
end
|
40
|
-
|
41
|
-
module Locators
|
42
|
-
attr_accessor :loaded
|
43
|
-
|
44
|
-
def lookup(username, create = false)
|
45
|
-
identity = self.find { |e| username.eql? e.username } ||
|
46
|
-
self.find { |e| username.eql? e.jboss_username }
|
47
|
-
if create and identity.nil?
|
48
|
-
identity = OpenStruct.new({:username => username})
|
49
|
-
if block_given?
|
50
|
-
yield identity
|
51
|
-
end
|
52
|
-
self << identity
|
53
|
-
end
|
54
|
-
identity
|
55
|
-
end
|
56
|
-
|
57
|
-
def lookup_by_name(name, create = false)
|
58
|
-
search = name.downcase
|
59
|
-
identity = self.find { |e| search.eql? e.name.to_s.downcase }
|
60
|
-
if create and identity.nil?
|
61
|
-
identity = OpenStruct.new({:name => name})
|
62
|
-
if block_given?
|
63
|
-
yield identity
|
64
|
-
end
|
65
|
-
self << identity
|
66
|
-
end
|
67
|
-
identity
|
68
|
-
end
|
69
|
-
|
70
|
-
def lookup_by_contributor(contributor)
|
71
|
-
identity = self.find { |e| e.contributor and e.contributor.emails and e.contributor.emails.include? contributor.email }
|
72
|
-
if identity.nil?
|
73
|
-
# Indication that we have a mismatched account
|
74
|
-
puts "Could not find contributor with e-mail " + contributor.email
|
75
|
-
end
|
76
|
-
identity
|
77
|
-
end
|
78
|
-
|
79
|
-
def lookup_by_email(email, create = false)
|
80
|
-
identity = self.find { |e| email.eql? e.email or !e.emails.nil? and e.emails.include? email }
|
81
|
-
if create and identity.nil?
|
82
|
-
identity = OpenStruct.new({:email => email})
|
83
|
-
if block_given?
|
84
|
-
yield identity
|
85
|
-
end
|
86
|
-
self << identity
|
87
|
-
end
|
88
|
-
identity
|
89
|
-
end
|
90
|
-
|
91
|
-
def lookup_by_github_id(github_id, create = false)
|
92
|
-
identity = self.find { |e| github_id.eql? e.github_id }
|
93
|
-
if create and identity.nil?
|
94
|
-
identity = OpenStruct.new({:github_id => github_id})
|
95
|
-
if block_given?
|
96
|
-
yield identity
|
97
|
-
end
|
98
|
-
self << identity
|
99
|
-
end
|
100
|
-
identity
|
101
|
-
end
|
102
|
-
|
103
|
-
def lookup_by_twitter_username(username)
|
104
|
-
self.find { |e| !e.twitter.nil? and username.eql? e.twitter.username }
|
105
|
-
end
|
106
|
-
|
107
|
-
def locate(*query)
|
108
|
-
query.map! { |e| e.downcase }
|
109
|
-
self.find { |e| not ([e.username, e.name.to_s.downcase, e.email] & query).empty? }
|
110
|
-
end
|
111
|
-
|
112
|
-
def core_team()
|
113
|
-
self.select { |e| e.core }
|
114
|
-
end
|
115
|
-
|
116
|
-
def contributors()
|
117
|
-
self.select { |e| e.contributor }
|
118
|
-
end
|
119
|
-
|
120
|
-
def speakers()
|
121
|
-
self.select { |e| e.speaker }
|
122
|
-
end
|
123
|
-
|
124
|
-
def translators()
|
125
|
-
self.select { |e| e.translator }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
module IdentityHelper
|
131
|
-
# SEMI-HACK this should received contributions from crawlers
|
132
|
-
def url
|
133
|
-
self.jbosscommunity ? self.jbosscommunity.profile_url : self.github.profile_url
|
134
|
-
end
|
135
|
-
|
136
|
-
# TODO support for CSS class, or just attributes in general
|
137
|
-
def to_link
|
138
|
-
"<a href=\"#{self.url}\">#{self.name}</a>"
|
139
|
-
end
|
140
|
-
|
141
|
-
def to_s
|
142
|
-
self.name
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
class Collect
|
147
|
-
def initialize(*collectors)
|
148
|
-
@collectors = collectors
|
149
|
-
end
|
150
|
-
|
151
|
-
def execute(site)
|
152
|
-
if !site.identities.loaded
|
153
|
-
@collectors.each do |c|
|
154
|
-
c.collect(site.identities)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
class Crawl
|
161
|
-
def initialize(*crawlers)
|
162
|
-
@crawlers = crawlers
|
163
|
-
end
|
164
|
-
|
165
|
-
def execute(site)
|
166
|
-
site.identities.each do |i|
|
167
|
-
@crawlers.each do |c|
|
168
|
-
c.crawl(i) if !site.identities.loaded
|
169
|
-
i.extend(IdentityHelper)
|
170
|
-
c.enhance(i) if c.respond_to? 'enhance'
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
class Cache
|
177
|
-
def execute(site)
|
178
|
-
data_file = File.join(site.tmp_dir, 'datacache', 'identity.yml')
|
179
|
-
FileUtils.mkdir_p File.dirname data_file
|
180
|
-
File.open(data_file, 'w') do |out|
|
181
|
-
YAML.dump site.identities, out
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
|
-
module Aweplug
|
4
|
-
module Extensions
|
5
|
-
module Identity
|
6
|
-
module Confluence
|
7
|
-
class Crawler
|
8
|
-
SESSION_PATH = '/rest/prototype/1/session'
|
9
|
-
SEARCH_PATH = '/rest/prototype/1/search/user'
|
10
|
-
SEARCH_PARAM = 'query'
|
11
|
-
|
12
|
-
# Public: Initialize a Crawler
|
13
|
-
#
|
14
|
-
# base_url - The String of the base confluence url, no trailing slash
|
15
|
-
# opts[:assign_to] - The String OpenStruct keys to send the data
|
16
|
-
# opts[:identity_search_keys] - The String OpenStruct keys to use to locate the search query
|
17
|
-
# opts[:assign_username_to] - The String OpenStruct key to which to assign the username
|
18
|
-
# opts[:auth_file] - The File containing the authentication credentials for secure requests
|
19
|
-
def initialize(base_url, opts = {})
|
20
|
-
@base_url = base_url
|
21
|
-
@identity_search_keys = opts[:identity_search_keys] || ['name']
|
22
|
-
@assign_to = opts[:assign_to] || 'confluence'
|
23
|
-
@assign_username_to = opts[:assign_username_to]
|
24
|
-
@auth_file = opts[:auth_file]
|
25
|
-
@session_cookie = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def crawl(identity)
|
29
|
-
search = nil
|
30
|
-
queries = []
|
31
|
-
data = nil
|
32
|
-
@identity_search_keys.each do |k|
|
33
|
-
search = identity.send(k)
|
34
|
-
next if search.nil?
|
35
|
-
# lowercase and remove middle names (shouldn't affect usernames)
|
36
|
-
search = search.downcase.gsub(/^([^ ]+ ?).*?([^ ]+)$/, '\1\2')
|
37
|
-
# don't search on same string twice
|
38
|
-
next if queries.include? search
|
39
|
-
queries << search
|
40
|
-
cleansed_query = search.gsub(' ', '-')
|
41
|
-
url = File.join(@base_url, SEARCH_PATH) + '?query=' + URI.encode(search)
|
42
|
-
data = RestClient.get(url, :cache_key => "confluence/query-#{cleansed_query}.json", :accept => 'application/json')
|
43
|
-
if data['totalSize'].to_i == 0
|
44
|
-
#puts "No results, advancing confluence user crawler to next query string for #{search}"
|
45
|
-
data = nil
|
46
|
-
#elsif data['totalSize'] > 1
|
47
|
-
# puts "Too many results, skipping confluence user crawler for #{search}."
|
48
|
-
# data = nil
|
49
|
-
else
|
50
|
-
break
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if data.nil?
|
55
|
-
if queries.empty?
|
56
|
-
puts "No property found to search, skipping confluence user crawler for #{identity.name}"
|
57
|
-
else
|
58
|
-
puts "No results, skipping confluence user crawler for #{queries.join ' / '}"
|
59
|
-
end
|
60
|
-
return
|
61
|
-
end
|
62
|
-
|
63
|
-
user = data['result'].first
|
64
|
-
username = user['username']
|
65
|
-
url = user['link'].select{|l| l['href'].end_with? "~#{username}" }.first['href']
|
66
|
-
identity.send(@assign_to + '=', OpenStruct.new({:username => username, :profile_url => url}))
|
67
|
-
if !@assign_username_to.nil?
|
68
|
-
identity.send(@assign_username_to + '=', username)
|
69
|
-
end
|
70
|
-
|
71
|
-
get_session_cookie()
|
72
|
-
if @session_cookie
|
73
|
-
profile = RestClient.get(url, :cache_key => "confluence/user-#{username}.html", :cookie => @session_cookie)
|
74
|
-
if profile.match(/ id="email".*?>(.+?)</)
|
75
|
-
replace = {' dot ' => '.', ' at ' => '@'}
|
76
|
-
email = $1.gsub(/ (dot|at) /) {|m| replace[m]}
|
77
|
-
identity.email = email if identity.email.nil?
|
78
|
-
identity.emails ||= []
|
79
|
-
identity.emails |= [identity.email, email]
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
def get_session_cookie()
|
86
|
-
if @session_cookie.nil?
|
87
|
-
@session_cookie = false
|
88
|
-
credentials = nil
|
89
|
-
if !@auth_file.nil?
|
90
|
-
if File.exist? @auth_file
|
91
|
-
credentials = File.read(@auth_file)
|
92
|
-
elsif Pathname.new(@auth_file).relative? and File.exist? File.join(ENV['HOME'], @auth_file)
|
93
|
-
credentials = File.read(File.join(ENV['HOME'], @auth_file))
|
94
|
-
end
|
95
|
-
end
|
96
|
-
if !credentials.nil?
|
97
|
-
url = @base_url.gsub(/^(https?:\/\/)/, '\1' + credentials.chomp + '@') + SESSION_PATH
|
98
|
-
response = RestClient.head(url)
|
99
|
-
@session_cookie = response.headers[:set_cookie].first.split(';').first
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|