sarnesjo-twhere 0.0.9 → 0.0.10

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.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/twhere +46 -8
  3. metadata +1 -1
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 9
3
+ :patch: 10
4
4
  :major: 0
data/bin/twhere CHANGED
@@ -6,28 +6,66 @@ require 'optparse'
6
6
 
7
7
  config_file = nil
8
8
 
9
- OptionParser.new do |opts|
10
- opts.banner = 'usage: twhere.rb [options]'
9
+ opts = OptionParser.new do |o|
10
+ o.banner = 'usage: twhere [options]'
11
11
 
12
- opts.on('-c', '--config FILE', 'specify config file') do |c|
12
+ o.on('-c', '--config FILE', 'specify config file') do |c|
13
13
  config_file = c
14
14
  end
15
15
 
16
- opts.on_tail('-h', '--help', 'show this message') do
17
- puts opts
16
+ o.on_tail('-h', '--help', 'show this message') do
17
+ $stderr.puts o
18
18
  exit
19
19
  end
20
20
 
21
- opts.on_tail('--version', 'show version') do
21
+ o.on_tail('-V', '--version', 'show version') do
22
22
  version = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', 'VERSION.yml')))
23
- puts "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
23
+ $stderr.puts "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
24
24
  exit
25
25
  end
26
- end.parse!
26
+ end
27
+
28
+ opts.parse!
29
+
30
+ # make sure the config option was given
31
+ unless config_file
32
+ $stderr.puts opts
33
+ exit 1
34
+ end
27
35
 
28
36
  # load config
29
37
  config = YAML::load(File.open(config_file))
30
38
 
39
+ # make sure config was properly loaded
40
+ unless config
41
+ $stderr.puts "could not load config from #{config_file}"
42
+ exit 1
43
+ end
44
+
45
+ # make sure these keys are set
46
+ [:twhere, :twitter].each do |key|
47
+ unless config[key]
48
+ $stderr.puts "could not find :#{key} in config"
49
+ exit 1
50
+ end
51
+ end
52
+
53
+ # make sure these keys are set
54
+ [:locations_file, :template_file].each do |key|
55
+ unless config[:twhere][key]
56
+ $stderr.puts "could not find :#{key} in config"
57
+ exit 1
58
+ end
59
+ end
60
+
61
+ # make sure these keys are set
62
+ [:username, :password].each do |key|
63
+ unless config[:twitter][key]
64
+ $stderr.puts "could not find :#{key} in config"
65
+ exit 1
66
+ end
67
+ end
68
+
31
69
  # load known locations
32
70
  locations = YAML::load(File.open(config[:twhere][:locations_file]))
33
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sarnesjo-twhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jesper S\xC3\xA4rnesj\xC3\xB6"