ayadn 1.0.4 → 1.0.5

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: 00656e4af8c792c9b5230d9da9bb4bc64513da1a
4
- data.tar.gz: 458d524340d6dbd9fc7fc6f9bf705f32777baa71
3
+ metadata.gz: 4887bcdeae96ce84899aa3ebaf4da316c0113b43
4
+ data.tar.gz: abfa9e72b28407bc4fbf358638a6f799b63be5ab
5
5
  SHA512:
6
- metadata.gz: 74744be16e5315052c51407642389e27d045667067270402359d6b081aafd4fd8567ef2f636a17d1b4837d4331181b2c2f4f0b7599179f23b7246e736f160907
7
- data.tar.gz: ffcc6b1211f8666f99d4b7bd6a911d08909a75ad4bd81a8209817225354251bc897e37d9a146b330fafecc7b8a7c1c35ab2f3acfa3b498363f9d820791b114cd
6
+ metadata.gz: 06e1c4314efd90a6ad3085ee89b229596922ebe3da3181ed018bdd419721ac82f3c693694493b10e4ff68c374e7647f5dc2b9ca6f9833d61f1f2c88fe98c164f
7
+ data.tar.gz: 8faf6206ac2a723787faea00a91c043d18f38946b475f31c0aa85a7be96c38b3fef1df7ed7c8ee1db1dd52eb777c6a2687e30a5e2a8febc7acddedd5684b1eaf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.5
2
+
3
+ - Fixed the colorization for mentions
4
+ - Added tests for colorization
5
+
1
6
  # 1.0.4
2
7
 
3
8
  - Fixed 'reply to an indexed stream' for Ruby < 2.1
data/lib/ayadn/scroll.rb CHANGED
@@ -36,7 +36,7 @@ module Ayadn
36
36
  if Databases.has_new?(stream, 'unified')
37
37
  show(stream, options)
38
38
  end
39
- unless stream['meta']['max_id'].nil?
39
+ unless stream['meta']['max_id'].nil? #check if there isn't lost posts
40
40
  Databases.save_max_id(stream)
41
41
  options = options_hash(stream)
42
42
  end
data/lib/ayadn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
data/lib/ayadn/workers.rb CHANGED
@@ -276,8 +276,6 @@ module Ayadn
276
276
  users_hash
277
277
  end
278
278
 
279
- private
280
-
281
279
  def colorize_text(text, mentions)
282
280
  handles = Array.new
283
281
  mentions.each {|username| handles << "@#{username}"}
@@ -290,7 +288,14 @@ module Ayadn
290
288
  if word =~ /#\w+/
