yapra-0.1.2.orig/0002775000372100037210000000000011220146245012206 5ustar tachtachyapra-0.1.2.orig/bin/0002775000372100037210000000000011220146245012756 5ustar tachtachyapra-0.1.2.orig/bin/yapra0000775000372100037210000000445711074771275014046 0ustar tachtach#!/usr/bin/env ruby -wKU $KCODE='u' require 'yaml' require 'optparse' require 'kconv' require 'pathname' require 'base64' YAPRA_ROOT = File.join(File.dirname(__FILE__), '..') $:.insert(0, *[ File.join(YAPRA_ROOT, 'lib-plugins'), File.join(YAPRA_ROOT, 'lib') ]) legacy_plugin_directory_paths = [ File.join(YAPRA_ROOT, 'legacy_plugins'), File.join(YAPRA_ROOT, 'plugins') ] require 'yapra/version' require 'yapra/runtime' require 'yapra/config' require 'yapra/legacy_plugin/registry_factory' Version = Yapra::VERSION::STRING mode = 'compatible' config_files = []#"config.yaml" loglebel = nil opt = OptionParser.new opt.on("-c", "--configfile CONFIGFILE") {|v| config_files << v } opt.on("-d", "--configfile-directory CONFIGFILE_DIRECTORY") { |v| Dir.glob(File.join(v, '**/*.yml')).each do |file| config_files << file end Dir.glob(File.join(v, '**/*.yaml')).each do |file| config_files << file end } opt.on("-p", "--plugindir PLUGINDIR") {|v| legacy_plugin_directory_paths << v } opt.on("-m", "--mode MODE", 'compatible / advance') { |v| mode = v } opt.on("--log-level LOGLEVEL", 'fatal / error / warn / info / debug') { |v| loglebel = v } # opt.on("-u", "--pluginusage PLUGINNAME") {|v| $plugins[v].source.gsub(/^## ?(.*)/){ puts $1 }; exit } # opt.on("-l", "--listplugin") { $plugins.keys.sort.each{|k| puts k }; exit } # opt.on("-w", "--where") { puts(Pathname.new(__FILE__).parent + "plugin"); exit } opt.parse! config_files << 'config.yaml' if config_files.size == 0 legacy_plugin_registry_factory = Yapra::LegacyPlugin::RegistryFactory.new(legacy_plugin_directory_paths, mode) yapra = nil config_files.each do |config_file| begin config = YAML.load(File.read(config_file).toutf8.gsub(/base64::([\w+\/]+=*)/){ Base64.decode64($1) }) config = Yapra::Config.new(config) config.env.update({ 'log' => { 'level' => loglebel } }) if loglebel Yapra::Runtime.logger = config.create_logger yapra = Yapra::Runtime.new( config.env, legacy_plugin_registry_factory ) yapra.execute(config.pipeline_commands) rescue => ex STDERR.puts("* Pipeline, '#{yapra.current_pipeline.name}'") if yapra && yapra.current_pipeline STDERR.puts("#{ex.class.name} in '#{ex.message}'") ex.backtrace.each do |t| STDERR.puts(t) end end end yapra-0.1.2.orig/lib/0002775000372100037210000000000011220146245012754 5ustar tachtachyapra-0.1.2.orig/lib/yapra/0002775000372100037210000000000011220146245014070 5ustar tachtachyapra-0.1.2.orig/lib/yapra/config.rb0000664000372100037210000000442611042036362015666 0ustar tachtachrequire 'logger' require 'yapra' # = Config Examples # # Config file for yapra. # # == Format 1: Pragger like. # A simplest. You can run one pipeline without global config. # # - module: Module:name # config: # a: 3 # - module: Module:name2 # config: # a: b # - module: Module:name3 # config: # a: 88 # # == Format 2: Python habu like. # You can run a lot of pipelines with global config. # # global: # log: # out: stderr # level: warn # # pipeline: # pipeline1: # - module: Module:name # config: # a: 3 # - module: Module:name2 # config: # a: b # # pipeline2: # - module: Module:name # config: # a: 3 # - module: Module:name2 # config: # a: b # # == Format 3: Mixed type. # You can run sigle pipeline with global config. # # global: # log: # out: stderr # level: warn # # pipeline: # - module: Module:name # config: # a: 3 # - module: Module:name2 # config: # a: b # class Yapra::Config attr_reader :env attr_reader :pipeline_commands def initialize config={} if config.kind_of?(Hash) @env = config['global'] || {} if config['pipeline'] if config['pipeline'].kind_of?(Hash) @pipeline_commands = config['pipeline'] elsif config['pipeline'].kind_of?(Array) @pipeline_commands = { 'default' => config['pipeline'] } end end raise 'config["global"]["pipeline"] is invalid!' unless @pipeline_commands elsif config.kind_of?(Array) @env = {} @pipeline_commands = { 'default' => config } else raise 'config file is invalid!' end end def create_logger logger = nil if env['log'] && env['log']['out'] if env['log']['out'].index('file://') logger = Logger.new(URI.parse(env['log']['out']).path) else logger = Logger.new(Yapra::Inflector.constantize(env['log']['out'].upcase)) end else logger = Logger.new(STDOUT) end if env['log'] && env['log']['level'] logger.level = Yapra::Inflector.constantize("Logger::#{env['log']['level'].upcase}") else logger.level = Logger::WARN end logger end endyapra-0.1.2.orig/lib/yapra/legacy_plugin.rb0000664000372100037210000000010511042036362017231 0ustar tachtach# require 'pathname' require 'yapra' module Yapra::LegacyPlugin end yapra-0.1.2.orig/lib/yapra/legacy_plugin/0002775000372100037210000000000011220146245016712 5ustar tachtachyapra-0.1.2.orig/lib/yapra/legacy_plugin/advance_mode_registry.rb0000664000372100037210000000250711042036362023576 0ustar tachtachrequire 'yapra/legacy_plugin' require 'yapra/inflector' module Yapra::LegacyPlugin # # AdvanceModeRegistry load legacy plugin at one by one. # class AdvanceModeRegistry attr_accessor :legacy_plugins attr_accessor :plugin_paths attr_accessor :pipeline # _paths_ :: Directory paths which contain legacy plugins. # _pipeline_ :: Runtime pipline. def initialize paths, pipeline self.legacy_plugins = {} self.plugin_paths = paths.reverse self.pipeline = pipeline end def logger Yapra::Runtime.logger end # load plugin from module name. # # example: # # registry = Yapra::LegacyPlugin::AdvanceModeRegistry.new(paths, pipeline) # feed_load_plugin = registry.get('Feed::load') # def get module_name plugin = legacy_plugins[module_name] unless plugin plugin_paths.each do |folder| file = File.join(folder, (module_name.gsub('::', '/') + '.rb')) if File.file?(file) plugin = Yapra::LegacyPlugin::Base.new(pipeline, file) legacy_plugins[ module_name ] = plugin logger.debug "#{module_name} is loaded from #{file}" break end end end raise "#{module_name} is not registered." unless plugin plugin end end endyapra-0.1.2.orig/lib/yapra/legacy_plugin/compatible_mode_registry.rb0000664000372100037210000000242311042036362024311 0ustar tachtachrequire 'pathname' require 'yapra/legacy_plugin' module Yapra::LegacyPlugin class CompatibleModeRegistry attr_accessor :legacy_plugins # _paths_ :: Directory paths which contain legacy plugins. # _pipeline_ :: Runtime pipline. def initialize paths, pipeline self.legacy_plugins = {} paths.each do |folder| folder = Pathname.new(folder) Pathname.glob(File.join(folder, "**/*.rb")).sort.each do |file| module_name = file.relative_path_from(folder).to_s.gsub("/","::")[0..-4] begin legacy_plugins[ module_name ] = Yapra::LegacyPlugin::Base.new(pipeline, file) logger.debug "#{module_name} is loaded from #{file}" rescue LoadError => ex logger.warn "#{module_name} can't load, because: #{ex.message}" end end end end def logger Yapra::Runtime.logger end # load plugin from module name. # # example: # # registry = Yapra::LegacyPlugin::CompatibleModeRegistry.new(paths, pipeline) # feed_load_plugin = registry.get('Feed::load') # def get module_name plugin = legacy_plugins[module_name] raise "#{module_name} is not registered." unless plugin plugin end end endyapra-0.1.2.orig/lib/yapra/legacy_plugin/base.rb0000664000372100037210000000123611042036362020151 0ustar tachtach# require 'pathname' require 'kconv' require 'yapra/legacy_plugin' class Yapra::LegacyPlugin::Base attr_reader :source attr_reader :_yapra_run_method attr_reader :_yapra_pipeline def initialize(pipeline, plugin_path) @_yapra_pipeline = pipeline @_yapra_run_method = File.basename(plugin_path, '.*') instance_eval( @source = File.read(plugin_path).toutf8, plugin_path, 1) end def logger Yapra::Runtime.logger end def eval_pragger(command_array, data) pipeline.execute_plugins(command_array, data) end def _yapra_run_as_legacy_plugin(config, data) self.__send__(self._yapra_run_method, config, data) end end yapra-0.1.2.orig/lib/yapra/legacy_plugin/registry_factory.rb0000664000372100037210000000162511042036362022640 0ustar tachtachrequire 'yapra/legacy_plugin' require 'yapra/inflector' # RegistryFactory is factory class for LegacyPluginRegistry. # # LegacyPluginRegistry is created by mode. # # If mode is compatible, this factory create a CompatibeModeRegistry. class Yapra::LegacyPlugin::RegistryFactory attr_reader :plugin_paths attr_reader :registry_class # plugin_paths :: directory paths which are contains legacy plugins. # mode :: 'compatible' / 'advance' def initialize plugin_paths, mode = 'compatible' registry_name = "Yapra::LegacyPlugin::#{Yapra::Inflector.camelize(mode)}ModeRegistry" @registry_class = Yapra.load_class_constant(registry_name) raise "'#{mode}' mode is not supported." unless @registry_class @plugin_paths = plugin_paths end def create pipeline registry = registry_class.new(plugin_paths, pipeline) pipeline.legacy_plugin_registry = registry registry end endyapra-0.1.2.orig/lib/yapra/plugin/0002775000372100037210000000000011220146245015366 5ustar tachtachyapra-0.1.2.orig/lib/yapra/plugin/erb_applier.rb0000664000372100037210000000053311042036362020176 0ustar tachtachrequire 'yapra/plugin' require 'erb' require 'uri' module Yapra::Plugin::ErbApplier def apply_template template, apply_binding=binding if template.index('file://') == 0 path = URI.parse(template).path open(path) do |io| template = io.read end end ERB.new(template, nil, '-').result(apply_binding) end endyapra-0.1.2.orig/lib/yapra/plugin/mechanize_base.rb0000664000372100037210000000167011043475762020666 0ustar tachtachrequire 'mechanize' require 'kconv' require 'yapra/plugin/base' class Yapra::Plugin::MechanizeBase < Yapra::Plugin::Base def agent pipeline.context['mechanize_agent'] ||= WWW::Mechanize.new pipeline.context['mechanize_agent'] end def extract_attribute_from element, item if plugin_config['extract_xpath'] plugin_config['extract_xpath'].each do |k, v| value = nil case v.class.to_s when 'String' value = element.search(v).to_html.toutf8 when 'Hash' ele = element.at( v['first_node'] ) value = ( ele.nil? ) ? nil : ele.get_attribute( v['attr'] ) end set_attribute_to item, k, value end end if plugin_config['apply_template_after_extracted'] plugin_config['apply_template_after_extracted'].each do |k, template| value = apply_template template, binding set_attribute_to item, k, value end end end endyapra-0.1.2.orig/lib/yapra/plugin/context_aware.rb0000664000372100037210000000046411042036362020560 0ustar tachtachrequire 'yapra/plugin' module Yapra::Plugin::ContextAware attr_accessor :yapra, :pipeline, :plugin_config def config @config ||= nil unless @config @config = {}.update(yapra.env).update(pipeline.context) @config.update(plugin_config) if plugin_config end @config end endyapra-0.1.2.orig/lib/yapra/plugin/base.rb0000664000372100037210000000072411042036362016626 0ustar tachtachrequire 'yapra/plugin' require 'yapra/plugin/context_aware' require 'yapra/plugin/erb_applier' require 'yapra/plugin/feed_item_operator' # Yapra plugin base class. # # Subclass this base is not required to be Yapra plugin. # But a few utility module is added in this base. class Yapra::Plugin::Base include Yapra::Plugin::ContextAware include Yapra::Plugin::FeedItemOperator include Yapra::Plugin::ErbApplier def logger Yapra::Runtime.logger end endyapra-0.1.2.orig/lib/yapra/plugin/feed_item_operator.rb0000664000372100037210000000066411042036362021553 0ustar tachtachrequire 'yapra/plugin' module Yapra::Plugin::FeedItemOperator LOCAL_VAL_RE = /[a-z_][0-9A-Za-z_]/ def set_attribute_to item, k, value raise NameError unless LOCAL_VAL_RE =~ k unless item.respond_to?("#{k}=") item.instance_eval %Q{ def #{k} @#{k} end def #{k}= v @#{k} = v end }, __FILE__, __LINE__ end item.__send__("#{k}=", value) end endyapra-0.1.2.orig/lib/yapra/inflector.rb0000664000372100037210000000370211042036362016402 0ustar tachtach# original from ActiveSupport-2.0.2 # MIT Licence require 'yapra' module Yapra::Inflector extend self # By default, camelize converts strings to UpperCamelCase. If the argument to camelize # is set to ":lower" then camelize produces lowerCamelCase. # # camelize will also convert '/' to '::' which is useful for converting paths to namespaces # # Examples # "active_record".camelize #=> "ActiveRecord" # "active_record".camelize(:lower) #=> "activeRecord" # "active_record/errors".camelize #=> "ActiveRecord::Errors" # "active_record/errors".camelize(:lower) #=> "activeRecord::Errors" def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) if first_letter_in_uppercase lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } else lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1] end end # The reverse of +camelize+. Makes an underscored form from the expression in the string. # # Changes '::' to '/' to convert namespaces to paths. # # Examples # "ActiveRecord".underscore #=> "active_record" # "ActiveRecord::Errors".underscore #=> active_record/errors def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end # Constantize tries to find a declared constant with the name specified # in the string. It raises a NameError when the name is not in CamelCase # or is not initialized. # # Examples # "Module".constantize #=> Module # "Class".constantize #=> Class def constantize(camel_cased_word) unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!" end Object.module_eval("::#{$1}", __FILE__, __LINE__) end endyapra-0.1.2.orig/lib/yapra/pipeline.rb0000664000372100037210000000740711074771162016241 0ustar tachtachrequire 'yapra' require 'yapra/runtime' require 'yapra/inflector' require 'yapra/legacy_plugin/base' class Yapra::Pipeline attr_reader :yapra, :context attr_writer :logger attr_accessor :legacy_plugin_registry UPPER_CASE = /[A-Z]/ def initialize pipeline_name, yapra=Yapra::Runtime.new @logger = nil @yapra = yapra @context = { 'pipeline_name' => pipeline_name } @module_name_prefix = construct_module_name_prefix yapra.env end def name self.context[ 'pipeline_name' ] end def logger return @logger || Yapra::Runtime.logger end # start pipeline from commands. # # example: # # pipeline.run([ # { # 'module' => 'Config::agent', # 'config' => { # 'user_agent_alias' => 'Windows IE 6' # } # }, # { # 'module' => 'RSS::load', # 'config' => { # 'uri' => 'http://www.example.com/hoge.rdf' # } # }, # { # 'module' => 'print' # } # ]) def run pipeline_command, data=[] @plugins = [] begin pipeline_command.inject(data) do |data, command| execute_plugin(command, data.clone) end rescue => ex @plugins.each do |plugin| begin plugin.on_error(ex) if plugin.respond_to?('on_error') rescue => exx self.logger.error("error is occured when error handling: #{exx.message}") end end raise ex end end def execute_plugin command, data self.logger.info("exec plugin #{command["module"]}") if class_based_plugin?(command['module']) run_class_based_plugin command, data else run_legacy_plugin command, data end end protected def class_based_plugin? command_name UPPER_CASE =~ command_name.split('::').last[0, 1] end def run_legacy_plugin command, data self.logger.debug("evaluate plugin as legacy") data = legacy_plugin_registry.get(command['module'])._yapra_run_as_legacy_plugin(command['config'], data) return data end def run_class_based_plugin command, data self.logger.debug("evaluate plugin as class based") load_error_stack = [] plugin_class = nil @module_name_prefix.each do |prefix| yapra_module_name = "#{prefix}#{command['module']}" begin plugin_class = Yapra.load_class_constant(yapra_module_name) break if plugin_class rescue LoadError, NameError => ex load_error_stack << ex end end raise_load_error(load_error_stack, command) unless plugin_class plugin = initialize_plugin(plugin_class, command) @plugins << plugin data = plugin.run(data) return data end def raise_load_error load_error_stack, command load_error = LoadError.new("#{command['module']} module is not found.") backtrace = load_error.backtrace || [] load_error_stack.each do |e| backtrace << "#{e.class.name} in '#{e.message}'" backtrace = backtrace + e.backtrace end load_error.set_backtrace(backtrace) raise load_error end def initialize_plugin plugin_class, command plugin = plugin_class.new plugin.yapra = yapra if plugin.respond_to?('yapra=') plugin.pipeline = self if plugin.respond_to?('pipeline=') plugin.plugin_config = command['config'] if plugin.respond_to?('plugin_config=') plugin end def construct_module_name_prefix env module_name_prefix = [ 'Yapra::Plugin::', '' ] if env['module_name_prefix'] if env['module_name_prefix'].kind_of?(Array) module_name_prefix = env['module_name_prefix'] else module_name_prefix = [ env['module_name_prefix'] ] end end module_name_prefix end end yapra-0.1.2.orig/lib/yapra/runtime.rb0000664000372100037210000000271411074771045016113 0ustar tachtachrequire 'logger' require 'yapra' require 'yapra/pipeline' require 'yapra/config' require 'yapra/inflector' # = How to use # # require 'yapra/runtime' # require 'yapra/config' # # config = YAML.load(config_file) # config = Yapra::Config.new(config) # # Yapra::Runtime.logger = Logger.new(STDOUT) # # yapra = Yapra::Runtime.new(config.env) # yapra.execute(config.pipeline_commands) # # config_file format written in Yapra::Config document. class Yapra::Runtime attr_reader :env attr_reader :legacy_plugin_registry_factory attr_reader :current_pipeline @@logger = Logger.new(STDOUT) def initialize env={}, legacy_plugin_registry_factory=nil @env = env @legacy_plugin_registry_factory = legacy_plugin_registry_factory end # execute pipelines from commands. def execute pipeline_commands pipeline_commands.each do |k, v| execute_pipeline k, v, [] end end # execute one pipeline. def execute_pipeline pipeline_name, command_array, data=[] self.class.logger.info("# pipeline '#{pipeline_name}' is started...") pipeline = Yapra::Pipeline.new(pipeline_name, self) @current_pipeline = pipeline legacy_plugin_registory = legacy_plugin_registry_factory.create(pipeline) if legacy_plugin_registry_factory pipeline.run(command_array, data) @current_pipeline = nil end def self.logger @@logger end def self.logger=logger @@logger = logger end endyapra-0.1.2.orig/lib/yapra/version.rb0000664000372100037210000000021011073555506016103 0ustar tachtachmodule Yapra module VERSION #:nodoc: MAJOR = 0 MINOR = 1 TINY = 2 STRING = [MAJOR, MINOR, TINY].join('.') end end yapra-0.1.2.orig/lib/yapra/plugin.rb0000664000372100037210000000005211042036362015706 0ustar tachtachrequire 'yapra' module Yapra::Plugin endyapra-0.1.2.orig/lib/yapra.rb0000664000372100037210000000323111073536023014415 0ustar tachtach#-- # Copyright (c) 2008 fraction.jp. Yuanying, Some rights reserved. # Original from 2008-06-12 http://pragger.ikejisoft.com/ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) module Yapra extend self # TODO create util class, and move this method. def load_class_constant module_name require Yapra::Inflector.underscore(module_name) return Yapra::Inflector.constantize(module_name) end end require 'rss/1.0' require 'rss/2.0' require 'rss/dublincore' require 'rss/maker' require 'rubygems' require 'yapra/inflector' yapra-0.1.2.orig/spec/0002775000372100037210000000000011220146245013140 5ustar tachtachyapra-0.1.2.orig/spec/yapra/0002775000372100037210000000000011220146245014254 5ustar tachtachyapra-0.1.2.orig/spec/yapra/config_spec.rb0000664000372100037210000000421611042036362017061 0ustar tachtachrequire File.dirname(__FILE__) + '/../spec_helper.rb' require 'yaml' require 'yapra/config' describe Yapra::Config do it 'should create logger from env setting' do config = Yapra::Config.new(YAML.load_file(File.join($fixture_dir, 'config', 'pragger_like.yml'))) config.env.update({ 'log' => { 'out' => 'stderr', 'level' => 'debug' } }) logger = config.create_logger logger.should be_debug end describe 'which is initialized by pragger like config file' do before do @config = Yapra::Config.new(YAML.load_file(File.join($fixture_dir, 'config', 'pragger_like.yml'))) end it 'should have empty env.' do @config.env.should == {} end it 'should have one pipeline command which is named "default".' do @config.should have(1).pipeline_commands end it 'should have pipeline command named "default"' do @config.pipeline_commands.should have_key('default') end end describe 'which is initialized by python habu like config file' do before do @habu_like_file = YAML.load_file(File.join($fixture_dir, 'config', 'habu_like.yml')) @config = Yapra::Config.new(@habu_like_file) end it 'should have env hash from habu_like_config_file "global" section.' do @config.env.should == @habu_like_file['global'] end it 'should have pipeline_commands from habu_like_config_file "pipeline" section.' do @config.pipeline_commands.should == @habu_like_file['pipeline'] end end describe 'which is initialized by mixed type config file' do before do @mixed_type_file = YAML.load_file(File.join($fixture_dir, 'config', 'mixed_type.yml')) @config = Yapra::Config.new(@mixed_type_file) end it 'should have env hash from mixed_type "global" section.' do @config.env.should == @mixed_type_file['global'] end it 'should have one pipeline command which is named "default".' do @config.should have(1).pipeline_commands end it 'should have pipeline command named "default"' do @config.pipeline_commands.should have_key('default') end end end yapra-0.1.2.orig/spec/yapra/legacy_plugin/0002775000372100037210000000000011074776611017113 5ustar tachtachyapra-0.1.2.orig/spec/yapra/legacy_plugin/registry_factory_spec.rb0000664000372100037210000000130711042036362024033 0ustar tachtachrequire File.dirname(__FILE__) + '/../../spec_helper.rb' require 'yapra/legacy_plugin/registry_factory' describe Yapra::LegacyPlugin::RegistryFactory do before do @pipeline = mock('pipeline', :null_object => true) end it 'should create advance mode registry from string "advance"' do factory = Yapra::LegacyPlugin::RegistryFactory.new([], 'advance') factory.create(@pipeline).class.should == Yapra::LegacyPlugin::AdvanceModeRegistry end it 'should create compatible mode registry from string "compatible"' do factory = Yapra::LegacyPlugin::RegistryFactory.new([], 'compatible') factory.create(@pipeline).class.should == Yapra::LegacyPlugin::CompatibleModeRegistry end endyapra-0.1.2.orig/spec/yapra/legacy_plugin/base_spec.rb0000664000372100037210000000204511042036362021346 0ustar tachtachrequire File.dirname(__FILE__) + '/../../spec_helper.rb' require 'yapra/legacy_plugin/base' describe Yapra::LegacyPlugin::Base do before do @pipeline = mock('pipeline', :null_object => true) end describe 'which is initialized by "fixtures/legacy_test_plugin.rb"' do before do @path = File.join($fixture_dir, 'legacy_plugin', 'legacy_test_plugin.rb') @plugin = Yapra::LegacyPlugin::Base.new(@pipeline, @path) end it 'should have _yapra_run_method named "legacy_test_plugin".' do @plugin._yapra_run_method.should == 'legacy_test_plugin' end it 'should have plugin source.' do @plugin.source.should == File.read(@path) end it 'should recieve message "legacy_test_plugin" when _yapra_run_as_legacy_plugin is called.' do config = mock('config') data = [] @plugin.stub!(:legacy_test_plugin).and_return(:default_value) @plugin.should_receive(:legacy_test_plugin).with(config, data) @plugin._yapra_run_as_legacy_plugin(config, data) end end endyapra-0.1.2.orig/spec/yapra/pipeline_spec.rb0000644000372100037210000000326611073572203017426 0ustar tachtachrequire File.dirname(__FILE__) + '/../spec_helper.rb' require 'yapra/pipeline' describe Yapra::Pipeline do before do require 'yapra/plugin/test/test' @pipeline = Yapra::Pipeline.new('spec test') @test_plugin = Yapra::Plugin::Test::Test.new end it 'execute pipeline from commands.' do @pipeline.run([ { 'module' => 'Test::Test' } ]) end it 'call run method of plugin, when pipeline is running.' do data = [] Yapra::Plugin::Test::Test.should_receive(:new).and_return(@test_plugin) @test_plugin.should_receive(:run).with(data).and_return([]) @pipeline.run([ { 'module' => 'Test::Test' } ], data) end it 'transfer previous plugin return object to next plugin.' do require 'yapra/plugin/test/test2' @test_plugin2 = Yapra::Plugin::Test::Test2.new data = [] modified_data = [ 'modified' ] Yapra::Plugin::Test::Test.should_receive(:new).and_return(@test_plugin) @test_plugin.should_receive(:run).with(data).and_return(modified_data) Yapra::Plugin::Test::Test2.should_receive(:new).and_return(@test_plugin2) @test_plugin2.should_receive(:run).with(modified_data) @pipeline.run([ { 'module' => 'Test::Test' }, { 'module' => 'Test::Test2' } ], data) end it 'call on_error method of plugin, when Error has occured.' do Yapra::Plugin::Test::Test.should_receive(:new).and_return(@test_plugin) @test_plugin.should_receive(:on_error) lambda { @pipeline.run([ { 'module' => 'Test::Test' }, { 'module' => 'Test::RaiseError' } ]) }.should raise_error end endyapra-0.1.2.orig/spec/spec_helper.rb0000664000372100037210000000045711042036362015762 0ustar tachtachbegin require 'spec' rescue LoadError require 'rubygems' gem 'rspec' require 'spec' end $fixture_dir = File.join(File.dirname(__FILE__), '..', 'fixtures') unless $fixture_dir $:.unshift(File.dirname(__FILE__) + '/../lib') $:.unshift(File.dirname(__FILE__) + '/../lib-plugins') require 'yapra' yapra-0.1.2.orig/spec/spec.opts0000664000372100037210000000001011042036362014766 0ustar tachtach--colouryapra-0.1.2.orig/spec/yapra_spec.rb0000664000372100037210000000062611073540045015617 0ustar tachtachrequire File.dirname(__FILE__) + '/spec_helper.rb' # Time to add your specs! # http://rspec.info/ describe Yapra do it "load class constant from string." do Yapra.load_class_constant('Yapra').should == Yapra end it 'can\'t load constant from invalid name.' do lambda { Yapra.load_class_constant('_arheiuhri_333***').should be_nil }.should raise_error(LoadError) end end yapra-0.1.2.orig/LICENCE0000664000372100037210000000215511042036362013174 0ustar tachtachCopyright (c) 2008 fraction.jp. Some rights reserved. Original from 2008-06-12 http://pragger.ikejisoft.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.yapra-0.1.2.orig/legacy_plugins/0002775000372100037210000000000011220146245015213 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/RSS/0002775000372100037210000000000011220146245015662 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/RSS/save.rb0000664000372100037210000000226011042036413017140 0ustar tachtach## Save RSS as a file -- IKeJI ## ## Save RSS as a file. ## Title, Link, and Description of the RSS can be set. ## The input is expected to be an Array of RSS::RDF::Item. ## ## - module: RSS::save ## config: ## title: An Title ## link: http://www.example.com/hoge.rdf ## description: sample rdf require "rss/maker" @count = Time.now.to_i def save(config,data) rss = RSS::Maker.make("1.0") do |maker| maker.channel.about = config['about'] || config['link'] || "http://example.net/" maker.channel.title = config['title'] || "Pragger output" maker.channel.description = config['description'] || "Generated by Yapra." maker.channel.link = config['link'] || "http://example.net/" data.each do |i| if(i.instance_of?(RSS::RDF::Item)) i.setup_maker(maker) else item = maker.items.new_item item.title = i.title rescue i.to_s item.link = i.link rescue (config['link'] || "http://example.net/") + "\##{@count}" item.description = i.description rescue i.to_s item.date = i.date rescue Time.now @count += 1 end end end open(config["filename"],"w"){|w| w.puts rss } return data end yapra-0.1.2.orig/legacy_plugins/RSS/load.rb0000664000372100037210000000144611042036362017131 0ustar tachtach## Load RSS from given URLs -- IKeJI ## ## Load RSS from given URLs. ## If URL is an Array, all URLs in the array will be loaded. ## ## - module: RSS::load ## config: ## uri: http://www.example.com/hoge.rdf require 'open-uri' require 'rss/1.0' require 'rss/2.0' require 'rss/maker' def load(config, data) begin rss_source = if config['url'].is_a?(Array) config['url'].map {|url| open(url) {|io| io.read } } else [ open(config['url']) {|r| r.read } ] end rescue puts "LoadError File = #{config["url"]}" return [] end feeds = rss_source.collect {|cont| begin RSS::Parser.parse(cont) rescue RSS::InvalidRSSError RSS::Parser.parse(cont, false) end } feeds.select {|f| f}.inject([]) {|acc,f| acc + f.items } end yapra-0.1.2.orig/legacy_plugins/Feed/0002775000372100037210000000000011220146245016056 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Feed/google_search_history.rb0000664000372100037210000000214011042036362022760 0ustar tachtach## get Google search history -- IKeJI ## ## for example you can get your search keyword 'harahetta' ## ## -module: Feed::google_search_history ## config: ## user: hoge ## pass: fuga ## require 'net/https' require 'rss/1.0' require 'rss/2.0' require 'rss/maker' def google_search_history(config,data) Net::HTTP.version_1_2 req = Net::HTTP::Get.new('/searchhistory/?output=rss') req["Accept-Language"] = "ja" req["Accept-Charset"] = "utf-8" req.basic_auth config['user'],config['pass'] ht = Net::HTTP.new("www.google.com",443) ht.use_ssl = true ht.start do |http| while(true) response = http.request(req) if(response.kind_of? Net::HTTPRedirection ) req = Net::HTTP::Get.new(response['location']) req["Accept-Language"] = "ja" req["Accept-Charset"] = "utf-8" req.basic_auth config['user'],config['pass'] else break end end rss = nil begin rss = RSS::Parser.parse(response.body) rescue RSS::InvalidRSSError rss = RSS::Parser.parse(response.body, false) end return rss.items rescue [] end end yapra-0.1.2.orig/legacy_plugins/Feed/lirs.rb0000664000372100037210000000147311042036362017357 0ustar tachtach## load lirs file plugin -- takatoh ## ## see http://d.hatena.ne.jp/takatoh/20070308/loadlirs ## ## example ## - module: Feed::load_lirs ## config: ## url: http://example.com/hoge.lirs.gz ## require 'open-uri' require 'rss/maker' require 'zlib' require 'kconv' def parse_lirs(record) fields = record.chomp.split(",") item = RSS::RDF::Item.new item.title = fields[6] # Title item.link = fields[5] # URL item.date = Time.at(fields[1].to_i + fields[3].to_i) # Last-Modified (local time) return item end def lirs(config, data) f = open(config["url"]) lirs = Zlib::GzipReader.wrap(f) {|gz| gz.read }.toutf8 items = lirs.map {|record| parse_lirs(record) } return items rescue puts "LoadError File = #{config["url"]}" return [] end yapra-0.1.2.orig/legacy_plugins/Feed/custom_feed.rb0000664000372100037210000000327611042036362020706 0ustar tachtach## Read data and convert to feed -- IKeJI ## ## Read data and convert to feed. ## ## Example ## - module: Feed::custom_feed ## config: ## url: addr of data -- optional ## capture: regex for content -- optional ## split: regex for item ## title: regex for title ## date: regex for date ## link: regex for link ## require 'open-uri' require 'kconv' def custom_feed(config,data) open(config['url']){|r| data = [r.read.toutf8] } if(config['url']) items = [] data.each do |input| body = "" if(config['capture']) if input =~ Regexp.new(config['capture'],Regexp::MULTILINE) body = $1 end else body = input end if(config['split']) body.gsub(Regexp.new(config['split'],Regexp::MULTILINE)) do items.push $1 end else items.push body end end if(config['title']) title = Regexp.new(config['title']) items.each do|i| if i =~ title mytitle = $1 i.instance_eval do @title = mytitle def title @title end end end end end if(config['date']) date = Regexp.new(config['date']) items.each do|i| if i =~ date mydate = Time.parse($1) i.instance_eval do @date = mydate def date @date end end end end end if config['link'] link = Regexp.new(config['link']) items.each do|i| if i =~ link mylink = config['url'] ? (config['url'] + '#' + $1) : $1 i.instance_eval do @link = mylink def link @link end end end end end return items end yapra-0.1.2.orig/legacy_plugins/Feed/google_calendar.rb0000664000372100037210000000233311042036362021507 0ustar tachtach## Read Google Calendar Events -- Soutaro Matsumoto ## ## Read Events from calendars. ## The output will be an array of GooleCalendar::Event. ## ## - module: feed::google_calendar ## config: ## mail: your gmail address ## pass: your password ## calendars: ## - the names of ## - your calendars ## max: 200 begin require 'rubygems' rescue LoadError end require 'gcalapi' require 'date' def google_calendar(config, data) today = Date.today pass = config['pass'] mail = config['mail'] calendar_pattern = Regexp.union(*config['calendars'].map{|ptn| /#{ptn}/}) max = config['max'] || 200 start_day = today - 30 end_day = today + 31 start_time = Time.mktime(start_day.year, start_day.month, start_day.day) end_time = Time.mktime(end_day.year, end_day.month, end_day.day) srv = GoogleCalendar::Service.new(mail, pass) cal_list = GoogleCalendar::Calendar.calendars(srv) cal_list.values.select {|cal| calendar_pattern =~ cal.title }.each {|cal| cal.events(:'max-results'=>max, :'start-min'=>start_time, :'start-max'=>end_time).each {|ev| data << ev if ev.st && ev.en && start_time <= ev.st && ev.en <= end_time } } data end yapra-0.1.2.orig/legacy_plugins/Feed/hatena_graph.rb0000664000372100037210000000204411042036362021022 0ustar tachtach## Get Hatena Graph data ## ## hatenaapigraph 0.2.2 is required. ## ## - module: Feed::hatena_graph ## config: ## user_id: your-hatena-user-id ## password: your-password ## graph_name: the-name-of-graph ## proxy_host: proxy-host-name (optional) ## proxy_port: proxy-port (optional) ## proxy_user: proxy-user (optional) ## proxy_pass: proxy-password (optional) begin require 'rubygems' gem 'hatenaapigraph', '>=0.2.2' rescue Exception end require 'hatena/api/graph' GraphData = Struct.new(:date, :value) def hatena_graph(config, data) graph = Hatena::API::Graph.new(config['user_id'], config['password']) if config['proxy_host'] proxy_host = config['proxy_host'] proxy_port = config['proxy_port'] proxy_user = config['proxy_user'] proxy_pass = config['proxy_pass'] graph.proxy = ::Net::HTTP.Proxy(proxy_host, proxy_port, proxy_user, proxy_pass) end graph_data = graph.get_data(config['graph_name']) graph_data.map{|k,v| GraphData.new(k, v)}.sort{|a,b| a.date<=>b.date} end yapra-0.1.2.orig/legacy_plugins/Yaml/0002775000372100037210000000000011074776610016131 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Yaml/save.rb0000664000372100037210000000020011042036362017366 0ustar tachtachrequire "yaml" def save(config,data) File.open(config["filename"],"w") do |w| YAML.dump(data,w) end return data end yapra-0.1.2.orig/legacy_plugins/Yaml/load.rb0000664000372100037210000000013611042036362017357 0ustar tachtachdef load(config,data) require "yaml" return YAML.load_file(config["filename"]) || [] end yapra-0.1.2.orig/legacy_plugins/Filter/0002775000372100037210000000000011220146245016440 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Filter/Translations/0002775000372100037210000000000011074776610021135 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Filter/Translations/yahoo.rb0000664000372100037210000000170111042036362022562 0ustar tachtach## Translate input strings by Yahoo Honyaku -- Soutaro Matsumoto def yahoo(config, data) begin require 'rubygems' rescue LoadError end require 'mechanize' config = (config || { "translation" => "en=>ja" }) trans = case config["translation"] when "en=>ja": "EJ" when "kr=>ja": "KJ" when "cn=>ja": "CJ" when "ja=>en": "JE" when "ja=>kr": "JK" when "ja=>cn": "JC" else return data end data.collect {|d| if d && d =~ /\S/ agent = WWW::Mechanize.new start = agent.get("http://honyaku.yahoo.co.jp/") form = start.forms.last form.radiobuttons.each {|radio| radio.checked = (radio.value =~ /#{trans}/) ? true : false } form.fields.name("text").first.value = d result = agent.submit(form) result.forms.name("textFormEntry").fields.name("trn_text").value else d.to_s end } end yapra-0.1.2.orig/legacy_plugins/Filter/invert.rb0000664000372100037210000000041411042036362020271 0ustar tachtach## filter::invert ## ## Apply filter of config: section and invert the result. ## ## - module: filter::invert ## config: ## - module: grep ## config: ## regex: "理系の人々" ## def invert(config, data) data - eval_pragger(config, data) end yapra-0.1.2.orig/legacy_plugins/Filter/average.rb0000664000372100037210000000020511042036362020372 0ustar tachtach## average plugin -- takatoh def average(config, data) sum = data.inject(0.0){|a,b| a + b.to_f } return [ sum / data.size ] end yapra-0.1.2.orig/legacy_plugins/Filter/apply_text_html.rb0000664000372100037210000000067111042036362022204 0ustar tachtach def apply_text_html(config, data) begin require 'rubygems' rescue LoadError end require 'hpricot' data.collect {|d| doc = Hpricot(d.to_s.toutf8) texts = [] doc.traverse_text {|text| texts << text.to_s } data2 = eval_pragger(config, texts) result_html = d.to_s.toutf8 Hash[*texts.zip(data2).flatten].each {|k,v| result_html.sub!(k,v) } result_html } end yapra-0.1.2.orig/legacy_plugins/Filter/deduped.rb0000664000372100037210000000205211042036362020374 0ustar tachtach## Filter::deduped - Plugin to get Deduped entries -- emergent ## ## Plugin to get Deduped entries ## Cache path can be set. ## ## - module: Filter::deduped ## config: ## path: /tmp/cache/hoge ## require 'pathname' require 'digest/md5' def mkdir_p path begin Dir.mkdir(path) rescue Errno::ENOENT mkdir_p Pathname.new(path).parent retry rescue Errno::EACCES raise end 0 end def deduped config, data cacheroot = Pathname(__FILE__).parent.parent.parent.realpath + 'cache' cachepath = Pathname.new(config['path']) || root if cachepath.relative? cachepath = cacheroot + cachepath end puts ' cache path: ' + cachepath if !File.exists?(cachepath) begin mkdir_p cachepath rescue puts "could'nt make cache directory" return data end end deduped_data = data.select {|d| hashpath = cachepath.to_s + '/' + Digest::MD5.hexdigest(d.to_s) if File.exists?(hashpath) false else File.open(hashpath, "wb").write(d.to_s) rescue false end } return deduped_data end yapra-0.1.2.orig/legacy_plugins/Filter/get_html.rb0000664000372100037210000000023311042036362020564 0ustar tachtachdef get_html(config,data) require 'open-uri' require 'kconv' data.map do |line| r = "" open(line) {|f| r = f.read.toutf8 } r end end yapra-0.1.2.orig/legacy_plugins/Filter/sort.rb0000664000372100037210000000034011042036362017747 0ustar tachtachdef sort(config,data) return data.sort do|a,b| if(config==nil || config["method"] == nil) a <=> b else eval_pragger(config["method"],[a])[0] <=> eval_pragger(config["method"],[b])[0] end end end yapra-0.1.2.orig/legacy_plugins/Filter/subs.rb0000664000372100037210000000017311042036362017740 0ustar tachtachdef subs(config,data) reg = Regexp.new(config["regex"]) to = config["to"] return data.map {|i| i.gsub(reg,to) } end yapra-0.1.2.orig/legacy_plugins/Filter/find_regex.rb0000664000372100037210000000025011042036362021072 0ustar tachtachdef find_regex(config,data) retval = [] reg = Regexp.new(config["regex"]) data.each do |text| text.gsub(reg) {|i| retval.push(i) } end return retval end yapra-0.1.2.orig/legacy_plugins/Filter/fresh.rb0000664000372100037210000000033511042036362020073 0ustar tachtachdef fresh(config,data) t = config['duration'] t = t.to_i * (60) if t=~/m$/ t = t.to_i * (60*60) if t=~/h$/ t = t.to_i * (60*60*24) if t=~/d$/ data.delete_if do |i| i.date < (Time.now - t) end end yapra-0.1.2.orig/legacy_plugins/Filter/to_integer.rb0000664000372100037210000000010011042036362021111 0ustar tachtachdef to_integer(config,data) return data.map{|i| i.to_i } end yapra-0.1.2.orig/legacy_plugins/Filter/grep.rb0000664000372100037210000000073111042036362017721 0ustar tachtach## Filter input by given regular expression -- IKeJI ## ## Filter input by given regular expression. ## The test will be done with the result of to_s method of the input. ## invert option will invert results(-v option of UNIX grep command). ## ## - module: grep ## config: ## regex: "[あ-ん]" ## invert: false def grep(config,data) regex = Regexp.new(config["regex"]) invert = config["invert"] || false data.select {|i| invert ^ (regex =~ i.to_s) } end yapra-0.1.2.orig/legacy_plugins/Filter/find_num.rb0000664000372100037210000000021211042036362020555 0ustar tachtachdef find_num(config,data) retval = [] data.each do |text| text.gsub(/\d(\d|,)+/) {|i| retval.push(i) } end return retval end yapra-0.1.2.orig/legacy_plugins/concat.rb0000664000372100037210000000043011042036362017002 0ustar tachtach## concat two data -- IKeJI ## ## concat two data plugin. ## this plugin is concat two data. ## ## - module: concat ## config: ## - module: foo ## - module: bar ## - module: baz ## def concat(config,data) data2 = eval_pragger(config,[]) return data+data2 end yapra-0.1.2.orig/legacy_plugins/stdout.rb0000664000372100037210000000015411042036362017060 0ustar tachtach## Write data to stdout -- Soutaro Matsumoto def stdout(config, data) data.each {|x| puts x } data end yapra-0.1.2.orig/legacy_plugins/send_msg.rb0000664000372100037210000000047411042036362017342 0ustar tachtach## Send Message Plugin -- Soutaro Matsumoto ## ## it invoke ruby method ## ## -module: send_msg ## config: ## method: to_s ## params: 16 ## def send_msg(config, data) method = config['method'] || nil params = config['params'] || [] data.collect {|x| method ? x.send(method, *params) : x } end yapra-0.1.2.orig/legacy_plugins/Publish/0002775000372100037210000000000011220146245016621 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Publish/scuttle.rb0000664000372100037210000000447611042036362020642 0ustar tachtach## Publish::scuttle - to post feed items to scuttle -- emergent ## ## - module: Publish::scuttle ## config: ## url: http://your.example.com/scuttle/ ## username: your_username ## password: your_password ## opt_tag: pragger ## no_comment: 1 ## require 'rubygems' require 'mechanize' require 'uri' require 'kconv' class Scuttle def initialize url, username, password, proxy=nil @post_url = url + 'api/posts/add?' @username = username @password = password @agent = WWW::Mechanize.new @agent.basic_auth(@username, @password) if proxy && proxy.is_a?(Hash) && proxy['proxy_addr'] && proxy['proxy_port'] @agent.set_proxy(proxy['proxy_addr'], proxy['proxy_port'], proxy['proxy_user'], proxy['proxy_pass']) end end def post url, desc, option=nil params = {} params[:url] = url params[:description] = desc if option params[:extended] = option["summary"] if option["summary"] params[:dt] = option["datetime"] if option["datetime"] params[:tags] = option["tags"] if option["tags"] params[:replace] = 'no' if option["no_replace"] params[:shared] = 'no' if option["private"] end req_param = [] params.each do |k,v| req_param << k.to_s.toutf8 + '=' + v.toutf8 if (v.length > 0) end result = @agent.get(URI.encode(@post_url + req_param.join('&'))) if result.body =~ /code="done"/ return true end false end end def get_tags entry entry.dc_subjects.map do |s| s.content end.join(' ') rescue '' end def scuttle config, data sleeptime = 3 if config['sleep'] sleeptime = config['sleep'].to_i end data.each {|entry| print 'posting ' + entry.title + ': ' tags = get_tags entry if config['opt_tag'] tags = [tags, config['opt_tag']].select{|t| t.length > 0}.join(' ') end summary = config['no_comment'] ? entry.description : '' begin agent = Scuttle.new(config['url'], config['username'], config['password']) res = agent.post(entry.link, entry.title, 'tags' => tags, 'summary' => summary) if res then puts 'done' else puts 'failed' end rescue puts 'exception' #raise end sleep sleeptime } return data end yapra-0.1.2.orig/legacy_plugins/Publish/mixi_diary_writer.rb0000664000372100037210000000543311042036362022703 0ustar tachtach## author "emergent" ## descr "post feed(s) to mixi diary" ## ## example < Field.new("username to login", String, true), ## :password => Field.new("password to login", String, true), ## :merge_feeds => Field.new("aggregate feeds to one diary", String), ## :title => Field.new("title when merge_feeds is on", String) }) require 'rubygems' require 'mechanize' require 'kconv' class MixiDiaryWriter def initialize username=nil, password=nil @id = nil @username = username @password = password @agent = WWW::Mechanize.new end def login username=@username, password=@password if username == nil || password == nil return else @username = username @password = password end @agent.post('http://mixi.jp/login.pl', { 'email' => @username, 'password' => @password, 'next_url' => '/home.pl' }) @home_page = @agent.get('http://mixi.jp/home.pl') end def edit title, content if /add_diary\.pl\?id=(\d+)/ =~ @home_page.body @id = $1 end @edit_page = @agent.get('http://mixi.jp/add_diary.pl?id='+@id) begin edit_form = @edit_page.forms.name("diary").first edit_form['diary_title'] = title.toeuc edit_form['diary_body'] = content.toeuc confirm_page = @agent.submit(edit_form) conf_form = confirm_page.forms[0] # select 'hai' @agent.submit(conf_form) rescue => e puts "Exception when posting diary" puts e.message puts e.backtrace.join("\n") end end OK_TAGS = 'a|p|strong|em|u|del|blockquote' def striptags str str.gsub!(//, "\n") str.gsub!(/<[\/]{0,1}(?!(?:(?:#{OK_TAGS})(?:\s|>)))\w+[\s]{0,1}.*?>/, '') str end end def mixi_diary_writer(config, data) title = config['title'] || data[0].title content = [] if config['merge_feeds'] #.to_i == 1 data.each {|item| content << {:title => title, :body => ('- '+item.title+"\n"+item.description+"...\n\n" rescue item.to_s)} } else data.each {|d| # delete line feed and space at the top of content content << {:title => d.title, :body => d.content_encoded.to_s.sub(/^(?:\s+)/, '')} } end mdw = MixiDiaryWriter.new(config['username'], config['password']) content.each {|entry| mdw.login mdw.edit entry[:title], mdw.striptags(entry[:body]) } return data end yapra-0.1.2.orig/legacy_plugins/Publish/twitter.rb0000664000372100037210000000132511042036362020647 0ustar tachtach##Publish::twitter -- itoshi ## ## from: http://itoshi.tv/d/?date=20071123#p01 ## ##- module: Publish::twitter ## config: ## login: xxxxxx ## password: xxx ## check: 30## ## begin require 'rubygems' rescue LoadError end require 'twitter' require 'kconv' def twitter(config, data) c = Twitter::Client.new(:login=>config["login"], :password=>config["password"]) posts = c.timeline_for(:me,:count=>config["check"]) posted_entries = posts.map do |post| post.text.gsub!(/ http.+$/, '') end data.reverse.each {|item| link = item.link title = item.title.toutf8 next if posted_entries.include? title comment = [title, link].join(' ') s = c.status(:post, comment) p comment } end yapra-0.1.2.orig/legacy_plugins/Publish/google_calendar.rb0000664000372100037210000000256711042036362022263 0ustar tachtach## Write Google Calendar Events -- Soutaro Matsumoto ## ## Write Events on given Calendar. ## The input must be an array of GooleCalendar::Event. ## ## - module: publish::google_calendar ## config: ## mail: your gmail address ## pass: your password ## calendar: the name of calendar begin require 'rubygems' rescue LoadError end require 'gcalapi' require 'date' def google_calendar(config, data) today = Date.today pass = config['pass'] mail = config['mail'] calendar_name = /#{config['calendar']}/ start_day = today - 30 end_day = today + 31 start_time = Time.mktime(start_day.year, start_day.month, start_day.day) end_time = Time.mktime(end_day.year, end_day.month, end_day.day) srv = GoogleCalendar::Service.new(mail, pass) cal_list = GoogleCalendar::Calendar.calendars(srv) calendar = cal_list.values.find {|cal| calendar_name =~ cal.title } if calendar calendar.events(:'start-min' => start_time, :'start-max' => end_time).each {|event| event.destroy! } data.each {|event| begin new_event = calendar.create_event new_event.title = event.title new_event.desc = event.desc new_event.where = event.where new_event.st = event.st new_event.en = event.en new_event.allday = event.allday new_event.save! rescue end } end data end yapra-0.1.2.orig/legacy_plugins/Publish/hatena_graph.rb0000664000372100037210000000216211042036362021566 0ustar tachtach## Post data to Hatena Graph -- takatoh ## ## hatenaapigraph 0.2.1 is required. ## ## - module: Publish::hatena_graph ## config: ## user_id: your-hatena-user-id ## password: your-password ## graph_name: the-name-of-graph ## proxy_host: proxy-host-name (optional) ## proxy_port: proxy-port (optional) ## proxy_user: proxy-user (optional) ## proxy_pass: proxy-password (optional) begin require 'rubygems' gem 'hatenaapigraph', '>=0.2.2' rescue Exception end require 'hatena/api/graph' def hatena_graph(config, data) graph = Hatena::API::Graph.new(config['user_id'], config['password']) if config['proxy_host'] proxy_host = config['proxy_host'] proxy_port = config['proxy_port'] proxy_user = config['proxy_user'] proxy_pass = config['proxy_pass'] graph.proxy = ::Net::HTTP.Proxy(proxy_host, proxy_port, proxy_user, proxy_pass) end data.each do |d| begin graph.post_data(config['graph_name'], :date => d.date, :value => d.value.to_f) rescue graph.post_data(config['graph_name'], :date => Date.today, :value => d.to_f) end end end yapra-0.1.2.orig/legacy_plugins/Publish/hatena_bookmark.rb0000664000372100037210000000241411042036362022272 0ustar tachtach## author "emergent" ## description "post feeds to hatena bookmark" ## this requires hatenabm ## ----- ## $ gem install hatenabm ## ----- ## example < Field.new("username to login", String, true), ## :password => Field.new("password to login", String, true), ## :opt_tag => Field.new("optional tag(s)", String) }) require 'rubygems' require 'hatenabm' def hatena_bookmark(config, data) sleeptime = config["sleep"] ? config["sleep"].to_i : 2 opt_tag = config[:opt_tag] || '' hbm = HatenaBM.new(:user => config['username'],:pass => config['password']) data.each {|entry| puts 'posting ' + entry.title + ': ' tags = entry.dc_subjects.map do |s| s.content end.join(' ') rescue '' if config['opt_tag'] tags = [tags, config['opt_tag']].select{|t| t.length > 0}.join(' ') end summary = config['no_comment'] ? '' : entry.description hbm.post( :title => entry.title, :link => entry.link, :tags => tags, :summary => summary ) sleep sleeptime } return data end yapra-0.1.2.orig/legacy_plugins/Publish/delicious.rb0000664000372100037210000000451511042036362021131 0ustar tachtach## Publish::delicious - to post feed items to del.icio.us-- emergent ## ## - module: Publish::delicious ## config: ## username: your_username ## password: your_password ## opt_tag: pragger ## no_comment: 1 ## require 'rubygems' require 'mechanize' require 'uri' require 'kconv' class Delicious def initialize username, password, proxy=nil @username = username @password = password @agent = WWW::Mechanize.new @agent.basic_auth(@username, @password) if proxy && proxy.is_a?(Hash) && proxy['proxy_addr'] && proxy['proxy_port'] @agent.set_proxy(proxy['proxy_addr'], proxy['proxy_port'], proxy['proxy_user'], proxy['proxy_pass']) end end def post url, desc, option=nil params = {} post_url = 'https://api.del.icio.us/v1/posts/add?' params[:url] = url params[:description] = desc if option params[:extended] = option["summary"] if option["summary"] params[:dt] = option["datetime"] if option["datetime"] params[:tags] = option["tags"] if option["tags"] params[:replace] = 'no' if option["no_replace"] params[:shared] = 'no' if option["private"] end req_param = [] params.map do |k,v| req_param << k.to_s.toutf8 + '=' + v.toutf8 if (v.length > 0) end result = @agent.get(URI.encode(post_url + req_param.join('&'))) puts URI.encode(post_url + req_param.join('&')) if result.body =~ /code="done"/ return true end false end end def get_tags entry entry.dc_subjects.map do |s| s.content end.join(' ') rescue '' end def delicious config, data sleeptime = 3 if config['sleep'] sleeptime = config['sleep'].to_i end data.each {|entry| print 'posting ' + entry.title + ': ' tags = get_tags entry if config['opt_tag'] tags = [tags, config['opt_tag']].select{|t| t.length > 0}.join(' ') end summary = config['no_comment'].to_i > 0 ? '' : entry.description begin agent = Delicious.new(config['username'], config['password']) res = agent.post(entry.link, entry.title, 'tags' => tags, 'summary' => summary) if res then puts 'done' else puts 'failed' end rescue puts 'exception' #raise end sleep sleeptime } data end yapra-0.1.2.orig/legacy_plugins/Publish/hatena_diary_writer.rb0000664000372100037210000000274211042036362023175 0ustar tachtach## Post data to Hatena Diary -- garyo ## ## - module: Publish::hatena_diary_writer ## config: ## user_id: your-hatena-user-id ## password: your-password require 'rubygems' require 'mechanize' require 'kconv' class HatenaDiaryWriter def initialize(id,password) @id = id @password = password @agent = WWW::Mechanize.new if proxy = ENV['HTTP_PROXY'] proxy = URI.parse(proxy) @agent.set_proxy(proxy.host, proxy.port) end @diary = @agent.get("http://d.hatena.ne.jp/#{id}/") end def login login_link = @diary.links.text("ログイン".toeuc) login_page = @agent.get(login_link.href) login_form = login_page.forms.first login_form['name'] = @id login_form['password'] = @password redirect_page = @agent.submit(login_form) @diary_link = redirect_page.links.text("こちら".toutf8) @diary_page = @agent.get(@diary_link.href) end def edit(content) edit_link = @diary_page.links.text("日記を書く".toeuc) edit_page = @agent.get(edit_link.href) edit_form = edit_page.forms.name("edit").first edit_form["body"] += content ok_button = edit_form.buttons.name("edit") @agent.submit(edit_form, ok_button) end end def hatena_diary_writer(config, data) diary = HatenaDiaryWriter.new(config['user_id'], config['password']) content = '' data.each do |line| content << ("* "+line.title+"\n"+line.link+"\n"+line.description rescue line.to_s) end diary.login diary.edit(content.toeuc) end yapra-0.1.2.orig/legacy_plugins/Publish/lingr.rb0000664000372100037210000000477611042036362020275 0ustar tachtach def lingr(config,data) require 'open-uri' require 'kconv' require 'net/http' require 'rexml/document' Net::HTTP.version_1_2 lapi = LingrRoom.new(config['key'],config['room']||'pragger',config['nick']||'praggrTan') data.each do |i| txt = i.title rescue txt = i.to_s lapi.say txt end return data end # Lingr API is from Sasada # http://www.atdot.net/~ko1/diary/200702.html#d5 class LingrRoom class LingrAPIError < RuntimeError; end def initialize key, room, nick @key = key create_session enter room, nick @active = true end def post uri, params = {} uri = URI.parse("http://www.lingr.com/api/#{uri}") Net::HTTP.start(uri.host, uri.port) {|http| response = http.post(uri.path, uri.query) body = response.body if false # ||true puts "---------------------------------------------" puts response.code puts uri puts body body end body } end def get uri, params = {} open("http://www.lingr.com/api/#{uri}"){|f| f.read } end def get_text doc, path e = doc.elements[path] raise LingrAPIError.new("path not found: #{path} at #{doc}") unless e e.get_text end def request method, uri, params doc = REXML::Document.new(__send__(method, uri, params)) raise LingrAPIError.new("Error: #{doc.to_s}") if get_text(doc, '/response/status') != 'ok' doc end def post_request uri, params = {} request :post, uri, params end def get_request uri, params = {} request :get, uri, params end def create_session doc = post_request "session/create?api_key=#{@key}" @session = get_text(doc, '/response/session') end def enter room, nick doc = post_request "room/enter?session=#{@session}&id=#{room}&nickname=#{nick}" @room_doc = doc @ticket = get_text(doc, '/response/ticket') @counter = get_text(doc, '/response/room/counter') end def observe doc = get_request "room/observe?session=#{@session}&ticket=#{@ticket}&counter=#{@counter}" # @counter = get_text(doc, '/response/counter') result = [] doc.elements['/response/messages'].each{|e| nick = get_text(e, 'nickname') text = get_text(e, 'text') result << [nick, text] } result end def observe_loop while @active observe.each{|nick, text| puts "#{nick}: #{text}".tosjis } end end def say text doc = post_request "room/say?session=#{@session}&ticket=#{@ticket}&message=#{URI.encode(text)}" end end yapra-0.1.2.orig/legacy_plugins/plagger.rb0000664000372100037210000000466511042036362017172 0ustar tachtach## Interleave Plagger processing -- Soutaro Matsumoto ## ## Invokes Plagger and process the input with your Plagger. ## The input must be an Array of RSS::RDF::Item. ## The output is an Array of RSS::RDF::Item. ## If "debug" is a value evaluated to true, tempolary files for/from Plagger won't be deleted. ## If "input" is not "feed", the input will be ignored. ## If you omit "dir", the default is /var. ## Make sure your system have /var directory and pragger/Plagger can write. ## ## - module: plagger ## config: ## input: feed ## debug: false ## dir: /var ## plugins: ## - module: Publish::CSV ## config: ## dir: /var ## filename: a.csv require 'rbconfig' require 'open-uri' require 'rss/1.0' require 'rss/2.0' require 'pathname' raise LoadError unless ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR']).find {|dir| File.executable?(File.join(dir, 'plagger')) || File.executable?(File.join(dir, 'plagger.bat')) } def plagger(config, data) pla_con = config["plugins"] if input_option(config) == :feed pla_con = [{"module" => "Subscription::Feed", "config"=>{ "url" => "file:#{pla_input(config)}" }}] + pla_con eval_pragger([{"module" => "save_rss", "config" => { "filename" => pla_input(config).to_s }}], data) end pla_con.push({"module" => "Publish::Feed", "config" => {"dir" => "/var", "format" => "RSS", "filename" => pla_output(config).basename.to_s}}) pla_config(config).open("w") {|io| io.write to_plagger_yaml(YAML.dump({ "plugins" => pla_con })) } system "plagger -c #{pla_config(config)}" begin RSS::Parser.parse(pla_output(config).read).items rescue [] ensure unless config.has_key?("debug") pla_config(config).delete pla_input(config).delete pla_output(config).delete end end end def pla_dir(config) Pathname.new(config.has_key?("dir") ? config["dir"] : "/var") end def pla_config(config) pla_dir(config) + "pla.yaml" end def pla_output(config) pla_dir(config) + "pla_output" end def pla_input(config) pla_dir(config) + "pla_input" end def input_option(config) opt = config.has_key?("input") ? config["input"] : "nothing" case opt when "feed": :feed when "nothing": :nothing else :nothing end end def to_plagger_yaml(yaml) a = yaml.split(/\n/) ret = a[1]+"\n" ret + a[2..(a.size-1)].collect {|x| " "+x }.join("\n")+"\n" end yapra-0.1.2.orig/legacy_plugins/reverse.rb0000664000372100037210000000017711042036362017216 0ustar tachtach## reverse plugin -- IKeJI ## ## it reverse data array ## ## -module: reverse ## def reverse(config, data) data.reverse end yapra-0.1.2.orig/legacy_plugins/first.rb0000664000372100037210000000022311042036362016662 0ustar tachtach## first data plugin -- IKeJI ## ## this plugin returns only first data ## ## -moduel: first ## def first(config,data) return [data.first] end yapra-0.1.2.orig/legacy_plugins/head.rb0000664000372100037210000000032311042036362016435 0ustar tachtach## head plugin -- IKeJI ## ## it looks like linux head command. ## this example is like 'head -n 10' ## ## -module: head ## config: ## n: 10 ## def head(config,data) return data[0, config['n'].to_i] end yapra-0.1.2.orig/legacy_plugins/print.rb0000664000372100037210000000025711042036362016676 0ustar tachtach## pritty print plugin -- IKeJI ## ## it for debug ## print data using pritty print ## ## -module: print ## require "pp" def print(config,data) pp data return data end yapra-0.1.2.orig/legacy_plugins/pluginbase.rb0000664000372100037210000000005511042036362017667 0ustar tachtachdef pluginbase(config,data) return [] end yapra-0.1.2.orig/legacy_plugins/stdin.rb0000664000372100037210000000030011042036362016650 0ustar tachtach## Read data from stdin -- Soutaro Matsumoto def stdin(config, data) stdin_data = readlines (config || { "input" => "concat" })["input"] == "nothing" ? stdin_data : data + stdin_data end yapra-0.1.2.orig/legacy_plugins/argv.rb0000664000372100037210000000012111042036362016467 0ustar tachtach## read data form argv -- takatoh def argv(config,data) return ARGV.clone end yapra-0.1.2.orig/legacy_plugins/const_list.rb0000664000372100037210000000026411042036362017721 0ustar tachtach## constant list -- IKeJI ## ## constant list plugin. ## ## - module: const_list ## config: ## - a ## - b ## - c ## def const_list(config,data) return config end yapra-0.1.2.orig/legacy_plugins/plugin_from_uri.rb0000664000372100037210000000136311042036362020741 0ustar tachtach## Load plugin from uri and evaluate it -- Soutaro Matsumoto ## ## Load plugiin from uri and evaluate it. ## If you omit "name", the last component of the uri will be used as the name of plugin. ## ## - module: plugin_from_uri ## config: ## uri: http://some_host/some_path ## name: super_plugin ## config: ## ** configuration for the plugin ** require 'open-uri' require 'uri' def plugin_from_uri(config, data) uri = URI(config["uri"]) name = config["name"] || uri.path.split("/").last.gsub(/\..*$/,'') body = open(uri.to_s) {|io| io.read} plugin = Class.new(Plugin) plugin.class_eval { def initialize() end } plugin.class_eval(body, uri.to_s, 1) plugin.new().send(name, config["config"], data) end yapra-0.1.2.orig/legacy_plugins/Download/0002775000372100037210000000000011074776610016776 5ustar tachtachyapra-0.1.2.orig/legacy_plugins/Download/nicovideo.rb0000664000372100037210000000234311042036362021266 0ustar tachtach## Download Nicovideo FLV -- IKeJI ## ## Download from Nicovideo to file ## ## - module: Download::nicovideo ## config: ## authfile: nicovideo_auth.yaml ## dir: ./nicovideo require 'rubygems' require 'mechanize' require 'cgi' def nicovideo(config,data) auth = YAML.load( File.read( config['authfile'] ) ) agent = WWW::Mechanize.new page = agent.post("https://secure.nicovideo.jp/secure/login?site=niconico", {"mail"=>auth["mail"],"password"=>auth["password"]}) sleep 3 data.each do|dat| link = dat.link next unless link =~ /www\.nicovideo\.jp\/watch\/(.*)/ id = $1 next if File.exist?("#{config['dir']}/#{id}.flv") begin page = agent.get("http://www.nicovideo.jp/api/getflv?v=#{id}") sleep 3 list = CGI.parse(page.body) flv = agent.get(link) sleep 3 flv = agent.get(list['url']) sleep 3 File.open("#{config['dir']}/#{id}.flv","w")do |w| w.write flv.body end File.open("#{config['dir']}/list.html","a")do |w| w.puts "

