octospy 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c3a44346c54c0c69fb51561b692fb4f9216304
4
- data.tar.gz: 80c043163646771135069da36e087dc01cab75c7
3
+ metadata.gz: 5cd0013747a9a0beb2685537dfe99b7afc590887
4
+ data.tar.gz: ad7d7b31e172f099dfac8a0167db0568502e4506
5
5
  SHA512:
6
- metadata.gz: d19a444802e932594a9513605314cd665bc85274f12d9a22a5892d9902cb327ee8279979e28f0ef79f3bd468b3b7818069438bea923c20bac07533da16a6ef0d
7
- data.tar.gz: 25694444c3dd360c39f1fa2549ca27795da1aaff97704b556502b04c2c4784f4bcf3fe4820cd962441a1f01dc150628086fde0f7996b8986bcb1d19d5d7b9ff5
6
+ metadata.gz: 1acb8dcef9fafe09dce81b7104366a066a1c1f994522336833f3938e5adf4c40d855d1849ca6b614944453e5d301a1872cced2148049d8ee805681203e7da3ec
7
+ data.tar.gz: 51b3b6dc3f079ac109471235edea04206f4508b9f84ffe29455486c8caeb154ad7c5de256a0c112ddcc87d529e47ee9e22ac8e1bdd5aff8e50b51c5314f99fa1
data/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ SERVER=irc.yourserver.net
2
+ CHANNELS=yourchannel
3
+ GITHUB_LOGIN=yourusername
4
+ GITHUB_TOKEN=e17e1c6caa3e452433ab55****************
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format progress
data/README.md CHANGED
@@ -13,30 +13,81 @@ Octospy
13
13
  [codeclimate]: https://codeclimate.com/github/linyows/octospy
14
14
  [coveralls]: https://coveralls.io/r/linyows/octospy
15
15
 
16
- Octospy notifies the repository activity to an IRC channel.
16
+ Octospy notifies the repository activity to some IRC channels.
17
17
 
18
+ <div align="center">
18
19
  <img src="http://octodex.github.com/images/daftpunktocat-thomas.gif" width="300">
19
20
  <img src="http://octodex.github.com/images/daftpunktocat-guy.gif" width="300">
21
+ </div>
20
22
 
21
23
  Installation
22
24
  ------------
23
25
 
24
26
  Add this line to your application's Gemfile:
25
27
 
26
- gem 'octospy'
28
+ ```ruby
29
+ gem 'octospy'
30
+ ```
27
31
 
28
32
  And then execute:
29
33
 
30
- $ bundle
34
+ ```sh
35
+ $ bundle
36
+ ```
31
37
 
32
38
  Or install it yourself as:
33
39
 
34
- $ gem install octospy
40
+ ```sh
41
+ $ gem install octospy
42
+ ```
35
43
 
36
44
  Usage
37
45
  -----
38
46
 
39
- TODO: Write usage instructions here
47
+ ```sh
48
+ $ cp .emv.example .env
49
+ ```
50
+
51
+ edit `.env`:
52
+
53
+ ```sh
54
+ SERVER=irc.yourserver.net
55
+ CHANNELS=yourchannel
56
+ GITHUB_LOGIN=yourusername
57
+ GITHUB_TOKEN=e17e1c6caa3e452433ab55****************
58
+ ```
59
+
60
+ github tokens: https://github.com/settings/applications
61
+
62
+ ```sh
63
+ $ octospy
64
+ ```
65
+
66
+ ### GitHub Enterprise
67
+
68
+ add to `.env`
69
+
70
+ ```sh
71
+ GITHUB_API_ENDPOINT=http://your.enterprise.domain/api/v3
72
+ GITHUB_WEB_ENDPOINT=http://your.enterprise.domain
73
+ ```
74
+
75
+ Commands
76
+ --------
77
+
78
+ format: `octospy: <command>`
79
+
80
+ Command | Description
81
+ ------- | -----------
82
+ `watch <repository>` | add repository to watch list (ex: watch rails/rails)
83
+ `unwatch <repository>` | remove repository to watch list
84
+ `watch <user or organization>` | add user's repositories to watch list (ex: watch dotcloud)
85
+ `unwatch <user or organization>` | remove user's repositories to watch list
86
+ `job start` | start the repository event monitoring
87
+ `job stop` | stop the repository event monitoring
88
+ `join <channel>` | invite octospy to another channel
89
+ `show watched` | display the watch list
90
+ `show status` | display the joined channels
40
91
 
41
92
  Contributing
42
93
  ------------
