sourcer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ Sourcer
2
+ =======
3
+
4
+ Get the source of web pages using hard-to-simulate user agents like the iPhone.
5
+
6
+ This is a light Ruby wrapper around curl. It has the advantage of being easy
7
+ to remember the user agents.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ sudo gem install sourcer
13
+
14
+ Usage
15
+ -----
16
+
17
+ sourcer http://beerfire.com
18
+
19
+ That is equivalent to:
20
+
21
+ sourcer http://beerfire.com -A iphone
22
+ sourcer http://beerfire.com --user-agent iphone
23
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'jeweler'
2
+
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "sourcer"
5
+ gem.summary = "Get the source of web pages using hard-to-simulate user agents like the iPhone."
6
+ gem.description = "Get the source of web pages using hard-to-simulate user agents like the iPhone."
7
+ gem.email = "dcroak@thoughtbot.com"
8
+ gem.homepage = "http://github.com/dancroak/sourcer"
9
+ gem.authors = ["Dan Croak"]
10
+ gem.bindir = "bin"
11
+ gem.executables = ["sourcer"]
12
+ end
13
+
14
+ Jeweler::GemcutterTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/sourcer ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'sourcer'
5
+
6
+ Sourcer.new(STDIN, ARGV).run
data/lib/sourcer.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'optparse'
2
+
3
+ class Sourcer
4
+ attr_accessor :site, :user_agent
5
+
6
+ def initialize(stdin, arguments = [])
7
+ self.user_agent = iphone
8
+
9
+ options = OptionParser.new
10
+ options.on('-A', '--user-agent') { self.user_agent = a }
11
+ options.parse!(arguments)
12
+
13
+ self.site = stdin.gets.chomp
14
+ end
15
+
16
+ def run
17
+ `curl -A "#{user_agent}" "#{site}"`
18
+ end
19
+
20
+ protected
21
+
22
+ def iphone
23
+ "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3"
24
+ end
25
+ end
data/sourcer.gemspec ADDED
@@ -0,0 +1,49 @@
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{sourcer}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dan Croak"]
12
+ s.date = %q{2010-02-15}
13
+ s.default_executable = %q{sourcer}
14
+ s.description = %q{Get the source of web pages using hard-to-simulate user agents like the iPhone.}
15
+ s.email = %q{dcroak@thoughtbot.com}
16
+ s.executables = ["sourcer"]
17
+ s.extra_rdoc_files = [
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/sourcer",
26
+ "lib/sourcer.rb",
27
+ "sourcer.gemspec",
28
+ "spec/sourcer_spec.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/dancroak/sourcer}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{Get the source of web pages using hard-to-simulate user agents like the iPhone.}
35
+ s.test_files = [
36
+ "spec/sourcer_spec.rb"
37
+ ]
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ else
45
+ end
46
+ else
47
+ end
48
+ end
49
+
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'sourcer')
4
+
5
+ describe Sourcer do
6
+ before do
7
+ stdin = StringIO.new("http://www.avc.com\n")
8
+ @source = Sourcer.new(stdin).run
9
+ end
10
+
11
+ it "should output the iphone body" do
12
+ @source.should =~ /Fred Wilson/
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sourcer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Croak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-15 00:00:00 -05:00
13
+ default_executable: sourcer
14
+ dependencies: []
15
+
16
+ description: Get the source of web pages using hard-to-simulate user agents like the iPhone.
17
+ email: dcroak@thoughtbot.com
18
+ executables:
19
+ - sourcer
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.md
24
+ files:
25
+ - .gitignore
26
+ - README.md
27
+ - Rakefile
28
+ - VERSION
29
+ - bin/sourcer
30
+ - lib/sourcer.rb
31
+ - sourcer.gemspec
32
+ - spec/sourcer_spec.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/dancroak/sourcer
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.3.5
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Get the source of web pages using hard-to-simulate user agents like the iPhone.
61
+ test_files:
62
+ - spec/sourcer_spec.rb