aweplug 1.0.0.a23 → 1.0.0.a24

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,6 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency 'faraday_middleware', '>= 0.9.0'
26
26
  gem.add_dependency 'curb', '~> 0.8.5'
27
27
  gem.add_dependency 'oauth', '~> 0.3.6'
28
+ gem.add_dependency 'net-http-persistent', '~> 2.9.4'
28
29
 
29
30
  gem.add_development_dependency 'guard-rspec', '~> 3.0.0'
30
31
  gem.add_development_dependency 'rake', '~> 10.0.4'
@@ -3,7 +3,6 @@ require 'asciidoctor'
3
3
  require 'aweplug/helpers/git_metadata'
4
4
  require 'aweplug/helpers/searchisko'
5
5
  require 'json'
6
- require 'pry'
7
6
 
8
7
  module Aweplug
9
8
  module Extensions
@@ -19,7 +18,9 @@ module Aweplug
19
18
  include Aweplug::Helper::Git::Commit::Metadata
20
19
  include Aweplug::Helper::Git::Repository
21
20
 
22
- # Public: Initialization method, used in the awestruct pipeline.
21
+ # Public: Initialization method, used in the awestruct pipeline. This
22
+ # makes use of the Aweplug::Helper::Searchisko class, please see
23
+ # that class for more info on options and settings for Searchisko.
23
24
  #
24
25
  # opts - A Hash of options, some being required, some not (default: {}).
25
26
  # :repository - The String name of the directory
@@ -78,7 +79,7 @@ module Aweplug
78
79
  :searchisko_username => ENV['dcp_user'],
79
80
  :searchisko_password => ENV['dcp_password'],
80
81
  :cache => site.cache,
81
- :logger => site.profile == 'developement'})
82
+ :logger => site.log_faraday})
82
83
  Find.find @directory do |path|
83
84
  Find.prune if File.directory?(path) && !@recurse_subdirectories
84
85
 
@@ -11,7 +11,9 @@ module Aweplug
11
11
  # Public: An awestruct extension for guides / examples written in AsciiDoc.
12
12
  # Files with the .asciidoc or .adoc extension are considered to be
13
13
  # AsciiDoc files. This extension makes use of asciidoctor to
14
- # render the files.
14
+ # render the files. This makes use of the
15
+ # Aweplug::Helper::Searchisko class, please see that class for
16
+ # more info on options and settings for Searchisko.
15
17
  #
16
18
  # Example
17
19
  #
@@ -65,7 +67,7 @@ module Aweplug
65
67
  :searchisko_username => ENV['dcp_user'],
66
68
  :searchisko_password => ENV['dcp_password'],
67
69
  :cache => site.cache,
68
- :logger => site.profile == 'developement'})
70
+ :logger => site.log_faraday})
69
71
  Dir["#{@repo}/*/README.md"].each do |file|
70
72
  next if @excludes.include?(File.dirname(file))
71
73
 
@@ -95,7 +97,8 @@ module Aweplug
95
97
  :sys_created => metadata[:commits].collect { |c| DateTime.parse c[:date] }.last,
96
98
  :sys_activity_dates => metadata[:commits].collect { |c| DateTime.parse c[:date] },
97
99
  :sys_updated => metadata[:commits].collect { |c| DateTime.parse c[:date] }.first,
98
- :target_product => metadata[:target_product]
100
+ :target_product => metadata[:target_product],
101
+ :github_repo_url => metadata[:github_repo_url]
99
102
  }
100
103
 
101
104
  unless site.profile =~ /development/
@@ -6,8 +6,10 @@ module Aweplug
6
6
  module Extensions
7
7
  module Video
8
8
  # Public: Awestruct Extension which iterates over a site variable which
9
- # contains vimeo URLs and creates pages out of them, also sends the info
10
- # over to a searchisko instance for indexing.
9
+ # contains vimeo URLs and creates pages out of them, also sends
10
+ # the info over to a searchisko instance for indexing. This
11
+ # makes use of the Aweplug::Helper::Searchisko class, please see
12
+ # that class for more info on options and settings for Searchisko.
11
13
  class Vimeo
12
14
  include Aweplug::Helpers::Vimeo
13
15
 
@@ -33,7 +35,7 @@ module Aweplug
33
35
  :searchisko_username => ENV['dcp_user'],
34
36
  :searchisko_password => ENV['dcp_password'],
35
37
  :cache => site.cache,
36
- :logger => site.profile == 'developement'})
38
+ :logger => site.log_faraday})
37
39
 
38
40
  site[@variable].each do |url|
39
41
  id = url.match(/^.*\/(\d*)$/)[1]
@@ -48,29 +50,12 @@ module Aweplug
48
50
  page.send('video=', video)
49
51
  page.send('video_url=', url)
50
52
  site.pages << page
51
-
52
- unless video.fetch_info['title'].include? 'Unable to fetch'
53
- searchisko_payload = {
54
- :sys_type => 'jbossdeveloper_video',
55
- :sys_content_provider => 'jboss-developer',
56
- :sys_content_type => 'video',
57
- :sys_content_id => video.id,
58
- :sys_updated => video.modified_date,
59
- :sys_contributors => video.cast,
60
- :sys_activity_dates => [video.modified_date, video.upload_date],
61
- :sys_created => video.upload_date,
62
- :sys_title => video.title,
63
- :sys_url_view => "http://vimeo.com/#{video.id}",
64
- :sys_description => video.description,
65
- :duration => video.duration,
66
- :thumbnail => video.thumb_url,
67
- :tag => video.tags
68
- }
69
-
53
+
54
+ unless (payload = video.searchisko_payload).nil?
70
55
  unless site.profile =~ /development/
