Skip to content

Commit

Permalink
read the model files
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Oct 4, 2014
1 parent 5d7e1d0 commit c220967
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/attr_accessible2strong_params.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
require 'find'
require 'active_support/core_ext/object'
require 'active_support/inflector'

class AttrAccessible2StrongParams
def self.convert(filename)
t = Converter.new
t.read_attr_accessible filename
def self.convert(file_or_dir)
@files = []
file_or_dir ||= '.'
if File.directory?(file_or_dir)
Find.find("#{file_or_dir}/app/models/") do |path|
next if path.end_with? '.rb.rb'
@files << path if path.end_with? '.rb'
end
else
@files << file_or_dir
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/test_attr_accessible2strong_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
require 'attr_accessible2strong_params'

class AttrAccessible2StrongParamsTest < MiniTest::Test
def test_convert
AttrAccessible2StrongParams.convert('test/railsapp')
end

def test_read_model_attr_accessible_sym_list
c = AttrAccessible2StrongParams::Converter.new
assert_equal [:create_badge, :create_shift_code, :in_time, :out_time, :profile_check, :update_badge, :update_shift_code] \
Expand Down

0 comments on commit c220967

Please sign in to comment.