apollo-commerce 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1088e83b95afd34505af1ebb8fdabc3d0633b013
4
- data.tar.gz: 65616e7a0ce19b432c10d20e093ccaf471c1636e
3
+ metadata.gz: bb3b71bfe42b599ecddfb1c0bd398258b195f77d
4
+ data.tar.gz: 612cfacbedda181f3c1b47a4ad9df1d5a495067d
5
5
  SHA512:
6
- metadata.gz: 9ba98bd12f228883c4ac360f82a0c4b76ad3acb33470073c934e2c64e7ba5630dc9a0287e53254c6139fca1b8be9767ef91bf737b50d3cb78356b5b858890b6e
7
- data.tar.gz: 5b768392cbf475b2b56b20cb6aa5190be72384447d4072eff6a933ba0566119591415fc320f56e6fe49a1f0eae8362710960a9982d2ccd153165ba0965aa3f19
6
+ metadata.gz: f78eff7754e594b3b93d93871c8ffbfb39d17eb2f8c05dd1b57daf8cc9d4c6bd4e9cc7d128249a81cb1e2619044b0bc9d5fcb943fea7872bec6d728f8e5978e4
7
+ data.tar.gz: af28b3a4bbb533b43af09aa03ca0c5acedd065f970562d50db0addcbb64efbfa5d1260693deb4579d975f0a5b9010d94866359b019b1816cf38e93184e5d75a5
@@ -1,4 +1,4 @@
1
- Copyright 2014 YOURNAME
1
+ Copyright 2014 Georg Schlenkhoff
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,9 @@
1
+ class Cart < ActiveRecord::Base
2
+ has_many :cart_items
3
+
4
+ # calculate sum of all cart items's prices
5
+ def total
6
+ self.cart_items.map.sum(&:price).to_i
7
+ end
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ class CartItem < ActiveRecord::Base
2
+ belongs_to :cart
3
+ belongs_to :product
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ class Product < ActiveRecord::Base
2
+ end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Apollo</title>
4
+ <title>ApolloCommerce</title>
5
5
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
6
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
7
  <%= csrf_meta_tags %>
@@ -6,7 +6,7 @@ require 'rails/all'
6
6
  # you've limited to :test, :development, or :production.
7
7
  Bundler.require(*Rails.groups)
8
8
 
9
- module Apollo
9
+ module ApolloCommerce
10
10
  class Application < Rails::Application
11
11
  # Settings in config/environments/* take precedence over those specified here.
12
12
  # Application configuration should go into files in config/initializers
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Rails.application.config.session_store :cookie_store, key: '_apollo_session'
3
+ Rails.application.config.session_store :cookie_store, key: '_apollo-commerce_session'
@@ -11,10 +11,10 @@
11
11
  # if you're sharing your code publicly.
12
12
 
13
13
  development:
14
- secret_key_base: 4dd1b05c78cfa6fe877c26200d27b764b0e743af35520164d45bdf3e593af0e11291e4ff6c16ada00483bc704e6f5a2c20e7031f5b949307b6e9cf29b3a257a3
14
+ secret_key_base: 19f90681efc676eb167f1fdfdb726c92997e35e4f6eab74f09de154db9008c6984d3d64bc97548ee55de008dbacfee8e14aafb6b64c91f9d81be4d361ffc425b
15
15
 
16
16
  test:
17
- secret_key_base: db70d0c15e0fed00d484c6bb48e303b354dce4ea7ca5a148f69b26cde4a34749977105e109cd9983858966d2e491e2657f4b22f5a57ffc511ec6e8b6334df263
17
+ secret_key_base: f3e212c61a3e9cc7a7accb1a093b45b30d44d063d93d3044f1998afd986b2cbab1c03b9b52a0098011d78b2f3b9449403b40cc84e6c3d1708de79bbc992fe0f8
18
18
 
19
19
  # Do not keep production secrets in the repository,
20
20
  # instead read values from the environment.
