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
@@ -11,43 +11,53 @@ module Ayadn
11
11
  end
12
12
 
13
13
  describe Ayadn::Action do
14
+
14
15
  before do
15
16
  Ayadn::Settings.stub(:options).and_return(
17
+ Ayadn::Preferences.new(
16
18
  {
17
19
  timeline: {
18
- directed: 1,
19
- html: 0,
20
+ directed: true,
20
21
  source: true,
21
22
  symbols: true,
22
23
  name: true,
23
24
  date: true,
24
- spinner: true,
25
25
  debug: false,
26
26
  compact: false
27
27
  },
28
+ marker: {
29
+ messages: true
30
+ },
28
31
  counts: {
29
- default: 50,
30
- unified: 100,
32
+ default: 100,
33
+ unified: 33,
31
34
  global: 100,
32
35
  checkins: 100,
33
- conversations: 50,
34
- photos: 50,
36
+ conversations: 100,
37
+ photos: 100,
35
38
  trending: 100,
36
39
  mentions: 100,
37
40
  convo: 100,
38
41
  posts: 100,
39
- messages: 50,
42
+ messages: 20,
40
43
  search: 200,
41
- whoreposted: 50,
42
- whostarred: 50,
44
+ whoreposted: 20,
45
+ whostarred: 20,
43
46
  whatstarred: 100,
44
47
  files: 100
45
48
  },
46
49
  formats: {
47
50
  table: {
48
- width: 75
51
+ width: 75,
52
+ borders: true
53
+ },
54
+ list: {
55
+ reverse: true
49
56
  }
50
57
  },
58
+ channels: {
59
+ links: true
60
+ },
51
61
  colors: {
52
62
  id: :blue,
53
63
  index: :red,
@@ -60,6 +70,7 @@ describe Ayadn::Action do
60
70
  mentions: :red,
61
71
  source: :cyan,
62
72
  symbols: :green,
73
+ unread: :cyan,
63
74
  debug: :red,
64
75
  excerpt: :green
65
76
  },
@@ -69,41 +80,49 @@ describe Ayadn::Action do
69
80
  lists: false
70
81
  },
71
82
  scroll: {
72
- timer: 3
83
+ spinner: true,
84
+ timer: 3,
85
+ date: false
73
86
  },
74
87
  nicerank: {
75
88
  threshold: 2.1,
76
- filter: false,
89
+ filter: true,
77
90
  unranked: false
78
91
  },
79
92
  nowplaying: {},
80
- movie: {
81
- hashtag: 'nowwatching'
82
- },
83
- tvshow: {
84
- hashtag: 'nowwatching'
85
- },
86
93
  blacklist: {
87
94
  active: true
88
95
  }
89
- })
90
- Ayadn::Settings.stub(:config).and_return({
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'
96
+ }))
97
+ require 'json'
98
+ require 'ostruct'
99
+ obj =
100
+ {
101
+ identity: {
102
+ username: 'test',
103
+ handle: '@test'
104
+ },
105
+ post_max_length: 256,
106
+ message_max_length: 2048,
107
+ version: 'wee',
108
+ paths: {
109
+ db: 'spec/mock/',
110
+ log: 'spec/mock'
111
+ },
112
+ platform: 'shoes',
113
+ ruby: '0',
114
+ locale: 'gibberish'
101
115
  }
102
- })
103
- Ayadn::Settings.stub(:global).and_return({
116
+ Ayadn::Settings.stub(:config).and_return(
117
+ JSON.parse(obj.to_json, object_class: OpenStruct)
118
+ )
119
+ global_hash = {
104
120
  scrolling: false,
105
121
  force: false
106
- })
122
+ }
123
+ Ayadn::Settings.stub(:global).and_return(
124
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
125
+ )
107
126
  Dir.stub(:home).and_return("spec/mock")
108
127
  Ayadn::Settings.stub(:get_token).and_return('XYZ')
109
128
  Ayadn::Settings.stub(:user_token).and_return('XYZ')
@@ -119,11 +138,13 @@ describe Ayadn::Action do
119
138
  Ayadn::Databases.stub(:has_new?).and_return(true)
120
139
  Ayadn::Databases.stub(:add_to_users_db_from_list)
121
140
  end
141
+
122
142
  let(:stream) { File.read("spec/mock/stream.json") }
123
143
  let(:mentions) { File.read("spec/mock/mentions.json") }
124
144
  let(:list) { File.read("spec/mock/fwr_@ayadn.json") }
125
145
  let(:ranks) { JSON.parse(File.read("spec/mock/nicerank.json")) }
