rubymon 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rubymon +28 -6
  3. data/lib/rubymon.rb +40 -4
  4. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1618731a0b414426b8681bcae6de5609aa84c8b8
4
- data.tar.gz: 5986ebcac23f8bc3904fbb54623af946c7fc41a0
3
+ metadata.gz: 60bbd2bc3478aec5edc4c2d14763268122543e7d
4
+ data.tar.gz: 46ca237b025ca7cf2ab529a7a683c193c792a37c
5
5
  SHA512:
6
- metadata.gz: ccb6cf15773a6687b175e7654d0190e3943e8f90d1321a9b5dbe7d4b6bb5cb5661311e1c0ec48f71f55f12cca179000b78d05e5fa4456d8a5c493527d0c399e6
7
- data.tar.gz: d4336276b0905394f7e20fe508823015731501a1a2b792dce5511bd1004be9d6e6f3657d81fbe792ef69a54e80709986d4b3e3bf814fe97faeee294aa8ec147c
6
+ metadata.gz: cfd8ce3d0d6c4d538209f7c2792470af6d3e36134dbde31af8de6c46377b19bc9123cb722848ff410dfcca332204a6ae8b61216e0e5e8b29ce201e224e52af2c
7
+ data.tar.gz: ebdcf7a8c1aef055a540135236ee586dba5198fdf6c9deac79ea21ec1fbb9468d69ffdc993c0a10bd882b3fbce38de2ca0c044caf3efc75eb6ad6829c1b347d7
data/bin/rubymon CHANGED
@@ -5,14 +5,36 @@ require 'listen'
5
5
 
6
6
  if ARGV[0].to_s.include?("f")
7
7
  puts "Input filename ..."
8
- path = STDIN.gets.chomp
8
+ @path = STDIN.gets.chomp
9
+ @copy = false
9
10
 
10
- while File.file?(path) == false
11
+ while File.file?(@path) == false
11
12
  puts "File not existing ..."
12
- path = STDIN.gets.chomp
13
+ @path = STDIN.gets.chomp
13
14
  end
14
-
15
- Rubymon.file(path)
15
+ if ARGV[1] != nil
16
+ @copy = true if ARGV[1].include?("c")
17
+ end
18
+
19
+ Rubymon.file(@path, @copy)
20
+ elsif ARGV[0] == "-h"
21
+ puts "RubyMon Version 0.1.1 - Major changes"
22
+ puts ""
23
+ puts "Simply switch to your working directory and type:"
24
+ puts "rubymon"
25
+ puts "into the command line. Whola. It SHOULD work."
26
+ puts ""
27
+ puts "To pay attention to a single file in your directory use:"
28
+ puts "rubymon file #Shortcut: rubymon f"
29
+ puts ""
30
+ puts "New in version 0.1.1"
31
+ puts "When using 'rubymon file' simply add 'copy or c' as an argument. What does it do? When you make changes to your file it will automatically backup the old version of the file and safe it as old_yourfilename.rb (in the same directory as yourfilename.rb). Attention: The old_yourfilename.rb file will be overridden everytime you safe your modified ruby file so it will only include code from the last version of your ruby file."
16
32
  else
17
- Rubymon.dir
33
+ #@copy = false
34
+
35
+ #if ARGV[0] != nil
36
+ #@copy = true if ARGV[0].include?("c")
37
+ # end
38
+
39
+ Rubymon.dir#(@copy)
18
40
  end
data/lib/rubymon.rb CHANGED
@@ -1,7 +1,35 @@
1
1
  class Rubymon
2
2
 
3
3
  $thr = Thread.new{}
4
+ $file_content_last = []
5
+ $file_last = ""
4
6
 
7
+ def self.last_save file
8
+
9
+ File.open(file, "r") do |file|
10
+ while(line = file.gets)
11
+ $file_content_last = []
12
+ $file_content_last.push(line)
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.save_last file
18
+ puts $file_last
19
+ puts file
20
+ if $file_last != "" && $file_last == file
21
+ File.delete("old_" + file) if File.file?("old_" + file)
22
+ File.open("old_" + file, "w") do |file|
23
+ file.truncate(0)
24
+ $file_content_last.each do |line|
25
+ file.write(line)
26
+ end
27
+ end
28
+ else
29
+ $file_content_last = []
30
+ end
31
+ end
32
+
5
33
  def self.execute_file modified
6
34
  puts "RubyMon executing file #{modified} ..."
7
35
  puts "************************\n"
@@ -10,7 +38,8 @@ class Rubymon
10
38
  puts "End of file ..."
11
39
  end
12
40
 
13
- def self.dir
41
+ def self.dir #copy
42
+ #@copy = copy
14
43
  begin
15
44
  puts "Can't run RubyMon in the home directory. Exiting ..." if Dir.pwd == Dir.home
16
45
  exit if Dir.pwd == Dir.home
@@ -18,7 +47,10 @@ class Rubymon
18
47
  puts "Listening to directory: #{Dir.pwd} ..."
19
48
 
20
49
  listener = Listen.to(Dir.pwd, only: /\.rb$/) { |modified|
21
- if modified.join("").include?(".rb")
50
+ if modified.join("").include?(".rb") && !modified.join("").start_with?("old_")
51
+ #Rubymon.save_last(modified.join("")) if @copy == true
52
+ #$file_last = modified.join("")
53
+ #Rubymon.last_save(modified.join("")) if @copy == true
22
54
  $thr.exit
23
55
  $thr = Thread.new{Rubymon.execute_file(modified.join(""))}
24
56
  end
@@ -30,7 +62,8 @@ class Rubymon
30
62
  end
31
63
  end
32
64
 
33
- def self.file path
65
+ def self.file path, copy
66
+ @copy = copy
34
67
  begin
35
68
  puts "Can't run RubyMon in the home directory. Exiting ..." if Dir.pwd == Dir.home
36
69
  exit if Dir.pwd == Dir.home
@@ -47,7 +80,10 @@ class Rubymon
47
80
  puts "Listening to file: #{Dir.pwd}/#{@path} ..."
48
81
 
49
82
  listener = Listen.to(Dir.pwd) { |modified|
50
- if modified.join("") == @path
83
+ if modified.join("") == @path && !modified.join("").start_with?("old_")
84
+ Rubymon.save_last(modified.join("")) if @copy == true
85
+ $file_last = modified.join("") if @copy == true
86
+ Rubymon.last_save(modified.join("")) if @copy == true
51
87
  $thr.exit
52
88
  $thr = Thread.new{Rubymon.execute_file(modified.join(""))}
53
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubymon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick
@@ -24,9 +24,10 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.0
27
- description: 'RubyMon automatically reruns your ruby file when changes are made. Simply
28
- switch to your working directory and type ''rubymon'' into the command line. To
29
- explicitly listen to a single file use: ''rubymon file''.'
27
+ description: RubyMon automatically restarts your ruby aplication when changes are
28
+ made. Read our documentation at Github (https://github.com/Cereal1974/RubyMon).
29
+ For a list of commands and a brief description of what they do type 'nodemon -h'
30
+ into your command line.
30
31
  email:
31
32
  executables:
32
33
  - rubymon
@@ -45,7 +46,7 @@ require_paths:
45
46
  - lib
46
47
  required_ruby_version: !ruby/object:Gem::Requirement
47
48
  requirements:
48
- - - "~>"
49
+ - - ">="
49
50
  - !ruby/object:Gem::Version
50
51
  version: '2.0'
51
52
  required_rubygems_version: !ruby/object:Gem::Requirement