cryptkeeper 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
File without changes
data/README.rdoc CHANGED
@@ -8,4 +8,7 @@ Rails gem for connecting to the Google Storage API
8
8
 
9
9
  == Usage
10
10
 
11
- Coming soon.
11
+ So far:
12
+
13
+ google_keeper = CryptKeeper::Connection({:access_key => 'your_access_key', :secret_key => 'your_secret_key'})
14
+ my_buckets = google_keeper.buckets
data/Rakefile CHANGED
@@ -1,14 +1,20 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
1
+ require 'jeweler'
2
+ require Dir.pwd << '/lib/crypt_keeper.rb'
4
3
 
5
- Echoe.new('cryptkeeper', '0.1.0') do |p|
6
- p.description = "Work with Google Storage"
7
- p.url = "http://github.com/adamthedeveloper/cryptkeeper"
8
- p.author = "Adam Medeiros"
9
- p.email = "adammede@gmail.com"
10
- p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.development_dependencies = []
4
+ Jeweler::Tasks.new do |gem|
5
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
6
+ gem.name = "cryptkeeper"
7
+ gem.summary = %Q{Google Storage Connector}
8
+ gem.description = %Q{Use cryptkeeper to talk to Google Storage}
9
+ gem.email = "adammede@gmail.com"
10
+ gem.homepage = "http://github.com/adamthedeveloper/cryptkeeper"
11
+ gem.authors = ["Adam Medeiros"]
12
+ gem.version = CryptKeeper::VERSION
13
+
14
+ # Dependencies
15
+ gem.add_dependency 'hpricot'
16
+ gem.add_dependency 'iconv'
17
+ gem.add_dependency 'ruby-hmac'
12
18
  end
13
19
 
14
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |rk_file| load rk_file }
20
+ Jeweler::RubygemsDotOrgTasks.new
data/cryptkeeper.gemspec CHANGED
@@ -1,30 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{cryptkeeper}
5
- s.version = "0.1.0"
8
+ s.version = "0.2.1"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Adam Medeiros"]
9
- s.date = %q{2011-02-13}
10
- s.description = %q{Work with Google Storage}
12
+ s.date = %q{2011-02-14}
13
+ s.description = %q{Use cryptkeeper to talk to Google Storage}
11
14
  s.email = %q{adammede@gmail.com}
