platform 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.rvmrc +1 -1
  2. data/Gemfile.lock +100 -103
  3. data/app/models/platform/application.rb +109 -57
  4. data/app/models/platform/application_category.rb +41 -22
  5. data/app/models/platform/application_developer.rb +39 -22
  6. data/app/models/platform/application_filter.rb +41 -22
  7. data/app/models/platform/application_log.rb +48 -22
  8. data/app/models/platform/application_log_filter.rb +41 -22
  9. data/app/models/platform/application_metric.rb +42 -23
  10. data/app/models/platform/application_metric_filter.rb +41 -22
  11. data/app/models/platform/application_permission.rb +38 -22
  12. data/app/models/platform/application_permission_filter.rb +41 -22
  13. data/app/models/platform/application_usage_metric.rb +43 -22
  14. data/app/models/platform/application_usage_metric_filter.rb +41 -22
  15. data/app/models/platform/application_user.rb +40 -22
  16. data/app/models/platform/application_user_filter.rb +41 -22
  17. data/app/models/platform/base_filter.rb +41 -22
  18. data/app/models/platform/category.rb +43 -22
  19. data/app/models/platform/daily_application_metric.rb +41 -22
  20. data/app/models/platform/developer.rb +42 -22
  21. data/app/models/platform/developer_filter.rb +41 -22
  22. data/app/models/platform/forum_message.rb +40 -22
  23. data/app/models/platform/forum_message_filter.rb +41 -22
  24. data/app/models/platform/forum_topic.rb +41 -22
  25. data/app/models/platform/forum_topic_filter.rb +41 -22
  26. data/app/models/platform/logged_exception.rb +47 -22
  27. data/app/models/platform/logged_exception_filter.rb +41 -22
  28. data/app/models/platform/monthly_application_metric.rb +41 -22
  29. data/app/models/platform/permission.rb +38 -22
  30. data/app/models/platform/rating.rb +42 -22
  31. data/app/models/platform/rating_filter.rb +41 -22
  32. data/app/models/platform/rollup_log.rb +39 -22
  33. data/app/models/platform/rollup_log_filter.rb +41 -22
  34. data/app/models/platform/total_application_metric.rb +41 -22
  35. data/app/models/platform/weekly_application_metric.rb +41 -22
  36. data/app/views/platform/developer/api_explorer/index.html.erb +4 -4
  37. data/app/views/platform/developer/apps/index.html.erb +5 -2
  38. data/lib/platform/config.rb +4 -0
  39. data/lib/platform/version.rb +1 -1
  40. data/lib/tasks/dev.rake +154 -0
  41. data/platform.gemspec +5 -6
  42. data/test/dummy/config/application.rb +2 -2
  43. metadata +46 -60
data/.rvmrc CHANGED
@@ -1,2 +1,2 @@
1
- rvm 1.9.2@platform --create
1
+ rvm use 1.9.2@platform --create
2
2
  #rvm gemset import | grep -v -E 'already installed|default\.gems|^$'
@@ -1,159 +1,156 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- platform (3.1.3)
5
- acts_as_state_machine
6
- acts_as_tree
7
- coffee-script
4
+ platform (3.1.4)
5
+ aasm
6
+ acts_as_tree_rails3
8
7
  kaminari
9
- rails (>= 3.1.0)
8
+ rails (>= 3.2.3)
10
9
  sass
11
- tr8n (>= 3.1.1)
12
- will_filter (>= 3.1.2)
10
+ tr8n (>= 3.2.3)
11
+ will_filter (>= 3.1.6)
13
12
 
14
13
  GEM
15
14
  remote: http://rubygems.org/
16
15
  specs:
17
- actionmailer (3.1.0)
18
- actionpack (= 3.1.0)
19
- mail (~> 2.3.0)
20
- actionpack (3.1.0)
21
- activemodel (= 3.1.0)
22
- activesupport (= 3.1.0)
16
+ aasm (3.0.4)
17
+ activerecord
18
+ actionmailer (3.2.3)
19
+ actionpack (= 3.2.3)
20
+ mail (~> 2.4.4)
21
+ actionpack (3.2.3)
22
+ activemodel (= 3.2.3)
23
+ activesupport (= 3.2.3)
23
24
  builder (~> 3.0.0)
