hubeye 0.1.0 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/tasks/install.rb CHANGED
@@ -1,36 +1,28 @@
1
- task :install => :chmod do
2
- puts "Done"
3
- end
1
+ HUBEYE_ROOT_DIR = File.join(ENV['HOME'], '.hubeye')
2
+ HUBEYE_REPOS_DIR = File.join(HUBEYE_ROOT_DIR, 'repos')
3
+ HUBEYE_HOOKS_DIR = File.join(HUBEYE_ROOT_DIR, 'hooks')
4
+ HUBEYE_LOG_FILE = File.join(HUBEYE_ROOT_DIR, 'log')
5
+ HUBEYE_CONF_FILE = File.join(HUBEYE_ROOT_DIR, 'hubeyerc')
4
6
 
5
- task :chmod => :config_file do
6
- binfile = File.join(File.expand_path(File.dirname(__FILE__) + '/..'), "/bin/hubeye")
7
- chmod 0777, binfile unless File.executable?(binfile)
7
+ task :install => :create_config_file do
8
+ puts "Done"
8
9
  end
9
10
 
10
- task :config_file do
11
- config_file = File.join(ENV['HOME'], "/.hubeye/hubeyerc")
12
- touch config_file unless File.exists? config_file
11
+ task :create_config_file do
12
+ touch HUBEYE_CONF_FILE unless File.exists? HUBEYE_CONF_FILE
13
13
  end
14
14
 
15
- task :config_file => :makelog
16
-
17
- task :makelog => :message do
18
- hubeye_dir = ENV['HOME'] + "/.hubeye"
19
- mkdir(hubeye_dir) unless File.exists?(hubeye_dir)
15
+ task :create_config_file => :make_log
20
16
 
21
- hooks_dir = hubeye_dir + "/hooks"
22
- mkdir(hooks_dir) unless File.exists?(hooks_dir)
17
+ task :make_log => :message do
18
+ mkdir HUBEYE_ROOT_DIR unless File.exists? HUBEYE_ROOT_DIR
19
+ mkdir HUBEYE_HOOKS_DIR unless File.exists? HUBEYE_HOOKS_DIR
20
+ mkdir HUBEYE_REPOS_DIR unless File.exists? HUBEYE_REPOS_DIR
23
21
 
24
- repos_dir = hubeye_dir + "/repos"
25
- mkdir(repos_dir) unless File.exists?(repos_dir)
26
-
27
- hubeye_log_file = File.join(ENV['HOME'], "/.hubeye/log")
28
- touch hubeye_log_file unless File.exists?(hubeye_log_file)
22
+ touch HUBEYE_LOG_FILE unless File.exists? HUBEYE_LOG_FILE
29
23
  end
30
24
 
31
-
32
-
33
25
  task :message do
34
- puts "Installing Hubeye..."
26
+ puts "Installing hubeye..."
35
27
  end
36
28
 
@@ -3,6 +3,13 @@ require 'stringio'
3
3
 
4
4
  class ConfigParserTests < Test::Unit::TestCase
5
5
 
6
+ # otherwise, Test::Unit busies the self.instance_variables
7
+ # array with things like @passed, and many others
8
+ def instance_vars
9
+ [:@username, :@default_track, :@hooks,
10
+ :@repos, :@oncearound, :@notification_wanted]
11
+ end
12
+
6
13
  def get_config_settings(config_file)
7
14
  Hubeye::Config::Parser.new(config_file, :test => true) do |c|
8
15
  @username = c.username
@@ -17,11 +24,8 @@ class ConfigParserTests < Test::Unit::TestCase
17
24
  def test_proper_username_parse
18
25
  text = 'username: luke-gru'
19
26
  get_config_settings(text)
20
- assert_nil @default_track
21
- assert_nil @oncearound
22
- assert_nil @hooks
23
- assert_nil @notification_wanted
24
- assert_nil @repos
27
+ other_vars = instance_vars.reject {|v| v =~ /username/}
28
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
25
29
 
26
30
  assert_equal 'luke-gru', @username
27
31
  end
@@ -29,16 +33,24 @@ class ConfigParserTests < Test::Unit::TestCase
29
33
  def test_proper_default_track_parse
30
34
  text = 'track: rails/rails, jimweirich/rake, sinatra/sinatra'
31
35
  get_config_settings(text)
32
- assert_nil @username
33
- assert_nil @oncearound
34
- assert_nil @hooks
35
- assert_nil @notification_wanted
36
- assert_nil @repos
36
+ other_vars = instance_vars.reject {|v| v =~ /default_track/}
37
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
37
38
 
38
39
  assert_equal 3, @default_track.length
39
40
  assert_equal ['rails/rails', 'jimweirich/rake', 'sinatra/sinatra'], @default_track
40
41
  end
41
42
 
43
+ def test_username_and_default_track_parse
44
+ text = "username: luke-gru\n" +
45
+ "track: rails/rails, jimweirich/rake, sinatra/sinatra"
46
+ get_config_settings(text)
47
+ other_vars = instance_vars.reject {|v| v =~ /default_track|username/}
48
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
49
+
50
+ assert_equal 'luke-gru', @username
51
+ assert_equal ['rails/rails', 'jimweirich/rake', 'sinatra/sinatra'], @default_track
52
+ end
53
+
42
54
  def test_oncearound_error
43
55
  text = 'oncearound: fooey'
44
56
  assert_raises(Hubeye::Config::Parser::ConfigParseError) { get_config_settings(text) }
@@ -47,23 +59,28 @@ class ConfigParserTests < Test::Unit::TestCase
47
59
  def test_proper_oncearound_parse
