stormpath-rails 0.2.0 → 0.3.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.
data/README.md CHANGED
@@ -12,9 +12,11 @@ edit config/stormpath.yml
12
12
 
13
13
  export stormpath connection string to STORMPATH_URL (optional)
14
14
 
15
+ ```ruby
15
16
  class User < ActiveRecord:Base
16
17
  include Stormpath::Rails::Account
17
18
  end
19
+ ```
18
20
 
19
21
  add stormpath_url column to store stormpath UID.
20
22
 
@@ -3,17 +3,18 @@ module Stormpath
3
3
  module Generators
4
4
  class ConfigGenerator < ::Rails::Generators::Base
5
5
  def create_initializer_file
6
- create_file "config/stormpath.yml", "development:
6
+ create_file "config/stormpath.yml", "common:
7
7
  href: <%= ENV['STORMPATH_URL'] %>
8
- root: https://api.stormpath.com/v1/directories/<root directory uid>
8
+ application: https://api.stormpath.com/v1/applications/<application id>
9
+
10
+ development:
11
+ root: https://api.stormpath.com/v1/directories/<root directory id>
9
12
 
10
13
  test:
11
- href: <%= ENV['STORMPATH_URL'] %>
12
- root: https://api.stormpath.com/v1/directories/<root directory uid>
14
+ root: https://api.stormpath.com/v1/directories/<root directory id>
13
15
 
14
16
  production:
15
- href: <%= ENV['STORMPATH_URL'] %>
16
- root: https://api.stormpath.com/v1/directories/<root directory uid>
17
+ root: https://api.stormpath.com/v1/directories/<root directory id>
17
18
  "
18
19
  end
19
20
  end
@@ -1,15 +1,15 @@
1
- require "stormpath-rails/version"
2
- require "stormpath-rails/client"
3
- require "stormpath-rails/account"
1
+ require "stormpath/rails/version"
2
+ require "stormpath/rails/client"
3
+ require "stormpath/rails/account"
4
4
 
5
5
  module Stormpath
6
6
  module Rails
7
7
  class Config
8
- cattr_accessor :_variables
8
+ cattr_accessor :vars
9
9
 
10
10
  def self.[](name)
11
- self._variables ||= YAML.load(ERB.new(File.read("#{::Rails.root}/config/stormpath.yml")).result)[::Rails.env]
12
- self._variables[name.to_s]
11
+ self.vars ||= YAML.load(ERB.new(File.read("#{::Rails.root}/config/stormpath.yml")).result)
12
+ self.vars["common"].update(self.vars[::Rails.env])[name.to_s]
13
13
  end
14
14
  end
15
15
  end
@@ -21,7 +21,7 @@ module Stormpath
21
21
  begin
22
22
  account = Client.find_account(user.stormpath_url)
23
23
  (STORMPATH_FIELDS - [:password]).each { |field| self.send("#{field}=", account.send("get_#{field}")) }
24
- rescue => e
24
+ rescue ResourceError => error
25
25
  #somehow mark as data not loaded
26
26
  end
27
27
  end
@@ -5,7 +5,13 @@ include Stormpath::Resource
5
5
  module Stormpath
6
6
  module Rails
7
7
  class Client
8
- cattr_accessor :_connection
8
+ cattr_accessor :connection
9
+
10
+ def self.authenticate_account(login, password)
11
+ #TODO remove app href from config
12
+ auth_result = self.application.authenticate_account UsernamePasswordRequest.new(login, password)
13
+ auth_result.get_account
14
+ end
9
15
 
10
16
  def self.create_account!(attributes)
11
17
  account = self.ds.instantiate ::Account
@@ -36,8 +42,13 @@ module Stormpath
36
42
  end
37
43
 
38
44
  def self.ds
39
- self._connection ||= ::ClientApplicationBuilder.new.set_application_href(Config[:href]).build
40
- self._connection.client.data_store
45
+ self.connection ||= ::ClientApplicationBuilder.new.set_application_href(Config[:href]).build
46
+ self.connection.client.data_store
47
+ end
48
+
49
+ def self.application
50
+ self.connection ||= ::ClientApplicationBuilder.new.set_application_href(Config[:href]).build
51
+ self.connection.application
41
52
  end
42
53
  end
43
54
  end
@@ -1,5 +1,5 @@
1
1
  module Stormpath
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'stormpath-rails/version'
4
+ require 'stormpath/rails/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "stormpath-rails"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stormpath-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
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: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -57,9 +57,9 @@ files:
57
57
  - Rakefile
58
58
  - lib/generators/stormpath/rails/config/config_generator.rb
59
59
  - lib/stormpath-rails.rb
60
- - lib/stormpath-rails/account.rb
61
- - lib/stormpath-rails/client.rb
62
- - lib/stormpath-rails/version.rb
60
+ - lib/stormpath/rails/account.rb
61
+ - lib/stormpath/rails/client.rb
62
+ - lib/stormpath/rails/version.rb
63
63
  - stormpath-rails.gemspec
64
64
  homepage:
65
65
  licenses: []