24
25
  erubis (~> 2.7.0)
25
- i18n (~> 0.6)
26
- rack (~> 1.3.2)
27
- rack-cache (~> 1.0.3)
28
- rack-mount (~> 0.8.2)
26
+ journey (~> 1.0.1)
27
+ rack (~> 1.4.0)
28
+ rack-cache (~> 1.2)
29
29
  rack-test (~> 0.6.1)
30
- sprockets (~> 2.0.0)
31
- activemodel (3.1.0)
32
- activesupport (= 3.1.0)
33
- bcrypt-ruby (~> 3.0.0)
30
+ sprockets (~> 2.1.2)
31
+ activemodel (3.2.3)
32
+ activesupport (= 3.2.3)
34
33
  builder (~> 3.0.0)
35
- i18n (~> 0.6)
36
- activerecord (3.1.0)
37
- activemodel (= 3.1.0)
38
- activesupport (= 3.1.0)
39
- arel (~> 2.2.1)
34
+ activerecord (3.2.3)
35
+ activemodel (= 3.2.3)
36
+ activesupport (= 3.2.3)
37
+ arel (~> 3.0.2)
40
38
  tzinfo (~> 0.3.29)
41
- activeresource (3.1.0)
42
- activemodel (= 3.1.0)
43
- activesupport (= 3.1.0)
44
- activesupport (3.1.0)
39
+ activeresource (3.2.3)
40
+ activemodel (= 3.2.3)
41
+ activesupport (= 3.2.3)
42
+ activesupport (3.2.3)
43
+ i18n (~> 0.6)
45
44
  multi_json (~> 1.0)
46
- acts_as_state_machine (2.2.0)
47
- activerecord (>= 2.1)
48
- acts_as_tree (0.1.1)
49
- arel (2.2.1)
50
- bcrypt-ruby (3.0.1)
45
+ acts_as_tree_rails3 (0.1.0)
46
+ addressable (2.2.7)
47
+ arel (3.0.2)
51
48
  builder (3.0.0)
52
- capybara (1.1.1)
49
+ capybara (1.1.2)
53
50
  mime-types (>= 1.16)
54
51
  nokogiri (>= 1.3.3)
55
52
  rack (>= 1.0.0)
56
53
  rack-test (>= 0.5.4)
57
54
  selenium-webdriver (~> 2.0)
58
55
  xpath (~> 0.1.4)
59
- childprocess (0.2.2)
56
+ childprocess (0.3.1)
60
57
  ffi (~> 1.0.6)
61
- coderay (0.9.8)
58
+ coderay (1.0.6)
62
59
  coffee-script (2.2.0)
63
60
  coffee-script-source
64
61
  execjs
65
- coffee-script-source (1.1.2)
66
- database_cleaner (0.6.7)
62
+ coffee-script-source (1.3.1)
63
+ database_cleaner (0.7.2)
67
64
  diff-lcs (1.1.3)
68
65
  erubis (2.7.0)
69
- execjs (1.2.9)
66
+ execjs (1.3.0)
70
67
  multi_json (~> 1.0)
71
- factory_girl (2.1.2)
72
- activesupport
73
- ffi (1.0.9)
68
+ factory_girl (3.1.0)
69
+ activesupport (>= 3.0.0)
70
+ ffi (1.0.11)
74
71
  hike (1.2.1)
75
72
  i18n (0.6.0)
76
- json_pure (1.6.1)
77
- kaminari (0.12.4)
78
- rails (>= 3.0.0)
79
- mail (2.3.0)
73
+ journey (1.0.3)
74
+ json (1.6.6)
75
+ kaminari (0.13.0)
76
+ actionpack (>= 3.0.0)
77
+ activesupport (>= 3.0.0)
78
+ railties (>= 3.0.0)
79
+ libwebsocket (0.1.3)
80
+ addressable
81
+ mail (2.4.4)
80
82
  i18n (>= 0.4.0)
