rainforest 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -6
  3. data/.travis.yml +13 -1
  4. data/Gemfile +6 -0
  5. data/README.md +72 -21
  6. data/Rakefile +6 -13
  7. data/VERSION +1 -1
  8. data/bin/rainforest-console +1 -1
  9. data/gemfiles/default-with-activesupport.gemfile +8 -1
  10. data/gemfiles/json.gemfile +10 -2
  11. data/gemfiles/yajl.gemfile +10 -2
  12. data/lib/rainforest.rb +61 -240
  13. data/lib/rainforest/apibits/api_client.rb +28 -0
  14. data/lib/rainforest/apibits/api_endpoint.rb +11 -0
  15. data/lib/rainforest/apibits/api_list.rb +88 -0
  16. data/lib/rainforest/apibits/api_method.rb +95 -0
  17. data/lib/rainforest/apibits/api_object.rb +52 -0
  18. data/lib/rainforest/apibits/api_resource.rb +153 -0
  19. data/lib/rainforest/apibits/headers_builder.rb +47 -0
  20. data/lib/rainforest/apibits/params_builder.rb +27 -0
  21. data/lib/rainforest/apibits/path_builder.rb +38 -0
  22. data/lib/rainforest/apibits/requester.rb +104 -0
  23. data/lib/rainforest/apibits/util.rb +51 -0
  24. data/lib/rainforest/clients/default_client.rb +59 -0
  25. data/lib/rainforest/endpoints/client_stats_endpoint.rb +11 -0
  26. data/lib/rainforest/endpoints/environment_runs_endpoint.rb +11 -0
  27. data/lib/rainforest/endpoints/environments_endpoint.rb +48 -0
  28. data/lib/rainforest/endpoints/generator_rows_endpoint.rb +17 -0
  29. data/lib/rainforest/endpoints/generators_endpoint.rb +48 -0
  30. data/lib/rainforest/endpoints/integrations_endpoint.rb +33 -0
  31. data/lib/rainforest/endpoints/run_tests_endpoint.rb +20 -0
  32. data/lib/rainforest/endpoints/runs_endpoint.rb +48 -0
  33. data/lib/rainforest/endpoints/schedules_endpoint.rb +48 -0
  34. data/lib/rainforest/endpoints/site_environments_endpoint.rb +24 -0
  35. data/lib/rainforest/endpoints/sites_endpoint.rb +39 -0
  36. data/lib/rainforest/endpoints/tests_endpoint.rb +57 -0
  37. data/lib/rainforest/endpoints/users_endpoint.rb +48 -0
  38. data/lib/rainforest/errors/api_connection_error.rb +1 -1
  39. data/lib/rainforest/errors/api_error.rb +32 -1
  40. data/lib/rainforest/errors/authentication_error.rb +1 -1
  41. data/lib/rainforest/errors/rainforest_error.rb +2 -9
  42. data/lib/rainforest/resources/client_stats.rb +31 -0
  43. data/lib/rainforest/resources/environment.rb +73 -0
  44. data/lib/rainforest/resources/generator.rb +73 -0
  45. data/lib/rainforest/resources/integration.rb +52 -0
  46. data/lib/rainforest/resources/run.rb +93 -0
  47. data/lib/rainforest/resources/schedule.rb +63 -0
  48. data/lib/rainforest/resources/site.rb +53 -0
  49. data/lib/rainforest/resources/site_environment.rb +40 -0
  50. data/lib/rainforest/resources/test.rb +98 -0
  51. data/lib/rainforest/resources/user.rb +75 -0
  52. data/rainforest.gemspec +8 -6
  53. data/test/rainforest/api_client_test.rb +51 -0
  54. data/test/rainforest/api_endpoint_test.rb +13 -0
  55. data/test/rainforest/api_list_test.rb +49 -0
  56. data/test/rainforest/api_method_test.rb +78 -0
  57. data/test/rainforest/headers_builder_test.rb +28 -0
  58. data/test/rainforest/params_builder_test.rb +57 -0
  59. data/test/rainforest/path_builder_test.rb +50 -0
  60. data/test/rainforest/requester_test.rb +86 -0
  61. data/test/rainforest/util_test.rb +41 -19
  62. data/test/test_data.rb +72 -0
  63. data/test/test_helper.rb +17 -134
  64. metadata +99 -59
  65. data/CONTRIBUTORS +0 -2
  66. data/History.txt +0 -4
  67. data/LICENSE +0 -21
  68. data/lib/data/ca-certificates.crt +0 -3918
  69. data/lib/rainforest/api_operations/create.rb +0 -16
  70. data/lib/rainforest/api_operations/delete.rb +0 -11
  71. data/lib/rainforest/api_operations/list.rb +0 -16
  72. data/lib/rainforest/api_operations/update.rb +0 -61
  73. data/lib/rainforest/api_resource.rb +0 -33
  74. data/lib/rainforest/errors/invalid_request_error.rb +0 -10
  75. data/lib/rainforest/json.rb +0 -21
  76. data/lib/rainforest/list_object.rb +0 -35
  77. data/lib/rainforest/rainforest_object.rb +0 -165
  78. data/lib/rainforest/run.rb +0 -8
  79. data/lib/rainforest/singleton_api_resource.rb +0 -20
  80. data/lib/rainforest/util.rb +0 -100
  81. data/test/rainforest/api_resource_test.rb +0 -11
  82. data/test/rainforest/auth_test.rb +0 -24
  83. data/test/rainforest/list_object_test.rb +0 -7
  84. data/test/rainforest/metadata_test.rb +0 -7
  85. data/test/rainforest/run_test.rb +0 -36
