tagutils 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e34415c99adfedcb4bd078a328b52a7c9f418931
4
- data.tar.gz: ba4d539d363122e793a0b8fac7609025520623cc
3
+ metadata.gz: c710e607cd4a57a3a1562e5b18c3b32ebc6039a5
4
+ data.tar.gz: d91d3322c08f33d66544fe43a8ace843a18f6d82
5
5
  SHA512:
6
- metadata.gz: c2ae676b1df654904a593519c0bfbb1874ebaaebf299977809b7c6ff007baef78be882d7ae00ffa1e1a662427b002131d7bc50c517f3a5946a5a1c5e7ffdef53
7
- data.tar.gz: f262dc809c38d893e7020be236bbfa5c9cbcceac3f49a38d6fc746862f43f268ba69739d578b84c1ec84cd9dec892ae5ba63026e2c18e05abdcad2d071be86fa
6
+ metadata.gz: 232f56d3800b84452ea1165a84d98339c209a103737cbc2f485f5fd360680da19abdbcaadfaab38e4b48869c7f12b366eb0cc5e6c8e26718adbf84dfa524bbae
7
+ data.tar.gz: 01b660a5c2e57b2c35e936ccf89cfbd862eca993877d7c035ddedec71d5d3436867bb7c0cade9396df6d51227f5f1adb6fe1cc11978b1c6761f8b65af1cbc514
@@ -1,24 +1,24 @@
1
- HISTORY.md
2
- Manifest.txt
3
- README.md
4
- Rakefile
5
- lib/tagutils.rb
6
- lib/tagutils/categories.rb
7
- lib/tagutils/categories/active_record.rb
8
- lib/tagutils/categories/models/categorization.rb
9
- lib/tagutils/categories/models/category.rb
10
- lib/tagutils/categories/models/category_comp.rb
11
- lib/tagutils/categories/schema.rb
12
- lib/tagutils/tags.rb
13
- lib/tagutils/tags/active_record.rb
14
- lib/tagutils/tags/models/tag.rb
15
- lib/tagutils/tags/models/tag_comp.rb
16
- lib/tagutils/tags/models/tagging.rb
17
- lib/tagutils/tags/patterns.rb
18
- lib/tagutils/tags/readers/tag.rb
19
- lib/tagutils/tags/schema.rb
20
- lib/tagutils/version.rb
21
- test/helper.rb
22
- test/tags.1.yml
23
- test/test_models.rb
24
- test/test_tag_reader.rb
1
+ HISTORY.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ lib/tagutils.rb
6
+ lib/tagutils/categories.rb
7
+ lib/tagutils/categories/active_record.rb
8
+ lib/tagutils/categories/models/categorization.rb
9
+ lib/tagutils/categories/models/category.rb
10
+ lib/tagutils/categories/models/category_comp.rb
11
+ lib/tagutils/categories/schema.rb
12
+ lib/tagutils/tags.rb
13
+ lib/tagutils/tags/active_record.rb
14
+ lib/tagutils/tags/models/tag.rb
15
+ lib/tagutils/tags/models/tag_comp.rb
16
+ lib/tagutils/tags/models/tagging.rb
17
+ lib/tagutils/tags/patterns.rb
18
+ lib/tagutils/tags/readers/tag.rb
19
+ lib/tagutils/tags/schema.rb
20
+ lib/tagutils/version.rb
21
+ test/helper.rb
22
+ test/tags.1.yml
23
+ test/test_models.rb
24
+ test/test_tag_reader.rb
data/README.md CHANGED
@@ -16,20 +16,20 @@ Use `TagDb.create` to build the `tags` and `taggings` tables
16
16
  and `CategoryDb.create` to build the `categories` and `categorizations` tables.
17
17
  Example:
18
18
 
19
- ~~~
19
+ ```
20
20
  # ...
21
21
  TagDb.create
22
22
  # ...
23
23
  CategoryDb.create
24
24
  # ...
25
- ~~~
25
+ ```
26
26
 
27
27
 
28
28
  ### Models
29
29
 
