kermit 1.0.0

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 (70) hide show
  1. data/Gemfile +18 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +54 -0
  4. data/Rakefile +31 -0
  5. data/VERSION +1 -0
  6. data/bin/kermit +24 -0
  7. data/config/config.example.yml +24 -0
  8. data/doc/Adapter.html +533 -0
  9. data/doc/Converter.html +348 -0
  10. data/doc/DAO.html +1047 -0
  11. data/doc/KermitPFC.html +927 -0
  12. data/doc/Link.html +667 -0
  13. data/doc/Logging.html +401 -0
  14. data/doc/Logging/Settings.html +170 -0
  15. data/doc/RandomAdapter.html +501 -0
  16. data/doc/RandomConverter.html +359 -0
  17. data/doc/RandomPhraseGenerator.html +317 -0
  18. data/doc/ToUser.html +815 -0
  19. data/doc/TwitterAdapter.html +550 -0
  20. data/doc/TwitterConverter.html +598 -0
  21. data/doc/USMF.html +2188 -0
  22. data/doc/User.html +1407 -0
  23. data/doc/WebSocketClient.html +316 -0
  24. data/doc/WebSocketServer.html +427 -0
  25. data/doc/_index.html +270 -0
  26. data/doc/class_list.html +53 -0
  27. data/doc/css/common.css +1 -0
  28. data/doc/css/full_list.css +57 -0
  29. data/doc/css/style.css +328 -0
  30. data/doc/file.LICENSE.html +73 -0
  31. data/doc/file.README.html +123 -0
  32. data/doc/file_list.html +58 -0
  33. data/doc/frames.html +28 -0
  34. data/doc/index.html +123 -0
  35. data/doc/js/app.js +214 -0
  36. data/doc/js/full_list.js +173 -0
  37. data/doc/js/jquery.js +4 -0
  38. data/doc/method_list.html +764 -0
  39. data/doc/top-level-namespace.html +138 -0
  40. data/lib/business/adapter/adapter.rb +39 -0
  41. data/lib/business/adapter/random_adapter.rb +50 -0
  42. data/lib/business/adapter/twitter_adapter.rb +75 -0
  43. data/lib/business/converter/converter.rb +24 -0
  44. data/lib/business/converter/random_converter.rb +42 -0
  45. data/lib/business/converter/twitter_converter.rb +164 -0
  46. data/lib/business/random_phrase_generator.rb +39 -0
  47. data/lib/helper/DAO.rb +94 -0
  48. data/lib/helper/settings.rb +11 -0
  49. data/lib/helper/websocket_client.rb +37 -0
  50. data/lib/helper/websocket_server.rb +65 -0
  51. data/lib/kermitpfc.rb +164 -0
  52. data/lib/logging.rb +31 -0
  53. data/lib/model/USMF/USMF.rb +98 -0
  54. data/lib/model/USMF/link.rb +30 -0
  55. data/lib/model/USMF/to_user.rb +32 -0
  56. data/lib/model/USMF/user.rb +41 -0
  57. data/lib/model/templates/USMF +56 -0
  58. data/lib/model/templates/atom.xml +74 -0
  59. data/lib/model/templates/example +59 -0
  60. data/lib/model/templates/rss.xml +68 -0
  61. data/lib/model/templates/template +49 -0
  62. data/lib/model/templates/tweet +116 -0
  63. data/spec/DAO_spec.rb +64 -0
  64. data/spec/random_adapter_spec.rb +24 -0
  65. data/spec/random_converter_spec.rb +115 -0
  66. data/spec/random_phrase_generator_spec.rb +15 -0
  67. data/spec/twitter_adapter_spec.rb +24 -0
  68. data/spec/twitter_converter_spec.rb +132 -0
  69. data/websocket_client.html +20 -0
  70. metadata +253 -0