@@ -0,0 +1,73 @@
1
+ module Rainforest
2
+ class Generator < ApiResource
3
+ attr_accessor :columns
4
+ attr_accessor :created_at
5
+ attr_accessor :description
6
+ attr_accessor :generator_type
7
+ attr_accessor :id
8
+ attr_accessor :name
9
+ attr_accessor :row_count
10
+
11
+ def self.all(params={}, headers={})
12
+ res = client.generators.all(params, headers)
13
+ res
14
+ end
15
+
16
+ def self.retrieve(generator_id, params={}, headers={})
17
+ res = client.generators.retrieve(generator_id, params, headers)
18
+ res
19
+ end
20
+
21
+ def self.update(generator_id, params={}, headers={})
22
+ res = client.generators.update(generator_id, params, headers)
23
+ res
24
+ end
25
+
26
+ def self.delete(generator_id, params={}, headers={})
27
+ res = client.generators.delete(generator_id, params, headers)
28
+ res
29
+ end
30
+
31
+ def self.create(params={}, headers={})
32
+ res = client.generators.create(params, headers)
33
+ res
34
+ end
35
+
36
+ def refresh(params={}, headers={})
37
+ res = client.generators.retrieve(id, params, headers)
38
+ self.refresh_from(res.json, res.api_method, res.client)
39
+ end
40
+
41
+ def update(params={}, headers={})
42
+ res = client.generators.update(id, params, headers)
43
+ self.refresh_from(res.json, res.api_method, res.client)
44
+ end
45
+
46
+ def save(params={}, headers={})
47
+ params = ParamsBuilder.merge(api_attributes, params)
48
+ res = client.generators.update(id, params, headers)
49
+ self.refresh_from(res.json, res.api_method, res.client)
50
+ end
51
+
52
+ def delete(params={}, headers={})
53
+ res = client.generators.delete(id, params, headers)
54
+ res
55
+ end
56
+
57
+ def rows()
58
+ GeneratorRowsEndpoint.new(client, self)
59
+ end
60
+
61
+ # Everything below here is used behind the scenes.
62
+ ApiResource.register_api_subclass(self, "generator")
63
+ @api_attributes = {
64
+ :columns => {},
65
+ :created_at => {},
66
+ :description => { :editable => true },
67
+ :generator_type => {},
68
+ :id => {},
69
+ :name => { :editable => true },
70
+ :row_count => {},
71
+ }
72
+ end
73
+ end
@@ -0,0 +1,52 @@
1
+ module Rainforest
2
+ class Integration < ApiResource
3
+ attr_accessor :created_at
4
+ attr_accessor :id
5
+ attr_accessor :recent_upstream_errors
6
+ attr_accessor :settings
7
+ attr_accessor :state
8
+ attr_accessor :type
9
+
10
+ def self.all(params={}, headers={})
11
+ res = client.integrations.all(params, headers)
12
+ res
13
+ end
14
+
15
+ def self.retrieve(integration_id, params={}, headers={})
16
+ res = client.integrations.retrieve(integration_id, params, headers)
17
+ res
18
+ end
19
+
20
+ def self.update(integration_id, params={}, headers={})
21
+ res = client.integrations.update(integration_id, params, headers)
22
+ res
23
+ end
24
+
25
+ def refresh(params={}, headers={})
26
+ res = client.integrations.retrieve(id, params, headers)
27
+ self.refresh_from(res.json, res.api_method, res.client)
28
+ end
29
+
30
+ def update(params={}, headers={})
31
+ res = client.integrations.update(id, params, headers)
32
+ self.refresh_from(res.json, res.api_method, res.client)
33
+ end
34
+
35
+ def save(params={}, headers={})
36
+ params = ParamsBuilder.merge(api_attributes, params)
37
+ res = client.integrations.update(id, params, headers)
38
+ self.refresh_from(res.json, res.api_method, res.client)
39
+ end
40
+
41
+ # Everything below here is used behind the scenes.
42
+ ApiResource.register_api_subclass(self, "integration")
43
+ @api_attributes = {
44
+ :created_at => {},
45
+ :id => {},
46
+ :recent_upstream_errors => {},
47
+ :settings => {},
48
+ :state => {},
49
+ :type => {},
50
+ }
51
+ end
52
+ end
@@ -0,0 +1,93 @@
1
+ module Rainforest
2
+ class Run < ApiResource
3
+ attr_accessor :browsers
4
+ attr_accessor :created_at
5
+ attr_accessor :current_progress
6
+ attr_accessor :description
7
+ attr_accessor :environment
8
+ attr_accessor :filters
9
+ attr_accessor :frontend_url
10
+ attr_accessor :id
11
+ attr_accessor :log_url
12
+ attr_accessor :real_cost_to_run
13
+ attr_accessor :result
14
+ attr_accessor :sample_test_titles
15
+ attr_accessor :state
16
+ attr_accessor :state_details
17
+ attr_accessor :stats
18
+ attr_accessor :timestamps
19
+ attr_accessor :total_failed_tests
20
+ attr_accessor :total_no_result_tests
21
+ attr_accessor :total_passed_tests
22
+ attr_accessor :total_tests
23
+
24
+ def self.all(params={}, headers={})
25
+ res = client.runs.all(params, headers)
26
+ res
27
+ end
28
+
29
+ def self.retrieve(run_id, params={}, headers={})
30
+ res = client.runs.retrieve(run_id, params, headers)
31
+ res
32
+ end
33
+
34
+ def self.delete(run_id, params={}, headers={})
35
+ res = client.runs.delete(run_id, params, headers)
36
+ res
37
+ end
38
+
39
+ def self.abort(run_id, params={}, headers={})
40
+ res = client.runs.delete(run_id, params, headers)
41
+ res
42
+ end
43
+
44
+ def self.create(params={}, headers={})
45
+ res = client.runs.create(params, headers)
46
+ res
47
+ end
48
+
49
+ def refresh(params={}, headers={})
50
+ res = client.runs.retrieve(id, params, headers)
51
+ self.refresh_from(res.json, res.api_method, res.client)
52
+ end
53
+
54
+ def delete(params={}, headers={})
55
+ res = client.runs.delete(id, params, headers)
56
+ res
57
+ end
58
+
59
+ def abort(params={}, headers={})
60
+ res = client.runs.delete(id, params, headers)
61
+ res
62
+ end
63
+
64
+ def tests()
65
+ RunTestsEndpoint.new(client, self)
66
+ end
67
+
68
+ # Everything below here is used behind the scenes.
69
+ ApiResource.register_api_subclass(self, "run")
70
+ @api_attributes = {
71
+ :browsers => {},
72
+ :created_at => {},
73
+ :current_progress => {},
74
+ :description => {},
75
+ :environment => {},
76
+ :filters => {},
77
+ :frontend_url => {},
78
+ :id => {},
79
+ :log_url => {},
80
+ :real_cost_to_run => {},
81
+ :result => {},
82
+ :sample_test_titles => {},
83
+ :state => {},
84
+ :state_details => {},
85
+ :stats => {},
86
+ :timestamps => {},
87
+ :total_failed_tests => {},
88
+ :total_no_result_tests => {},
89
+ :total_passed_tests => {},
90
+ :total_tests => {},
91
+ }
92
+ end
93
+ end
@@ -0,0 +1,63 @@
1
+ module Rainforest
2
+ class Schedule < ApiResource
3
+ attr_accessor :created_at
4
+ attr_accessor :filters
5
+ attr_accessor :id
6
+ attr_accessor :repeat_rules
7
+
8
+ def self.all(params={}, headers={})
9
+ res = client.schedules.all(params, headers)
10
+ res
11
+ end
12
+
13
+ def self.retrieve(schedule_id, params={}, headers={})
14
+ res = client.schedules.retrieve(schedule_id, params, headers)
15
+ res
16
+ end
17
+
18
+ def self.update(schedule_id, params={}, headers={})
19
+ res = client.schedules.update(schedule_id, params, headers)
20
+ res
21
+ end
22
+
23
+ def self.delete(schedule_id, params={}, headers={})
24
+ res = client.schedules.delete(schedule_id, params, headers)
25
+ res
26
+ end
27
+
28
+ def self.create(params={}, headers={})
29
+ res = client.schedules.create(params, headers)
30
+ res
31
+ end
32
+
33
+ def refresh(params={}, headers={})
34
+ res = client.schedules.retrieve(id, params, headers)
35
+ self.refresh_from(res.json, res.api_method, res.client)
36
+ end
37
+
38
+ def update(params={}, headers={})
39
+ res = client.schedules.update(id, params, headers)
40
+ self.refresh_from(res.json, res.api_method, res.client)
41
+ end
42
+
43
+ def save(params={}, headers={})
44
+ params = ParamsBuilder.merge(api_attributes, params)
45
+ res = client.schedules.update(id, params, headers)
46
+ self.refresh_from(res.json, res.api_method, res.client)
47
+ end
48
+
49
+ def delete(params={}, headers={})
50
+ res = client.schedules.delete(id, params, headers)
51
+ res
52
+ end
53
+
54
+ # Everything below here is used behind the scenes.
55
+ ApiResource.register_api_subclass(self, "schedule")
56
+ @api_attributes = {
57
+ :created_at => {},
58
+ :filters => { :editable => true },
59
+ :id => {},
60
+ :repeat_rules => { :editable => true },
61
+ }
62
+ end
63
+ end
@@ -0,0 +1,53 @@
1
+ module Rainforest
2
+ class Site < ApiResource
3
+ attr_accessor :created_at
4
+ attr_accessor :default
5
+ attr_accessor :id
6
+ attr_accessor :name
7
+
8
+ def self.all(params={}, headers={})
9
+ res = client.sites.all(params, headers)
10
+ res
11
+ end
12
+
13
+ def self.update(site_id, params={}, headers={})
14
+ res = client.sites.update(site_id, params, headers)
15
+ res
16
+ end
17
+
18
+ def self.delete(site_id, params={}, headers={})
19
+ res = client.sites.delete(site_id, params, headers)
20
+ res
21
+ end
22
+
23
+ def self.create(params={}, headers={})
24
+ res = client.sites.create(params, headers)
25
+ res
26
+ end
27
+
28
+ def update(params={}, headers={})
29
+ res = client.sites.update(id, params, headers)
30
+ self.refresh_from(res.json, res.api_method, res.client)
31
+ end
32
+
33
+ def save(params={}, headers={})
34
+ params = ParamsBuilder.merge(api_attributes, params)
35
+ res = client.sites.update(id, params, headers)
36
+ self.refresh_from(res.json, res.api_method, res.client)
37
+ end
38
+
39
+ def delete(params={}, headers={})
40
+ res = client.sites.delete(id, params, headers)
41
+ res
42
+ end
43
+
44
+ # Everything below here is used behind the scenes.
45
+ ApiResource.register_api_subclass(self, "site")
46
+ @api_attributes = {
47
+ :created_at => {},
48
+ :default => {},
49
+ :id => {},
50
+ :name => {},
51
+ }
52
+ end
53
+ end
@@ -0,0 +1,40 @@
1
+ module Rainforest
2
+ class SiteEnvironment < ApiResource
3
+ attr_accessor :created_at
4
+ attr_accessor :environment_id
5
+ attr_accessor :id
6
+ attr_accessor :site_id
7
+ attr_accessor :url
8
+
9
+ def self.all(params={}, headers={})
10
+ res = client.site_environments.all(params, headers)
11
+ res
12
+ end
13
+
14
+ def self.update(site_environment_id, params={}, headers={})
15
+ res = client.site_environments.update(site_environment_id, params, headers)
16
+ res
17
+ end
18
+
19
+ def update(params={}, headers={})
20
+ res = client.site_environments.update(id, params, headers)
21
+ self.refresh_from(res.json, res.api_method, res.client)
22
+ end
23
+
24
+ def save(params={}, headers={})
25
+ params = ParamsBuilder.merge(api_attributes, params)
26
+ res = client.site_environments.update(id, params, headers)
27
+ self.refresh_from(res.json, res.api_method, res.client)
28
+ end
29
+
30
+ # Everything below here is used behind the scenes.
31
+ ApiResource.register_api_subclass(self, "site_environment")
32
+ @api_attributes = {
33
+ :created_at => {},
34
+ :environment_id => {},
35
+ :id => {},
36
+ :site_id => {},
37
+ :url => {},
38
+ }
39
+ end
40
+ end
@@ -0,0 +1,98 @@
1
+ module Rainforest
2
+ class Test < ApiResource
3
+ attr_accessor :browsers
4
+ attr_accessor :created_at
5
+ attr_accessor :deletable
6
+ attr_accessor :deleted
7
+ attr_accessor :description
8
+ attr_accessor :dry_run_url
9
+ attr_accessor :editable
10
+ attr_accessor :elements
11
+ attr_accessor :has_been_dry_run
12
+ attr_accessor :id
13
+ attr_accessor :last_run
14
+ attr_accessor :result
15
+ attr_accessor :run_mode
16
+ attr_accessor :site_id
17
+ attr_accessor :start_uri
18
+ attr_accessor :step_count
19
+ attr_accessor :tags
20
+ attr_accessor :test_id
21
+ attr_accessor :title
22
+
23
+ def self.all(params={}, headers={})
24
+ res = client.tests.all(params, headers)
25
+ res
26
+ end
27
+
28
+ def self.retrieve(test_id, params={}, headers={})
29
+ res = client.tests.retrieve(test_id, params, headers)
30
+ res
31
+ end
32
+
33
+ def self.update(test_id, params={}, headers={})
34
+ res = client.tests.update(test_id, params, headers)
35
+ res
36
+ end
37
+
38
+ def self.delete(test_id, params={}, headers={})
39
+ res = client.tests.delete(test_id, params, headers)
40
+ res
41
+ end
42
+
43
+ def self.create(params={}, headers={})
44
+ res = client.tests.create(params, headers)
45
+ res
46
+ end
47
+
48
+ def refresh(params={}, headers={})
49
+ res = client.tests.retrieve(id, params, headers)
50
+ self.refresh_from(res.json, res.api_method, res.client)
51
+ end
52
+
53
+ def update(params={}, headers={})
54
+ res = client.tests.update(id, params, headers)
55
+ self.refresh_from(res.json, res.api_method, res.client)
56
+ end
57
+
58
+ def save(params={}, headers={})
59
+ params = ParamsBuilder.merge(api_attributes, params)
60
+ res = client.tests.update(id, params, headers)
61
+ self.refresh_from(res.json, res.api_method, res.client)
62
+ end
63
+
64
+ def delete(params={}, headers={})
65
+ res = client.tests.delete(id, params, headers)
66
+ res
67
+ end
68
+
69
+ def history(params={}, headers={})
70
+ res = client.tests.history(id, params, headers)
71
+ res
72
+ end
73
+
74
+ # Everything below here is used behind the scenes.
75
+ ApiResource.register_api_subclass(self, "test")
76
+ @api_attributes = {
77
+ :browsers => {},
78
+ :created_at => {},
79
+ :deletable => {},
80
+ :deleted => {},
81
+ :description => {},
82
+ :dry_run_url => {},
83
+ :editable => {},
84
+ :elements => { :editable => true },
85
+ :has_been_dry_run => {},
86
+ :id => {},
87
+ :last_run => {},
88
+ :result => {},
89
+ :run_mode => {},
90
+ :site_id => {},
91
+ :start_uri => { :editable => true },
92
+ :step_count => {},
93
+ :tags => { :editable => true },
94
+ :test_id => {},
95
+ :title => { :editable => true },
96
+ }
97
+ end
98
+ end