adn-reborn 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +8 -0
  4. data/CHANGELOG.md +34 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +25 -0
  7. data/LICENSE +16 -0
  8. data/README.md +19 -0
  9. data/Rakefile +17 -0
  10. data/adn-reborn.gemspec +19 -0
  11. data/lib/adn-reborn/api/file.rb +36 -0
  12. data/lib/adn-reborn/api/filter.rb +10 -0
  13. data/lib/adn-reborn/api/message.rb +29 -0
  14. data/lib/adn-reborn/api/post.rb +51 -0
  15. data/lib/adn-reborn/api/response.rb +19 -0
  16. data/lib/adn-reborn/api/stream.rb +10 -0
  17. data/lib/adn-reborn/api/subscription.rb +11 -0
  18. data/lib/adn-reborn/api/token.rb +12 -0
  19. data/lib/adn-reborn/api/user.rb +19 -0
  20. data/lib/adn-reborn/api.rb +62 -0
  21. data/lib/adn-reborn/constants.rb +18 -0
  22. data/lib/adn-reborn/file.rb +62 -0
  23. data/lib/adn-reborn/message.rb +76 -0
  24. data/lib/adn-reborn/post.rb +76 -0
  25. data/lib/adn-reborn/recipes/broadcast_message_builder.rb +103 -0
  26. data/lib/adn-reborn/recipes.rb +5 -0
  27. data/lib/adn-reborn/user.rb +103 -0
  28. data/lib/adn-reborn/version.rb +9 -0
  29. data/lib/adn-reborn.rb +69 -0
  30. data/spec/adn-reborn/api/file_spec.rb +73 -0
  31. data/spec/adn-reborn/api/filter_spec.rb +9 -0
  32. data/spec/adn-reborn/api/message_spec.rb +73 -0
  33. data/spec/adn-reborn/api/post_spec.rb +147 -0
  34. data/spec/adn-reborn/api/response_spec.rb +13 -0
  35. data/spec/adn-reborn/api/stream_spec.rb +9 -0
  36. data/spec/adn-reborn/api/subscription_spec.rb +9 -0
  37. data/spec/adn-reborn/api/token_spec.rb +23 -0
  38. data/spec/adn-reborn/api/user_spec.rb +27 -0
  39. data/spec/adn-reborn/file_spec.rb +103 -0
  40. data/spec/adn-reborn/message_spec.rb +152 -0
  41. data/spec/adn-reborn/post_spec.rb +147 -0
  42. data/spec/adn-reborn/recipes/broadcast_message_builder_spec.rb +179 -0
  43. data/spec/adn-reborn/user_spec.rb +115 -0
  44. data/spec/adn-reborn_spec.rb +42 -0
  45. data/spec/fixtures/post.json +88 -0
  46. data/spec/fixtures/user.json +70 -0
  47. data/spec/spec_helper.rb +30 -0
  48. metadata +141 -0