#{dat.title}

#{dat.description}" end rescue STDERR.puts "an error occurred in downloadng FLV #{id}" end sleep 3 end end yapra-0.1.2.orig/legacy_plugins/load_path.rb0000664000372100037210000000055711042036362017500 0ustar tachtach## Add path to $LOAD_PATH -- gtaka555 ## ## Add path to $LOAD_PATH plugin. ## ## - module: load_path ## config: ## path: ## - /home/foo/ruby/lib/1 ## - /home/foo/ruby/lib/2 ## - /home/foo/ruby/lib/3 ## def load_path(config, data) return data unless config.key?('path') config['path'].each {|path| $LOAD_PATH << path } data end yapra-0.1.2.orig/Rakefile0000664000372100037210000000071711042036362013656 0ustar tachtachrequire 'config/requirements' require 'config/hoe' # setup Hoe + all gem configuration Dir['tasks/**/*.rake'].each { |rake| load rake } ############################################################################## # SVN ############################################################################## desc "Add new files to subversion" task :svn_add do system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add" end yapra-0.1.2.orig/tasks/0002775000372100037210000000000011220146245013333 5ustar tachtachyapra-0.1.2.orig/tasks/deployment.rake0000664000372100037210000000217511042036362016362 0ustar tachtachdesc 'Release the website and new gem version' task :deploy => [:check_version, :website, :release] do puts "Remember to create SVN tag:" puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " + "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} " puts "Suggested comment:" puts "Tagging release #{CHANGES}" end desc 'Runs tasks website_generate and install_gem as a local deployment of the gem' task :local_deploy => [:website_generate, :install_gem] task :check_version do unless ENV['VERSION'] puts 'Must pass a VERSION=x.y.z release version' exit end unless ENV['VERSION'] == VERS puts "Please update your version.rb to match the release version, currently #{VERS}" exit end end desc 'Install the package as a gem, without generating documentation(ri/rdoc)' task :install_gem_no_doc => [:clean, :package] do sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri" end namespace :manifest do desc 'Recreate Manifest.txt to include ALL files' task :refresh do `rake check_manifest | patch -p0 > Manifest.txt` end endyapra-0.1.2.orig/tasks/environment.rake0000664000372100037210000000017311042036362016542 0ustar tachtachtask :ruby_env do RUBY_APP = if RUBY_PLATFORM =~ /java/ "jruby" else "ruby" end unless defined? RUBY_APP end yapra-0.1.2.orig/tasks/rspec.rake0000664000372100037210000000063611042036362015316 0ustar tachtachbegin require 'spec' rescue LoadError require 'rubygems' require 'spec' end begin require 'spec/rake/spectask' rescue LoadError puts <<-EOS To use rspec for testing you must install rspec gem: gem install rspec EOS exit(0) end desc "Run the specs under spec/models" Spec::Rake::SpecTask.new do |t| t.spec_opts = ['--options', "spec/spec.opts"] t.spec_files = FileList['spec/**/*_spec.rb'] end yapra-0.1.2.orig/tasks/website.rake0000664000372100037210000000111111042036362015631 0ustar tachtachdesc 'Generate website files' task :website_generate => :ruby_env do (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt| sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} } end end desc 'Upload website files to rubyforge' task :website_upload do host = "#{rubyforge_username}@rubyforge.org" remote_dir = "/var/www/gforge-projects/#{PATH}/" local_dir = 'website' sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}} end desc 'Generate and upload website files' task :website => [:website_generate, :website_upload, :publish_docs] yapra-0.1.2.orig/Manifest.txt0000664000372100037210000000672511073574536014543 0ustar tachtachHistory.txt LICENCE License.txt Manifest.txt PostInstall.txt README.txt Rakefile bin/yapra config/hoe.rb config/requirements.rb fixtures/config/habu_like.yml fixtures/config/mixed_type.yml fixtures/config/pragger_like.yml fixtures/legacy_plugin/legacy_test_plugin.rb legacy_plugins/Download/nicovideo.rb legacy_plugins/Feed/custom_feed.rb legacy_plugins/Feed/google_calendar.rb legacy_plugins/Feed/google_search_history.rb legacy_plugins/Feed/hatena_graph.rb legacy_plugins/Feed/lirs.rb legacy_plugins/Filter/Translations/yahoo.rb legacy_plugins/Filter/apply_text_html.rb legacy_plugins/Filter/average.rb legacy_plugins/Filter/deduped.rb legacy_plugins/Filter/find_num.rb legacy_plugins/Filter/find_regex.rb legacy_plugins/Filter/fresh.rb legacy_plugins/Filter/get_html.rb legacy_plugins/Filter/grep.rb legacy_plugins/Filter/invert.rb legacy_plugins/Filter/sort.rb legacy_plugins/Filter/subs.rb legacy_plugins/Filter/to_integer.rb legacy_plugins/Publish/delicious.rb legacy_plugins/Publish/google_calendar.rb legacy_plugins/Publish/hatena_bookmark.rb legacy_plugins/Publish/hatena_diary_writer.rb legacy_plugins/Publish/hatena_graph.rb legacy_plugins/Publish/lingr.rb legacy_plugins/Publish/mixi_diary_writer.rb legacy_plugins/Publish/scuttle.rb legacy_plugins/Publish/twitter.rb legacy_plugins/RSS/load.rb legacy_plugins/RSS/save.rb legacy_plugins/Yaml/load.rb legacy_plugins/Yaml/save.rb legacy_plugins/argv.rb legacy_plugins/concat.rb legacy_plugins/const_list.rb legacy_plugins/first.rb legacy_plugins/head.rb legacy_plugins/load_path.rb legacy_plugins/plagger.rb legacy_plugins/plugin_from_uri.rb legacy_plugins/pluginbase.rb legacy_plugins/print.rb legacy_plugins/reverse.rb legacy_plugins/send_msg.rb legacy_plugins/stdin.rb legacy_plugins/stdout.rb lib-plugins/yapra/plugin/config/agent.rb lib-plugins/yapra/plugin/config/basic_auth.rb lib-plugins/yapra/plugin/config/web_post.rb lib-plugins/yapra/plugin/feed/custom.rb lib-plugins/yapra/plugin/feed/load.rb lib-plugins/yapra/plugin/filter/apply_template.rb lib-plugins/yapra/plugin/filter/deduped.rb lib-plugins/yapra/plugin/filter/entry_full_text.rb lib-plugins/yapra/plugin/publish/file_download.rb lib-plugins/yapra/plugin/publish/gmail.rb lib-plugins/yapra/plugin/publish/imap.rb lib-plugins/yapra/plugin/publish/on_memory_download.rb lib-plugins/yapra/plugin/test/append_entry.rb lib-plugins/yapra/plugin/test/raise_error.rb lib-plugins/yapra/plugin/test/test.rb lib-plugins/yapra/plugin/test/test2.rb lib/yapra.rb lib/yapra/config.rb lib/yapra/inflector.rb lib/yapra/legacy_plugin.rb lib/yapra/legacy_plugin/advance_mode_registry.rb lib/yapra/legacy_plugin/base.rb lib/yapra/legacy_plugin/compatible_mode_registry.rb lib/yapra/legacy_plugin/registry_factory.rb lib/yapra/pipeline.rb lib/yapra/plugin.rb lib/yapra/plugin/base.rb lib/yapra/plugin/context_aware.rb lib/yapra/plugin/erb_applier.rb lib/yapra/plugin/feed_item_operator.rb lib/yapra/plugin/mechanize_base.rb lib/yapra/runtime.rb lib/yapra/version.rb plugins/Filter/deduped.rb plugins/Filter/grep.rb plugins/Filter/sort.rb plugins/Filter/subs.rb script/console script/destroy script/generate script/txt2html setup.rb spec/spec.opts spec/spec_helper.rb spec/yapra/config_spec.rb spec/yapra/legacy_plugin/base_spec.rb spec/yapra/legacy_plugin/registry_factory_spec.rb spec/yapra/pipeline_spec.rb spec/yapra_spec.rb tasks/deployment.rake tasks/environment.rake tasks/rspec.rake tasks/website.rake website/index.txt website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css website/template.html.erb yapra-0.1.2.orig/config/0002775000372100037210000000000011074776610013467 5ustar tachtachyapra-0.1.2.orig/config/requirements.rb0000664000372100037210000000052411042036362016522 0ustar tachtachrequire 'fileutils' include FileUtils require 'rubygems' %w[rake hoe newgem rubigen].each do |req_gem| begin require req_gem rescue LoadError puts "This Rakefile requires the '#{req_gem}' RubyGem." puts "Installation: gem install #{req_gem} -y" exit end end $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib])) yapra-0.1.2.orig/config/hoe.rb0000664000372100037210000000470211042036362014554 0ustar tachtachrequire 'yapra/version' AUTHOR = 'Yuanying' # can also be an array of Authors EMAIL = "yuanying at fraction dot jp" DESCRIPTION = "Yet another pragger implementation." GEM_NAME = 'yapra' # what ppl will type to install your gem RUBYFORGE_PROJECT = 'yapra' # The unix name for your project HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" EXTRA_DEPENDENCIES = [ ['mechanize', '>= 0.7.6'] ] # An array of rubygem dependencies [name, version] @config_file = "~/.rubyforge/user-config.yml" @config = nil RUBYFORGE_USERNAME = "unknown" def rubyforge_username unless @config begin @config = YAML.load(File.read(File.expand_path(@config_file))) rescue puts <<-EOS ERROR: No rubyforge config file found: #{@config_file} Run 'rubyforge setup' to prepare your env for access to Rubyforge - See http://newgem.rubyforge.org/rubyforge.html for more details EOS exit end end RUBYFORGE_USERNAME.replace @config["username"] end REV = nil # UNCOMMENT IF REQUIRED: # REV = YAML.load(`svn info`)['Revision'] VERS = Yapra::VERSION::STRING + (REV ? ".#{REV}" : "") RDOC_OPTS = ['--quiet', '--title', 'yapra documentation', "--opname", "index.html", "--line-numbers", "--main", "README", "--inline-source"] class Hoe def extra_deps @extra_deps.reject! { |x| Array(x).first == 'hoe' } @extra_deps end end # Generate all the Rake tasks # Run 'rake -T' to see list of generated tasks (from gem root directory) $hoe = Hoe.new(GEM_NAME, VERS) do |p| p.developer(AUTHOR, EMAIL) p.description = DESCRIPTION p.summary = DESCRIPTION p.url = HOMEPATH p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT p.test_globs = ["test/**/test_*.rb"] p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean. # == Optional p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") #p.extra_deps = EXTRA_DEPENDENCIES p.spec_extras = { 'require_paths' => ['lib', 'lib-plugins'] } end CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n") PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}" $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc') $hoe.rsync_args = '-av --delete --ignore-errors' $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""yapra-0.1.2.orig/License.txt0000664000372100037210000000215511042036362014332 0ustar tachtachCopyright (c) 2008 fraction.jp. Some rights reserved. Original from 2008-06-12 http://pragger.ikejisoft.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.yapra-0.1.2.orig/fixtures/0002775000372100037210000000000011074776610014073 5ustar tachtachyapra-0.1.2.orig/fixtures/legacy_plugin/0002775000372100037210000000000011074776610016715 5ustar tachtachyapra-0.1.2.orig/fixtures/legacy_plugin/legacy_test_plugin.rb0000664000372100037210000000006011042036362023101 0ustar tachtach def legacy_test_plugin(config, data) data endyapra-0.1.2.orig/fixtures/config/0002775000372100037210000000000011074776610015340 5ustar tachtachyapra-0.1.2.orig/fixtures/config/habu_like.yml0000664000372100037210000000154611042036362017776 0ustar tachtachglobal: log: out: stderr level: debug pipeline: pipeline1: - module: RSS::load config: url: - http://www.fraction.jp/log/feed/rdf - http://d.hatena.ne.jp/yuanying/rss - http://yuanying.oeilvert.org/books.rss - module: Filter::sort config: method: date - module: reverse - module: head config: n: 10 - module: RSS::save config: filename: feed.xml link: http://www.fraction.jp/ title: BONNOH FRACTION pipeline2: - module: Feed::pixiv_tag config: id: yuanying password: kojiro tag: C74 - module: RSS::save config: #filename: /Users/Shared/Sites/fraction/feed.xml filename: pixiv.xml link: http://www.pixiv.net/tags.php?tag=C74 title: Pixiv - C74 yapra-0.1.2.orig/fixtures/config/mixed_type.yml0000664000372100037210000000054111042036362020214 0ustar tachtachglobal: log: out: stderr level: debug pipeline: - module: Feed::pixiv_tag config: id: yuanying password: kojiro tag: C74 - module: RSS::save config: #filename: /Users/Shared/Sites/fraction/feed.xml filename: pixiv.xml link: http://www.pixiv.net/tags.php?tag=C74 title: Pixiv - C74 yapra-0.1.2.orig/fixtures/config/pragger_like.yml0000664000372100037210000000041111042036362020474 0ustar tachtach- module: Feed::pixiv_tag config: id: yuanying password: kojiro tag: C74 - module: RSS::save config: #filename: /Users/Shared/Sites/fraction/feed.xml filename: pixiv.xml link: http://www.pixiv.net/tags.php?tag=C74 title: Pixiv - C74yapra-0.1.2.orig/README.txt0000664000372100037210000000356711042036362013715 0ustar tachtach= yapra * http://yapra.rubyforge.org/ * http://github.com/yuanying/yapra/tree/master == DESCRIPTION: Yet Another Pragger(http://pragger.ikejisoft.com/) implementation. == FEATURES/PROBLEMS: * 99% compatible of Pragger. * Class-based plugin support. * Loadpass based plugin loading strategy. (also support pragger's plugin in advance mode.) * Support Python habu like config file. == SYNOPSIS: === Use at command $ yapra -c config_file.yml === Use in your application require 'yapra/runtime' require 'yapra/config' config = YAML.load(config_file) config = Yapra::Config.new(config) Yapra::Runtime.logger = Logger.new(STDOUT) yapra = Yapra::Runtime.new(config.env) yapra.execute(config.pipeline_commands) == REQUIREMENTS: * mechanize (>= 0.7.6) == INSTALL: * sudo gem install yapra == LICENSE: (The MIT License) Copyright (c) 2008 Yuanying Ohtsuka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.yapra-0.1.2.orig/lib-plugins/0002775000372100037210000000000011074776610014447 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/0002775000372100037210000000000011074776610015563 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/0002775000372100037210000000000011074776611017062 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/publish/0002775000372100037210000000000011220146245020513 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/publish/on_memory_download.rb0000664000372100037210000000422111042036362024730 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Publish # = Publish::OnMemoryDownload -- Yuanying # # download web resource and set to item attribute. # # example: # # - module: Publish::OnMemoryDownload # config: # regexp: http://www\.yahoo\.co\.jp/* # attribute: binary_image # before_hook: "agent.get('http://www.yahoo.co.jp/'); sleep 1" # url: # attribute: link # replace: index(\d*?)\.html # to: file\1.zip # referrer: # attribute: link # replace: 'zip' # to: 'html' # class OnMemoryDownload < Yapra::Plugin::MechanizeBase def run(data) regexp = nil if config['regexp'] regexp = Regexp.new(config['regexp']) else regexp = /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/ end wait = config['wait'] || 3 data.each do |item| url = construct_data(config['url'], item, item.respond_to?('link') ? item.link : item) if regexp =~ url logger.debug "Download start: #{url}" referrer = construct_data(config['referrer'], item) download(item, url, referrer) sleep wait end end data end protected def construct_data(config, item, original=nil) if config && config['attribute'] if item.respond_to?(config['attribute']) original = item.__send__(config['attribute']) end elsif config original = item end if original && config && config['replace'] original = original.gsub(config['replace'], config['to'] || Time.now.to_s) end original end def save config, item, page set_attribute_to item, config['attribute'], page end def download(item, url, referrer) if config['before_hook'] eval(config['before_hook']) end dir = config['dir'] page = agent.get(url, referrer) save(config, item, page) if config['after_hook'] eval(config['after_hook']) end end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/publish/gmail.rb0000664000372100037210000000114511042036362022130 0ustar tachtachrequire 'net/imap' require 'yapra/plugin/publish/imap' module Yapra::Plugin::Publish # = module: Publish::Gmail -- Yuanying # # publish entry to imap mail. # # example: # # - module: Publish::Gmail # config: # username: username # password: password # wait: 1 # mail: # subject_prefix: '[Yapra]' # from: 'test@example.com' # to: 'test2@example.com' # class Gmail < Yapra::Plugin::Publish::Imap protected def create_imap server, port, usessl Net::IMAP.new('imap.gmail.com', 993, true) end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/publish/file_download.rb0000664000372100037210000000314511042036362023647 0ustar tachtachrequire 'yapra/plugin/publish/on_memory_download' module Yapra::Plugin::Publish # = Publish::FileDownload -- Yuanying # # download file with WWW::Mechanize. # # example: # # - module: Publish::FileDownload # config: # regexp: http://www\.yahoo\.co\.jp/* # dir: '/Users/yuanying/Downloads/' # auto_suffix: true # before_hook: "agent.get('http://www.yahoo.co.jp/'); sleep 1" # url: # attribute: link # replace: index(\d*?)\.html # to: file\1.zip # filename: # attribute: title # replace: 'Yahoo' # to: '' # referrer: # attribute: link # replace: 'zip' # to: 'html' # class FileDownload < Yapra::Plugin::Publish::OnMemoryDownload protected def discover_extensions page require 'mime/types' types = MIME::Types[page.content_type] if types.size > 0 && types[0].extensions.size > 0 return type[0].extensions[0] else logger.info 'suitable extention is not found.' return nil end rescue LoadError => ex logger.warn 'require mime-types is failed.' end def save config, item, page filename = construct_data(config['filename'], item) filename = page.filename unless filename if config['auto_suffix'] ext = discover_extensions(page) filename = "#{filename}.#{ext}" if ext end path = File.join(dir, filename) open(path, 'w') do |io| io.write page.body end end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/publish/imap.rb0000664000372100037210000000770511042036362021775 0ustar tachtachrequire 'net/imap' require 'yapra/version' require 'yapra/plugin/base' module Yapra::Plugin::Publish # = module: Publish::Imap -- Yuanying # # publish entry to imap mail. # # example: # # - module: Publish::Imap # config: # username: username # password: password # imap_server: imap.gmail.com # port: 993 # ssl: on # wait: 1 # mail: # subject_prefix: '[Yapra]' # from_template: <%=item.author%> # #from: 'test@example.com' # to: 'test2@example.com' # class Imap < Yapra::Plugin::Base def run(data) username = config['username'] password = config['password'] server = config['imap_server'] || 'imap.gmail.com' port = config['port'] || 993 usessl = ('off' != config['ssl']) mailbox = config['mailbox'] || 'inbox' wait = config['wait'] || 1 unless config['mail'] config['mail'] = {} end subject_prefix = config['mail']['subject_prefix'] || '' from = config['mail']['from'] || 'yapra@localhost' to = config['mail']['to'] || 'me@localhost' imap = create_imap server, port, usessl logger.debug(imap.greeting) imap.login(username, password) logger.info('imap login was succeed.') imap.examine(mailbox) data.each do |item| date = item.date || item.dc_date || Time.now content = item.content_encoded || item.description || 'from Yapra.' content = [content].pack('m') if config['mail']['from_template'] from = apply_template(config['mail']['from_template'], binding) end if config['mail']['to_template'] to = apply_template(config['mail']['to_template'], binding) end subject = (subject_prefix + item.title).gsub(/\n/, '').chomp logger.debug("try append item: #{subject}") boundary = "----_____====#{Time.now.to_i}--BOUDARY" attachments = create_attachments(item, config) imap.append(mailbox, apply_template(mail_template, binding), nil, date) # puts apply_template(mail_template, binding) sleep wait end imap.disconnect data end protected def create_imap server, port, usessl logger.debug("server: #{server}:#{port}, usessl = #{usessl}") Net::IMAP.new(server, port, usessl) end def encode_field field field.gsub(/[^\x01-\x7f]*/) {|x| x.scan(/.{1,10}/).map {|y| "=?UTF-8?B?" + y.to_a.pack('m').chomp + "?=" }.join("\n ") } end def create_attachments item, config attachments = [] attachment_attributes = config['mail']['attachments'] if attachment_attributes.kind_of?(String) file = item.__send__(attachment_attributes) attachments << file if file.kind_of?(WWW::Mechanize::File) elsif attachment_attributes.kind_of?(Array) attachment_attributes.each do |atc| file = item.__send__(atc) attachments << file if file.kind_of?(WWW::Mechanize::File) end end attachments end def mail_template return < To: <%=encode_field(to) %> Date: <%=date.rfc2822 %> MIME-Version: 1.0 X-Mailer: Yapra <%=Yapra::VERSION::STRING %> Subject: <%=encode_field(subject) %> Content-Type: multipart/mixed; boundary="<%=boundary -%>" This is a multi-part message in MIME format. --<%=boundary %> Content-type: text/html; charset=UTF-8 Content-transfer-encoding: base64 <%=content %> --<%=boundary %> <% attachments.each do |file| -%> Content-Type: <%=file.header['Content-Type'] %>; name="<%=encode_field(file.filename) %>" Content-Disposition: attachment; filename="<%=encode_field(file.filename) %>" Content-Transfer-Encoding: base64 <%=[file.body].pack('m') -%> --<%=boundary %> <% end -%> EOT end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/feed/0002775000372100037210000000000011220146245017750 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/feed/load.rb0000664000372100037210000000154111042036362021213 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Feed # = Load RSS from given URLs # # Load RSS from given URLs. # If URL is an Array, all URLs in the array will be loaded. # # - module: RSS::load # config: # uri: http://www.example.com/hoge.rdf # class Load < Yapra::Plugin::MechanizeBase def run(data) urls = if config['url'].kind_of?(Array) config['url'] else [ config['url'] ] end urls.each do |url| logger.debug("Process: #{url}") source = agent.get(url).body rss = nil begin rss = RSS::Parser.parse(source) rescue rss = RSS::Parser.parse(source, false) end rss.items.each do |item| data << item end end data end end end yapra-0.1.2.orig/lib-plugins/yapra/plugin/feed/custom.rb0000664000372100037210000000211611042036362021605 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Feed # = Feed::Custom # # generate rss feed from web page. # # example: # # - module: Feed::Custom # config: # url: 'http://www.fraction.jp/' # extract_xpath: # capture: '//div' # split: '//div[@class="test"]' # description: '//div' # link: '//li[2]' # title: '//p' # apply_template_after_extracted: # content_encoded: '

