flowdock-git-hook 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.3
4
+ - jruby
data/Gemfile CHANGED
@@ -4,9 +4,11 @@ gem "grit", ">= 2.4.1"
4
4
  gem "multi_json"
5
5
 
6
6
  group :development do
7
- gem "rspec", "~> 2.6.0"
8
- gem "bundler", "~> 1.0.0"
7
+ gem "rdoc", ">= 2.4.2"
8
+ gem "rspec", "~> 2.8"
9
+ gem "bundler", "~> 1.0"
9
10
  gem "jeweler", "~> 1.6.2"
10
11
  gem "rcov", ">= 0"
11
12
  gem "webmock", ">= 1.6.4"
13
+ gem "jruby-openssl", :platforms => :jruby, :require => false
12
14
  end
data/Rakefile CHANGED
@@ -37,12 +37,12 @@ end
37
37
 
38
38
  task :default => :spec
39
39
 
40
- require 'rake/rdoctask'
41
- Rake::RDocTask.new do |rdoc|
40
+ require 'rdoc/task'
41
+ RDoc::Task.new do |rdoc|
42
42
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
43
 
44
44
  rdoc.rdoc_dir = 'rdoc'
45
- rdoc.title = "flowdock-git-hook #{version}"
45
+ rdoc.title = "flowdock #{version}"
46
46
  rdoc.rdoc_files.include('README*')
47
47
  rdoc.rdoc_files.include('lib/**/*.rb')
48
48
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{flowdock-git-hook}
8
- s.version = "0.2.0"
7
+ s.name = "flowdock-git-hook"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ville Lautanala"]
12
- s.date = %q{2011-08-23}
13
- s.email = %q{lautis@gmail.com}
12
+ s.date = "2012-01-17"
13
+ s.email = "lautis@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
16
16
  "README.rdoc"
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.files = [
19
19
  ".document",
20
20
  ".rspec",
21
+ ".travis.yml",
21
22
  "Gemfile",
22
23
  "LICENSE.txt",
23
24
  "README.rdoc",
@@ -32,41 +33,46 @@ Gem::Specification.new do |s|
32
33
  "spec/flowdock_git_spec.rb",
33
34
  "spec/spec_helper.rb"
34
35
  ]
35
- s.homepage = %q{http://github.com/flowdock/flowdock-git-hook}
36
+ s.homepage = "http://github.com/flowdock/flowdock-git-hook"
36
37
  s.licenses = ["MIT"]
37
38
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.6}
39
- s.summary = %q{Git Post-Receive hook for Flowdock}
39
+ s.rubygems_version = "1.8.10"
40
+ s.summary = "Git Post-Receive hook for Flowdock"
40
41
 
41
42
  if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
43
  s.specification_version = 3
44
44
 
45
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
46
  s.add_runtime_dependency(%q<grit>, [">= 2.4.1"])
47
47
  s.add_runtime_dependency(%q<multi_json>, [">= 0"])
