entagging 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f9fa0e26bb1121d308c301a85c5fc258fa7203b129a09e8e66a02c60c74314d7
4
+ data.tar.gz: 372be013414b3056dacbdeef57805fe33904021b2c289b53499bf25864be81ab
5
+ SHA512:
6
+ metadata.gz: 71970c92b7a944571be07a82ae2b5584fb59a2350b78a57ba176b24a9a7d76339ccef61226b114fa905cc8064f647c0fcadeedc3f352d034daacd1ec530b66c1
7
+ data.tar.gz: 25dc1424003d7d3cdbac1e0cb9c8e30b08288704e610608cac55ba7140b15b1835ed272d145f4749a15a16317b7cd68b831ab4c68b071e1f9143b71ffea93726
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Entagging
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/entagging`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/entagging.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
9
+ require 'release/gem'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Entagging
4
+ VERSION = "0.1.1"
5
+ end
data/lib/entagging.rb ADDED
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'teLogger'
4
+ require 'toolrack'
5
+
6
+ require 'yaml'
7
+
8
+ require_relative "entagging/version"
9
+
10
+ module Entagging
11
+ include TR::CondUtils
12
+
13
+ class Error < StandardError; end
14
+ # Your code goes here...
15
+
16
+
17
+ module ClassMethods
18
+ include TR::CondUtils
19
+
20
+ def set_separator(sep)
21
+ @sep = sep
22
+ end
23
+
24
+ def separator
25
+ if is_empty?(@sep)
26
+ ","
27
+ else
28
+ @sep
29
+ end
30
+ end
31
+ end
32
+ def self.included(klas)
33
+ klas.extend(ClassMethods)
34
+ end
35
+ # end module ClassMethods
36
+
37
+
38
+ ## Instance methods
39
+ def add_tags(*str)
40
+ str.each do |s|
41
+ s.split(self.class.separator).each do |ts|
42
+ if not_empty?(ts)
43
+ _tags << ts.strip.downcase
44
+ end
45
+ end
46
+ end
47
+ end
48
+ alias_method :add_tag, :add_tags
49
+
50
+ def has_tag?(val)
51
+ if not_empty?(val)
52
+ _tags.include?(val.downcase)
53
+ else
54
+ false
55
+ end
56
+ end
57
+
58
+ def rm_tag(*tag)
59
+ tag.each do |t|
60
+ if not_empty?(t)
61
+ _tags.delete(t.downcase)
62
+ end
63
+ end
64
+ end
65
+ alias_method :rm_tags, :rm_tag
66
+
67
+ def replace_tag(src, target)
68
+ if has_tag?(src)
69
+ rm_tag(src)
70
+ add_tag(target)
71
+ end
72
+ end
73
+
74
+ def defined_tags
75
+ _tags.freeze
76
+ end
77
+
78
+ def dump_tags
79
+ YAML.dump(_tags)
80
+ end
81
+
82
+ def load_tags(str)
83
+ @_tags = YAML.unsafe_load(str)
84
+ end
85
+
86
+
87
+ def self.logger(tag = nil, &block)
88
+ if @_logger.nil?
89
+ @_logger = TeLogger::Tlogger.new
90
+ end
91
+
92
+ if block
93
+ if not_empty?(tag)
94
+ @_logger.with_tag(tag, &block)
95
+ else
96
+ @_logger.with_tag(@_logger.tag, &block)
97
+ end
98
+ else
99
+ if is_empty?(tag)
100
+ @_logger.tag = :tagging
101
+ @_logger
102
+ else
103
+ # no block but tag is given? hmm
104
+ @_logger.tag = tag
105
+ @_logger
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+
112
+ private
113
+ def _tags
114
+ if @_tags.nil?
115
+ @_tags = []
116
+ end
117
+ @_tags
118
+ end
119
+
120
+ end
data/sig/entagging.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Entagging
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: entagging
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: toolrack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.23'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.23'
27
+ - !ruby/object:Gem::Dependency
28
+ name: teLogger
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: release-gem
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ''
56
+ email:
57
+ - chris@antrapol.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - README.md
64
+ - Rakefile
65
+ - lib/entagging.rb
66
+ - lib/entagging/version.rb
67
+ - sig/entagging.rbs
68
+ homepage: ''
69
+ licenses: []
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.6.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.4.6
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Library processing tag on a record
90
+ test_files: []