idobata 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: 985790bdacbb0f117570e37449886e257a6b26f4
4
- data.tar.gz: fbd07bda386268f878bd62cd779df2501cff7a46
3
+ metadata.gz: 08557b7ab233ed5fd457979d3ee5c4c26d0207fe
4
+ data.tar.gz: 40d3b3d76d085fbcb402fb755d559ce6654a4ede
5
5
  SHA512:
6
- metadata.gz: 610ea0f941218635f90e51f49809f5c22f8e3f2ee159010d792ae5f140dbcac713fe5bbf4814b2f5ef8307e83cdf1799c920a0d0a9a3cad51283c5ebbfd9bcac
7
- data.tar.gz: 88de3d45a0d8248d49f6a616af540521c477d83759d9626a6c805b8e6821cbd478d2d657b8540db1a806d4ca08c8d538fd79326f3e56314ccd506b14147f9df6
6
+ metadata.gz: f60b134327dabcf2bf18d9879a32bcfd8ec9e1b6131ecb1eba33101b53b50cbd90c9bb63c8dfc5824dd32a8d8b0b0c5782472058f356b8f21f84b80024471125
7
+ data.tar.gz: 0717c5d6d56f2ebaadbfe45c1e0a306e323435bd3876791f6a82de501dc929b0075ffd52fad440bd710de62d00a75356e1f232d2cb2b5a8178af73e0c772d810
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format d
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
  require 'idobata'
23
23
 
24
24
  # set hook url
25
- Idobata.hooK_url = "https://idobata.io/hook/XXXXX"
25
+ Idobata.hook_url = "https://idobata.io/hook/XXXXX"
26
26
 
27
27
  # plain text
28
28
  Idobata::Message.create(source: "Hello, Idobata!")
data/idobata.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["hzw1258@gmail.com"]
11
11
  spec.description = %q{idobata is content free chat}
12
12
  spec.summary = %q{Ruby bindings of Idobata}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/asonas/idobata-ruby"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.14.0"
25
26
  end
@@ -1,7 +1,18 @@
1
1
  module Idobata
2
2
  class Message
3
3
  def self.create(params = {})
4
+ params = self.label_writer(params)
4
5
  Idobata.client.post(params)
5
6
  end
7
+
8
+ def self.label_writer(params)
9
+ label = params[:label]
10
+ if label
11
+ type = label[:type] ? "label-#{label[:type]}" : ""
12
+ params[:source] = "<span class='label #{type}'>#{label[:text]}</span> #{params[:source]}"
13
+ params[:format] = :html unless params[:format] == :html
14
+ end
15
+ params
16
+ end
6
17
  end
7
18
  end
@@ -1,3 +1,3 @@
1
1
  module Idobata
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'elasticsearch'
2
+ require 'json'
3
+ es = Elasticsearch::Client.new(hosts: "localhost:9200")
4
+
5
+ messages = JSON.parse(`curl 'https://idobata.io/api/messages?room_id=696' -H "X-API-Token: 748528b4eaa7ad402c01affa027c8263"`)['messages']
6
+
7
+ #puts messages?
8
+ messages.each do |message|
9
+ if message['sender_type'] == "User"
10
+ es.index index: "idobata-tmix", type: "idodobata-messages", body: {
11
+ id: message['id'],
12
+ sender_name: message['sender_name'],
13
+ body: message['body'],
14
+ images_urls: message['images_urls'],
15
+ created_at: message['created_at']
16
+ }
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Idobata::Message do
4
+ describe ".label_writer" do
5
+ context "when do not specify :label" do
6
+ let(:params) {
7
+ {
8
+ source: "hello idobata",
9
+ format: :html
10
+ }
11
+ }
12
+ subject(:formatting_params) { Idobata::Message.label_writer(params) }
13
+ it "should not change params" do
14
+ expect(formatting_params).to eq(params)
15
+ end
16
+ end
17
+
18
+ context "when spicify label" do
19
+ let(:params) {
20
+ {
21
+ source: "hello idobata",
22
+ format: :html,
23
+ label: { type: :success, text: "DEPLOY" }
24
+ }
25
+ }
26
+ subject(:formatting_params) { Idobata::Message.label_writer(params) }
27
+ it "should include span tag" do
28
+ expect(formatting_params[:source]).to match("<span class='label label-success'>DEPLOY</span>")
29
+ end
30
+ end
31
+
32
+ context "when spicify label and exclude format key" do
33
+ let(:params) {
34
+ {
35
+ source: "hello idobata",
36
+ label: { type: :success, text: "DEPLOY" }
37
+ }
38
+ }
39
+ subject(:formatting_params) { Idobata::Message.label_writer(params) }
40
+ it "should include html" do
41
+ expect(formatting_params[:source]).to match("<span class='label label-success'>DEPLOY</span>")
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,2 @@
1
+ require 'idobata'
2
+ $: << File.expand_path(File.join(*%w{.. .. lib}), __FILE__)
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idobata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - asonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.8.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.8.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.0
55
69
  description: idobata is content free chat
56
70
  email:
57
71
  - hzw1258@gmail.com
@@ -59,7 +73,8 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
- - .gitignore
76
+ - ".gitignore"
77
+ - ".rspec"
63
78
  - Gemfile
64
79
  - LICENSE.txt
65
80
  - README.md
@@ -68,9 +83,11 @@ files:
68
83
  - lib/idobata.rb
69
84
  - lib/idobata/client.rb
70
85
  - lib/idobata/message.rb
71
- - lib/idobata/support.rb
72
86
  - lib/idobata/version.rb
73
- homepage: ''
87
+ - sample/idobata2es.rb
88
+ - spec/lib/idobata/message_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: https://github.com/asonas/idobata-ruby
74
91
  licenses:
75
92
  - MIT
76
93
  metadata: {}
@@ -80,19 +97,21 @@ require_paths:
80
97
  - lib
81
98
  required_ruby_version: !ruby/object:Gem::Requirement
82
99
  requirements:
83
- - - '>='
100
+ - - ">="
84
101
  - !ruby/object:Gem::Version
85
102
  version: '0'
86
103
  required_rubygems_version: !ruby/object:Gem::Requirement
87
104
  requirements:
88
- - - '>='
105
+ - - ">="
89
106
  - !ruby/object:Gem::Version
90
107
  version: '0'
91
108
  requirements: []
92
109
  rubyforge_project:
93
- rubygems_version: 2.0.14
110
+ rubygems_version: 2.2.0
94
111
  signing_key:
95
112
  specification_version: 4
96
113
  summary: Ruby bindings of Idobata
97
- test_files: []
114
+ test_files:
115
+ - spec/lib/idobata/message_spec.rb
116
+ - spec/spec_helper.rb
98
117
  has_rdoc:
@@ -1,9 +0,0 @@
1
- module Idobata
2
- class Support
3
- def self.deploy_notification(user_name: "anonymous", application_name: "", revision_url: "", revision: "")
4
- source = "[DEPLOY] #{user_name} deployed a new version of #{application_name}"
5
- source += " (deployed revision: <a href=#{revision_url} target='_blank'>#{revision[0..8]}</a>)" unless revision.empty?
6
- Idobata.client.post(format: :html, source: source)
7
- end
8
- end
9
- end