pry-reload 0.1

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
+ SHA1:
3
+ metadata.gz: 9529f56971fd7cbd2ebd087531b8cb96edcae161
4
+ data.tar.gz: f7978965805983ca061bbb95c3c5726ec529ad69
5
+ SHA512:
6
+ metadata.gz: 6e98bd4a640bde8d74620ed895a3b6d514624d23ded7a3d3162fd6ed111cee8bb2e6bf32026fed545b81e1afa9c7f2b6c22f8aecd872824a88acaf5195b5763c
7
+ data.tar.gz: 90c21a8232d9e9846d511dc4d09ee3ee7d33cf24884a12b3426fc76fca46a61b88debdca1a664110272d199026a35c31e00d8bfbdbd6a67b418e493f382e28fb
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pry-reload.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Pry::Reload
2
+
3
+ Tracks and reloads changed files
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pry-reload'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pry-reload
20
+
21
+ ## Usage
22
+
23
+ Use `reload!` command on Pry to reload all modified files.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
28
+ `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To
31
+ release a new version, update the version number in `version.rb`, and then run
32
+ `bundle exec rake release` to create a git tag for the version, push git
33
+ commits and tags, and push the `.gem` file to
34
+ [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/runa/pry-reload/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/lib/pry-reload.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "pry-reload/commands.rb"
2
+ require "pry-reload/watch.rb"
@@ -0,0 +1,7 @@
1
+ Pry.hooks.add_hook(:before_session, "reload-init") do
2
+ PryReload::Watch.instance
3
+ end
4
+
5
+ Pry::Commands.block_command "reload!", "Reload changed files since the session started" do
6
+ PryReload::Watch.instance.reload!(output)
7
+ end
@@ -0,0 +1,3 @@
1
+ class PryReload
2
+ VERSION = 0.1
3
+ end
@@ -0,0 +1,59 @@
1
+ require "rb-inotify"
2
+ require "thread"
3
+
4
+ class PryReload
5
+ class Watch
6
+ include Singleton
7
+
8
+ @@mutex = Mutex.new
9
+
10
+ def initialize
11
+ @notifier = INotify::Notifier.new
12
+ @modified = []
13
+ setup
14
+ process
15
+ end
16
+
17
+ def dirs
18
+ Dir.glob("**/*/");
19
+ end
20
+
21
+ def process_event(evt)
22
+ if File.directory?(evt.absolute_name)
23
+ evt.notifier.watch(evt.absolute_name)
24
+ elsif evt.absolute_name.end_with?(".rb")
25
+ @@mutex.synchronize { @modified << evt.absolute_name }
26
+ #puts "modified #{evt.absolute_name}"
27
+ end
28
+ end
29
+
30
+ def setup
31
+ dirs.each do |dir|
32
+ #puts "Listening #{dir}"
33
+ @notifier.watch(dir, :modify, &Proc.new { |evt| process_event(evt) })
34
+ end
35
+ end
36
+
37
+ def process
38
+ @thread ||= Thread.new do
39
+ #puts "Running!"
40
+ @notifier.run
41
+ end
42
+ end
43
+
44
+ def reload!(output)
45
+ @@mutex.synchronize do
46
+ if @modified.size == 0
47
+ output.puts "Nothing changed!"
48
+ else
49
+ changed = @modified.dup.uniq
50
+ @modified = []
51
+ while path = changed.shift
52
+ output.puts "Reloading #{path}"
53
+ load path
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pry-reload/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pry-reload"
8
+ spec.version = PryReload::VERSION
9
+ spec.authors = ["martin sarsale"]
10
+ spec.email = ["martin@malditainternet.com"]
11
+
12
+ spec.summary = %q{Tracks and reloads changed files}
13
+ spec.homepage = "https://github.com/runa/pry-reload"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.8"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_dependency "rb-inotify", "~> 0.9.7"
23
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-reload
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - martin sarsale
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb-inotify
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.7
55
+ description:
56
+ email:
57
+ - martin@malditainternet.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - lib/pry-reload.rb
67
+ - lib/pry-reload/commands.rb
68
+ - lib/pry-reload/version.rb
69
+ - lib/pry-reload/watch.rb
70
+ - pry-reload.gemspec
71
+ homepage: https://github.com/runa/pry-reload
72
+ licenses: []
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.5.1
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Tracks and reloads changed files
94
+ test_files: []