m_and_m 0.0.5 → 0.0.6
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 +4 -4
- data/lib/m_and_m/cli.rb +26 -4
- data/lib/m_and_m/preferences.rb +1 -1
- data/lib/m_and_m/server.rb +21 -5
- data/lib/m_and_m/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c9985bbdbe5ada5160ec014ad84d0e89b5373a
|
4
|
+
data.tar.gz: c4bbcfe308d991b2559f8158f64a9b964e965394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b763e10366a437628efe96a6b7d8b7b60ae3025ae6b5b1a2d0d8e1dc8c6c54343ca4c16496793b7e48e7b0b289e952db09dd4fa5614b86602c89f7d9d95f285
|
7
|
+
data.tar.gz: 48ad4d1ec4c7db4175f3b7553de3c7493e9c8aa3c7508d96273093a7278cbd67e7ddc6ea8923aad128eb3c11d5aab3d0f94dec7fda2c024a613009087cbc12a5
|
data/lib/m_and_m/cli.rb
CHANGED
@@ -10,14 +10,28 @@ class MAndM::Cli
|
|
10
10
|
@preferences = MAndM::Preferences.new '.m_and_m'
|
11
11
|
end
|
12
12
|
|
13
|
-
def execute
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def execute *args
|
14
|
+
command = args.shift
|
15
|
+
command = :list unless command
|
16
|
+
send command, *args
|
17
|
+
end
|
18
|
+
|
19
|
+
def list
|
20
|
+
server.messages.each do |message|
|
17
21
|
puts "#{c :yellow, time(message["at"])} #{c :magenta, message["from"]} said #{c :green, message["message"]}"
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
25
|
+
def say who, message_id
|
26
|
+
server.say uuid_for(who), message_id
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def server
|
32
|
+
MAndM::Server.new url, preferences
|
33
|
+
end
|
34
|
+
|
21
35
|
def time at
|
22
36
|
Time.at(at).strftime("%d/%b %H:%M:%S")
|
23
37
|
end
|
@@ -25,4 +39,12 @@ class MAndM::Cli
|
|
25
39
|
def c colour, text
|
26
40
|
text.to_s.foreground colour
|
27
41
|
end
|
42
|
+
|
43
|
+
def uuid_for name
|
44
|
+
preferences.ask "#{name}_uuid".to_sym, "What is the uuid for #{name}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def url
|
48
|
+
preferences.ask :url, 'What is the server url'
|
49
|
+
end
|
28
50
|
end
|
data/lib/m_and_m/preferences.rb
CHANGED
data/lib/m_and_m/server.rb
CHANGED
@@ -3,12 +3,32 @@ require 'httparty'
|
|
3
3
|
MAndM::Server = Struct.new :base_url, :preferences
|
4
4
|
|
5
5
|
class MAndM::Server
|
6
|
+
def messages
|
7
|
+
HTTParty.get message_url
|
8
|
+
end
|
9
|
+
|
10
|
+
def say to_uuid, message_id
|
11
|
+
HTTParty.post base_url,
|
12
|
+
body: message_body(to_uuid, message_id),
|
13
|
+
headers: headers
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def message_body to_uuid, message_id
|
19
|
+
{uuid: token, to_uuid: to_uuid, message_id: message_id}
|
20
|
+
end
|
21
|
+
|
22
|
+
def headers
|
23
|
+
{'ContentType' => 'application/json'}
|
24
|
+
end
|
25
|
+
|
6
26
|
def last_message_id
|
7
27
|
preferences[:last_message_id]
|
8
28
|
end
|
9
29
|
|
10
30
|
def token
|
11
|
-
preferences
|
31
|
+
preferences.ask :token, 'What is the authentication token'
|
12
32
|
end
|
13
33
|
|
14
34
|
def authenticated_base_url
|
@@ -18,8 +38,4 @@ class MAndM::Server
|
|
18
38
|
def message_url
|
19
39
|
last_message_id ? "#{authenticated_base_url}&id=#{last_message_id}" : authenticated_base_url
|
20
40
|
end
|
21
|
-
|
22
|
-
def messages
|
23
|
-
HTTParty.get message_url
|
24
|
-
end
|
25
41
|
end
|
data/lib/m_and_m/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m_and_m
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lionel Randall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|