reloader_gem 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/lib/reloader_gem.rb +47 -0
- data/lib/reloader_gem/version.rb +3 -0
- data/reloader_gem.gemspec +21 -0
- metadata +69 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Michał Szyma
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# ReloaderGem
|
2
|
+
|
3
|
+
Reload gem when we change content of gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'reloader_gem'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install reloader_gem
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require "reloader_gem"
|
22
|
+
|
23
|
+
ReloaderGem.new(name_of_gem)
|
24
|
+
|
25
|
+
where name_of_gem is name of gem which you want modify
|
data/Rakefile
ADDED
data/lib/reloader_gem.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "reloader_gem/version"
|
4
|
+
require "digest/md5"
|
5
|
+
require "logger"
|
6
|
+
|
7
|
+
class ReloaderGem
|
8
|
+
|
9
|
+
def initialize(gem_name, time = 0.5)
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@gem_name = gem_name
|
12
|
+
@gem_dir = Gem::Specification.find_by_name(@gem_name).gem_dir
|
13
|
+
@check_sum = md5_gem
|
14
|
+
@time = time
|
15
|
+
run
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def run
|
21
|
+
Thread.new do
|
22
|
+
while true
|
23
|
+
sleep @time
|
24
|
+
begin
|
25
|
+
check_sum = md5_gem
|
26
|
+
unless check_sum == @check_sum
|
27
|
+
@check_sum = check_sum
|
28
|
+
$".delete_if{|item| item.include?(@gem_name)}
|
29
|
+
require @gem_name
|
30
|
+
@logger.info "----- updated gem #{@gem_name} -----"
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
@logger.info "----- not updated gem #{@gem_name} -----"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def md5_gem
|
40
|
+
result = ""
|
41
|
+
Dir["#{@gem_dir}/**/*.rb"].each do |path|
|
42
|
+
result << Digest::MD5.hexdigest(File.read(path))
|
43
|
+
end
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/reloader_gem/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Michal Szyma"]
|
6
|
+
gem.email = ["raglub.ruby@gmail.com"]
|
7
|
+
gem.description = %q{Reload gem when we change content of gem}
|
8
|
+
gem.summary = %q{Reload gem when we change content of gem}
|
9
|
+
gem.date = "2012-08-08"
|
10
|
+
gem.homepage = "https://github.com/raglub/reloader_gem"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "reloader_gem"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.platform = Gem::Platform::RUBY
|
18
|
+
gem.version = ReloaderGem::VERSION
|
19
|
+
|
20
|
+
gem.add_dependency "logger", ">= 1.2.8"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reloader_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michal Szyma
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: logger
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.2.8
|
30
|
+
description: Reload gem when we change content of gem
|
31
|
+
email:
|
32
|
+
- raglub.ruby@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/reloader_gem.rb
|
43
|
+
- lib/reloader_gem/version.rb
|
44
|
+
- reloader_gem.gemspec
|
45
|
+
homepage: https://github.com/raglub/reloader_gem
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.24
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Reload gem when we change content of gem
|
69
|
+
test_files: []
|