xxx 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ *.gem
data/README.rdoc CHANGED
@@ -1,9 +1,11 @@
1
1
  = xxx
2
2
 
3
- Description goes here.
3
+ == Usage
4
+
5
+ Xxx.watch_porn
4
6
 
5
7
  == Note on Patches/Pull Requests
6
-
8
+
7
9
  * Fork the project.
8
10
  * Make your feature addition or bug fix.
9
11
  * Add tests for it. This is important so I don't break it in a
data/Rakefile CHANGED
@@ -8,10 +8,11 @@ begin
8
8
  Jeweler::Tasks.new do |gem|
9
9
  gem.name = "xxx"
10
10
  gem.summary = %Q{Porn of the day}
11
- gem.email = "qoobaa+github@gmail.com"
11
+ gem.email = "qoobaa@gmail.com"
12
12
  gem.homepage = "http://github.com/qoobaa/xxx"
13
- gem.authors = ["Jakub Kuźma"]
14
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
13
+ gem.authors = ["Jakub Kuźma", "Wojciech Wnętrzak"]
14
+ gem.add_dependency "launchy"
15
+ gem.add_dependency "mechanize"
15
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/xxx ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Version = "0.1.0"
4
+
5
+ require "optparse"
6
+ require "pp"
7
+
8
+ require "xxx"
9
+
10
+ options = {}
11
+
12
+ optparse = OptionParser.new do|opts|
13
+ opts.banner = "Usage: xxx [options] command"
14
+
15
+ opts.separator ""
16
+ opts.separator "Available commands:"
17
+ opts.separator " latest (default)"
18
+
19
+ opts.separator ""
20
+ opts.separator "Specific options:"
21
+
22
+ opts.on("-c", "--channel [CHANNEL]", [:youporn, :szukajcipki], "Select channel (youporn, szukajcipki)") do |channel|
23
+ options[:channel] = channel
24
+ end
25
+
26
+ opts.on("-h", "--help", "Display this screen") do
27
+ puts opts
28
+ exit
29
+ end
30
+ end
31
+
32
+ optparse.parse!
33
+
34
+ command = ARGV.shift || "latest"
35
+
36
+ begin
37
+ Xxx.watch_porn(options[:channel], command)
38
+ rescue Exception => e
39
+ abort("xxx: #{e.message}")
40
+ end
data/lib/xxx.rb CHANGED
@@ -0,0 +1,35 @@
1
+ require "mechanize"
2
+ require "open-uri"
3
+ require "launchy"
4
+
5
+ require "xxx/youporn"
6
+ require "xxx/szukaj_cipki"
7
+
8
+ module Xxx
9
+ CHANNEL_NAMES = [:youporn, :szukajcipki]
10
+
11
+ class << self
12
+ def watch_porn(channel_name, command = "latest")
13
+ channel_name ||= CHANNEL_NAMES.sort_by { rand }.first
14
+ channel = open_channel(channel_name)
15
+
16
+ if channel.respond_to?(command)
17
+ uri = channel.send(command)
18
+ Launchy.open(uri)
19
+ else
20
+ raise ArgumentError, "unknown command: #{command}"
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def open_channel(channel_name)
27
+ case channel_name
28
+ when :youporn
29
+ Youporn.new
30
+ when :szukajcipki
31
+ SzukajCipki.new
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ module Xxx
2
+ class SzukajCipki
3
+ HOST = "http://szukajcipki.pl"
4
+
5
+ attr_accessor :doc, :link
6
+
7
+ def agent
8
+ @doc = Nokogiri::HTML(open(HOST))
9
+ end
10
+
11
+ def latest
12
+ @link = HOST + agent.css("ul#movies a").first['href']
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module Xxx
2
+ class Youporn
3
+ HOST = "youporn.com"
4
+ URI = "http://#{HOST}"
5
+ BROWSE_TIME_PATH = "/browse/time"
6
+ ENTER_WEBSITE = lambda { |page| page.forms.first.click_button }
7
+
8
+ def agent
9
+ @agent ||= WWW::Mechanize.new
10
+ end
11
+
12
+ def latest
13
+ agent.get(uri(BROWSE_TIME_PATH), &ENTER_WEBSITE)
14
+ path = agent.page.links_with(:href => /watch/).first.href
15
+ uri(path)
16
+ end
17
+
18
+ def uri(path)
19
+ "#{URI}#{path}"
20
+ end
21
+ end
22
+ end
data/xxx.gemspec ADDED
@@ -0,0 +1,61 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{xxx}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jakub Kuźma", "Wojciech Wnętrzak"]
12
+ s.date = %q{2010-02-05}
13
+ s.default_executable = %q{xxx}
14
+ s.email = %q{qoobaa@gmail.com}
15
+ s.executables = ["xxx"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/xxx",
28
+ "lib/xxx.rb",
29
+ "lib/xxx/szukaj_cipki.rb",
30
+ "lib/xxx/youporn.rb",
31
+ "test/helper.rb",
32
+ "test/test_xxx.rb",
33
+ "xxx.gemspec"
34
+ ]
35
+ s.homepage = %q{http://github.com/qoobaa/xxx}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.5}
39
+ s.summary = %q{Porn of the day}
40
+ s.test_files = [
41
+ "test/test_xxx.rb",
42
+ "test/helper.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<launchy>, [">= 0"])
51
+ s.add_runtime_dependency(%q<mechanize>, [">= 0"])
52
+ else
53
+ s.add_dependency(%q<launchy>, [">= 0"])
54
+ s.add_dependency(%q<mechanize>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<launchy>, [">= 0"])
58
+ s.add_dependency(%q<mechanize>, [">= 0"])
59
+ end
60
+ end
61
+
metadata CHANGED
@@ -1,20 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xxx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub Ku\xC5\xBAma"
8
+ - "Wojciech Wn\xC4\x99trzak"
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
13
  date: 2010-02-05 00:00:00 +01:00
13
- default_executable:
14
+ default_executable: xxx
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
17
- type: :development
17
+ name: launchy
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: mechanize
28
+ type: :runtime
18
29
  version_requirement:
19
30
  version_requirements: !ruby/object:Gem::Requirement
20
31
  requirements:
@@ -23,9 +34,9 @@ dependencies:
23
34
  version: "0"
24
35
  version:
25
36
  description:
26
- email: qoobaa+github@gmail.com
27
- executables: []
28
-
37
+ email: qoobaa@gmail.com
38
+ executables:
39
+ - xxx
29
40
  extensions: []
30
41
 
31
42
  extra_rdoc_files:
@@ -37,9 +48,14 @@ files:
37
48
  - LICENSE
38
49
  - README.rdoc
39
50
  - Rakefile
51
+ - VERSION
52
+ - bin/xxx
40
53
  - lib/xxx.rb
54
+ - lib/xxx/szukaj_cipki.rb
55
+ - lib/xxx/youporn.rb
41
56
  - test/helper.rb
42
57
  - test/test_xxx.rb
58
+ - xxx.gemspec
43
59
  has_rdoc: true
44
60
  homepage: http://github.com/qoobaa/xxx
45
61
  licenses: []