12
- s.extra_rdoc_files = ["README.rdoc", "lib/crypt_keeper.rb"]
13
- s.files = ["README.rdoc", "Rakefile", "lib/crypt_keeper.rb", "Manifest", "cryptkeeper.gemspec"]
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "CHANGELOG",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "cryptkeeper.gemspec",
23
+ "lib/buckets.rb",
24
+ "lib/crypt_keeper.rb",
25
+ "lib/objects.rb"
26
+ ]
14
27
  s.homepage = %q{http://github.com/adamthedeveloper/cryptkeeper}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cryptkeeper", "--main", "README.rdoc"]
16
28
  s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{cryptkeeper}
18
29
  s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{Work with Google Storage}
30
+ s.summary = %q{Google Storage Connector}
20
31
 
21
32
  if s.respond_to? :specification_version then
22
33
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
34
  s.specification_version = 3
24
35
 
25
36
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
38
+ s.add_runtime_dependency(%q<iconv>, [">= 0"])
39
+ s.add_runtime_dependency(%q<ruby-hmac>, [">= 0"])
26
40
  else
41
+ s.add_dependency(%q<hpricot>, [">= 0"])
42
+ s.add_dependency(%q<iconv>, [">= 0"])
43
+ s.add_dependency(%q<ruby-hmac>, [">= 0"])
27
44
  end
28
45
  else
46
+ s.add_dependency(%q<hpricot>, [">= 0"])
47
+ s.add_dependency(%q<iconv>, [">= 0"])
48
+ s.add_dependency(%q<ruby-hmac>, [">= 0"])
29
49
  end
30
50
  end
51
+
data/lib/buckets.rb ADDED
@@ -0,0 +1,65 @@
1
+ module Buckets
2
+ # GET Service
3
+ # lists all of the buckets that you own
4
+ # return an array of Bucket objects
5
+ def buckets
6
+ res = nil
7
+ time = request_time
8
+ Net::HTTP.start(@host[:address]) do |http|
9
+
10
+ req = Net::HTTP::Get.new("/")
11
+ req.add_field('Host', @host[:address])
12
+ req.add_field('Date', time)
13
+ req.add_field('Content-Length',0)
14
+
15
+ sig = signature("GET\n\n\n#{time}\n/")
16
+
17
+ req.add_field('Authorization', "#{@signature_id} #{@access_key}:#{sig}")
18
+ res = http.request(req)
19
+ end
20
+
21
+ hpr = Hpricot(res.body)
22
+ bucket_hashes = hpr.search("bucket").map do |el|
23
+ {
24
+ :name => el.search("name").inner_html,
25
+ :created_at => el.search("creationdate").inner_html
26
+ }
27
+ end
28
+
29
+ bucket_hashes.collect { |h| Bucket.new(h) }
30
+ end
31
+
32
+ # GET Bucket
33
+ # lists the contents of a bucket or retrieves the ACLs that are
34
+ # applied to a bucket.
35
+ # return a Bucket object
36
+ def bucket(*args)
37
+
38
+ end
39
+
40
+ def create_bucket(*args)
41
+
42
+ end
43
+
44
+ class Bucket
45
+ attr_accessor :name, :created_at
46
+ def initialize(*args)
47
+ options = {}
48
+ options.merge!(args.pop) if args.last.is_a? Hash
49
+ @name = options[:name]
50
+ @created_at = options[:created_at]
51
+ end
52
+
53
+ def create(*args)
54
+
55
+ end
56
+
57
+ def update(*args)
58
+
59
+ end
60
+
61
+ def destroy
62
+
63
+ end
64
+ end
65
+ end
data/lib/crypt_keeper.rb CHANGED
@@ -1,8 +1,47 @@
1
+ require Dir.pwd << '/lib/buckets.rb'
2
+ require Dir.pwd << '/lib/objects.rb'
3
+ require 'net/http'
4
+ require 'iconv'
5
+ require 'hmac-sha1'
6
+ require 'base64'
7
+ require 'uri'
8
+ require 'hpricot'
9
+
1
10
  module CryptKeeper
11
+ VERSION = "0.2.1"
2
12
  class Connection
3
13
  def initialize(*args)
4
- options = {}
14
+ options = {
15
+ :signature_identifier => "GOOG1",
16
+ :host => "commondatastorage.googleapis.com",
17
+ :port => "80"
18
+ }
19
+
5
20
  options.merge!(args.pop) if args.last.kind_of? Hash
21
+
22
+ @access_key = options[:access_key]
23
+ @secret_key = options[:secret_key]
24
+ @signature_id = options[:signature_identifier]
25
+ @host = {
26
+ :address => options[:host],
27
+ :port => options[:port]
28
+ }
29
+ @ic_utf8 = Iconv.new('ascii//TRANSLIT//IGNORE', 'UTF-8')
6
30
  end
31
+
32
+ def signature(message)
33
+ utf8_message = @ic_utf8.iconv(message)
34
+ utf8_key = @ic_utf8.iconv(@secret_key)
35
+ sha1 = HMAC::SHA1.digest(utf8_key, utf8_message)
36
+ Base64.encode64(sha1).strip
37
+ end
38
+
39
+ def request_time
40
+ Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
41
+ end
42
+
43
+ include Buckets
44
+ include Objects
7
45
  end
46
+
8
47
  end
data/lib/objects.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Objects
2
+
3
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 2
7
8
  - 1
8
- - 0
9
- version: 0.1.0
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Medeiros
@@ -14,11 +14,49 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-13 00:00:00 -08:00
17
+ date: 2011-02-14 00:00:00 -08:00
18
18
  default_executable:
19
- dependencies: []
20
-
21
- description: Work with Google Storage
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hpricot
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: iconv
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: ruby-hmac
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ description: Use cryptkeeper to talk to Google Storage
22
60
  email: adammede@gmail.com
23
61
  executables: []
24
62
 
@@ -26,25 +64,21 @@ extensions: []
26
64
 
27
65
  extra_rdoc_files:
28
66
  - README.rdoc
29
- - lib/crypt_keeper.rb
30
67
  files:
68
+ - CHANGELOG
31
69
  - README.rdoc
32
70
  - Rakefile
33
- - lib/crypt_keeper.rb
34
- - Manifest
35
71
  - cryptkeeper.gemspec
72
+ - lib/buckets.rb
73
+ - lib/crypt_keeper.rb
74
+ - lib/objects.rb
36
75
  has_rdoc: true
37
76
  homepage: http://github.com/adamthedeveloper/cryptkeeper
38
77
  licenses: []
39
78
 
40
79
  post_install_message:
41
- rdoc_options:
42
- - --line-numbers
43
- - --inline-source
44
- - --title
45
- - Cryptkeeper
46
- - --main
47
- - README.rdoc
80
+ rdoc_options: []
81
+
48
82
  require_paths:
49
83
  - lib
50
84
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -61,15 +95,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
95
  - - ">="
62
96
  - !ruby/object:Gem::Version
63
97
  segments:
64
- - 1
65
- - 2
66
- version: "1.2"
98
+ - 0
99
+ version: "0"
67
100
  requirements: []
68
101
 
69
- rubyforge_project: cryptkeeper
102
+ rubyforge_project:
70
103
  rubygems_version: 1.3.7
71
104
  signing_key:
72
105
  specification_version: 3
73
- summary: Work with Google Storage
106
+ summary: Google Storage Connector
74
107
  test_files: []
75
108
 
data/Manifest DELETED
@@ -1,4 +0,0 @@
1
- README.rdoc
2
- Rakefile
3
- lib/crypt_keeper.rb
4
- Manifest