highlander 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8d4284b42ffc643eb16bd6f3866e52b7b33cc5b95a2f7968b84c50e1de50543
4
- data.tar.gz: 77933ea6a43de8d6c9b5df5fc22df056b9fa0936f9bfa739ba880965ae9e4a4c
3
+ metadata.gz: f3e3f093b445573f2d96fc4c07e95dfae01eee82f38ba503d0cff020baf50991
4
+ data.tar.gz: cc60e6a8b44af4795040e391219449292962739ae3f13a710b6dbbc91fd26c37
5
5
  SHA512:
6
- metadata.gz: 10c717e7b41e470c2c459d1e14fe83c52569a8b0cf341d1d944a32b0f5aca8ce88060c61fd46bf2ffc97aab31fa33ed4de4de92dbd4f404d954f7f53609e1bc3
7
- data.tar.gz: cda33cf9c6bd29c9068aa7e87f56d0b077c65f44cccdc6cc87a0c3f68ec44e541b4b0d15c39f2f5b0b80de9018c3339a9c5b8b88fc3455448d65bddd1f4ffaab
6
+ metadata.gz: 9ac29f950680461fab70e884fd9e147f2bc371329fba6bcccff1655ce080d49bbe004832415f06cc6c03a15c9cb30410a978ecf45798b3997737489dc4192c35
7
+ data.tar.gz: b5f1685b7791205747823235b050b1da16a3053f4f59ad91242cf9ce9dabcbc6969d5f45004cbdaec06b552692fd48d3e49e9fe756250763e274802be8106357
checksums.yaml.gz.sig CHANGED
Binary file
data/Gemfile CHANGED
@@ -1,6 +1,2 @@
1
- source 'https://rubygems.org' do
2
- group 'test' do
3
- gem 'rake'
4
- gem 'test-unit', '~> 3.3'
5
- end
6
- end
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md CHANGED
@@ -5,19 +5,22 @@
5
5
  ## Installation
6
6
  `gem install highlander`
7
7
 
