yammer-cli 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/yammer-cli.rb +30 -10
  2. data/yammer-cli.gemspec +1 -1
  3. metadata +2 -2
@@ -7,20 +7,18 @@ require 'yaml'
7
7
 
8
8
  class YammerCli
9
9
 
10
- #attr_accessor :yammer
11
-
12
10
  def self.new
13
11
  super
14
12
  end
15
13
 
16
14
  def initialize
17
15
 
18
- settings_path = File.dirname(__FILE__) + '/config.yml'
16
+ @config_file_path = File.dirname(__FILE__) + '/config.yml'
17
+ @required_settings = [:consumer_token, :consumer_secret, :oauth_token, :oauth_secret]
19
18
 
20
- if File.exists?(settings_path)
21
- settings = YAML::load(File.open(settings_path))
19
+ if valid_config?
20
+ settings = YAML::load(File.open(@config_file_path))
22
21
  else
23
- puts "Settings not found. Run yammer with --setup (-s) option."
24
22
  exit
25
23
  end
26
24
 
@@ -63,7 +61,7 @@ class YammerCli
63
61
  current_date = date
64
62
  end
65
63
 
66
- puts user.foreground(:red) + " at " + created_at.strftime("%I:%M%p").foreground(:blue) + " " + body
64
+ puts user.foreground(:red) + " at " + created_at.to_time.getlocal.strftime("%I:%M%p").foreground(:blue) + " " + body
67
65
  end
68
66
  end
69
67
 
@@ -83,9 +81,8 @@ class YammerCli
83
81
 
84
82
  tokens = {:oauth_token => access_token.token, :oauth_secret => access_token.secret, :consumer_token => consumer_token, :consumer_secret => consumer_secret}
85
83
 
86
- settings_path = File.dirname(__FILE__) + '/config.yml'
87
-
88
- File.open(settings_path, "w") do |f|
84
+ config_file_path = File.dirname(__FILE__) + '/config.yml'
85
+ File.open(config_file_path, "w") do |f|
89
86
  f.write tokens.to_yaml
90
87
  end
91
88
 
@@ -93,6 +90,29 @@ class YammerCli
93
90
 
94
91
  end
95
92
 
93
+ def valid_config?
94
+
95
+ valid_config = true
96
+ if File.exists?(@config_file_path)
97
+ settings = YAML::load(File.open(@config_file_path))
98
+ @required_settings.each do |required_setting|
99
+ if settings[required_setting] == nil
100
+ valid_config = false
101
+ end
102
+ end
103
+ else
104
+ valid_config = false
105
+ end
106
+
107
+ if !valid_config
108
+ puts "Settings not valid. Run yammer with --setup (-s) option with your yammer Consumer Token and Consumer Secret."
109
+ puts "If you have not registered the app you can do so here https://developer.yammer.com/introduction/"
110
+ puts "to receive your Consumer Token and Consumer Secret."
111
+ end
112
+
113
+ valid_config
114
+
115
+ end
96
116
 
97
117
  #search users for user with specific id and return that user
98
118
  def get_user(users, id)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "yammer-cli"
3
- gem.version = "0.2.3"
3
+ gem.version = "0.2.4"
4
4
  gem.authors = ["Joe Wright"]
5
5
  gem.email = ["joe.wright@noventech.com"]
6
6
  gem.description = "A yammer command line client."
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: yammer-cli
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joe Wright
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-04-30 00:00:00 Z
13
+ date: 2013-05-23 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yammer