48
60
  text = 'oncearound: 80'
49
61
  get_config_settings(text)
50
- assert_nil @username
51
- assert_nil @default_track
52
- assert_nil @hooks
53
- assert_nil @notification_wanted
54
- assert_nil @repos
62
+ other_vars = instance_vars.reject {|v| v =~ /oncearound/}
63
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
55
64
 
56
65
  assert_equal 80, @oncearound
57
66
  end
58
67
 
68
+ def test_oncearound_and_default_track_parse_with_spaces_tabs
69
+ text = "oncearound: 2330\n" +
70
+ "track: luke-gru/hubeye, sinatra/sinatra, rails/rails"
71
+ get_config_settings(text)
72
+ other_vars = instance_vars.reject {|v| v =~ /oncearound|default_track/}
73
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
74
+
75
+ assert_equal 2330, @oncearound
76
+ assert_equal ['luke-gru/hubeye', 'sinatra/sinatra', 'rails/rails'], @default_track
77
+ end
78
+
59
79
  def test_proper_default_hook_parse
60
80
  text = 'load hooks: myhook1, myhook2, captain_hook'
61
81
  get_config_settings(text)
62
- assert_nil @username
63
- assert_nil @oncearound
64
- assert_nil @default_track
65
- assert_nil @notification_wanted
66
- assert_nil @repos
82
+ other_vars = instance_vars.reject {|v| v =~ /hooks/}
83
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
67
84
 
68
85
  assert_equal ['myhook1', 'myhook2', 'captain_hook'], @hooks
69
86
  end
@@ -71,11 +88,8 @@ class ConfigParserTests < Test::Unit::TestCase
71
88
  def test_proper_default_repos_parse
72
89
  text = 'load repos: myforks, myprojects, mywork'
73
90
  get_config_settings(text)
74
- assert_nil @username
75
- assert_nil @oncearound
76
- assert_nil @default_track
77
- assert_nil @notification_wanted
78
- assert_nil @hooks
91
+ other_vars = instance_vars.reject {|v| v =~ /repos/}
92
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
79
93
 
80
94
  assert_equal ['myforks', 'myprojects', 'mywork'], @repos
81
95
  end
@@ -83,11 +97,8 @@ class ConfigParserTests < Test::Unit::TestCase
83
97
  def test_notification_off_parse
84
98
  text = 'desktop notification: off'
85
99
  get_config_settings(text)
86
- assert_nil @username
87
- assert_nil @oncearound
88
- assert_nil @default_track
89
- assert_nil @hooks
90
- assert_nil @repos
100
+ other_vars = instance_vars.reject {|v| v =~ /notification_wanted/}
101
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
91
102
 
92
103
  assert_equal false, @notification_wanted
93
104
  end
@@ -95,11 +106,8 @@ class ConfigParserTests < Test::Unit::TestCase
95
106
  def test_notification_on_parse
96
107
  text = 'desktop notification: on'
97
108
  get_config_settings(text)
98
- assert_nil @username
99
- assert_nil @oncearound
100
- assert_nil @default_track
101
- assert_nil @hooks
102
- assert_nil @repos
109
+ other_vars = instance_vars.reject {|v| v =~ /notification_wanted/}
110
+ other_vars.each {|v| assert_nil instance_variable_get(v)}
103
111
 
104
112
  assert_equal true, @notification_wanted
105
113
 
@@ -110,5 +118,24 @@ class ConfigParserTests < Test::Unit::TestCase
110
118
  assert_raises(Hubeye::Config::Parser::ConfigParseError) { get_config_settings(text) }
111
119
  end
112
120
 
121
+ def test_all_options
122
+ text = "oncearound: 2330\n" +
123
+ "track: luke-gru/hubeye, sinatra/sinatra, rails/rails\n" +
124
+ "desktop notification: on\n" +
125
+ "load repos: myforks, myprojects, mywork\n" +
126
+ "load hooks: myhook1, myhook2, captain_hook\n" +
127
+ "username: hansolo" +
128
+ "\n\n"
129
+ get_config_settings(text)
130
+
131
+ assert_equal 2330, @oncearound
132
+ assert_equal ['luke-gru/hubeye', 'sinatra/sinatra', 'rails/rails'], @default_track
133
+ assert @notification_wanted
134
+ assert_equal ['myforks', 'myprojects', 'mywork'], @repos
135
+ assert_equal ['myhook1', 'myhook2', 'captain_hook'], @hooks
136
+ assert_equal 'hansolo', @username
137
+
138
+ end
139
+
113
140
  end
114
141
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubeye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,21 +9,19 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-04 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: octopi
16
- requirement: &86576300 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *86576300
25
- description: Github repository commit watcher -- keep your eye on new commits from
26
- multiple repos through an interactive CLI
12
+ date: 2011-12-04 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ! 'Keep your eye on new commits being pushed to Github through an
15
+
16
+ interactive interface. When new commits are seen by Hubeye, you can
17
+
18
+ choose to be notified by one of Hubeye''s notification systems (growl,
19
+
20
+ libnotify, etc...). All interesting activity is logged, so leave
21
+
22
+ your computer, come back, and know what changed.
23
+
24
+ '
27
25
  email: luke.gru@gmail.com
28
26
  executables:
29
27
  - hubeye
@@ -77,5 +75,5 @@ rubygems_version: 1.8.10
77
75
  signing_key:
78
76
  specification_version: 3
79
77
  summary: Github repository commit watcher -- keep your eye on new commits from multiple
80
- repos through an interactive CLI
78
+ repos through an interactive CLI.
81
79
  test_files: []