81
83
  mime-types (~> 1.16)
82
84
  treetop (~> 1.4.8)
83
85
  memcache-client (1.8.5)
84
- method_source (0.6.6)
85
- ruby_parser (~> 2.0.5)
86
- mime-types (1.16)
87
- multi_json (1.0.3)
88
- nokogiri (1.5.0)
89
- polyglot (0.3.2)
90
- pry (0.9.6.2)
91
- coderay (~> 0.9.8)
92
- method_source (~> 0.6.5)
93
- ruby_parser (~> 2.0.5)
94
- slop (~> 2.1.0)
95
- rack (1.3.4)
96
- rack-cache (1.0.3)
86
+ method_source (0.7.1)
87
+ mime-types (1.18)
88
+ multi_json (1.2.0)
89
+ nokogiri (1.5.2)
90
+ polyglot (0.3.3)
91
+ pry (0.9.8.4)
92
+ coderay (~> 1.0.5)
93
+ method_source (~> 0.7.1)
94
+ slop (>= 2.4.4, < 3)
95
+ rack (1.4.1)
96
+ rack-cache (1.2)
97
97
  rack (>= 0.4)
98
- rack-mount (0.8.3)
99
- rack (>= 1.0.0)
100
98
  rack-ssl (1.3.2)
101
99
  rack
102
100
  rack-test (0.6.1)
103
101
  rack (>= 1.0)
104
- rails (3.1.0)
105
- actionmailer (= 3.1.0)
106
- actionpack (= 3.1.0)
107
- activerecord (= 3.1.0)
108
- activeresource (= 3.1.0)
109
- activesupport (= 3.1.0)
102
+ rails (3.2.3)
103
+ actionmailer (= 3.2.3)
104
+ actionpack (= 3.2.3)
105
+ activerecord (= 3.2.3)
106
+ activeresource (= 3.2.3)
107
+ activesupport (= 3.2.3)
110
108
  bundler (~> 1.0)
111
- railties (= 3.1.0)
112
- railties (3.1.0)
113
- actionpack (= 3.1.0)
114
- activesupport (= 3.1.0)
109
+ railties (= 3.2.3)
110
+ railties (3.2.3)
111
+ actionpack (= 3.2.3)
112
+ activesupport (= 3.2.3)
115
113
  rack-ssl (~> 1.3.2)
116
114
  rake (>= 0.8.7)
117
115
  rdoc (~> 3.4)
118
116
  thor (~> 0.14.6)
119
- rake (0.9.2)
120
- rdoc (3.9.4)
117
+ rake (0.9.2.2)
118
+ rdoc (3.12)
119
+ json (~> 1.4)
121
120
  rr (1.0.4)
122
- rspec (2.6.0)
123
- rspec-core (~> 2.6.0)
124
- rspec-expectations (~> 2.6.0)
125
- rspec-mocks (~> 2.6.0)
126
- rspec-core (2.6.4)
127
- rspec-expectations (2.6.0)
128
- diff-lcs (~> 1.1.2)
129
- rspec-mocks (2.6.0)
130
- rspec-rails (2.6.1)
131
- actionpack (~> 3.0)
132
- activesupport (~> 3.0)
133
- railties (~> 3.0)
134
- rspec (~> 2.6.0)
135
- ruby_parser (2.0.6)
136
- sexp_processor (~> 3.0)
137
- rubyzip (0.9.4)
138
- sass (3.1.10)
139
- selenium-webdriver (2.7.0)
140
- childprocess (>= 0.2.1)
141
- ffi (>= 1.0.7)
142
- json_pure
121
+ rspec (2.9.0)
122
+ rspec-core (~> 2.9.0)
123
+ rspec-expectations (~> 2.9.0)
124
+ rspec-mocks (~> 2.9.0)
125
+ rspec-core (2.9.0)
126
+ rspec-expectations (2.9.1)
127
+ diff-lcs (~> 1.1.3)
128
+ rspec-mocks (2.9.0)
129
+ rspec-rails (2.9.0)
130
+ actionpack (>= 3.0)
131
+ activesupport (>= 3.0)
132
+ railties (>= 3.0)
133
+ rspec (~> 2.9.0)
134
+ rubyzip (0.9.7)
135
+ sass (3.1.15)
136
+ selenium-webdriver (2.21.0)
137
+ childprocess (>= 0.2.5)
138
+ ffi (~> 1.0)
139
+ libwebsocket (~> 0.1.3)
140
+ multi_json (~> 1.0)
143
141
  rubyzip
