enju_inventory 0.0.11 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/app/controllers/inventories_controller.rb +1 -1
- data/app/controllers/inventory_files_controller.rb +15 -15
- data/app/models/inventory.rb +0 -1
- data/app/models/inventory_file.rb +4 -10
- data/app/views/inventory_files/edit.html.erb +2 -2
- data/app/views/inventory_files/index.html.erb +2 -2
- data/app/views/inventory_files/show.html.erb +2 -2
- data/config/locales/translation_en.yml +1 -1
- data/config/locales/translation_ja.yml +1 -1
- data/db/migrate/20081117143156_create_inventory_files.rb +2 -0
- data/db/migrate/20120413100431_add_fingerprint_to_inventory_file.rb +1 -1
- data/lib/enju_inventory.rb +0 -17
- data/lib/enju_inventory/engine.rb +5 -2
- data/lib/enju_inventory/version.rb +1 -1
- data/spec/dummy/config/initializers/devise.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +10 -31
- data/spec/dummy/db/schema.rb +8 -15
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/fixtures/inventory_files.yml +6 -3
- data/spec/models/inventory_file_spec.rb +4 -8
- metadata +49 -58
- data/spec/dummy/README.rdoc +0 -261
data/MIT-LICENSE
CHANGED
@@ -2,33 +2,33 @@ class InventoryFilesController < ApplicationController
|
|
2
2
|
load_and_authorize_resource
|
3
3
|
|
4
4
|
# GET /inventory_files
|
5
|
-
# GET /inventory_files.
|
5
|
+
# GET /inventory_files.xml
|
6
6
|
def index
|
7
7
|
@inventory_files = InventoryFile.page(params[:page])
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html # index.html.erb
|
11
|
-
format.
|
11
|
+
format.xml { render :xml => @inventory_files }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
# GET /inventory_files/1
|
16
|
-
# GET /inventory_files/1.
|
16
|
+
# GET /inventory_files/1.xml
|
17
17
|
def show
|
18
18
|
respond_to do |format|
|
19
19
|
format.html # show.html.erb
|
20
|
-
format.
|
20
|
+
format.xml { render :xml => @inventory_file }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
# GET /inventory_files/new
|
25
|
-
# GET /inventory_files/new.
|
25
|
+
# GET /inventory_files/new.xml
|
26
26
|
def new
|
27
27
|
@inventory_file = InventoryFile.new
|
28
28
|
|
29
29
|
respond_to do |format|
|
30
30
|
format.html # new.html.erb
|
31
|
-
format.
|
31
|
+
format.xml { render :xml => @inventory_file }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -37,7 +37,7 @@ class InventoryFilesController < ApplicationController
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# POST /inventory_files
|
40
|
-
# POST /inventory_files.
|
40
|
+
# POST /inventory_files.xml
|
41
41
|
def create
|
42
42
|
@inventory_file = InventoryFile.new(params[:inventory_file])
|
43
43
|
@inventory_file.user = current_user
|
@@ -47,37 +47,37 @@ class InventoryFilesController < ApplicationController
|
|
47
47
|
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.inventory_file'))
|
48
48
|
@inventory_file.import
|
49
49
|
format.html { redirect_to(@inventory_file) }
|
50
|
-
format.
|
50
|
+
format.xml { render :xml => @inventory_file, :status => :created, :location => @inventory_file }
|
51
51
|
else
|
52
52
|
format.html { render :action => "new" }
|
53
|
-
format.
|
53
|
+
format.xml { render :xml => @inventory_file.errors, :status => :unprocessable_entity }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
# PUT /inventory_files/1
|
59
|
-
# PUT /inventory_files/1.
|
59
|
+
# PUT /inventory_files/1.xml
|
60
60
|
def update
|
61
61
|
respond_to do |format|
|
62
62
|
if @inventory_file.update_attributes(params[:inventory_file])
|
63
63
|
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.inventory_file'))
|
64
64
|
format.html { redirect_to(@inventory_file) }
|
65
|
-
format.
|
65
|
+
format.xml { head :ok }
|
66
66
|
else
|
67
67
|
format.html { render :action => "edit" }
|
68
|
-
format.
|
68
|
+
format.xml { render :xml => @inventory_file.errors, :status => :unprocessable_entity }
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
# DELETE /inventory_files/1
|
74
|
-
# DELETE /inventory_files/1.
|
74
|
+
# DELETE /inventory_files/1.xml
|
75
75
|
def destroy
|
76
76
|
@inventory_file.destroy
|
77
77
|
|
78
78
|
respond_to do |format|
|
79
|
-
format.html { redirect_to
|
80
|
-
format.
|
79
|
+
format.html { redirect_to(inventory_files_url) }
|
80
|
+
format.xml { head :ok }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
data/app/models/inventory.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
class InventoryFile < ActiveRecord::Base
|
2
|
-
attr_accessible :inventory, :note
|
3
2
|
has_many :inventories, :dependent => :destroy
|
4
3
|
has_many :items, :through => :inventories
|
5
4
|
belongs_to :user
|
6
|
-
|
7
|
-
has_attached_file :inventory, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
|
8
|
-
:s3_permissions => :private
|
9
|
-
else
|
10
|
-
has_attached_file :inventory, :path => ":rails_root/private:url"
|
11
|
-
end
|
5
|
+
has_attached_file :inventory, :path => ":rails_root/private:url"
|
12
6
|
validates_attachment_content_type :inventory, :content_type => ['text/csv', 'text/plain', 'text/tab-separated-values']
|
13
7
|
validates_attachment_presence :inventory
|
14
8
|
validates_presence_of :user
|
@@ -42,14 +36,14 @@ end
|
|
42
36
|
# filename :string(255)
|
43
37
|
# content_type :string(255)
|
44
38
|
# size :integer
|
39
|
+
# file_hash :string(255)
|
45
40
|
# user_id :integer
|
46
41
|
# note :text
|
47
|
-
# created_at :datetime
|
48
|
-
# updated_at :datetime
|
42
|
+
# created_at :datetime
|
43
|
+
# updated_at :datetime
|
49
44
|
# inventory_file_name :string(255)
|
50
45
|
# inventory_content_type :string(255)
|
51
46
|
# inventory_file_size :integer
|
52
47
|
# inventory_updated_at :datetime
|
53
|
-
# inventory_fingerprint :string(255)
|
54
48
|
#
|
55
49
|
|
@@ -18,8 +18,8 @@
|
|
18
18
|
<%= f.text_field :inventory_file_size -%>
|
19
19
|
</div>
|
20
20
|
<div class="field">
|
21
|
-
<%= f.label :
|
22
|
-
<%= f.text_field :
|
21
|
+
<%= f.label :file_hash -%> <br />
|
22
|
+
<%= f.text_field :file_hash -%>
|
23
23
|
</div>
|
24
24
|
<div class="field">
|
25
25
|
<%= f.label :user_id -%> <br />
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<th><%= t('activerecord.attributes.inventory_file.inventory_file_name') -%> </th>
|
8
8
|
<th><%= t('activerecord.attributes.inventory_file.inventory_content_type') -%> </th>
|
9
9
|
<th><%= t('activerecord.attributes.inventory_file.inventory_file_size') -%> </th>
|
10
|
-
<th><%= t('activerecord.attributes.inventory_file.
|
10
|
+
<th><%= t('activerecord.attributes.inventory_file.file_hash') -%> </th>
|
11
11
|
<th><%= t('activerecord.models.user') -%> </th>
|
12
12
|
<th><%= t('activerecord.attributes.inventory_file.note') -%> </th>
|
13
13
|
</tr>
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<td><%= inventory_file.inventory_file_name -%> </td>
|
18
18
|
<td><%= inventory_file.inventory_content_type -%> </td>
|
19
19
|
<td><%= inventory_file.inventory_file_size -%> </td>
|
20
|
-
<td><%= inventory_file.
|
20
|
+
<td><%= inventory_file.file_hash -%> </td>
|
21
21
|
<td><%= link_to inventory_file.user.username, inventory_file.user -%> </td>
|
22
22
|
<td><%= inventory_file.note -%> </td>
|
23
23
|
<td><%= link_to t('page.show'), inventory_file -%> </td>
|
@@ -19,8 +19,8 @@
|
|
19
19
|
</p>
|
20
20
|
|
21
21
|
<p>
|
22
|
-
<strong><%= t('activerecord.attributes.inventory_file.
|
23
|
-
<%= @inventory_file.
|
22
|
+
<strong><%= t('activerecord.attributes.inventory_file.file_hash') -%> :</strong>
|
23
|
+
<%= @inventory_file.file_hash -%>
|
24
24
|
</p>
|
25
25
|
|
26
26
|
<p>
|
@@ -4,12 +4,14 @@ class CreateInventoryFiles < ActiveRecord::Migration
|
|
4
4
|
t.string :filename
|
5
5
|
t.string :content_type
|
6
6
|
t.integer :size
|
7
|
+
t.string :file_hash
|
7
8
|
t.integer :user_id
|
8
9
|
t.text :note
|
9
10
|
|
10
11
|
t.timestamps
|
11
12
|
end
|
12
13
|
add_index :inventory_files, :user_id
|
14
|
+
add_index :inventory_files, :file_hash
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.down
|
data/lib/enju_inventory.rb
CHANGED
@@ -1,21 +1,4 @@
|
|
1
1
|
require "enju_inventory/engine"
|
2
2
|
|
3
3
|
module EnjuInventory
|
4
|
-
def self.included(base)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def enju_inventory
|
10
|
-
include EnjuInventory::InstanceMethods
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module InstanceMethods
|
15
|
-
def get_inventory_file
|
16
|
-
@inventory_file = InventoryFile.find(params[:inventory_file_id]) if params[:inventory_file_id]
|
17
|
-
end
|
18
|
-
end
|
19
4
|
end
|
20
|
-
|
21
|
-
ActionController::Base.send(:include, EnjuInventory)
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'devise'
|
2
|
+
require 'cancan'
|
2
3
|
require 'paperclip'
|
3
4
|
require 'inherited_resources'
|
5
|
+
require 'will_paginate'
|
6
|
+
require 'sunspot_rails'
|
4
7
|
|
5
8
|
module EnjuInventory
|
6
|
-
class Engine <
|
9
|
+
class Engine < Rails::Engine
|
7
10
|
end
|
8
11
|
end
|
@@ -92,6 +92,10 @@ Devise.setup do |config|
|
|
92
92
|
# If true, extends the user's remember period when remembered via cookie.
|
93
93
|
# config.extend_remember_period = false
|
94
94
|
|
95
|
+
# If true, uses the password salt as remember token. This should be turned
|
96
|
+
# to false if you are not using database authenticatable.
|
97
|
+
config.use_salt_as_remember_token = true
|
98
|
+
|
95
99
|
# Options to be passed to the created cookie. For instance, you can set
|
96
100
|
# :secure => true in order to force SSL only cookies.
|
97
101
|
# config.cookie_options = {}
|
Binary file
|
@@ -1,40 +1,19 @@
|
|
1
1
|
class AddDeviseToUsers < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
change_table(:users) do |t|
|
4
|
-
|
5
|
-
t.
|
6
|
-
t.
|
4
|
+
t.database_authenticatable :null => false
|
5
|
+
t.recoverable
|
6
|
+
t.rememberable
|
7
|
+
t.trackable
|
7
8
|
|
8
|
-
|
9
|
-
t.
|
10
|
-
t.
|
9
|
+
# t.encryptable
|
10
|
+
# t.confirmable
|
11
|
+
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
|
12
|
+
# t.token_authenticatable
|
11
13
|
|
12
|
-
## Rememberable
|
13
|
-
t.datetime :remember_created_at
|
14
14
|
|
15
|
-
|
16
|
-
t.
|
17
|
-
t.datetime :current_sign_in_at
|
18
|
-
t.datetime :last_sign_in_at
|
19
|
-
t.string :current_sign_in_ip
|
20
|
-
t.string :last_sign_in_ip
|
21
|
-
|
22
|
-
## Encryptable
|
23
|
-
t.string :password_salt
|
24
|
-
|
25
|
-
## Confirmable
|
26
|
-
t.string :confirmation_token
|
27
|
-
t.datetime :confirmed_at
|
28
|
-
t.datetime :confirmation_sent_at
|
29
|
-
t.string :unconfirmed_email # Only if using reconfirmable
|
30
|
-
|
31
|
-
## Lockable
|
32
|
-
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
33
|
-
t.string :unlock_token # Only if unlock strategy is :email or :both
|
34
|
-
t.datetime :locked_at
|
35
|
-
|
36
|
-
# Token authenticatable
|
37
|
-
t.string :authentication_token
|
15
|
+
# Uncomment below if timestamps were not included in your original model.
|
16
|
+
# t.timestamps
|
38
17
|
end
|
39
18
|
|
40
19
|
add_index :users, :email #, :unique => true
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -28,6 +28,7 @@ ActiveRecord::Schema.define(:version => 20120413100431) do
|
|
28
28
|
t.string "filename"
|
29
29
|
t.string "content_type"
|
30
30
|
t.integer "size"
|
31
|
+
t.string "file_hash"
|
31
32
|
t.integer "user_id"
|
32
33
|
t.text "note"
|
33
34
|
t.datetime "created_at", :null => false
|
@@ -36,9 +37,10 @@ ActiveRecord::Schema.define(:version => 20120413100431) do
|
|
36
37
|
t.string "inventory_content_type"
|
37
38
|
t.integer "inventory_file_size"
|
38
39
|
t.datetime "inventory_updated_at"
|
39
|
-
t.string "
|
40
|
+
t.string "fingerprint"
|
40
41
|
end
|
41
42
|
|
43
|
+
add_index "inventory_files", ["file_hash"], :name => "index_inventory_files_on_file_hash"
|
42
44
|
add_index "inventory_files", ["user_id"], :name => "index_inventory_files_on_user_id"
|
43
45
|
|
44
46
|
create_table "items", :force => true do |t|
|
@@ -92,27 +94,18 @@ ActiveRecord::Schema.define(:version => 20120413100431) do
|
|
92
94
|
t.string "username"
|
93
95
|
t.text "note"
|
94
96
|
t.string "locale"
|
95
|
-
t.datetime "created_at",
|
96
|
-
t.datetime "updated_at",
|
97
|
-
t.string "email",
|
98
|
-
t.string "encrypted_password", :default => "", :null => false
|
97
|
+
t.datetime "created_at", :null => false
|
98
|
+
t.datetime "updated_at", :null => false
|
99
|
+
t.string "email", :default => "", :null => false
|
100
|
+
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
99
101
|
t.string "reset_password_token"
|
100
102
|
t.datetime "reset_password_sent_at"
|
101
103
|
t.datetime "remember_created_at"
|
102
|
-
t.integer "sign_in_count",
|
104
|
+
t.integer "sign_in_count", :default => 0
|
103
105
|
t.datetime "current_sign_in_at"
|
104
106
|
t.datetime "last_sign_in_at"
|
105
107
|
t.string "current_sign_in_ip"
|
106
108
|
t.string "last_sign_in_ip"
|
107
|
-
t.string "password_salt"
|
108
|
-
t.string "confirmation_token"
|
109
|
-
t.datetime "confirmed_at"
|
110
|
-
t.datetime "confirmation_sent_at"
|
111
|
-
t.string "unconfirmed_email"
|
112
|
-
t.integer "failed_attempts", :default => 0
|
113
|
-
t.string "unlock_token"
|
114
|
-
t.datetime "locked_at"
|
115
|
-
t.string "authentication_token"
|
116
109
|
end
|
117
110
|
|
118
111
|
add_index "users", ["email"], :name => "index_users_on_email"
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -4,18 +4,21 @@ inventory_file_00001:
|
|
4
4
|
id: 1
|
5
5
|
inventory_file_name: MyString
|
6
6
|
inventory_file_size: 1
|
7
|
+
file_hash: MyString
|
7
8
|
user_id: 1
|
8
9
|
inventory_content_type: text/csv
|
9
10
|
inventory_file_00002:
|
10
11
|
id: 2
|
11
12
|
inventory_file_name: MyString
|
12
13
|
inventory_file_size: 1
|
14
|
+
file_hash: MyString
|
13
15
|
user_id: 1
|
14
16
|
inventory_content_type: text/csv
|
15
17
|
inventory_file_00003:
|
16
18
|
id: 3
|
17
19
|
inventory_file_name: MyString
|
18
20
|
inventory_file_size: 1
|
21
|
+
file_hash: MyString
|
19
22
|
user_id: 1
|
20
23
|
inventory_content_type: text/csv
|
21
24
|
|
@@ -27,14 +30,14 @@ inventory_file_00003:
|
|
27
30
|
# filename :string(255)
|
28
31
|
# content_type :string(255)
|
29
32
|
# size :integer
|
33
|
+
# file_hash :string(255)
|
30
34
|
# user_id :integer
|
31
35
|
# note :text
|
32
|
-
# created_at :datetime
|
33
|
-
# updated_at :datetime
|
36
|
+
# created_at :datetime
|
37
|
+
# updated_at :datetime
|
34
38
|
# inventory_file_name :string(255)
|
35
39
|
# inventory_content_type :string(255)
|
36
40
|
# inventory_file_size :integer
|
37
41
|
# inventory_updated_at :datetime
|
38
|
-
# inventory_fingerprint :string(255)
|
39
42
|
#
|
40
43
|
|
@@ -2,12 +2,8 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe InventoryFile do
|
5
|
-
fixtures :users
|
6
|
-
|
7
5
|
before(:each) do
|
8
|
-
@file = InventoryFile.
|
9
|
-
@file.user = users(:admin)
|
10
|
-
@file.save
|
6
|
+
@file = InventoryFile.create :inventory => File.new("#{Rails.root.to_s}/../../examples/inventory_file_sample.tsv"), :user => FactoryGirl.create(:user)
|
11
7
|
end
|
12
8
|
|
13
9
|
it "should be imported" do
|
@@ -23,14 +19,14 @@ end
|
|
23
19
|
# filename :string(255)
|
24
20
|
# content_type :string(255)
|
25
21
|
# size :integer
|
22
|
+
# file_hash :string(255)
|
26
23
|
# user_id :integer
|
27
24
|
# note :text
|
28
|
-
# created_at :datetime
|
29
|
-
# updated_at :datetime
|
25
|
+
# created_at :datetime
|
26
|
+
# updated_at :datetime
|
30
27
|
# inventory_file_name :string(255)
|
31
28
|
# inventory_content_type :string(255)
|
32
29
|
# inventory_file_size :integer
|
33
30
|
# inventory_updated_at :datetime
|
34
|
-
# inventory_fingerprint :string(255)
|
35
31
|
#
|
36
32
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70139511942120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,31 +21,43 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: *70139511942120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: devise
|
27
|
+
requirement: &70139511941460 !ruby/object:Gem::Requirement
|
25
28
|
none: false
|
26
29
|
requirements:
|
27
|
-
- -
|
30
|
+
- - ! '>='
|
28
31
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70139511941460
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
+
name: cancan
|
38
|
+
requirement: &70139511940820 !ruby/object:Gem::Requirement
|
33
39
|
none: false
|
34
40
|
requirements:
|
35
|
-
- -
|
41
|
+
- - ! '>='
|
36
42
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
43
|
+
version: '0'
|
38
44
|
type: :runtime
|
39
45
|
prerelease: false
|
40
|
-
version_requirements:
|
46
|
+
version_requirements: *70139511940820
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: paperclip
|
49
|
+
requirement: &70139511940200 !ruby/object:Gem::Requirement
|
41
50
|
none: false
|
42
51
|
requirements:
|
43
52
|
- - ~>
|
44
53
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
54
|
+
version: '3.0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70139511940200
|
46
58
|
- !ruby/object:Gem::Dependency
|
47
59
|
name: inherited_resources
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &70139511939540 !ruby/object:Gem::Requirement
|
49
61
|
none: false
|
50
62
|
requirements:
|
51
63
|
- - ! '>='
|
@@ -53,15 +65,21 @@ dependencies:
|
|
53
65
|
version: '0'
|
54
66
|
type: :runtime
|
55
67
|
prerelease: false
|
56
|
-
version_requirements:
|
68
|
+
version_requirements: *70139511939540
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: will_paginate
|
71
|
+
requirement: &70139511955260 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
73
|
requirements:
|
59
74
|
- - ! '>='
|
60
75
|
- !ruby/object:Gem::Version
|
61
76
|
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70139511955260
|
62
80
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
+
name: sunspot_rails
|
82
|
+
requirement: &70139511954820 !ruby/object:Gem::Requirement
|
65
83
|
none: false
|
66
84
|
requirements:
|
67
85
|
- - ! '>='
|
@@ -69,15 +87,21 @@ dependencies:
|
|
69
87
|
version: '0'
|
70
88
|
type: :runtime
|
71
89
|
prerelease: false
|
72
|
-
version_requirements:
|
90
|
+
version_requirements: *70139511954820
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: sunspot_solr
|
93
|
+
requirement: &70139511954300 !ruby/object:Gem::Requirement
|
73
94
|
none: false
|
74
95
|
requirements:
|
75
96
|
- - ! '>='
|
76
97
|
- !ruby/object:Gem::Version
|
77
98
|
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70139511954300
|
78
102
|
- !ruby/object:Gem::Dependency
|
79
103
|
name: sqlite3
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirement: &70139511953520 !ruby/object:Gem::Requirement
|
81
105
|
none: false
|
82
106
|
requirements:
|
83
107
|
- - ! '>='
|
@@ -85,15 +109,10 @@ dependencies:
|
|
85
109
|
version: '0'
|
86
110
|
type: :development
|
87
111
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
112
|
+
version_requirements: *70139511953520
|
94
113
|
- !ruby/object:Gem::Dependency
|
95
114
|
name: rspec-rails
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirement: &70139511952680 !ruby/object:Gem::Requirement
|
97
116
|
none: false
|
98
117
|
requirements:
|
99
118
|
- - ! '>='
|
@@ -101,44 +120,18 @@ dependencies:
|
|
101
120
|
version: '0'
|
102
121
|
type: :development
|
103
122
|
prerelease: false
|
104
|
-
version_requirements:
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
123
|
+
version_requirements: *70139511952680
|
110
124
|
- !ruby/object:Gem::Dependency
|
111
125
|
name: factory_girl_rails
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: sunspot_solr
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirement: &70139511951880 !ruby/object:Gem::Requirement
|
129
127
|
none: false
|
130
128
|
requirements:
|
131
129
|
- - ~>
|
132
130
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
131
|
+
version: '3.0'
|
134
132
|
type: :development
|
135
133
|
prerelease: false
|
136
|
-
version_requirements:
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 2.0.0.pre.120720
|
134
|
+
version_requirements: *70139511951880
|
142
135
|
description: Inventory management for Next-L Enju
|
143
136
|
email:
|
144
137
|
- tanabe@mwr.mediacom.keio.ac.jp
|
@@ -222,7 +215,6 @@ files:
|
|
222
215
|
- spec/dummy/public/500.html
|
223
216
|
- spec/dummy/public/favicon.ico
|
224
217
|
- spec/dummy/Rakefile
|
225
|
-
- spec/dummy/README.rdoc
|
226
218
|
- spec/dummy/script/rails
|
227
219
|
- spec/factories/user.rb
|
228
220
|
- spec/fixtures/inventories.yml
|
@@ -255,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
247
|
version: '0'
|
256
248
|
requirements: []
|
257
249
|
rubyforge_project:
|
258
|
-
rubygems_version: 1.8.
|
250
|
+
rubygems_version: 1.8.11
|
259
251
|
signing_key:
|
260
252
|
specification_version: 3
|
261
253
|
summary: enju_inventory plugin
|
@@ -310,7 +302,6 @@ test_files:
|
|
310
302
|
- spec/dummy/public/500.html
|
311
303
|
- spec/dummy/public/favicon.ico
|
312
304
|
- spec/dummy/Rakefile
|
313
|
-
- spec/dummy/README.rdoc
|
314
305
|
- spec/dummy/script/rails
|
315
306
|
- spec/factories/user.rb
|
316
307
|
- spec/fixtures/inventories.yml
|
data/spec/dummy/README.rdoc
DELETED
@@ -1,261 +0,0 @@
|
|
1
|
-
== Welcome to Rails
|
2
|
-
|
3
|
-
Rails is a web-application framework that includes everything needed to create
|
4
|
-
database-backed web applications according to the Model-View-Control pattern.
|
5
|
-
|
6
|
-
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
-
templates that are primarily responsible for inserting pre-built data in between
|
8
|
-
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
-
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
-
persist themselves to a database. The controller handles the incoming requests
|
11
|
-
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
-
and directing data to the view.
|
13
|
-
|
14
|
-
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
-
layer entitled Active Record. This layer allows you to present the data from
|
16
|
-
database rows as objects and embellish these data objects with business logic
|
17
|
-
methods. You can read more about Active Record in
|
18
|
-
link:files/vendor/rails/activerecord/README.html.
|
19
|
-
|
20
|
-
The controller and view are handled by the Action Pack, which handles both
|
21
|
-
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
-
are bundled in a single package due to their heavy interdependence. This is
|
23
|
-
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
-
more separate. Each of these packages can be used independently outside of
|
25
|
-
Rails. You can read more about Action Pack in
|
26
|
-
link:files/vendor/rails/actionpack/README.html.
|
27
|
-
|
28
|
-
|
29
|
-
== Getting Started
|
30
|
-
|
31
|
-
1. At the command prompt, create a new Rails application:
|
32
|
-
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
-
|
34
|
-
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
-
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
-
|
37
|
-
3. Go to http://localhost:3000/ and you'll see:
|
38
|
-
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
-
|
40
|
-
4. Follow the guidelines to start developing your application. You can find
|
41
|
-
the following resources handy:
|
42
|
-
|
43
|
-
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
-
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
-
|
46
|
-
|
47
|
-
== Debugging Rails
|
48
|
-
|
49
|
-
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
-
will help you debug it and get it back on the rails.
|
51
|
-
|
52
|
-
First area to check is the application log files. Have "tail -f" commands
|
53
|
-
running on the server.log and development.log. Rails will automatically display
|
54
|
-
debugging and runtime information to these files. Debugging info will also be
|
55
|
-
shown in the browser on requests from 127.0.0.1.
|
56
|
-
|
57
|
-
You can also log your own messages directly into the log file from your code
|
58
|
-
using the Ruby logger class from inside your controllers. Example:
|
59
|
-
|
60
|
-
class WeblogController < ActionController::Base
|
61
|
-
def destroy
|
62
|
-
@weblog = Weblog.find(params[:id])
|
63
|
-
@weblog.destroy
|
64
|
-
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
The result will be a message in your log file along the lines of:
|
69
|
-
|
70
|
-
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
-
|
72
|
-
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
-
|
74
|
-
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
-
several books available online as well:
|
76
|
-
|
77
|
-
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
-
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
-
|
80
|
-
These two books will bring you up to speed on the Ruby language and also on
|
81
|
-
programming in general.
|
82
|
-
|
83
|
-
|
84
|
-
== Debugger
|
85
|
-
|
86
|
-
Debugger support is available through the debugger command when you start your
|
87
|
-
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
-
execution at any point in the code, investigate and change the model, and then,
|
89
|
-
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
-
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
-
|
92
|
-
class WeblogController < ActionController::Base
|
93
|
-
def index
|
94
|
-
@posts = Post.all
|
95
|
-
debugger
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
So the controller will accept the action, run the first line, then present you
|
100
|
-
with a IRB prompt in the server window. Here you can do things like:
|
101
|
-
|
102
|
-
>> @posts.inspect
|
103
|
-
=> "[#<Post:0x14a6be8
|
104
|
-
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
-
#<Post:0x14a6620
|
106
|
-
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
-
>> @posts.first.title = "hello from a debugger"
|
108
|
-
=> "hello from a debugger"
|
109
|
-
|
110
|
-
...and even better, you can examine how your runtime objects actually work:
|
111
|
-
|
112
|
-
>> f = @posts.first
|
113
|
-
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
-
>> f.
|
115
|
-
Display all 152 possibilities? (y or n)
|
116
|
-
|
117
|
-
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
-
|
119
|
-
|
120
|
-
== Console
|
121
|
-
|
122
|
-
The console is a Ruby shell, which allows you to interact with your
|
123
|
-
application's domain model. Here you'll have all parts of the application
|
124
|
-
configured, just like it is when the application is running. You can inspect
|
125
|
-
domain models, change values, and save to the database. Starting the script
|
126
|
-
without arguments will launch it in the development environment.
|
127
|
-
|
128
|
-
To start the console, run <tt>rails console</tt> from the application
|
129
|
-
directory.
|
130
|
-
|
131
|
-
Options:
|
132
|
-
|
133
|
-
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
-
made to the database.
|
135
|
-
* Passing an environment name as an argument will load the corresponding
|
136
|
-
environment. Example: <tt>rails console production</tt>.
|
137
|
-
|
138
|
-
To reload your controllers and models after launching the console run
|
139
|
-
<tt>reload!</tt>
|
140
|
-
|
141
|
-
More information about irb can be found at:
|
142
|
-
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
-
|
144
|
-
|
145
|
-
== dbconsole
|
146
|
-
|
147
|
-
You can go to the command line of your database directly through <tt>rails
|
148
|
-
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
-
defined in database.yml. Starting the script without arguments will connect you
|
150
|
-
to the development database. Passing an argument will connect you to a different
|
151
|
-
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
-
PostgreSQL and SQLite 3.
|
153
|
-
|
154
|
-
== Description of Contents
|
155
|
-
|
156
|
-
The default directory structure of a generated Ruby on Rails application:
|
157
|
-
|
158
|
-
|-- app
|
159
|
-
| |-- assets
|
160
|
-
| |-- images
|
161
|
-
| |-- javascripts
|
162
|
-
| `-- stylesheets
|
163
|
-
| |-- controllers
|
164
|
-
| |-- helpers
|
165
|
-
| |-- mailers
|
166
|
-
| |-- models
|
167
|
-
| `-- views
|
168
|
-
| `-- layouts
|
169
|
-
|-- config
|
170
|
-
| |-- environments
|
171
|
-
| |-- initializers
|
172
|
-
| `-- locales
|
173
|
-
|-- db
|
174
|
-
|-- doc
|
175
|
-
|-- lib
|
176
|
-
| `-- tasks
|
177
|
-
|-- log
|
178
|
-
|-- public
|
179
|
-
|-- script
|
180
|
-
|-- test
|
181
|
-
| |-- fixtures
|
182
|
-
| |-- functional
|
183
|
-
| |-- integration
|
184
|
-
| |-- performance
|
185
|
-
| `-- unit
|
186
|
-
|-- tmp
|
187
|
-
| |-- cache
|
188
|
-
| |-- pids
|
189
|
-
| |-- sessions
|
190
|
-
| `-- sockets
|
191
|
-
`-- vendor
|
192
|
-
|-- assets
|
193
|
-
`-- stylesheets
|
194
|
-
`-- plugins
|
195
|
-
|
196
|
-
app
|
197
|
-
Holds all the code that's specific to this particular application.
|
198
|
-
|
199
|
-
app/assets
|
200
|
-
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
-
|
202
|
-
app/controllers
|
203
|
-
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
-
automated URL mapping. All controllers should descend from
|
205
|
-
ApplicationController which itself descends from ActionController::Base.
|
206
|
-
|
207
|
-
app/models
|
208
|
-
Holds models that should be named like post.rb. Models descend from
|
209
|
-
ActiveRecord::Base by default.
|
210
|
-
|
211
|
-
app/views
|
212
|
-
Holds the template files for the view that should be named like
|
213
|
-
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
-
eRuby syntax by default.
|
215
|
-
|
216
|
-
app/views/layouts
|
217
|
-
Holds the template files for layouts to be used with views. This models the
|
218
|
-
common header/footer method of wrapping views. In your views, define a layout
|
219
|
-
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
-
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
-
layout.
|
222
|
-
|
223
|
-
app/helpers
|
224
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
-
generated for you automatically when using generators for controllers.
|
226
|
-
Helpers can be used to wrap functionality for your views into methods.
|
227
|
-
|
228
|
-
config
|
229
|
-
Configuration files for the Rails environment, the routing map, the database,
|
230
|
-
and other dependencies.
|
231
|
-
|
232
|
-
db
|
233
|
-
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
-
sequence of Migrations for your schema.
|
235
|
-
|
236
|
-
doc
|
237
|
-
This directory is where your application documentation will be stored when
|
238
|
-
generated using <tt>rake doc:app</tt>
|
239
|
-
|
240
|
-
lib
|
241
|
-
Application specific libraries. Basically, any kind of custom code that
|
242
|
-
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
-
the load path.
|
244
|
-
|
245
|
-
public
|
246
|
-
The directory available for the web server. Also contains the dispatchers and the
|
247
|
-
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
-
server.
|
249
|
-
|
250
|
-
script
|
251
|
-
Helper scripts for automation and generation.
|
252
|
-
|
253
|
-
test
|
254
|
-
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
-
command, template test files will be generated for you and placed in this
|
256
|
-
directory.
|
257
|
-
|
258
|
-
vendor
|
259
|
-
External libraries that the application depends on. Also includes the plugins
|
260
|
-
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
-
vendor/rails/. This directory is in the load path.
|