30
30
  Add the associations yourself with the standard `has_many` class macro:
31
31
 
32
- ~~~
32
+ ```
33
33
  class Movie < ActiveRecord::Base
34
34
  # ...
35
35
  has_many :taggings, class_name: 'TagDb::Model::Tagging', :as => :taggable
@@ -39,11 +39,11 @@ class Movie < ActiveRecord::Base
39
39
  has_many :categories, class_name: 'CategoryDb::Model::Category', :through => :categorizations
40
40
  # ...
41
41
  end
42
- ~~~
42
+ ```
43
43
 
44
44
  or use the built-in class macro shortcuts:
45
45
 
46
- ~~~
46
+ ```
47
47
  class Movie < ActiveRecord::Base
48
48
  # ...
49
49
  has_many_tags
@@ -51,27 +51,27 @@ class Movie < ActiveRecord::Base
51
51
  has_many_categories
52
52
  # ...
53
53
  end
54
- ~~~
54
+ ```
55
55
 
56
56
  The `has_many_tags` also adds the following methods:
57
57
 
58
- ~~~
58
+ ```
59
59
  Movie.with_tag( 'doc' )
60
60
  # e.g. scope :with_tag, ->(tag_key){ joins(:tags).where('tags.key' => tag_key) }
61
- ~~~
61
+ ```
62
62
 
63
63
  The `has_many_categories` also adds the following methods:
64
64
 
65
- ~~~
65
+ ```
66
66
  Movie.with_category( 'doc' )
67
67
  # e.g. scope :with_category, ->(category_key){ joins(:categories).where('categories.key' => category_key) }
68
- ~~~
68
+ ```
69
69
 
70
70
  ### Reader
71
71
 
72
72
  The `TagReader` lets you read plain text fixtures (data sets). Example:
73
73
 
74
- ~~~
74
+ ```
75
75
  tags.1.yml:
76
76
  -----------
77
77
 
@@ -83,194 +83,23 @@ football: fifa, uefa, afc, ofc, caf, csf, concacaf
83
83
  # national regions
84
84
 
85
85
  brasil: s|South, se|Southeast, co|Centerwest, ne|Northeast, n|North
86
- ~~~
86
+ ```
87
87
 
88
88
  To read the tags use:
89
89
 
90
- ~~~
90
+ ```
91
91
  TagReader.new( <include_path>).read( `tags.1` )
92
- ~~~
92
+ ```
93
93
 
94
94
 
95
95
 
96
96
  ## Real World Usage
97
97
 