144
- sexp_processor (3.0.7)
145
- slop (2.1.0)
146
- sprockets (2.0.2)
142
+ slop (2.4.4)
143
+ sprockets (2.1.2)
147
144
  hike (~> 1.2)
148
145
  rack (~> 1.0)
149
146
  tilt (~> 1.1, != 1.3.0)
150
- sqlite3 (1.3.4)
147
+ sqlite3 (1.3.5)
151
148
  steak (2.0.0)
152
149
  capybara (>= 1.0.0)
153
150
  rspec-rails (>= 2.5.0)
154
151
  thor (0.14.6)
155
152
  tilt (1.3.3)
156
- tr8n (3.1.4)
153
+ tr8n (3.2.3)
157
154
  coffee-script
158
155
  kaminari
159
156
  rails (>= 3.1.0)
@@ -162,8 +159,8 @@ GEM
162
159
  treetop (1.4.10)
163
160
  polyglot
164
161
  polyglot (>= 0.3.1)
165
- tzinfo (0.3.30)
166
- will_filter (3.1.3)
162
+ tzinfo (0.3.33)
163
+ will_filter (3.1.6)
167
164
  coffee-script
168
165
  kaminari
169
166
  rails (>= 3.1.0)
@@ -1,31 +1,81 @@
1
- #--
2
- # Copyright (c) 2011 Michael Berkovich
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
1
+ #--
2
+ # Copyright (c) 2010-2012 Michael Berkovich
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+ #-- Platform::Application Schema Information
25
+ #
26
+ # Table name: platform_applications
27
+ #
28
+ # id INTEGER not null, primary key
29
+ # developer_id integer
30
+ # name varchar(255)
31
+ # description text
32
+ # state varchar(255) default = new
33
+ # locale varchar(255)
34
+ # url varchar(255)
35
+ # site_domain varchar(255)
36
+ # support_url varchar(255)
37
+ # callback_url varchar(255)
38
+ # contact_email varchar(255)
39
+ # privacy_policy_url varchar(255)
40
+ # terms_of_service_url varchar(255)
41
+ # permissions varchar(255)
42
+ # key varchar(255)
43
+ # secret varchar(255)
44
+ # icon_id integer
45
+ # logo_id integer
46
+ # canvas_name varchar(255)
47
+ # canvas_url varchar(255)
48
+ # auto_resize boolean
49
+ # auto_login boolean
50
+ # mobile_application_type varchar(255)
51
+ # ios_bundle_id varchar(255)
52
+ # itunes_app_store_id varchar(255)
53
+ # android_key_hash varchar(255)
54
+ # rank integer
55
+ # auto_signin boolean
56
+ # deauthorize_callback_url varchar(255)
57
+ # version varchar(255)
58
+ # api_version varchar(255)
59
+ # parent_id integer
60
+ # created_at datetime
61
+ # updated_at datetime
62
+ #
63
+ # Indexes
64
+ #
65
+ # index_platform_applications_on_parent_id (parent_id)
66
+ # index_platform_applications_on_key (key) UNIQUE
67
+ # index_platform_applications_on_developer_id (developer_id)
68
+ #
69
+ #++
23
70
 
24
71
  class Platform::Application < ActiveRecord::Base
