riaction 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- riaction (0.0.3)
5
- activemodel
6
- activerecord
4
+ riaction (0.2.0)
5
+ activerecord (>= 3.0.0)
6
+ activesupport (>= 3.0.0)
7
7
  faraday
8
8
  faraday-stack
9
9
  rake
@@ -12,16 +12,16 @@ PATH
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- activemodel (3.1.1)
16
- activesupport (= 3.1.1)
15
+ activemodel (3.1.2)
16
+ activesupport (= 3.1.2)
17
17
  builder (~> 3.0.0)
18
18
  i18n (~> 0.6)
19
- activerecord (3.1.1)
20
- activemodel (= 3.1.1)
21
- activesupport (= 3.1.1)
19
+ activerecord (3.1.2)
20
+ activemodel (= 3.1.2)
21
+ activesupport (= 3.1.2)
22
22
  arel (~> 2.2.1)
23
23
  tzinfo (~> 0.3.29)
24
- activesupport (3.1.1)
24
+ activesupport (3.1.2)
25
25
  multi_json (~> 1.0)
26
26
  addressable (2.2.6)
27
27
  arel (2.2.1)
@@ -61,7 +61,7 @@ GEM
61
61
  rack-protection (~> 1.1, >= 1.1.2)
62
62
  tilt (~> 1.3, >= 1.3.3)
63
63
  tilt (1.3.3)
64
- tzinfo (0.3.30)
64
+ tzinfo (0.3.31)
65
65
  vegas (0.1.8)
66
66
  rack (>= 1.0.0)
67
67
 
data/README.md CHANGED
@@ -29,12 +29,11 @@ IActionable's API speaks in JSON, and here those responses are wrapped in simple
29
29
 
30
30
  While the API wrapper in riaction can be used directly (and I ought just pull it out as a separate gem), the rest of riaction consists of an "acts-as" style interface for your application's ActiveRecord models that leverages the API wrapper to associate your models with IActionable profiles and to have IActionable event logging be driven by your models' CRUD actions. riaction relies on Resque for tasking all of the requests made to IActionable's service.
31
31
 
32
- ### Initializing the API Wrapper ###
32
+ ### Generators ###
33
33
 
34
- Just as above, before the wrapper can be used (either directly or by the riaction interface) it needs to be initialized with your IActionable credentials. This can be done in a small rails initializer:
34
+ Riaction comes with a generator for creating a YAML file to contain your credentials for each environment of your application. The YAML file is necessary for riaction to run correctly in your rails app.
35
35
 
36
- I_ACTIONABLE_CREDS = (YAML.load_file("#{::Rails.root.to_s}/config/i_actionable.yml")[::Rails.env]).symbolize_keys!
37
- IAction::Api.init_settings(I_ACTIONABLE_CREDS)
36
+ rails g riaction development:12345:abcde production:54321:edcba
38
37
 
39
38
  ### Declaring A Model As A Profile ###
40
39
 
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a Yaml file in your config directory to contain your IActionable credentials.
3
+
4
+ Example:
5
+ rails generate riaction ENVIRONMENT:APP_KEY:API_KEY ENVIRONMENT:APP_KEY:API_KEY
6
+
7
+ This will create:
8
+ config/i_actionable.yml
@@ -0,0 +1,17 @@
1
+ class RiactionGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+ argument :credentials, :type => :array, :required => true, :banner => "environment:app_key:api_key environment:app_key:api_key"
4
+
5
+ def create_credentials_file
6
+ credentials.map!{|credential| { :env => credential[credential_regexp,1],
7
+ :app_key => credential[credential_regexp,2],
8
+ :api_key => credential[credential_regexp,3] } }
9
+ template "i_actionable.yml", "config/i_actionable.yml"
10
+ end
11
+
12
+ private
13
+
14
+ def credential_regexp
15
+ /^(\w+):(\w+):(\w+)$/
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ defaults: &defaults
2
+ version: 3
3
+
4
+ <% credentials.each do |credential| %>
5
+ <%= credential[:env] %>:
6
+ <<: *defaults
7
+ app_key: "<%= credential[:app_key] %>"
8
+ api_key: "<%= credential[:api_key] %>"
9
+
10
+ <% end %>
@@ -2,8 +2,22 @@ require 'rails'
2
2
 
