rage_flip 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4b780908672f74c2712af5e8181f0d9cb4dbd16762c7f6cfeed78d1919de117
4
- data.tar.gz: 9195ac9f1f12a2158851f4ff8e14888a55bb967800a04496ade227ab16887e60
3
+ metadata.gz: 63cef068ded99a79213e516650f5c8af352e54d56b40fbac108655cf8534380b
4
+ data.tar.gz: 276ecb0beecce2fdd08eeb99d42a41ced8eff9701a15ef060171ff8b416d617f
5
5
  SHA512:
6
- metadata.gz: 01ab12c8e8b0d5a211d00a0debaf91084b4581812810f9681c874fc8bdeeaed913d3351779b0d17df5c2ce2ebae45fae2f647df525c478b1114e47d1523194e7
7
- data.tar.gz: fb9930f012419ba490887f7b292c85e2b6cbce3cf6837fd417f4c25f80d3af010fd09a945ffa4c043d062b760f3b0625ddbac8ad94aa7e9e44111b3c69369a68
6
+ metadata.gz: 58ad3abfe8d692cc13f3ab14131f58426f3a7e6463cab8d8442a217025ec16ddbe2eabe7e5e0f507a2f2ff02591c353318205200a2c499b121979e5846d9dcef
7
+ data.tar.gz: bcb13ace487889aab8f435693ebd79f6d8aa23c35f91a33396520e32b7df36bb1df9ef4decd28ce00cc2383cf48de4e804bdb6261ca3640445a7955ee0f03b8b
data/README.md CHANGED
@@ -86,13 +86,15 @@ chaos "chaotic text"
86
86
  # Output: c̸̰̈h̴̲̆a̷̰̋ò̶̰ẗ̸̲ḭ̷̋c̶̰̈ ̸̰̈t̷̰̋ĕ̴̲ẍ̸̰t̷̰̋
87
87
  ```
88
88
 
89
- The chaos level can be controlled with the `CHAOS_LEVEL` environment variable or the `chaos_level` command.
89
+ The chaos level is persistently stored in `~/.chaos_level.txt` and can be controlled with the `chaos_level` command.
90
90
 
91
91
  ### chaos_level
92
92
 
93
93
  Controls the chaos level for the chaos command:
94
94
 
95
95
  ```bash
96
+ chaos_level # Show current chaos level
97
+ chaos_level show # Show current chaos level
96
98
  chaos_level more # Increase chaos level by 1
97
99
  chaos_level less # Decrease chaos level by 1
98
100
  chaos_level 15 # Set chaos level to 15
@@ -119,9 +121,9 @@ The flip functionality uses comprehensive character mappings including:
119
121
  - Common punctuation and symbols
120
122
  - Special Unicode characters for upside-down equivalents
121
123
 
122
- ## Environment Variables
124
+ ## Persistent Settings
123
125
 
124
- - `CHAOS_LEVEL`: Controls the intensity of the chaos effect (default: 10)
126
+ - **Chaos Level**: Stored in `~/.chaos_level.txt` and controls the intensity of the chaos effect (default: 10). This setting persists across terminal sessions and system reboots.
125
127
 
126
128
  ## Library Usage
127
129
 
data/exe/chaos CHANGED
@@ -9,8 +9,7 @@ if text.empty?
9
9
  exit 1
10
10
  end
11
11
 
12
- chaos_level = ENV['CHAOS_LEVEL']&.to_i || 10
13
- result = RageFlip::Chaos.process(text, chaos_level)
12
+ result = RageFlip::Chaos.process(text)
14
13
 
15
14
  if RageFlip::Clipboard.copy(result)
16
15
  puts result
data/exe/chaos_level CHANGED
@@ -2,14 +2,24 @@
2
2
 
3
3
  require_relative '../lib/rage_flip'
4
4
 
5
- if ARGV.length != 1
6
- puts "Usage: chaos_level <more|less|number>"
7
- puts " more - Increase chaos level by 1"
8
- puts " less - Decrease chaos level by 1"
9
- puts " number - Set chaos level to specific number"
5
+ if ARGV.length == 0
6
+ puts "Current chaos level: #{RageFlip::Chaos.current_chaos_level}"
7
+ exit 0
8
+ elsif ARGV.length != 1
9
+ puts "Usage: chaos_level [more|less|number|show]"
10
+ puts " (no args) - Show current chaos level"
11
+ puts " more - Increase chaos level by 1"
12
+ puts " less - Decrease chaos level by 1"
13
+ puts " number - Set chaos level to specific number"
14
+ puts " show - Show current chaos level"
10
15
  exit 1
11
16
  end
12
17
 
13
18
  instruction = ARGV[0]
14
- result = RageFlip::Chaos.set_chaos_level(instruction)
15
- puts result
19
+
20
+ if instruction == 'show'
21
+ puts "Current chaos level: #{RageFlip::Chaos.current_chaos_level}"
22
+ else
23
+ result = RageFlip::Chaos.set_chaos_level(instruction)
24
+ puts result
25
+ end
@@ -1,9 +1,10 @@
1
1
  module RageFlip
2
2
  class Chaos
3
3
  DEFAULT_CHAOS_LEVEL = 10