48
- s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
49
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_development_dependency(%q<rdoc>, [">= 2.4.2"])
49
+ s.add_development_dependency(%q<rspec>, ["~> 2.8"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
50
51
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
51
52
  s.add_development_dependency(%q<rcov>, [">= 0"])
52
53
  s.add_development_dependency(%q<webmock>, [">= 1.6.4"])
54
+ s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
53
55
  else
54
56
  s.add_dependency(%q<grit>, [">= 2.4.1"])
55
57
  s.add_dependency(%q<multi_json>, [">= 0"])
56
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<rdoc>, [">= 2.4.2"])
59
+ s.add_dependency(%q<rspec>, ["~> 2.8"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
58
61
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
59
62
  s.add_dependency(%q<rcov>, [">= 0"])
60
63
  s.add_dependency(%q<webmock>, [">= 1.6.4"])
64
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
61
65
  end
62
66
  else
63
67
  s.add_dependency(%q<grit>, [">= 2.4.1"])
64
68
  s.add_dependency(%q<multi_json>, [">= 0"])
65
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
66
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
69
+ s.add_dependency(%q<rdoc>, [">= 2.4.2"])
70
+ s.add_dependency(%q<rspec>, ["~> 2.8"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
67
72
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
68
73
  s.add_dependency(%q<rcov>, [">= 0"])
69
74
  s.add_dependency(%q<webmock>, [">= 1.6.4"])
75
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
70
76
  end
71
77
  end
72
78
 
@@ -33,7 +33,7 @@ module Flowdock
33
33
  end
34
34
 
35
35
  def to_hash
36
- {
36
+ encode({
37
37
  :before => @before,
38
38
  :after => @after,
39
39
  :ref => @ref,
@@ -42,7 +42,7 @@ module Flowdock
42
42
  :repository => {
43
43
  :name => File.basename(Dir.pwd).sub(/\.git$/,'')
44
44
  }
45
- }.merge(if @before == "0000000000000000000000000000000000000000"
45
+ }).merge(if @before == "0000000000000000000000000000000000000000"
46
46
  {:created => true}
47
47
  elsif @after == "0000000000000000000000000000000000000000"
48
48
  {:deleted => true}
@@ -56,6 +56,29 @@ module Flowdock
56
56
  def filter(diffs)
57
57
  diffs.select { |e| yield e }.map { |diff| diff.b_path }
58
58
  end
59
+
60
+ # This only works on Ruby 1.9
61
+ def encode_as_utf8(obj)
62
+ if obj.is_a? Hash
63
+ obj.each_pair do |key, val|
64
+ encode_as_utf8(val)
65
+ end
66
+ elsif obj.is_a?(Array)
67
+ obj.each do |val|
68
+ encode_as_utf8(val)
69
+ end
70
+ elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8
71
+ if !obj.force_encoding("UTF-8").valid_encoding?
72
+ obj.force_encoding("ISO-8859-1").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)
73
+ end
74
+ end
75
+ obj
76
+ end
77
+
78
+ def encode(hash)
79
+ return hash unless "".respond_to? :encode
80
+ encode_as_utf8(hash)
81
+ end
59
82
  end
60
83
  end
61
84
  end
data/spec/builder_spec.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
3
 
3
4
  describe "Git Payload Builder" do
@@ -17,14 +18,14 @@ describe "Git Payload Builder" do
17
18
 
18
19
  it "detects new branch and sets created=true in data" do
19
20
  hash = Flowdock::Git::Builder.new(@repo, "refs/heads/master", "0000000000000000000000000000000000000000", @after).to_hash
20
- hash[:created].should == true
21
- hash[:deleted].should_not == true
21
+ hash[:created].should eq(true)
22
+ hash[:deleted].should_not eq(true)
22
23
  end
23
24
 
24
25
  it "detects deleted branch and sets deleted=true in data" do
25
26
  hash = Flowdock::Git::Builder.new(@repo, "refs/heads/master", @before, "0000000000000000000000000000000000000000").to_hash
26
- hash[:deleted].should == true
27
- hash[:created].should_not == true
27
+ hash[:deleted].should eq(true)
28
+ hash[:created].should_not eq(true)
28
29
  end
29
30
 
30
31
  it "doesn't include commits in branch delete" do
@@ -38,6 +39,48 @@ describe "Git Payload Builder" do
38
39
  @hash = Flowdock::Git::Builder.new(@repo, "refs/heads/master", @before, @after).to_hash
39
40
  end
40
41
 
42
+ if RUBY_VERSION > '1.9'
43
+ it "properly sets encoding for UTF-8 content" do
44
+ builder = Flowdock::Git::Builder.new(@repo, "refs/heads/master", @before, "0000000000000000000000000000000000000000")
45
+ builder.stub(:commits).and_return([
46
+ {
47
+ :id => "0000000000000000000000000000000000000001",
48
+ :message => "This message contains UTF-8: ö".force_encoding("ASCII-8BIT"),
49
+ :timestamp => Time.now.iso8601,
50
+ :author => {
51
+ :name => "Föö Bär".force_encoding("ASCII-8BIT"),
52
+ :email => "foo@example.com"
53
+ },
54
+ :removed => [],
55
+ :added => [],
56
+ :modified => []
57
+ }
58
+ ])
59
+ builder.to_hash[:commits][0][:message].encoding.should eq(Encoding::UTF_8)
60
+ builder.to_hash[:commits][0][:message].should == "This message contains UTF-8: ö"
61
+ end
62
+
63
+ it "encodes ISO-8859-1 to UTF-8" do
64
+ builder = Flowdock::Git::Builder.new(@repo, "refs/heads/master", @before, "0000000000000000000000000000000000000000")
65
+ builder.stub(:commits).and_return([
66
+ {
67
+ :id => "0000000000000000000000000000000000000001",
68
+ :message => "This message contains UTF-8: ö".encode("ISO-8859-1").force_encoding("ASCII-8BIT"),
69
+ :timestamp => Time.now.iso8601,
70
+ :author => {
71
+ :name => "Föö Bär".encode("ISO-8859-1").force_encoding("ASCII-8BIT"),
72
+ :email => "foo@example.com"
73
+ },
74
+ :removed => [],
75
+ :added => [],
76
+ :modified => []
77
+ }
78
+ ])
79
+ builder.to_hash[:commits][0][:author][:name].encoding.should eq(Encoding::UTF_8)
80
+ builder.to_hash[:commits][0][:author][:name].should == "Föö Bär"
81
+ end
82
+ end
83
+
41
84
  it "contains before" do
42
85
  @hash[:before].should == @before
43
86
  end
@@ -60,8 +103,8 @@ describe "Git Payload Builder" do
60
103
  end
61
104
 
62
105
  it "has commit author information" do
63
- @hash[:commits].first[:author][:name].should == "Ville Lautanala"
64
- @hash[:commits].first[:author][:email].should == "lautis@gmail.com"
106
+ @hash[:commits].first[:author][:name].should eq("Ville Lautanala")
107
+ @hash[:commits].first[:author][:email].should eq("lautis@gmail.com")
65
108
  end
66
109
 
67
110
  it "has commit id" do
@@ -17,6 +17,14 @@ describe "Flowdock Git Hook" do
17
17
  }.should_not raise_error
18
18
  end
19
19
 
20
+ it "encodes content as UTF-8" do
21
+ @repo = Grit::Repo.new(".")
22
+ @before = "7e32af569ba794b0b1c5e4c38fef1d4e2e56be51"
23
+ @after = "a66d3ce668ae6f2a42d54d811962724200d5b32b"
24
+ @repo.stub!(:path).and_return("/foo/bar/flowdock-git-hook/.git")
25
+ @hash = Flowdock::Git::Builder.new(@repo, "refs/heads/master", @before, @after).to_hash
26
+ end
27
+
20
28
  it "builds payload" do
21
29
  stub_request(:post, "https://api.flowdock.com/v1/git/flowdock-token")
22
30
  Flowdock::Git.post("refs/heads/master", "7e32af569ba794b0b1c5e4c38fef1d4e2e56be51", "a1a94ba4bfa5f855676066861604b8edae1a20f5", :token => "flowdock-token")
@@ -40,7 +48,7 @@ describe "Flowdock Git Hook" do
40
48
  end
41
49
 
42
50
  it "encodes tags suitable for URI" do
43
- Flowdock::Git.new(:token => "flowdock-token", :tags => "foo%bar").send(:tags).should include("foo%25bar")
51
+ Flowdock::Git.new(:token => "flowdock-token", :tags => ["foo%bar"]).send(:tags).should include("foo%25bar")
44
52
  end
45
53
  end
46
54
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowdock-git-hook
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 21
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 0
9
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ville Lautanala
@@ -14,103 +15,144 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-08-23 00:00:00 +03:00
18
- default_executable:
18
+ date: 2012-01-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- type: :runtime
23
- name: grit
24
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
25
23
  requirements:
26
24
  - - ">="
27
25
  - !ruby/object:Gem::Version
26
+ hash: 29
28
27
  segments:
29
28
  - 2
30
29
  - 4
31
30
  - 1
32
31
  version: 2.4.1
33
- requirement: *id001
34
- - !ruby/object:Gem::Dependency
32
+ name: grit
35
33
  prerelease: false
36
34
  type: :runtime
37
- name: multi_json
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
38
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
+ hash: 3
42
43
  segments:
43
44
  - 0
44
45
  version: "0"
46
+ name: multi_json
47
+ prerelease: false
48
+ type: :runtime
45
49
  requirement: *id002
46
50
  - !ruby/object:Gem::Dependency
47
- prerelease: false
48
- type: :development
49
- name: rspec
50
51
  version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
51
53
  requirements:
52
- - - ~>
54
+ - - ">="
53
55
  - !ruby/object:Gem::Version
56
+ hash: 27
54
57
  segments:
55
58
  - 2
56
- - 6
57
- - 0
58
- version: 2.6.0
59
+ - 4
60
+ - 2
61
+ version: 2.4.2
62
+ name: rdoc
63
+ prerelease: false
64
+ type: :development
59
65
  requirement: *id003
60
66
  - !ruby/object:Gem::Dependency
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 19
73
+ segments:
74
+ - 2
75
+ - 8
76
+ version: "2.8"
77
+ name: rspec
61
78
  prerelease: false
62
79
  type: :development
63
- name: bundler
64
- version_requirements: &id004 !ruby/object:Gem::Requirement
80
+ requirement: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
83
+ none: false
65
84
  requirements:
66
85
  - - ~>
67
86
  - !ruby/object:Gem::Version
87
+ hash: 15
68
88
  segments:
69
89
  - 1
70
90
  - 0
71
- - 0
72
- version: 1.0.0
73
- requirement: *id004
74
- - !ruby/object:Gem::Dependency
91
+ version: "1.0"
92
+ name: bundler
75
93
  prerelease: false
76
94
  type: :development
77
- name: jeweler
78
- version_requirements: &id005 !ruby/object:Gem::Requirement
95
+ requirement: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
79
99
  requirements:
80
100
  - - ~>
81
101
  - !ruby/object:Gem::Version
102
+ hash: 11
82
103
  segments:
83
104
  - 1
84
105
  - 6
85
106
  - 2
86
107
  version: 1.6.2
87
- requirement: *id005
88
- - !ruby/object:Gem::Dependency
108
+ name: jeweler
89
109
  prerelease: false
90
110
  type: :development
91
- name: rcov
92
- version_requirements: &id006 !ruby/object:Gem::Requirement
111
+ requirement: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ version_requirements: &id007 !ruby/object:Gem::Requirement
114
+ none: false
93
115
  requirements:
94
116
  - - ">="
95
117
  - !ruby/object:Gem::Version
118
+ hash: 3
96
119
  segments:
97
120
  - 0
98
121
  version: "0"
99
- requirement: *id006
100
- - !ruby/object:Gem::Dependency
122
+ name: rcov
101
123
  prerelease: false
102
124
  type: :development
103
- name: webmock
104
- version_requirements: &id007 !ruby/object:Gem::Requirement
125
+ requirement: *id007
126
+ - !ruby/object:Gem::Dependency
127
+ version_requirements: &id008 !ruby/object:Gem::Requirement
128
+ none: false
105
129
  requirements:
106
130
  - - ">="
107
131
  - !ruby/object:Gem::Version
132
+ hash: 7
108
133
  segments:
109
134
  - 1
110
135
  - 6
111
136
  - 4
112
137
  version: 1.6.4
113
- requirement: *id007
138
+ name: webmock
139
+ prerelease: false
140
+ type: :development
141
+ requirement: *id008
142
+ - !ruby/object:Gem::Dependency
143
+ version_requirements: &id009 !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ name: jruby-openssl
153
+ prerelease: false
154
+ type: :development
155
+ requirement: *id009
114
156
  description:
115
157
  email: lautis@gmail.com
116
158
  executables: []
@@ -123,6 +165,7 @@ extra_rdoc_files:
123
165
  files:
124
166
  - .document
125
167
  - .rspec
168
+ - .travis.yml
126
169
  - Gemfile
127
170
  - LICENSE.txt
128
171
  - README.rdoc
@@ -136,7 +179,6 @@ files:
136
179
  - spec/builder_spec.rb
137
180
  - spec/flowdock_git_spec.rb
138
181
  - spec/spec_helper.rb
139
- has_rdoc: true
140
182
  homepage: http://github.com/flowdock/flowdock-git-hook
141
183
  licenses:
142
184
  - MIT
@@ -146,23 +188,27 @@ rdoc_options: []
146
188
  require_paths:
147
189
  - lib
148
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
149
192
  requirements:
150
193
  - - ">="
151
194
  - !ruby/object:Gem::Version
195
+ hash: 3
152
196
  segments:
153
197
  - 0
154
198
  version: "0"
155
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
156
201
  requirements:
157
202
  - - ">="
158
203
  - !ruby/object:Gem::Version
204
+ hash: 3
159
205
  segments:
160
206
  - 0
161
207
  version: "0"
162
208
  requirements: []
163
209
 
164
210
  rubyforge_project:
165
- rubygems_version: 1.3.6
211
+ rubygems_version: 1.8.10
166
212
  signing_key:
167
213
  specification_version: 3
168
214
  summary: Git Post-Receive hook for Flowdock