71
- searchisko.push_content(searchisko_payload[:sys_type],
72
- searchisko_payload[:sys_content_id],
73
- searchisko_payload.to_json)
56
+ searchisko.push_content(payload[:sys_type],
57
+ payload[:sys_content_id],
58
+ payload.to_json)
74
59
  end
75
60
  end
76
61
  end
@@ -1,6 +1,7 @@
1
1
  require 'faraday'
2
2
  require 'faraday_middleware'
3
3
  require 'aweplug/cache/yaml_file_cache'
4
+ require 'logger'
4
5
 
5
6
  module Aweplug
6
7
  module Helpers
@@ -13,7 +14,7 @@ module Aweplug
13
14
  # :authenticate - boolean flag for authentication
14
15
  # :searchisko_username - Username to use for auth
15
16
  # :searchisko_password - Password to use for auth
16
- # :logging - Boolean to log responses
17
+ # :logger - Boolean to log responses or an instance of Logger to use
17
18
  # :raise_error - Boolean flag if 404 and 500 should raise exceptions
18
19
  # :adapter - faraday adapter to use, defaults to :net_http
19
20
  # :cache - Instance of a cache to use, required.
@@ -28,11 +29,17 @@ module Aweplug
28
29
  $LOG.warn 'Missing username and / or password for searchisko'
29
30
  end
30
31
  end
31
- builder.response :logger if opts[:logging]
32
+ if (opts[:logger])
33
+ if (opts[:logger].is_a?(::Logger))
34
+ builder.response :logger, opts[:logger]
35
+ else
36
+ builder.response :logger, ::Logger.new('_tmp/faraday.log', 'daily')
37
+ end
38
+ end
32
39
  builder.response :raise_error if opts[:raise_error]
33
40
  builder.use FaradayMiddleware::Caching, opts[:cache], {}
34
41
  #builder.response :json, :content_type => /\bjson$/
35
- builder.adapter opts[:adapter] || :net_http
42
+ builder.adapter opts[:adapter] || :net_http_persistent
36
43
  end
37
44
  end
38
45
 
@@ -153,11 +153,11 @@ module Aweplug
153
153
  end
154
154
 
155
155
  def author
156
- @author
156
+ @cast[0] ? @cast[0] : OpenStruct.new({"display_name" => "Unknown"})
157
157
  end
158
158
 
159
159
  def cast
160
- @cast || ''
160
+ @cast
161
161
  end
162
162
 
163
163
  def tags
@@ -182,6 +182,7 @@ module Aweplug
182
182
  @video = JSON.parse(body)["video"][0]
183
183
  @cache.write(@id, body)
184
184
  else
185
+ @fetch_failed = true
185
186
  @video = {"title" => "Unable to fetch video info from vimeo"}
186
187
  end
187
188
  else
@@ -189,6 +190,30 @@ module Aweplug
189
190
  end
190
191
  end
191
192
 
193
+ def searchisko_payload
194
+ unless @fetch_failed
195
+ cast_as_hash = []
196
+ @cast.each do |c|
197
+ cast_as_hash << c.marshal_dump
198
+ end
199
+ author_as_hash = @cast[0] ? @cast[0].marshal_dump : {}
200
+ searchisko_payload = {
201
+ :sys_title => title,
202
+ :sys_description => description,
203
+ :sys_url_view => "http://#{@site.base_url}/video/vimeo/#{id}",
204
+ :sys_type => 'jbossdeveloper_video',
205
+ :author => author_as_hash,
206
+ :contributors => cast_as_hash,
207
+ :sys_created => @video["upload_date"],
208
+ :sys_activity_dates => [@video["modified_date"], @video["upload_date"]],
209
+ :sys_updated => @video["modified_date"],
210
+ :duration => duration,
211
+ :thumbnail => thumb_url,
212
+ :tag => tags
213
+ }
214
+ end
215
+ end
216
+
192
217
  def fetch_thumb_url
193
218
  if @video['thumbnails']
194
219
  @thumb = @video["thumbnails"]["thumbnail"][1]
@@ -214,7 +239,6 @@ module Aweplug
214
239
  end
215
240
  end
216
241
  end
217
- @author = @cast[0] ? @cast[0] : OpenStruct.new({"display_name" => "Unknown"})
218
242
  end
219
243
 
220
244
  # Internal: Execute a method against the Vimeo API
@@ -1,4 +1,4 @@
1
1
  module Aweplug
2
- VERSION='1.0.0.a23'
2
+ VERSION='1.0.0.a24'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aweplug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.a23
4
+ version: 1.0.0.a24
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-18 00:00:00.000000000 Z
12
+ date: 2014-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit
@@ -97,6 +97,22 @@ dependencies:
97
97
  - - ~>
98
98
  - !ruby/object:Gem::Version
99
99
  version: 0.3.6
100
+ - !ruby/object:Gem::Dependency
101
+ name: net-http-persistent
102
+ requirement: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ version: 2.9.4
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ~>
114
+ - !ruby/object:Gem::Version
115
+ version: 2.9.4
100
116
  - !ruby/object:Gem::Dependency
101
117
  name: guard-rspec
102
118
  requirement: !ruby/object:Gem::Requirement
@@ -189,9 +205,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
205
  - - ! '>='
190
206
  - !ruby/object:Gem::Version
191
207
  version: '0'
192
- segments:
193
- - 0
194
- hash: -1575929041350407489
195
208
  required_rubygems_version: !ruby/object:Gem::Requirement
196
209
  none: false
197
210
  requirements: