action_messenger 0.0.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e68141ddc28dac3e57f44f223afefd22cc218c50d277c5e86c9d873688e5f99c
4
- data.tar.gz: 46361436e3ca93434bb8ac04bb4c842725cff380c551cba355b1ce9628390ba3
3
+ metadata.gz: 5d5a6a977ceab4f388b9a4e196e3744976adec18fa7b26dad0285a5ec75f9f91
4
+ data.tar.gz: 1f6d8c6c48cb4738555b590ce1917024d3e364285fb9267548d798c5681b6bb5
5
5
  SHA512:
6
- metadata.gz: 143fdc0b65b241180799d93129a573c0f75b0dd84efb75ee0c7795a9e18afc6ef215e262d9dab6966aa6d5e73ddb4fa49d66f1736148826d3648cc37392ee031
7
- data.tar.gz: 0677d9696b83d39bc80ef752faf56bf5e8e6c444d6fd89128e037d3243b1c0ef41d29c0837b1208747db5adb0b776beb17bd3d5b743be82bb6a9cf85a6b97992
6
+ metadata.gz: 747754bd8611f48faa537f6f63638a9405dc4ac370848cbb76e3795e09fab2f4127ba399c6a231ec2609da907993553fc4d91d99c57d06bb08d4545f098856a2
7
+ data.tar.gz: 95c36f648c031dc8d7be88fee706d93e30c3d3cec5b5641844b7986c33a1c13186942093245ce4cd635cc82b5face6e0cdf7131c356162aaac83bfc6749c2e1b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_messenger (0.0.2)
4
+ action_messenger (0.1.1)
5
5
  actionpack
6
6
  actionview
7
7
  activejob
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Framework for delivering messages to Messenger. Currently only slack is supported.
4
4
 
5
- :warning: **This is highly experimental project. Current version is 0.0.1**
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -95,6 +93,20 @@ upload_file_to_slack(channels: '#general',file: Faraday::UploadIO.new('/path/to/
95
93
  # -> https://api.slack.com/methods/files.upload
96
94
  ```
97
95
 
96
+ ## Get delivery logs
97
+
98
+ ```rb
99
+ class AccouyntMessenger < ApplicationMessenger
100
+ def notify
101
+ message_to_slack(channel: '#sample', options: {text: 'hoge'})
102
+ end
103
+ end
104
+ message_delivery = AccountMessenger.notify
105
+ notify.deliver_now!
106
+ p message_delivery.messenger.deliveries
107
+ # => [#<struct ActionMessenger::Base::DeliveryLog method=:message_to_slack, channels="#sample", result=#<Slack::Messages::Message channel="xxxxx" message=#<Slack::Messages::Message bot_id="xxxxx" subtype="bot_message" text="hoge" ts="xxxxx" type="message" username="Slack API Tester"> ok=true ts="xxxxx">>]
108
+ ```
109
+
98
110
  ## Development
99
111
 
100
112
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -32,8 +32,13 @@ module ActionMessenger
32
32
 
33
33
  end # end class << self
34
34
 
35
+ attr_reader :caller_method_name, :deliveries
35
36
 
36
- attr_reader :caller_method_name
37
+ DeliveryLog = Struct.new(:method, :channels, :result)
38
+
39
+ def initialize
40
+ @deliveries = []
41
+ end
37
42
 
38
43
  # message to slack
39
44
  #
@@ -51,6 +56,8 @@ module ActionMessenger
51
56
  message = slack_client.message(channel, options)
52
57
  end
53
58
  message
59
+ ensure
60
+ self.deliveries << DeliveryLog.new(__method__, channel, message)
54
61
  end
55
62
 
56
63
  # upload file to slack
@@ -66,6 +73,8 @@ module ActionMessenger
66
73
  upload_file = slack_client.upload_file(channels, file, options)
67
74
  end
68
75
  upload_file
76
+ ensure
77
+ self.deliveries << DeliveryLog.new(__method__, channels, upload_file)
69
78
  end
70
79
 
71
80
 
@@ -1,3 +1,3 @@
1
1
  module ActionMessenger
2
- VERSION = "0.0.2"
3
- end
2
+ VERSION = "0.1.1"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_messenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - h1kita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler