paths_of_glory 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.md +73 -0
- data/Rakefile +43 -0
- data/achievement_system.gemspec +65 -0
- data/app/models/achievement.rb +73 -0
- data/app/models/achievements.rb +36 -0
- data/generators/achievement/USAGE +0 -0
- data/generators/achievement/achievement_generator.rb +32 -0
- data/generators/achievement/templates/achievement.rb +19 -0
- data/generators/achievement/templates/achievement_observer.rb +7 -0
- data/generators/paths_of_glory/USAGE +5 -0
- data/generators/paths_of_glory/paths_of_glory_generator.rb +30 -0
- data/generators/paths_of_glory/templates/20100311101933_create_achievements.rb +16 -0
- data/rails/init.rb +1 -0
- data/spec/achievement_generator_spec.rb +50 -0
- data/spec/achievement_spec.rb +102 -0
- data/spec/blueprints.rb +6 -0
- data/spec/database.yml +21 -0
- data/spec/debug.log +4061 -0
- data/spec/paths_of_glory_generator_spec.rb +38 -0
- data/spec/schema.rb +33 -0
- data/spec/spec_helper.rb +42 -0
- metadata +88 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_generator'
|
3
|
+
require 'rails_generator/scripts/generate'
|
4
|
+
|
5
|
+
describe PathsOfGloryGenerator do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@dirs = {}
|
9
|
+
@dirs['migration'] = fake_rails_root + '/db/migrate'
|
10
|
+
@dirs['config'] = fake_rails_root + '/config'
|
11
|
+
@dirs.each do |key, dir|
|
12
|
+
FileUtils.mkdir_p(dir)
|
13
|
+
end
|
14
|
+
@original_files = {}
|
15
|
+
@original_files['migration'] = file_list(@dirs['migration'])
|
16
|
+
@original_files['config'] = file_list(@dirs['config'])
|
17
|
+
Rails::Generator::Scripts::Generate.new.run(["paths_of_glory"], :destination => fake_rails_root, :backtrace => true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create the migration file" do
|
21
|
+
new_migration_file = (file_list(@dirs['migration']) - @original_files['migration']).first
|
22
|
+
"20100311101933_create_achievements.rb".should == File.basename(new_migration_file)
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
FileUtils.rm_r(fake_rails_root)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def fake_rails_root
|
31
|
+
File.join(File.dirname(__FILE__), 'spec', 'rails_root')
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_list(dir)
|
35
|
+
Dir.glob(File.join(dir, "*"))
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/schema.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 0) do
|
2
|
+
create_table "achievements", :force => true do |t|
|
3
|
+
t.string "type"
|
4
|
+
t.integer "level"
|
5
|
+
t.integer "user_id"
|
6
|
+
t.datetime "created_at"
|
7
|
+
t.datetime "updated_at"
|
8
|
+
t.boolean "notified", :default => false
|
9
|
+
end
|
10
|
+
|
11
|
+
create_table "users", :force => true do |t|
|
12
|
+
t.string "email", :null => false
|
13
|
+
t.string "encrypted_password", :limit => 40, :null => false
|
14
|
+
t.string "password_salt", :null => false
|
15
|
+
t.string "confirmation_token", :limit => 20
|
16
|
+
t.datetime "confirmed_at"
|
17
|
+
t.datetime "confirmation_sent_at"
|
18
|
+
t.string "reset_password_token", :limit => 20
|
19
|
+
t.string "remember_token", :limit => 20
|
20
|
+
t.datetime "remember_created_at"
|
21
|
+
t.integer "sign_in_count"
|
22
|
+
t.datetime "current_sign_in_at"
|
23
|
+
t.datetime "last_sign_in_at"
|
24
|
+
t.string "current_sign_in_ip"
|
25
|
+
t.string "last_sign_in_ip"
|
26
|
+
t.integer "failed_attempts", :default => 0
|
27
|
+
t.string "unlock_token", :limit => 20
|
28
|
+
t.datetime "locked_at"
|
29
|
+
t.datetime "created_at"
|
30
|
+
t.datetime "updated_at"
|
31
|
+
t.boolean "password_set", :default => false
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
begin
|
2
|
+
require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
|
3
|
+
rescue LoadError
|
4
|
+
puts "You need to install rspec in your base app"
|
5
|
+
exit
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/blueprints'
|
9
|
+
|
10
|
+
plugin_spec_dir = File.dirname(__FILE__)
|
11
|
+
ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
|
12
|
+
|
13
|
+
def load_schema
|
14
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
15
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
16
|
+
|
17
|
+
db_adapter = ENV['DB']
|
18
|
+
|
19
|
+
# no db passed, try one of these fine config-free DBs before bombing.
|
20
|
+
db_adapter ||=
|
21
|
+
begin
|
22
|
+
require 'rubygems'
|
23
|
+
require 'sqlite'
|
24
|
+
'sqlite'
|
25
|
+
rescue MissingSourceFile
|
26
|
+
begin
|
27
|
+
require 'sqlite3'
|
28
|
+
'sqlite3'
|
29
|
+
rescue MissingSourceFile
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if db_adapter.nil?
|
34
|
+
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
|
35
|
+
end
|
36
|
+
|
37
|
+
ActiveRecord::Base.establish_connection(config[db_adapter])
|
38
|
+
load(File.dirname(__FILE__) + "/schema.rb")
|
39
|
+
require File.dirname(__FILE__) + '/../rails/init.rb'
|
40
|
+
end
|
41
|
+
|
42
|
+
load_schema
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paths_of_glory
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Paul Campbell
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-20 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: paul@rslw.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.md
|
29
|
+
files:
|
30
|
+
- CHANGELOG
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- achievement_system.gemspec
|
34
|
+
- app/models/achievement.rb
|
35
|
+
- app/models/achievements.rb
|
36
|
+
- generators/achievement/USAGE
|
37
|
+
- generators/achievement/achievement_generator.rb
|
38
|
+
- generators/achievement/templates/achievement.rb
|
39
|
+
- generators/achievement/templates/achievement_observer.rb
|
40
|
+
- generators/paths_of_glory/USAGE
|
41
|
+
- generators/paths_of_glory/paths_of_glory_generator.rb
|
42
|
+
- generators/paths_of_glory/templates/20100311101933_create_achievements.rb
|
43
|
+
- rails/init.rb
|
44
|
+
- spec/achievement_generator_spec.rb
|
45
|
+
- spec/achievement_spec.rb
|
46
|
+
- spec/blueprints.rb
|
47
|
+
- spec/database.yml
|
48
|
+
- spec/debug.log
|
49
|
+
- spec/paths_of_glory_generator_spec.rb
|
50
|
+
- spec/schema.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
has_rdoc: false
|
53
|
+
homepage: http://www.github.com/paulca/paths_of_glory
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.6
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Getting you started on the road to achievements.
|
82
|
+
test_files:
|
83
|
+
- spec/achievement_generator_spec.rb
|
84
|
+
- spec/achievement_spec.rb
|
85
|
+
- spec/blueprints.rb
|
86
|
+
- spec/paths_of_glory_generator_spec.rb
|
87
|
+
- spec/schema.rb
|
88
|
+
- spec/spec_helper.rb
|