@@ -0,0 +1,98 @@
1
+ require_relative './user'
2
+ require_relative '../../logging'
3
+
4
+ # @author Daniel Machado Fernandez
5
+ # @version 1.0
6
+ #
7
+ # USMF standard message from Tawlk
8
+ # @see https://github.com/Tawlk/hyve/wiki/Unified-Social-Media-Format-(USMF)
9
+ class USMF
10
+
11
+ include Logging
12
+
13
+ attr_accessor :service,:user,:to_users,:links,:id,:geo,:application,:location,:date,:source,:text,:description,:keywords,
14
+ :category,:duration,:likes,:dislikes,:favorites,:comments,:rates,:rating,:min_rating,:max_rating
15
+
16
+ # Unify the fields into a string
17
+ #
18
+ # @return [String] resultant string
19
+ def to_s
20
+
21
+ res = "\nservice: " + service.to_s + "\nid: " + id.to_s + "\ngeo: " + geo.to_s + "\napplication: " + application.to_s + "\nlocation: " + location.to_s + "\ndate: " + date.to_s + "\nsource: " + source.to_s + "\ntext: " + text.to_s + "\ndescription: " + description.to_s + "\nkeywords: " + keywords.to_s + "\ncategory: " + category.to_s + "\nduration: " + duration.to_s + "\nlikes: " + likes.to_s + "\ndislikes: " + dislikes.to_s + "\nfavorites: " + favorites.to_s + "\ncomments: " + comments.to_s + "\nrates: " + rates.to_s + "\nrating: " + rating.to_s + "\nmin_rating: " + min_rating.to_s + "\nmax_rating: " + max_rating.to_s + "\n[USER]: " + user.to_s + "\n[TO_USERS]: " + to_users.to_s + "\n[LINKS]: " + links.to_s
22
+ res
23
+
24
+ end
25
+
26
+ # Unify the fields into a hash
27
+ #
28
+ # @return [Hash] resultant hash
29
+ def to_hash
30
+
31
+ res = {
32
+ "service" => service,
33
+ "id" => id,
34
+ "geo" => geo,
35
+ "application" => application,
36
+ "location" => location,
37
+ "date" => date,
38
+ "source" => source,
39
+ "text" => text,
40
+ "description" => description,
41
+ "keywords" => keywords,
42
+ "category" => category,
43
+ "duration" => duration,
44
+ "likes" => likes,
45
+ "dislikes" => dislikes,
46
+ "favorites" => favorites,
47
+ "comments" => comments,
48
+ "rates" => rates,
49
+ "rating" => rating,
50
+ "min_rating" => min_rating,
51
+ "max_rating" => max_rating
52
+ }
53
+ begin
54
+
55
+ unless :user == nil
56
+ res["user"] = user.to_hash
57
+ end
58
+
59
+ rescue
60
+
61
+ res["user"] = nil
62
+ logger.error("A corrupt user was found")
63
+
64
+ end
65
+
66
+ l = []
67
+
68
+ unless :links == nil
69
+
70
+ links.each do |link|
71
+
72
+ l << link.to_hash
73
+
74
+ end
75
+
76
+ res["links"] = l
77
+
78
+ end
79
+
80
+ tu = []
81
+
82
+ unless :to_users == nil
83
+
84
+ to_users.each do |us|
85
+
86
+ tu << us.to_hash
87
+
88
+ end
89
+
90
+ res["to_users"] = tu
91
+
92
+ end
93
+
94
+ res
95
+
96
+ end
97
+
98
+ end
@@ -0,0 +1,30 @@
1
+ # @author Daniel Machado Fernandez
2
+ # @version 1.0
3
+ #
4
+ # A Link model
5
+ class Link
6
+
7
+ attr_accessor :service,:title,:thumbnail,:href
8
+
9
+ # Unify the fields into a string
10
+ #
11
+ # @return [String] resultant string
12
+ def to_s
13
+ res = "\nservice: " + service.to_s + "\ntitle: " + title.to_s + "\nthumbnail: " + thumbnail.to_s + "\nhref: " + href.to_s
14
+ res
15
+ end
16
+
17
+ # Unify the fields into a hash
18
+ #
19
+ # @return [Hash] resultant hash
20
+ def to_hash
21
+ res = {
22
+ "service" => service,
23
+ "title" => title,
24
+ "thumbnail" => thumbnail,
25
+ "href" => href
26
+ }
27
+ res
28
+ end
29
+
30
+ end
@@ -0,0 +1,32 @@
1
+ # @author Daniel Machado Fernandez
2
+ # @version 1.0
3
+ #
4
+ # Models the ToUser relation
5
+ class ToUser
6
+
7
+ attr_accessor :name,:id,:service,:title,:thumbnail,:href
8
+
9
+ # Unify the fields into a string
10
+ #
11
+ # @return [String] resultant string
12
+ def to_s
13
+ res = "\nname: " + name.to_s + "\nid: " + id.to_s + "\nservice: " + service.to_s + "\ntitle: " + title.to_s + "\nthumbnail: " + thumbnail.to_s + "\nhref: " + href.to_s
14
+ res
15
+ end
16
+
17
+ # Unify the fields into a hash
18
+ #
19
+ # @return [Hash] resultant hash
20
+ def to_hash
21
+ res = {
22
+ "name" => name,
23
+ "id" => id,
24
+ "service" => service,
25
+ "title" => title,
26
+ "thumbnail" => thumbnail,
27
+ "href" => href
28
+ }
29
+ res
30
+ end
31
+
32
+ end
@@ -0,0 +1,41 @@
1
+ # @author Daniel Machado Fernandez
2
+ # @version 1.0
3
+ #
4
+ # Models a User into USMF standard
5
+ class User
6
+
7
+ attr_accessor :name,:real_name,:id,:language,:utc,:geo,:description,:avatar,:location,:subscribers,:subscriptions,
8
+ :postings,:profile,:website
9
+
10
+ # Unify the fields into a string
11
+ #
12
+ # @return [String] resultant string
13
+ def to_s
14
+ res = "\nname: " + name.to_s + "\nreal_name: " + real_name.to_s + "\nid: " + id.to_s + "\nlanguage: " + language.to_s + "\nutc: " + utc.to_s + "\ngeo: " + geo.to_s + "\ndescription: " + description.to_s + "\navatar: " + avatar.to_s + "\nlocation: " + location.to_s + "\nsubscribers: " + subscribers.to_s + "\nsubscriptions: " + subscriptions.to_s + "\npostings: " + postings.to_s + "\nprofile: " + profile.to_s + "\nwebsite: " + website.to_s
15
+ res
16
+ end
17
+
18
+ # Unify the fields into a hash
19
+ #
20
+ # @return [Hash] resultant hash
21
+ def to_hash
22
+ res = {
23
+ "name" => name,
24
+ "real_name" => real_name,
25
+ "id" => id,
26
+ "language" => language,
27
+ "utc" => utc,
28
+ "geo" => geo,
29
+ "description" => description,
30
+ "avatar" => avatar,
31
+ "location" => location,
32
+ "subscribers" => subscribers,
33
+ "subscriptions" => subscriptions,
34
+ "postings" => postings,
35
+ "profile" => profile,
36
+ "website" => website
37
+ }
38
+ res
39
+ end
40
+
41
+ end
@@ -0,0 +1,56 @@
1
+ {
2
+ "service" : "", # Service Name.
3
+ "user" : { # User Info
4
+ "name" : "", # User Name
5
+ "real_name" : "" # Real name of user
6
+ "id" : "", # Unique User ID
7
+ "language": "", # Spoken language of user
8
+ "utc" : "", # UTC time offset of user
9
+ "geo" : "", # Latitude/Logitude User location
10
+ "description" : "" # User profile description
11
+ "avatar" : "", # Direct href to avatar image
12
+ "location": "", # Plain Language User location
13
+ "subscribers": "", # Number of subscribers
14
+ "subscriptions": "", # Number of subscriptions
15
+ "postings": "", # Number of postings made
16
+ "profile": "", # Href to user profile
17
+ "website": "", # Href to user website
18
+ }
19
+ "to_users" { # Attached link(s)
20
+ "0": { # Index of link
21
+ "name" : "", # User Name
22
+ "id" : "", # Unique User ID
23
+ "service" # Name of service/Domain hosting link
24
+ "title" : "", # Title of item
25
+ "thumbnail" : "", # Direct href to thumbnail for item
26
+ "href" : "", # Direct href to item
27
+ },
28
+ },
29
+ "links" { # Attached link(s)
30
+ "0": { # Index of link
31
+ "service" # Name of service/Domain hosting link
32
+ "title" : "", # Title of item
33
+ "thumbnail" : "", # Direct href to thumbnail for item
34
+ "href" : "", # Direct href to item
35
+ },
36
+ },
37
+ "id" : "", # Unique ID
38
+ "geo" : "", # Latitude/Logitude content creation location
39
+ "application" : "", # Application used to create this posting
40
+ "location" : "", # Plain Language content creation location
41
+ "date" : "", # Date posted
42
+ "source" : "", # User friendly link to content
43
+ "text" : "", # Microblog text / Video Title / Etc
44
+ "description" : "", # Full post text / Decription
45
+ "keywords" : "", # Related Keywords
46
+ "category" : "", # Category of content
47
+ "duration" : "", # Duration of content (if video)
48
+ "likes" : "", # Number of users who "liked" this
49
+ "dislikes" : "", # Number of users who "disliked" this
50
+ "favorites": "", # Number of users who "favorited" this
51
+ "comments": "", # Number of users who "commented" this
52
+ "rates": "", # Number of users who "rated" this
53
+ "rating": "", # Average "rating" of content
54
+ "min_rating": "", # Minimum "rating" of content
55
+ "max_rating": "", # Maximum "rating" of content
56
+ }
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
3
+
4
+ <title>KermitPFC-Core</title>
5
+ <link href="https:\/\/github.com\/danielmachado\/kermitpfc-core"/>
6
+ <updated>to-date</updated>
7
+ <author>
8
+ <name>KermitPFC</name>
9
+ </author>
10
+ <id>¿id del stream que servimos?(p.ej)</id>
11
+
12
+ <entry>
13
+ <title></title> <!-- título para cada message que enviemos.. -->
14
+ <link href="http://www.twitter.com/id_str"/>
15
+ <id>id_str</id>
16
+ <updated>created_at</updated>
17
+ <summary>
18
+ text
19
+ </summary>
20
+ {
21
+ "service" : "Twitter", # Service Name.
22
+ "user" : { # User Info
23
+ "name" : "screen_name", # User Name
24
+ "real_name" : "name" # Real name of user
25
+ "id" : "id_str", # Unique User ID
26
+ "language": "lang", # Spoken language of user
27
+ "utc" : "time_zone + utc_offset", # UTC time offset of user
28
+ "geo" : "", # Latitude/Logitude User location
29
+ "description" : "description" # User profile description
30
+ "avatar" : "profile_image_url_https", # Direct href to avatar image
31
+ "location": "location", # Plain Language User location
32
+ "subscribers": "followers_count", # Number of subscribers
33
+ "subscriptions": "friends_count", # Number of subscriptions
34
+ "postings": "statuses_count", # Number of postings made
35
+ "profile": "http://www.twitter.com/name", # Href to user profile
36
+ "website": "url", # Href to user website
37
+ }
38
+ "to_users" { # Attached link(s) // // Tantos como UserMentions tenga entities 0...N
39
+ "0": { # Index of link
40
+ "name" : "screen_name", # User Name
41
+ "id" : "id_str", # Unique User ID
42
+ "twitter/instagram/..." # Name of service/Domain hosting link
43
+ "title" : "mention/reply/retweet", # Title of item
44
+ "thumbnail" : "?", # Direct href to thumbnail for item
45
+ "href" : "http://www.service.com/name", # Direct href to item
46
+ },
47
+ },
48
+ "links" { # Attached link(s) //Media del status
49
+ "0": { # Index of link // Tantos como entities se necesiten 0...N
50
+ "instagram/lockerz/youtube/..." # Name of service/Domain hosting link
51
+ "photo/video/url.." : "", # Title of item
52
+ "thumbnail" : "url", # Direct href to thumbnail for item
53
+ "href" : "media_url", # Direct href to item
54
+ },
55
+ },
56
+ "id" : "id_str", # Unique ID
57
+ "geo" : "coordinates", # Latitude/Logitude content creation location
58
+ "application" : "source", # Application used to create this posting
59
+ "location" : "full_name+country", # Plain Language content creation location
60
+ "date" : "created_at", # Date posted
61
+ "source" : "http://www.twitter.com/id_str", # User friendly link to content
62
+ "text" : "text", # Microblog text / Video Title / Etc
63
+ "description" : "", # Full post text / Decription
64
+ "keywords" : "hashtags", # Related Keywords
65
+ "likes" : "retweet_count", # Number of users who "liked" this
66
+ "dislikes" : "", # Number of users who "disliked" this
67
+ "favorites": "favourites_count", # Number of users who "favorited" this
68
+ }
69
+ <georss:polygon>coordinates</georss:polygon>
70
+ <georss:featureTypeTag>place_type</georss:featureTypeTag>
71
+ <georss:featureName>name</georss:featureName>
72
+ </entry>
73
+ <!-- tantos entry como tweets se envíen -->
74
+ </feed>
@@ -0,0 +1,59 @@
1
+ sending message: {
2
+ "service":"Twitter",
3
+ "id":"209236208210022401",
4
+ "geo":null,
5
+ "application":"web",
6
+ "location":"A Pobra de Trives, Ourense , Spain",
7
+ "date":"Sun Jun 03 10:52:55 +0000 2012",
8
+ "source":"https://twitter.com/KermitPFC/status/209236208210022401",
9
+ "text":"#TestingKermitPFC @Minikisto @nataliagm888 echando a andar el experimento... http://t.co/LHsLea6s",
10
+ "description":null,
11
+ "keywords":"TestingKermitPFC, ",
12
+ "category":null,
13
+ "duration":null,
14
+ "likes":0,
15
+ "dislikes":null,
16
+ "favorites":null,
17
+ "comments":null,
18
+ "rates":null,
19
+ "rating":null,
20
+ "min_rating":null,
21
+ "max_rating":null,
22
+ "user":{
23
+ "name":"KermitPFC",
24
+ "real_name":"KermitPFC",
25
+ "id":"401402484",
26
+ "language":"es",
27
+ "utc":"Madrid + 3600",
28
+ "geo":null,
29
+ "description":"Soy una rana.",
30
+ "avatar":"https://si0.twimg.com/profile_images/1616971308/kermit_normal.jpg",
31
+ "location":"Oviedo, Asturias",
32
+ "subscribers":0,
33
+ "subscriptions":4,
34
+ "postings":3,
35
+ "profile":"https://twitter.com/#!/KermitPFC",
36
+ "website":"https://github.com/danielmachado/kermitpfc-core"},
37
+ "links":[{
38
+ "service":null,
39
+ "title":"photo",
40
+ "thumbnail":"http://p.twimg.com/AudbOQjCEAAMRKq.jpg",
41
+ "href":"http://t.co/LHsLea6s"}
42
+ ],
43
+ "to_users":[{
44
+ "name":"Minikisto",
45
+ "id":"105619316",
46
+ "service":"mention",
47
+ "title":null,
48
+ "thumbnail":null,
49
+ "href":null},
50
+ {
51
+ "name":"nataliagm888",
52
+ "id":"289913868",
53
+ "service":"mention",
54
+ "title":null,
55
+ "thumbnail":null,
56
+ "href":null
57
+ }
58
+ ]
59
+ }
@@ -0,0 +1,68 @@
1
+ <?xml version="1.0"?>
2
+ <rss version="2.0" xmlns:georss="http://www.georss.org/georss">
3
+ <channel>
4
+ <title>KermitPFC - Core - Stream</title>
5
+ <link>https:\/\/github.com\/danielmachado\/kermitpfc-core</link>
6
+ <description>Stream served by KermitPFC</description>
7
+ <pubDate>created_at</pubDate>
8
+ <item>
9
+ <title>text</title>
10
+ <link>http://www.twitter.com/id_str</link>
11
+ <description>
12
+ {
13
+ "service" : "Twitter", # Service Name.
14
+ "user" : { # User Info
15
+ "name" : "screen_name", # User Name
16
+ "real_name" : "name" # Real name of user
17
+ "id" : "id_str", # Unique User ID
18
+ "language": "lang", # Spoken language of user
19
+ "utc" : "time_zone + utc_offset", # UTC time offset of user
20
+ "geo" : "", # Latitude/Logitude User location
21
+ "description" : "description" # User profile description
22
+ "avatar" : "profile_image_url_https", # Direct href to avatar image
23
+ "location": "location", # Plain Language User location
24
+ "subscribers": "followers_count", # Number of subscribers
25
+ "subscriptions": "friends_count", # Number of subscriptions
26
+ "postings": "statuses_count", # Number of postings made
27
+ "profile": "http://www.twitter.com/name", # Href to user profile
28
+ "website": "url", # Href to user website
29
+ }
30
+ "to_users" { # Attached link(s) // // Tantos como UserMentions tenga entities 0...N
31
+ "0": { # Index of link
32
+ "name" : "screen_name", # User Name
33
+ "id" : "id_str", # Unique User ID
34
+ "twitter/instagram/..." # Name of service/Domain hosting link
35
+ "title" : "mention/reply/retweet", # Title of item
36
+ "thumbnail" : "?", # Direct href to thumbnail for item
37
+ "href" : "http://www.service.com/name", # Direct href to item
38
+ },
39
+ },
40
+ "links" { # Attached link(s) //Media del status
41
+ "0": { # Index of link // Tantos como entities se necesiten 0...N
42
+ "instagram/lockerz/youtube/..." # Name of service/Domain hosting link
43
+ "photo/video/url.." : "", # Title of item
44
+ "thumbnail" : "url", # Direct href to thumbnail for item
45
+ "href" : "media_url", # Direct href to item
46
+ },
47
+ },
48
+ "id" : "id_str", # Unique ID
49
+ "geo" : "coordinates", # Latitude/Logitude content creation location
50
+ "application" : "source", # Application used to create this posting
51
+ "location" : "full_name+country", # Plain Language content creation location
52
+ "date" : "created_at", # Date posted
53
+ "source" : "http://www.twitter.com/id_str", # User friendly link to content
54
+ "text" : "text", # Microblog text / Video Title / Etc
55
+ "description" : "", # Full post text / Decription
56
+ "keywords" : "hashtags", # Related Keywords
57
+ "likes" : "retweet_count", # Number of users who "liked" this
58
+ "dislikes" : "", # Number of users who "disliked" this
59
+ "favorites": "favourites_count", # Number of users who "favorited" this
60
+ }
61
+ </description>
62
+ <georss:polygon>coordinates</georss:polygon>
63
+ <georss:featureTypeTag>place_type</georss:featureTypeTag>
64
+ <georss:featureName>name</georss:featureName>
65
+ <pubDate>created_at</pubDate>
66
+ </item>
67
+ </channel>
68
+ </rss>