Comments (11)
I'll try and figure it out later, but I would like to implement it with the help of inheritance, and not before_
and after_
methods. I have successful experience with it in Flame framework with before
and after
hooks (with super
calls).
from filewatcher.
A plugin system is a good idea. It keeps the core small and manageable while still allowing new features to be added.
I haven't thought too much about what an API for a plugin system should look like. The first idea that comes to mind is having a :plugins option in the Filewatcher constructor.
require 'filewatcher/plugins/file_read_detection'
frd = new Filewatcher::FileReadDetection()
Filewatcher.new('**/*.*', plugins: [frd]).watch do |filename, event|
if(event == :access) do
puts "Read file detected:" + filename
end
end
from filewatcher.
@thomasfl I thought that all plugins can be loaded (required) by default, and add some options for Filewatcher (include executable), but options is good idea too, also for executable (--plugins
), I guess.
from filewatcher.
Having an --plugins options for the cli is a good idea.
When using the filewatcher API with plugins that add features, then the plugins should probably be explicitly imported. That way users could easily create their own plugins.
from filewatcher.
So, --help
option should show additional info from plugins, listed in --plugins
option — OK.
from filewatcher.
I guess a file read detection plugin should be available like this:
$ filewatcher --plugins fileread **/*
And visible in the help section like this
$ filewatcher --help
--plugins, -p: Specify plugins to load.
"fileread" plugin detects file reads and emits a "fileread" event.
It looks a bit stupid to have a plugin system, when there's only one plugin. Do you have any ideas for other plugins? We could make the spinner available on the command line into a plugin, so there's at least two plugins.
from filewatcher.
And visible in the help section like this
I mean something like this:
$ filewatcher --plugins fileread --help
*standard help*
Plugins: /* or "Fileread plugin:" */
--access, -a: Add `access` event (when some file was read)
We could make the spinner available on the command line into a plugin, so there's at least two plugins.
Not bad idea.
It looks a bit stupid to have a plugin system, when there's only one plugin. Do you have any ideas for other plugins?
I think we need to make the system so that third-party developers can add their functionality without changing the main gem. The main thing is the possibility, and the quantity of plugins is already secondary.
from filewatcher.
A plugin could be very simple if it looked something like this:
class FilewatcherFileReadPlugin
def file_updated?(absolutefilename)
<if file is read return> do
return {status: true, event: :fileread}
end
end
def initialize(filenames, options = {})
...
end
def before_each_cycle
print "spinner"
end
def after_each_cycle
....
end
end
With this API there should be possible to make plugins that can provide alternative spinners, file read detection and also alter which files should be included in the watch list.
from filewatcher.
I think, CLI also can be a plugin. For such cases when user want only Ruby DSL.
Also I'm thinking about a plugin for multiple patterns-commands from YAML file.
from filewatcher.
I'm on the way to do it, but I see problems with CLI flags for CLI as a plugin itself. I guess the situation can be better after #144 merge, but it's blocked right now, yes.
from filewatcher.
Done! 🎉 In #147.
Now I'm going to:
- make some notes about upcoming major release (2.0) in README;
- release
2.0.0.beta1
or something like this; - test new plugins with beta-version, fix their CI;
- release Filewatcher
2.0.0
stable; - test plugins with stable Filewatcher;
- release these plugins.
from filewatcher.
Related Issues (20)
- The filewatch does not work if files are creating too fast HOT 5
- unexpected behavior on Windows and two callbacks on one DELETE on Linux HOT 3
- --restart flag support process kill with custom signal? HOT 3
- filewatcher loops infinitely when executing a script that invokes ssh HOT 9
- "Batching" all changes into one event HOT 3
- Sync to database example HOT 1
- Question regarding API HOT 3
- How do I know which directory has changed when there is a change HOT 1
- Stable release soon? HOT 2
- Filewatcher not found in Ruby 3.2.2 HOT 13
- When used with multiple watch paths block vars are improperly assigned HOT 5
- Speed up tests HOT 1
- `Filewatcher` vs `FileWatcher` case change from rubygems HOT 4
- 1.0 Release -- event 'updated' raises NotImplementedError HOT 4
- Crash on file deletion (via executable) HOT 1
- Doesn't seem to work if repos have a dot in the name HOT 2
- Replace Gemnasium with Depfu
- Trollop dependency is deprecated HOT 9
- Switch from Travis CI to Cirrus CI HOT 1
- Detect rename HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filewatcher.