collect_first_word_of_case_menu 0.0.7

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: f8af505cbffe44c84aed0e081698d6e80aa7503a14651db825d661da7fba4753
4
+ data.tar.gz: f3cd9008b0e3dcfe390c0113207b39c90c7e7504d17ab92ac16f28a5fdd3cb60
5
+ SHA512:
6
+ metadata.gz: de8f5ac7d8ba46c5d2f39a61c9837d1eb236fe61a2d4a4cae10d8eb250a423f701ba3ba3723a97155eb177c36c2307cc04b2fc360158076cbd216eb777c9fbf5
7
+ data.tar.gz: 17b319717bb70d5279773644cad7e8b70e2ab0d7482623f5eb769d287d6e4d7ef33319b1974522d6086c3af75364ff474d07b1196d0058dfd66ecc70c9c2566a
@@ -0,0 +1,44 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project CollectFirstWordOfCaseMenu.
3
+ # =========================================================================== #
4
+ Gem::Specification.new { |s|
5
+
6
+ s.name = 'collect_first_word_of_case_menu'
7
+ s.version = '0.0.7'
8
+ s.date = Time.now.strftime('%Y-%m-%d')
9
+
10
+ s.summary = <<-EOF
11
+
12
+ This class shall be able to collect all first entries
13
+ in a case menu.
14
+
15
+ If you have specific suggestions to make this gem more
16
+ useful for others, please drop me an email at:
17
+ shevegen@gmail.com
18
+ Thank you.
19
+ EOF
20
+
21
+ s.description = <<-EOF
22
+
23
+ This class shall be able to collect all first entries
24
+ in a case menu.
25
+
26
+ This library is called collect_first_word_of_case_menu
27
+ EOF
28
+
29
+ s.extra_rdoc_files = %w()
30
+
31
+ s.authors = ['Robert A. Heiler']
32
+ s.email = 'shevegen@gmail.com'
33
+ s.files = Dir.glob('**/*')
34
+ s.license = 'GPL-2.0'
35
+ s.homepage = 'http://rubygems.org/gems/collect_first_word_of_case_menu'
36
+
37
+ s.required_ruby_version = '>= '+RUBY_VERSION
38
+ s.required_rubygems_version = '>= '+Gem::VERSION
39
+ s.rubygems_version = '>= '+Gem::VERSION
40
+
41
+ s.add_dependency 'colours'
42
+ s.add_dependency 'convert_global_env'
43
+
44
+ }
@@ -0,0 +1,143 @@
1
+ #!/System/Index/bin/ruby -w
2
+ # Encoding: ISO-8859-1
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === CollectFirstWordOfCaseMenu
6
+ #
7
+ # This file will give us an Array of "when" words.
8
+ #
9
+ # Usage examples:
10
+ # GetFirstWordOfCaseMenu.new
11
+ # =========================================================================== #
12
+ begin
13
+ require 'colours'
14
+ rescue LoadError; end
15
+ require 'convert_global_env'
16
+
17
+ class CollectFirstWordOfCaseMenu # require 'collect_first_word_of_case_menu'; GetFirstWordOfCaseMenu.new
18
+
19
+ include Colours
20
+
21
+ # ========================================================================= #
22
+ # Test it via compile.rb.
23
+ # ========================================================================= #
24
+ DEFAULT_FILE = ENV['RBT'].to_s+'/compile.rb'
25
+
26
+ attr_reader :result # Has the results.
27
+
28
+ # ========================================================================= #
29
+ # === initialize
30
+ #
31
+ # The first argument specifies the .rb file in question from where we
32
+ # try to find the case/when structure.
33
+ # ========================================================================= #
34
+ def initialize(
35
+ this_file = nil,
36
+ run_already = true
37
+ )
38
+ reset
39
+ set_read_this_file(this_file)
40
+ run if run_already
41
+ end
42
+
43
+ # ========================================================================= #
44
+ # === reset
45
+ # ========================================================================= #
46
+ def reset
47
+ @result = []
48
+ @array_all_with_words = []
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === convert_env
53
+ # ========================================================================= #
54
+ def convert_env(i)
55
+ return ConvertGlobalEnv.convert(i) # Always return it.
56
+ end
57
+
58
+ # ========================================================================= #
59
+ # === set_read_this_file
60
+ # ========================================================================= #
61
+ def set_read_this_file(i = nil) # some symbols are special keyword instructions.
62
+ i = DEFAULT_FILE if i.nil?
63
+ case i
64
+ when :beautiful_menu
65
+ _ = '$RSRC/beautiful_url/lib/beautiful_url/menu/beautiful_menu.rb'
66
+ i = convert_env(_)
67
+ end
68
+ @read_this_file = i
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === read_in_the_dataset
73
+ # ========================================================================= #
74
+ def read_in_the_dataset
75
+ @data = File.readlines(@read_this_file).sort
76
+ end
77
+
78
+ # ========================================================================= #
79
+ # === add
80
+ # ========================================================================= #
81
+ def add(i)
82
+ if i.include? '/' # Assume we give a regex. In this case we do not continue.
83
+ else
84
+ @array_all_with_words << i
85
+ end
86
+ end
87
+ # === assign_result
88
+ def assign_result
89
+ @result = @array_all_with_words
90
+ end
91
+
92
+ # ========================================================================= #
93
+ # === report_result
94
+ # ========================================================================= #
95
+ def report_result
96
+ if @array_all_with_words.empty?
97
+ e 'Unfortunately we found no entry.'
98
+ else
99
+ e 'The results are:'
100
+ @array_all_with_words.each {|entry| e ' '+entry }
101
+ end
102
+ end
103
+
104
+ # ========================================================================= #
105
+ # === cleanup
106
+ # ========================================================================= #
107
+ def cleanup # get rid of some things.
108
+ remove_instance_variable(:@data)
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === work_through_dataset
113
+ # ========================================================================= #
114
+ def work_through_dataset
115
+ @data.sort.each {|line|
116
+ if line =~ /when /
117
+ line = line.strip
118
+ next if line.start_with? '#'
119
+ line = line.gsub(/when /,'')
120
+ splitted = line
121
+ splitted = splitted.split(',')[0] if splitted.include? ','
122
+ splitted = splitted.delete("'") if splitted.include? "'"
123
+ add splitted
124
+ end
125
+ }
126
+ end
127
+
128
+ # ========================================================================= #
129
+ # === run
130
+ # ========================================================================= #
131
+ def run # (run tag)
132
+ read_in_the_dataset
133
+ work_through_dataset
134
+ assign_result
135
+ cleanup
136
+ end
137
+
138
+ end
139
+
140
+ if __FILE__ == $PROGRAM_NAME
141
+ _ = CollectFirstWordOfCaseMenu.new(ARGV.first)
142
+ _.report_result
143
+ end # gword $RSRC/beautiful_url/lib/beautiful_url/beautiful_menu.rb
@@ -0,0 +1 @@
1
+ require 'collect_first_word_of_case_menu/collect_first_word_of_case_menu.rb'
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: collect_first_word_of_case_menu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colours
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
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: convert_global_env
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |2
42
+
43
+ This class shall be able to collect all first entries
44
+ in a case menu.
45
+
46
+ This library is called collect_first_word_of_case_menu
47
+ email: shevegen@gmail.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - collect_first_word_of_case_menu.gemspec
53
+ - lib/collect_first_word_of_case_menu.rb
54
+ - lib/collect_first_word_of_case_menu/collect_first_word_of_case_menu.rb
55
+ homepage: http://rubygems.org/gems/collect_first_word_of_case_menu
56
+ licenses:
57
+ - GPL-2.0
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.3
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.0.3
73
+ requirements: []
74
+ rubygems_version: 3.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: 'This class shall be able to collect all first entries in a case menu. If
78
+ you have specific suggestions to make this gem more useful for others, please drop
79
+ me an email at: shevegen@gmail.com Thank you.'
80
+ test_files: []