githubwatcher 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,6 +35,14 @@ with your favorite editor.
35
35
 
36
36
  Should look like this (if you have ran ```githubwatcher start```)
37
37
 
38
+ We provide a `config` command to easily edit it.
39
+
40
+ ``` sh
41
+ $ githubwatcher config
42
+ ```
43
+
44
+ It will open in texmate or vim this:
45
+
38
46
  ``` yaml
39
47
  ---
40
48
  - daddye/all
@@ -62,7 +70,7 @@ If you want to watch **all** repositories of a given user you simply provide **/
62
70
  Restart the deamon
63
71
 
64
72
  ``` sh
65
- $ githubwatcher start
73
+ $ githubwatcher restart
66
74
  ```
67
75
 
68
76
  ## Working with Ruby Forever
data/Rakefile CHANGED
@@ -1,2 +1,17 @@
1
1
  require 'rubygems' unless defined?(Gem)
2
- require 'bundler/gem_tasks'
2
+ require 'bundler/gem_tasks'
3
+
4
+ %w(install release).each do |task|
5
+ Rake::Task[task].enhance do
6
+ sh "rm -rf pkg"
7
+ end
8
+ end
9
+
10
+ desc "Bump version on github"
11
+ task :bump do
12
+ puts "Nothing to commit (working directory clean)" and return if `git status -s`.strip == ""
13
+ version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
14
+ sh "git add .; git commit -m \"Bump to version #{version}\""
15
+ end
16
+
17
+ task :release => :bump
@@ -1,19 +1,18 @@
1
1
  #!/usr/bin/ruby
2
+ $: << File.expand_path('../../lib', __FILE__) # For unknow reason bundler don't always add this path
2
3
  require 'rubygems' unless defined?(Gem)
3
4
  require 'forever'
4
5
  require 'bundler/setup'
5
6
  require 'githubwatcher'
6
7
 
7
- Forever.run do
8
- ##
9
- # You can set these values
10
- #
11
- # dir "foo" # Default: File.expand_path('../../', __FILE__)
12
- # file "bar" # Default: __FILE__
13
- # log "bar.log" # Default: File.expand_path(dir, '/log/[file_name].log')
14
- # pid "bar.pid" # Default: File.expand_path(dir, '/tmp/[file_name].pid')
15
- #
8
+ if ARGV.any? { |cmd| cmd =~ /config(?:ure)?/i }
9
+ editor = `which mate`.chomp! || `which vim`.chomp!
10
+ puts "Im unable to find an editor, open manually ~/.githubwatcher/repos.yaml" and exit unless editor
11
+ system editor, File.expand_path('~/.githubwatcher/repos.yaml') and exit
12
+ end
16
13
 
14
+ Forever.run do
15
+ # Our working directory, here we store pids/logs and obviously our list of repo to watch
17
16
  dir File.expand_path('~/.githubwatcher')
18
17
 
19
18
  on_error do |e|
@@ -21,6 +20,15 @@ Forever.run do
21
20
  end
22
21
 
23
22
  on_ready do
24
- Githubwatcher.start!
23
+ Githubwatcher.setup
24
+ Githubwatcher.notify("GitHub Watcher", "was started...")
25
+ end
26
+
27
+ on_exit do
28
+ Githubwatcher.notify("GitHub Watcher", "was stopped...")
29
+ end
30
+
31
+ every 5.seconds do
32
+ Githubwatcher.run
25
33
  end
26
34
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
  s.add_dependency 'httparty', '~>0.7.8'
21
21
  s.add_dependency 'growl', '~>1.0.3'
22
- s.add_dependency 'foreverb', '~>0.1.7'
22
+ s.add_dependency 'foreverb', '~>0.2.0'
23
23
  end
@@ -12,9 +12,9 @@ module Githubwatcher
12
12
  base_uri 'https://api.github.com'
13
13
  format :json
14
14
 
15
- def start!
15
+ def setup
16
16
  raise "You need to install growlnotify, use brew install growlnotify or install it from growl.info site" unless Growl.installed?
17
- log "Starting GitHub Watcher..."
17
+ puts "Starting GitHub Watcher..."
18
18
 
19
19
  unless File.exist?(WATCH)
20
20
  warn "Add the repositories you're willing to monitor editing: ~/.githubwatcher/repos.yaml"
@@ -23,56 +23,56 @@ module Githubwatcher
23
23
  end
24
24
 
25
25
  @_watch = YAML.load_file(WATCH)
26
-
27
- notify("GitHub Watcher", "is now listening...")
28
26
  @_repos = YAML.load_file(DB) if File.exist?(DB)
29
- while !@_stop do
30
- repos_was = repos.dup
31
- watch.each do |value|
32
- key, value = *value.split("/")
33
- r = get "/users/%s/repos" % key
34
- r.each do |repo|
35
- next unless value.include?(repo["name"]) || value.include?("all")
36
- log "Quering #{repo["git_url"]}..."
37
-
38
- found = repos_was.find { |r| r["name"] == repo["name"] }
39
-
40
- if !found
41
- notify(repo["name"], "Was created")
42
- repos_was << repo
43
- repos << repo
44
- end
45
-
46
- repo_was = repos_was.find { |r| r["name"] == repo["name"] }
47
-
48
- if repo_was["watchers"] != repo["watchers"]
49
- notify(repo["name"], "Has new #{repo["watchers"]-repo_was["watchers"]} watchers")
50
- repo_was["watchers"] = repo["watchers"]
51
- end
52
-
53
- if repo_was["open_issues"] != repo["open_issues"]
54
- notify(repo["name"], "Has new #{repo["open_issues"]-repo_was["open_issues"]} open issues")
55
- repo_was["open_issues"] = repo["open_issues"]
56
- end
57
-
58
- if repo_was["pushed_at"] != repo["pushed_at"]
59
- notify(repo["name"], "Was updated!")
60
- repo_was["pushed_at"] = repo["pushed_at"]
61
- end
62
-
63
- if repo_was["forks"] != repo["forks"]
64
- notify(repo["name"], "Has new #{repo["forks"]-repo_was["forks"]} forks")
65
- repo_was["forks"] = repo["forks"]
66
- end
67
-
68
- found = repo if found
27
+ end
28
+
29
+ def start!
30
+ repos_was = repos.dup
31
+ watch.each do |value|
32
+ key, value = *value.split("/")
33
+ r = get "/users/%s/repos" % key
34
+ r.each do |repo|
35
+ next unless value.include?(repo["name"]) || value.include?("all")
36
+ puts "Quering #{repo["git_url"]}..."
37
+
38
+ found = repos_was.find { |r| r["name"] == repo["name"] }
39
+
40
+ repo_fullname = [repo['owner']['login'],repo['name']].join('/')
41
+ if !found
42
+ notify(repo_fullname, "Was created")
43
+ repos_was << repo
44
+ repos << repo
45
+ end
46
+
47
+ repo_was = repos_was.find { |r| r["name"] == repo["name"] }
48
+
49
+ if repo_was["watchers"] != repo["watchers"]
50
+ notify(repo_fullname, "Has new #{repo["watchers"]-repo_was["watchers"]} watchers")
51
+ repo_was["watchers"] = repo["watchers"]
52
+ end
53
+
54
+ if repo_was["open_issues"] != repo["open_issues"]
55
+ notify(repo_fullname, "Has new #{repo["open_issues"]-repo_was["open_issues"]} open issues")
56
+ repo_was["open_issues"] = repo["open_issues"]
69
57
  end
58
+
59
+ if repo_was["pushed_at"] != repo["pushed_at"]
60
+ notify(repo_fullname, "Was updated!")
61
+ repo_was["pushed_at"] = repo["pushed_at"]
62
+ end
63
+
64
+ if repo_was["forks"] != repo["forks"]
65
+ notify(repo_fullname, "Has new #{repo["forks"]-repo_was["forks"]} forks")
66
+ repo_was["forks"] = repo["forks"]
67
+ end
68
+
69
+ found = repo if found
70
70
  end
71
- Dir.mkdir(File.dirname(DB)) unless File.exist?(File.dirname(DB))
72
- File.open(DB, "w"){ |f| f.write @_repos.to_yaml }
73
- sleep 5
74
71
  end
72
+ Dir.mkdir(File.dirname(DB)) unless File.exist?(File.dirname(DB))
73
+ File.open(DB, "w"){ |f| f.write @_repos.to_yaml }
75
74
  end
75
+ alias :run :start!
76
76
 
77
77
  def repos
78
78
  @_repos ||= []
@@ -82,19 +82,8 @@ module Githubwatcher
82
82
  @_watch ||= []
83
83
  end
84
84
 
85
- def stop!
86
- puts "\n<= Exiting ..."
87
- @_stop = true
88
- end
89
-
90
- def log(text="")
91
- text = "[%s] %s" % [Time.now.strftime("%d/%m %H:%M"), text.to_s]
92
- text += "\n" unless text[-1] == ?\n
93
- print text; $stdout.flush
94
- end
95
-
96
85
  def notify(title, text)
97
86
  Growl.notify text, :title => title, :icon => File.expand_path("../../images/icon.png", __FILE__); sleep 0.2
98
- log "=> #{title}: #{text}"
87
+ puts "=> #{title}: #{text}"
99
88
  end
100
89
  end
@@ -1,3 +1,3 @@
1
1
  module Githubwatcher
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubwatcher
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 25
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Davide D'Agostino
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-07-08 00:00:00 +02:00
18
+ date: 2011-07-14 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: httparty
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ~>
26
28
  - !ruby/object:Gem::Version
29
+ hash: 19
27
30
  segments:
28
31
  - 0
29
32
  - 7
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: growl
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ~>
40
44
  - !ruby/object:Gem::Version
45
+ hash: 17
41
46
  segments:
42
47
  - 1
43
48
  - 0
@@ -49,14 +54,16 @@ dependencies:
49
54
  name: foreverb
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ~>
54
60
  - !ruby/object:Gem::Version
61
+ hash: 23
55
62
  segments:
56
63
  - 0
57
- - 1
58
- - 7
59
- version: 0.1.7
64
+ - 2
65
+ - 0
66
+ version: 0.2.0
60
67
  type: :runtime
61
68
  version_requirements: *id003
62
69
  description: Github Growl Watcher, watch any project and receive growl notification for updates, new watchers, forks and issues
@@ -88,23 +95,27 @@ rdoc_options: []
88
95
  require_paths:
89
96
  - lib
90
97
  required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
91
99
  requirements:
92
100
  - - ">="
93
101
  - !ruby/object:Gem::Version
102
+ hash: 3
94
103
  segments:
95
104
  - 0
96
105
  version: "0"
97
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
98
108
  requirements:
99
109
  - - ">="
100
110
  - !ruby/object:Gem::Version
111
+ hash: 3
101
112
  segments:
102
113
  - 0
103
114
  version: "0"
104
115
  requirements: []
105
116
 
106
117
  rubyforge_project: githubwatcher
107
- rubygems_version: 1.3.6
118
+ rubygems_version: 1.6.2
108
119
  signing_key:
109
120
  specification_version: 3
110
121
  summary: Github Growl Watcher, watch any project and receive growl notification