yapra 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ require 'cgi'
13
13
 
14
14
  def nicovideo(config,data)
15
15
  auth = YAML.load( File.read( config['authfile'] ) )
16
- agent = WWW::Mechanize.new
16
+ agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
17
17
 
18
18
  page = agent.post("https://secure.nicovideo.jp/secure/login?site=niconico",
19
19
  {"mail"=>auth["mail"],"password"=>auth["password"]})
@@ -11,19 +11,19 @@ def yahoo(config, data)
11
11
  config = (config || { "translation" => "en=>ja" })
12
12
 
13
13
  trans = case config["translation"]
14
- when "en=>ja": "EJ"
15
- when "kr=>ja": "KJ"
16
- when "cn=>ja": "CJ"
17
- when "ja=>en": "JE"
18
- when "ja=>kr": "JK"
19
- when "ja=>cn": "JC"
14
+ when "en=>ja" then "EJ"
15
+ when "kr=>ja" then "KJ"
16
+ when "cn=>ja" then "CJ"
17
+ when "ja=>en" then "JE"
18
+ when "ja=>kr" then "JK"
19
+ when "ja=>cn" then "JC"
20
20
  else
21
21
  return data
22
22
  end
23
23
 
24
24
  data.collect {|d|
25
25
  if d && d =~ /\S/
26
- agent = WWW::Mechanize.new
26
+ agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
27
27
  start = agent.get("http://honyaku.yahoo.co.jp/")
28
28
  form = start.forms.last
29
29
 
@@ -16,7 +16,7 @@ class Delicious
16
16
  def initialize username, password, proxy=nil
17
17
  @username = username
18
18
  @password = password
19
- @agent = WWW::Mechanize.new
19
+ @agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
20
20
  @agent.basic_auth(@username, @password)
21
21
  if proxy && proxy.is_a?(Hash) && proxy['proxy_addr'] && proxy['proxy_port']
22
22
  @agent.set_proxy(proxy['proxy_addr'], proxy['proxy_port'],
@@ -13,7 +13,7 @@ class HatenaDiaryWriter
13
13
  def initialize(id,password)
14
14
  @id = id
15
15
  @password = password
16
- @agent = WWW::Mechanize.new
16
+ @agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
17
17
  if proxy = ENV['HTTP_PROXY']
18
18
  proxy = URI.parse(proxy)
19
19
  @agent.set_proxy(proxy.host, proxy.port)
@@ -31,7 +31,7 @@ class MixiDiaryWriter
31
31
  @id = nil
32
32
  @username = username
33
33
  @password = password
34
- @agent = WWW::Mechanize.new
34
+ @agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
35
35
  end
36
36
 
37
37
  def login username=@username, password=@password
@@ -19,7 +19,7 @@ class Scuttle
19
19
  @post_url = url + 'api/posts/add?'
20
20
  @username = username
21
21
  @password = password
22
- @agent = WWW::Mechanize.new
22
+ @agent = defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new
23
23
  @agent.basic_auth(@username, @password)
24
24
  if proxy && proxy.is_a?(Hash) && proxy['proxy_addr'] && proxy['proxy_port']
25
25
  @agent.set_proxy(proxy['proxy_addr'], proxy['proxy_port'],
@@ -79,8 +79,8 @@ end
79
79
  def input_option(config)
80
80
  opt = config.has_key?("input") ? config["input"] : "nothing"
81
81
  case opt
82
- when "feed": :feed
83
- when "nothing": :nothing
82
+ when "feed" then :feed
83
+ when "nothing" then :nothing
84
84
  else
85
85
  :nothing
86
86
  end
@@ -10,7 +10,7 @@ class Yapra::LegacyPlugin::Base
10
10
  def initialize(pipeline, plugin_path)
11
11
  @_yapra_pipeline = pipeline
12
12
  @_yapra_run_method = File.basename(plugin_path, '.*')
13
- instance_eval( @source = File.read(plugin_path).toutf8, plugin_path, 1)
13
+ instance_eval( @source = File.read(plugin_path).toutf8, plugin_path.to_s, 1)
14
14
  end
15
15
 
16
16
  def logger
@@ -4,7 +4,7 @@ require 'yapra/plugin/base'
4
4
 
5
5
  class Yapra::Plugin::MechanizeBase < Yapra::Plugin::Base
6
6
  def agent
7
- pipeline.context['mechanize_agent'] ||= WWW::Mechanize.new
7
+ pipeline.context['mechanize_agent'] ||= (defined?(Mechanize) ? Mechanize.new : WWW::Mechanize.new)
8
8
  pipeline.context['mechanize_agent']
9
9
  end
10
10
 
data/lib/yapra/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Yapra
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 3
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -61,15 +61,16 @@ module Yapra::Plugin::Publish
61
61
  end
62
62
 
63
63
  def create_attachments item, config
64
+ mechanize_file_type = defined?(Mechanize) ? Mechanize::File : WWW::Mechanize::File
64
65
  attachments = []
65
66
  attachment_attributes = config['mail']['attachments']
66
67
  if attachment_attributes.kind_of?(String)
67
68
  file = item.__send__(attachment_attributes)
68
- attachments << file if file.kind_of?(WWW::Mechanize::File)
69
+ attachments << file if file.kind_of?(mechanize_file_type)
69
70
  elsif attachment_attributes.kind_of?(Array)
70
71
  attachment_attributes.each do |atc|
71
72
  file = item.__send__(atc)
72
- attachments << file if file.kind_of?(WWW::Mechanize::File)
73
+ attachments << file if file.kind_of?(mechanize_file_type)
73
74
  end
74
75
  end
75
76
  attachments
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yapra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - yuanying
@@ -9,19 +15,25 @@ autorequire: ""
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-04 00:00:00 +09:00
18
+ date: 2011-02-09 00:00:00 +09:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: mechanize
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 6
23
34
  version: 0.7.6
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  description: Yet another pragger implementation.
26
38
  email: yuanying at fraction dot jp
27
39
  executables:
@@ -169,21 +181,27 @@ require_paths:
169
181
  - lib
170
182
  - lib-plugins
171
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
+ none: false
172
185
  requirements:
173
186
  - - ">="
174
187
  - !ruby/object:Gem::Version
188
+ hash: 3
189
+ segments:
190
+ - 0
175
191
  version: "0"
176
- version:
177
192
  required_rubygems_version: !ruby/object:Gem::Requirement
193
+ none: false
178
194
  requirements:
179
195
  - - ">="
180
196
  - !ruby/object:Gem::Version
197
+ hash: 3
198
+ segments:
199
+ - 0
181
200
  version: "0"
182
- version:
183
201
  requirements: []
184
202
 
185
203
  rubyforge_project: yapra
186
- rubygems_version: 1.3.5
204
+ rubygems_version: 1.3.7
187
205
  signing_key:
188
206
  specification_version: 3
189
207
  summary: Yet another pragger implementation.