126
146
  let(:cnx) {Ayadn::CNX}
147
+
127
148
  describe "#Global" do
128
149
  before do
129
150
  cnx.stub(:get)
Binary file
@@ -6,40 +6,50 @@ describe Ayadn::Annotations do
6
6
 
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,
12
+ directed: true,
13
13
  source: true,
14
14
  symbols: true,
15
15
  name: true,
16
16
  date: true,
17
- spinner: true,
18
- debug: false
17
+ debug: false,
18
+ compact: false
19
+ },
20
+ marker: {
21
+ messages: true
19
22
  },
20
23
  counts: {
21
24
  default: 50,
22
- unified: 100,
23
- global: 100,
24
- checkins: 100,
25
+ unified: 50,
26
+ global: 50,
27
+ checkins: 50,
25
28
  conversations: 50,
26
29
  photos: 50,
27
- trending: 100,
28
- mentions: 100,
29
- convo: 100,
30
- posts: 100,
31
- messages: 50,
30
+ trending: 50,
31
+ mentions: 50,
32
+ convo: 50,
33
+ posts: 50,
34
+ messages: 20,
32
35
  search: 200,
33
- whoreposted: 50,
34
- whostarred: 50,
36
+ whoreposted: 20,
37
+ whostarred: 20,
35
38
  whatstarred: 100,
36
- files: 100
39
+ files: 50
37
40
  },
38
41
  formats: {
39
42
  table: {
40
- width: 75
43
+ width: 75,
44
+ borders: true
45
+ },
46
+ list: {
47
+ reverse: true
41
48
  }
42
49
  },
50
+ channels: {
51
+ links: true
52
+ },
43
53
  colors: {
44
54
  id: :blue,
45
55
  index: :red,
@@ -52,6 +62,7 @@ describe Ayadn::Annotations do
52
62
  mentions: :red,
53
63
  source: :cyan,
54
64
  symbols: :green,
65
+ unread: :cyan,
55
66
  debug: :red,
56
67
  excerpt: :green
57
68
  },
@@ -61,7 +72,9 @@ describe Ayadn::Annotations do
61
72
  lists: false
62
73
  },
63
74
  scroll: {
64
- timer: 3
75
+ spinner: true,
76
+ timer: 3,
77
+ date: false
65
78
  },
66
79
  nicerank: {
67
80
  threshold: 2.1,
@@ -69,15 +82,15 @@ describe Ayadn::Annotations do
69
82
  unranked: false
70
83
  },
71
84
  nowplaying: {},
72
- movie: {
73
- hashtag: 'nowwatching'
74
- },
75
- tvshow: {
76
- hashtag: 'nowwatching'
85
+ blacklist: {
86
+ active: true
77
87
  }
78
- }
88
+ })
79
89
  )
80
- Ayadn::Settings.stub(:config).and_return({
90
+ require 'json'
91
+ require 'ostruct'
92
+ obj =
93
+ {
81
94
  identity: {
82
95
  username: 'test',
83
96
  handle: '@test'
@@ -85,10 +98,24 @@ describe Ayadn::Annotations do
85
98
  post_max_length: 256,
86
99
  message_max_length: 2048,
87
100
  version: 'wee',
101
+ paths: {
102
+ db: 'spec/mock/',
103
+ log: 'spec/mock'
104
+ },
105
+ platform: 'shoes',
88
106
  ruby: '0',
89
- locale: 'gibberish',
90
- platform: 'shoes'
91
- })
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
+ )
92
119
  Ayadn::Errors.stub(:warn).and_return("warned")
93
120
  Ayadn::Logs.stub(:rec).and_return("logged")
94
121
  Ayadn::FileOps.stub(:make_paths).and_return(['~/your/path/cat.jpg', '~/your/path/dog.png']) # STUB1
@@ -124,20 +151,6 @@ describe Ayadn::Annotations do
124
151
  end
125
152
  end
126
153
 
127
- describe "#movie" do
128
- it "creates movie annotations" do
129
- ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {movie: true}})
130
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"https://github.com/ericdke/na", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.movie", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
131
- end
132
- end
133
-
134
- describe "#tvshow" do
135
- it "creates tvshow annotations" do
136
- ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {tvshow: true}})
137
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"https://github.com/ericdke/na", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.tvshow", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
138
- end
139
- end
140
-
141
154
  describe "#nowplaying --silent" do
142
155
  it "creates nowplaying --silent annotations" do
143
156
  ann = Ayadn::Annotations.new({source: 'wadawadawada', options: {nowplaying: true, no_url: true}})
