active_model_serializer_plus 1.0.0
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.
- checksums.yaml +7 -0
- data/.yardopts +3 -0
- data/Appraisals +3 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE.md +22 -0
- data/README.md +142 -0
- data/Rakefile +7 -0
- data/active_model_serializer_plus.gemspec +37 -0
- data/gemfiles/rails_4.2.gemfile +7 -0
- data/lib/active_model_serializer_plus.rb +4 -0
- data/lib/active_model_serializer_plus/assignment.rb +64 -0
- data/lib/active_model_serializer_plus/railtie.rb +7 -0
- data/lib/active_model_serializer_plus/translations.rb +218 -0
- data/lib/active_model_serializer_plus/version.rb +6 -0
- data/test/active_model_serializer_plus/active_model_serializer_plus_test.rb +10 -0
- data/test/active_model_serializer_plus/assignment_test.rb +64 -0
- data/test/active_model_serializer_plus/translations_test.rb +260 -0
- data/test/app/rails_4.2/Rakefile +6 -0
- data/test/app/rails_4.2/app/assets/javascripts/application.js +16 -0
- data/test/app/rails_4.2/app/assets/stylesheets/application.css +15 -0
- data/test/app/rails_4.2/app/controllers/application_controller.rb +5 -0
- data/test/app/rails_4.2/app/helpers/application_helper.rb +2 -0
- data/test/app/rails_4.2/app/views/layouts/application.html.erb +14 -0
- data/test/app/rails_4.2/bin/bundle +3 -0
- data/test/app/rails_4.2/bin/rails +8 -0
- data/test/app/rails_4.2/bin/rake +8 -0
- data/test/app/rails_4.2/bin/setup +29 -0
- data/test/app/rails_4.2/bin/spring +15 -0
- data/test/app/rails_4.2/config.ru +4 -0
- data/test/app/rails_4.2/config/application.rb +26 -0
- data/test/app/rails_4.2/config/boot.rb +3 -0
- data/test/app/rails_4.2/config/database.yml +25 -0
- data/test/app/rails_4.2/config/environment.rb +5 -0
- data/test/app/rails_4.2/config/environments/development.rb +41 -0
- data/test/app/rails_4.2/config/environments/production.rb +79 -0
- data/test/app/rails_4.2/config/environments/test.rb +42 -0
- data/test/app/rails_4.2/config/initializers/assets.rb +11 -0
- data/test/app/rails_4.2/config/initializers/backtrace_silencers.rb +7 -0
- data/test/app/rails_4.2/config/initializers/cookies_serializer.rb +3 -0
- data/test/app/rails_4.2/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/app/rails_4.2/config/initializers/inflections.rb +16 -0
- data/test/app/rails_4.2/config/initializers/mime_types.rb +4 -0
- data/test/app/rails_4.2/config/initializers/session_store.rb +3 -0
- data/test/app/rails_4.2/config/initializers/wrap_parameters.rb +14 -0
- data/test/app/rails_4.2/config/locales/en.yml +23 -0
- data/test/app/rails_4.2/config/routes.rb +56 -0
- data/test/app/rails_4.2/config/secrets.yml +22 -0
- data/test/app/rails_4.2/db/schema.rb +0 -0
- data/test/app/rails_4.2/db/seeds.rb +7 -0
- data/test/app/rails_4.2/public/404.html +67 -0
- data/test/app/rails_4.2/public/422.html +67 -0
- data/test/app/rails_4.2/public/500.html +66 -0
- data/test/app/rails_4.2/public/favicon.ico +0 -0
- data/test/app/rails_4.2/public/robots.txt +5 -0
- data/test/test_helper.rb +20 -0
- metadata +259 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
require '../test_helper'
|
2
|
+
require 'active_model_serializer_plus'
|
3
|
+
|
4
|
+
class ActiveModelSerializerPlusTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
test 'API' do
|
7
|
+
assert_not_nil ActiveModelSerializerPlus::VERSION
|
8
|
+
assert_kind_of String, ActiveModelSerializerPlus::VERSION
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require '../test_helper'
|
2
|
+
require 'active_model_serializer_plus'
|
3
|
+
|
4
|
+
class InnerClass
|
5
|
+
include ActiveModel::Model
|
6
|
+
include ActiveModel::Serializers::JSON
|
7
|
+
include ActiveModelSerializerPlus::Assignment
|
8
|
+
|
9
|
+
attr_accessor :x
|
10
|
+
|
11
|
+
def attributes
|
12
|
+
{ 'x' => nil
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class ModelClass
|
18
|
+
include ActiveModel::Model
|
19
|
+
include ActiveModel::Serializers::JSON
|
20
|
+
include ActiveModelSerializerPlus::Assignment
|
21
|
+
|
22
|
+
attr_accessor :a
|
23
|
+
attr_accessor :b
|
24
|
+
|
25
|
+
def attributes
|
26
|
+
{ 'a' => nil,
|
27
|
+
'b' => nil
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def attribute_types
|
32
|
+
{ 'b' => 'InnerClass'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class AssignmentTest < ActiveSupport::TestCase
|
38
|
+
include ActiveModel::Lint::Tests
|
39
|
+
|
40
|
+
def setup
|
41
|
+
@model = ModelClass.new
|
42
|
+
@model.a = 'xyzzy'
|
43
|
+
@model.b = InnerClass.new
|
44
|
+
@model.b.x = 15
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'deserialize ModelClass' do
|
48
|
+
json = @model.to_json
|
49
|
+
assert_kind_of String, json, 'convert model to JSON'
|
50
|
+
|
51
|
+
r = ModelClass.new
|
52
|
+
r.from_json(json)
|
53
|
+
assert_not_nil r, 'check new object'
|
54
|
+
assert_kind_of ModelClass, r, 'check new object'
|
55
|
+
assert_not_nil r.a, 'check attribute a'
|
56
|
+
assert_kind_of String, r.a, 'check attribute a'
|
57
|
+
assert_equal 'xyzzy', r.a, 'check attribute a'
|
58
|
+
assert_not_nil r.b, 'check inner object'
|
59
|
+
assert_kind_of InnerClass, r.b, 'check inner object'
|
60
|
+
assert_not_nil r.b.x, 'check attribute x'
|
61
|
+
assert_kind_of Integer, r.b.x, 'check attribute x'
|
62
|
+
assert_equal 15, r.b.x, 'check attribute x'
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
require '../test_helper'
|
2
|
+
require 'active_model_serializer_plus'
|
3
|
+
|
4
|
+
class ParsingClass
|
5
|
+
attr_accessor :x
|
6
|
+
end
|
7
|
+
|
8
|
+
class BuilderClass
|
9
|
+
attr_accessor :a
|
10
|
+
attr_accessor :b
|
11
|
+
end
|
12
|
+
|
13
|
+
class BuilderSubClass < BuilderClass
|
14
|
+
end
|
15
|
+
|
16
|
+
class TranslationsTest < ActiveSupport::TestCase
|
17
|
+
|
18
|
+
def setup
|
19
|
+
@date_today = Date.today
|
20
|
+
@datetime_now = DateTime.now
|
21
|
+
@time_now = Time.now
|
22
|
+
|
23
|
+
@format_parse = ParsingClass.new
|
24
|
+
@format_parse.x = 'xyzzy'
|
25
|
+
@build = BuilderClass.new
|
26
|
+
@build.a = 'attr x'
|
27
|
+
@build.b = 17
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'type name translation' do
|
31
|
+
r_true = ActiveModelSerializerPlus.type_name_xlate('TrueClass')
|
32
|
+
assert_equal 'Boolean', r_true, 'translate TrueClass'
|
33
|
+
r_false = ActiveModelSerializerPlus.type_name_xlate('FalseClass')
|
34
|
+
assert_equal 'Boolean', r_false, 'translate FalseClass'
|
35
|
+
r_hash = ActiveModelSerializerPlus.type_name_xlate('Hash')
|
36
|
+
assert_equal 'Container', r_hash, 'translate Hash'
|
37
|
+
r_array = ActiveModelSerializerPlus.type_name_xlate('Array')
|
38
|
+
assert_equal 'Container', r_array, 'translate Array'
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'format value' do
|
42
|
+
assert_equal @date_today.xmlschema, ActiveModelSerializerPlus.format(@date_today), 'format date'
|
43
|
+
assert_equal @datetime_now.xmlschema, ActiveModelSerializerPlus.format(@datetime_now), 'format datetime'
|
44
|
+
assert_equal @time_now.xmlschema, ActiveModelSerializerPlus.format(@time_now), 'format time'
|
45
|
+
assert_equal '5', ActiveModelSerializerPlus.format(5), 'format integer'
|
46
|
+
assert_equal 'xyzzy', ActiveModelSerializerPlus.format('xyzzy'), 'format string'
|
47
|
+
assert_equal 'true', ActiveModelSerializerPlus.format(true), 'format true'
|
48
|
+
assert_equal 'false', ActiveModelSerializerPlus.format(false), 'format false'
|
49
|
+
assert_equal '7.14', ActiveModelSerializerPlus.format(7.14), 'format float'
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'parse strings' do
|
53
|
+
v = ActiveModelSerializerPlus.parse('Symbol', 'xyzzy')
|
54
|
+
assert_not_nil v, 'Symbol from string'
|
55
|
+
assert_kind_of Symbol, v, 'Symbol from string'
|
56
|
+
assert_equal :xyzzy, v, 'Symbol from string'
|
57
|
+
v = ActiveModelSerializerPlus.parse('Symbol', 5)
|
58
|
+
assert_not_nil v, 'Symbol from integer'
|
59
|
+
assert_kind_of Symbol, v, 'Symbol from integer'
|
60
|
+
assert_equal :'5', v, 'Symbol from integer'
|
61
|
+
v = ActiveModelSerializerPlus.parse('Symbol', [5, 4, 8])
|
62
|
+
assert_not_nil v, 'Symbol from array'
|
63
|
+
assert_kind_of Symbol, v, 'Symbol from array'
|
64
|
+
assert_equal :'[5, 4, 8]', v, 'Symbol from array'
|
65
|
+
|
66
|
+
v = ActiveModelSerializerPlus.parse('Time', @time_now.xmlschema)
|
67
|
+
assert_not_nil v, 'Time from xmlschema'
|
68
|
+
assert_kind_of Time, v, 'Time from xmlschema'
|
69
|
+
assert_equal @time_now.utc.to_s, v.to_s, 'Time from xmlschema'
|
70
|
+
v = ActiveModelSerializerPlus.parse('Time', @time_now.to_s)
|
71
|
+
assert_not_nil v, 'Time from to_s'
|
72
|
+
assert_kind_of Time, v, 'Time from to_s'
|
73
|
+
assert_equal @time_now.to_s, v.to_s, 'Time from to_s'
|
74
|
+
|
75
|
+
v = ActiveModelSerializerPlus.parse('Date', @date_today.xmlschema)
|
76
|
+
assert_not_nil v, 'Date from xmlschema'
|
77
|
+
assert_kind_of Date, v, 'Date from xmlschema'
|
78
|
+
assert_equal @date_today.to_s, v.to_s, 'Date from xmlschema'
|
79
|
+
v = ActiveModelSerializerPlus.parse('Date', @date_today.to_s)
|
80
|
+
assert_not_nil v, 'Date from to_s'
|
81
|
+
assert_kind_of Date, v, 'Date from to_s'
|
82
|
+
assert_equal @date_today.to_s, v.to_s, 'Date from to_s'
|
83
|
+
|
84
|
+
v = ActiveModelSerializerPlus.parse('DateTime', @datetime_now.xmlschema)
|
85
|
+
assert_not_nil v, 'DateTime from xmlschema'
|
86
|
+
assert_kind_of DateTime, v, 'DateTime from xmlschema'
|
87
|
+
assert_equal @datetime_now.to_s, v.to_s, 'DateTime from xmlschema'
|
88
|
+
v = ActiveModelSerializerPlus.parse('DateTime', @datetime_now.to_s)
|
89
|
+
assert_not_nil v, 'DateTime from to_s'
|
90
|
+
assert_kind_of DateTime, v, 'DateTime from to_s'
|
91
|
+
assert_equal @datetime_now.to_s, v.to_s, 'DateTime from to_s'
|
92
|
+
|
93
|
+
v = ActiveModelSerializerPlus.parse('Integer', '5')
|
94
|
+
assert_not_nil v, 'Integer from integer'
|
95
|
+
assert_kind_of Integer, v, 'Integer from integer'
|
96
|
+
assert_equal 5, v, 'Integer from integer'
|
97
|
+
|
98
|
+
v = ActiveModelSerializerPlus.parse('Float', '7.43')
|
99
|
+
assert_not_nil v, 'Float from float'
|
100
|
+
assert_kind_of Float, v, 'Float from float'
|
101
|
+
assert_equal 7.43, v, 'Float from float'
|
102
|
+
|
103
|
+
v = ActiveModelSerializerPlus.parse('BigDecimal', '89.461')
|
104
|
+
assert_not_nil v, 'BigDecimal from decimal'
|
105
|
+
assert_kind_of BigDecimal, v, 'BigDecimal from decimal'
|
106
|
+
assert_equal 89.461, v, 'BigDecimal from decimal'
|
107
|
+
|
108
|
+
v = ActiveModelSerializerPlus.parse('Boolean', 'true')
|
109
|
+
assert_not_nil v, 'Boolean from true'
|
110
|
+
assert_kind_of TrueClass, v, 'Boolean from true'
|
111
|
+
assert v, 'Boolean from true'
|
112
|
+
v = ActiveModelSerializerPlus.parse('Boolean', '1')
|
113
|
+
assert_not_nil v, 'Boolean from 1'
|
114
|
+
assert_kind_of TrueClass, v, 'Boolean from 1'
|
115
|
+
assert v, 'Boolean from 1'
|
116
|
+
v = ActiveModelSerializerPlus.parse('Boolean', 'false')
|
117
|
+
assert_not_nil v, 'Boolean from false'
|
118
|
+
assert_kind_of FalseClass, v, 'Boolean from false'
|
119
|
+
assert_not v, 'Boolean from false'
|
120
|
+
v = ActiveModelSerializerPlus.parse('Boolean', '0')
|
121
|
+
assert_not_nil v, 'Boolean from 0'
|
122
|
+
assert_kind_of FalseClass, v, 'Boolean from 0'
|
123
|
+
assert_not v, 'Boolean from 0'
|
124
|
+
v = ActiveModelSerializerPlus.parse('Boolean', 'few')
|
125
|
+
assert_not_nil v, 'Boolean from invalid string'
|
126
|
+
assert_kind_of FalseClass, v, 'Boolean from invalid string'
|
127
|
+
assert_not v, 'Boolean from invalid string'
|
128
|
+
|
129
|
+
v = ActiveModelSerializerPlus.parse('String', 'xyzzy')
|
130
|
+
assert_nil v, 'String'
|
131
|
+
|
132
|
+
v = ActiveModelSerializerPlus.parse('IPAddr', '192.168.9.25')
|
133
|
+
assert_nil v, 'IPAddr'
|
134
|
+
|
135
|
+
v = ActiveModelSerializerPlus.parse('Fixnum', '5')
|
136
|
+
assert_not_nil v, 'Fixnum from integer'
|
137
|
+
assert_kind_of Integer, v, 'Fixnum from integer'
|
138
|
+
assert_equal 5, v, 'Fixnum from integer'
|
139
|
+
end
|
140
|
+
|
141
|
+
test 'build from hash' do
|
142
|
+
v = IPAddr.new('192.168.23.94/24')
|
143
|
+
j = v.to_json
|
144
|
+
h = JSON.parse(j)
|
145
|
+
r = ActiveModelSerializerPlus.build('IPAddr', h)
|
146
|
+
assert_not_nil r, 'build IPAddr'
|
147
|
+
assert_kind_of IPAddr, r, 'build IPAddr'
|
148
|
+
assert_equal v, r, 'build IPAddr'
|
149
|
+
|
150
|
+
r = ActiveModelSerializerPlus.build('Integer', { 'value' => 5 })
|
151
|
+
assert_nil r, 'build integer'
|
152
|
+
end
|
153
|
+
|
154
|
+
test 'add types' do
|
155
|
+
ActiveModelSerializerPlus.add_xlate( 'Xyzzy1', 'Xyzzy')
|
156
|
+
r = ActiveModelSerializerPlus.type_name_xlate('Xyzzy1')
|
157
|
+
assert_not_nil r, 'add type, translate type name, found'
|
158
|
+
assert_kind_of String, r, 'add type, translate type name, found'
|
159
|
+
assert_equal 'Xyzzy', r, 'add type, translate type name, found'
|
160
|
+
r = ActiveModelSerializerPlus.type_name_xlate('Xyzzy')
|
161
|
+
assert_nil r, 'add type, translate type name, not found'
|
162
|
+
|
163
|
+
fmt_proc = Proc.new { |p| p.x.to_s }
|
164
|
+
prs_proc = Proc.new { |s|
|
165
|
+
p = ParsingClass.new
|
166
|
+
p.x = s
|
167
|
+
p
|
168
|
+
}
|
169
|
+
ActiveModelSerializerPlus.add_type('ParsingClass', fmt_proc, prs_proc, nil)
|
170
|
+
v = ActiveModelSerializerPlus.format(@format_parse)
|
171
|
+
assert_not_nil v, 'add type, format'
|
172
|
+
assert_kind_of String, v, 'add type, format'
|
173
|
+
assert_equal 'xyzzy', v, 'add type, format'
|
174
|
+
v = ActiveModelSerializerPlus.parse('ParsingClass', 'jklmn')
|
175
|
+
assert_not_nil v, 'add type, parse'
|
176
|
+
assert_kind_of ParsingClass, v, 'add type, parse'
|
177
|
+
assert_equal 'jklmn', v.x, 'add type, parse'
|
178
|
+
v = ActiveModelSerializerPlus.parse('UnknownClass', 'abcde')
|
179
|
+
assert_nil v, 'add type, parse, not found'
|
180
|
+
|
181
|
+
bld_proc = Proc.new { |h|
|
182
|
+
b = BuilderClass.new
|
183
|
+
b.a = h['a']
|
184
|
+
b.b = h['b'].to_i
|
185
|
+
b
|
186
|
+
}
|
187
|
+
ActiveModelSerializerPlus.add_type('BuilderClass', nil, nil, bld_proc)
|
188
|
+
v = ActiveModelSerializerPlus.build('BuilderClass', { 'a' => 'abcde', 'b' => 17 })
|
189
|
+
assert_not_nil v, 'add type, build'
|
190
|
+
assert_kind_of BuilderClass, v, 'add type, build'
|
191
|
+
assert_not_nil v.a, 'add type, build'
|
192
|
+
assert_equal 'abcde', v.a, 'add type, build'
|
193
|
+
assert_not_nil v.b, 'add type, build'
|
194
|
+
assert_equal 17, v.b, 'add type, build'
|
195
|
+
v = ActiveModelSerializerPlus.build('UnknownClass', { 'a' => 'xyzzy', 'b' => 24 })
|
196
|
+
assert_nil v, 'add type, build, not found'
|
197
|
+
|
198
|
+
v = ActiveModelSerializerPlus.build('BuilderSubClass', { 'a' => 'abcde', 'b' => 17 })
|
199
|
+
assert_nil v, 'add type, build subclass'
|
200
|
+
end
|
201
|
+
|
202
|
+
test 'convert to class' do
|
203
|
+
r = ActiveModelSerializerPlus.to_class('Fixnum')
|
204
|
+
assert_not_nil r, 'convert to class, string'
|
205
|
+
assert_kind_of Class, r, 'convert to class, string'
|
206
|
+
assert_equal 'Fixnum', r.name, 'convert to class, string'
|
207
|
+
|
208
|
+
r = ActiveModelSerializerPlus.to_class(:Float)
|
209
|
+
assert_not_nil r, 'convert to class, symbol'
|
210
|
+
assert_kind_of Class, r, 'convert to class, symbol'
|
211
|
+
assert_equal 'Float', r.name, 'convert to class, symbol'
|
212
|
+
|
213
|
+
r = ActiveModelSerializerPlus.to_class(Hash)
|
214
|
+
assert_not_nil r, 'convert to class, class'
|
215
|
+
assert_kind_of Class, r, 'convert to class, class'
|
216
|
+
assert_equal 'Hash', r.name, 'convert to class, class'
|
217
|
+
|
218
|
+
assert_raise ArgumentError, 'convert to class, string, invalid' do
|
219
|
+
r = ActiveModelSerializerPlus.to_class('Garbage')
|
220
|
+
end
|
221
|
+
|
222
|
+
assert_raise ArgumentError, 'convert to class, symbol, invalid' do
|
223
|
+
r = ActiveModelSerializerPlus.to_class(:Garbage)
|
224
|
+
end
|
225
|
+
|
226
|
+
assert_raise NameError, 'convert to class, class, invalid' do
|
227
|
+
r = ActiveModelSerializerPlus.to_class(Garbage)
|
228
|
+
end
|
229
|
+
|
230
|
+
assert_raise ArgumentError, 'convert to class, integer' do
|
231
|
+
r = ActiveModelSerializerPlus.to_class(5)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
test 'convert to class name' do
|
236
|
+
r = ActiveModelSerializerPlus.to_classname('Fixnum')
|
237
|
+
assert_not_nil r, 'convert to class name, string'
|
238
|
+
assert_kind_of String, r, 'convert to class name, string'
|
239
|
+
assert_equal 'Fixnum', r, 'convert to class name, string'
|
240
|
+
|
241
|
+
r = ActiveModelSerializerPlus.to_classname(:Float)
|
242
|
+
assert_not_nil r, 'convert to class name, symbol'
|
243
|
+
assert_kind_of String, r, 'convert to class name, symbol'
|
244
|
+
assert_equal 'Float', r, 'convert to class name, symbol'
|
245
|
+
|
246
|
+
r = ActiveModelSerializerPlus.to_classname(Hash)
|
247
|
+
assert_not_nil r, 'convert to class name, class'
|
248
|
+
assert_kind_of String, r, 'convert to class name, class'
|
249
|
+
assert_equal 'Hash', r, 'convert to class name, class'
|
250
|
+
|
251
|
+
assert_raise ArgumentError, 'convert to class name, invalid' do
|
252
|
+
r = ActiveModelSerializerPlus.to_classname(17)
|
253
|
+
end
|
254
|
+
|
255
|
+
assert_raise NameError, 'convert to class name, bad class' do
|
256
|
+
r = ActiveModelSerializerPlus.to_classname(Garbage)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Rails42</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|