mirror of https://github.com/Calamitous/iris.git
Fix bug where "hostname" portion of author is missing or garbled
This commit is contained in:
parent
2361933f81
commit
d744eb023d
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.1.2
|
||||||
|
* Fix bug where "hostname" portion of author is missing or garbled
|
||||||
|
|
||||||
## 1.1.1
|
## 1.1.1
|
||||||
* Make discarded message response more prominent
|
* Make discarded message response more prominent
|
||||||
* Try nano if /usr/bin/vim is not set
|
* Try nano if /usr/bin/vim is not set
|
||||||
|
|
18
README.md
18
README.md
|
@ -596,7 +596,7 @@ Iris must:
|
||||||
* Deleted or edited messages should leave flags or placeholders for other users to know that other content was there before.
|
* Deleted or edited messages should leave flags or placeholders for other users to know that other content was there before.
|
||||||
* The Iris client should expect that any message file could be missing, altered, or corrupted, and should handle those cases gracefully.
|
* The Iris client should expect that any message file could be missing, altered, or corrupted, and should handle those cases gracefully.
|
||||||
* Be portable
|
* Be portable
|
||||||
* All Iris files should be human-readable (and -editable, in a pinch)
|
* All Iris data files should be human-readable (and -editable, in a pinch)
|
||||||
* The use of the official Iris client should be optional for a user to manage his or her messages. A text editor should suffice.
|
* The use of the official Iris client should be optional for a user to manage his or her messages. A text editor should suffice.
|
||||||
* Other clients which follow the Iris file format should work seamlessly with the official Iris client.
|
* Other clients which follow the Iris file format should work seamlessly with the official Iris client.
|
||||||
* Be secure
|
* Be secure
|
||||||
|
@ -605,7 +605,7 @@ Iris must:
|
||||||
* Be a teacher
|
* Be a teacher
|
||||||
* Code should be clean, well-organized, and readable.
|
* Code should be clean, well-organized, and readable.
|
||||||
* Be limited in scope
|
* Be limited in scope
|
||||||
* The source code should not exceed 1,000 LOC
|
* The source code should not exceed 1,000 SLOC
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
|
@ -622,6 +622,20 @@ To run the tests:
|
||||||
ruby tests/iris_test.rb
|
ruby tests/iris_test.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Run options: --seed 11507
|
||||||
|
|
||||||
|
# Running:
|
||||||
|
|
||||||
|
.........................SSS.......SS.......S.....SSSSSSS....SSSSS
|
||||||
|
|
||||||
|
Finished in 0.107785s, 612.3294 runs/s, 677.2734 assertions/s.
|
||||||
|
|
||||||
|
66 runs, 73 assertions, 0 failures, 0 errors, 18 skips
|
||||||
|
|
||||||
|
You have skipped tests. Run with --verbose for details.
|
||||||
|
```
|
||||||
|
|
||||||
## Technical Bits
|
## Technical Bits
|
||||||
|
|
||||||
* [Dependencies](#dependencies)
|
* [Dependencies](#dependencies)
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -10,6 +10,8 @@
|
||||||
* Flesh out technical sections
|
* Flesh out technical sections
|
||||||
|
|
||||||
### Bugs
|
### Bugs
|
||||||
|
* Terrible slowdown when refreshing topics
|
||||||
|
* Performance is fine when no new topics show up
|
||||||
* Is `Time.now.utc.iso8601` working as expected?
|
* Is `Time.now.utc.iso8601` working as expected?
|
||||||
* Fix bug when people are posting from different time zones
|
* Fix bug when people are posting from different time zones
|
||||||
* Fix message ordering when editing/deleting multiple messages
|
* Fix message ordering when editing/deleting multiple messages
|
||||||
|
|
23
iris.rb
23
iris.rb
|
@ -27,13 +27,26 @@ class Config
|
||||||
HISTORY_FILE = "#{ENV['HOME']}/.iris.history"
|
HISTORY_FILE = "#{ENV['HOME']}/.iris.history"
|
||||||
IRIS_SCRIPT = __FILE__
|
IRIS_SCRIPT = __FILE__
|
||||||
|
|
||||||
USER = ENV['USER'] || ENV['LOGNAME'] || ENV['USERNAME']
|
|
||||||
HOSTNAME = `hostname -d`.chomp
|
|
||||||
AUTHOR = "#{USER}@#{HOSTNAME}"
|
|
||||||
ENV_EDITOR = ENV['EDITOR'].presence || `which nano`.chomp.presence
|
ENV_EDITOR = ENV['EDITOR'].presence || `which nano`.chomp.presence
|
||||||
|
|
||||||
@@debug_mode = false
|
@@debug_mode = false
|
||||||
|
|
||||||
|
def self.hostname
|
||||||
|
return @hostname if @hostname
|
||||||
|
|
||||||
|
hostname = `hostname`.chomp
|
||||||
|
hostname = 'localhost' if hostname.empty?
|
||||||
|
|
||||||
|
return @hostname = hostname if hostname == 'localhost'
|
||||||
|
|
||||||
|
@hostname = hostname.split('.')[-2..-1].compact.join('.')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.author
|
||||||
|
user = ENV['USER'] || ENV['LOGNAME'] || ENV['USERNAME']
|
||||||
|
@author ||= "#{user}@#{self.hostname}"
|
||||||
|
end
|
||||||
|
|
||||||
def self.find_files
|
def self.find_files
|
||||||
(`ls /home/**/.iris.messages`).split("\n")
|
(`ls /home/**/.iris.messages`).split("\n")
|
||||||
end
|
end
|
||||||
|
@ -343,7 +356,7 @@ end
|
||||||
class Message
|
class Message
|
||||||
attr_reader :timestamp, :edit_hash, :author, :parent, :message, :errors, :is_deleted
|
attr_reader :timestamp, :edit_hash, :author, :parent, :message, :errors, :is_deleted
|
||||||
|
|
||||||
def initialize(message, parent = nil, author = Config::AUTHOR, edit_hash = nil, timestamp = Time.now.utc.iso8601, is_deleted = nil)
|
def initialize(message, parent = nil, author = Config.author, edit_hash = nil, timestamp = Time.now.utc.iso8601, is_deleted = nil)
|
||||||
@message = message
|
@message = message
|
||||||
@parent = parent
|
@parent = parent
|
||||||
@author = author
|
@author = author
|
||||||
|
@ -890,7 +903,7 @@ class Interface
|
||||||
end
|
end
|
||||||
|
|
||||||
def prompt
|
def prompt
|
||||||
"#{Config::AUTHOR}~> "
|
"#{Config.author}~> "
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(args)
|
def initialize(args)
|
||||||
|
|
|
@ -24,16 +24,48 @@ describe Config do
|
||||||
_(Config::HISTORY_FILE).must_match /\/\.iris\.history$/
|
_(Config::HISTORY_FILE).must_match /\/\.iris\.history$/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the username' do
|
describe '.hostname' do
|
||||||
_(Config::USER).must_equal 'jerryberry'
|
before do
|
||||||
end
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
end
|
||||||
|
|
||||||
it 'has a hostname' do
|
it 'has a hostname' do
|
||||||
_(Config::HOSTNAME).wont_be_nil
|
_(Config.hostname).wont_be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets an empty string' do
|
||||||
|
Config.expects(:`).with('hostname').returns('')
|
||||||
|
_(Config.hostname).must_equal 'localhost'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets localhost' do
|
||||||
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
Config.expects(:`).with('hostname').returns('localhost')
|
||||||
|
_(Config.hostname).must_equal 'localhost'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets a subdomain' do
|
||||||
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
Config.expects(:`).with('hostname').returns('example.com')
|
||||||
|
_(Config.hostname).must_equal 'example.com'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets a subsubdomain' do
|
||||||
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
Config.expects(:`).with('hostname').returns('foo.example.com')
|
||||||
|
_(Config.hostname).must_equal 'example.com'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets an arbitrary number of subdomains' do
|
||||||
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
Config.expects(:`).with('hostname').returns('foo.bar.baz.quux.example.com')
|
||||||
|
_(Config.hostname).must_equal 'example.com'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the author' do
|
it 'has the author' do
|
||||||
_(Config::AUTHOR).must_equal "#{Config::USER}@#{Config::HOSTNAME}"
|
user = 'jerryberry'
|
||||||
|
_(Config.author).must_equal "#{user}@#{Config.hostname}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the $EDITOR environment variable' do
|
it 'has the $EDITOR environment variable' do
|
||||||
|
|
Loading…
Reference in New Issue