Binary file
@@ -0,0 +1,12 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :products do |t|
4
+ t.string :title
5
+ t.text :description
6
+ t.string :gtin
7
+ t.string :sku
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ class CreateCarts < ActiveRecord::Migration
2
+ def change
3
+ create_table :carts do |t|
4
+
5
+ t.timestamps
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ class CreateCartItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :cart_items do |t|
4
+ t.integer :quantity
5
+ t.integer :price
6
+ t.belongs_to :cart
7
+ t.belongs_to :product
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20140524092715) do
15
+
16
+ create_table "cart_items", force: true do |t|
17
+ t.integer "quantity"
18
+ t.integer "price"
19
+ t.integer "cart_id"
20
+ t.integer "product_id"
21
+ t.datetime "created_at"
22
+ t.datetime "updated_at"
23
+ end
24
+
25
+ create_table "carts", force: true do |t|
26
+ t.datetime "created_at"
27
+ t.datetime "updated_at"
28
+ end
29
+
30
+ create_table "products", force: true do |t|
31
+ t.string "title"
32
+ t.text "description"
33
+ t.string "gtin"
34
+ t.string "sku"
35
+ t.datetime "created_at"
36
+ t.datetime "updated_at"
37
+ end
38
+
39
+ end
Binary file
@@ -0,0 +1,26 @@
1
+ desc 'Publish to GitHub'
2
+ task :publish => [:test, :yard, :gem, :git] do
3
+ puts 'published to GitHub'
4
+ end
5
+
6
+ desc 'Build yard docs'
7
+ task :yard do
8
+ %x{yardoc}
9
+ puts 'updated yard'
10
+ end
11
+
12
+ desc 'Git add files, and git commit'
13
+ task :git do
14
+ %x{git add --all}
15
+ %x{git commit}
16
+ %x{git push origin master}
17
+ puts 'commited git'
18
+ end
19
+
20
+ desc 'Publish to RubyGems'
21
+ task :gem do
22
+ %x{gem build apollo-commerce.gemspec}
23
+ puts 'Gem built'
24
+ %x{gem push apollo-commerce*.gem}
25
+ puts 'Gem published'
26
+ end
@@ -0,0 +1,11 @@
1
+ one:
2
+ quantity: 1
3
+ price: 1
4
+ product: one
5
+ cart: one
6
+
7
+ two:
8
+ quantity: 1
9
+ price: 1
10
+ cart: two
11
+ product: one
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,11 @@
1
+ one:
2
+ sku: MyString
3
+ gtin: MyString
4
+ title: MyString
5
+ description: MyText
6
+
7
+ two:
8
+ sku: MyString
9
+ gtin: MyString
10
+ title: MyString
11
+ description: MyText
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class CartItemTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class CartTest < ActiveSupport::TestCase
4
+ fixtures :carts, :cart_items
5
+
6
+ test 'should calculate total sum' do
7
+ carts(:one).cart_items << [cart_items(:one), cart_items(:two)]
8
+ assert_equal carts(:one).total, (cart_items(:one).price.to_i + cart_items(:two).price.to_i)
9
+ end
10
+
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class ProductTest < ActiveSupport::TestCase
4
+
5
+ end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo-commerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Schlenkhoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
11
+ date: 2014-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Apollo Commerce is the essential e-commerce solution for lean entrepreneurs
14
+ building on Ruby on Rails
14
15
  email:
15
16
  - georg.schlenkhoff@gmail.com
16
17
  executables: []
@@ -18,12 +19,14 @@ extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - MIT-LICENSE
21
- - README.rdoc
22
22
  - Rakefile
23
23
  - app/assets/javascripts/application.js
24
24
  - app/assets/stylesheets/application.css
25
25
  - app/controllers/application_controller.rb
26
26
  - app/helpers/application_helper.rb
27
+ - app/models/cart.rb
28
+ - app/models/cart_item.rb
29
+ - app/models/product.rb
27
30
  - app/views/layouts/application.html.erb
28
31
  - config/application.rb
29
32
  - config/boot.rb
@@ -42,8 +45,20 @@ files:
42
45
  - config/locales/en.yml
43
46
  - config/routes.rb
44
47
  - config/secrets.yml
48
+ - db/development.sqlite3
49
+ - db/migrate/20140524092344_create_products.rb
50
+ - db/migrate/20140524092515_create_carts.rb
51
+ - db/migrate/20140524092715_create_cart_items.rb
52
+ - db/schema.rb
45
53
  - db/seeds.rb
46
54
  - db/test.sqlite3
55
+ - lib/tasks/publish.rake
56
+ - test/fixtures/cart_items.yml
57
+ - test/fixtures/carts.yml
58
+ - test/fixtures/products.yml
59
+ - test/models/cart_item_test.rb
60
+ - test/models/cart_test.rb
61
+ - test/models/product_test.rb
47
62
  - test/test_helper.rb
48
63
  homepage: http://apolloventur.es
49
64
  licenses:
@@ -70,5 +85,11 @@ signing_key:
70
85
  specification_version: 4
71
86
  summary: Apollo Commerce
72
87
  test_files:
88
+ - test/fixtures/cart_items.yml
89
+ - test/fixtures/carts.yml
90
+ - test/fixtures/products.yml
91
+ - test/models/cart_item_test.rb
92
+ - test/models/cart_test.rb
93
+ - test/models/product_test.rb
73
94
  - test/test_helper.rb
74
95
  has_rdoc:
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.