spunkmeyer 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spunkmeyer (0.0.2)
5
+ colorize
6
+ etc
7
+ sqlite3
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ colorize (0.5.8)
13
+ diff-lcs (1.2.4)
14
+ etc (0.2.0)
15
+ rake (10.1.0)
16
+ rspec (2.13.0)
17
+ rspec-core (~> 2.13.0)
18
+ rspec-expectations (~> 2.13.0)
19
+ rspec-mocks (~> 2.13.0)
20
+ rspec-core (2.13.1)
21
+ rspec-expectations (2.13.0)
22
+ diff-lcs (>= 1.1.3, < 2.0)
23
+ rspec-mocks (2.13.1)
24
+ sqlite3 (1.3.7)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ rake
31
+ rspec
32
+ spunkmeyer!
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2013 Tim Miller
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # spunkmeyer
2
+
3
+ Grab cookies from your browser from ruby code.
4
+
5
+ # requirements
6
+
7
+ Currently, the only supported browser is Chrome on OSX.
8
+
9
+ # installation
10
+
11
+ gem install spunkmeyer
12
+
13
+ # library usage
14
+
15
+ ```ruby
16
+ require 'spunkmeyer'
17
+
18
+ puts Spunkmeyer.cookies('http://github.com')
19
+ ```
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ GEM_NAME = 'spunkmeyer'
4
+ spec = eval File.read("#{GEM_NAME}.gemspec")
5
+
6
+ task :install do
7
+ sh %{gem build #{GEM_NAME}.gemspec}
8
+ sh %{gem install #{GEM_NAME}-#{spec.version}.gem --no-ri --no-rdoc}
9
+ end
10
+
11
+ RSpec::Core::RakeTask.new(:spec) do |t|
12
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
13
+ t.rspec_opts = '--color'
14
+ end
@@ -0,0 +1,32 @@
1
+ require 'sqlite3'
2
+
3
+ module Spunkmeyer
4
+
5
+ module Chrome
6
+
7
+ # currently supports only OSX.
8
+ def self.cookie_path
9
+ "#{Dir.home}/Library/Application Support/Google/Chrome/Default/Cookies"
10
+ end
11
+
12
+ def self.cookies(domain)
13
+ hk = host_key domain
14
+ db = SQLite3::Database.open cookie_path
15
+ fields = [ :host_key, :path, :name, :value, :expires_utc ]
16
+ sql_fields = fields.map { |f| f.to_s }.join(', ')
17
+ rows = db.execute "select #{sql_fields} from cookies where host_key like '%#{hk}%'"
18
+ rows.map! { |r| Hash[fields.zip r] }
19
+ names = rows.map { |r| r[:name] }
20
+ Hash[names.zip rows]
21
+ end
22
+
23
+ def self.host_key(domain)
24
+ server = domain.scan(/:\/\/([^:#\/\?]+)/).flatten.first
25
+ raise "Malformed domain!" unless server
26
+ parts = server.split(".")
27
+ ".#{parts[-2]}.#{parts[-1]}"
28
+ end
29
+
30
+ end
31
+
32
+ end
data/lib/spunkmeyer.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'spunkmeyer/chrome'
2
+
3
+ module Spunkmeyer
4
+
5
+ def self.cookies(domain)
6
+ Chrome.cookies domain
7
+ end
8
+
9
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ module Spunkmeyer
4
+ module Chrome
5
+ def self.cookie_path
6
+ "#{File.expand_path File.dirname(__FILE__)}/fixtures/chrome.sqlite"
7
+ end
8
+ end
9
+ end
10
+
11
+ describe Spunkmeyer::Chrome do
12
+
13
+ it 'should grab cookies for a specified domain' do
14
+ Spunkmeyer::Chrome.cookies('https://foo.com').should == {
15
+ "some other name" => {
16
+ :host_key => ".foo.com",
17
+ :path => "/some/other/path",
18
+ :name => "some other name",
19
+ :value => "some other value",
20
+ :expires_utc => 13017385153000000
21
+ },
22
+ "some name" => {
23
+ :host_key => ".foo.com",
24
+ :path => "/some/path",
25
+ :name => "some name",
26
+ :value => "some value",
27
+ :expires_utc=>13017385153000000
28
+ }
29
+ }
30
+ end
31
+
32
+ end
Binary file
@@ -0,0 +1,2 @@
1
+ $:.push File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'spunkmeyer'))
2
+ require 'spunkmeyer'
@@ -0,0 +1,25 @@
1
+ #
2
+ # -*- encoding: utf-8 -*-
3
+ Gem::Specification.new do |s|
4
+ s.name = 'spunkmeyer'
5
+ s.version = '0.0.4'
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = [ 'Tim Miller' ]
8
+ s.email = [ '' ]
9
+ s.homepage = 'https://github.com/echohead/spunkmeyer'
10
+ s.summary = %q{extracts cookies from browser databases.}
11
+ s.description = %q{extracts cookies from browser databases.}
12
+
13
+ s.required_ruby_version = ">= 1.9.1"
14
+ s.required_rubygems_version = ">= 1.3.7"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_runtime_dependency 'colorize', '>= 0'
22
+ s.add_runtime_dependency 'sqlite3', '>= 0'
23
+ s.add_development_dependency 'rake', '>= 0'
24
+ s.add_development_dependency 'rspec', '>= 0'
25
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spunkmeyer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Miller
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: extracts cookies from browser databases.
79
+ email:
80
+ - ''
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - Gemfile
86
+ - Gemfile.lock
87
+ - LICENSE
88
+ - README.md
89
+ - Rakefile
90
+ - lib/spunkmeyer.rb
91
+ - lib/spunkmeyer/chrome.rb
92
+ - spec/chrome_spec.rb
93
+ - spec/fixtures/chrome.sqlite
94
+ - spec/spec_helper.rb
95
+ - spunkmeyer.gemspec
96
+ homepage: https://github.com/echohead/spunkmeyer
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: 1.9.1
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: 1.3.7
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.23
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: extracts cookies from browser databases.
120
+ test_files: []