Skip to content

Commit

Permalink
Use DecomposerRegistory
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 1, 2014
1 parent 9612572 commit 14cce61
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/chupa-text/command/chupa-text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,30 @@ def run(*arguments)
end

def initialize
@feeder = Feeder.new
end

def run(*arguments)
paths = arguments
feeder = create_feeder
paths.each do |path|
data = Data.new
data.path = path
@feeder.feed(data) do |extracted|
feeder.feed(data) do |extracted|
puts(extracted.body)
end
end
true
end

private
def create_feeder
Decomposer.load
feeder = Feeder.new
Decomposer.registory.decomposers.each do |decomposer|
feeder.add_decomposer(decomposer)
end
feeder
end
end
end
end
19 changes: 19 additions & 0 deletions lib/chupa-text/decomposer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,27 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "chupa-text/decomposer-registory"

module ChupaText
class Decomposer
class << self
def registory
@@registory ||= DecomposerRegistory.new
end

def load
$LOAD_PATH.each do |load_path|
next unless File.directory?(load_path)
Dir.chdir(load_path) do
Dir.glob("chupa-text/plugin/decomposer/*.rb") do |plugin_path|
require plugin_path.gsub(/\.rb\z/, "")
end
end
end
end
end

def target?(data)
false
end
Expand Down

0 comments on commit 14cce61

Please sign in to comment.