loop 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/README.md +84 -0
  4. data/Rakefile +23 -0
  5. data/bin/loop +30 -0
  6. data/lib/loop/version.rb +3 -0
  7. data/loop.gemspec +17 -0
  8. metadata +74 -0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in loop.gemspec
4
+ gemspec
@@ -0,0 +1,84 @@
1
+ # Loop
2
+
3
+ A tiny Ruby program used to periodically execute a command.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ Usage: loop [options] <cmd>
9
+
10
+ Options:
11
+
12
+ -i, --interval=val Interval in seconds default to 0.5
13
+ -v, --version Display the version number
14
+ -h, --help Show this help message
15
+ ```
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ $ (sudo) gem install loop
21
+ ```
22
+
23
+ ## About
24
+
25
+ This project is very a port of [watch(2)](https://github.com/visionmedia/watch) implemented by VisionMedia.
26
+
27
+ ## Milliseconds resolution
28
+
29
+ We support millisecond resolution i.e.:
30
+
31
+ ```
32
+ $ watch -i 0.3 echo hey
33
+ ```
34
+
35
+ ## Examples
36
+
37
+ Here a simple script that compile `stylus` and `coffee` in `public` folder:
38
+
39
+ Create a folder in your `sinatra`/`padrino` app:
40
+
41
+ ```sh
42
+ mkdir -p app/assets/js
43
+ mkdir -p app/assets/css
44
+ ```
45
+
46
+ In js put your `coffee` script files and under css `stylus` stylesheets.
47
+
48
+ Be sure to install both:
49
+
50
+ ```sh
51
+ npm -g install stylus coffee-script
52
+ ```
53
+
54
+ In the root of your project create a `Makefile` with this content:
55
+
56
+ ```make
57
+ COFFEE=$(shell find app/assets/js -name '*.coffee' -type f)
58
+ JS=$(patsubst app/assets/js/%.coffee, public/javascripts/%.js, $(COFFEE))
59
+ STYLUS=$(shell find app/assets/css -name '*.styl' -type f)
60
+
61
+ all: $(JS) public/stylesheets/app.css
62
+
63
+ public/javascripts/%.js: app/assets/js/%.coffee
64
+ coffee -b -o public/javascripts -c $<
65
+
66
+ public/stylesheets/app.css: $(STYLUS)
67
+ stylus -o public/stylesheets -c $<
68
+ ```
69
+
70
+ Create some `*.styl` files and `*.coffee` files under `app/assets`
71
+
72
+ Test it:
73
+
74
+ ```sh
75
+ make
76
+ ```
77
+
78
+ Now run loop:
79
+
80
+ ```sh
81
+ loop make
82
+ ```
83
+
84
+ More details are available here: https://github.com/visionmedia/watch/blob/master/Readme.md
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env rake
2
+ require 'rubygems' unless defined?(Gem)
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rake/testtask'
6
+
7
+ %w(install release).each do |task|
8
+ Rake::Task[task].enhance do
9
+ sh "rm -rf pkg"
10
+ end
11
+ end
12
+
13
+ desc 'Bump version on github'
14
+ task :bump do
15
+ if `git status -s`.strip == ''
16
+ puts "\e[31mNothing to commit (working directory clean)\e[0m"
17
+ else
18
+ version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
19
+ sh "git add .; git commit -a -m \"Bump to version #{version}\""
20
+ end
21
+ end
22
+
23
+ task :release => :bump
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'optparse'
4
+ require 'loop/version'
5
+
6
+ options = {
7
+ :interval => 0.5
8
+ }
9
+
10
+ ARGV << '-h' if ARGV.empty?
11
+
12
+ ARGV.options do |o|
13
+ script_name = File.basename($0)
14
+ o.set_summary_width(20)
15
+ o.set_summary_indent(' ')
16
+ o.banner = ''
17
+ o.separator 'Usage: %s [options] <cmd>' % script_name
18
+ o.separator ''
19
+ o.separator 'Options:'
20
+ o.separator ''
21
+ o.on('-i', '--interval=val', Float, 'Interval in seconds default to 0.5') { |v| options[:interval] = v }
22
+ o.on('-v', '--version', 'Display the version number') { puts Loop::VERSION; exit }
23
+ o.on('-h', '--help', 'Show this help message') { puts o; exit }
24
+ o.separator ''
25
+ o.parse!
26
+ o.permute!
27
+ end
28
+
29
+ trap(:INT) { abort 'Exiting ...' }
30
+ loop { system(*ARGV); sleep options[:interval] }
@@ -0,0 +1,3 @@
1
+ module Loop
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/loop/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Davide D\'Agostino']
6
+ gem.email = ['d.dagostino@lipsiasoft.com']
7
+ gem.description = 'A tiny Ruby program used to periodically execute a command'
8
+ gem.summary = 'A tiny Ruby program used to periodically execute a command'
9
+ gem.homepage = 'https://github.com/DAddYE/loop'
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = 'loop'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Loop::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loop
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Davide D'Agostino
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-13 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A tiny Ruby program used to periodically execute a command
23
+ email:
24
+ - d.dagostino@lipsiasoft.com
25
+ executables:
26
+ - loop
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.md
35
+ - Rakefile
36
+ - bin/loop
37
+ - lib/loop/version.rb
38
+ - loop.gemspec
39
+ has_rdoc: true
40
+ homepage: https://github.com/DAddYE/loop
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.6.2
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: A tiny Ruby program used to periodically execute a command
73
+ test_files: []
74
+