rails_embed_editor 0.0.1 → 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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTliNjU3ODNmZmIxYTk0YTkzYWU3NTI0NGQxZGRhYjU4YmIzNWUyNg==
4
+ ZDFjZGNkMzQ0YzJiZWI3MDdlMTYyZjFkNDg0M2MwZWIyZDkwZDgwNA==
5
5
  data.tar.gz: !binary |-
6
- YmFlNWMxYTdmYmY1MWVmYWY0OWM4YjBmYzA0MWM5NTM0MGZjNzNmYw==
6
+ MzUwM2Y3NTlmZjUyOTFmMzA2NTgzNTY2Yjg3NzQ2OWI5MTk0NTI1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjA2OWI3YTk5Nzg1Y2RmNDZkODNkYWUxNzkzM2Y3MjUzMDEyMDk1ZjU4MTcx
10
- N2Y1MDhhNzY2NDdmMWM4YzVjN2M3ZDEyY2NhZDY2OTk0MmYxZWNiZWZlMTVl
11
- NTE4MWM0YmUyMjk2YjIxZGFhMjBiMGY2NWMzMjNiMTU3YjgyYmY=
9
+ MDgwNDE0NWM5NDhjZjRjYTc0NTdlMTBmMWRlNzc0MTA2ZDY0OWZjZDk0NTE2
10
+ YzZiMjZlNWM3MDYwMzMxNDhhZWRmNmZiYzlkYjc0MjE2Mjg4NDgwYmMwMzQy
11
+ ODQ2MmJhNjYyZTUyYWZlMDRiMzllOWI3ZGVjY2QyMTRjZDRkZjI=
12
12
  data.tar.gz: !binary |-
13
- YTliNDNhZDg0Y2IzOGQwM2NlM2RjNGViZGUxZTE3NjgxMGQ2ZDAzMzIzYTNh
14
- MjEyOGM4NzY0NTBjOWI4MjhhNjYzY2YzYjlhNDFlYjkzZmQxMzI3ZTA2NWUy
15
- MjJlYmZhMzY0NTEzNzYzNDI2YWNmZmNjMTI5MzBjY2YxYjgzOTM=
13
+ YzdhODQ0YTQwNTkxMjNiYWE4MWZhNjBmMDdmYzE5NjA5N2ZhNTdmMmJjM2Ez
14
+ NDJmZWFiOWI3ZmIxOWIyYzFiNzBlNTcxYTM3MmIxYzFkMGRkZTAwYTE2MmM3
15
+ YjYzZDBhZWZiNDgyMjBhM2ZiNGFjNGUzM2UxMTg4NzBjOWZjYTg=
@@ -3,7 +3,10 @@
3
3
  #= require ace/ace
4
4
  #= require ace/mode-ruby
5
5
  #= require ace/theme-monokai
6
+ #= require ace/theme-github
6
7
 
8
+ window.rails_embed_editor_default_theme ?= 'github'
9
+ Range = require('ace/range').Range
7
10
  $(document).ready () ->
8
11
  window.load_rails_embed_code_editor()
9
12
 
@@ -18,13 +21,14 @@ window.load_rails_embed_code_editor = () ->
18
21
  first_line: container.data('first-line')
19
22
  last_line: container.data('last-line')
20
23
  editormode: container.data('editormode')
24
+ highlight: compute_range(container.data('highlight'), container.data('first-line'))
21
25
  }
22
26
  setup_editor(container[0], options)
23
27
 
24
28
 
25
29
  setup_editor = (element, options) ->