@@ -2,16 +2,87 @@ require 'spec_helper'
2
2
 
3
3
  describe Ayadn::API do
4
4
  before do
5
- Ayadn::Settings.stub(:options).and_return({
5
+ Ayadn::Settings.stub(:options).and_return(
6
+ Ayadn::Preferences.new(
7
+ {
8
+ timeline: {
9
+ directed: false,
10
+ source: true,
11
+ symbols: true,
12
+ name: true,
13
+ date: true,
14
+ debug: false,
15
+ compact: false
16
+ },
17
+ marker: {
18
+ messages: true
19
+ },
6
20
  counts: {
7
- default: 50
21
+ default: 50,
22
+ unified: 50,
23
+ global: 50,
24
+ checkins: 50,
25
+ conversations: 50,
26
+ photos: 50,
27
+ trending: 50,
28
+ mentions: 50,
29
+ convo: 50,
30
+ posts: 50,
31
+ messages: 20,
32
+ search: 200,
33
+ whoreposted: 20,
34
+ whostarred: 20,
35
+ whatstarred: 100,
36
+ files: 50
8
37
  },
9
- timeline: {
10
- directed: 1,
11
- html: 0,
12
- annotations: 1
38
+ formats: {
39
+ table: {
40
+ width: 75,
41
+ borders: true
42
+ },
43
+ list: {
44
+ reverse: true
45
+ }
46
+ },
47
+ channels: {
48
+ links: true
49
+ },
50
+ colors: {
51
+ id: :blue,
52
+ index: :red,
53
+ username: :green,
54
+ name: :magenta,
55
+ date: :cyan,
56
+ link: :yellow,
57
+ dots: :blue,
58
+ hashtags: :cyan,
59
+ mentions: :red,
60
+ source: :cyan,
61
+ symbols: :green,
62
+ unread: :cyan,
63
+ debug: :red,
64
+ excerpt: :green
65
+ },
66
+ backup: {
67
+ posts: false,
68
+ messages: false,
69
+ lists: false
70
+ },
71
+ scroll: {
72
+ spinner: true,
73
+ timer: 3,
74
+ date: false
75
+ },
76
+ nicerank: {
77
+ threshold: 2.1,
78
+ filter: true,
79
+ unranked: false
80
+ },
81
+ nowplaying: {},
82
+ blacklist: {
83
+ active: true
13
84
  }
14
- })
85
+ }))
15
86
  end
16
87
  describe ".build_query" do
17
88
  it 'returns a URL with count=12' do
@@ -3,32 +3,91 @@ require 'helpers'
3
3
 
4
4
  describe Ayadn::BlacklistWorkers 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,
11
- id: :blue,
12
- name: :yellow,
13
- source: :blue,
61
+ source: :cyan,
14
62
  symbols: :green,
15
- index: :blue,
16
- date: :cyan,
17
- link: :magenta,
63
+ unread: :cyan,
64
+ debug: :red,
18
65
  excerpt: :green
19
66
  },
20
- timeline: {
21
- name: true,
22
- date: true,
23
- symbols: true,
24
- source: true
67
+ backup: {
68
+ posts: false,
69
+ messages: false,
70
+ lists: false
25
71
  },
26
- formats: {table: {width: 75}},
27
- counts: {
28
- default: 33
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
29
85
  }
30
- })
31
- Ayadn::Settings.stub(:config).and_return({
86
+ }))
87
+ require 'json'
88
+ require 'ostruct'
89
+ obj =
90
+ {
32
91
  identity: {
33
92
  username: 'test',
34
93
  handle: '@test'
@@ -39,8 +98,21 @@ describe Ayadn::BlacklistWorkers do
39
98
  paths: {
40
99
  db: 'spec/mock/',
41
100
  log: 'spec/mock'
42
- }
43
- })
101
+ },
102
+ platform: 'shoes',
103
+ ruby: '0',
104
+ locale: 'gibberish'
105
+ }
106
+ Ayadn::Settings.stub(:config).and_return(
107
+ JSON.parse(obj.to_json, object_class: OpenStruct)
108
+ )
109
+ global_hash = {
110
+ scrolling: false,
111
+ force: false
112
+ }
113
+ Ayadn::Settings.stub(:global).and_return(
114
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
115
+ )
44
116
  Ayadn::Settings.stub(:user_token).and_return('XYZ')
45
117
  Ayadn::Settings.stub(:check_for_accounts)
46
118
  Ayadn::Settings.stub(:load_config)