tagutils 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +4 -2
- data/lib/tagutils.rb +2 -7
- data/lib/tagutils/tags/readers/tag.rb +36 -11
- data/lib/tagutils/version.rb +1 -1
- data/test/helper.rb +3 -16
- data/test/test_models.rb +1 -1
- data/test/test_tag_reader.rb +7 -5
- metadata +67 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e34415c99adfedcb4bd078a328b52a7c9f418931
|
4
|
+
data.tar.gz: ba4d539d363122e793a0b8fac7609025520623cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2ae676b1df654904a593519c0bfbb1874ebaaebf299977809b7c6ff007baef78be882d7ae00ffa1e1a662427b002131d7bc50c517f3a5946a5a1c5e7ffdef53
|
7
|
+
data.tar.gz: f262dc809c38d893e7020be236bbfa5c9cbcceac3f49a38d6fc746862f43f268ba69739d578b84c1ec84cd9dec892ae5ba63026e2c18e05abdcad2d071be86fa
|
data/Rakefile
CHANGED
@@ -19,13 +19,15 @@ Hoe.spec 'tagutils' do
|
|
19
19
|
|
20
20
|
self.extra_deps = [
|
21
21
|
['activerecord' ],
|
22
|
-
['
|
22
|
+
['props', '>=1.1.2'],
|
23
|
+
['logutils', '>= 0.6.1'],
|
24
|
+
['textutils', '>=0.10.0']
|
23
25
|
]
|
24
26
|
|
25
27
|
self.licenses = ['Public Domain']
|
26
28
|
|
27
29
|
self.spec_extras = {
|
28
|
-
:
|
30
|
+
required_ruby_version: '>= 1.9.2'
|
29
31
|
}
|
30
32
|
|
31
33
|
|
data/lib/tagutils.rb
CHANGED
@@ -4,15 +4,9 @@
|
|
4
4
|
require 'active_record' ## todo: add sqlite3? etc.
|
5
5
|
|
6
6
|
require 'props'
|
7
|
-
require 'props/db' # note: also use ConfDb (ConfDb::Model::Prop etc.)
|
8
7
|
require 'logutils'
|
9
8
|
require 'textutils'
|
10
9
|
|
11
|
-
#########
|
12
|
-
# fix/todo:
|
13
|
-
# move props/db - Props.create_from_fixture! to textutils/db
|
14
|
-
# require 'textutils/db'
|
15
|
-
|
16
10
|
|
17
11
|
# our own code
|
18
12
|
|
@@ -43,4 +37,5 @@ module TagUtils
|
|
43
37
|
end # module TagUtils
|
44
38
|
|
45
39
|
|
46
|
-
|
40
|
+
# say hello
|
41
|
+
puts TagUtils.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
|
@@ -16,20 +16,46 @@ class TagReader
|
|
16
16
|
include TextUtils::ValueHelper
|
17
17
|
|
18
18
|
|
19
|
-
|
19
|
+
def self.from_zip( zip_file, entry_path, more_attribs={} )
|
20
|
+
## get text content from zip
|
21
|
+
entry = zip_file.find_entry( entry_path )
|
20
22
|
|
23
|
+
text = entry.get_input_stream().read()
|
24
|
+
text = text.force_encoding( Encoding::UTF_8 )
|
25
|
+
|
26
|
+
self.from_string( text, more_attribs )
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.from_file( path, more_attribs={} )
|
30
|
+
## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
|
31
|
+
## - see textutils/utils.rb
|
32
|
+
text = File.read_utf8( path )
|
33
|
+
|
34
|
+
self.from_string( text, more_attribs )
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.from_string( text, more_attribs={} )
|
38
|
+
TagReader.new( text, more_attribs )
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def initialize( text, more_attribs={} )
|
43
|
+
## todo/fix: how to add opts={} ???
|
44
|
+
@text = text
|
45
|
+
@more_attribs = more_attribs
|
46
|
+
end
|
47
|
+
|
48
|
+
## fix: for now no way to pass in opts hash
|
21
49
|
def strict?() @strict == true; end
|
22
50
|
|
23
|
-
def
|
24
|
-
|
51
|
+
def initialize_old_removeeeee( include_path, opts = {} )
|
25
52
|
@include_path = include_path
|
26
53
|
|
27
54
|
## option: for now issue warning on update, that is, if key/record (country,region,city) already exists
|
28
55
|
@strict = opts[:strict].present? ? true : false
|
29
56
|
end
|
30
57
|
|
31
|
-
|
32
|
-
def read( name )
|
58
|
+
def read_old_removeeee( name )
|
33
59
|
## check for grade in name e.g. tag.1, tag.2 etc.
|
34
60
|
|
35
61
|
if name =~ /^tag.*\.(\d)$/
|
@@ -40,14 +66,13 @@ class TagReader
|
|
40
66
|
end
|
41
67
|
|
42
68
|
|
43
|
-
def
|
44
|
-
|
45
|
-
reader = HashReaderV2.new( name, include_path )
|
69
|
+
def read()
|
70
|
+
reader = HashReader.from_string( @text ) # NOTE: for now HashReader does NOT accept 2nd more_attributes para - check back later
|
46
71
|
|
47
72
|
grade = 1
|
48
73
|
|
49
|
-
if more_attribs[:grade].present?
|
50
|
-
grade = more_attribs[:grade].to_i
|
74
|
+
if @more_attribs[:grade].present?
|
75
|
+
grade = @more_attribs[:grade].to_i
|
51
76
|
end
|
52
77
|
|
53
78
|
reader.each do |key, value|
|
@@ -93,7 +118,7 @@ class TagReader
|
|
93
118
|
end
|
94
119
|
end # each key,value
|
95
120
|
|
96
|
-
end # method
|
121
|
+
end # method read
|
97
122
|
|
98
123
|
|
99
124
|
end # class TagReader
|
data/lib/tagutils/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -3,28 +3,15 @@
|
|
3
3
|
|
4
4
|
## minitest setup
|
5
5
|
|
6
|
-
# require 'minitest/unit'
|
7
6
|
require 'minitest/autorun'
|
8
7
|
|
9
|
-
# include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
|
10
|
-
|
11
|
-
|
12
|
-
# ruby stdlibs
|
13
|
-
|
14
|
-
require 'json'
|
15
|
-
require 'uri'
|
16
|
-
require 'pp'
|
17
|
-
require 'logger'
|
18
|
-
|
19
|
-
# ruby gems
|
20
|
-
|
21
|
-
require 'active_record'
|
22
|
-
|
23
8
|
|
24
9
|
# our own code
|
25
10
|
|
26
11
|
require 'tagutils'
|
27
|
-
|
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)
|
28
15
|
|
29
16
|
|
30
17
|
|
data/test/test_models.rb
CHANGED
data/test/test_tag_reader.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'helper'
|
4
4
|
|
5
|
-
class TestTagReader < MiniTest::
|
5
|
+
class TestTagReader < MiniTest::Test
|
6
6
|
|
7
7
|
def setup
|
8
8
|
TagDb.delete!
|
@@ -13,10 +13,12 @@ class TestTagReader < MiniTest::Unit::TestCase
|
|
13
13
|
|
14
14
|
def test_read
|
15
15
|
include_path = "#{TagUtils.root}/test"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
|
17
|
+
path = "#{include_path}/tags.1.yml"
|
18
|
+
puts "[TestTagReader.test_read] path: #{path}"
|
19
|
+
|
20
|
+
reader = TagDb::TagReader.from_file( path )
|
21
|
+
reader.read()
|
20
22
|
end
|
21
23
|
|
22
24
|
|
metadata
CHANGED
@@ -1,60 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gerald Bauer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-04
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: props
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.2
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
42
|
name: logutils
|
27
|
-
requirement:
|
28
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: textutils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
29
58
|
requirements:
|
30
|
-
- -
|
59
|
+
- - ">="
|
31
60
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
61
|
+
version: 0.10.0
|
33
62
|
type: :runtime
|
34
63
|
prerelease: false
|
35
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.0
|
36
69
|
- !ruby/object:Gem::Dependency
|
37
70
|
name: rdoc
|
38
|
-
requirement:
|
39
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
40
72
|
requirements:
|
41
|
-
- - ~>
|
73
|
+
- - "~>"
|
42
74
|
- !ruby/object:Gem::Version
|
43
75
|
version: '4.0'
|
44
76
|
type: :development
|
45
77
|
prerelease: false
|
46
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
47
83
|
- !ruby/object:Gem::Dependency
|
48
84
|
name: hoe
|
49
|
-
requirement:
|
50
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
51
86
|
requirements:
|
52
|
-
- - ~>
|
87
|
+
- - "~>"
|
53
88
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
89
|
+
version: '3.13'
|
55
90
|
type: :development
|
56
91
|
prerelease: false
|
57
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.13'
|
58
97
|
description: tagutils - tag utilities (tag, taggings, tag list, etc.)
|
59
98
|
email: openmundi@googlegroups.com
|
60
99
|
executables: []
|
@@ -64,6 +103,7 @@ extra_rdoc_files:
|
|
64
103
|
- Manifest.txt
|
65
104
|
- README.md
|
66
105
|
files:
|
106
|
+
- ".gemtest"
|
67
107
|
- HISTORY.md
|
68
108
|
- Manifest.txt
|
69
109
|
- README.md
|
@@ -88,33 +128,31 @@ files:
|
|
88
128
|
- test/tags.1.yml
|
89
129
|
- test/test_models.rb
|
90
130
|
- test/test_tag_reader.rb
|
91
|
-
- .gemtest
|
92
131
|
homepage: https://github.com/rubylibs/tagutils
|
93
132
|
licenses:
|
94
133
|
- Public Domain
|
134
|
+
metadata: {}
|
95
135
|
post_install_message:
|
96
136
|
rdoc_options:
|
97
|
-
- --main
|
137
|
+
- "--main"
|
98
138
|
- README.md
|
99
139
|
require_paths:
|
100
140
|
- lib
|
101
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
142
|
requirements:
|
104
|
-
- -
|
143
|
+
- - ">="
|
105
144
|
- !ruby/object:Gem::Version
|
106
145
|
version: 1.9.2
|
107
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
147
|
requirements:
|
110
|
-
- -
|
148
|
+
- - ">="
|
111
149
|
- !ruby/object:Gem::Version
|
112
150
|
version: '0'
|
113
151
|
requirements: []
|
114
152
|
rubyforge_project:
|
115
|
-
rubygems_version:
|
153
|
+
rubygems_version: 2.4.2
|
116
154
|
signing_key:
|
117
|
-
specification_version:
|
155
|
+
specification_version: 4
|
118
156
|
summary: tagutils - tag utilities (tag, taggings, tag list, etc.)
|
119
157
|
test_files:
|
120
158
|
- test/test_models.rb
|