@@ -47,12 +98,12 @@ Contributing
47
98
  4. Push to the branch (`git push origin my-new-feature`)
48
99
  5. Create new Pull Request
49
100
 
50
- Author
51
- ------
101
+ Authors
102
+ -------
52
103
 
53
104
  - [linyows](https://github.com/linyows)
54
105
 
55
106
  License
56
107
  -------
57
108
 
58
- MIT
109
+ The MIT License (MIT)
@@ -49,7 +49,7 @@ module Cinch
49
49
 
50
50
  def show_status(m)
51
51
  @bot.channels.each.with_index(1) do |channel, i|
52
- number = ::Octospy.channel(channel).repos.count
52
+ number = ::Octospy::Recordable.channel(channel).repos.count
53
53
  m.reply "#{"%02d" % i} #{channel}: #{number} repo"
54
54
  end
55
55
  end
@@ -49,7 +49,7 @@ module Cinch
49
49
  end
50
50
 
51
51
  def start(m)
52
- repos = ::Octospy.channel(m.channel.name).repos
52
+ repos = ::Octospy::Recordable.channel(m.channel.name).repos
53
53
  channel = m.channel
54
54
 
55
55
  worker = ::Octospy.worker(repos) do |message|
@@ -4,10 +4,10 @@ module Cinch
4
4
  module Recording
5
5
  def self.included(base)
6
6
  base.class_eval do
7
- match(/watch ([\w\-\.]+)\/([\w\-\.]+)/, method: :watch_repository)
8
- match(/unwatch ([\w\-\.]+)\/([\w\-\.]+)/, method: :unwatch_repository)
9
- match(/watch ([\w\-\.]+)/, method: :watch_repositories)
10
- match(/unwatch ([\w\-\.]+)/, method: :unwatch_repositories)
7
+ match(/watch ([\w\-\.]+)\/([\w\-\.]+)$/, method: :watch_repository)
8
+ match(/unwatch ([\w\-\.]+)\/([\w\-\.]+)$/, method: :unwatch_repository)
9
+ match(/watch ([\w\-\.]+)$/, method: :watch_repositories)
10
+ match(/unwatch ([\w\-\.]+)$/, method: :unwatch_repositories)
11
11
  match(/show watched( repos(itories)?)?/, method: :show_watched_repositories)
12
12
  end
13
13
  end
@@ -20,8 +20,8 @@ module Cinch
20
20
  return
21
21
  end
22
22
 
23
- ::Octospy.add_channel m.channel.name
24
- ::Octospy.channel(m.channel.name).add_repo(repo)
23
+ ::Octospy::Recordable.add_channel m.channel.name
24
+ ::Octospy::Recordable.channel(m.channel.name).add_repo(repo)
25
25
 
26
26
  restart(m)
27
27
  m.reply "I started to watch the #{repo} events"
@@ -35,10 +35,10 @@ module Cinch
35
35
  return
36
36
  end
37
37
 
38
- ::Octospy.add_channel m.channel.name
38
+ ::Octospy::Recordable.add_channel m.channel.name
39
39
  method = "#{'org_' if user.type == 'Organization'}repos".to_sym
40
40
  repos = ::Octokit.send(method, owner).map { |repo|
41
- ::Octospy.channel(m.channel.name).add_repo(repo.full_name)
41
+ ::Octospy::Recordable.channel(m.channel.name).add_repo(repo.full_name)
42
42
  repo.full_name
43
43
  }
44
44
 
@@ -56,21 +56,21 @@ module Cinch
56
56
  return
57
57
  end
58
58
 
59
- ::Octospy.channel(m.channel.name).remove_repo(repo)
59
+ ::Octospy::Recordable.channel(m.channel.name).remove_repo(repo)
60
60
 
61
61
  restart(m)
62
62
  m.reply "I stopped to watch the #{repo} events"
63
63
  end
64
64
 
65
65
  def unwatch_repositories(m, owner)
66
- repos = ::Octospy.channel(m.channel.name).repos.each_with_object([]) do |repo, obj|
66
+ repos = ::Octospy::Recordable.channel(m.channel.name).repos.each_with_object([]) do |repo, obj|
67
67
  next unless repo.split('/').first == owner
68
- ::Octospy.channel(m.channel.name).remove_repo(repo)
68
+ ::Octospy::Recordable.channel(m.channel.name).remove_repo(repo)
69
69
  opj << repo
70
70
  end
71
71
 
72
72
  if repos.count > 0
73
- if ::Octospy.channel(m.channel.name).repos.count > 0
73
+ if ::Octospy::Recordable.channel(m.channel.name).repos.count > 0
74
74
  m.reply "stopped to watch events of #{repos.count} repositories"
75
75
  restart(m)
76
76
  else
@@ -84,9 +84,9 @@ module Cinch
84
84
  end
85
85
 
86
86
  def show_watched_repositories(m)
87
- channel = ::Octospy.channel(m.channel.name)
87
+ channel = ::Octospy::Recordable.channel(m.channel.name)
88
88
 
89
- if channel.nil? || channel.repos.nil? || !channel.repos
89
+ if channel.nil? || channel.repos.nil? || channel.repos.empty?
90
90
  m.reply 'nothing!'
91
91
  return
92
92
  end
data/lib/octospy.rb CHANGED
@@ -14,7 +14,6 @@ require 'octospy/octokit/client'
14
14
  module Octospy
15
15
  class << self
16
16
  include Octospy::Configurable
17
- include Octospy::Recordable
18
17
 
19
18
  def parse(event)
20
19
  Octospy::Parser.new(event).parse
@@ -1,25 +1,34 @@
1
1
  require 'octospy/recordable/channel'
2
- require 'octospy/recordable/repo'
3
2
 
4
3
  module Octospy
5
4
  module Recordable
6
- def channels
7
- @channels ||= {}
8
- end
5
+ class << self
6
+ def channels
7
+ @channels ||= []
8
+ end
9
9
 
10
- def add_channel(name)
11
- @channels.merge!(:"#{name}" => Channel.new(name)) unless channels.has_key?(name.to_sym)
12
- end
10
+ def channels_include?(name)
11
+ !!find_channel(name)
12
+ end
13
13
 
14
- def del_channel(name)
15
- @channels.delete(name.to_sym) if channels.has_key?(name)
16
- end
14
+ def find_channel(name)
15
+ channels.find { |channel| channel.name.to_s == name.to_s }
16
+ end
17
+
18
+ def add_channel(name)
19
+ channels << Channel.new(name) unless channels_include? name
20
+ end
21
+
22
+ def del_channel(name)
23
+ channels.delete_if { |channel| channel.name.to_s == name.to_s }
24
+ end
17
25
 
18
- def channel(name)
19
- if channels.has_key?(name.to_sym)
20
- @channels[name.to_sym]
21
- else
22
- Channel.new(name)
26
+ def channel(name)
27
+ if channels_include? name
28
+ find_channel name
29
+ else
30
+ Channel.new(name)
31
+ end
23
32
  end
24
33
  end
25
34
  end
@@ -1,8 +1,8 @@
1
- require 'octospy/recordable/repo'
2
-
3
1
  module Octospy
4
2
  module Recordable
5
3
  class Channel
4
+ attr_reader :name
5
+
6
6
  def initialize(name)
7
7
  @name = name.to_sym
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Octospy
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
data/octospy.gemspec CHANGED
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "faraday"
35
35
  spec.add_dependency "faraday_middleware"
36
36
  spec.add_dependency "dotenv"
37
+ spec.add_dependency "hashie"
37
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octospy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - linyows
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-23 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: hashie
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  description: This is IRC bot that notifies repository activity on github.
224
238
  email:
225
239
  - linyows@gmail.com
@@ -228,6 +242,7 @@ executables:
228
242
  extensions: []
229
243
  extra_rdoc_files: []
230
244
  files:
245
+ - ".env.example"
231
246
  - ".gitignore"
232
247
  - ".rspec"
233
248
  - ".travis.yml"
@@ -255,7 +270,6 @@ files:
255
270
  - lib/octospy/parser/wiki.rb
256
271
  - lib/octospy/recordable.rb
257
272
  - lib/octospy/recordable/channel.rb
258
- - lib/octospy/recordable/repo.rb
259
273
  - lib/octospy/shortener.rb
260
274
  - lib/octospy/version.rb
261
275
  - lib/octospy/worker.rb
@@ -309,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
323
  version: '0'
310
324
  requirements: []
311
325
  rubyforge_project:
312
- rubygems_version: 2.2.0
326
+ rubygems_version: 2.2.2
313
327
  signing_key:
314
328
  specification_version: 4
315
329
  summary: Octospy notifies the repository activity to an IRC channel.
@@ -1,16 +0,0 @@
1
- module Octospy
2
- module Recordable
3
- class Repo
4
- attr_accessor :name, :last_event_id
5
-
6
- def initialize(name)
7
- @name = name.to_sym
8
- @last_event_id = nil
9
- end
10
-
11
- def clear!
12
- @last_event_id = nil
13
- end
14
- end
15
- end
16
- end