Permalink
Browse files

Create streamlined installion command

  • Loading branch information...
timcase committed Oct 9, 2012
1 parent 8847a38 commit 7c716ee65c8648aeea505d06c5f3827cbd1614a7
Showing with 94 additions and 27 deletions.
  1. +13 −26 README.md
  2. +12 −0 bin/piggybak
  3. +60 −0 lib/piggybak/cli.rb
  4. +9 −1 piggybak.gemspec
@@ -13,44 +13,31 @@ Modular / mountable ecommerce gem. Features:
Installation
========
* First create a new rails project:
rails new webstore
* First, add to Gemfile (from RubyGems, with version specified, or source) with *one* of the following options:
* Config your database.yml and create the databases
* Add to Gemfile:
gem "piggybak"
gem "piggybak", '0.4.19'
gem "piggybak", :git => "git://github.com/stephskardal/piggybak.git"
* Next, run rake task to copy migrations:
* Next, run bundle install:
rake piggybak_engine:install:migrations
bundle install
* Next, run rake task to run migrations:
* Next, run the piggybak install command:
rake db:migrate
piggybak install
* Next, mount in your application by adding:
mount Piggybak::Engine => '/checkout', :as => 'piggybak'" to config/routes
* Add acts_as_variant to any model that will become a sellable item.
* Piggybak is now installed and ready to be added to whatever model class will be sold.
class Product < ActiveRecord::Base
acts_as_variant
end
* You must include jquery_ujs in your application.js file in to get the remove item from cart functionality to work.
//= require jquery_ujs
* You must add the following to your application layout:
<% if "#{params[:controller]}##{params[:action]}" == "piggybak/orders#submit" -%>
<%= javascript_include_tag "piggybak-application" %>
<% end -%>
acts_as_sellable
end
* And you must add this to your production configuration, in order for this asset to be precompiled (and in some cases, ensure that it is served via SSL):
* Piggybak checkout is located at /checkout
config.assets.precompile += %w( piggybak-application.js )
More Details
========
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby
require 'rubygems'
begin
require 'piggybak/cli'
rescue LoadError => e
warn 'Could not load "piggybak/cli"'
exit -1
end
Piggybak::CLI.start
@@ -0,0 +1,60 @@
require 'thor'
module Piggybak
class CLI < Thor
include Thor::Actions
desc "install", "install and configure piggybak"
def install
inject_rails_admin
run('bundle install')
run('rake piggybak_engine:install:migrations')
run('rake db:migrate')
mount_piggybak_route
add_javascript_include_tag
config_assets_precompile
welcome
end
desc "inject_rails_admin", "add rails_admin"
def inject_rails_admin
puts 'add reference to rails_admin in GEMFILE'
insert_into_file "GEMFILE", "gem 'rails_admin'", :after => "source 'https://rubygems.org'\n"
end
desc "mount_piggybak_route", "mount piggbak route"
def mount_piggybak_route
insert_into_file "config/routes.rb", "\n mount Piggybak::Engine => '/checkout', :as => 'piggybak'\n", :after => "Village::Application.routes.draw do\n"
end
desc "add_javascript_include_tag", "add javascript include tag to application layout"
def add_javascript_include_tag
jit_code_block = <<-eos
\n <% if "\#{params[:controller]}#\#\{params[:action]\}" == "piggybak/orders#submit" -%>
<%= javascript_include_tag "piggybak-application" %>\n <% end -%>
eos
insert_into_file 'app/views/layouts/application.html.erb', jit_code_block, :after => "<%= javascript_include_tag \"application\" %>"
end
desc "config_assets-precompile", "amust add this to your production configuration, in order for this asset to be precompiled"
def config_assets_precompile
insert_into_file 'config/environments/production.rb', "\n config.assets.precompile += %w( piggybak-application.js )", :after => 'Village::Application.configure do'
end
desc "welcome", "invite to piggybak"
def welcome
say "******************************************************************"
say "******************************************************************"
say "Piggybak Successfully Installed!"
say "******************************************************************"
say ""
say "Add acts_as_sellable to any model that will be a sellable item."
say ""
say "class Product < ActiveRecord::Base"
say " acts_as_sellable"
say "end"
end
end
end
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = "piggybak"
s.version = "0.5.5"
s.version = "0.5.6"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Steph Skardal", "Brian Buchalter"]
@@ -75,6 +75,7 @@ Gem::Specification.new do |s|
"app/views/rails_admin/main/_order_notes.html.erb",
"app/views/rails_admin/main/_payment_refund.html.haml",
"app/views/rails_admin/main/_recorded_changer.html.erb",
"bin/piggybak",
"config/routes.rb",
"db/migrate/20111227150106_create_orders.rb",
"db/migrate/20111227150322_create_addresses.rb",
@@ -109,6 +110,8 @@ Gem::Specification.new do |s|
"lib/mask_submissions.rb",
"lib/piggybak.rb",
"lib/piggybak/config.rb",
"lib/piggybak/config.rb",
"lib/piggybak/cli.rb",
"piggybak.gemspec",
"spec/TODO",
"spec/database_helpers.rb",
@@ -172,6 +175,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.rubygems_version = "1.8.11"
s.summary = "Mountable ecommerce"
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = ["spec/spec_helper.rb", "spec/dummy_app", "spec/dummy_app/db", "spec/dummy_app/db/migrate", "spec/dummy_app/db/migrate/20120119002503_create_images.rb", "spec/dummy_app/db/migrate/20120119003643_devise_create_users.rb", "spec/dummy_app/db/schema.rb", "spec/dummy_app/db/seeds.rb", "spec/dummy_app/app", "spec/dummy_app/app/helpers", "spec/dummy_app/app/helpers/application_helper.rb", "spec/dummy_app/app/helpers/images_helper.rb", "spec/dummy_app/app/views", "spec/dummy_app/app/views/layouts", "spec/dummy_app/app/views/layouts/application.html.erb", "spec/dummy_app/app/views/images", "spec/dummy_app/app/views/images/index.html", "spec/dummy_app/app/mailers", "spec/dummy_app/app/models", "spec/dummy_app/app/models/user.rb", "spec/dummy_app/app/models/image.rb", "spec/dummy_app/app/assets", "spec/dummy_app/app/assets/javascripts", "spec/dummy_app/app/assets/javascripts/application.js", "spec/dummy_app/app/assets/javascripts/images.js.coffee", "spec/dummy_app/app/assets/stylesheets", "spec/dummy_app/app/assets/stylesheets/application.css", "spec/dummy_app/app/assets/stylesheets/images.css.scss", "spec/dummy_app/app/assets/images", "spec/dummy_app/app/assets/images/rails.png", "spec/dummy_app/app/controllers", "spec/dummy_app/app/controllers/application_controller.rb", "spec/dummy_app/app/controllers/images_controller.rb", "spec/dummy_app/Gemfile.lock", "spec/dummy_app/config.ru", "spec/dummy_app/script", "spec/dummy_app/script/rails", "spec/dummy_app/Rakefile", "spec/dummy_app/lib", "spec/dummy_app/lib/tasks", "spec/dummy_app/lib/assets", "spec/dummy_app/public", "spec/dummy_app/public/robots.txt", "spec/dummy_app/public/favicon.ico", "spec/dummy_app/public/404.html", "spec/dummy_app/public/500.html", "spec/dummy_app/public/422.html", "spec/dummy_app/Gemfile", "spec/dummy_app/config", "spec/dummy_app/config/routes.rb", "spec/dummy_app/config/application.rb", "spec/dummy_app/config/initializers", "spec/dummy_app/config/initializers/wrap_parameters.rb", "spec/dummy_app/config/initializers/quiet_assets.rb", "spec/dummy_app/config/initializers/mime_types.rb", "spec/dummy_app/config/initializers/secret_token.rb", "spec/dummy_app/config/initializers/backtrace_silencers.rb", "spec/dummy_app/config/initializers/inflections.rb", "spec/dummy_app/config/initializers/devise.rb", "spec/dummy_app/config/initializers/session_store.rb", "spec/dummy_app/config/database.yml", "spec/dummy_app/config/environments", "spec/dummy_app/config/environments/test.rb", "spec/dummy_app/config/environments/production.rb", "spec/dummy_app/config/environments/development.rb", "spec/dummy_app/config/locales", "spec/dummy_app/config/locales/en.yml", "spec/dummy_app/config/locales/devise.en.yml", "spec/dummy_app/config/environment.rb", "spec/dummy_app/config/boot.rb", "spec/factories.rb", "spec/models", "spec/models/order_spec.rb", "spec/models/line_item_spec.rb", "spec/TODO", "spec/database_helpers.rb"]
if s.respond_to? :specification_version then
@@ -193,6 +198,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<devise>, [">= 0"])
s.add_runtime_dependency(%q<activemerchant>, [">= 0"])
s.add_runtime_dependency(%q<countries>, [">= 0"])
s.add_runtime_dependency(%q<thor>, [">= 0"])
s.add_development_dependency(%q<rspec>, [">= 0"])
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
s.add_development_dependency(%q<diff-lcs>, [">= 0"])
@@ -202,6 +208,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<countries>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<thor>, [">= 0"])
s.add_dependency(%q<rspec>, [">= 0"])
s.add_dependency(%q<rspec-rails>, ["~> 2.7.0"])
s.add_dependency(%q<factory_girl>, [">= 0"])
@@ -224,6 +231,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<countries>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<thor>, [">= 0"])
s.add_dependency(%q<rspec>, [">= 0"])
s.add_dependency(%q<rspec-rails>, ["~> 2.7.0"])
s.add_dependency(%q<factory_girl>, [">= 0"])

0 comments on commit 7c716ee

Please sign in to comment.