291
289
  words << word.gsub(/#([A-Za-z0-9_]{1,255})(?![\w+])/, '#\1'.color(hashtag_color))
292
290
  elsif word =~ /@\w+/
293
- if handles.include?(word) || word =~ /@\w+[:]/
291
+ splitted = word.split(/[:\-;,?!'&`^=+<>*%()]/) if word =~ /[:\-;,?!'&`^=+<>*%()]/
292
+ if splitted
293
+ splitted.each {|d| @str = d if d =~ /@\w+/}
294
+ @str = word if @str.nil?
295
+ else
296
+ @str = word
297
+ end
298
+ if handles.include?(@str.downcase)
294
299
  words << word.gsub(/@([A-Za-z0-9_]{1,20})(?![\w+])/, '@\1'.color(mention_color))
295
300
  else
296
301
  words << word
@@ -305,6 +310,8 @@ module Ayadn
305
310
  sentences.join("\n")
306
311
  end
307
312
 
313
+ private
314
+
308
315
  def init_table
309
316
  Terminal::Table.new do |t|
310
317
  t.style = { :width => Settings.options[:formats][:table][:width] }
@@ -0,0 +1,188 @@
1
+ {
2
+ "meta": {
3
+ "code": 200
4
+ },
5
+ "data": {
6
+ "created_at": "2014-04-07T20:13:45Z",
7
+ "num_stars": 0,
8
+ "num_replies": 0,
9
+ "entities": {
10
+ "mentions": [
11
+ {
12
+ "pos": 13,
13
+ "id": "185581",
14
+ "len": 10,
15
+ "name": "aya_tests"
16
+ },
17
+ {
18
+ "pos": 34,
19
+ "id": "185581",
20
+ "len": 10,
21
+ "name": "aya_tests"
22
+ },
23
+ {
24
+ "pos": 52,
25
+ "id": "185581",
26
+ "len": 10,
27
+ "name": "aya_tests"
28
+ },
29
+ {
30
+ "pos": 113,
31
+ "id": "185581",
32
+ "len": 10,
33
+ "name": "aya_tests"
34
+ },
35
+ {
36
+ "pos": 141,
37
+ "id": "185581",
38
+ "len": 10,
39
+ "name": "aya_tests"
40
+ }
41
+ ],
42
+ "hashtags": [
43
+ {
44
+ "name": "test",
45
+ "len": 5,
46
+ "pos": 0
47
+ },
48
+ {
49
+ "name": "regex",
50
+ "len": 6,
51
+ "pos": 6
52
+ },
53
+ {
54
+ "name": "true",
55
+ "len": 5,
56
+ "pos": 26
57
+ },
58
+ {
59
+ "name": "true",
60
+ "len": 5,
61
+ "pos": 46
62
+ },
63
+ {
64
+ "name": "true",
65
+ "len": 5,
66
+ "pos": 63
67
+ },
68
+ {
69
+ "name": "false",
70
+ "len": 6,
71
+ "pos": 79
72
+ },
73
+ {
74
+ "name": "false",
75
+ "len": 6,
76
+ "pos": 105
77
+ },
78
+ {
79
+ "name": "true",
80
+ "len": 5,
81
+ "pos": 130
82
+ },
83
+ {
84
+ "name": "true",
85
+ "len": 5,
86
+ "pos": 156
87
+ }
88
+ ],
89
+ "links": [
90
+
91
+ ]
92
+ },
93
+ "text": "#test #regex\n@aya_tests's #true \n(@aya_tests) #true\n@AyA_TeSts #true\n@aya_test #false\naya@aya_tests.yolo #false\n-@aya_tests:ohai! #true\ntext,@aya_tests,txt #true",
94
+ "num_reposts": 0,
95
+ "canonical_url": "https://alpha.app.net/aya_tests/post/27981025",
96
+ "source": {
97
+ "link": "http://www.ayadn-app.net",
98
+ "name": "Ayadn",
99
+ "client_id": "hFsCGArAjgJkYBHTHbZnUvzTmL4vaLHL"
100
+ },
101
+ "machine_only": false,
102
+ "user": {
103
+ "username": "aya_tests",
104
+ "avatar_image": {
105
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/5/wtcnGHTyeGX988iObjlCFHdHEM17InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDcvMDEvODAvMDcwMTgwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0",
106
+ "width": 322,
107
+ "is_default": false,
108
+ "height": 322
109
+ },
110
+ "description": {
111
+ "text": "Experimental account for running tests.",
112
+ "entities": {
113
+ "mentions": [
114
+
115
+ ],
116
+ "hashtags": [
117
+
118
+ ],
119
+ "links": [
120
+
121
+ ]
122
+ }
123
+ },
124
+ "locale": "fr_FR",
125
+ "created_at": "2013-11-02T17:06:51Z",
126
+ "id": "185581",
127
+ "canonical_url": "https://alpha.app.net/aya_tests",
128
+ "cover_image": {
129
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/5/kZ-JRmTbmd3WVPswTJ8Nwxzkf917InMiOiJzMyIsImIiOiJ0YXBwLWFzc2V0cyIsImsiOiJpL1UvaS9ZL1VpWW5xRFNvTUtyTEhLNXA0OHN2NkxmTmRVMC5qcGciLCJvIjoiIn0",
130
+ "width": 960,
131
+ "is_default": true,
132
+ "height": 260
133
+ },
134
+ "timezone": "Europe/Berlin",
135
+ "counts": {
136
+ "following": 15,
137
+ "posts": 758,
138
+ "followers": 13,
139
+ "stars": 5
140
+ },
141
+ "type": "human",
142
+ "annotations": [
143
+ {
144
+ "type": "net.chimpli.media",
145
+ "value": {
146
+ "image": "29487",
147
+ "audio": "29489",
148
+ "video": "29488"
149
+ }
150
+ }
151
+ ],
152
+ "name": "@ericd's tests account"
153
+ },
154
+ "you_reposted": false,
155
+ "id": "27981025",
156
+ "you_starred": false,
157
+ "thread_id": "27981025",
158
+ "annotations": [
159
+ {
160
+ "type": "com.ayadn.user",
161
+ "value": {
162
+ "username": "aya_tests",
163
+ "avatar_image": {
164
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/5/wtcnGHTyeGX988iObjlCFHdHEM17InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDcvMDEvODAvMDcwMTgwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0",
165
+ "width": 322,
166
+ "is_default": false,
167
+ "height": 322
168
+ },
169
+ "id": "185581",
170
+ "name": "@ericd's tests account"
171
+ }
172
+ },
173
+ {
174
+ "type": "com.ayadn.client",
175
+ "value": {
176
+ "url": "http://ayadn-app.net",
177
+ "version": "1.0.4",
178
+ "author": {
179
+ "username": "ericd",
180
+ "email": "eric@aya.io",
181
+ "id": "69904",
182
+ "name": "Eric Dejonckheere"
183
+ }
184
+ }
185
+ }
186
+ ]
187
+ }
188
+ }
@@ -21,6 +21,7 @@ describe Ayadn::Workers do
21
21
 
22
22
  let(:data) { JSON.parse(File.read("spec/mock/stream.json")) }
23
23
  let(:checkins) { JSON.parse(File.read("spec/mock/checkins.json")) }
24
+ let(:regex_post) { JSON.parse(File.read("spec/mock/regex.json")) }
24
25
 
25
26
  describe "#build_posts" do
26
27
  it "builds posts hash from stream" do
@@ -144,4 +145,12 @@ describe Ayadn::Workers do
144
145
  end
145
146
  end
146
147
 
148
+ describe "#colorize_text" do
149
+ it "colorizes mentions and hashtags" do
150
+ text = regex_post['data']['text']
151
+ mentions = regex_post['data']['entities']['mentions']
152
+ expect(Ayadn::Workers.new.colorize_text(text, mentions)).to eq "\e[36m#test\e[0m \e[36m#regex\e[0m\n@aya_tests's \e[36m#true\e[0m\n(@aya_tests) \e[36m#true\e[0m\n@AyA_TeSts \e[36m#true\e[0m\n@aya_test \e[36m#false\e[0m\naya@aya_tests.yolo \e[36m#false\e[0m\n-@aya_tests:ohai! \e[36m#true\e[0m\ntext,@aya_tests,txt \e[36m#true\e[0m"
153
+ end
154
+ end
155
+
147
156
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayadn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-06 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -234,6 +234,7 @@ files:
234
234
  - spec/mock/index.db
235
235
  - spec/mock/pagination.db
236
236
  - spec/mock/posted.json
237
+ - spec/mock/regex.json
237
238
  - spec/mock/stream.json
238
239
  - spec/mock/users.db
239
240
  - spec/spec_helper.rb
@@ -282,6 +283,7 @@ test_files:
282
283
  - spec/mock/index.db
283
284
  - spec/mock/pagination.db
284
285
  - spec/mock/posted.json
286
+ - spec/mock/regex.json
285
287
  - spec/mock/stream.json
286
288
  - spec/mock/users.db
287
289
  - spec/spec_helper.rb