ayadn 3.0 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -4
  3. data/CHANGELOG.md +12 -4
  4. data/README.md +2 -5
  5. data/ayadn.gemspec +0 -2
  6. data/doc/01-index.md +0 -3
  7. data/doc/02-install.md +0 -4
  8. data/doc/06-post.md +0 -16
  9. data/doc/{18-contact.md → 16-contact.md} +0 -0
  10. data/doc/{19-examples.md → 17-examples.md} +0 -0
  11. data/doc/18-develop.md +165 -0
  12. data/lib/ayadn/action.rb +206 -396
  13. data/lib/ayadn/alias.rb +1 -1
  14. data/lib/ayadn/annotations.rb +15 -27
  15. data/lib/ayadn/api.rb +39 -28
  16. data/lib/ayadn/app.rb +19 -29
  17. data/lib/ayadn/authorize.rb +22 -13
  18. data/lib/ayadn/blacklist.rb +6 -19
  19. data/lib/ayadn/channel_object.rb +75 -0
  20. data/lib/ayadn/check.rb +19 -11
  21. data/lib/ayadn/cnx.rb +9 -15
  22. data/lib/ayadn/databases.rb +15 -27
  23. data/lib/ayadn/debug.rb +9 -9
  24. data/lib/ayadn/descriptions.rb +1 -99
  25. data/lib/ayadn/diagnostics.rb +16 -15
  26. data/lib/ayadn/endpoints.rb +18 -22
  27. data/lib/ayadn/errors.rb +1 -1
  28. data/lib/ayadn/fileops.rb +12 -12
  29. data/lib/ayadn/filtered_post_object.rb +11 -0
  30. data/lib/ayadn/ids.rb +0 -3
  31. data/lib/ayadn/logs.rb +4 -4
  32. data/lib/ayadn/mark.rb +34 -30
  33. data/lib/ayadn/nicerank.rb +7 -7
  34. data/lib/ayadn/nowplaying.rb +8 -22
  35. data/lib/ayadn/pinboard.rb +8 -12
  36. data/lib/ayadn/post.rb +18 -18
  37. data/lib/ayadn/post_object.rb +118 -0
  38. data/lib/ayadn/preferences_object.rb +290 -0
  39. data/lib/ayadn/profile.rb +2 -2
  40. data/lib/ayadn/scroll.rb +58 -67
  41. data/lib/ayadn/search.rb +22 -15
  42. data/lib/ayadn/set.rb +93 -83
  43. data/lib/ayadn/settings.rb +25 -33
  44. data/lib/ayadn/status.rb +24 -26
  45. data/lib/ayadn/stream.rb +68 -66
  46. data/lib/ayadn/stream_object.rb +56 -0
  47. data/lib/ayadn/switch.rb +2 -2
  48. data/lib/ayadn/user_object.rb +116 -0
  49. data/lib/ayadn/version.rb +1 -1
  50. data/lib/ayadn/view.rb +255 -278
  51. data/lib/ayadn/workers.rb +172 -174
  52. data/spec/integration/action_spec.rb +55 -34
  53. data/spec/mock/ayadn.sqlite +0 -0
  54. data/spec/unit/annotations_spec.rb +54 -41
  55. data/spec/unit/api_spec.rb +78 -7
  56. data/spec/unit/blacklistworkers_spec.rb +92 -20
  57. data/spec/unit/databases_spec.rb +117 -36
  58. data/spec/unit/endpoints_spec.rb +82 -10
  59. data/spec/unit/nicerank_spec.rb +56 -27
  60. data/spec/unit/post_spec.rb +94 -21
  61. data/spec/unit/set_spec.rb +141 -210
  62. data/spec/unit/view_spec.rb +105 -32
  63. data/spec/unit/workers_spec.rb +143 -52
  64. metadata +12 -37
  65. data/doc/16-movie.md +0 -39
  66. data/doc/17-tvshow.md +0 -46
  67. data/lib/ayadn/nowwatching.rb +0 -118
  68. data/lib/ayadn/tvshow.rb +0 -162
@@ -3,38 +3,123 @@ require 'helpers'
3
3
 
4
4
  describe Ayadn::Databases do
5
5
  before do