26
30
  defaults = {
27
- theme: 'monokai'
31
+ theme: window.rails_embed_editor_default_theme
28
32
  mode: 'ruby'
29
33
  firstLineNumber: 1
30
34
  editormode: 'readonly'
@@ -40,20 +44,47 @@ setup_editor = (element, options) ->
40
44
  editor.setOption("maxLines", 40);
41
45
  editor.setOption("minLines", 5);
42
46
 
47
+ editor.getSession().addMarker(options['highlight'], "editor_highlight", "text") unless options['highlight'] == null
48
+
43
49
  if options['editormode'] != 'readonly'
44
50
  options['last_line'] ?= options['firstLineNumber'] + editor.session.getLength()
45
51
 
46
52
  button = $('<div><button class="rails_embed_code_editor_button">Save</button></div>').appendTo(element).children()
47
53
  button.text('Enable edit') if options['editormode'] == 'readwrite'
48
54
  button.click () ->
49
- if options['editormode'] == 'readwrite'
50
- button.text('Save')
51
- editor.setReadOnly(false)
52
- else
53
- $.post('/rails_embed_editor/edit', {
54
- content: editor.getValue()
55
- first_line: options['first_line']
56
- last_line: options['last_line']
57
- filename: options['filename']
58
- }).success (data) ->
59
- console.log(data)
55
+ if options['editormode'] != 'readonly'
56
+ if options['editormode'] == 'readwrite' and editor.getReadOnly()
57
+ button.text('Save')
58
+ editor.setReadOnly(false)
59
+ else
60
+ $.post('/rails_embed_editor/edit', {
61
+ content: editor.getValue()
62
+ first_line: options['first_line']
63
+ last_line: options['last_line']
64
+ filename: options['filename']
65
+ }).success (data) ->
66
+ if data['success'] == true
67
+ button.text('Saved!')
68
+
69
+ else
70
+ button.text('Error')
71
+ console.log('Error saving:' + data['message'])
72
+ setTimeout(() ->
73
+ button.text("Save")
74
+ , 2000)
75
+
76
+ compute_range = (str, line = 1) ->
77
+ offset = parseInt(line)
78
+ return null if str == undefined
79
+ _array = str.toString().split(',')
80
+ for i in [0..._array.length]
81
+ _array[i] = parseInt(_array[i])
82
+ switch _array.length
83
+ when 1
84
+ new Range(_array[0] - offset, 0, _array[0] - offset, Infinity)
85
+ when 2
86
+ new Range(_array[0] - offset, 0, _array[1] - offset, Infinity)
87
+ when 4
88
+ new Range(_array[0] - offset, _array[1], _array[2] - offset, _array[3])
89
+ else
90
+ null
@@ -64,3 +64,10 @@ button.rails_embed_code_editor_button:active {
64
64
  top: 6px;
65
65
  right: 5px;
66
66
  }
67
+
68
+ .editor_highlight {
69
+ background: #7994CD;
70
+ position: absolute;
71
+ width: 100% !important;
72
+ left: 0 !important;
73
+ }
@@ -1,4 +1,21 @@
1
1
  module RailsEmbedEditor
2
2
  class ApplicationController < ActionController::Base
3
+
4
+ def _authorize!(*args)
5
+ if defined? current_user
6
+ RailsEmbedEditor::Authorization.authorize!(current_user, *args)
7
+ else
8
+ true
9
+ end
10
+ end
11
+
12
+ def _authorize(*args)
13
+ begin
14
+ _authorize! *args
15
+ true
16
+ rescue CanCan::AccessDenied => e
17
+ false
18
+ end
19
+ end
3
20
  end
4
21
  end
@@ -1,6 +1,11 @@
1
1
  module RailsEmbedEditor
2
- class EditorController < ApplicationController
2
+ class EditorController < RailsEmbedEditor::ApplicationController
3
3
  def edit
4
+ unless _authorize :edit, :local_file
5
+ render :json => {:success => false, :message => 'You dont have access to this file!'}
6
+ return
7
+ end
8
+
4
9
  filename = params[:filename]
5
10
  text = params[:content]
6
11
  if filename.nil? or text.nil?
@@ -8,6 +8,7 @@ module RailsEmbedEditor
8
8
  last_line = manager.last_line
9
9
  content_tag('div', text, :class => 'rails_embed_code_editor',
10
10
  'data-first-line' => first_line, 'data-last-line' => last_line, 'data-filename' => filename,
11
+ 'data-highlight' => options[:highlight],
11
12
  'data-editormode' => options[:editormode])
12
13
  end
13
14
  end
@@ -0,0 +1,11 @@
1
+ require 'rails/generators'
2
+ module RailsEmbedEditor
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+ desc 'Creates a InstallGenerator initializer and copy locale files to your application.'
6
+
7
+ def install
8
+ template 'initializer.rb', 'config/initializers/rails_embed_editor.rb'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ RailsEmbedEditor.config do |config|
2
+
3
+ #Define the authentication library
4
+ #config.authorize_with :cancan
5
+
6
+ end
@@ -3,6 +3,7 @@ require 'rails_embed_editor/engine'
3
3
  require 'rails_embed_editor/config'
4
4
  require 'rails_embed_editor/file_manager'
5
5
  require 'rails_embed_editor/editor_mode'
6
+ require 'rails_embed_editor/authorization'
6
7
 
7
8
  module RailsEmbedEditor
8
9
  def self.config(&block)
@@ -0,0 +1,12 @@
1
+ module RailsEmbedEditor
2
+ class Authorization
3
+ def self.authorize!(user, *args)
4
+ case RailsEmbedEditor::Config.authorize_with
5
+ when :cancan
6
+ Ability.new(user).authorize!(*args)
7
+ else
8
+ true
9
+ end
10
+ end
11
+ end
12
+ end
@@ -3,7 +3,18 @@ require 'active_support/core_ext/module/attribute_accessors'
3
3
  module RailsEmbedEditor
4
4
  module Config
5
5
  class << self
6
+ attr_accessor :authorize_with
7
+
6
8
  def reset
9
+ self.authorize_with = nil
10
+ end
11
+
12
+ def authorize_with(param = nil)
13
+ if param.nil?
14
+ @authorize_with
15
+ else
16
+ @authorize_with = param
17
+ end
7
18
 
8
19
  end
9
20
  end
@@ -1,3 +1,3 @@
1
- module RailsEmbedEditor
2
- VERSION = '0.0.1'
3
- end
1
+ module RailsEmbedEditor
2
+ VERSION = '1.0.0'
3
+ end
@@ -1139,5 +1139,390 @@ FileManagerTest: test_Save_text
1139
1139
   (0.0ms) begin transaction
1140
1140
  --------------------------------
1141
1141
  RailsEmbedEditorTest: test_truth
1142
+ --------------------------------
1143
+  (0.0ms) rollback transaction
1144
+  (0.0ms) begin transaction
1145
+ -------------------------------------------
1146
+ EditorControllerTest: test_should_edit_file
1147
+ -------------------------------------------
1148
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1149
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1150
+ Completed 200 OK in 3ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1151
+  (0.0ms) rollback transaction
1152
+  (0.0ms) begin transaction
1153
+ ------------------------------------------
1154
+ EditorControllerTest: test_should_not_edit
1155
+ ------------------------------------------
1156
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1157
+ Completed 200 OK in 1ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1158
+  (0.0ms) rollback transaction
1159
+  (0.0ms) begin transaction
1160
+ ----------------------------------------------------------------
1161
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1162
+ ----------------------------------------------------------------
1163
+  (0.0ms) rollback transaction
1164
+  (0.0ms) begin transaction
1165
+ --------------------------------------------
1166
+ ConfigTest: test_Load_config_fine_with_block
1167
+ --------------------------------------------
1168
+  (0.0ms) rollback transaction
1169
+  (0.0ms) begin transaction
1170
+ ---------------------------------------------------
1171
+ ConfigTest: test_Test_config_function_without_param
1172
+ ---------------------------------------------------
1173
+  (0.0ms) rollback transaction
1174
+  (0.0ms) begin transaction
1175
+ ---------------------------------------------------
1176
+ FileManagerTest: test_Init_from_options_with_around
1177
+ ---------------------------------------------------
1178
+  (0.0ms) rollback transaction
1179
+  (0.0ms) begin transaction
1180
+ --------------------------------------------------
1181
+ FileManagerTest: test_Init_from_options_with_range
1182
+ --------------------------------------------------
1183
+  (0.0ms) rollback transaction
1184
+  (0.0ms) begin transaction
1185
+ --------------------------------------
1186
+ FileManagerTest: test_Read_right_lines
1187
+ --------------------------------------
1188
+  (0.0ms) rollback transaction
1189
+  (0.0ms) begin transaction
1190
+ -------------------------------
1191
+ FileManagerTest: test_Save_text
1192
+ -------------------------------
1193
+  (0.0ms) rollback transaction
1194
+  (0.0ms) begin transaction
1195
+ --------------------------------
1196
+ RailsEmbedEditorTest: test_truth
1197
+ --------------------------------
1198
+  (0.0ms) rollback transaction
1199
+  (0.0ms) begin transaction
1200
+ -------------------------------------------
1201
+ EditorControllerTest: test_should_edit_file
1202
+ -------------------------------------------
1203
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1204
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1205
+ Completed 200 OK in 2ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1206
+  (0.0ms) rollback transaction
1207
+  (0.0ms) begin transaction
1208
+ ------------------------------------------
1209
+ EditorControllerTest: test_should_not_edit
1210
+ ------------------------------------------
1211
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1212
+ Completed 200 OK in 1ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1213
+  (0.0ms) rollback transaction
1214
+  (0.0ms) begin transaction
1215
+ ----------------------------------------------------------------
1216
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1217
+ ----------------------------------------------------------------
1218
+  (0.0ms) rollback transaction
1219
+  (0.0ms) begin transaction
1220
+ --------------------------------------------
1221
+ ConfigTest: test_Load_config_fine_with_block
1222
+ --------------------------------------------
1223
+  (0.0ms) rollback transaction
1224
+  (0.0ms) begin transaction
1225
+ ---------------------------------------------------
1226
+ ConfigTest: test_Test_config_function_without_param
1227
+ ---------------------------------------------------
1228
+  (0.0ms) rollback transaction
1229
+  (0.0ms) begin transaction
1230
+ ---------------------------------------------------
1231
+ FileManagerTest: test_Init_from_options_with_around
1232
+ ---------------------------------------------------
1233
+  (0.0ms) rollback transaction
1234
+  (0.0ms) begin transaction
1235
+ --------------------------------------------------
1236
+ FileManagerTest: test_Init_from_options_with_range
1237
+ --------------------------------------------------
1238
+  (0.0ms) rollback transaction
1239
+  (0.0ms) begin transaction
1240
+ --------------------------------------
1241
+ FileManagerTest: test_Read_right_lines
1242
+ --------------------------------------
1243
+  (0.0ms) rollback transaction
1244
+  (0.0ms) begin transaction
1245
+ -------------------------------
1246
+ FileManagerTest: test_Save_text
1247
+ -------------------------------
1248
+  (0.0ms) rollback transaction
1249
+  (1.0ms) begin transaction
1250
+ --------------------------------
1251
+ RailsEmbedEditorTest: test_truth
1252
+ --------------------------------
1253
+  (0.0ms) rollback transaction
1254
+  (0.0ms) begin transaction
1255
+ -------------------------------------------
1256
+ EditorControllerTest: test_should_edit_file
1257
+ -------------------------------------------
1258
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1259
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1260
+ Completed 500 Internal Server Error in 2ms
1261
+  (0.0ms) rollback transaction
1262
+  (0.0ms) begin transaction
1263
+ ------------------------------------------
1264
+ EditorControllerTest: test_should_not_edit
1265
+ ------------------------------------------
1266
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1267
+ Completed 500 Internal Server Error in 2ms
1268
+  (0.0ms) rollback transaction
1269
+  (0.0ms) begin transaction
1270
+ ----------------------------------------------------------------
1271
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1272
+ ----------------------------------------------------------------
1273
+  (0.0ms) rollback transaction
1274
+  (0.0ms) begin transaction
1275
+ --------------------------------------------
1276
+ ConfigTest: test_Load_config_fine_with_block
1277
+ --------------------------------------------
1278
+  (0.0ms) rollback transaction
1279
+  (0.0ms) begin transaction
1280
+ ---------------------------------------------------
1281
+ ConfigTest: test_Test_config_function_without_param
1282
+ ---------------------------------------------------
1283
+  (0.0ms) rollback transaction
1284
+  (0.0ms) begin transaction
1285
+ ---------------------------------------------------
1286
+ FileManagerTest: test_Init_from_options_with_around
1287
+ ---------------------------------------------------
1288
+  (0.0ms) rollback transaction
1289
+  (0.0ms) begin transaction
1290
+ --------------------------------------------------
1291
+ FileManagerTest: test_Init_from_options_with_range
1292
+ --------------------------------------------------
1293
+  (0.0ms) rollback transaction
1294
+  (0.0ms) begin transaction
1295
+ --------------------------------------
1296
+ FileManagerTest: test_Read_right_lines
1297
+ --------------------------------------
1298
+  (0.0ms) rollback transaction
1299
+  (0.0ms) begin transaction
1300
+ -------------------------------
1301
+ FileManagerTest: test_Save_text
1302
+ -------------------------------
1303
+  (0.0ms) rollback transaction
1304
+  (0.0ms) begin transaction
1305
+ --------------------------------
1306
+ RailsEmbedEditorTest: test_truth
1307
+ --------------------------------
1308
+  (0.0ms) rollback transaction
1309
+  (0.0ms) begin transaction
1310
+ -------------------------------------------
1311
+ EditorControllerTest: test_should_edit_file
1312
+ -------------------------------------------
1313
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1314
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1315
+ Completed 500 Internal Server Error in 1ms
1316
+  (0.0ms) rollback transaction
1317
+  (0.0ms) begin transaction
1318
+ ------------------------------------------
1319
+ EditorControllerTest: test_should_not_edit
1320
+ ------------------------------------------
1321
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1322
+ Completed 500 Internal Server Error in 1ms
1323
+  (0.0ms) rollback transaction
1324
+  (0.0ms) begin transaction
1325
+ ----------------------------------------------------------------
1326
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1327
+ ----------------------------------------------------------------
1328
+  (0.0ms) rollback transaction
1329
+  (0.0ms) begin transaction
1330
+ --------------------------------------------
1331
+ ConfigTest: test_Load_config_fine_with_block
1332
+ --------------------------------------------
1333
+  (0.0ms) rollback transaction
1334
+  (0.0ms) begin transaction
1335
+ ---------------------------------------------------
1336
+ ConfigTest: test_Test_config_function_without_param
1337
+ ---------------------------------------------------
1338
+  (0.0ms) rollback transaction
1339
+  (0.0ms) begin transaction
1340
+ ---------------------------------------------------
1341
+ FileManagerTest: test_Init_from_options_with_around
1342
+ ---------------------------------------------------
1343
+  (0.0ms) rollback transaction
1344
+  (0.0ms) begin transaction
1345
+ --------------------------------------------------
1346
+ FileManagerTest: test_Init_from_options_with_range
1347
+ --------------------------------------------------
1348
+  (0.0ms) rollback transaction
1349
+  (0.0ms) begin transaction
1350
+ --------------------------------------
1351
+ FileManagerTest: test_Read_right_lines
1352
+ --------------------------------------
1353
+  (0.0ms) rollback transaction
1354
+  (0.0ms) begin transaction
1355
+ -------------------------------
1356
+ FileManagerTest: test_Save_text
1357
+ -------------------------------
1358
+  (0.0ms) rollback transaction
1359
+  (0.0ms) begin transaction
1360
+ --------------------------------
1361
+ RailsEmbedEditorTest: test_truth
1362
+ --------------------------------
1363
+  (0.0ms) rollback transaction
1364
+  (0.0ms) begin transaction
1365
+ -------------------------------------------
1366
+ EditorControllerTest: test_should_edit_file
1367
+ -------------------------------------------
1368
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1369
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1370
+ Completed 200 OK in 2ms (Views: 1.0ms | ActiveRecord: 0.0ms)
1371
+  (0.0ms) rollback transaction
1372
+  (0.0ms) begin transaction
1373
+ ------------------------------------------
1374
+ EditorControllerTest: test_should_not_edit
1375
+ ------------------------------------------
1376
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1377
+ Completed 200 OK in 1ms (Views: 1.0ms | ActiveRecord: 0.0ms)
1378
+  (0.0ms) rollback transaction
1379
+  (0.0ms) begin transaction
1380
+ ----------------------------------------------------------------
1381
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1382
+ ----------------------------------------------------------------
1383
+  (0.0ms) rollback transaction
1384
+  (0.0ms) begin transaction
1385
+ --------------------------------------------
1386
+ ConfigTest: test_Load_config_fine_with_block
1387
+ --------------------------------------------
1388
+  (1.0ms) rollback transaction
1389
+  (0.0ms) begin transaction
1390
+ ---------------------------------------------------
1391
+ ConfigTest: test_Test_config_function_without_param
1392
+ ---------------------------------------------------
1393
+  (0.0ms) rollback transaction
1394
+  (0.0ms) begin transaction
1395
+ ---------------------------------------------------
1396
+ FileManagerTest: test_Init_from_options_with_around
1397
+ ---------------------------------------------------
1398
+  (0.0ms) rollback transaction
1399
+  (0.0ms) begin transaction
1400
+ --------------------------------------------------
1401
+ FileManagerTest: test_Init_from_options_with_range
1402
+ --------------------------------------------------
1403
+  (0.0ms) rollback transaction
1404
+  (0.0ms) begin transaction
1405
+ --------------------------------------
1406
+ FileManagerTest: test_Read_right_lines
1407
+ --------------------------------------
1408
+  (0.0ms) rollback transaction
1409
+  (0.0ms) begin transaction
1410
+ -------------------------------
1411
+ FileManagerTest: test_Save_text
1412
+ -------------------------------
1413
+  (0.0ms) rollback transaction
1414
+  (0.0ms) begin transaction
1415
+ --------------------------------
1416
+ RailsEmbedEditorTest: test_truth
1417
+ --------------------------------
1418
+  (0.0ms) rollback transaction
1419
+  (0.0ms) begin transaction
1420
+ -------------------------------------------
1421
+ EditorControllerTest: test_should_edit_file
1422
+ -------------------------------------------
1423
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1424
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1425
+ Completed 200 OK in 2ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1426
+  (0.0ms) rollback transaction
1427
+  (0.0ms) begin transaction
1428
+ ------------------------------------------
1429
+ EditorControllerTest: test_should_not_edit
1430
+ ------------------------------------------
1431
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1432
+ Completed 200 OK in 1ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1433
+  (0.0ms) rollback transaction
1434
+  (0.0ms) begin transaction
1435
+ ----------------------------------------------------------------
1436
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1437
+ ----------------------------------------------------------------
1438
+  (1.0ms) rollback transaction
1439
+  (0.0ms) begin transaction
1440
+ --------------------------------------------
1441
+ ConfigTest: test_Load_config_fine_with_block
1442
+ --------------------------------------------
1443
+  (0.0ms) rollback transaction
1444
+  (0.0ms) begin transaction
1445
+ ---------------------------------------------------
1446
+ ConfigTest: test_Test_config_function_without_param
1447
+ ---------------------------------------------------
1448
+  (0.0ms) rollback transaction
1449
+  (0.0ms) begin transaction
1450
+ ---------------------------------------------------
1451
+ FileManagerTest: test_Init_from_options_with_around
1452
+ ---------------------------------------------------
1453
+  (0.0ms) rollback transaction
1454
+  (1.0ms) begin transaction
1455
+ --------------------------------------------------
1456
+ FileManagerTest: test_Init_from_options_with_range
1457
+ --------------------------------------------------
1458
+  (0.0ms) rollback transaction
1459
+  (0.0ms) begin transaction
1460
+ --------------------------------------
1461
+ FileManagerTest: test_Read_right_lines
1462
+ --------------------------------------
1463
+  (0.0ms) rollback transaction
1464
+  (0.0ms) begin transaction
1465
+ -------------------------------
1466
+ FileManagerTest: test_Save_text
1467
+ -------------------------------
1468
+  (0.0ms) rollback transaction
1469
+  (0.0ms) begin transaction
1470
+ --------------------------------
1471
+ RailsEmbedEditorTest: test_truth
1472
+ --------------------------------
1473
+  (0.0ms) rollback transaction
1474
+  (0.0ms) begin transaction
1475
+ -------------------------------------------
1476
+ EditorControllerTest: test_should_edit_file
1477
+ -------------------------------------------
1478
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1479
+ Parameters: {"filename"=>"C:/dev/ws/ruby/rails_embed_editor/test/tmp/edit_test/dumbfile.erb", "first_line"=>"2", "last_line"=>"5", "content"=>"Replace with some othe ansowmn content"}
1480
+ Completed 200 OK in 2ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1481
+  (0.0ms) rollback transaction
1482
+  (0.0ms) begin transaction
1483
+ ------------------------------------------
1484
+ EditorControllerTest: test_should_not_edit
1485
+ ------------------------------------------
1486
+ Processing by RailsEmbedEditor::EditorController#edit as HTML
1487
+ Completed 200 OK in 1ms (Views: 0.0ms | ActiveRecord: 0.0ms)
1488
+  (0.0ms) rollback transaction
1489
+  (0.0ms) begin transaction
1490
+ ----------------------------------------------------------------
1491
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
1492
+ ----------------------------------------------------------------
1493
+  (0.0ms) rollback transaction
1494
+  (0.0ms) begin transaction
1495
+ --------------------------------------------
1496
+ ConfigTest: test_Load_config_fine_with_block
1497
+ --------------------------------------------
1498
+  (0.0ms) rollback transaction
1499
+  (0.0ms) begin transaction
1500
+ ---------------------------------------------------
1501
+ ConfigTest: test_Test_config_function_without_param
1502
+ ---------------------------------------------------
1503
+  (0.0ms) rollback transaction
1504
+  (0.0ms) begin transaction
1505
+ ---------------------------------------------------
1506
+ FileManagerTest: test_Init_from_options_with_around
1507
+ ---------------------------------------------------
1508
+  (0.0ms) rollback transaction
1509
+  (0.0ms) begin transaction
1510
+ --------------------------------------------------
1511
+ FileManagerTest: test_Init_from_options_with_range
1512
+ --------------------------------------------------
1513
+  (0.0ms) rollback transaction
1514
+  (0.0ms) begin transaction
1515
+ --------------------------------------
1516
+ FileManagerTest: test_Read_right_lines
1517
+ --------------------------------------
1518
+  (0.0ms) rollback transaction
1519
+  (0.0ms) begin transaction
1520
+ -------------------------------
1521
+ FileManagerTest: test_Save_text
1522
+ -------------------------------
1523
+  (0.0ms) rollback transaction
1524
+  (0.0ms) begin transaction
1525
+ --------------------------------
1526
+ RailsEmbedEditorTest: test_truth
1142
1527
  --------------------------------
1143
1528
   (0.0ms) rollback transaction
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+ require 'rails/generators'
3
+ require 'generators/rails_embed_editor/install_generator'
4
+
5
+
6
+ class InstallGeneratorTest < Rails::Generators::TestCase
7
+ tests RailsEmbedEditor::InstallGenerator
8
+ destination File.expand_path('../../tmp', __FILE__)
9
+
10
+ setup do
11
+ prepare_destination
12
+ end
13
+
14
+ test 'Assert all files are properly created' do
15
+ run_generator
16
+ assert_file 'config/initializers/rails_embed_editor.rb'
17
+ end
18
+ end
data/test/test_helper.rb CHANGED
@@ -1,11 +1,14 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
1
4
  require 'coveralls'
2
5
  Coveralls.wear!
3
6
 
4
- # Configure Rails Environment
5
- ENV["RAILS_ENV"] = "test"
6
7
 
7
8
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
- require "rails/test_help"
9
+ require 'rails/test_help'
10
+
11
+
9
12
 
10
13
  Rails.backtrace_cleaner.remove_silencers!
11
14
 
@@ -0,0 +1,6 @@
1
+ RailsEmbedEditor.config do |config|
2
+
3
+ #Define the authentication library
4
+ #config.authorize_with :cancan
5
+
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_embed_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timothee Guerin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -72,6 +72,62 @@ dependencies:
72
72
  - - ! '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: cancan
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: tzinfo-data
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: minitest
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: minitest-reporters
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
75
131
  description: A tool that allow to display a embed editor on your page and edit local
76
132
  file(Views, Controller, ...). Details otw
77
133
  email:
@@ -90,7 +146,10 @@ files:
90
146
  - app/helpers/rails_embed_editor/application_helper.rb
91
147
  - app/views/layouts/rails_embed_editor/application.html.erb
92
148
  - config/routes.rb
149
+ - lib/generators/rails_embed_editor/install_generator.rb
150
+ - lib/generators/rails_embed_editor/templates/initializer.rb
93
151
  - lib/rails_embed_editor.rb
152
+ - lib/rails_embed_editor/authorization.rb
94
153
  - lib/rails_embed_editor/config.rb
95
154
  - lib/rails_embed_editor/editor_mode.rb
96
155
  - lib/rails_embed_editor/engine.rb
@@ -132,12 +191,14 @@ files:
132
191
  - test/dummy/public/422.html
133
192
  - test/dummy/public/500.html
134
193
  - test/dummy/public/favicon.ico
194
+ - test/generators/install_generator_test.rb
135
195
  - test/integration/navigation_test.rb
136
196
  - test/rails_embed_editor/config_test.rb
137
197
  - test/rails_embed_editor/dumbfile.erb
138
198
  - test/rails_embed_editor/file_manager_test.rb
139
199
  - test/rails_embed_editor_test.rb
140
200
  - test/test_helper.rb
201
+ - test/tmp/config/initializers/rails_embed_editor.rb
141
202
  - test/tmp/edit_test/dumbfile.erb
142
203
  homepage: http://github.com/timcolonel/rails_embed_editor
143
204
  licenses: []
@@ -199,10 +260,12 @@ test_files:
199
260
  - test/dummy/public/favicon.ico
200
261
  - test/dummy/Rakefile
201
262
  - test/dummy/README.rdoc
263
+ - test/generators/install_generator_test.rb
202
264
  - test/integration/navigation_test.rb
203
265
  - test/rails_embed_editor/config_test.rb
204
266
  - test/rails_embed_editor/dumbfile.erb
205
267
  - test/rails_embed_editor/file_manager_test.rb
206
268
  - test/rails_embed_editor_test.rb
207
269
  - test/test_helper.rb
270
+ - test/tmp/config/initializers/rails_embed_editor.rb
208
271
  - test/tmp/edit_test/dumbfile.erb