4
+ CHAOS_LEVEL_FILE = File.expand_path("~/.chaos_level.txt")
4
5
 
5
6
  def self.process(text, chaos_level = nil)
6
- chaos_level ||= ENV['CHAOS_LEVEL']&.to_i || DEFAULT_CHAOS_LEVEL
7
+ chaos_level ||= read_chaos_level
7
8
 
8
9
  text.each_char.map do |c|
9
10
  combining_chars = rand(1..chaos_level).times.map do
@@ -14,18 +15,39 @@ module RageFlip
14
15
  end
15
16
 
16
17
  def self.set_chaos_level(instruction)
17
- current_level = ENV['CHAOS_LEVEL']&.to_i || DEFAULT_CHAOS_LEVEL
18
+ current_level = read_chaos_level
18
19
 
19
20
  case instruction
20
21
  when 'more'
21
- ENV['CHAOS_LEVEL'] = (current_level + 1).to_s
22
+ new_level = current_level + 1
22
23
  when 'less'
23
- ENV['CHAOS_LEVEL'] = (current_level - 1).to_s
24
+ new_level = [current_level - 1, 1].max # Don't go below 1
24
25
  else
25
- ENV['CHAOS_LEVEL'] = instruction.to_s
26
+ new_level = instruction.to_i
27
+ if new_level <= 0
28
+ return "Error: Chaos level must be a positive number"
29
+ end
26
30
  end
27
31
 
28
- "chaos level is now #{ENV['CHAOS_LEVEL']}"
32
+ write_chaos_level(new_level)
33
+ "chaos level is now #{new_level}"
34
+ end
35
+
36
+ def self.read_chaos_level
37
+ if File.exist?(CHAOS_LEVEL_FILE)
38
+ level = File.read(CHAOS_LEVEL_FILE).strip.to_i
39
+ level > 0 ? level : DEFAULT_CHAOS_LEVEL
40
+ else
41
+ DEFAULT_CHAOS_LEVEL
42
+ end
43
+ end
44
+
45
+ def self.write_chaos_level(level)
46
+ File.write(CHAOS_LEVEL_FILE, level.to_s)
47
+ end
48
+
49
+ def self.current_chaos_level
50
+ read_chaos_level
29
51
  end
30
52
  end
31
53
  end
@@ -1,3 +1,3 @@
1
1
  module RageFlip
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -53,19 +53,68 @@ RSpec.describe RageFlip do
53
53
  end
54
54
 
55
55
  describe RageFlip::Chaos do
56
+ let(:chaos_file) { File.expand_path("~/.chaos_level.txt") }
57
+
58
+ before do
59
+ # Clean up chaos file before each test
60
+ File.delete(chaos_file) if File.exist?(chaos_file)
61
+ end
62
+
63
+ after do
64
+ # Clean up chaos file after each test
65
+ File.delete(chaos_file) if File.exist?(chaos_file)
66
+ end
67
+
56
68
  describe '.process' do
57
69
  it 'adds combining characters for chaos effect' do
58
70
  result = RageFlip::Chaos.process('test', 5)
59
71
  expect(result.length).to be > 4 # Should be longer than original
60
72
  end
73
+
74
+ it 'uses default chaos level when no file exists' do
75
+ result = RageFlip::Chaos.process('test')
76
+ expect(result.length).to be > 4 # Should be longer than original
77
+ end
61
78
  end
62
79
 
63
80
  describe '.set_chaos_level' do
64
81
  it 'sets chaos level to specific number' do
65
82
  result = RageFlip::Chaos.set_chaos_level('15')
66
- expect(ENV['CHAOS_LEVEL']).to eq('15')
83
+ expect(File.read(chaos_file).strip).to eq('15')
67
84
  expect(result).to eq('chaos level is now 15')
68
85
  end
86
+
87
+ it 'increases chaos level with more' do
88
+ RageFlip::Chaos.set_chaos_level('10')
89
+ result = RageFlip::Chaos.set_chaos_level('more')
90
+ expect(File.read(chaos_file).strip).to eq('11')
91
+ expect(result).to eq('chaos level is now 11')
92
+ end
93
+
94
+ it 'decreases chaos level with less' do
95
+ RageFlip::Chaos.set_chaos_level('10')
96
+ result = RageFlip::Chaos.set_chaos_level('less')
97
+ expect(File.read(chaos_file).strip).to eq('9')
98
+ expect(result).to eq('chaos level is now 9')
99
+ end
100
+
101
+ it 'does not go below 1' do
102
+ RageFlip::Chaos.set_chaos_level('1')
103
+ result = RageFlip::Chaos.set_chaos_level('less')
104
+ expect(File.read(chaos_file).strip).to eq('1')
105
+ expect(result).to eq('chaos level is now 1')
106
+ end
107
+ end
108
+
109
+ describe '.read_chaos_level' do
110
+ it 'returns default when file does not exist' do
111
+ expect(RageFlip::Chaos.read_chaos_level).to eq(10)
112
+ end
113
+
114
+ it 'reads level from file when it exists' do
115
+ File.write(chaos_file, '25')
116
+ expect(RageFlip::Chaos.read_chaos_level).to eq(25)
117
+ end
69
118
  end
70
119
  end
71
120
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Powell