@@ -0,0 +1,115 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ describe ADNReborn::User do
6
+ subject { ADNReborn::User }
7
+
8
+ let(:empty_user) { subject.new({}) }
9
+ let(:user) { subject.new(user_data) }
10
+ let(:user_response) { fixture('user.json') }
11
+ let(:user_data) { user_response["data"] }
12
+
13
+ describe "me" do
14
+ it "retrieves the user based on the current token" do
15
+ ADNReborn::API::Token.stub(:current, { "user" => user_data }) do
16
+ u = subject.me
17
+ u.user_id.must_equal "4821"
18
+ u.username.must_equal "peterhellberg"
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "find" do
24
+ it "retrieves the user data from the API and returns a User object" do
25
+ ADNReborn::API::User.stub(:retrieve, user_response) do
26
+ u = subject.find("4821")
27
+ u.name.must_equal "Peter Hellberg"
28
+ u.user_id.must_equal "4821"
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "initialize" do
34
+ it "populates the accessors based on the raw user data passed in" do
35
+ u = subject.new(user_data)
36
+ u.name.must_equal "Peter Hellberg"
37
+ u.user_id.must_equal "4821"
38
+ end
39
+ end
40
+
41
+ describe "created_at" do
42
+ it "it returns the date and time the user was created" do
43
+ user.created_at.to_s.must_equal '2012-08-17T00:38:18+00:00'
44
+ end
45
+ end
46
+
47
+ describe "follow" do
48
+ it "" do
49
+ end
50
+ end
51
+
52
+ describe "unfollow" do
53
+ it "" do
54
+ end
55
+ end
56
+
57
+ describe "followers" do
58
+ it "" do
59
+ end
60
+ end
61
+
62
+ describe "following" do
63
+ it "" do
64
+ end
65
+ end
66
+
67
+ describe "mute" do
68
+ it "" do
69
+ end
70
+ end
71
+
72
+ describe "unmute" do
73
+ it "" do
74
+ end
75
+ end
76
+
77
+ describe "mute_list" do
78
+ it "" do
79
+ end
80
+ end
81
+
82
+ describe "posts" do
83
+ it "" do
84
+ end
85
+ end
86
+
87
+ describe "stream" do
88
+ it "" do
89
+ end
90
+ end
91
+
92
+ describe "mentions" do
93
+ it "" do
94
+ end
95
+ end
96
+
97
+ describe "set_values" do
98
+ it "only sets valid attributes" do
99
+ u = subject.new({})
100
+ u.set_values({ foo: 'bar', name: 'Molly' })
101
+ u.name.must_equal 'Molly'
102
+ -> { u.foo }.must_raise NoMethodError
103
+ end
104
+ end
105
+
106
+ describe "valid_user?" do
107
+ it "returns false if no id" do
108
+ empty_user.valid_user?.must_equal false
109
+ end
110
+
111
+ it "returns true if the user has an id" do
112
+ user.valid_user?.must_equal true
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ describe ADNReborn do
6
+ subject { ADNReborn }
7
+
8
+ let(:example_token) {
9
+ 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
10
+ }
11
+
12
+ it "can set and get a token" do
13
+ subject.token.must_equal nil
14
+ subject.token = example_token
15
+ subject.token.must_equal example_token
16
+ end
17
+
18
+ it "has a constant containing the hostname of the api" do
19
+ ADNReborn::API_HOST.must_equal 'api.app.net'
20
+ end
21
+
22
+ it "has constants for the API endpoints posts, users, channels, and files" do
23
+ ADNReborn::API_ENDPOINT_POSTS.must_equal '/stream/0/posts'
24
+ ADNReborn::API_ENDPOINT_USERS.must_equal '/stream/0/users'
25
+ ADNReborn::API_ENDPOINT_CHANNELS.must_equal '/stream/0/channels'
26
+ ADNReborn::API_ENDPOINT_FILES.must_equal '/stream/0/files'
27
+ end
28
+
29
+ it "has constants containing the API endpoints for tokens" do
30
+ ADNReborn::API_ENDPOINT_TOKEN.must_equal '/stream/0/token'
31
+ end
32
+
33
+ # TODO: Move into the ADNReborn module, and rename using snake case
34
+ # Should probably be refactored to a separate class
35
+ it "currently has a constant containing a http client" do
36
+ ADNReborn::HTTP.tap { |http|
37
+ http.address.must_equal "api.app.net"
38
+ http.port.must_equal 443
39
+ http.use_ssl?.must_equal true
40
+ }
41
+ end
42
+ end
@@ -0,0 +1,88 @@
1
+ {
2
+ "created_at": "2012-08-24T15:47:22Z",
3
+ "entities": {
4
+ "hashtags": [
5
+ {
6
+ "len": 5,
7
+ "name": "Ruby",
8
+ "pos": 27
9
+ }
10
+ ],
11
+ "links": [
12
+
13
+ ],
14
+ "mentions": [
15
+ {
16
+ "id": "351",
17
+ "len": 6,
18
+ "name": "joyce",
19
+ "pos": 0
20
+ }
21
+ ]
22
+ },
23
+ "html": "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"mention\" data-mention-id=\"351\" data-mention-name=\"joyce\">@joyce</span> I&#8217;m very partial to <span itemprop=\"hashtag\" data-hashtag-name=\"Ruby\">#Ruby</span> when it comes to server side languages, and it&#8217;s also quite easy to learn. (Probably takes a lifetime to fully master though)</span>",
24
+ "id": "175510",
25
+ "machine_only": false,
26
+ "num_replies": 1,
27
+ "reply_to": "175485",
28
+ "source": {
29
+ "link": "http://xtendr.net",
30
+ "name": "xtendr"
31
+ },
32
+ "text": "@joyce I’m very partial to #Ruby when it comes to server side languages, and it’s also quite easy to learn. (Probably takes a lifetime to fully master though)",
33
+ "thread_id": "175470",
34
+ "user": {
35
+ "avatar_image": {
36
+ "height": 200,
37
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/vKp-0ksqIbYGrrDV6y2sDSjvg9Cg5AmCjyVGfuokT2M-U8fB2NM23UW_EDPC-0oEfpgPy7SD7YFuF4Lra1mousUVeMMu5lNcth1BqHYMu-tIKIp3-wpADI0UEhUqr5J5sT4eKopTw34RWXvLOHJE_C7O-wE",
38
+ "width": 200
39
+ },
40
+ "counts": {
41
+ "followers": 85,
42
+ "following": 62,
43
+ "posts": 390
44
+ },
45
+ "cover_image": {
46
+ "height": 538,
47
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/LGbl1tTJt3wsWEtK2HQko7gSiM10_hIHy8Z20oC7mH_BVjlZNH2hNaaRTvC00FWUq-jYS_GA4ZX9ivltg6Y6T_uYyvVEPQ7Ijtn5dlhrlClqCP1QxhVk3kcT300TjHfXy0y10p_nYjZi4X6kDQwvJh2oFPM",
48
+ "width": 1280
49
+ },
50
+ "created_at": "2012-08-17T00:38:18Z",
51
+ "description": {
52
+ "entities": {
53
+ "hashtags": [
54
+ {
55
+ "len": 5,
56
+ "name": "Ruby",
57
+ "pos": 0
58
+ }
59
+ ],
60
+ "links": [
61
+ {
62
+ "len": 35,
63
+ "pos": 83,
64
+ "text": "http://black-white-city.tumblr.com/",
65
+ "url": "http://black-white-city.tumblr.com/"
66
+ },
67
+ {
68
+ "len": 13,
69
+ "pos": 122,
70
+ "text": "http://c7.se/",
71
+ "url": "http://c7.se/"
72
+ }
73
+ ],
74
+ "mentions": [
75
+
76
+ ]
77
+ },
78
+ "html": "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"hashtag\" data-hashtag-name=\"Ruby\">#Ruby</span> developer, Mac convert, Linux aficionado and Boulder climber. Photo project: <a href=\"http://black-white-city.tumblr.com/\">http://black-white-city.tumblr.com/</a>\r\n\r\n<a href=\"http://c7.se/\">http://c7.se/</a></span>",
79
+ "text": "#Ruby developer, Mac convert, Linux aficionado and Boulder climber. Photo project: http://black-white-city.tumblr.com/\r\n\r\nhttp://c7.se/"
80
+ },
81
+ "id": "4821",
82
+ "locale": "en_US",
83
+ "name": "Peter Hellberg",
84
+ "timezone": "America/Los_Angeles",
85
+ "type": "human",
86
+ "username": "peterhellberg"
87
+ }
88
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "data": {
3
+ "avatar_image": {
4
+ "height": 440,
5
+ "is_default": false,
6
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/5/MfpIbYccafFMBK_B_KeuJ7ZaVdF7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvYzQvOGIvMzAvYzQ4YjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0",
7
+ "width": 440
8
+ },
9
+ "canonical_url": "https://alpha.app.net/peterhellberg",
10
+ "counts": {
11
+ "followers": 198,
12
+ "following": 137,
13
+ "posts": 1544,
14
+ "stars": 0
15
+ },
16
+ "cover_image": {
17
+ "height": 538,
18
+ "is_default": false,
19
+ "url": "https://d2rfichhc2fb9n.cloudfront.net/image/5/LGbl1tTJt3wsWEtK2HQko7gSiM17InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvYjIvNDMvMDAvYjI0MzAwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0",
20
+ "width": 1280
21
+ },
22
+ "created_at": "2012-08-17T00:38:18Z",
23
+ "description": {
24
+ "entities": {
25
+ "hashtags": [
26
+ {
27
+ "len": 5,
28
+ "name": "ruby",
29
+ "pos": 0
30
+ }
31
+ ],
32
+ "links": [
33
+ {
34
+ "len": 35,
35
+ "pos": 87,
36
+ "text": "http://black-white-city.tumblr.com/",
37
+ "url": "http://black-white-city.tumblr.com/"
38
+ },
39
+ {
40
+ "len": 30,
41
+ "pos": 128,
42
+ "text": "http://500px.com/peterhellberg",
43
+ "url": "http://500px.com/peterhellberg"
44
+ }
45
+ ],
46
+ "mentions": [
47
+ {
48
+ "id": "93657",
49
+ "len": 3,
50
+ "name": "c7",
51
+ "pos": 168
52
+ }
53
+ ]
54
+ },
55
+ "html": "<span itemscope=\"https://app.net/schemas/Post\"><span data-hashtag-name=\"ruby\" itemprop=\"hashtag\">#Ruby</span> developer, Mac convert, Linux aficionado and Boulder climber.&#13;<br>&#13;<br>Photo projects: <a href=\"http://black-white-city.tumblr.com/\">http://black-white-city.tumblr.com/</a> and <a href=\"http://500px.com/peterhellberg\">http://500px.com/peterhellberg</a>&#13;<br>&#13;<br>I run <span data-mention-id=\"93657\" data-mention-name=\"c7\" itemprop=\"mention\">@c7</span> on the side of my day job.</span>",
56
+ "text": "#Ruby developer, Mac convert, Linux aficionado and Boulder climber.\r\n\r\nPhoto projects: http://black-white-city.tumblr.com/ and http://500px.com/peterhellberg\r\n\r\nI run @c7 on the side of my day job."
57
+ },
58
+ "id": "4821",
59
+ "locale": "en_US",
60
+ "name": "Peter Hellberg",
61
+ "timezone": "Europe/Stockholm",
62
+ "type": "human",
63
+ "username": "peterhellberg",
64
+ "verified_domain": "c7.se",
65
+ "verified_link": "http://c7.se"
66
+ },
67
+ "meta": {
68
+ "code": 200
69
+ }
70
+ }
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest/spec'
5
+
6
+ begin
7
+ require 'minitest/pride'
8
+ rescue LoadError
9
+ puts "Install the minitest gem if you want colored output"
10
+ end
11
+
12
+ require "find"
13
+
14
+ %w{./lib}.each do |load_path|
15
+ Find.find(load_path) { |f| require f if f.match(/\.rb$/) }
16
+ end
17
+
18
+ def arg(m, k = ADNReborn::API, &b)
19
+ k.stub(m,->(a){a}, &b)
20
+ end
21
+
22
+ def args(m, k = ADNReborn::API, &b)
23
+ k.stub(m,->(*a){a}, &b)
24
+ end
25
+
26
+ def fixture(file_name)
27
+ JSON.parse IO.read(
28
+ File.dirname(__FILE__) + "/fixtures/#{file_name}"
29
+ )
30
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adn-reborn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - trorornmn
8
+ - Kishyr Ramdial
9
+ - Dave Goodchild
10
+ - Peter Hellberg
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2016-02-13 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: multipart-post
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: mime-types
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ description: A simple and easy to use library to interact with App.net's API
45
+ email:
46
+ - trorornmn.develop@gmail.com
47
+ - kishyr@gmail.com
48
+ - buddhamagnet@gmail.com
49
+ - peter@c7.se
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - ".gitignore"
55
+ - ".travis.yml"
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - Gemfile.lock
59
+ - LICENSE
60
+ - README.md
61
+ - Rakefile
62
+ - adn-reborn.gemspec
63
+ - lib/adn-reborn.rb
64
+ - lib/adn-reborn/api.rb
65
+ - lib/adn-reborn/api/file.rb
66
+ - lib/adn-reborn/api/filter.rb
67
+ - lib/adn-reborn/api/message.rb
68
+ - lib/adn-reborn/api/post.rb
69
+ - lib/adn-reborn/api/response.rb
70
+ - lib/adn-reborn/api/stream.rb
71
+ - lib/adn-reborn/api/subscription.rb
72
+ - lib/adn-reborn/api/token.rb
73
+ - lib/adn-reborn/api/user.rb
74
+ - lib/adn-reborn/constants.rb
75
+ - lib/adn-reborn/file.rb
76
+ - lib/adn-reborn/message.rb
77
+ - lib/adn-reborn/post.rb
78
+ - lib/adn-reborn/recipes.rb
79
+ - lib/adn-reborn/recipes/broadcast_message_builder.rb
80
+ - lib/adn-reborn/user.rb
81
+ - lib/adn-reborn/version.rb
82
+ - spec/adn-reborn/api/file_spec.rb
83
+ - spec/adn-reborn/api/filter_spec.rb
84
+ - spec/adn-reborn/api/message_spec.rb
85
+ - spec/adn-reborn/api/post_spec.rb
86
+ - spec/adn-reborn/api/response_spec.rb
87
+ - spec/adn-reborn/api/stream_spec.rb
88
+ - spec/adn-reborn/api/subscription_spec.rb
89
+ - spec/adn-reborn/api/token_spec.rb
90
+ - spec/adn-reborn/api/user_spec.rb
91
+ - spec/adn-reborn/file_spec.rb
92
+ - spec/adn-reborn/message_spec.rb
93
+ - spec/adn-reborn/post_spec.rb
94
+ - spec/adn-reborn/recipes/broadcast_message_builder_spec.rb
95
+ - spec/adn-reborn/user_spec.rb
96
+ - spec/adn-reborn_spec.rb
97
+ - spec/fixtures/post.json
98
+ - spec/fixtures/user.json
99
+ - spec/spec_helper.rb
100
+ homepage: https://github.com/trorornmn/adn-reborn
101
+ licenses: []
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 1.9.3
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.5.1
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: A Ruby library for App.net
123
+ test_files:
124
+ - spec/adn-reborn/api/file_spec.rb
125
+ - spec/adn-reborn/api/filter_spec.rb
126
+ - spec/adn-reborn/api/message_spec.rb
127
+ - spec/adn-reborn/api/post_spec.rb
128
+ - spec/adn-reborn/api/response_spec.rb
129
+ - spec/adn-reborn/api/stream_spec.rb
130
+ - spec/adn-reborn/api/subscription_spec.rb
131
+ - spec/adn-reborn/api/token_spec.rb
132
+ - spec/adn-reborn/api/user_spec.rb
133
+ - spec/adn-reborn/file_spec.rb
134
+ - spec/adn-reborn/message_spec.rb
135
+ - spec/adn-reborn/post_spec.rb
136
+ - spec/adn-reborn/recipes/broadcast_message_builder_spec.rb
137
+ - spec/adn-reborn/user_spec.rb
138
+ - spec/adn-reborn_spec.rb
139
+ - spec/fixtures/post.json
140
+ - spec/fixtures/user.json
141
+ - spec/spec_helper.rb