98
98
  - [worlddb gem](http://rubygems.org/gems/worlddb) - continent, country, region, metro, city, district etc. models
99
- - [winedb gem](http://rubygems.org/gems/winedb) - wine, winery, winemaker, vineyards, etc. models
99
+ - [winedb gem](http://rubygems.org/gems/winedb) - wine, winery, winemaker, vineyards, etc. models
100
100
  - [beerdb gem](http://rubygems.org/gems/beerdb) - beer, brand, brewery, etc. models
101
101
 
102
102
 
103
- ## Alternatives
104
-
105
-
106
- ### Tags
107
-
108
- - [gutentag](https://github.com/pat/gutentag)
109
-
110
- ~~~
111
- create_table :taggings do |t|
112
- t.integer :tag_id, null: false
113
- t.integer :taggable_id, null: false
114
- t.string :taggable_type, null: false
115
- t.timestamps
116
- end
117
-
118
- create_table :tags do |t|
119
- t.string :name, null: false
120
- t.integer :taggings_count, null: false, default: 0
121
- t.timestamps
122
- end
123
- ~~~
124
-
125
-
126
- - [acts_as_taggable_on](https://github.com/mbleigh/acts-as-taggable-on)
127
-
128
- ~~~
129
- create_table :tags do |t|
130
- t.string :name
131
- end
132
-
133
- create_table :taggings do |t|
134
- t.references :tag
135
- t.references :taggable, polymorphic: true
136
- t.references :tagger, polymorphic: true
137
- t.string :context, limit: 128
138
- t.datetime :created_at
139
- end
140
- ~~~
141
-
142
- (Source: [db/migrate/1_acts_as_taggable_on_migration.rb](https://github.com/mbleigh/acts-as-taggable-on/blob/master/db/migrate/1_acts_as_taggable_on_migration.rb))
143
-
144
-
145
- - [is_taggable](https://github.com/jamesgolick/is_taggable)
146
-
147
- ~~~
148
- create_table :tags do |t|
149
- t.string :name, default: ''
150
- t.string :kind, default: ''
151
- end
152
-
153
- create_table :taggings do |t|
154
- t.integer :tag_id
155
-
156
- t.string :taggable_type, default: ''
157
- t.integer :taggable_id
158
- end
159
- ~~~
160
-
161
- (Source: [generators/is_taggable_migration/templates/migration.rb](https://github.com/jamesgolick/is_taggable/blob/master/generators/is_taggable_migration/templates/migration.rb))
162
-
163
- - [rocket_tag](https://github.com/bradphelan/rocket_tag)
164
-
165
- ~~~
166
- create_table :tags do |t|
167
- t.string :name
168
- end
169
-
170
- create_table :taggings do |t|
171
- t.references :tag
172
- t.references :taggable, polymorphic: true
173
- t.references :tagger, polymorphic: true
174
- t.string :context
175
- t.datetime :created_at
176
- end
177
-
178
- create_table :alias_tags, :id => false do |t|
179
- t.integer :tag_id
180
- t.integer :alias_id
181
- end
182
- ~~~
183
-
184
- (Source: [generators/rocket_tag/migration/templates/active_record/migration.rb](https://github.com/bradphelan/rocket_tag/blob/master/lib/generators/rocket_tag/migration/templates/active_record/migration.rb))
185
-
186
-
187
- - [acts_as_taggable_redux](https://github.com/geemus/acts_as_taggable_redux)
188
-
189
- ~~~
190
- create_table :tags do |t|
191
- t.string :name
192
- t.integer :taggings_count, null: false, default: 0
193
- end
194
-
195
- create_table :taggings do |t|
196
- t.integer :tag_id
197
- t.integer :taggable_id
198
- t.string :taggable_type
199
- t.integer :user_id
200
- end
201
- ~~~
202
-
203
- (Source: [generators/acts_as_taggable_tables/templates/migration.rb](https://github.com/geemus/acts_as_taggable_redux/blob/master/generators/acts_as_taggable_tables/templates/migration.rb))
204
-
205
-
206
- - [acts_as_taggable_on_steroids](https://github.com/mattetti/acts_as_taggable_on_steroids)
207
-
208
- ~~~
209
- create_table :tags do |t|
210
- t.string :name
211
- end
212
-
213
- create_table :taggings do |t|
214
- t.integer :tag_id
215
- t.integer :taggable_id
216
- t.string :taggable_type
217
-
218
- t.datetime :created_at
219
- end
220
- ~~~
221
-
222
- (Source: [generators/acts_as_taggable_migration/templates/migration.rb](https://github.com/mattetti/acts_as_taggable_on_steroids/blob/master/generators/acts_as_taggable_migration/templates/migration.rb))
223
-
224
-
225
- - [Ruby Toolbook - Rails Tagging Category](https://www.ruby-toolbox.com/categories/rails_tagging)
226
-
227
-
228
- ### Categories
229
-
230
- - [categoryz3](https://github.com/tscolari/categoryz3)
231
-
232
- ~~~
233
- create_table :categoryz3_categories do |t|
234
- t.string :name
235
- t.references :parent
236
- t.integer :items_count, default: 0
237
- t.integer :child_items_count, default: 0
238
- t.integer :childrens_count, default: 0
239
- t.timestamps
240
- end
241
-
242
- create_table :categoryz3_items do |t|
243
- t.references :category, null: false
244
- t.references :categorizable, null: false, polymorphic: true
245
- t.timestamps
246
- end
247
-
248
- create_table :categoryz3_child_items do |t|
249
- t.references :category, null: false
250
- t.references :categorizable, null: false, polymorphic: true
251
- t.references :master_item, null: false
252
- t.timestamps
253
- end
254
- ~~~
255
-
256
- - [categorizable](https://github.com/boof/categorizable)
257
-
258
- ~~~
259
- create_table :categories do |t|
260
- t.string :name, null: false
261
- t.timestamps
262
- end
263
-
264
- create_table :categorizations do |t|
265
- t.references :category, null: false
266
- t.references :categorizable, null: false, :polymorphic: true
267
- t.timestamps
268
- end
269
- ~~~
270
-
271
- - [acts_as_category](https://github.com/wuwx/acts_as_category)
272
-
273
-
274
103
  ## License
275
104
 
276
105
  The `tagutils` scripts are dedicated to the public domain.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.spec 'tagutils' do
11
11
  self.urls = ['https://github.com/rubylibs/tagutils']
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'openmundi@googlegroups.com'
14
+ self.email = 'ruby-talk@ruby-lang.org'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -19,15 +19,15 @@ Hoe.spec 'tagutils' do
19
19
 
20
20
  self.extra_deps = [
21
21
  ['activerecord' ],
22
- ['props', '>=1.1.2'],
22
+ ['props', '>=1.2.0'],
23
23
  ['logutils', '>= 0.6.1'],
24
- ['textutils', '>=0.10.0']
24
+ ['textutils', '>=1.4.0'] ## fix - do NOT depend on textutils - why? why not?
25
25
  ]
26
26
 
27
27
  self.licenses = ['Public Domain']
28
28
 
29
29
  self.spec_extras = {
30
- required_ruby_version: '>= 1.9.2'
30
+ required_ruby_version: '>= 2.3'
31
31
  }
32
32
 
33
33
 
@@ -19,8 +19,8 @@ end
19
19
  add_index :categories, :key, unique: true
20
20
 
21
21
  create_table :categorizations do |t|
22
- t.references :category, null: false
23
- t.references :categorizable, null: false, polymorphic: true
22
+ t.references :category, null: false, index: false ## Note: do NOT auto-add index
23
+ t.references :categorizable, null: false, index: false, polymorphic: true ## Note: do NOT auto-add index
24
24
 
25
25
  # todo: use only t.datetime :created_at (do we get ar magic? is updated used/needed??)
26
26
  t.timestamps
@@ -11,26 +11,28 @@ create_table :tags do |t|
11
11
  t.string :key, null: false
12
12
  t.string :slug, null: false
13
13
  t.string :name # todo: make required? -- note: was title formerly
14
- t.integer :grade, null: false, default: 1 # grade/tier e.g. 1/2/3 for now
14
+ t.integer :grade, null: false, default: 1 # grade/tier e.g. 1/2/3 for now - rename to rank why? why not??
15
15
 
16
- # parent used for hierachy (e.g. lets you use tag stacks/packs etc.)
17
- t.references :parent
16
+
17
+ # parent used for hierarchy (e.g. lets you use tag stacks/packs etc.)
18
+ t.references :parent ## foreign_key: true -- check/todo: add foreign_key, add index: false - why? why not?
18
19
 
19
20
  # todo: use only t.datetime :created_at (do we get ar magic? is updated used/needed??)
20
21
  t.timestamps
21
22
  end
22
23
 
24
+
23
25
  add_index :tags, :key, unique: true
24
26
 
25
27
  create_table :taggings do |t|
26
- t.references :tag, null: false
27
- t.references :taggable, null: false, polymorphic: true
28
+ t.references :tag, null: false, index: false ## Note: do NOT auto-add index
29
+ t.references :taggable, null: false, index: false, polymorphic: true ## Note: do NOT auto-add index
28
30
 
29
31
  # todo: use only t.datetime :created_at (do we get ar magic? is updated used/needed??)
30
32
  t.timestamps
31
33
  end
32
34
 
33
- add_index :taggings, :tag_id
35
+ add_index :taggings, :tag_id ## note: add index "by hand" in AR5.0 gets auto-added (use index: false!!!)
34
36
  add_index :taggings, [:taggable_id, :taggable_type]
35
37
  add_index :taggings, [:taggable_id, :taggable_type, :tag_id], unique: true
36
38
 
@@ -1,5 +1,4 @@
1
1
 
2
2
  module TagUtils
3
- VERSION = '0.3.0'
3
+ VERSION = '1.0.0'
4
4
  end
5
-
@@ -10,8 +10,8 @@ require 'minitest/autorun'
10
10
 
11
11
  require 'tagutils'
12
12
 
13
- require 'logutils/activerecord' # NB: explict require required for LogDb (not automatic)
14
- require 'props/activerecord' # NB: explict require required for ConfDb (not automatic)
13
+ require 'logutils/activerecord' # NB: explict require required for LogDb (not automatic)
14
+ require 'props/activerecord' # NB: explict require required for ConfDb (not automatic)
15
15
 
16
16
 
17
17
 
@@ -28,18 +28,20 @@ class Movie < ActiveRecord::Base
28
28
  end
29
29
 
30
30
 
31
- class CreateMovieDb < ActiveRecord::Migration
31
+ class CreateMovieDb
32
32
 
33
33
  def up
34
- create_table :movies do |t|
35
- t.string :key, null: false
36
- t.string :name, null: false
37
- t.timestamps
38
- end
34
+ ActiveRecord::Schema.define do
35
+ create_table :movies do |t|
36
+ t.string :key, null: false
37
+ t.string :name, null: false
38
+ t.timestamps
39
+ end
40
+ end # Schema.define
39
41
  end # method up
40
42
 
41
- def down
42
- raise ActiveRecord::IrreversibleMigration
43
+ def self.create
44
+ self.new.up ## CreateMovieDb.new.up
43
45
  end
44
46
 
45
47
  end # class CreateMovieDb
@@ -70,7 +72,8 @@ def setup_in_memory_db
70
72
 
71
73
  TagDb.create
72
74
  CategoryDb.create
73
- CreateMovieDb.new.up
75
+
76
+ CreateMovieDb.create
74
77
  end
75
78
 
76
79
 
@@ -18,7 +18,7 @@ class TestTagReader < MiniTest::Test
18
18
  puts "[TestTagReader.test_read] path: #{path}"
19
19
 
20
20
  reader = TagDb::TagReader.from_file( path )
21
- reader.read()
21
+ reader.read
22
22
  end
23
23
 
24
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.2
33
+ version: 1.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.2
40
+ version: 1.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: logutils
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.0
61
+ version: 1.4.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.0
68
+ version: 1.4.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,16 +86,16 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.13'
89
+ version: '3.16'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.13'
96
+ version: '3.16'
97
97
  description: tagutils - tag utilities (tag, taggings, tag list, etc.)
98
- email: openmundi@googlegroups.com
98
+ email: ruby-talk@ruby-lang.org
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files:
@@ -103,7 +103,6 @@ extra_rdoc_files:
103
103
  - Manifest.txt
104
104
  - README.md
105
105
  files:
106
- - ".gemtest"
107
106
  - HISTORY.md
108
107
  - Manifest.txt
109
108
  - README.md
@@ -142,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
141
  requirements:
143
142
  - - ">="
144
143
  - !ruby/object:Gem::Version
145
- version: 1.9.2
144
+ version: '2.3'
146
145
  required_rubygems_version: !ruby/object:Gem::Requirement
147
146
  requirements:
148
147
  - - ">="
@@ -150,10 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
149
  version: '0'
151
150
  requirements: []
152
151
  rubyforge_project:
153
- rubygems_version: 2.4.2
152
+ rubygems_version: 2.5.2
154
153
  signing_key:
155
154
  specification_version: 4
156
155
  summary: tagutils - tag utilities (tag, taggings, tag list, etc.)
157
- test_files:
158
- - test/test_models.rb
159
- - test/test_tag_reader.rb
156
+ test_files: []
data/.gemtest DELETED
File without changes