<%= title %>
' class Custom < Yapra::Plugin::MechanizeBase def run(data) page = agent.get(config['url']) root = page.root xconfig = config['extract_xpath'] if xconfig['capture'] root = root.at(xconfig['capture']) end split = xconfig['split'] xconfig.delete('capture') xconfig.delete('split') root.search(split).each do |element| item = RSS::RDF::Item.new extract_attribute_from element, item data << item end data end end end yapra-0.1.2.orig/lib-plugins/yapra/plugin/test/0002775000372100037210000000000011220146245020024 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/test/raise_error.rb0000664000372100037210000000030611073527763022700 0ustar tachtachrequire 'yapra/plugin/base' module Yapra::Plugin::Test class RaiseError < Yapra::Plugin::Base def run(data) message = config['message'] || 'Error.' raise message end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/test/test2.rb0000644000372100037210000000035211073572113021411 0ustar tachtachrequire 'yapra/plugin/base' module Yapra::Plugin::Test class Test2 < Yapra::Plugin::Base def run(data) logger.debug 'test2!!' data end def on_error(ex) logger.debug 'on error2!!' end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/test/test.rb0000644000372100037210000000027411073537676021351 0ustar tachtachrequire 'yapra/plugin' module Yapra::Plugin::Test class Test def run(data) puts 'test!!' data end def on_error(ex) puts 'on error!!' end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/test/append_entry.rb0000664000372100037210000000076611042036362023050 0ustar tachtachrequire 'yapra/plugin/base' module Yapra::Plugin::Test # module: Test::AppendEntry -- Yuanying # # append entry to data array. # # example: # # - module: Test::AppendEntry # config: # title: 'title' # description: 'description.' class AppendEntry < Yapra::Plugin::Base def run(data) item = RSS::RDF::Item.new plugin_config.each do |k, v| set_attribute_to item, k, v end data << item data end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/config/0002775000372100037210000000000011220146245020312 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/config/agent.rb0000664000372100037210000000142711042036362021737 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Config # Yapra::Config::Agent -- Yuanying # # add WWW::Mechanize agent to context. # # - module: Config::Agent # config: # user_agent_alias: Windows IE 6 # proxy: # addr: localhost # port: 8080 # user: username # password: password # class Agent < Yapra::Plugin::MechanizeBase def run(data) agent.user_agent_alias = config['user_agent_alias'] || 'Windows IE 6' if config['proxy'] agent.set_proxy( config['proxy']['addr'], config['proxy']['port'], config['proxy']['user'], config['proxy']['password'] ) end return data end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/config/basic_auth.rb0000664000372100037210000000066211042036362022743 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Config # Config::BasicAuth -- Yuanying # # post to web page with WWW::Mechanize agent. # # - module: Config::BasicAuth # config: # user: yuanying # password: password-dayo class BasicAuth < Yapra::Plugin::MechanizeBase def run(data) agent.basic_auth(config['user'], config['password']) data end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/config/web_post.rb0000664000372100037210000000076011042036362022462 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Config # Config::WebPost -- Yuanying # # post to web page with WWW::Mechanize agent. # # - module: Config::WebPost # config: # url: http://www.pixiv.net/index.php # params: # pixiv_id: yuanying # pass: password-dayo # class WebPost < Yapra::Plugin::MechanizeBase def run(data) agent.post(config['url'], config['params']) data end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/filter/0002775000372100037210000000000011220146245020332 5ustar tachtachyapra-0.1.2.orig/lib-plugins/yapra/plugin/filter/deduped.rb0000664000372100037210000000267211073564622022307 0ustar tachtachrequire 'yapra/plugin/base' require 'fileutils' require 'pathname' require 'digest/md5' module Yapra::Plugin::Filter # Filter::Deduped - Plugin to get Deduped entries -- original by emergent # # Plugin to get Deduped entries # Cache path can be set. # # - module: Filter::Deduped # config: # path: /tmp/cache/hoge # class Deduped < Yapra::Plugin::Base def run(data) cacheroot = Pathname.new(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'cache')) cachepath = Pathname.new(config['path']) || cacheroot if cachepath.relative? cachepath = cacheroot + cachepath end unless File.exists?(cachepath) FileUtils.mkdir_p(cachepath) end attribute = config['attribute'] @cache_paths = [] deduped_data = data.select {|d| v = d.link rescue d.to_s if attribute && d.respond_to?(attribute) v = d.__send__(attribute).to_s end hashpath = File.join(cachepath.to_s, Digest::MD5.hexdigest(v)) if File.exists?(hashpath) false else begin File.open(hashpath, "wb").write(v) @cache_paths << hashpath true rescue false end end } return deduped_data end def on_error(ex) logger.debug('error is occured.') FileUtils.rm(@cache_paths, {:force => true}) end end endyapra-0.1.2.orig/lib-plugins/yapra/plugin/filter/entry_full_text.rb0000664000372100037210000000316111042036362024105 0ustar tachtachrequire 'yapra/plugin/mechanize_base' module Yapra::Plugin::Filter # Filter::EntryFullText -- Yuanying # # get the entry full text from page with WWW::Mechanize. # # - module: Filter::EntryFullText # config: # regexp: http://www\.pixiv\.net/* # extract_xpath: # title: '//title/text()' # dc_creator: "//div[@id='profile']/div/text()" # author: "//div[@id='profile']/div/text()" # description: "//div[@id='content2']" # apply_template_after_extracted: # content_encoded: '
<%= title %>
' class EntryFullText < Yapra::Plugin::MechanizeBase def run(data) regexp = nil if config['regexp'] regexp = Regexp.new(config['regexp']) else regexp = /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/ end wait = config['wait'] || 1 data.map! do |item| url = item if item.respond_to?('link') url = item.link end if regexp =~ url logger.debug "Process: #{url}" page = agent.get(url) sleep wait unless(item.instance_of?(RSS::RDF::Item)) new_item = RSS::RDF::Item.new new_item.title = item.title rescue item.to_s new_item.date = item.date rescue Time.now new_item.description = item.description rescue item.to_s new_item.link = item.link rescue '#' item = new_item end extract_attribute_from page.root, item end item end data end end end yapra-0.1.2.orig/lib-plugins/yapra/plugin/filter/apply_template.rb0000664000372100037210000000247411042036362023704 0ustar tachtachrequire 'yapra/plugin/base' module Yapra::Plugin::Filter # = Filter::ApplyTemplate -- Yuanying # # apply template and set to attribute. # # example: # # - module: Filter::ApplyTemplate # config: # content_encoded: '
<%= title %>
' # class ApplyTemplate < Yapra::Plugin::Base def run(data) regexp = nil if config['regexp'] regexp = Regexp.new(config['regexp']) else regexp = /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/ end data.map! do |item| url = item if item.respond_to?('link') url = item.link end if regexp =~ url unless(item.instance_of?(RSS::RDF::Item)) new_item = RSS::RDF::Item.new new_item.title = item.title rescue item.to_s new_item.date = item.date rescue Time.now new_item.description = item.description rescue item.to_s new_item.link = item.link rescue '#' item = new_item end if plugin_config plugin_config.each do |k, template| value = apply_template template, binding set_attribute_to item, k, value end end end item end data end end end yapra-0.1.2.orig/script/0002775000372100037210000000000011074776611013527 5ustar tachtachyapra-0.1.2.orig/script/console0000775000372100037210000000066011042036362015102 0ustar tachtach#!/usr/bin/env ruby # File: script/console irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' libs = " -r irb/completion" # Perhaps use a console_lib to store any extra methods I may want available in the cosole # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}" libs << " -r #{File.dirname(__FILE__) + '/../lib/yapra.rb'}" puts "Loading yapra gem" exec "#{irb} #{libs} --simple-prompt"yapra-0.1.2.orig/script/txt2html0000775000372100037210000000415011042036362015224 0ustar tachtach#!/usr/bin/env ruby GEM_NAME = 'yapra' # what ppl will type to install your gem RUBYFORGE_PROJECT = 'yapra' require 'rubygems' begin require 'newgem' require 'rubyforge' rescue LoadError puts "\n\nGenerating the website requires the newgem RubyGem" puts "Install: gem install newgem\n\n" exit(1) end require 'redcloth' require 'syntax/convertors/html' require 'erb' require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb" version = Yapra::VERSION::STRING download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" def rubyforge_project_id RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT] end class Fixnum def ordinal # teens return 'th' if (10..19).include?(self % 100) # others case self % 10 when 1: return 'st' when 2: return 'nd' when 3: return 'rd' else return 'th' end end end class Time def pretty return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}" end end def convert_syntax(syntax, source) return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^
|
$!,'') end if ARGV.length >= 1 src, template = ARGV template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb') else puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html") exit! end template = ERB.new(File.open(template).read) title = nil body = nil File.open(src) do |fsrc| title_text = fsrc.readline body_text_template = fsrc.read body_text = ERB.new(body_text_template).result(binding) syntax_items = [] body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)!m){ ident = syntax_items.length element, syntax, source = $1, $2, $3 syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}" "syntax-temp-#{ident}" } title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip body = RedCloth.new(body_text).to_html body.gsub!(%r!(?:
)?syntax-temp-(\d+)(?:
)?!){ syntax_items[$1.to_i] } end stat = File.stat(src) created = stat.ctime modified = stat.mtime $stdout << template.result(binding) yapra-0.1.2.orig/script/destroy0000775000372100037210000000060311042036362015126 0ustar tachtach#!/usr/bin/env ruby APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) begin require 'rubigen' rescue LoadError require 'rubygems' require 'rubigen' end require 'rubigen/scripts/destroy' ARGV.shift if ['--help', '-h'].include?(ARGV[0]) RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] RubiGen::Scripts::Destroy.new.run(ARGV) yapra-0.1.2.orig/script/generate0000775000372100037210000000060511042036362015231 0ustar tachtach#!/usr/bin/env ruby APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) begin require 'rubigen' rescue LoadError require 'rubygems' require 'rubigen' end require 'rubigen/scripts/generate' ARGV.shift if ['--help', '-h'].include?(ARGV[0]) RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] RubiGen::Scripts::Generate.new.run(ARGV) yapra-0.1.2.orig/PostInstall.txt0000664000372100037210000000000011042036362015207 0ustar tachtachyapra-0.1.2.orig/setup.rb0000664000372100037210000010650211042036362013675 0ustar tachtach# # setup.rb # # Copyright (c) 2000-2005 Minero Aoki # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # unless Enumerable.method_defined?(:map) # Ruby 1.4.6 module Enumerable alias map collect end end unless File.respond_to?(:read) # Ruby 1.6 def File.read(fname) open(fname) {|f| return f.read } end end unless Errno.const_defined?(:ENOTEMPTY) # Windows? module Errno class ENOTEMPTY # We do not raise this exception, implementation is not needed. end end end def File.binread(fname) open(fname, 'rb') {|f| return f.read } end # for corrupted Windows' stat(2) def File.dir?(path) File.directory?((path[-1,1] == '/') ? path : path + '/') end class ConfigTable include Enumerable def initialize(rbconfig) @rbconfig = rbconfig @items = [] @table = {} # options @install_prefix = nil @config_opt = nil @verbose = true @no_harm = false end attr_accessor :install_prefix attr_accessor :config_opt attr_writer :verbose def verbose? @verbose end attr_writer :no_harm def no_harm? @no_harm end def [](key) lookup(key).resolve(self) end def []=(key, val) lookup(key).set val end def names @items.map {|i| i.name } end def each(&block) @items.each(&block) end def key?(name) @table.key?(name) end def lookup(name) @table[name] or setup_rb_error "no such config item: #{name}" end def add(item) @items.push item @table[item.name] = item end def remove(name) item = lookup(name) @items.delete_if {|i| i.name == name } @table.delete_if {|name, i| i.name == name } item end def load_script(path, inst = nil) if File.file?(path) MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path end end def savefile '.config' end def load_savefile begin File.foreach(savefile()) do |line| k, v = *line.split(/=/, 2) self[k] = v.strip end rescue Errno::ENOENT setup_rb_error $!.message + "\n#{File.basename($0)} config first" end end def save @items.each {|i| i.value } File.open(savefile(), 'w') {|f| @items.each do |i| f.printf "%s=%s\n", i.name, i.value if i.value? and i.value end } end def load_standard_entries standard_entries(@rbconfig).each do |ent| add ent end end def standard_entries(rbconfig) c = rbconfig rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) major = c['MAJOR'].to_i minor = c['MINOR'].to_i teeny = c['TEENY'].to_i version = "#{major}.#{minor}" # ruby ver. >= 1.4.4? newpath_p = ((major >= 2) or ((major == 1) and ((minor >= 5) or ((minor == 4) and (teeny >= 4))))) if c['rubylibdir'] # V > 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = c['rubylibdir'] librubyverarch = c['archdir'] siteruby = c['sitedir'] siterubyver = c['sitelibdir'] siterubyverarch = c['sitearchdir'] elsif newpath_p # 1.4.4 <= V <= 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = c['sitedir'] siterubyver = "$siteruby/#{version}" siterubyverarch = "$siterubyver/#{c['arch']}" else # V < 1.4.4 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" siterubyver = siteruby siterubyverarch = "$siterubyver/#{c['arch']}" end parameterize = lambda {|path| path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') } if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } makeprog = arg.sub(/'/, '').split(/=/, 2)[1] else makeprog = 'make' end [ ExecItem.new('installdirs', 'std/site/home', 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ {|val, table| case val when 'std' table['rbdir'] = '$librubyver' table['sodir'] = '$librubyverarch' when 'site' table['rbdir'] = '$siterubyver' table['sodir'] = '$siterubyverarch' when 'home' setup_rb_error '$HOME was not set' unless ENV['HOME'] table['prefix'] = ENV['HOME'] table['rbdir'] = '$libdir/ruby' table['sodir'] = '$libdir/ruby' end }, PathItem.new('prefix', 'path', c['prefix'], 'path prefix of target environment'), PathItem.new('bindir', 'path', parameterize.call(c['bindir']), 'the directory for commands'), PathItem.new('libdir', 'path', parameterize.call(c['libdir']), 'the directory for libraries'), PathItem.new('datadir', 'path', parameterize.call(c['datadir']), 'the directory for shared data'), PathItem.new('mandir', 'path', parameterize.call(c['mandir']), 'the directory for man pages'), PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), 'the directory for system configuration files'), PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), 'the directory for local state data'), PathItem.new('libruby', 'path', libruby, 'the directory for ruby libraries'), PathItem.new('librubyver', 'path', librubyver, 'the directory for standard ruby libraries'), PathItem.new('librubyverarch', 'path', librubyverarch, 'the directory for standard ruby extensions'), PathItem.new('siteruby', 'path', siteruby, 'the directory for version-independent aux ruby libraries'), PathItem.new('siterubyver', 'path', siterubyver, 'the directory for aux ruby libraries'), PathItem.new('siterubyverarch', 'path', siterubyverarch, 'the directory for aux ruby binaries'), PathItem.new('rbdir', 'path', '$siterubyver', 'the directory for ruby scripts'), PathItem.new('sodir', 'path', '$siterubyverarch', 'the directory for ruby extentions'), PathItem.new('rubypath', 'path', rubypath, 'the path to set to #! line'), ProgramItem.new('rubyprog', 'name', rubypath, 'the ruby program using for installation'), ProgramItem.new('makeprog', 'name', makeprog, 'the make program to compile ruby extentions'), SelectItem.new('shebang', 'all/ruby/never', 'ruby', 'shebang line (#!) editing mode'), BoolItem.new('without-ext', 'yes/no', 'no', 'does not compile/install ruby extentions') ] end private :standard_entries def load_multipackage_entries multipackage_entries().each do |ent| add ent end end def multipackage_entries [ PackageSelectionItem.new('with', 'name,name...', '', 'ALL', 'package names that you want to install'), PackageSelectionItem.new('without', 'name,name...', '', 'NONE', 'package names that you do not want to install') ] end private :multipackage_entries ALIASES = { 'std-ruby' => 'librubyver', 'stdruby' => 'librubyver', 'rubylibdir' => 'librubyver', 'archdir' => 'librubyverarch', 'site-ruby-common' => 'siteruby', # For backward compatibility 'site-ruby' => 'siterubyver', # For backward compatibility 'bin-dir' => 'bindir', 'bin-dir' => 'bindir', 'rb-dir' => 'rbdir', 'so-dir' => 'sodir', 'data-dir' => 'datadir', 'ruby-path' => 'rubypath', 'ruby-prog' => 'rubyprog', 'ruby' => 'rubyprog', 'make-prog' => 'makeprog', 'make' => 'makeprog' } def fixup ALIASES.each do |ali, name| @table[ali] = @table[name] end @items.freeze @table.freeze @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ end def parse_opt(opt) m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" m.to_a[1,2] end def dllext @rbconfig['DLEXT'] end def value_config?(name) lookup(name).value? end class Item def initialize(name, template, default, desc) @name = name.freeze @template = template @value = default @default = default @description = desc end attr_reader :name attr_reader :description attr_accessor :default alias help_default default def help_opt "--#{@name}=#{@template}" end def value? true end def value @value end def resolve(table) @value.gsub(%r<\$([^/]+)>) { table[$1] } end def set(val) @value = check(val) end private def check(val) setup_rb_error "config: --#{name} requires argument" unless val val end end class BoolItem < Item def config_type 'bool' end def help_opt "--#{@name}" end private def check(val) return 'yes' unless val case val when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' else setup_rb_error "config: --#{@name} accepts only yes/no for argument" end end end class PathItem < Item def config_type 'path' end private def check(path) setup_rb_error "config: --#{@name} requires argument" unless path path[0,1] == '$' ? path : File.expand_path(path) end end class ProgramItem < Item def config_type 'program' end end class SelectItem < Item def initialize(name, selection, default, desc) super @ok = selection.split('/') end def config_type 'select' end private def check(val) unless @ok.include?(val.strip) setup_rb_error "config: use --#{@name}=#{@template} (#{val})" end val.strip end end class ExecItem < Item def initialize(name, selection, desc, &block) super name, selection, nil, desc @ok = selection.split('/') @action = block end def config_type 'exec' end def value? false end def resolve(table) setup_rb_error "$#{name()} wrongly used as option value" end undef set def evaluate(val, table) v = val.strip.downcase unless @ok.include?(v) setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" end @action.call v, table end end class PackageSelectionItem < Item def initialize(name, template, default, help_default, desc) super name, template, default, desc @help_default = help_default end attr_reader :help_default def config_type 'package' end private def check(val) unless File.dir?("packages/#{val}") setup_rb_error "config: no such package: #{val}" end val end end class MetaConfigEnvironment def initialize(config, installer) @config = config @installer = installer end def config_names @config.names end def config?(name) @config.key?(name) end def bool_config?(name) @config.lookup(name).config_type == 'bool' end def path_config?(name) @config.lookup(name).config_type == 'path' end def value_config?(name) @config.lookup(name).config_type != 'exec' end def add_config(item) @config.add item end def add_bool_config(name, default, desc) @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) end def add_path_config(name, default, desc) @config.add PathItem.new(name, 'path', default, desc) end def set_config_default(name, default) @config.lookup(name).default = default end def remove_config(name) @config.remove(name) end # For only multipackage def packages raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer @installer.packages end # For only multipackage def declare_packages(list) raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer @installer.packages = list end end end # class ConfigTable # This module requires: #verbose?, #no_harm? module FileOperations def mkdir_p(dirname, prefix = nil) dirname = prefix + File.expand_path(dirname) if prefix $stderr.puts "mkdir -p #{dirname}" if verbose? return if no_harm? # Does not check '/', it's too abnormal. dirs = File.expand_path(dirname).split(%r<(?=/)>) if /\A[a-z]:\z/i =~ dirs[0] disk = dirs.shift dirs[0] = disk + dirs[0] end dirs.each_index do |idx| path = dirs[0..idx].join('') Dir.mkdir path unless File.dir?(path) end end def rm_f(path) $stderr.puts "rm -f #{path}" if verbose? return if no_harm? force_remove_file path end def rm_rf(path) $stderr.puts "rm -rf #{path}" if verbose? return if no_harm? remove_tree path end def remove_tree(path) if File.symlink?(path) remove_file path elsif File.dir?(path) remove_tree0 path else force_remove_file path end end def remove_tree0(path) Dir.foreach(path) do |ent| next if ent == '.' next if ent == '..' entpath = "#{path}/#{ent}" if File.symlink?(entpath) remove_file entpath elsif File.dir?(entpath) remove_tree0 entpath else force_remove_file entpath end end begin Dir.rmdir path rescue Errno::ENOTEMPTY # directory may not be empty end end def move_file(src, dest) force_remove_file dest begin File.rename src, dest rescue File.open(dest, 'wb') {|f| f.write File.binread(src) } File.chmod File.stat(src).mode, dest File.unlink src end end def force_remove_file(path) begin remove_file path rescue end end def remove_file(path) File.chmod 0777, path File.unlink path end def install(from, dest, mode, prefix = nil) $stderr.puts "install #{from} #{dest}" if verbose? return if no_harm? realdest = prefix ? prefix + File.expand_path(dest) : dest realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) str = File.binread(from) if diff?(str, realdest) verbose_off { rm_f realdest if File.exist?(realdest) } File.open(realdest, 'wb') {|f| f.write str } File.chmod mode, realdest File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| if prefix f.puts realdest.sub(prefix, '') else f.puts realdest end } end end def diff?(new_content, path) return true unless File.exist?(path) new_content != File.binread(path) end def command(*args) $stderr.puts args.join(' ') if verbose? system(*args) or raise RuntimeError, "system(#{args.map{|a| a.inspect }.join(' ')}) failed" end def ruby(*args) command config('rubyprog'), *args end def make(task = nil) command(*[config('makeprog'), task].compact) end def extdir?(dir) File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") end def files_of(dir) Dir.open(dir) {|d| return d.select {|ent| File.file?("#{dir}/#{ent}") } } end DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) def directories_of(dir) Dir.open(dir) {|d| return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT } end end # This module requires: #srcdir_root, #objdir_root, #relpath module HookScriptAPI def get_config(key) @config[key] end alias config get_config # obsolete: use metaconfig to change configuration def set_config(key, val) @config[key] = val end # # srcdir/objdir (works only in the package directory) # def curr_srcdir "#{srcdir_root()}/#{relpath()}" end def curr_objdir "#{objdir_root()}/#{relpath()}" end def srcfile(path) "#{curr_srcdir()}/#{path}" end def srcexist?(path) File.exist?(srcfile(path)) end def srcdirectory?(path) File.dir?(srcfile(path)) end def srcfile?(path) File.file?(srcfile(path)) end def srcentries(path = '.') Dir.open("#{curr_srcdir()}/#{path}") {|d| return d.to_a - %w(. ..) } end def srcfiles(path = '.') srcentries(path).select {|fname| File.file?(File.join(curr_srcdir(), path, fname)) } end def srcdirectories(path = '.') srcentries(path).select {|fname| File.dir?(File.join(curr_srcdir(), path, fname)) } end end class ToplevelInstaller Version = '3.4.1' Copyright = 'Copyright (c) 2000-2005 Minero Aoki' TASKS = [ [ 'all', 'do config, setup, then install' ], [ 'config', 'saves your configurations' ], [ 'show', 'shows current configuration' ], [ 'setup', 'compiles ruby extentions and others' ], [ 'install', 'installs files' ], [ 'test', 'run all tests in test/' ], [ 'clean', "does `make clean' for each extention" ], [ 'distclean',"does `make distclean' for each extention" ] ] def ToplevelInstaller.invoke config = ConfigTable.new(load_rbconfig()) config.load_standard_entries config.load_multipackage_entries if multipackage? config.fixup klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) klass.new(File.dirname($0), config).invoke end def ToplevelInstaller.multipackage? File.dir?(File.dirname($0) + '/packages') end def ToplevelInstaller.load_rbconfig if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } ARGV.delete(arg) load File.expand_path(arg.split(/=/, 2)[1]) $".push 'rbconfig.rb' else require 'rbconfig' end ::Config::CONFIG end def initialize(ardir_root, config) @ardir = File.expand_path(ardir_root) @config = config # cache @valid_task_re = nil end def config(key) @config[key] end def inspect "#<#{self.class} #{__id__()}>" end def invoke run_metaconfigs case task = parsearg_global() when nil, 'all' parsearg_config init_installers exec_config exec_setup exec_install else case task when 'config', 'test' ; when 'clean', 'distclean' @config.load_savefile if File.exist?(@config.savefile) else @config.load_savefile end __send__ "parsearg_#{task}" init_installers __send__ "exec_#{task}" end end def run_metaconfigs @config.load_script "#{@ardir}/metaconfig" end def init_installers @installer = Installer.new(@config, @ardir, File.expand_path('.')) end # # Hook Script API bases # def srcdir_root @ardir end def objdir_root '.' end def relpath '.' end # # Option Parsing # def parsearg_global while arg = ARGV.shift case arg when /\A\w+\z/ setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) return arg when '-q', '--quiet' @config.verbose = false when '--verbose' @config.verbose = true when '--help' print_usage $stdout exit 0 when '--version' puts "#{File.basename($0)} version #{Version}" exit 0 when '--copyright' puts Copyright exit 0 else setup_rb_error "unknown global option '#{arg}'" end end nil end def valid_task?(t) valid_task_re() =~ t end def valid_task_re @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ end def parsearg_no_options unless ARGV.empty? task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" end end alias parsearg_show parsearg_no_options alias parsearg_setup parsearg_no_options alias parsearg_test parsearg_no_options alias parsearg_clean parsearg_no_options alias parsearg_distclean parsearg_no_options def parsearg_config evalopt = [] set = [] @config.config_opt = [] while i = ARGV.shift if /\A--?\z/ =~ i @config.config_opt = ARGV.dup break end name, value = *@config.parse_opt(i) if @config.value_config?(name) @config[name] = value else evalopt.push [name, value] end set.push name end evalopt.each do |name, value| @config.lookup(name).evaluate value, @config end # Check if configuration is valid set.each do |n| @config[n] if @config.value_config?(n) end end def parsearg_install @config.no_harm = false @config.install_prefix = '' while a = ARGV.shift case a when '--no-harm' @config.no_harm = true when /\A--prefix=/ path = a.split(/=/, 2)[1] path = File.expand_path(path) unless path[0,1] == '/' @config.install_prefix = path else setup_rb_error "install: unknown option #{a}" end end end def print_usage(out) out.puts 'Typical Installation Procedure:' out.puts " $ ruby #{File.basename $0} config" out.puts " $ ruby #{File.basename $0} setup" out.puts " # ruby #{File.basename $0} install (may require root privilege)" out.puts out.puts 'Detailed Usage:' out.puts " ruby #{File.basename $0} " out.puts " ruby #{File.basename $0} [] []" fmt = " %-24s %s\n" out.puts out.puts 'Global options:' out.printf fmt, '-q,--quiet', 'suppress message outputs' out.printf fmt, ' --verbose', 'output messages verbosely' out.printf fmt, ' --help', 'print this message' out.printf fmt, ' --version', 'print version and quit' out.printf fmt, ' --copyright', 'print copyright and quit' out.puts out.puts 'Tasks:' TASKS.each do |name, desc| out.printf fmt, name, desc end fmt = " %-24s %s [%s]\n" out.puts out.puts 'Options for CONFIG or ALL:' @config.each do |item| out.printf fmt, item.help_opt, item.description, item.help_default end out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" out.puts out.puts 'Options for INSTALL:' out.printf fmt, '--no-harm', 'only display what to do if given', 'off' out.printf fmt, '--prefix=path', 'install path prefix', '' out.puts end # # Task Handlers # def exec_config @installer.exec_config @config.save # must be final end def exec_setup @installer.exec_setup end def exec_install @installer.exec_install end def exec_test @installer.exec_test end def exec_show @config.each do |i| printf "%-20s %s\n", i.name, i.value if i.value? end end def exec_clean @installer.exec_clean end def exec_distclean @installer.exec_distclean end end # class ToplevelInstaller class ToplevelInstallerMulti < ToplevelInstaller include FileOperations def initialize(ardir_root, config) super @packages = directories_of("#{@ardir}/packages") raise 'no package exists' if @packages.empty? @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) end def run_metaconfigs @config.load_script "#{@ardir}/metaconfig", self @packages.each do |name| @config.load_script "#{@ardir}/packages/#{name}/metaconfig" end end attr_reader :packages def packages=(list) raise 'package list is empty' if list.empty? list.each do |name| raise "directory packages/#{name} does not exist"\ unless File.dir?("#{@ardir}/packages/#{name}") end @packages = list end def init_installers @installers = {} @packages.each do |pack| @installers[pack] = Installer.new(@config, "#{@ardir}/packages/#{pack}", "packages/#{pack}") end with = extract_selection(config('with')) without = extract_selection(config('without')) @selected = @installers.keys.select {|name| (with.empty? or with.include?(name)) \ and not without.include?(name) } end def extract_selection(list) a = list.split(/,/) a.each do |name| setup_rb_error "no such package: #{name}" unless @installers.key?(name) end a end def print_usage(f) super f.puts 'Inluded packages:' f.puts ' ' + @packages.sort.join(' ') f.puts end # # Task Handlers # def exec_config run_hook 'pre-config' each_selected_installers {|inst| inst.exec_config } run_hook 'post-config' @config.save # must be final end def exec_setup run_hook 'pre-setup' each_selected_installers {|inst| inst.exec_setup } run_hook 'post-setup' end def exec_install run_hook 'pre-install' each_selected_installers {|inst| inst.exec_install } run_hook 'post-install' end def exec_test run_hook 'pre-test' each_selected_installers {|inst| inst.exec_test } run_hook 'post-test' end def exec_clean rm_f @config.savefile run_hook 'pre-clean' each_selected_installers {|inst| inst.exec_clean } run_hook 'post-clean' end def exec_distclean rm_f @config.savefile run_hook 'pre-distclean' each_selected_installers {|inst| inst.exec_distclean } run_hook 'post-distclean' end # # lib # def each_selected_installers Dir.mkdir 'packages' unless File.dir?('packages') @selected.each do |pack| $stderr.puts "Processing the package `#{pack}' ..." if verbose? Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") Dir.chdir "packages/#{pack}" yield @installers[pack] Dir.chdir '../..' end end def run_hook(id) @root_installer.run_hook id end # module FileOperations requires this def verbose? @config.verbose? end # module FileOperations requires this def no_harm? @config.no_harm? end end # class ToplevelInstallerMulti class Installer FILETYPES = %w( bin lib ext data conf man ) include FileOperations include HookScriptAPI def initialize(config, srcroot, objroot) @config = config @srcdir = File.expand_path(srcroot) @objdir = File.expand_path(objroot) @currdir = '.' end def inspect "#<#{self.class} #{File.basename(@srcdir)}>" end def noop(rel) end # # Hook Script API base methods # def srcdir_root @srcdir end def objdir_root @objdir end def relpath @currdir end # # Config Access # # module FileOperations requires this def verbose? @config.verbose? end # module FileOperations requires this def no_harm? @config.no_harm? end def verbose_off begin save, @config.verbose = @config.verbose?, false yield ensure @config.verbose = save end end # # TASK config # def exec_config exec_task_traverse 'config' end alias config_dir_bin noop alias config_dir_lib noop def config_dir_ext(rel) extconf if extdir?(curr_srcdir()) end alias config_dir_data noop alias config_dir_conf noop alias config_dir_man noop def extconf ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt end # # TASK setup # def exec_setup exec_task_traverse 'setup' end def setup_dir_bin(rel) files_of(curr_srcdir()).each do |fname| update_shebang_line "#{curr_srcdir()}/#{fname}" end end alias setup_dir_lib noop def setup_dir_ext(rel) make if extdir?(curr_srcdir()) end alias setup_dir_data noop alias setup_dir_conf noop alias setup_dir_man noop def update_shebang_line(path) return if no_harm? return if config('shebang') == 'never' old = Shebang.load(path) if old $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 new = new_shebang(old) return if new.to_s == old.to_s else return unless config('shebang') == 'all' new = Shebang.new(config('rubypath')) end $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? open_atomic_writer(path) {|output| File.open(path, 'rb') {|f| f.gets if old # discard output.puts new.to_s output.print f.read } } end def new_shebang(old) if /\Aruby/ =~ File.basename(old.cmd) Shebang.new(config('rubypath'), old.args) elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' Shebang.new(config('rubypath'), old.args[1..-1]) else return old unless config('shebang') == 'all' Shebang.new(config('rubypath')) end end def open_atomic_writer(path, &block) tmpfile = File.basename(path) + '.tmp' begin File.open(tmpfile, 'wb', &block) File.rename tmpfile, File.basename(path) ensure File.unlink tmpfile if File.exist?(tmpfile) end end class Shebang def Shebang.load(path) line = nil File.open(path) {|f| line = f.gets } return nil unless /\A#!/ =~ line parse(line) end def Shebang.parse(line) cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') new(cmd, args) end def initialize(cmd, args = []) @cmd = cmd @args = args end attr_reader :cmd attr_reader :args def to_s "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") end end # # TASK install # def exec_install rm_f 'InstalledFiles' exec_task_traverse 'install' end def install_dir_bin(rel) install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 end def install_dir_lib(rel) install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 end def install_dir_ext(rel) return unless extdir?(curr_srcdir()) install_files rubyextentions('.'), "#{config('sodir')}/#{File.dirname(rel)}", 0555 end def install_dir_data(rel) install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 end def install_dir_conf(rel) # FIXME: should not remove current config files # (rename previous file to .old/.org) install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 end def install_dir_man(rel) install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 end def install_files(list, dest, mode) mkdir_p dest, @config.install_prefix list.each do |fname| install fname, dest, mode, @config.install_prefix end end def libfiles glob_reject(%w(*.y *.output), targetfiles()) end def rubyextentions(dir) ents = glob_select("*.#{@config.dllext}", targetfiles()) if ents.empty? setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" end ents end def targetfiles mapdir(existfiles() - hookfiles()) end def mapdir(ents) ents.map {|ent| if File.exist?(ent) then ent # objdir else "#{curr_srcdir()}/#{ent}" # srcdir end } end # picked up many entries from cvs-1.11.1/src/ignore.c JUNK_FILES = %w( core RCSLOG tags TAGS .make.state .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb *~ *.old *.bak *.BAK *.orig *.rej _$* *$ *.org *.in .* ) def existfiles glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) end def hookfiles %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| %w( config setup install clean ).map {|t| sprintf(fmt, t) } }.flatten end def glob_select(pat, ents) re = globs2re([pat]) ents.select {|ent| re =~ ent } end def glob_reject(pats, ents) re = globs2re(pats) ents.reject {|ent| re =~ ent } end GLOB2REGEX = { '.' => '\.', '$' => '\$', '#' => '\#', '*' => '.*' } def globs2re(pats) /\A(?:#{ pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') })\z/ end # # TASK test # TESTDIR = 'test' def exec_test unless File.directory?('test') $stderr.puts 'no test in this package' if verbose? return end $stderr.puts 'Running tests...' if verbose? begin require 'test/unit' rescue LoadError setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' end runner = Test::Unit::AutoRunner.new(true) runner.to_run << TESTDIR runner.run end # # TASK clean # def exec_clean exec_task_traverse 'clean' rm_f @config.savefile rm_f 'InstalledFiles' end alias clean_dir_bin noop alias clean_dir_lib noop alias clean_dir_data noop alias clean_dir_conf noop alias clean_dir_man noop def clean_dir_ext(rel) return unless extdir?(curr_srcdir()) make 'clean' if File.file?('Makefile') end # # TASK distclean # def exec_distclean exec_task_traverse 'distclean' rm_f @config.savefile rm_f 'InstalledFiles' end alias distclean_dir_bin noop alias distclean_dir_lib noop def distclean_dir_ext(rel) return unless extdir?(curr_srcdir()) make 'distclean' if File.file?('Makefile') end alias distclean_dir_data noop alias distclean_dir_conf noop alias distclean_dir_man noop # # Traversing # def exec_task_traverse(task) run_hook "pre-#{task}" FILETYPES.each do |type| if type == 'ext' and config('without-ext') == 'yes' $stderr.puts 'skipping ext/* by user option' if verbose? next end traverse task, type, "#{task}_dir_#{type}" end run_hook "post-#{task}" end def traverse(task, rel, mid) dive_into(rel) { run_hook "pre-#{task}" __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') directories_of(curr_srcdir()).each do |d| traverse task, "#{rel}/#{d}", mid end run_hook "post-#{task}" } end def dive_into(rel) return unless File.dir?("#{@srcdir}/#{rel}") dir = File.basename(rel) Dir.mkdir dir unless File.dir?(dir) prevdir = Dir.pwd Dir.chdir dir $stderr.puts '---> ' + rel if verbose? @currdir = rel yield Dir.chdir prevdir $stderr.puts '<--- ' + rel if verbose? @currdir = File.dirname(rel) end def run_hook(id) path = [ "#{curr_srcdir()}/#{id}", "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } return unless path begin instance_eval File.read(path), path, 1 rescue raise if $DEBUG setup_rb_error "hook #{path} failed:\n" + $!.message end end end # class Installer class SetupError < StandardError; end def setup_rb_error(msg) raise SetupError, msg end if $0 == __FILE__ begin ToplevelInstaller.invoke rescue SetupError raise if $DEBUG $stderr.puts $!.message $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." exit 1 end end yapra-0.1.2.orig/website/0002775000372100037210000000000011074776611013665 5ustar tachtachyapra-0.1.2.orig/website/stylesheets/0002775000372100037210000000000011074776611016241 5ustar tachtachyapra-0.1.2.orig/website/stylesheets/screen.css0000664000372100037210000000434411042036362020220 0ustar tachtachbody { background-color: #E1D1F1; font-family: "Georgia", sans-serif; font-size: 16px; line-height: 1.6em; padding: 1.6em 0 0 0; color: #333; } h1, h2, h3, h4, h5, h6 { color: #444; } h1 { font-family: sans-serif; font-weight: normal; font-size: 4em; line-height: 0.8em; letter-spacing: -0.1ex; margin: 5px; } li { padding: 0; margin: 0; list-style-type: square; } a { color: #5E5AFF; background-color: #DAC; font-weight: normal; text-decoration: underline; } blockquote { font-size: 90%; font-style: italic; border-left: 1px solid #111; padding-left: 1em; } .caps { font-size: 80%; } #main { width: 45em; padding: 0; margin: 0 auto; } .coda { text-align: right; color: #77f; font-size: smaller; } table { font-size: 90%; line-height: 1.4em; color: #ff8; background-color: #111; padding: 2px 10px 2px 10px; border-style: dashed; } th { color: #fff; } td { padding: 2px 10px 2px 10px; } .success { color: #0CC52B; } .failed { color: #E90A1B; } .unknown { color: #995000; } pre, code { font-family: monospace; font-size: 90%; line-height: 1.4em; color: #ff8; background-color: #111; padding: 2px 10px 2px 10px; } .comment { color: #aaa; font-style: italic; } .keyword { color: #eff; font-weight: bold; } .punct { color: #eee; font-weight: bold; } .symbol { color: #0bb; } .string { color: #6b4; } .ident { color: #ff8; } .constant { color: #66f; } .regex { color: #ec6; } .number { color: #F99; } .expr { color: #227; } #version { float: right; text-align: right; font-family: sans-serif; font-weight: normal; background-color: #B3ABFF; color: #141331; padding: 15px 20px 10px 20px; margin: 0 auto; margin-top: 15px; border: 3px solid #141331; } #version .numbers { display: block; font-size: 4em; line-height: 0.8em; letter-spacing: -0.1ex; margin-bottom: 15px; } #version p { text-decoration: none; color: #141331; background-color: #B3ABFF; margin: 0; padding: 0; } #version a { text-decoration: none; color: #141331; background-color: #B3ABFF; } .clickable { cursor: pointer; cursor: hand; } yapra-0.1.2.orig/website/template.html.erb0000664000372100037210000000274011042036362017121 0ustar tachtach <%= title %>

