apple_cart 0.0.1

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.
Files changed (56) hide show
  1. data/.gitignore +4 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +82 -0
  5. data/LICENSE +22 -0
  6. data/README.md +1 -0
  7. data/Rakefile +2 -0
  8. data/apple_cart.gemspec +40 -0
  9. data/bin/apple_cart +103 -0
  10. data/lib/apple_cart.rb +3 -0
  11. data/lib/apple_cart/helpers.rb +17 -0
  12. data/lib/apple_cart/version.rb +3 -0
  13. data/source/.autotest +23 -0
  14. data/source/.gitignore +36 -0
  15. data/source/.rspec +2 -0
  16. data/source/.rvmrc.erb +1 -0
  17. data/source/Capfile +5 -0
  18. data/source/Gemfile +87 -0
  19. data/source/app/helpers/body_class_helper.rb +7 -0
  20. data/source/app/views/layouts/application.html.erb.erb +14 -0
  21. data/source/app/views/pages/maintenance.html.erb.erb +37 -0
  22. data/source/app/views/shared/_flashes.html.erb +5 -0
  23. data/source/app/views/shared/_javascript.html.erb +7 -0
  24. data/source/autotest/discover.rb +2 -0
  25. data/source/config/cucumber.yml +13 -0
  26. data/source/config/database.yml.example +14 -0
  27. data/source/config/deploy.rb.erb +23 -0
  28. data/source/config/initializers/actionmailer.rb.erb +12 -0
  29. data/source/config/initializers/constants.rb +1 -0
  30. data/source/config/initializers/core_ext.rb +1 -0
  31. data/source/config/initializers/date_and_time_formats.rb +9 -0
  32. data/source/db/samplize.rb +58 -0
  33. data/source/db/seed.rb +27 -0
  34. data/source/features/step_definitions/form_steps.rb +16 -0
  35. data/source/features/step_definitions/object_creation_steps.rb +34 -0
  36. data/source/features/step_definitions/third_person_web_steps.rb +94 -0
  37. data/source/features/support/factory_girl.rb +1 -0
  38. data/source/features/support/regex.rb +3 -0
  39. data/source/features/support/seed_data.rb +6 -0
  40. data/source/lib/formats.rb +5 -0
  41. data/source/lib/recipes/kompanee-recipes.rb +2 -0
  42. data/source/lib/tasks/db.rake +38 -0
  43. data/source/lib/tasks/seed.rake +33 -0
  44. data/source/public/humans.txt +49 -0
  45. data/source/public/stylesheets/sass/fonts.scss +38 -0
  46. data/source/public/stylesheets/sass/grids.scss +14 -0
  47. data/source/public/stylesheets/sass/reset.scss +98 -0
  48. data/source/public/stylesheets/sass/template.scss +63 -0
  49. data/source/spec/factories/users.rb +12 -0
  50. data/source/spec/support/color.rb +3 -0
  51. data/source/spec/support/devise.rb +3 -0
  52. data/source/spec/support/focused.rb +6 -0
  53. data/source/spec/support/matchers/paperclip_matchers.rb +5 -0
  54. data/source/spec/support/pending.rb +5 -0
  55. data/source/template.rb +309 -0
  56. metadata +169 -0