8
+ ## Adding the trusted cert
9
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/highlander/MacLeod/certs/djberg96_pub.pem)`
10
+
8
11
  ## Synopsis
9
- ```
10
- require 'highlander' # This should be the -first- thing in your code.
11
- # Your code here
12
+ ```ruby
13
+ require 'highlander' # This should be the -first- thing in your code.
14
+ # Your code here
12
15
 
13
- # Meanwhile, back on the command line...
16
+ # Meanwhile, back on the command line...
14
17
 
15
- # First attempt, works. Assume it's running in the background.
16
- ruby your_script.rb
18
+ # First attempt, works. Assume it's running in the background.
19
+ ruby your_script.rb
17
20
 
18
- # Second attempt while the first instance is still running, fails.
19
- ruby your_script.rb # => RuntimeError
20
- ```
21
+ # Second attempt while the first instance is still running, fails.
22
+ ruby your_script.rb # => RuntimeError
23
+ ```
21
24
 
22
25
  ## Notes
23
26
  Simply requiring the highlander gem ensures that only one instance
@@ -35,7 +38,7 @@
35
38
  Apache-2.0
36
39
 
37
40
  ## Copyright
38
- (C) 2010-2020 Daniel J. Berger
41
+ (C) 2010-2022 Daniel J. Berger
39
42
  All Rights Reserved.
40
43
 
41
44
  ## Warranty
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
 
5
5
  CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
6
6
 
@@ -8,7 +8,7 @@ namespace 'gem' do
8
8
  desc 'Create the highlander gem'
9
9
  task :create => [:clean] do
10
10
  require 'rubygems/package'
11
- spec = eval(IO.read('highlander.gemspec'))
11
+ spec = Gem::Specification.load('highlander.gemspec')
12
12
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
13
  Gem::Package.build(spec)
14
14
  end
@@ -20,9 +20,7 @@ namespace 'gem' do
20
20
  end
21
21
  end
22
22
 
23
- Rake::TestTask.new do |t|
24
- t.verbose = true
25
- t.warning = true
26
- end
23
+ desc "Run the test suite"
24
+ RSpec::Core::RakeTask.new(:spec)
27
25
 
28
- task :default => :test
26
+ task :default => :spec
data/highlander.gemspec CHANGED
@@ -2,16 +2,27 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'highlander'
5
- spec.version = '0.2.3'
5
+ spec.version = '0.3.0'
6
6
  spec.license = 'Apache-2.0'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/highlander'
10
10
  spec.summary = 'There can be only one! Process, that is.'
11
- spec.test_files = Dir['test/test*']
11
+ spec.test_files = Dir['spec/*.rb']
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
+ spec.add_development_dependency('rspec', '~> 3.11')
16
+
17
+ spec.metadata = {
18
+ 'homepage_uri' => 'https://github.com/djberg96/highlander',
19
+ 'bug_tracker_uri' => 'https://github.com/djberg96/highlander/issues',
20
+ 'changelog_uri' => 'https://github.com/djberg96/highlander/blob/MacLeod/CHANGES.md',
21
+ 'documentation_uri' => 'https://github.com/djberg96/highlander/wiki',
22
+ 'source_code_uri' => 'https://github.com/djberg96/highlander',
23
+ 'wiki_uri' => 'https://github.com/djberg96/highlander/wiki'
24
+ }
25
+
15
26
  spec.description = <<-EOF
16
27
  The highlander spec ensures that only one instance of the current
17
28
  process is running. If you try to run the same Ruby program again
data/lib/highlander.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Highlander
2
2
  # The version of the highlander library
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
 
6
6
  BEGIN{
@@ -0,0 +1,42 @@
1
+ #######################################################################
2
+ # highlander_spec.rb
3
+ #
4
+ # Test suite for the highlander library.
5
+ #######################################################################
6
+ require 'rspec'
7
+ require 'highlander'
8
+
9
+ RSpec.describe Highlander do
10
+ let(:filename){ 'highlander_test.rb' }
11
+ let(:outfile){ 'highlander_output.txt' }
12
+
13
+ before do
14
+ File.open(filename, 'w') do |fh|
15
+ fh.puts 'require_relative "lib/highlander"'
16
+ fh.puts '3.times{ puts "hello"; sleep 1 }'
17
+ end
18
+ end
19
+
20
+ after do
21
+ File.delete(filename) if File.exist?(filename)
22
+ File.delete(outfile) if File.exist?(outfile)
23
+ end
24
+
25
+ example "version" do
26
+ expect(Highlander::VERSION).to eq('0.3.0')
27
+ expect(Highlander::VERSION).to be_frozen
28
+ end
29
+
30
+ example "attempting to run multiple instances will fail" do
31
+ pid1 = Process.spawn("ruby #{filename}", [:out, :err] => IO::NULL)
32
+ sleep 1 # Make sure pid1 runs first, is there a better way?
33
+ pid2 = Process.spawn("ruby #{filename}", :err => [outfile, 'w'], :out => IO::NULL)
34
+
35
+ status1 = Process.waitpid2(pid1).last
36
+ status2 = Process.waitpid2(pid2).last
37
+
38
+ expect(status1.exitstatus).to eq(0)
39
+ expect(status2.exitstatus).not_to eq(0)
40
+ expect(File.read(outfile)).to include("There can be only one!")
41
+ end
42
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highlander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,8 +35,22 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2020-12-16 00:00:00.000000000 Z
39
- dependencies: []
38
+ date: 2022-06-05 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.11'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.11'
40
54
  description: |2
41
55
  The highlander spec ensures that only one instance of the current
42
56
  process is running. If you try to run the same Ruby program again
@@ -55,11 +69,17 @@ files:
55
69
  - certs/djberg96_pub.pem
56
70
  - highlander.gemspec
57
71
  - lib/highlander.rb
58
- - test/test_highlander.rb
72
+ - spec/highlander_spec.rb
59
73
  homepage: https://github.com/djberg96/highlander
60
74
  licenses:
61
75
  - Apache-2.0
62
- metadata: {}
76
+ metadata:
77
+ homepage_uri: https://github.com/djberg96/highlander
78
+ bug_tracker_uri: https://github.com/djberg96/highlander/issues
79
+ changelog_uri: https://github.com/djberg96/highlander/blob/MacLeod/CHANGES.md
80
+ documentation_uri: https://github.com/djberg96/highlander/wiki
81
+ source_code_uri: https://github.com/djberg96/highlander
82
+ wiki_uri: https://github.com/djberg96/highlander/wiki
63
83
  post_install_message:
64
84
  rdoc_options: []
65
85
  require_paths:
@@ -75,9 +95,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
95
  - !ruby/object:Gem::Version
76
96
  version: '0'
77
97
  requirements: []
78
- rubygems_version: 3.1.4
98
+ rubygems_version: 3.3.15
79
99
  signing_key:
80
100
  specification_version: 4
81
101
  summary: There can be only one! Process, that is.
82
102
  test_files:
83
- - test/test_highlander.rb
103
+ - spec/highlander_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,14 +0,0 @@
1
- #######################################################################
2
- # test_highlander.rb
3
- #
4
- # Test suite for the highlander gem. Easier to test on the command
5
- # line than with a formal test suite, hence the sparseness here.
6
- #######################################################################
7
- require 'test/unit'
8
- require 'highlander'
9
-
10
- class TC_Highlander < Test::Unit::TestCase
11
- def test_version
12
- assert_equal("0.2.3", Highlander::VERSION)
13
- end
14
- end