marty 1.0.26 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -4
- data/app/components/marty/extras/layout.rb +2 -1
- data/app/models/marty/data_grid.rb +6 -2
- data/app/models/marty/pg_enum.rb +8 -0
- data/lib/marty/migrations.rb +22 -1
- data/lib/marty/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32549066e0c8789c2965387c0a5351ae672f454d
|
4
|
+
data.tar.gz: e6cf959267b704fb809bb145c58ff38723b863eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af5710ceabc29629e4261e8fd3fda9ac7f350b7e609ddefe1c347106fee24a6988399b9bc3a5e430e09b81adbfd5ce5b1ad6e9b97d0ea3467ba714ca5f112c4a
|
7
|
+
data.tar.gz: ffe61d68b9c660770436a74ed835db71648a95c89143f0b15e7d8bc5ed92178af27af64bc32c16c678079a241042e25d305abba3146e518589d7034c13a9b571
|
data/README.md
CHANGED
@@ -15,7 +15,8 @@ support for role-based authorization.
|
|
15
15
|
The Marty framework provides several rake tasks to manage its database tables
|
16
16
|
and delorean scripts.
|
17
17
|
|
18
|
-
To create the correct migrations for a Marty-based
|
18
|
+
To create the correct migrations for a Marty-based application (see below for
|
19
|
+
getting the internal dummy application to work):
|
19
20
|
|
20
21
|
```
|
21
22
|
$ rake marty:install:migrations
|
@@ -50,7 +51,7 @@ To delete scripts:
|
|
50
51
|
$ rake marty:delete_scripts
|
51
52
|
```
|
52
53
|
|
53
|
-
# Testing
|
54
|
+
# Dummy Application & Testing
|
54
55
|
|
55
56
|
Make sure that extjs is installed (or symbolically linked) in the
|
56
57
|
dummy app at spec/dummy/public.
|
@@ -63,16 +64,30 @@ You can use the example file by doing:
|
|
63
64
|
$ cp spec/dummy/config/database.yml.example spec/dummy/config/database.yml
|
64
65
|
```
|
65
66
|
|
67
|
+
To initialize the dummy application for a demo run:
|
68
|
+
|
69
|
+
```bash
|
70
|
+
$ bundle install
|
71
|
+
$ bundle exec rake db:create db:migrate db:seed app:marty:load_scripts
|
72
|
+
$ cd spec/dummy
|
73
|
+
$ rails s
|
74
|
+
```
|
75
|
+
|
76
|
+
The marty dummy app should now be accessible in your browser:
|
77
|
+
`localhost:3000`
|
78
|
+
|
79
|
+
You can log in using `marty` as both user and password.
|
80
|
+
|
66
81
|
To create the test database in prepartion to run your tests:
|
67
82
|
|
68
83
|
```bash
|
69
|
-
$ RAILS_ENV=test rake db:create
|
84
|
+
$ RAILS_ENV=test bundle exec rake db:create
|
70
85
|
```
|
71
86
|
|
72
87
|
Then to run the tests:
|
73
88
|
|
74
89
|
```bash
|
75
|
-
$ rspec
|
90
|
+
$ bundle exec rspec
|
76
91
|
```
|
77
92
|
|
78
93
|
# History & Status
|
@@ -75,7 +75,8 @@ module Layout
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def enum_setter(name)
|
78
|
-
lambda {|r, v| r.send("#{name}=", v
|
78
|
+
lambda {|r, v| r.send("#{name}=", v.nil? || v.empty? || v == '---' ?
|
79
|
+
nil : v)}
|
79
80
|
end
|
80
81
|
|
81
82
|
######################################################################
|
@@ -261,8 +261,12 @@ class Marty::DataGrid < Marty::Base
|
|
261
261
|
# not expected to be called from Delorean.
|
262
262
|
cached_delorean_fn :find_class_instance, sig: 3 do
|
263
263
|
|pt, klass, v|
|
264
|
-
|
265
|
-
|
264
|
+
if Marty::PgEnum === klass
|
265
|
+
StringEnum.new(v)
|
266
|
+
else
|
267
|
+
# FIXME: very hacky -- hard-coded name
|
268
|
+
Marty::DataConversion.find_row(klass, {"name" => v}, pt)
|
269
|
+
end
|
266
270
|
end
|
267
271
|
|
268
272
|
def lookup_grid_distinct_entry(pt, h, visited=nil, follow=true,
|
data/app/models/marty/pg_enum.rb
CHANGED
@@ -14,11 +14,19 @@ module Marty::PgEnum
|
|
14
14
|
end
|
15
15
|
|
16
16
|
GET_ALL_SIG = [0, 0]
|
17
|
+
LOOKUP_SIG = [1, 1]
|
18
|
+
FIND_BY_NAME_SIG = [1, 1]
|
17
19
|
def self.extended(base)
|
18
20
|
base.class_eval do
|
19
21
|
const_set :GET_ALL_SIG, Marty::PgEnum::GET_ALL_SIG
|
22
|
+
const_set :LOOKUP_SIG, Marty::PgEnum::LOOKUP_SIG
|
23
|
+
const_set :FIND_BY_NAME_SIG, Marty::PgEnum::FIND_BY_NAME_SIG
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
27
|
+
def seed
|
28
|
+
end
|
29
|
+
|
23
30
|
alias_method :find_by_name, :[]
|
31
|
+
alias_method :lookup, :[]
|
24
32
|
end
|
data/lib/marty/migrations.rb
CHANGED
@@ -249,6 +249,17 @@ OUT
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
+
# some migrations attempt to get the id using the model.
|
253
|
+
# after enumification models have no notion of numeric id
|
254
|
+
# we have to get it from the database
|
255
|
+
def get_old_enum_id(klass, name)
|
256
|
+
ActiveRecord::Base.
|
257
|
+
connection.execute(<<-SQL).to_a.first.try{|v| v['id']}
|
258
|
+
select id from #{klass.table_name} where name =
|
259
|
+
#{ActiveRecord::Base.sanitize(name)}
|
260
|
+
SQL
|
261
|
+
end
|
262
|
+
|
252
263
|
private
|
253
264
|
def fk_opts(from, to, column)
|
254
265
|
name = "fk_#{from}_#{to}_#{column}"
|
@@ -278,7 +289,17 @@ OUT
|
|
278
289
|
"unique_#{klass.table_name}"
|
279
290
|
end
|
280
291
|
|
292
|
+
# if the database does not agree with the model regarding columns,
|
293
|
+
# get the actual column name
|
281
294
|
def get_attrs(klass)
|
282
|
-
(Mcfly.mcfly_uniqueness(klass) + ['obsoleted_dt']).uniq
|
295
|
+
cols = (Mcfly.mcfly_uniqueness(klass) + ['obsoleted_dt']).uniq.map(&:to_s)
|
296
|
+
act_cols = klass.column_names
|
297
|
+
use_cols = cols.map do |col|
|
298
|
+
col_id = col + '_id'
|
299
|
+
act_cols.include?(col) ? col :
|
300
|
+
act_cols.include?(col_id) ? col_id :
|
301
|
+
(raise "problem adding index for #{klass}: "\
|
302
|
+
"cols = #{cols}, act_cols = #{act_cols}")
|
303
|
+
end.map(&:to_sym)
|
283
304
|
end
|
284
305
|
end
|
data/lib/marty/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require 'marty_rspec'
|
|
7
7
|
|
8
8
|
Dummy::Application.initialize!
|
9
9
|
|
10
|
+
ActiveRecord::Migrator.migrate File.expand_path("../../db/migrate/", __FILE__)
|
10
11
|
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
11
12
|
|
12
13
|
Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-05-
|
17
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|