dbox 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/dbox.gemspec +4 -6
- data/lib/dbox.rb +2 -1
- data/vendor/insensitive_hash_patched.rb +191 -0
- metadata +5 -20
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/dbox.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dbox"
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ken Pratt"]
|
12
|
-
s.date = "2012-11-
|
12
|
+
s.date = "2012-11-13"
|
13
13
|
s.description = "An easy-to-use Dropbox client with fine-grained control over syncs."
|
14
14
|
s.email = "ken@kenpratt.net"
|
15
15
|
s.executables = ["dbox"]
|
@@ -48,7 +48,8 @@ Gem::Specification.new do |s|
|
|
48
48
|
"vendor/dropbox-ruby-sdk/lib/trusted-certs.crt",
|
49
49
|
"vendor/dropbox-ruby-sdk/search_cache.json",
|
50
50
|
"vendor/dropbox-ruby-sdk/search_cache.rb",
|
51
|
-
"vendor/dropbox-ruby-sdk/web_file_browser.rb"
|
51
|
+
"vendor/dropbox-ruby-sdk/web_file_browser.rb",
|
52
|
+
"vendor/insensitive_hash_patched.rb"
|
52
53
|
]
|
53
54
|
s.homepage = "http://github.com/kenpratt/dbox"
|
54
55
|
s.licenses = ["MIT"]
|
@@ -64,20 +65,17 @@ Gem::Specification.new do |s|
|
|
64
65
|
s.add_runtime_dependency(%q<oauth>, [">= 0.4.5"])
|
65
66
|
s.add_runtime_dependency(%q<json>, [">= 1.5.3"])
|
66
67
|
s.add_runtime_dependency(%q<sqlite3>, [">= 1.3.3"])
|
67
|
-
s.add_runtime_dependency(%q<insensitive_hash>, [">= 0.3.0"])
|
68
68
|
else
|
69
69
|
s.add_dependency(%q<multipart-post>, [">= 1.1.2"])
|
70
70
|
s.add_dependency(%q<oauth>, [">= 0.4.5"])
|
71
71
|
s.add_dependency(%q<json>, [">= 1.5.3"])
|
72
72
|
s.add_dependency(%q<sqlite3>, [">= 1.3.3"])
|
73
|
-
s.add_dependency(%q<insensitive_hash>, [">= 0.3.0"])
|
74
73
|
end
|
75
74
|
else
|
76
75
|
s.add_dependency(%q<multipart-post>, [">= 1.1.2"])
|
77
76
|
s.add_dependency(%q<oauth>, [">= 0.4.5"])
|
78
77
|
s.add_dependency(%q<json>, [">= 1.5.3"])
|
79
78
|
s.add_dependency(%q<sqlite3>, [">= 1.3.3"])
|
80
|
-
s.add_dependency(%q<insensitive_hash>, [">= 0.3.0"])
|
81
79
|
end
|
82
80
|
end
|
83
81
|
|
data/lib/dbox.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
2
2
|
$:.unshift File.join(ROOT_PATH, "lib")
|
3
|
+
$:.unshift File.join(ROOT_PATH, "vendor")
|
3
4
|
$:.unshift File.join(ROOT_PATH, "vendor", "dropbox-ruby-sdk", "lib")
|
4
5
|
|
5
6
|
require "dropbox_sdk"
|
@@ -9,7 +10,7 @@ require "yaml"
|
|
9
10
|
require "logger"
|
10
11
|
require "cgi"
|
11
12
|
require "sqlite3"
|
12
|
-
require "
|
13
|
+
require "insensitive_hash_patched"
|
13
14
|
|
14
15
|
require "dbox/loggable"
|
15
16
|
require "dbox/utils"
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# A slightly patched version of https://github.com/junegunn/insensitive_hash v0.3.0
|
2
|
+
# that is not insensitive to underscores vs. strings.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2011 Junegunn Choi
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
class InsensitiveHash < Hash
|
26
|
+
class KeyClashError < Exception
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize default = nil, &block
|
30
|
+
if block_given?
|
31
|
+
raise ArgumentError.new('wrong number of arguments') unless default.nil?
|
32
|
+
super &block
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
@key_map = {}
|
38
|
+
@safe = false
|
39
|
+
end
|
40
|
+
|
41
|
+
# Sets whether to detect key clashes
|
42
|
+
# @param [Boolean]
|
43
|
+
# @return [Boolean]
|
44
|
+
def safe= s
|
45
|
+
raise ArgumentError.new("Neither true nor false") unless [true, false].include?(s)
|
46
|
+
@safe = s
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Boolean] Key-clash detection enabled?
|
50
|
+
def safe?
|
51
|
+
@safe
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns a normal, sensitive Hash
|
55
|
+
# @return [Hash]
|
56
|
+
def to_hash
|
57
|
+
{}.merge self
|
58
|
+
end
|
59
|
+
alias sensitive to_hash
|
60
|
+
|
61
|
+
def self.[] *init
|
62
|
+
h = Hash[*init]
|
63
|
+
InsensitiveHash.new.tap do |ih|
|
64
|
+
ih.merge! h
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
%w[[] assoc has_key? include? key? member?].each do |symb|
|
69
|
+
class_eval <<-EVAL
|
70
|
+
def #{symb} key
|
71
|
+
super lookup_key(key)
|
72
|
+
end
|
73
|
+
EVAL
|
74
|
+
end
|
75
|
+
|
76
|
+
def []= key, value
|
77
|
+
delete key
|
78
|
+
ekey = encode key
|
79
|
+
@key_map[ekey] = key
|
80
|
+
super key, value
|
81
|
+
end
|
82
|
+
alias store []=
|
83
|
+
|
84
|
+
def merge! other_hash
|
85
|
+
detect_clash other_hash
|
86
|
+
other_hash.each do |key, value|
|
87
|
+
deep_set key, value
|
88
|
+
end
|
89
|
+
self
|
90
|
+
end
|
91
|
+
alias update! merge!
|
92
|
+
|
93
|
+
def merge other_hash
|
94
|
+
InsensitiveHash.new.tap do |ih|
|
95
|
+
ih.replace self
|
96
|
+
ih.merge! other_hash
|
97
|
+
end
|
98
|
+
end
|
99
|
+
alias update merge
|
100
|
+
|
101
|
+
def delete key, &block
|
102
|
+
super lookup_key(key, true), &block
|
103
|
+
end
|
104
|
+
|
105
|
+
def clear
|
106
|
+
@key_map.clear
|
107
|
+
super
|
108
|
+
end
|
109
|
+
|
110
|
+
def replace other
|
111
|
+
super other
|
112
|
+
|
113
|
+
self.safe = other.respond_to?(:safe?) ? other.safe? : safe?
|
114
|
+
|
115
|
+
@key_map.clear
|
116
|
+
self.each do |k, v|
|
117
|
+
ekey = encode k
|
118
|
+
@key_map[ekey] = k
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def shift
|
123
|
+
super.tap do |ret|
|
124
|
+
@key_map.delete_if { |k, v| v == ret.first }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def values_at *keys
|
129
|
+
keys.map { |k| self[k] }
|
130
|
+
end
|
131
|
+
|
132
|
+
def fetch *args, &block
|
133
|
+
args[0] = lookup_key(args[0]) if args.first
|
134
|
+
super *args, &block
|
135
|
+
end
|
136
|
+
|
137
|
+
def dup
|
138
|
+
super.tap { |copy|
|
139
|
+
copy.instance_variable_set :@key_map, @key_map.dup
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
def clone
|
144
|
+
super.tap { |copy|
|
145
|
+
copy.instance_variable_set :@key_map, @key_map.dup
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
def deep_set key, value
|
151
|
+
wv = wrap value
|
152
|
+
self[key] = wv
|
153
|
+
end
|
154
|
+
|
155
|
+
def wrap value
|
156
|
+
case value
|
157
|
+
when InsensitiveHash
|
158
|
+
value
|
159
|
+
when Hash
|
160
|
+
InsensitiveHash[value]
|
161
|
+
when Array
|
162
|
+
value.map { |v| wrap v }
|
163
|
+
else
|
164
|
+
value
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def lookup_key key, delete = false
|
169
|
+
ekey = encode key
|
170
|
+
if @key_map.has_key?(ekey)
|
171
|
+
delete ? @key_map.delete(ekey) : @key_map[ekey]
|
172
|
+
else
|
173
|
+
key
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def encode key
|
178
|
+
case key
|
179
|
+
when String, Symbol
|
180
|
+
key.to_s.downcase
|
181
|
+
else
|
182
|
+
key
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def detect_clash hash
|
187
|
+
hash.keys.map { |k| encode k }.tap { |ekeys|
|
188
|
+
raise KeyClashError.new("Key clash detected") if ekeys != ekeys.uniq
|
189
|
+
} if @safe
|
190
|
+
end
|
191
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Pratt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: multipart-post
|
@@ -81,22 +81,6 @@ dependencies:
|
|
81
81
|
version: 1.3.3
|
82
82
|
type: :runtime
|
83
83
|
version_requirements: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: insensitive_hash
|
86
|
-
prerelease: false
|
87
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
|
-
requirements:
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 19
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
- 3
|
96
|
-
- 0
|
97
|
-
version: 0.3.0
|
98
|
-
type: :runtime
|
99
|
-
version_requirements: *id005
|
100
84
|
description: An easy-to-use Dropbox client with fine-grained control over syncs.
|
101
85
|
email: ken@kenpratt.net
|
102
86
|
executables:
|
@@ -138,6 +122,7 @@ files:
|
|
138
122
|
- vendor/dropbox-ruby-sdk/search_cache.json
|
139
123
|
- vendor/dropbox-ruby-sdk/search_cache.rb
|
140
124
|
- vendor/dropbox-ruby-sdk/web_file_browser.rb
|
125
|
+
- vendor/insensitive_hash_patched.rb
|
141
126
|
homepage: http://github.com/kenpratt/dbox
|
142
127
|
licenses:
|
143
128
|
- MIT
|