make 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/make +2 -2
- data/lib/make/form.rb +10 -10
- data/lib/make/table.rb +15 -6
- data/lib/make.rb +0 -3
- 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: 79ac078514af6ee434000d2190d1849f5bbba72b
|
4
|
+
data.tar.gz: 4f02f085249edbe40ed8747f415e3fcf5236f2b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b2cb3222c3e2a46764c4374e93d82855bc786245e82ab2a8cd16642f0a90e765604e936ff261d7f7505f92e81868d5c73d26a81a73da77e13e195c0cdadfd08
|
7
|
+
data.tar.gz: 0c11cd30284a5342cf65b656a13877401ef598f654ab5c5e8411a9a460f333265a0daf2c54036dfd3f631dc38eaad085937aaca7571adb79c8054812ec2c36d3
|
data/bin/make
CHANGED
data/lib/make/form.rb
CHANGED
@@ -7,7 +7,7 @@ class Form
|
|
7
7
|
@formMethodHidden=nil
|
8
8
|
@formStart=''
|
9
9
|
@formMiddle=[]
|
10
|
-
@formEnd='<input id="authenticity_token" name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>"
|
10
|
+
@formEnd='\n\t<input id="authenticity_token" name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>">\n\t<input type="submit" value="Submit">\n</form>'
|
11
11
|
@default_keys_to_ignore = ['id', 'created_at', 'updated_at']
|
12
12
|
@potential_keys_to_ignore = ['salt']
|
13
13
|
@defaults = {}
|
@@ -58,19 +58,19 @@ class Form
|
|
58
58
|
# Similar to default, but instead of a hidden specific value you pass in an array and create a select/option field.
|
59
59
|
def select column, array, assoc = false
|
60
60
|
columnName = column.titleize
|
61
|
-
input = '<label>' + columnName + '</label
|
61
|
+
input = '\n\t<label>' + columnName + '\n\t</label>\n\t<select name="' + @modelName + '[' + column + ']">'
|
62
62
|
if assoc #if association is checked true
|
63
63
|
array.each do |id|
|
64
64
|
val = column[0...-3].capitalize.constantize.find(id).attributes.values[1]
|
65
|
-
input += '<option value="' + id.to_s + '">' + val.to_s + '</option>'
|
65
|
+
input += '\n\t\t\t<option value="' + id.to_s + '">' + val.to_s + '</option>'
|
66
66
|
end
|
67
67
|
else #if no associations exist for array
|
68
68
|
array.each do |item|
|
69
|
-
input += '<option value="' + item.to_s + '">' + item.to_s + '</option>'
|
69
|
+
input += '\n\t\t\t<option value="' + item.to_s + '">' + item.to_s + '</option>'
|
70
70
|
end
|
71
71
|
end
|
72
72
|
@potential_keys_to_ignore.push(column)
|
73
|
-
input += '</select>'
|
73
|
+
input += '\n\t</select>'
|
74
74
|
@formMiddle.push(input)
|
75
75
|
return self
|
76
76
|
end
|
@@ -78,7 +78,7 @@ class Form
|
|
78
78
|
def starter
|
79
79
|
if @formMethodHidden
|
80
80
|
@formStart = '<form class="' + @formClass + '" action="' + @formAction + '/'+ @id.to_s + '" method="' + @formMethod + '">'
|
81
|
-
@formStart += '<input name="_method" type="hidden" value="' + @formMethodHidden + '">'
|
81
|
+
@formStart += '\n\t<input name="_method" type="hidden" value="' + @formMethodHidden + '">'
|
82
82
|
else
|
83
83
|
@formStart = '<form class="' + @formClass + '" action="' + @formAction + '" method="' + @formMethod + '">'
|
84
84
|
end
|
@@ -95,19 +95,19 @@ class Form
|
|
95
95
|
# Create text input labels
|
96
96
|
@columns.each do |column|
|
97
97
|
if column.include? 'password'
|
98
|
-
input = '<label>Password</label
|
98
|
+
input = '\n\t<label>Password</label>\n\t<input type="text" name="' + @modelName + '[password]">'
|
99
99
|
@formMiddle.push(input)
|
100
100
|
if @password_confirmation
|
101
|
-
input = '<label>Confirm Password</label
|
101
|
+
input = '\n\t<label>Confirm Password</label>\n\t<input type="text"' + @modelName + '[password_confirmation]">'
|
102
102
|
@formMiddle.push(input)
|
103
103
|
end
|
104
104
|
else
|
105
|
-
input = '<label>' + column.titleize + '</label
|
105
|
+
input = '\n\t<label>' + column.titleize + '\n\t</label>\n\t<input type="text" name="' + @modelName + '[' + column + ']">'
|
106
106
|
@formMiddle.push(input)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
@defaults.each_pair do |key, value|
|
110
|
-
input = '<input type="hidden" name="'+ @modelName + '[' + key.to_s + ']" value="' + value.to_s + '">'
|
110
|
+
input = '\n\t<input type="hidden" name="'+ @modelName + '[' + key.to_s + ']" value="' + value.to_s + '">'
|
111
111
|
puts input
|
112
112
|
puts @formMiddle
|
113
113
|
@formMiddle.push(input)
|
data/lib/make/table.rb
CHANGED
@@ -10,6 +10,7 @@ class Table
|
|
10
10
|
@crud=''
|
11
11
|
@all_columns=[]
|
12
12
|
@run_make_head=true
|
13
|
+
@file=false
|
13
14
|
end
|
14
15
|
|
15
16
|
# Assigns desired column names to be combined
|
@@ -141,7 +142,13 @@ class Table
|
|
141
142
|
end
|
142
143
|
|
143
144
|
# Writes table html code to 'table_html.txt' file located in application's root folder
|
144
|
-
def file
|
145
|
+
def file!
|
146
|
+
remake_columns
|
147
|
+
if @run_make_head
|
148
|
+
make_head
|
149
|
+
end
|
150
|
+
make_body
|
151
|
+
@file=true
|
145
152
|
File.open('table_html.txt', 'w') { |f| f.write(("<table>\n\t<thead>\n\t\t<tr>"+@thead+"\n\t\t</tr>\n\t</thead>\n\t<tbody>"+@tbody+"\n\t</tbody>\n</table>")) }
|
146
153
|
return self
|
147
154
|
end
|
@@ -162,11 +169,13 @@ class Table
|
|
162
169
|
|
163
170
|
# Place table code into view
|
164
171
|
def now!
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
172
|
+
if !@file
|
173
|
+
remake_columns
|
174
|
+
if @run_make_head
|
175
|
+
make_head
|
176
|
+
end
|
177
|
+
make_body
|
178
|
+
end
|
170
179
|
return ('<table><thead><tr>'+@thead+'</tr></thead><tbody>'+@tbody+'</tbody></table>').html_safe
|
171
180
|
end
|
172
181
|
end
|
data/lib/make.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sara Wong
|
@@ -15,7 +15,7 @@ description: A gem that shortcuts typing out forms for SQL users. Assuming your
|
|
15
15
|
is named Model_Name, just type <%= Make.form(Model) %> wherever in your Rails view
|
16
16
|
and it will return an html-safe string from your column names for creating a new
|
17
17
|
record. In addition, you can type <%= Make.table.model("Table_Name").now! %> to
|
18
|
-
automatically generate a table.
|
18
|
+
automatically generate a table. Use <%= Make.header("Title") to make a default header.
|
19
19
|
email:
|
20
20
|
- swong2@wellesley.edu
|
21
21
|
- utemoc@gmail.com
|