6
- Ayadn::Settings.stub(:options).and_return({
6
+ Ayadn::Settings.stub(:options).and_return(
7
+ Ayadn::Preferences.new(
8
+ {
9
+ timeline: {
10
+ directed: true,
11
+ source: true,
12
+ symbols: true,
13
+ name: true,
14
+ date: true,
15
+ debug: false,
16
+ compact: false
17
+ },
18
+ marker: {
19
+ messages: true
20
+ },
21
+ counts: {
22
+ default: 50,
23
+ unified: 50,
24
+ global: 50,
25
+ checkins: 50,
26
+ conversations: 50,
27
+ photos: 50,
28
+ trending: 50,
29
+ mentions: 50,
30
+ convo: 50,
31
+ posts: 50,
32
+ messages: 20,
33
+ search: 200,
34
+ whoreposted: 20,
35
+ whostarred: 20,
36
+ whatstarred: 100,
37
+ files: 50
38
+ },
39
+ formats: {
40
+ table: {
41
+ width: 75,
42
+ borders: true
43
+ },
44
+ list: {
45
+ reverse: true
46
+ }
47
+ },
48
+ channels: {
49
+ links: true
50
+ },
7
51
  colors: {
52
+ id: :blue,
53
+ index: :red,
54
+ username: :green,
55
+ name: :magenta,
56
+ date: :cyan,
57
+ link: :yellow,
58
+ dots: :blue,
8
59
  hashtags: :cyan,
9
60
  mentions: :red,
10
- username: :green,
61
+ source: :cyan,
62
+ symbols: :green,
63
+ unread: :cyan,
64
+ debug: :red,
11
65
  excerpt: :green
12
66
  },
13
- timeline: {compact: false},
14
- formats: {table: {width: 75}, list: {reverse: true}},
15
- blacklist: {active: true}
16
- })
17
- Ayadn::Settings.stub(:config).and_return({
18
- identity: {
19
- username: 'test',
20
- handle: '@test'
21
- },
22
- post_max_length: 256,
23
- message_max_length: 2048,
24
- version: 'wee',
25
- paths: {
26
- db: 'spec/mock/',
27
- log: 'spec/mock'
67
+ backup: {
68
+ posts: false,
69
+ messages: false,
70
+ lists: false
71
+ },
72
+ scroll: {
73
+ spinner: true,
74
+ timer: 3,
75
+ date: false
76
+ },
77
+ nicerank: {
78
+ threshold: 2.1,
79
+ filter: true,
80
+ unranked: false
81
+ },
82
+ nowplaying: {},
83
+ blacklist: {
84
+ active: true
85
+ }
86
+ }))
87
+ require 'json'
88
+ require 'ostruct'
89
+ obj =
90
+ {
91
+ identity: {
92
+ username: 'test',
93
+ handle: '@test'
94
+ },
95
+ post_max_length: 256,
96
+ message_max_length: 2048,
97
+ version: 'wee',
98
+ paths: {
99
+ db: 'spec/mock/',
100
+ log: 'spec/mock'
101
+ },
102
+ platform: 'shoes',
103
+ ruby: '0',
104
+ locale: 'gibberish'
28
105
  }
29
- })
30
- Ayadn::Settings.stub(:global).and_return({
106
+ Ayadn::Settings.stub(:config).and_return(
107
+ JSON.parse(obj.to_json, object_class: OpenStruct)
108
+ )
109
+ global_hash = {
31
110
  scrolling: false,
32
111
  force: false
33
- })
112
+ }
113
+ Ayadn::Settings.stub(:global).and_return(
114
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
115
+ )
34
116
  Ayadn::Logs.stub(:rec).and_return("logged")
35
117
  Dir.stub(:home).and_return("spec/mock")
36
118
  Ayadn::Databases.open_databases
37
119
  end
120
+
121
+ let(:data) { JSON.parse(File.read("spec/mock/stream.json")) }
122
+
38
123
  describe ".add_to_users_db" do
39
124
  it "adds a user" do
40
125
  Ayadn::Databases.add_to_users_db(33, 'test', 'Mr Test')
@@ -58,26 +143,22 @@ describe Ayadn::Databases do
58
143
  end
59
144
  describe ".save_max_id" do
60
145
  it "saves pagination" do
61
- stream = {'meta'=>{'max_id'=>'33666','marker'=>{'name'=>'test_stream'}}}
62
- Ayadn::Databases.save_max_id(stream)
63
- expect(Ayadn::Databases.all_pagination).to eq ['test_stream', 33666]
64
- expect(Ayadn::Databases.find_last_id_from('test_stream')).to eq 33666
65
-
66
- Ayadn::Databases.pagination_delete('test_stream')
67
-
68
- stream = {'meta'=>{'max_id'=>'12'}}
69
- Ayadn::Databases.save_max_id(stream, 'yolo')
70
- expect(Ayadn::Databases.all_pagination).to eq ['yolo', 12]
71
- expect(Ayadn::Databases.find_last_id_from('yolo')).to eq 12
146
+ stream_object = Ayadn::StreamObject.new(data)
147
+ Ayadn::Databases.save_max_id(stream_object)
148
+ expect(Ayadn::Databases.all_pagination).to eq ['unified', 23187443]
149
+ expect(Ayadn::Databases.find_last_id_from('unified')).to eq 23187443
150
+ Ayadn::Databases.pagination_delete('unified')
72
151
  end
73
152
  end
74
153
  describe ".has_new?" do
75
154
  it "check if new posts since last pagination record" do
76
- stream = {'meta'=>{'max_id'=>'33666','marker'=>{'name'=>'test_stream'}}}
77
- Ayadn::Databases.save_max_id(stream)
78
- expect(Ayadn::Databases.has_new?(stream, 'test_stream')).to eq false
79
- stream = {'meta'=>{'max_id'=>'42000000','marker'=>{'name'=>'test_stream'}}}
80
- expect(Ayadn::Databases.has_new?(stream, 'test_stream')).to eq true
155
+ stream_object = Ayadn::StreamObject.new(data)
156
+ Ayadn::Databases.save_max_id(stream_object)
157
+ expect(Ayadn::Databases.has_new?(stream_object, 'unified')).to eq false
158
+ temp = stream_object.input
159
+ temp['meta']['max_id'] = '42000000'
160
+ stream_object = Ayadn::StreamObject.new(temp)
161
+ expect(Ayadn::Databases.has_new?(stream_object, 'unified')).to eq true
81
162
  end
82
163
  end
83
164
  describe ".save_indexed_posts" do
@@ -3,22 +3,94 @@ require 'spec_helper'
3
3
  describe Ayadn::Endpoints do
4
4
  before do
5
5
  Ayadn::Settings.stub(:user_token).and_return('XXX')
6
- Ayadn::Settings.stub(:options).and_return({
6
+ Ayadn::Settings.stub(:options).and_return(
7
+ Ayadn::Preferences.new(
8
+ {
9
+ timeline: {
10
+ directed: true,
11
+ source: true,
12
+ symbols: true,
13
+ name: true,
14
+ date: true,
15
+ debug: false,
16
+ compact: false
17
+ },
18
+ marker: {
19
+ messages: true
20
+ },
7
21
  counts: {
8
- unified: 33,
9
22
  default: 100,
10
- conversations: 12
23
+ unified: 33,
24
+ global: 100,
25
+ checkins: 100,
26
+ conversations: 12,
27
+ photos: 100,
28
+ trending: 100,
29
+ mentions: 100,
30
+ convo: 100,
31
+ posts: 100,
32
+ messages: 20,
33
+ search: 200,
34
+ whoreposted: 20,
35
+ whostarred: 20,
36
+ whatstarred: 100,
37
+ files: 100
11
38
  },
12
- timeline: {
13
- directed: 1,
14
- html: 0,
15
- annotations: 1
39
+ formats: {
40
+ table: {
41
+ width: 75,
42
+ borders: true
43
+ },
44
+ list: {
45
+ reverse: true
46
+ }
47
+ },
48
+ channels: {
49
+ links: true
50
+ },
51
+ colors: {
52
+ id: :blue,
53
+ index: :red,
54
+ username: :green,
55
+ name: :magenta,
56
+ date: :cyan,
57
+ link: :yellow,
58
+ dots: :blue,
59
+ hashtags: :cyan,
60
+ mentions: :red,
61
+ source: :cyan,
62
+ symbols: :green,
63
+ unread: :cyan,
64
+ debug: :red,
65
+ excerpt: :green
66
+ },
67
+ backup: {
68
+ posts: false,
69
+ messages: false,
70
+ lists: false
71
+ },
72
+ scroll: {
73
+ spinner: true,
74
+ timer: 3,
75
+ date: false
76
+ },
77
+ nicerank: {
78
+ threshold: 2.1,
79
+ filter: true,
80
+ unranked: false
81
+ },
82
+ nowplaying: {},
83
+ blacklist: {
84
+ active: true
16
85
  }
17
- })
18
- Ayadn::Settings.stub(:global).and_return({
86
+ }))
87
+ global_hash = {
19
88
  scrolling: false,
20
89
  force: false
21
- })
90
+ }
91
+ Ayadn::Settings.stub(:global).and_return(
92
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
93
+ )
22
94
  end
23
95
  describe '#token_info' do
24
96
  it "returns the Token url" do
@@ -6,41 +6,50 @@ require 'json'
6
6
  describe Ayadn::NiceRank do
7
7
  before do
8
8
  Ayadn::Settings.stub(:options).and_return(
9
+ Ayadn::Preferences.new(
9
10
  {
10
11
  timeline: {
11
- directed: 1,
12
- html: 0,
13
- annotations: 1,
12
+ directed: true,
14
13
  source: true,
15
14
  symbols: true,
16
15
  name: true,
17
16
  date: true,
18
- spinner: true,
19
- debug: false
17
+ debug: false,
18
+ compact: false
19
+ },
20
+ marker: {
21
+ messages: true
20
22
  },
21
23
  counts: {
22
24
  default: 50,
23
- unified: 100,
24
- global: 100,
25
- checkins: 100,
25
+ unified: 50,
26
+ global: 50,
27
+ checkins: 50,
26
28
  conversations: 50,
27
29
  photos: 50,
28
- trending: 100,
29
- mentions: 100,
30
- convo: 100,
31
- posts: 100,
32
- messages: 50,
30
+ trending: 50,
31
+ mentions: 50,
32
+ convo: 50,
33
+ posts: 50,
34
+ messages: 20,
33
35
  search: 200,
34
- whoreposted: 50,
35
- whostarred: 50,
36
+ whoreposted: 20,
37
+ whostarred: 20,
36
38
  whatstarred: 100,
37
- files: 100
39
+ files: 50
38
40
  },
39
41
  formats: {
40
42
  table: {
41
- width: 75
43
+ width: 75,
44
+ borders: true
45
+ },
46
+ list: {
47
+ reverse: true
42
48
  }
43
49
  },
50
+ channels: {
51
+ links: true
52
+ },
44
53
  colors: {
45
54
  id: :blue,
46
55
  index: :red,
@@ -53,6 +62,7 @@ describe Ayadn::NiceRank do
53
62
  mentions: :red,
54
63
  source: :cyan,
55
64
  symbols: :green,
65
+ unread: :cyan,
56
66
  debug: :red,
57
67
  excerpt: :green
58
68
  },
@@ -62,7 +72,9 @@ describe Ayadn::NiceRank do
62
72
  lists: false
63
73
  },
64
74
  scroll: {
65
- timer: 3
75
+ spinner: true,
76
+ timer: 3,
77
+ date: false
66
78
  },
67
79
  nicerank: {
68
80
  threshold: 2.1,
@@ -70,23 +82,40 @@ describe Ayadn::NiceRank do
70
82
  unranked: false
71
83
  },
72
84
  nowplaying: {},
73
- movie: {
74
- hashtag: 'nowwatching'
75
- },
76
- tvshow: {
77
- hashtag: 'nowwatching'
85
+ blacklist: {
86
+ active: true
78
87
  }
79
- }
88
+ })
80
89
  )
81
- Ayadn::Settings.stub(:config).and_return({
90
+ require 'json'
91
+ require 'ostruct'
92
+ obj =
93
+ {
82
94
  identity: {
83
95
  username: 'test',
84
96
  handle: '@test'
85
97
  },
86
98
  post_max_length: 256,
87
99
  message_max_length: 2048,
88
- version: 'wee'
89
- })
100
+ version: 'wee',
101
+ paths: {
102
+ db: 'spec/mock/',
103
+ log: 'spec/mock'
104
+ },
105
+ platform: 'shoes',
106
+ ruby: '0',
107
+ locale: 'gibberish'
108
+ }
109
+ Ayadn::Settings.stub(:config).and_return(
110
+ JSON.parse(obj.to_json, object_class: OpenStruct)
111
+ )
112
+ global_hash = {
113
+ scrolling: false,
114
+ force: false
115
+ }
116
+ Ayadn::Settings.stub(:global).and_return(
117
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
118
+ )
90
119
  Ayadn::Settings.stub(:user_token).and_return('XYZ')
91
120
  Ayadn::Settings.stub(:check_for_accounts)
92
121
  Ayadn::Errors.stub(:warn).and_return("warned")
@@ -5,32 +5,91 @@ require 'json'
5
5
 
6
6
  describe Ayadn::Post do
7
7
  before do
8
- Ayadn::Settings.stub(:options).and_return({
8
+ Ayadn::Settings.stub(:options).and_return(
9
+ Ayadn::Preferences.new(
10
+ {
11
+ timeline: {
12
+ directed: true,
13
+ source: true,
14
+ symbols: true,
15
+ name: true,
16
+ date: true,
17
+ debug: false,
18
+ compact: false
19
+ },
20
+ marker: {
21
+ messages: true
22
+ },
23
+ counts: {
24
+ default: 50,
25
+ unified: 50,
26
+ global: 50,
27
+ checkins: 50,
28
+ conversations: 50,
29
+ photos: 50,
30
+ trending: 50,
31
+ mentions: 50,
32
+ convo: 50,
33
+ posts: 50,
34
+ messages: 20,
35
+ search: 200,
36
+ whoreposted: 20,
37
+ whostarred: 20,
38
+ whatstarred: 100,
39
+ files: 50
40
+ },
41
+ formats: {
42
+ table: {
43
+ width: 75,
44
+ borders: true
45
+ },
46
+ list: {
47
+ reverse: true
48
+ }
49
+ },
50
+ channels: {
51
+ links: true
52
+ },
9
53
  colors: {
54
+ id: :blue,
55
+ index: :red,
56
+ username: :green,
57
+ name: :magenta,
58
+ date: :cyan,
59
+ link: :yellow,
60
+ dots: :blue,
10
61
  hashtags: :cyan,
11
62
  mentions: :red,
12
- username: :green,
13
- id: :blue,
14
- name: :yellow,
15
- source: :blue,
63
+ source: :cyan,
16
64
  symbols: :green,
17
- index: :blue,
18
- date: :cyan,
19
- link: :magenta,
65
+ unread: :cyan,
66
+ debug: :red,
20
67
  excerpt: :green
21
68
  },
22
- timeline: {
23
- name: true,
24
- date: true,
25
- symbols: true,
26
- source: true
69
+ backup: {
70
+ posts: false,
71
+ messages: false,
72
+ lists: false
27
73
  },
28
- formats: {table: {width: 75}},
29
- counts: {
30
- default: 33
74
+ scroll: {
75
+ spinner: true,
76
+ timer: 3,
77
+ date: false
78
+ },
79
+ nicerank: {
80
+ threshold: 2.1,
81
+ filter: true,
82
+ unranked: false
83
+ },
84
+ nowplaying: {},
85
+ blacklist: {
86
+ active: true
31
87
  }
32
- })
33
- Ayadn::Settings.stub(:config).and_return({
88
+ }))
89
+ require 'json'
90
+ require 'ostruct'
91
+ obj =
92
+ {
34
93
  identity: {
35
94
  username: 'test',
36
95
  handle: '@test'
@@ -38,10 +97,24 @@ describe Ayadn::Post do
38
97
  post_max_length: 256,
39
98
  message_max_length: 2048,
40
99
  version: 'wee',
100
+ paths: {
101
+ db: 'spec/mock/',
102
+ log: 'spec/mock'
103
+ },
104
+ platform: 'shoes',
41
105
  ruby: '0',
42
- locale: 'gibberish',
43
- platform: 'shoes'
44
- })
106
+ locale: 'gibberish'
107
+ }
108
+ Ayadn::Settings.stub(:config).and_return(
109
+ JSON.parse(obj.to_json, object_class: OpenStruct)
110
+ )
111
+ global_hash = {
112
+ scrolling: false,
113
+ force: false
114
+ }
115
+ Ayadn::Settings.stub(:global).and_return(
116
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
117
+ )
45
118
  Ayadn::Settings.stub(:user_token).and_return('XYZ')
46
119
  Ayadn::Settings.stub(:check_for_accounts)
47
120
  Ayadn::Errors.stub(:warn).and_return("warned")