openstax_connect 0.0.7 → 0.0.8

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.
@@ -0,0 +1,33 @@
1
+ module OpenStax::Connect::Dev
2
+ class CreateUser
3
+ lev_routine
4
+
5
+ protected
6
+
7
+ def exec(inputs={})
8
+
9
+ username = inputs[:username]
10
+
11
+ if username.nil? || inputs[:ensure_no_errors]
12
+ loop do
13
+ break if !username.nil? && OpenStax::Connect::User.where(username: username).none?
14
+ username = "#{inputs[:username] || 'user'}#{rand(1000000)}"
15
+ end
16
+ end
17
+
18
+ outputs[:user] = OpenStax::Connect::User.create do |user|
19
+ user.first_name = inputs[:first_name]
20
+ user.last_name = inputs[:last_name]
21
+ user.username = username
22
+ user.openstax_uid = available_negative_openstax_uid
23
+ end
24
+
25
+ transfer_errors_from(outputs[:user], {type: :verbatim})
26
+ end
27
+
28
+ def available_negative_openstax_uid
29
+ (OpenStax::Connect::User.order("openstax_uid DESC").last.try(:openstax_uid) || 0) - 1
30
+ end
31
+
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Connect
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-07 00:00:00.000000000 Z
12
+ date: 2013-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -144,6 +144,7 @@ files:
144
144
  - app/helpers/openstax/connect/application_helper.rb
145
145
  - app/helpers/openstax/connect/sessions_helper.rb
146
146
  - app/models/openstax/connect/user.rb
147
+ - app/routines/openstax/connect/dev/create_user.rb
147
148
  - app/routines/openstax/connect/search_users.rb
148
149
  - app/views/layouts/openstax/connect/application.html.erb
149
150
  - app/views/openstax/connect/dev/users/login.html.erb
@@ -186,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
187
  version: '0'
187
188
  segments:
188
189
  - 0
189
- hash: 4441139255658210770
190
+ hash: -4136033706291355193
190
191
  required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  none: false
192
193
  requirements:
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  version: '0'
196
197
  segments:
197
198
  - 0
198
- hash: 4441139255658210770
199
+ hash: -4136033706291355193
199
200
  requirements: []
200
201
  rubyforge_project:
201
202
  rubygems_version: 1.8.25