taggata 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/taggata +10 -5
- data/lib/taggata/constants.rb +0 -2
- data/lib/taggata/parser/tag.rb +1 -1
- data/lib/taggata/tag.rb +1 -1
- data/lib/taggata/version.rb +1 -1
- data/taggata.gemspec +0 -3
- metadata +1 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af1fd56a3c40bf5cae4dd502103e294280763987
|
4
|
+
data.tar.gz: f8f7b604307f9ce1402a5b73989475be2778ab45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce98df89bbb25cbe946517853ef9b675b12687071538c246bad6c6ae165697d65ecac7458e997699d2d6668d6a67c9b2d959748fd7e9b56012347c49dec23bd
|
7
|
+
data.tar.gz: cc2c1d8091c499072ebc92c0c7616626f96fd2eb83700ac92467126591a10587f31e2ae6efdcbf182be980ff786a350bc7b3c2148d5334577aeed24fb6b440fa
|
data/bin/taggata
CHANGED
@@ -6,6 +6,7 @@ DB = Sequel.connect("sqlite://#{ARGV[0]}")
|
|
6
6
|
DB.create_table :file_tags do
|
7
7
|
foreign_key :tag_id, :tags
|
8
8
|
foreign_key :file_id, :files
|
9
|
+
primary_key [:tag_id, :file_id], :name => :file_tags_pk, :unique => true
|
9
10
|
end unless DB.table_exists? :file_tags
|
10
11
|
|
11
12
|
Sequel::Model.plugin(:schema)
|
@@ -29,14 +30,18 @@ when 'tag'
|
|
29
30
|
result = ::Taggata::Parser::Query.parse(ARGV[2])
|
30
31
|
tag_hash = ::Taggata::Parser::Tag.parse(ARGV[3])
|
31
32
|
result.each do |file|
|
32
|
-
tag_hash[:del].
|
33
|
-
|
34
|
-
end
|
33
|
+
deletions = tag_hash[:del].map { |tag| [file.id, tag.id] }
|
34
|
+
DB[:file_tags].where([:file_id, :tag_id] => deletions).delete
|
35
|
+
end.flatten 1
|
36
|
+
additions = result.map do |file|
|
37
|
+
adds = tag_hash[:add].map { |tag| [file.id, tag.id] }
|
38
|
+
in_db = DB[:file_tags].where([:file_id, :tag_id] => adds).map([:file_id, :tag_id])
|
39
|
+
(adds - in_db).map { |file_id, tag_id| { :file_id => file_id, :tag_id => tag_id } }
|
40
|
+
end.flatten
|
41
|
+
DB[:file_tags].multi_insert(additions)
|
35
42
|
when 'remove'
|
36
43
|
files = ::Taggata::Parser::Query.parse(ARGV[2])
|
37
44
|
files.each(&:destroy)
|
38
45
|
when 'count'
|
39
46
|
puts ::Taggata::Parser::Query.parse(ARGV[2]).count
|
40
|
-
when 'pry'
|
41
|
-
require 'pry'; binding.pry
|
42
47
|
end
|
data/lib/taggata/constants.rb
CHANGED
data/lib/taggata/parser/tag.rb
CHANGED
@@ -18,7 +18,7 @@ module Taggata
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def self.find_tags(names)
|
21
|
-
in_db = ::Taggata::Tag.where(:name => names).
|
21
|
+
in_db = ::Taggata::Tag.where(:name => names).map(:name)
|
22
22
|
::Taggata::Tag
|
23
23
|
.dataset
|
24
24
|
.multi_insert((names - in_db).map { |name| { :name => name } })
|
data/lib/taggata/tag.rb
CHANGED
data/lib/taggata/version.rb
CHANGED
data/taggata.gemspec
CHANGED
@@ -27,7 +27,4 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'minitest', '~> 5.6.1', '>= 5.6.1'
|
28
28
|
spec.add_development_dependency 'minitest-reporters', '~> 1.0.16', '>= 1.0.16'
|
29
29
|
spec.add_development_dependency 'mocha', '~> 1.1', '>= 1.1.0'
|
30
|
-
spec.add_development_dependency 'pry', '~> 0.1', '>= 0.0.1'
|
31
|
-
spec.add_development_dependency 'pry-coolline', '~> 0.1', '>= 0.0.1'
|
32
|
-
|
33
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taggata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Ruzicka
|
@@ -138,46 +138,6 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 1.1.0
|
141
|
-
- !ruby/object:Gem::Dependency
|
142
|
-
name: pry
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '0.1'
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 0.0.1
|
151
|
-
type: :development
|
152
|
-
prerelease: false
|
153
|
-
version_requirements: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - "~>"
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0.1'
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 0.0.1
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
name: pry-coolline
|
163
|
-
requirement: !ruby/object:Gem::Requirement
|
164
|
-
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: '0.1'
|
168
|
-
- - ">="
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
version: 0.0.1
|
171
|
-
type: :development
|
172
|
-
prerelease: false
|
173
|
-
version_requirements: !ruby/object:Gem::Requirement
|
174
|
-
requirements:
|
175
|
-
- - "~>"
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
version: '0.1'
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 0.0.1
|
181
141
|
description:
|
182
142
|
email:
|
183
143
|
- a.ruzicka@outlook.com
|