riaction 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +47 -26
  4. data/README.md +101 -52
  5. data/db/riaction.db +0 -0
  6. data/lib/riaction.rb +1 -1
  7. data/lib/riaction/constants.rb +10 -0
  8. data/lib/riaction/crud_event_callback.rb +3 -3
  9. data/lib/riaction/event_performer.rb +11 -16
  10. data/lib/riaction/profile_creation_callback.rb +1 -1
  11. data/lib/riaction/profile_creator.rb +13 -6
  12. data/lib/riaction/railtie.rb +4 -0
  13. data/lib/riaction/riaction.rb +302 -282
  14. data/lib/riaction/version.rb +1 -1
  15. data/lib/tasks/riaction.rake +16 -14
  16. data/riaction.gemspec +3 -2
  17. data/spec/event_performer_spec.rb +233 -0
  18. data/spec/profile_creation_spec.rb +135 -0
  19. data/spec/riaction_spec.rb +820 -253
  20. data/spec/spec_helper.rb +8 -1
  21. metadata +38 -71
  22. data/lib/riaction/iactionable/api.rb +0 -170
  23. data/lib/riaction/iactionable/connection.rb +0 -114
  24. data/lib/riaction/iactionable/error.rb +0 -17
  25. data/lib/riaction/iactionable/objects.rb +0 -27
  26. data/lib/riaction/iactionable/objects/achievement.rb +0 -29
  27. data/lib/riaction/iactionable/objects/awardable.rb +0 -50
  28. data/lib/riaction/iactionable/objects/challenge.rb +0 -27
  29. data/lib/riaction/iactionable/objects/goal.rb +0 -30
  30. data/lib/riaction/iactionable/objects/i_actionable_object.rb +0 -36
  31. data/lib/riaction/iactionable/objects/identifier.rb +0 -17
  32. data/lib/riaction/iactionable/objects/leaderboard.rb +0 -15
  33. data/lib/riaction/iactionable/objects/leaderboard_report.rb +0 -30
  34. data/lib/riaction/iactionable/objects/level.rb +0 -24
  35. data/lib/riaction/iactionable/objects/level_type.rb +0 -15
  36. data/lib/riaction/iactionable/objects/point_type.rb +0 -15
  37. data/lib/riaction/iactionable/objects/profile_achievements.rb +0 -20
  38. data/lib/riaction/iactionable/objects/profile_challenges.rb +0 -20
  39. data/lib/riaction/iactionable/objects/profile_goals.rb +0 -20
  40. data/lib/riaction/iactionable/objects/profile_level.rb +0 -20
  41. data/lib/riaction/iactionable/objects/profile_notifications.rb +0 -29
  42. data/lib/riaction/iactionable/objects/profile_points.rb +0 -29
  43. data/lib/riaction/iactionable/objects/profile_summary.rb +0 -37
  44. data/lib/riaction/iactionable/objects/progress.rb +0 -46
  45. data/lib/riaction/iactionable/settings.rb +0 -30
  46. data/spec/api_spec.rb +0 -314
  47. data/spec/connection_spec.rb +0 -111
  48. data/spec/get_achievements_api_response_spec.rb +0 -46
  49. data/spec/get_challenges_api_response_spec.rb +0 -42
  50. data/spec/get_goals_api_response_spec.rb +0 -46
  51. data/spec/get_leaderboard_api_response_spec.rb +0 -76
  52. data/spec/get_profile_achievements_api_response_spec.rb +0 -99
  53. data/spec/get_profile_api_response_spec.rb +0 -103
  54. data/spec/get_profile_challenges_api_response_spec.rb +0 -85
  55. data/spec/get_profile_goals_api_response_spec.rb +0 -89
  56. data/spec/get_profile_notifications_api_response_spec.rb +0 -75
  57. data/spec/get_profile_points_api_response_spec.rb +0 -67
  58. data/spec/settings_spec.rb +0 -52
