auctionhouse 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +110 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +29 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/auctionhouse.gemspec +76 -0
- data/lib/auctionhouse.rb +6 -0
- data/lib/auctionhouse/generators.rb +0 -0
- data/lib/auctionhouse/tasks.rb +0 -0
- data/lib/generators/auctionhouse/README.markdown +2 -0
- data/lib/generators/auctionhouse/USAGE +17 -0
- data/lib/generators/auctionhouse/auctionhouse_generator.rb +39 -0
- data/lib/generators/auctionhouse/templates/controllers/bids_controller.rb +20 -0
- data/lib/generators/auctionhouse/templates/controllers/items_controller.rb +47 -0
- data/lib/generators/auctionhouse/templates/migrations/migration.rb +19 -0
- data/lib/generators/auctionhouse/templates/models/bid.rb +31 -0
- data/lib/generators/auctionhouse/templates/models/item.rb +37 -0
- data/spec/auctionhouse_spec.rb +0 -0
- data/test/helper.rb +18 -0
- data/test/test_auctionhouse.rb +7 -0
- metadata +141 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "rails", "~> 3.2.0"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "shoulda", ">= 0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.8.4"
|
15
|
+
gem "rspec"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.6)
|
5
|
+
actionpack (= 3.2.6)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.6)
|
8
|
+
activemodel (= 3.2.6)
|
9
|
+
activesupport (= 3.2.6)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.3)
|
17
|
+
activemodel (3.2.6)
|
18
|
+
activesupport (= 3.2.6)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.6)
|
21
|
+
activemodel (= 3.2.6)
|
22
|
+
activesupport (= 3.2.6)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.6)
|
26
|
+
activemodel (= 3.2.6)
|
27
|
+
activesupport (= 3.2.6)
|
28
|
+
activesupport (3.2.6)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
arel (3.0.2)
|
32
|
+
builder (3.0.0)
|
33
|
+
diff-lcs (1.1.3)
|
34
|
+
erubis (2.7.0)
|
35
|
+
git (1.2.5)
|
36
|
+
hike (1.2.1)
|
37
|
+
i18n (0.6.0)
|
38
|
+
jeweler (1.8.4)
|
39
|
+
bundler (~> 1.0)
|
40
|
+
git (>= 1.2.5)
|
41
|
+
rake
|
42
|
+
rdoc
|
43
|
+
journey (1.0.4)
|
44
|
+
json (1.7.3)
|
45
|
+
mail (2.4.4)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.19)
|
50
|
+
multi_json (1.3.6)
|
51
|
+
polyglot (0.3.3)
|
52
|
+
rack (1.4.1)
|
53
|
+
rack-cache (1.2)
|
54
|
+
rack (>= 0.4)
|
55
|
+
rack-ssl (1.3.2)
|
56
|
+
rack
|
57
|
+
rack-test (0.6.1)
|
58
|
+
rack (>= 1.0)
|
59
|
+
rails (3.2.6)
|
60
|
+
actionmailer (= 3.2.6)
|
61
|
+
actionpack (= 3.2.6)
|
62
|
+
activerecord (= 3.2.6)
|
63
|
+
activeresource (= 3.2.6)
|
64
|
+
activesupport (= 3.2.6)
|
65
|
+
bundler (~> 1.0)
|
66
|
+
railties (= 3.2.6)
|
67
|
+
railties (3.2.6)
|
68
|
+
actionpack (= 3.2.6)
|
69
|
+
activesupport (= 3.2.6)
|
70
|
+
rack-ssl (~> 1.3.2)
|
71
|
+
rake (>= 0.8.7)
|
72
|
+
rdoc (~> 3.4)
|
73
|
+
thor (>= 0.14.6, < 2.0)
|
74
|
+
rake (0.9.2.2)
|
75
|
+
rdoc (3.12)
|
76
|
+
json (~> 1.4)
|
77
|
+
rspec (2.11.0)
|
78
|
+
rspec-core (~> 2.11.0)
|
79
|
+
rspec-expectations (~> 2.11.0)
|
80
|
+
rspec-mocks (~> 2.11.0)
|
81
|
+
rspec-core (2.11.0)
|
82
|
+
rspec-expectations (2.11.1)
|
83
|
+
diff-lcs (~> 1.1.3)
|
84
|
+
rspec-mocks (2.11.1)
|
85
|
+
shoulda (3.0.1)
|
86
|
+
shoulda-context (~> 1.0.0)
|
87
|
+
shoulda-matchers (~> 1.0.0)
|
88
|
+
shoulda-context (1.0.0)
|
89
|
+
shoulda-matchers (1.0.0)
|
90
|
+
sprockets (2.1.3)
|
91
|
+
hike (~> 1.2)
|
92
|
+
rack (~> 1.0)
|
93
|
+
tilt (~> 1.1, != 1.3.0)
|
94
|
+
thor (0.15.4)
|
95
|
+
tilt (1.3.3)
|
96
|
+
treetop (1.4.10)
|
97
|
+
polyglot
|
98
|
+
polyglot (>= 0.3.1)
|
99
|
+
tzinfo (0.3.33)
|
100
|
+
|
101
|
+
PLATFORMS
|
102
|
+
ruby
|
103
|
+
|
104
|
+
DEPENDENCIES
|
105
|
+
bundler (~> 1.0.0)
|
106
|
+
jeweler (~> 1.8.4)
|
107
|
+
rails (~> 3.2.0)
|
108
|
+
rdoc (~> 3.12)
|
109
|
+
rspec
|
110
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Thomas Chen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= auctionhouse
|
2
|
+
|
3
|
+
Builds the auction-house back end models and controllers to allow for some sort
|
4
|
+
of user-contributed bidding system. Obviously, a rails app.
|
5
|
+
|
6
|
+
models:
|
7
|
+
item (has_many bids)
|
8
|
+
bid (belongs_to item)
|
9
|
+
|
10
|
+
controllers:
|
11
|
+
item : [show index edit post put destroy]
|
12
|
+
bid : [post put destroy]
|
13
|
+
|
14
|
+
|
15
|
+
== Contributing to auctionhouse
|
16
|
+
|
17
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
18
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
19
|
+
* Fork the project.
|
20
|
+
* Start a feature/bugfix branch.
|
21
|
+
* Commit and push until you are happy with your contribution.
|
22
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
23
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2012 Thomas Chen. See LICENSE.txt for
|
28
|
+
further details.
|
29
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "auctionhouse"
|
18
|
+
gem.homepage = "http://github.com/foxnewsnetwork/auctionhouse"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Simple macro used to generate out an online-auction platform. Currently in development.}
|
21
|
+
gem.description = %Q{Generates out a fully functional set of models, controllers, views, specs, and migrations for an operational auction site much like ebay or the millions of flash-sales sites out there. Currently in development.}
|
22
|
+
gem.email = "foxnewsnetwork@gmail.com"
|
23
|
+
gem.authors = ["Thomas Chen"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# require 'rcov/rcovtask'
|
36
|
+
# Rcov::RcovTask.new do |test|
|
37
|
+
# test.libs << 'test'
|
38
|
+
# test.pattern = 'test/**/test_*.rb'
|
39
|
+
# test.verbose = true
|
40
|
+
# test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
# end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rdoc/task'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "auctionhouse #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "auctionhouse"
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Thomas Chen"]
|
12
|
+
s.date = "2012-07-15"
|
13
|
+
s.description = "Generates out a fully functional set of models, controllers, views, specs, and migrations for an operational auction site much like ebay or the millions of flash-sales sites out there. Currently in development."
|
14
|
+
s.email = "foxnewsnetwork@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"auctionhouse.gemspec",
|
28
|
+
"lib/auctionhouse.rb",
|
29
|
+
"lib/auctionhouse/generators.rb",
|
30
|
+
"lib/auctionhouse/tasks.rb",
|
31
|
+
"lib/generators/auctionhouse/README.markdown",
|
32
|
+
"lib/generators/auctionhouse/USAGE",
|
33
|
+
"lib/generators/auctionhouse/auctionhouse_generator.rb",
|
34
|
+
"lib/generators/auctionhouse/templates/controllers/bids_controller.rb",
|
35
|
+
"lib/generators/auctionhouse/templates/controllers/items_controller.rb",
|
36
|
+
"lib/generators/auctionhouse/templates/migrations/migration.rb",
|
37
|
+
"lib/generators/auctionhouse/templates/models/bid.rb",
|
38
|
+
"lib/generators/auctionhouse/templates/models/item.rb",
|
39
|
+
"spec/auctionhouse_spec.rb",
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/test_auctionhouse.rb"
|
42
|
+
]
|
43
|
+
s.homepage = "http://github.com/foxnewsnetwork/auctionhouse"
|
44
|
+
s.licenses = ["MIT"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = "1.8.11"
|
47
|
+
s.summary = "Simple macro used to generate out an online-auction platform. Currently in development."
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<rails>, ["~> 3.2.0"])
|
54
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
56
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
58
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<rails>, ["~> 3.2.0"])
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<rails>, ["~> 3.2.0"])
|
69
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
71
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
73
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/lib/auctionhouse.rb
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Description:
|
2
|
+
A big macro for generating out a (currently simple) item-auction platform.
|
3
|
+
The current functionality is highly limited because I am still building it,
|
4
|
+
but eventually expect it to generate an ebay-like service with 1 command.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
rails generate auctionhouse Item
|
8
|
+
|
9
|
+
This will create:
|
10
|
+
app/controllers/items_controller.rb
|
11
|
+
app/controllers/item_bids_controller.rb
|
12
|
+
app/model/item.rb
|
13
|
+
app/model/item_bid.rb
|
14
|
+
db/migrate/auctionhouse_create_item.rb
|
15
|
+
|
16
|
+
This will modify:
|
17
|
+
config/routes.rb
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module Auctionhouse
|
4
|
+
class AuctionhouseGenerator < Rails::Generators::NamedBase
|
5
|
+
# Modules mixins
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
include Rails::Generators::ResourceHelpers
|
8
|
+
|
9
|
+
# Setup and description
|
10
|
+
source_root File.expand_path('../templates', __FILE__)
|
11
|
+
desc "Generates the model, controller, and migration given the NAME as well as " <<
|
12
|
+
"setups the routing to have a simplistic auction system."
|
13
|
+
|
14
|
+
def create_controllers
|
15
|
+
template "controllers/items_controller.rb", "app/controllers/#{file_name.pluralize}_controller.rb"
|
16
|
+
template "controllers/bids_controller.rb", "app/controllers/#{file_name}_bids_controller.rb"
|
17
|
+
end # create_controller
|
18
|
+
|
19
|
+
def create_models
|
20
|
+
template "models/item.rb", "app/models/#{file_name}.rb"
|
21
|
+
template "models/bid.rb", "app/models/#{file_name}_bid.rb"
|
22
|
+
end # create_models
|
23
|
+
|
24
|
+
def create_migration
|
25
|
+
migration_template "migrations/migration.rb", "db/migrate/auctionhouse_create_#{table_name}"
|
26
|
+
end # create_migration
|
27
|
+
|
28
|
+
def add_auctionhouse_routes
|
29
|
+
auctionhouse_routes = %Q(resources :#{plural_name} do
|
30
|
+
resources :#{singular_name}_bids, :only => [:create, :destroy, :update]
|
31
|
+
end # #{plural_name})
|
32
|
+
route auctionhouse_routes
|
33
|
+
end # add_auctionhouse_routes
|
34
|
+
|
35
|
+
def self.next_migration_number(data)
|
36
|
+
ActiveRecord::Generators::Base.next_migration_number(data)
|
37
|
+
end # next_migration_number
|
38
|
+
end # AuctionhouseGenerator
|
39
|
+
end # Auctionhouse
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class <%= class_name.pluralize %>Controller < ApplicationController
|
2
|
+
def create
|
3
|
+
@<%= singular_name %> = <%= class_name %>.find_by_id params[:<%= singular_name %>_id]
|
4
|
+
if @<%= singular_name %>.nil?
|
5
|
+
flash[:error] = t( :fail_<%= singular_name %>_bid_create )
|
6
|
+
else
|
7
|
+
@<%= singular_name %>.<%= singular_name %>_bid params[:<%= singular_name %>_bid]
|
8
|
+
flash[:success] = t( :success_<%= singular_name %>_bid_create )
|
9
|
+
end # if
|
10
|
+
redirect_to <%= singular_name %>_path @<%= singular_name %>
|
11
|
+
end # create
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
@<%= singular_name %> = <%= class_name %>.find_by_id params[ :<%= singular_name %>_id ]
|
15
|
+
@<%= singular_name %>_bid = <%= class_name %>Bid.find_by_id params[ :id ]
|
16
|
+
@<%= singular_name %>_bid.destroy
|
17
|
+
flash[:success] = t( :success_<%= singular_name %>_bid_destroy )
|
18
|
+
redirect_to <%= singular_name %>_path @<%= singular_name %>
|
19
|
+
end # destroy
|
20
|
+
end # <%= class_name.pluralize %>Controller
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class <%= class_name.pluralize %>Controller < ApplicationController
|
2
|
+
def show
|
3
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.find_by_id( params[:id] )
|
4
|
+
end # show
|
5
|
+
|
6
|
+
def index
|
7
|
+
# TODO: show less, paginate, or do something here
|
8
|
+
@<%= plural_name %> = <%= plural_name.singularize %>.all
|
9
|
+
end # index
|
10
|
+
|
11
|
+
def new
|
12
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.new
|
13
|
+
end # new
|
14
|
+
|
15
|
+
def edit
|
16
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.find_by_id( params[:id] )
|
17
|
+
end # edit
|
18
|
+
|
19
|
+
def create
|
20
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.new( params[:<%= plural_name.singularize %>] )
|
21
|
+
# TODO: i18n this junk!
|
22
|
+
if @<%= plural_name.singularize %>.save
|
23
|
+
flash[:success] = t( :success_<%= plural_name.singularize %>_create )
|
24
|
+
redirect_to item_path(@<%= plural_name.singularize %>)
|
25
|
+
else
|
26
|
+
flash[:error] = t( :fail_<%= plural_name.singularize %>_create )
|
27
|
+
redirect_to new_<%= plural_name.singularize %>_path
|
28
|
+
end # if save
|
29
|
+
end # create
|
30
|
+
|
31
|
+
def update
|
32
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.find_by_id( params[:id] )
|
33
|
+
if @<%= plural_name.singularize %>.update_attributes( params[:<%= plural_name.singularize %>] )
|
34
|
+
flash[:success] = t( :success_<%= plural_name.singularize %>_update )
|
35
|
+
else
|
36
|
+
flash[:error] = t( :fail_<%= plural_name.singularize %>_update )
|
37
|
+
end # if success update
|
38
|
+
redirect_to edit_<%= plural_name.singularize %>_path( @<%= plural_name.singularize %> )
|
39
|
+
end # update
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@<%= plural_name.singularize %> = <%= plural_name.singularize %>.find_by_id params[:id]
|
43
|
+
@<%= plural_name.singularize %>.destroy
|
44
|
+
flash[:success] = t( :success_<%= plural_name.singularize %>_destroy )
|
45
|
+
redirect_to root_path
|
46
|
+
end # destroy
|
47
|
+
end # <%= plural_name %>Controller
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AuctionHouseCreate<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:<%= table_name %>) do |t|
|
4
|
+
t.string :title, :null => false, :default => "Untitled"
|
5
|
+
t.description :text
|
6
|
+
t.decimal :quantity, :null => false, :default => 1.0
|
7
|
+
t.string :units, :null => false, :default => "unit"
|
8
|
+
t.timestamps
|
9
|
+
end # create_table
|
10
|
+
create_table( :<%= table_name.singularize %>_bids ) do |t|
|
11
|
+
t.integer :<%= table_name.singularize %>_id
|
12
|
+
t.decimal :price, :null => false, :default => 0.0
|
13
|
+
t.string :units, :null => false, :default => "USD"
|
14
|
+
t.timestamps
|
15
|
+
end # create_table
|
16
|
+
add_index :<%= table_name.singularize %>_bids, :<%= table_name %>_id
|
17
|
+
add_index :<%= table_name.singularize %>_bids, [:<%= table_name.singularize %>_id, :id], :unique => true
|
18
|
+
end # change
|
19
|
+
end # AuctionHouseCreate<%= table_name.camelize %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: <%= singular_name %>_bids
|
4
|
+
#
|
5
|
+
# created_at :datetime not null
|
6
|
+
# id :integer not null, primary key
|
7
|
+
# <%= singular_name %>_id :integer not null
|
8
|
+
# price :decimal default(0.0)
|
9
|
+
# units :string(255) default("USD")
|
10
|
+
# updated_at :datetime not null
|
11
|
+
#
|
12
|
+
|
13
|
+
class Bid < ActiveRecord::Base
|
14
|
+
# Attributes
|
15
|
+
attr_accessible :price, :units
|
16
|
+
|
17
|
+
# Relationships
|
18
|
+
belongs_to :<%= singular_name %>
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
def offer
|
23
|
+
price
|
24
|
+
end # price
|
25
|
+
|
26
|
+
def offer=(p)
|
27
|
+
price = price
|
28
|
+
end # price
|
29
|
+
|
30
|
+
|
31
|
+
end # Bid
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: <%= plural_name %>
|
4
|
+
#
|
5
|
+
# created_at :datetime not null
|
6
|
+
# description :text
|
7
|
+
# id :integer not null, primary key
|
8
|
+
# quantity :decimal default(1.0)
|
9
|
+
# title :string(255) default("No title")
|
10
|
+
# units :string(255) default("unit")
|
11
|
+
# updated_at :datetime not null
|
12
|
+
#
|
13
|
+
|
14
|
+
class <%= class_name %> < ActiveRecord::Base
|
15
|
+
attr_accessible :description, :quantity, :title, :units
|
16
|
+
|
17
|
+
has_many :<%= singular_name %>_bids, :dependent => :destroy
|
18
|
+
|
19
|
+
# Hooks
|
20
|
+
after_save :kill_all_<%= singular_name %>_bids
|
21
|
+
|
22
|
+
def bid( data = nil )
|
23
|
+
offer = self.<%= singular_name %>_bids.new( data )
|
24
|
+
return offer if offer.save
|
25
|
+
return nil
|
26
|
+
end # bid
|
27
|
+
|
28
|
+
def <%= singular_name %>_bid( data = nil )
|
29
|
+
bid( data )
|
30
|
+
end # <%= singular_name %>_bid
|
31
|
+
|
32
|
+
private
|
33
|
+
def kill_all_<%= singular_name %>_bids
|
34
|
+
# TODO : make the batch deletion less resource intensive
|
35
|
+
self.<%= singular_name %>_bids.each { |bid| bid.destroy }
|
36
|
+
end # kill_all_<%= singular_name %>_bids
|
37
|
+
end # <%= class_name %>
|
File without changes
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'auctionhouse'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: auctionhouse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Chen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &74166000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *74166000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: shoulda
|
27
|
+
requirement: &74165350 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *74165350
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rdoc
|
38
|
+
requirement: &74164780 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.12'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *74164780
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &74157400 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *74157400
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &74156920 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.8.4
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *74156920
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &74156310 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *74156310
|
80
|
+
description: Generates out a fully functional set of models, controllers, views, specs,
|
81
|
+
and migrations for an operational auction site much like ebay or the millions of
|
82
|
+
flash-sales sites out there. Currently in development.
|
83
|
+
email: foxnewsnetwork@gmail.com
|
84
|
+
executables: []
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files:
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.rdoc
|
89
|
+
files:
|
90
|
+
- .document
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.rdoc
|
95
|
+
- Rakefile
|
96
|
+
- VERSION
|
97
|
+
- auctionhouse.gemspec
|
98
|
+
- lib/auctionhouse.rb
|
99
|
+
- lib/auctionhouse/generators.rb
|
100
|
+
- lib/auctionhouse/tasks.rb
|
101
|
+
- lib/generators/auctionhouse/README.markdown
|
102
|
+
- lib/generators/auctionhouse/USAGE
|
103
|
+
- lib/generators/auctionhouse/auctionhouse_generator.rb
|
104
|
+
- lib/generators/auctionhouse/templates/controllers/bids_controller.rb
|
105
|
+
- lib/generators/auctionhouse/templates/controllers/items_controller.rb
|
106
|
+
- lib/generators/auctionhouse/templates/migrations/migration.rb
|
107
|
+
- lib/generators/auctionhouse/templates/models/bid.rb
|
108
|
+
- lib/generators/auctionhouse/templates/models/item.rb
|
109
|
+
- spec/auctionhouse_spec.rb
|
110
|
+
- test/helper.rb
|
111
|
+
- test/test_auctionhouse.rb
|
112
|
+
homepage: http://github.com/foxnewsnetwork/auctionhouse
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: 149918291
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.8.11
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: Simple macro used to generate out an online-auction platform. Currently in
|
140
|
+
development.
|
141
|
+
test_files: []
|