@@ -0,0 +1,7 @@
1
+ module BodyClassHelper
2
+ def body_class
3
+ qualified_controller_name = controller.controller_path.gsub('/','-')
4
+
5
+ "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
5
+ <title><%= app_name %></title>
6
+ <%%= stylesheet_link_tag :defaults, :media => 'all', :cache => true %>
7
+ <%%= csrf_meta_tag %>
8
+ </head>
9
+ <body class="<%%= body_class %>">
10
+ <%%= render :partial => 'shared/flashes' -%>
11
+ <%%= yield %>
12
+ <%%= render :partial => 'shared/javascript' %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= app_name %> - Down for Maintenance</title>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <style>
7
+ html, body, div, span, applet, object, iframe,
8
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
9
+ a, abbr, acronym, address, big, cite, code,
10
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
11
+ small, strike, strong, sub, sup, tt, var,
12
+ dl, dt, dd, ol, ul, li,
13
+ fieldset, form, label, legend,
14
+ table, caption, tbody, tfoot, thead, tr, th, td {
15
+ margin: 0;
16
+ padding: 0;
17
+ border: 0;
18
+ outline: 0;
19
+ font-weight: inherit;
20
+ font-style: inherit;
21
+ font-size: 100%;
22
+ font-family: arial, helvetica, sans-serif;
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <div id="content">
28
+ <h1>We're currently down for <%%= reason ? reason : "maintenance" %> as of <%%= Time.now.strftime("%H:%M %Z") %>.</h1>
29
+ <p>
30
+ Sorry for the inconvenience. We'll be back
31
+ <%%= deadline ? "by #{deadline}" : "shortly" %>.
32
+ Please email us if you need to get in touch.
33
+ </p>
34
+ </div>
35
+ </body>
36
+ </html>
37
+
@@ -0,0 +1,5 @@
1
+ <div id="flash">
2
+ <% flash.each do |key, value| -%>
3
+ <div id="flash_<%= key %>"><%= value %></div>
4
+ <% end -%>
5
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= javascript_tag "head.js('/javascripts/jquery.js', '/javascripts/jquery-ui.js', '/javascripts/rails.js')" %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <% if Rails.env.test? %>
6
+ <%= javascript_tag "$.ajaxSetup({ async: false });" %>
7
+ <% end %>
@@ -0,0 +1,2 @@
1
+ Autotest.add_discovery { "rails" }
2
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1,13 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ preferred_format = "--format #{ENV['CUCUMBER_FORMAT'] || 'Cucumber::Formatter::Fuubar'}"
4
+
5
+ rerun_opts = rerun.to_s.strip.empty? ? "#{preferred_format} features" : "#{preferred_format} #{rerun}"
6
+ std_opts = "#{preferred_format} --strict --color"
7
+ %>
8
+
9
+ default: <%= std_opts %> features
10
+ wip: --tags @wip --wip features
11
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
12
+ autotest: <%= std_opts %>
13
+ autotest-all: <%= std_opts %>
@@ -0,0 +1,14 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: tmp/development.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ test: &test
8
+ adapter: sqlite3
9
+ database: tmp/test.sqlite3
10
+ pool: 5
11
+ timeout: 5000
12
+
13
+ cucumber:
14
+ <<: *test
@@ -0,0 +1,23 @@
1
+ #
2
+ # Set your application information here.
3
+ #
4
+ set :application, ""
5
+ set :application_short, "<%= app_name %>"
6
+
7
+ desc "Sets up the environment for a staging deployment."
8
+ task :staging do
9
+ set :deployment_type, :rackspace
10
+
11
+ set :domain, "thekompanee.com"
12
+
13
+ set :server_ip, "174.143.210.58"
14
+ set :server_name, "zeus.#{domain}"
15
+ end
16
+
17
+ desc "Sets up the environment for a production deployment."
18
+ task :production do
19
+ set :deployment_type, :heroku
20
+
21
+ set :deploy_name, "<%= app_name %>"
22
+ set :user, "heroku@thekompanee.com"
23
+ end
@@ -0,0 +1,12 @@
1
+ <%= @app_class %>::Application.configure do
2
+ case Rails.env
3
+ when "production"
4
+ host = "<%= @app_domain %>.com"
5
+ when "staging"
6
+ host = "staging.<%= @app_domain %>.com"
7
+ else
8
+ host = "localhost:3000"
9
+ end
10
+
11
+ config.action_mailer.default_url_options = { :host => host }
12
+ end
@@ -0,0 +1 @@
1
+ Dir[Rails.root.join("app/constants/**/*.rb")].each {|f| require f}
@@ -0,0 +1 @@
1
+ Dir[Rails.root.join("lib/core_ext/**/*.rb")].each {|f| require f}
@@ -0,0 +1,9 @@
1
+ DateAndTimeFormats = {
2
+ :simple => '%m/%d/%Y', # 04/13/2010
3
+ :long_date => "%a, %b %d, %Y", # Tue, Apr 13, 2010
4
+ :mon_year => '%m/%Y', # 04/2010
5
+ :tstamp => "%Y%m%d-%H%M%S" # 20100413-135959
6
+ }
7
+
8
+ Time::DATE_FORMATS.merge! DateAndTimeFormats
9
+ Date::DATE_FORMATS.merge! DateAndTimeFormats
@@ -0,0 +1,58 @@
1
+ unless Rails.env.production?
2
+ require 'factory_girl'
3
+ Dir[File.join(Rails.root, 'spec', 'factories', '*.rb')].each {|f| require f}
4
+
5
+ module DB
6
+ class Samplize
7
+ # Use this method to call all of the sub-methods used
8
+ # to create sample data for your application.
9
+ #
10
+ # For example:
11
+ # samplize_users
12
+ # or
13
+ # samplize(University)
14
+ #
15
+ # If you call the second one, it will look for a factory
16
+ # with the name <class_name_underscored>_sample and run it
17
+ # anywhere from 1 to 100 times.
18
+ def self.all
19
+ # samplize_users
20
+ # samplize(University)
21
+ end
22
+
23
+ def self.samplize_users
24
+ Factory(:user_sample, :email => 'test@test.com')
25
+
26
+ if !Rails.env.test?
27
+ puts "*" * 80
28
+ puts "** The following accounts are available for use: **"
29
+ puts "** test@test.com/testtickle **"
30
+ puts "*" * 80
31
+ end
32
+ end
33
+
34
+ private
35
+ def self.samplize(clazz, count = nil)
36
+ count ||= rand(100)
37
+ factory_name = "#{clazz.name.underscore}_sample".to_sym
38
+
39
+ count.times { Factory(factory_name.to_sym) }
40
+
41
+ sample_info_in_pretty_box(clazz, count)
42
+ end
43
+
44
+ def self.sample_info_in_pretty_box(clazz, count = nil)
45
+ if !Rails.env.test?
46
+ count = clazz.all.count
47
+ message = "#{count} #{clazz.name.underscore.titleize.pluralize} Created"
48
+ left_just_size = ((80 - message.length - 4) / 2).round + message.length
49
+ message = message.ljust(left_just_size).rjust(76)
50
+
51
+ puts "*" * 80
52
+ puts "**#{message}**"
53
+ puts "*" * 80
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ require 'factory_girl'
2
+ Dir[File.join(Rails.root, 'spec', 'factories', '*.rb')].each {|f| require f}
3
+
4
+ module DB
5
+ class Seed
6
+ def self.all
7
+ # Call all of the methods which seed your DB here.
8
+ # DO NOT put methods which install sample data here.
9
+ end
10
+
11
+ # Put all of the methods which seed your DB here.
12
+
13
+ private
14
+ def self.seed_info_in_pretty_box(clazz)
15
+ if !Rails.env.test?
16
+ count = clazz.all.count
17
+ message = "#{count} #{clazz.name.underscore.titleize.pluralize} Created"
18
+ left_just_size = ((80 - message.length - 4) / 2).round + message.length
19
+ message = message.ljust(left_just_size).rjust(76)
20
+
21
+ puts "*" * 80
22
+ puts "**#{message}**"
23
+ puts "*" * 80
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # When /^he fills in "([^"]*)" with his (incorrect )?(.*)$/ do |field, correctness, attribute|
2
+ # value = correctness.nil? ? @last_reference.send(attribute) : @last_reference.send(attribute).reverse
3
+
4
+ # When %{I fill in "#{field}" with "#{value}"}
5
+ # end
6
+
7
+ # When /^they fill in "([^"]*)" with their email$/ do |field|
8
+ # When %{I fill in "#{field}" with "someone@somewhere.com"}
9
+ # end
10
+
11
+ # When /^(?:I|he|she|it|they) fills? in the advised student form$/ do
12
+ # fill_in "Students name", :with => "Johnny Mneumonic"
13
+ # fill_in_date "advised_student_started_on", :with => "2010-08-01"
14
+ # fill_in_date "advised_student_ended_on", :with => "2010-12-12"
15
+ # fill_in "Description", :with => "A data courier, carrying a data package literally inside his head too large to hold for long, must deliver it before he dies from it."
16
+ # end
@@ -0,0 +1,34 @@
1
+ require 'rake'
2
+ load 'lib/tasks/seed.rake'
3
+
4
+ Given /^the standard dataset exists$/ do
5
+ Rake::Task['db:seed:base'].execute
6
+ end
7
+
8
+ # Given /^a user named "([^"]*)" exists$/ do |users_name|
9
+ # @object_lookup = {}
10
+
11
+ # @user = Factory(:user, :first_name => users_name)
12
+
13
+ # @object_lookup[users_name] = @user
14
+ # @last_reference = @user
15
+ # end
16
+
17
+ # Given /^(?:he|she|they|it) (?:has|have) rendered a service of "([^"]*)" for "([^"]*)" at "([^"]*)" in "([^"]*)"$/ do |service_position, organization, location_name, city_state|
18
+ # Given %Q{a location of "#{location_name}" in "#{city_state}" exists}
19
+ # service_position_type = Factory(:service_position_type, :name => service_position)
20
+ # Factory(:service_position, :service_position_type => service_position_type, :location => @location, :organization => organization)
21
+ # end
22
+
23
+ # Given /^(?:he|she|they|it) (?:has|have) taken a professional leave on (\d{2}\/\d{2}\/\d{4}) for "([^"]*)"$/ do |start_date, leave_type|
24
+ # leave_type = Factory(:professional_leave_type, :name => leave_type)
25
+ # Factory(:professional_leave, :professional_leave_type => leave_type, :started_on => Date.strptime(start_date, "%m/%d/%Y"))
26
+ # end
27
+
28
+ # Then /^they should exist in the system$/ do
29
+ # User.first.should_not be_nil
30
+ # end
31
+
32
+ # Then /^they should not exist in the system$/ do
33
+ # User.first.should be_nil
34
+ # end
@@ -0,0 +1,94 @@
1
+ Given /^#{@person} #{@modifier} (?:currently )on (.+)$/ do |page_name|
2
+ Given %{I am on #{page_name}}
3
+ end
4
+
5
+ When /^#{@person} go(?:es)? to (.+)$/ do |page_name|
6
+ When %{I go to #{page_name}}
7
+ end
8
+
9
+ When /^(?:|then )(?:#{@person}|I) clicks? (?:on )?"([^\"]*)"(?: within (.*))?(?: and #{@person} waits? (\d+) seconds?)?$/ do |item, parent, delay|
10
+ delay = delay.nil? ? 0 : delay.to_i
11
+
12
+ with_scope(parent) do
13
+ click_link_or_button(item)
14
+
15
+ sleep(delay)
16
+ end
17
+ end
18
+
19
+ When /^#{@person} press(?:es)? "([^"]*)"(?: within (.*))?$/ do |button, parent|
20
+ When %{I press "#{button}" within #{parent}}
21
+ end
22
+
23
+ When /^#{@person} follows? "([^"]*)"(?: within (.*))?$/ do |link, parent|
24
+ When %{I follow "#{link}" within #{parent}}
25
+ end
26
+
27
+ When /^#{@person} fills? in "([^"]*)" with #{@possessive} (.+)(?: within (.*))?$/ do |field, value, parent|
28
+ value = @last_reference.send(value.to_sym)
29
+ When %{I fill in "#{field}" with "#{value}" within #{parent}}
30
+ end
31
+
32
+ When /^#{@person} fills? in "([^"]*)" with "([^"]*)"(?: within (.*))?$/ do |field, value, parent|
33
+ When %{I fill in "#{field}" with "#{value}" within #{parent}}
34
+ end
35
+
36
+ When /^#{@person} fills? in "([^"]*)" for "([^"]*)"(?: within (.*))?$/ do |value, field, parent|
37
+ When %{I fill in "#{field}" with "#{value}" within #{parent}}
38
+ end
39
+
40
+ When /^#{@person} fills? in the following(?: within (.*))?:$/ do |parent, fields|
41
+ When %{I fill in "#{name}" with "#{value}"}, fields
42
+ end
43
+
44
+ When /^#{@person} selects? "([^"]*)" from "([^"]*)"(?: within (.*))?$/ do |value, field, parent|
45
+ When %{I select "#{value}" from "#{field}" within #{parent}}
46
+ end
47
+
48
+ When /^#{@person} checks? "([^"]*)"(?: within (.*))?$/ do |field, parent|
49
+ When %{I check "#{field}" within #{parent}}
50
+ end
51
+
52
+ When /^#{@person} unchecks? "([^"]*)"(?: within (.*))?$/ do |field, parent|
53
+ When %{I uncheck "#{field}" within #{parent}}
54
+ end
55
+
56
+ When /^#{@person} chooses? "([^"]*)"(?: within (.*))?$/ do |field, parent|
57
+ When %{I choose "#{field}" within #{parent}}
58
+ end
59
+
60
+ When /^#{@person} attach(?:es) the file "([^"]*)" to "([^"]*)"(?: within (.*))?$/ do |path, field, parent|
61
+ When %{I attach the file "#{path}" to "#{field}"}
62
+ end
63
+
64
+ Then /^#{@person} should see JSON:$/ do |expected_json|
65
+ Then %{I should see JSON:}, expected_json
66
+ end
67
+
68
+ Then /^#{@person} should see "([^"]*)"(?: within (.*))?$/ do |text, parent|
69
+ Then %{I should see "#{text}" within #{parent}}
70
+ end
71
+
72
+ Then /^#{@person} should see \/([^\/]*)\/(?: within (.*))?$/ do |regexp, parent|
73
+ Then %{I should see #{regexp} when #{parent}}
74
+ end
75
+
76
+ Then /^#{@person} should not see "([^"]*)"(?: within (.*))?$/ do |text, parent|
77
+ Then %{I should not see "#{text}" within #{parent}}
78
+ end
79
+
80
+ Then /^#{@person} should not see \/([^\/]*)\/(?: within (.*))?$/ do |regexp, parent|
81
+ Then %{I should not see #{regexp} within #{parent}}
82
+ end
83
+
84
+ Then /^#{@person} should (?:still )?be on (.+)$/ do |page_name|
85
+ Then %{I should be on #{page_name}}
86
+ end
87
+
88
+ Then /^#{@person} should be taken to (.+)$/ do |page_name|
89
+ Then %{I should be on #{page_name}}
90
+ end
91
+
92
+ Then /^#{@person} should have the following query string:$/ do |expected_pairs|
93
+ Then %{I should have the following query string:}, expected_pairs
94
+ end
@@ -0,0 +1 @@
1
+ require 'factory_girl/step_definitions'
@@ -0,0 +1,3 @@
1
+ @person = "(?:he|she|they|it|you)"
2
+ @possessive = "(?:his|her|their|its|your)"
3
+ @modifier = "(?:is|am|are|have|has)"
@@ -0,0 +1,6 @@
1
+ require File.join(Rails.root, "db", "seed")
2
+ DB::Seed.all
3
+
4
+ at_exit do
5
+ DatabaseCleaner.clean
6
+ end
@@ -0,0 +1,5 @@
1
+ # Common Regular Expressions should be added here.
2
+
3
+ # module Formats
4
+ # PageNumber = /^(?:(?:\d{0,3},?\d{3})|(?:\d{1,3}))(?:-(?:(?:\d{0,3},?\d{3})|(?:\d{1,3})))?$/
5
+ # end
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'kompanee-recipes/deploy'
@@ -0,0 +1,38 @@
1
+ namespace :db do
2
+ desc "Backs up the database. Auto-detects database type."
3
+ task :backup => :environment do
4
+ directory = ENV["BACKUP_DIRECTORY"].blank? ? "db" : ENV["BACKUP_DIRECTORY"]
5
+
6
+ @db_config = ActiveRecord::Base.configurations[Rails.env]
7
+
8
+ case @db_config["adapter"]
9
+ when "mysql"
10
+ execute_mysql_command("mysqldump", "--comments --extended-insert --flush-privileges > #{directory}/#{Time.now.strftime("%Y%m%d%H%M%S")}.dump.sql")
11
+ when "postgresql"
12
+ execute_postgres_command("pg_dump", "--file=#{directory}/#{Time.now.strftime("%Y%m%d%H%M%S")}.dump.sql")
13
+ else
14
+ raise "Sorry, I can't figure out how to backup a #{@db_config["adapter"]} database."
15
+ end
16
+ end
17
+ end
18
+
19
+ def execute_postgres_command(command, arguments)
20
+ ENV['PGUSER'] = @db_config["username"] if @db_config["username"]
21
+ ENV['PGHOST'] = @db_config["host"] if @db_config["host"]
22
+ ENV['PGPORT'] = @db_config["port"].to_s if @db_config["port"]
23
+ ENV['PGPASSWORD'] = @db_config["password"].to_s if @db_config["password"]
24
+
25
+ command = [ command, @db_config["database"], arguments ].join(" ")
26
+ puts ">> Executing Postgres Command: #{command}"
27
+ system(command)
28
+ end
29
+
30
+ def execute_mysql_command(command, arguments)
31
+ ENV['MYSQL_PWD'] = @db_config["password"] if @db_config["password"]
32
+ ENV['MYSQL_TCP_PORT'] = @db_config["port"] if @db_config["port"]
33
+
34
+ connection = "-u #{@db_config["username"]}"
35
+ command = [ command, connection, @db_config["database"], arguments ].join(" ")
36
+ puts ">> Executing MySQL Command: #{command}"
37
+ system(command)
38
+ end