@@ -1,85 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe "API response to get_profile_challenges" do
4
- before do
5
- @sample_response = {
6
- "Available" => [
7
- {
8
- "Key" => "hard_challenge",
9
- "Description" => "Do something hard 10 times and earn 200 points",
10
- "Name" => "Easy Challenge",
11
- "Progress" => [
12
- {
13
- "ConditionMetDate" => nil,
14
- "CurrentValue" => 9,
15
- "Description" => "Do something hard 10 times",
16
- "RequiredValue" => 10
17
- }
18
- ]
19
- }
20
- ],
21
- "Completed" => [
22
- {
23
- "Key" => "easy_challenge",
24
- "Description" => "Do something easy 5 times and earn 100 points",
25
- "Name" => "Easy Challenge",
26
- "Progress" => [
27
- {
28
- "ConditionMetDate" => "/Date(1275706032317-0600)/",
29
- "CurrentValue" => 5,
30
- "Description" => "Do something easy 5 times",
31
- "RequiredValue" => "5"
32
- }
33
- ],
34
- "AwardDate" => "/Date(1275706032317-0600)/"
35
- }
36
- ]
37
- }
38
- end
39
-
40
- it "should not raise error on wrapping in an object" do
41
- lambda { IActionable::Objects::ProfileChallenges.new(@sample_response) }.should_not raise_error
42
- end
43
-
44
- describe "when wrapped in an object" do
45
- before do
46
- @wrapped = IActionable::Objects::ProfileChallenges.new(Marshal.load(Marshal.dump(@sample_response)))
47
- end
48
-
49
- it "should contain ar array of available challenges" do
50
- @wrapped.available.should be_instance_of Array
51
- @wrapped.available.first.key.should == @sample_response["Available"][0]["Key"]
52
- @wrapped.available.first.description.should == @sample_response["Available"][0]["Description"]
53
- @wrapped.available.first.name.should == @sample_response["Available"][0]["Name"]
54
- @wrapped.available.first.award_date.should be_nil
55
- end
56
-
57
- it "should contain an array of progresses within each available challenge" do
58
- @wrapped.available.first.progress.should be_instance_of Array
59
- @wrapped.available.first.progress.first.condition_met_date.should be_nil
60
- @wrapped.available.first.progress.first.current_value.should == @sample_response["Available"][0]["Progress"][0]["CurrentValue"]
61
- @wrapped.available.first.progress.first.description.should == @sample_response["Available"][0]["Progress"][0]["Description"]
62
- @wrapped.available.first.progress.first.required_value.should == @sample_response["Available"][0]["Progress"][0]["RequiredValue"]
63
- end
64
-
65
- it "should contain ar array of completed challenges" do
66
- @wrapped.completed.should be_instance_of Array
67
- @wrapped.completed.first.key.should == @sample_response["Completed"][0]["Key"]
68
- @wrapped.completed.first.description.should == @sample_response["Completed"][0]["Description"]
69
- @wrapped.completed.first.name.should == @sample_response["Completed"][0]["Name"]
70
- @wrapped.completed.first.award_date.should_not be_nil
71
- end
72
-
73
- it "should contain an array of progresses within each completed achievement" do
74
- @wrapped.completed.first.progress.should be_instance_of Array
75
- @wrapped.completed.first.progress.first.condition_met_date.should_not be_nil
76
- @wrapped.completed.first.progress.first.current_value.should == @sample_response["Completed"][0]["Progress"][0]["CurrentValue"]
77
- @wrapped.completed.first.progress.first.description.should == @sample_response["Completed"][0]["Progress"][0]["Description"]
78
- @wrapped.completed.first.progress.first.required_value.should == @sample_response["Completed"][0]["Progress"][0]["RequiredValue"]
79
- end
80
-
81
- it "should convert to a hash equal to the original" do
82
- hash_including(@sample_response).should == @wrapped.to_hash
83
- end
84
- end
85
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe "API response to get_profile_goals" do
4
- before do
5
- @sample_response = {
6
- "Available" => [
7
- {
8
- "Key" => "hard_goal",
9
- "Description" => "Do something hard 10 times within a week and earn 200 points",
10
- "Name" => "Hard Goal",
11
- "Interval" => "Weekly",
12
- "Progress" => [
13
- {
14
- "ConditionMetDate" => nil,
15
- "CurrentValue" => 9,
16
- "Description" => "Do something hard 10 times",
17
- "RequiredValue" => 10
18
- }
19
- ]
20
- }
21
- ],
22
- "Completed" => [
23
- {
24
- "Key" => "easy_goal",
25
- "Description" => "Do something easy 5 times today and earn 100 points",
26
- "Name" => "Easy Goal",
27
- "Interval" => "Daily",
28
- "Progress" => [
29
- {
30
- "ConditionMetDate" => "/Date(1275706032317-0600)/",
31
- "CurrentValue" => 5,
32
- "Description" => "Do something easy 5 times",
33
- "RequiredValue" => "5"
34
- }
35
- ],
36
- "AwardDate" => "/Date(1275706032317-0600)/"
37
- }
38
- ]
39
- }
40
- end
41
-
42
- it "should not raise error on wrapping in an object" do
43
- lambda { IActionable::Objects::ProfileGoals.new(@sample_response) }.should_not raise_error
44
- end
45
-
46
- describe "when wrapped in an object" do
47
- before do
48
- @wrapped = IActionable::Objects::ProfileGoals.new(Marshal.load(Marshal.dump(@sample_response)))
49
- end
50
-
51
- it "should contain ar array of available goals" do
52
- @wrapped.available.should be_instance_of Array
53
- @wrapped.available.first.key.should == @sample_response["Available"][0]["Key"]
54
- @wrapped.available.first.description.should == @sample_response["Available"][0]["Description"]
55
- @wrapped.available.first.name.should == @sample_response["Available"][0]["Name"]
56
- @wrapped.available.first.interval.should == @sample_response["Available"][0]["Interval"]
57
- @wrapped.available.first.award_date.should be_nil
58
- end
59
-
60
- it "should contain an array of progresses within each available goals" do
61
- @wrapped.available.first.progress.should be_instance_of Array
62
- @wrapped.available.first.progress.first.condition_met_date.should be_nil
63
- @wrapped.available.first.progress.first.current_value.should == @sample_response["Available"][0]["Progress"][0]["CurrentValue"]
64
- @wrapped.available.first.progress.first.description.should == @sample_response["Available"][0]["Progress"][0]["Description"]
65
- @wrapped.available.first.progress.first.required_value.should == @sample_response["Available"][0]["Progress"][0]["RequiredValue"]
66
- end
67
-
68
- it "should contain ar array of completed goals" do
69
- @wrapped.completed.should be_instance_of Array
70
- @wrapped.completed.first.key.should == @sample_response["Completed"][0]["Key"]
71
- @wrapped.completed.first.description.should == @sample_response["Completed"][0]["Description"]
72
- @wrapped.completed.first.name.should == @sample_response["Completed"][0]["Name"]
73
- @wrapped.available.first.interval.should == @sample_response["Available"][0]["Interval"]
74
- @wrapped.completed.first.award_date.should_not be_nil
75
- end
76
-
77
- it "should contain an array of progresses within each completed goals" do
78
- @wrapped.completed.first.progress.should be_instance_of Array
79
- @wrapped.completed.first.progress.first.condition_met_date.should_not be_nil
80
- @wrapped.completed.first.progress.first.current_value.should == @sample_response["Completed"][0]["Progress"][0]["CurrentValue"]
81
- @wrapped.completed.first.progress.first.description.should == @sample_response["Completed"][0]["Progress"][0]["Description"]
82
- @wrapped.completed.first.progress.first.required_value.should == @sample_response["Completed"][0]["Progress"][0]["RequiredValue"]
83
- end
84
-
85
- it "should convert to a hash equal to the original" do
86
- hash_including(@sample_response).should == @wrapped.to_hash
87
- end
88
- end
89
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe "API response to get_profile_notifications" do
4
- before do
5
- @sample_response = {
6
- "Achievements" => {
7
- "Available" => [ ],
8
- "Completed" => [
9
- {
10
- "Description" => "Achieve the impossible",
11
- "ImageURL" => "http://iactionable.blob.core.windows.net/achievementimages/99999",
12
- "Key" => "mission_impossible",
13
- "Name" => "Mission Impossible"
14
- }
15
- ]
16
- },
17
- "Challenges" => {
18
- "Available" => [ ],
19
- "Completed" => [
20
- {
21
- "Description" => "Do something extraordinary",
22
- "Key" => "super_challenge",
23
- "Name" => "Super Challenge"
24
- }
25
- ]
26
- },
27
- "Goals" => {
28
- "Available" => [ ],
29
- "Completed" => [
30
- {
31
- "Description" => "Complete an awesome goal",
32
- "Key" => "awesome_goal",
33
- "Name" => "Awesome Goal"
34
- }
35
- ]
36
- },
37
- "Levels" => [
38
- {
39
- "LevelType" => {
40
- "Key" => "player_experience_points",
41
- "Name" => "Player Experience Points"
42
- },
43
- "Name" => "Noobie",
44
- "Number" => 2,
45
- "RequiredPoints" => 10
46
- }
47
- ],
48
- "Points" => [
49
- {
50
- "PointType" => {
51
- "Key" => "experience_points",
52
- "Name" => "Experience Points"
53
- },
54
- "Points" => 20,
55
- "Reason" => "Achieve the impossible"
56
- }
57
- ]
58
- }
59
- end
60
-
61
- it "should not raise error on wrapping in an object" do
62
- lambda { IActionable::Objects::ProfileNotifications.new(@sample_response) }.should_not raise_error
63
- end
64
-
65
- describe "when wrapped in an object" do
66
- before do
67
- @wrapped = IActionable::Objects::ProfileNotifications.new(Marshal.load(Marshal.dump(@sample_response)))
68
- end
69
-
70
-
71
- it "should convert to a hash equal to the original" do
72
- hash_including(@sample_response).should == @wrapped.to_hash
73
- end
74
- end
75
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe "API response to get_profile_points" do
4
- before do
5
- @sample_response = {
6
- "Level" => {
7
- "Current" =>
8
- {
9
- "Name" => "Beginner",
10
- "Number" => 1,
11
- "RequiredPoints" => 200,
12
- "LevelType" =>
13
- {
14
- "Key" => "player_experience_level",
15
- "Name" => "Experience Level"
16
- },
17
- },
18
- "Next" =>
19
- {
20
- "Name" => "Member",
21
- "Number" => 2,
22
- "RequiredPoints" => 300,
23
- "LevelType" =>
24
- {
25
- "Key" => "player_experience_level",
26
- "Name" => "Experience Level"
27
- },
28
- }
29
- },
30
- "PointType" => {
31
- "Key" => "experience_points",
32
- "Name" => "Experience Points"
33
- },
34
- "Points" => 200
35
- }
36
- end
37
-
38
- it "should not raise error on wrapping in an object" do
39
- lambda { IActionable::Objects::ProfilePoints.new(@sample_response) }.should_not raise_error
40
- end
41
-
42
- describe "when wrapped in an object" do
43
- before do
44
- @wrapped = IActionable::Objects::ProfilePoints.new(Marshal.load(Marshal.dump(@sample_response)))
45
- end
46
-
47
- it "should contain all the correct fields for a profile point summary" do
48
- @wrapped.points.should == @sample_response["Points"]
49
- @wrapped.point_type.key.should == @sample_response["PointType"]["Key"]
50
- @wrapped.point_type.name.should == @sample_response["PointType"]["Name"]
51
- @wrapped.level.current.name.should == @sample_response["Level"]["Current"]["Name"]
52
- @wrapped.level.current.number.should == @sample_response["Level"]["Current"]["Number"]
53
- @wrapped.level.current.required_points.should == @sample_response["Level"]["Current"]["RequiredPoints"]
54
- @wrapped.level.current.level_type.key.should == @sample_response["Level"]["Current"]["LevelType"]["Key"]
55
- @wrapped.level.current.level_type.name.should == @sample_response["Level"]["Current"]["LevelType"]["Name"]
56
- @wrapped.level.next.name.should == @sample_response["Level"]["Next"]["Name"]
57
- @wrapped.level.next.number.should == @sample_response["Level"]["Next"]["Number"]
58
- @wrapped.level.next.required_points.should == @sample_response["Level"]["Next"]["RequiredPoints"]
59
- @wrapped.level.next.level_type.key.should == @sample_response["Level"]["Next"]["LevelType"]["Key"]
60
- @wrapped.level.next.level_type.name.should == @sample_response["Level"]["Next"]["LevelType"]["Name"]
61
- end
62
-
63
- it "should convert to a hash equal to the original" do
64
- hash_including(@sample_response).should == @wrapped.to_hash
65
- end
66
- end
67
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe IActionable::Settings do
4
- before do
5
- @settings_hash = {
6
- :app_key => "12345",
7
- :api_key => "abcde",
8
- :version => "3"
9
- }
10
- end
11
-
12
- describe "with a valid input hash" do
13
- it "should initialize" do
14
- lambda { IActionable::Settings.new(@settings_hash) }.should_not raise_error
15
- end
16
- end
17
-
18
- describe "with an invalid input hash" do
19
- it "should not initialize from missing app key" do
20
- @settings_hash.delete(:app_key)
21
- lambda { IActionable::Settings.new(@settings_hash) }.should raise_error(IActionable::ConfigError)
22
- end
23
-
24
- it "should not initialize from missing api key" do
25
- @settings_hash.delete(:api_key)
26
- lambda { IActionable::Settings.new(@settings_hash) }.should raise_error(IActionable::ConfigError)
27
- end
28
-
29
- it "should not initialize from missing version" do
30
- @settings_hash.delete(:version)
31
- lambda { IActionable::Settings.new(@settings_hash) }.should raise_error(IActionable::ConfigError)
32
- end
33
- end
34
-
35
- describe "once initialized" do
36
- before do
37
- @settings = IActionable::Settings.new(@settings_hash)
38
- end
39
-
40
- it "should return the app key" do
41
- @settings.app_key.should == @settings_hash[:app_key]
42
- end
43
-
44
- it "should return the api key" do
45
- @settings.api_key.should == @settings_hash[:api_key]
46
- end
47
-
48
- it "should return the version" do
49
- @settings.version.should == @settings_hash[:version]
50
- end
51
- end
52
- end