25
72
  set_table_name :platform_applications
26
73
 
27
74
  # useful methods - should be public
28
75
  include Platform::SimpleStringPermissions
76
+ # include ActiveRecord::Acts:Tree
77
+ include AASM
78
+
29
79
  acts_as_tree :order => "version"
30
80
 
31
81
  belongs_to :developer, :class_name => "Platform::Developer"
@@ -51,50 +101,47 @@ class Platform::Application < ActiveRecord::Base
51
101
  URL_REGEX = /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i
52
102
  validates_format_of :url, :with => URL_REGEX, :allow_blank=>true
53
103
  validates_format_of :support_url, :with => URL_REGEX, :allow_blank=>true
54
- validates_format_of :callback_url, :with => URL_REGEX, :allow_blank=>true
55
- validates_format_of :support_url, :with => URL_REGEX, :allow_blank=>true
56
104
  validates_format_of :privacy_policy_url, :with => URL_REGEX, :allow_blank=>true
57
105
  validates_format_of :terms_of_service_url, :with => URL_REGEX, :allow_blank=>true
58
- validates_format_of :canvas_url, :with => URL_REGEX, :allow_blank=>true
59
106
 
60
107
  attr_accessor :token_callback_url
61
108
 
62
- acts_as_state_machine :initial => :new
63
-
64
- state :new
65
- state :submitted
66
- state :approved
67
- state :rejected
68
- state :blocked
69
- state :deprecated
70
-
71
- event :submit do
72
- transitions :from => :new, :to => :submitted
73
- transitions :from => :rejected, :to => :submitted
74
- end
109
+ aasm :column => :state do
110
+ state :new, :initial => true
111
+ state :submitted
112
+ state :approved
113
+ state :rejected
114
+ state :blocked
115
+ state :deprecated
116
+
117
+ event :submit do
118
+ transitions :from => :new, :to => :submitted
119
+ transitions :from => :rejected, :to => :submitted
120
+ end
75
121
 
76
- event :deprecate do
77
- transitions :from => :approved, :to => :deprecated
78
- end
79
-
80
- event :block do
81
- transitions :from => :new, :to => :blocked
82
- transitions :from => :submitted, :to => :blocked
83
- transitions :from => :approved, :to => :blocked
84
- transitions :from => :rejected, :to => :blocked
85
- end
122
+ event :deprecate do
123
+ transitions :from => :approved, :to => :deprecated
124
+ end
125
+
126
+ event :block do
127
+ transitions :from => :new, :to => :blocked
128
+ transitions :from => :submitted, :to => :blocked
129
+ transitions :from => :approved, :to => :blocked
130
+ transitions :from => :rejected, :to => :blocked
131
+ end
86
132
 
87
- event :unblock do
88
- transitions :from => :blocked, :to => :new
89
- end
133
+ event :unblock do
134
+ transitions :from => :blocked, :to => :new
135
+ end
90
136
 
91
- event :approve do
92
- transitions :from => :new, :to => :approved
93
- transitions :from => :submitted, :to => :approved
94
- end
137
+ event :approve do
138
+ transitions :from => :new, :to => :approved
139
+ transitions :from => :submitted, :to => :approved
140
+ end
95
141
 
96
- event :reject do
97
- transitions :from => :submitted, :to => :rejected
142
+ event :reject do
143
+ transitions :from => :submitted, :to => :rejected
144
+ end
98
145
  end
99
146
 
100
147
  def self.for(client_id)
@@ -375,6 +422,11 @@ class Platform::Application < ActiveRecord::Base
375
422
  end
376
423
  end
377
424
 
425
+ def oauth_url
426
+ protocol = Platform::Config.env == "development" ? 'http' : 'https'
427
+ "#{protocol}://#{Platform::Config.site_base_url}/platform/oauth/authorize?client_id=#{key}&response_type=token&display=web&redirect_url=#{CGI.escape(callback_url || '')}"
428
+ end
429
+
378
430
  protected
379
431
 
380
432
  def generate_keys