3
3
  module Riaction
4
4
  class Railtie < Rails::Railtie
5
- rake_tasks do
6
- load "tasks/riaction.rake"
5
+ rake_tasks do
6
+ load "tasks/riaction.rake"
7
+ end
8
+
9
+ generators do
10
+ require "generators/riaction/riaction_generator"
11
+ end
12
+
13
+ initializer "riaction_railtie.configure_i_actionable_creds" do |app|
14
+ begin
15
+ IActionable::Api.init_settings(YAML.load_file("#{::Rails.root}/config/i_actionable.yml")[::Rails.env].symbolize_keys!)
16
+ rescue Errno::ENOENT => e
17
+ # warn of missing credentials file
18
+ rescue NoMethodError => e
19
+ # warn of malformed credentials file
7
20
  end
8
21
  end
22
+ end
9
23
  end
@@ -1,3 +1,3 @@
1
1
  module Riaction
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/riaction.gemspec CHANGED
@@ -18,16 +18,13 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib", "spec"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
24
21
 
25
22
  s.add_development_dependency "rspec", ">= 2.6"
26
23
 
27
24
  s.add_runtime_dependency "rake"
28
25
  s.add_runtime_dependency "faraday"
29
26
  s.add_runtime_dependency "faraday-stack"
30
- s.add_runtime_dependency "activemodel"
31
- s.add_runtime_dependency "activerecord"
27
+ s.add_runtime_dependency "activerecord", ">= 3.0.0"
28
+ s.add_runtime_dependency "activesupport", ">= 3.0.0"
32
29
  s.add_runtime_dependency "resque"
33
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-14 00:00:00.000000000Z
12
+ date: 2011-11-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2157024040 !ruby/object:Gem::Requirement
16
+ requirement: &2164355820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.6'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2157024040
24
+ version_requirements: *2164355820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2157014660 !ruby/object:Gem::Requirement
27
+ requirement: &2164355120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2157014660
35
+ version_requirements: *2164355120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday
38
- requirement: &2157014200 !ruby/object:Gem::Requirement
38
+ requirement: &2164354440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2157014200
46
+ version_requirements: *2164354440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday-stack
49
- requirement: &2157013740 !ruby/object:Gem::Requirement
49
+ requirement: &2164353680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,32 +54,32 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2157013740
57
+ version_requirements: *2164353680
58
58
  - !ruby/object:Gem::Dependency
59
- name: activemodel
60
- requirement: &2157013320 !ruby/object:Gem::Requirement
59
+ name: activerecord
60
+ requirement: &2164352440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: '0'
65
+ version: 3.0.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2157013320
68
+ version_requirements: *2164352440
69
69
  - !ruby/object:Gem::Dependency
70
- name: activerecord
71
- requirement: &2157012900 !ruby/object:Gem::Requirement
70
+ name: activesupport
71
+ requirement: &2164351820 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 3.0.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2157012900
79
+ version_requirements: *2164351820
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: resque
82
- requirement: &2157012480 !ruby/object:Gem::Requirement
82
+ requirement: &2164351340 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *2157012480
90
+ version_requirements: *2164351340
91
91
  description: Wrapper for IActionable's restful API and an "acts-as" style interface
92
92
  for models to behave as profiles and drive game events.
93
93
  email:
@@ -101,6 +101,9 @@ files:
101
101
  - Gemfile.lock
102
102
  - README.md
103
103
  - Rakefile
104
+ - lib/generators/riaction/USAGE
105
+ - lib/generators/riaction/riaction_generator.rb
106
+ - lib/generators/riaction/templates/i_actionable.yml
104
107
  - lib/riaction.rb
105
108
  - lib/riaction/iactionable/api.rb
106
109
  - lib/riaction/iactionable/connection.rb