<%= title %>

Get Version

<%= version %>
<%= body %>

Yuanying Ohtsuka, <%= modified.pretty %>
Theme extended from Paul Battley

yapra-0.1.2.orig/website/javascripts/0002775000372100037210000000000011074776611016216 5ustar tachtachyapra-0.1.2.orig/website/javascripts/rounded_corners_lite.inc.js0000664000372100037210000006077211042036362023531 0ustar tachtach /**************************************************************** * * * curvyCorners * * ------------ * * * * This script generates rounded corners for your divs. * * * * Version 1.2.9 * * Copyright (c) 2006 Cameron Cooke * * By: Cameron Cooke and Tim Hutchison. * * * * * * Website: http://www.curvycorners.net * * Email: info@totalinfinity.com * * Forum: http://www.curvycorners.net/forum/ * * * * * * This library is free software; you can redistribute * * it and/or modify it under the terms of the GNU * * Lesser General Public License as published by the * * Free Software Foundation; either version 2.1 of the * * License, or (at your option) any later version. * * * * This library is distributed in the hope that it will * * be useful, but WITHOUT ANY WARRANTY; without even the * * implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU Lesser General Public * * License for more details. * * * * You should have received a copy of the GNU Lesser * * General Public License along with this library; * * Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * * * ****************************************************************/ var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners() { if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string") { var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);} else { var startIndex = 1; var boxCol = arguments;} var curvyCornersCol = new Array(); if(arguments[0].validTags) var validElements = arguments[0].validTags; else var validElements = ["div"]; for(var i = startIndex, j = boxCol.length; i < j; i++) { var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false) { curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);} } this.objects = curvyCornersCol; this.applyCornersToAll = function() { for(var x = 0, k = this.objects.length; x < k; x++) { this.objects[x].applyCorners();} } } function curvyObject() { this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0) this.box.innerHTML = ""; this.applyCorners = function() { for(var t = 0; t < 2; t++) { switch(t) { case 0: if(this.settings.tl || this.settings.tr) { var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);} break; case 1: if(this.settings.bl || this.settings.br) { var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);} break;} } if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners) { if(i > -1 < 4) { var cc = corners[i]; if(!this.settings[cc]) { if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) { var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "") newCorner.style.backgroundColor = this.boxColour; else newCorner.style.backgroundImage = this.backgroundImage; switch(cc) { case "tl": newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr": newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl": newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br": newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px" newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;} } } else { if(this.masterCorners[this.settings[cc].radius]) { var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);} else { var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) { if((intx +1) >= borderRadius) var y1 = -1; else var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j) { if((intx) >= borderRadius) var y2 = -1; else var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j) var y3 = -1; else var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);} if((intx) >= j) var y4 = -1; else var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j) { for(var inty = (y1 + 1); inty < y2; inty++) { if(this.settings.antiAlias) { if(this.backgroundImage != "") { var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30) { this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);} else { this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);} } else { var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);} } } if(this.settings.antiAlias) { if(y3 >= y2) { if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);} } else { if(y3 >= y1) { this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);} } var outsideColour = this.borderColour;} else { var outsideColour = this.boxColour; var y3 = y1;} if(this.settings.antiAlias) { for(var inty = (y3 + 1); inty < y4; inty++) { this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);} } } this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);} if(cc != "br") { for(var t = 0, k = newCorner.childNodes.length; t < k; t++) { var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";} if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";} switch(cc) { case "tr": pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl": pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl": pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;} } } } if(newCorner) { switch(cc) { case "tl": if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr": if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl": if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br": if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;} } } } var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff) { if(z == "t" || z == "b") { if(radiusDiff[z]) { var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px" newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType) { case "tl": newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr": newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl": newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br": newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;} } var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z) { case "t": if(this.topContainer) { if(this.settings.tl.radius && this.settings.tr.radius) { newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "") newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);} this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";} break; case "b": if(this.bottomContainer) { if(this.settings.bl.radius && this.settings.br.radius) { newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "") newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);} } break;} } } if(this.settings.autoPad == true && this.boxPadding > 0) { var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding) contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding) contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);} } this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) { var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "") { pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";} else { pixel.style.backgroundColor = colour;} if (transAmount != 100) setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);} } function insertAfter(parent, node, referenceNode) { parent.insertBefore(node, referenceNode.nextSibling);} function BlendColour(Col1, Col2, Col1Fraction) { var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);} function IntToHex(strNum) { base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;} function MakeHex(x) { if((x >= 0) && (x <= 9)) { return x;} else { switch(x) { case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";} } } function pixelFraction(x, y, r) { var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1))) { whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;} var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1))) { whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;} var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1))) { whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;} var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1))) { whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;} switch (whatsides) { case "LeftRight": pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight": pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom": pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom": pixelfraction = (yvalues[0]*xvalues[1])/2; break; default: pixelfraction = 1;} return pixelfraction;} function rgb2Hex(rgbColour) { try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);} catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");} return hexColour;} function rgb2Array(rgbColour) { var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;} function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME") { var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";} else if(typeof(obj.style.opacity) != "undefined") { obj.style.opacity = opacity/100;} else if(typeof(obj.style.MozOpacity) != "undefined") { obj.style.MozOpacity = opacity/100;} else if(typeof(obj.style.filter) != "undefined") { obj.style.filter = "alpha(opacity:" + opacity + ")";} else if(typeof(obj.style.KHTMLOpacity) != "undefined") { obj.style.KHTMLOpacity = opacity/100;} } function inArray(array, value) { for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;} return false;} function inArrayKey(array, value) { for(key in array){ if(key === value) return true;} return false;} function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;} else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;} else { elm['on' + evType] = fn;} } function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");} } function format_colour(colour) { var returnColour = "#ffffff"; if(colour != "" && colour != "transparent") { if(colour.substr(0, 3) == "rgb") { returnColour = rgb2Hex(colour);} else if(colour.length == 4) { returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);} else { returnColour = colour;} } return returnColour;} function get_style(obj, property, propertyNS) { try { if(obj.currentStyle) { var returnVal = eval("obj.currentStyle." + property);} else { if(isSafari && obj.style.display == "none") { obj.style.display = ""; var wasHidden = true;} var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden) { obj.style.display = "none";} } } catch(e) { } return returnVal;} function getElementsByClass(searchClass, node, tag) { var classElements = new Array(); if(node == null) node = document; if(tag == null) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if(pattern.test(els[i].className)) { classElements[j] = els[i]; j++;} } return classElements;} function newCurvyError(errorMessage) { return new Error("curvyCorners Error:\n" + errorMessage) } yapra-0.1.2.orig/website/index.txt0000664000372100037210000000206111042036362015515 0ustar tachtachh1. yapra h1. → 'yapra' h2. What Yet Another "Pragger":http://pragger.ikejisoft.com/ implementation. h2. Installing
sudo gem install yapra
h2. The basics h2. Demonstration of usage h3. Use on command
yapra -c config_file.yml
This command looks like "Pragger":http://pragger.ikejisoft.com/ h3. Use in your application
require 'yapra/runtime'
require 'yapra/config'

