svn-campfire-notifier 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,35 @@
|
|
1
1
|
class SVNCampfireNotifier
|
2
2
|
class GoogleImage
|
3
|
-
URL = 'http://images.google.com/images?safe=active
|
3
|
+
URL = 'http://images.google.com/images?safe=active'
|
4
4
|
RESULTS_REGEXP = /setResults\((\[\[.+\]\])\);/
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_reader :project
|
7
|
+
|
8
|
+
def initialize(project)
|
9
|
+
@project = project
|
10
|
+
end
|
11
|
+
|
12
|
+
def extra_options
|
13
|
+
{
|
14
|
+
'isch' => '1',
|
15
|
+
'itp' => project.image_type,
|
16
|
+
'ic' => 'specific',
|
17
|
+
'ics' => project.color
|
18
|
+
}.inject([]) do |serialized, (key, value)|
|
19
|
+
serialized << "#{key}:#{value}"
|
20
|
+
end.join(',')
|
8
21
|
end
|
9
22
|
|
10
23
|
def query
|
11
|
-
"
|
24
|
+
"#{project.subject}+#{project.revision}"
|
12
25
|
end
|
13
26
|
|
14
27
|
def url
|
15
|
-
URL
|
28
|
+
"#{URL}&q=#{query}&tbs=#{extra_options}"
|
16
29
|
end
|
17
30
|
|
18
31
|
def feeling_lucky
|
32
|
+
puts url
|
19
33
|
response = REST.get(url)
|
20
34
|
if response.ok? and match = RESULTS_REGEXP.match(response.body)
|
21
35
|
data = JSON.parse(match[1]).first
|
@@ -16,11 +16,10 @@ class SVNCampfireNotifier
|
|
16
16
|
parts = []
|
17
17
|
parts << ["#{SALUTATIONS.random}, #{project.author.capitalize} just committed revision #{project.revision} of #{project.name}: https://fngtps.com/browser/#{project.name}/changesets/#{project.revision}"]
|
18
18
|
parts << ["#{Wrap.wrap(project.log)}\n\n#{project.changed.strip}", {:type => :paste}]
|
19
|
-
if image_url = GoogleImage.feeling_lucky(project
|
19
|
+
if image_url = GoogleImage.feeling_lucky(project)
|
20
20
|
parts << [image_url]
|
21
21
|
end
|
22
22
|
parts
|
23
|
-
# room.speak(IMAGE_EXCEPTIONS.has_key?(revision) ? IMAGE_EXCEPTIONS[revision] : Google::Images.feeling_lucky(revision).thumbnail_url)
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class SVNCampfireNotifier
|
2
2
|
class Project
|
3
|
+
SUBJECTS = %w(kitty turtle dog car computer retro)
|
4
|
+
COLORS = %w(red orange yellow green teal blue purple pink white grey black brown)
|
5
|
+
TYPES = %w(face photo clipart lineart)
|
6
|
+
|
3
7
|
attr_reader :repository_path, :revision
|
4
8
|
|
5
9
|
def initialize(repository_path, revision)
|
@@ -22,5 +26,21 @@ class SVNCampfireNotifier
|
|
22
26
|
def log
|
23
27
|
@log ||= `svnlook log -r #{revision} #{repository_path}`.strip
|
24
28
|
end
|
29
|
+
|
30
|
+
def index
|
31
|
+
name[0]
|
32
|
+
end
|
33
|
+
|
34
|
+
def subject
|
35
|
+
SUBJECTS[index % SUBJECTS.length]
|
36
|
+
end
|
37
|
+
|
38
|
+
def color
|
39
|
+
COLORS[index % COLORS.length]
|
40
|
+
end
|
41
|
+
|
42
|
+
def image_type
|
43
|
+
TYPES[index % TYPES.length]
|
44
|
+
end
|
25
45
|
end
|
26
46
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svn-campfire-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Manfred Stienstra
|