config = YAML.load(config_file)
config = Yapra::Config.new(config)

Yapra::Runtime.logger = Logger.new(STDOUT)

yapra = Yapra::Runtime.new(config.env)
yapra.execute(config.pipeline_commands)
h2. Forum "http://www.fraction.jp/trac/rana2/wiki/Yapra":http://www.fraction.jp/trac/rana2/wiki/Yapra h2. Build and test instructions
cd yapra
rake spec
rake install_gem
h2. License This code is free to use under the terms of the MIT license. h2. Contact Comments are welcome. Send an email to "Yuanying":mailto:yuanyin-at-fraction-dot-jp email via the "forum":http://groups.google.com/group/yapra yapra-0.1.2.orig/plugins/0002775000372100037210000000000011074776611013704 5ustar tachtachyapra-0.1.2.orig/plugins/Filter/0002775000372100037210000000000011220146245015114 5ustar tachtachyapra-0.1.2.orig/plugins/Filter/deduped.rb0000664000372100037210000000230711073530171017054 0ustar tachtach## Filter::deduped - Plugin to get Deduped entries -- emergent ## ## Plugin to get Deduped entries ## Cache path can be set. ## ## - module: Filter::deduped ## config: ## path: /tmp/cache/hoge ## require 'pathname' require 'digest/md5' def mkdir_p path begin Dir.mkdir(path) rescue Errno::ENOENT mkdir_p Pathname.new(path).parent retry rescue Errno::EACCES raise end 0 end def deduped config, data cacheroot = Pathname(__FILE__).parent.parent.parent.realpath + 'cache' cachepath = Pathname.new(config['path']) || cacheroot if cachepath.relative? cachepath = cacheroot + cachepath end #puts 'cache path: ' + cachepath if !File.exists?(cachepath) begin mkdir_p cachepath rescue STDERR.puts "could'nt make cache directory" return data end end attribute = config['attribute'] deduped_data = data.select {|d| v = d.link rescue d.to_s if attribute && d.respond_to?(attribute) v = d.__send__(attribute).to_s end hashpath = cachepath.to_s + '/' + Digest::MD5.hexdigest(v) if File.exists?(hashpath) false else File.open(hashpath, "wb").write(v) rescue false end } return deduped_data end yapra-0.1.2.orig/plugins/Filter/sort.rb0000664000372100037210000000130611042036362016426 0ustar tachtachdef create_compare_proc config if(config==nil || config["method"] == nil) return lambda do |a, b| a <=> b end elsif config["method"].kind_of?(Hash) return lambda do |a, b| eval_pragger(config["method"],[a])[0] <=> eval_pragger(config["method"],[b])[0] end else return lambda do |a, b| method = config['method'] a = a.respond_to?(method) ? a.__send__(method) : nil b = b.respond_to?(method) ? b.__send__(method) : nil return a <=> b if a.respond_to?('<=>') return b <=> a if b.respond_to?('<=>') nil end end end def sort(config,data) proc = create_compare_proc(config) return data.sort do|a, b| proc.call(a, b) end end yapra-0.1.2.orig/plugins/Filter/subs.rb0000664000372100037210000000056711042036362016423 0ustar tachtachdef subs(config,data) reg = Regexp.new(config["regex"]) to = config["to"] attribute = config['attribute'] data.map! do |i| if attribute if i.respond_to?(attribute) && i.respond_to?("#{attribute}=") i.__send__("#{attribute}=", i.__send__("#{attribute}").gsub(reg, to)) end else i = i.gsub(reg,to) end i end return data endyapra-0.1.2.orig/plugins/Filter/grep.rb0000664000372100037210000000115011042036362016371 0ustar tachtach## Filter input by given regular expression -- IKeJI ## ## Filter input by given regular expression. ## The test will be done with the result of to_s method of the input. ## invert option will invert results(-v option of UNIX grep command). ## ## - module: grep ## config: ## regex: "[あ-ん]" ## invert: false def grep(config,data) regex = Regexp.new(config["regex"]) invert = config["invert"] || false attribute = config['attribute'] data.select do |i| if attribute invert ^ (regex =~ i.__send__(attribute).to_s) else invert ^ (regex =~ i.to_s) end end end yapra-0.1.2.orig/History.txt0000664000372100037210000000075611073555646014435 0ustar tachtach== 0.1.2 * 1 bug fix: * rss 1.0 format bug is fixed. (RSS::save) * 2 majar enhancement: * Error handling of plugin is added. * Plugin load error has more detailed informations. == 0.1.1 * 1 bug fix: * Publish::Imap, mailbox select fixed. * Spec files are added. * 2 majar enhancement: * A few plugins are added. * RDoc is improved. * -d option is added. * Source code management is migrated to github.com. == 0.1.0 2008-06-20 * 1 major enhancement: * Initial release