reveal-ck 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.rvmrc +16 -0
- data/.travis.yml +4 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +52 -0
- data/LICENSE +20 -0
- data/README.md +103 -0
- data/Rakefile +16 -0
- data/VERSION +1 -0
- data/bin/reveal-ck +46 -0
- data/features/data/images/ruby100.png +0 -0
- data/features/generate.feature +63 -0
- data/features/help.feature +18 -0
- data/features/step_definitions/file_management_steps.rb +3 -0
- data/features/support/env.rb +15 -0
- data/features/support/file_management.rb +16 -0
- data/lib/reveal-ck.rb +4 -0
- data/lib/reveal-ck/file_slicer.rb +23 -0
- data/lib/reveal-ck/file_splicer.rb +39 -0
- data/lib/reveal-ck/haml_processor.rb +24 -0
- data/lib/reveal-ck/version.rb +4 -0
- data/rakelib/cucumber.rake +2 -0
- data/rakelib/jeweler.rake +12 -0
- data/rakelib/presentation.rake +40 -0
- data/rakelib/reveal.rake +15 -0
- data/rakelib/rspec.rake +5 -0
- data/reveal-ck.gemspec +152 -0
- data/reveal.js/LICENSE +19 -0
- data/reveal.js/README.md +374 -0
- data/reveal.js/css/print/paper.css +176 -0
- data/reveal.js/css/print/pdf.css +160 -0
- data/reveal.js/css/reveal.css +1312 -0
- data/reveal.js/css/reveal.min.css +7 -0
- data/reveal.js/css/shaders/tile-flip.fs +64 -0
- data/reveal.js/css/shaders/tile-flip.vs +141 -0
- data/reveal.js/css/theme/README.md +25 -0
- data/reveal.js/css/theme/beige.css +163 -0
- data/reveal.js/css/theme/default.css +163 -0
- data/reveal.js/css/theme/night.css +150 -0
- data/reveal.js/css/theme/serif.css +150 -0
- data/reveal.js/css/theme/simple.css +152 -0
- data/reveal.js/css/theme/sky.css +156 -0
- data/reveal.js/css/theme/source/beige.scss +50 -0
- data/reveal.js/css/theme/source/default.scss +42 -0
- data/reveal.js/css/theme/source/night.scss +35 -0
- data/reveal.js/css/theme/source/serif.scss +33 -0
- data/reveal.js/css/theme/source/simple.scss +38 -0
- data/reveal.js/css/theme/source/sky.scss +41 -0
- data/reveal.js/css/theme/template/mixins.scss +29 -0
- data/reveal.js/css/theme/template/settings.scss +33 -0
- data/reveal.js/css/theme/template/theme.scss +163 -0
- data/reveal.js/grunt.js +84 -0
- data/reveal.js/index.html +375 -0
- data/reveal.js/js/reveal.js +1796 -0
- data/reveal.js/js/reveal.min.js +8 -0
- data/reveal.js/lib/css/zenburn.css +115 -0
- data/reveal.js/lib/font/league_gothic-webfont.eot +0 -0
- data/reveal.js/lib/font/league_gothic-webfont.svg +230 -0
- data/reveal.js/lib/font/league_gothic-webfont.ttf +0 -0
- data/reveal.js/lib/font/league_gothic-webfont.woff +0 -0
- data/reveal.js/lib/font/league_gothic_license +2 -0
- data/reveal.js/lib/js/classList.js +2 -0
- data/reveal.js/lib/js/head.min.js +8 -0
- data/reveal.js/lib/js/html5shiv.js +7 -0
- data/reveal.js/package.json +31 -0
- data/reveal.js/plugin/highlight/highlight.js +9 -0
- data/reveal.js/plugin/markdown/markdown.js +37 -0
- data/reveal.js/plugin/markdown/showdown.js +62 -0
- data/reveal.js/plugin/notes-server/client.js +57 -0
- data/reveal.js/plugin/notes-server/index.js +58 -0
- data/reveal.js/plugin/notes-server/notes.html +139 -0
- data/reveal.js/plugin/notes/notes.html +164 -0
- data/reveal.js/plugin/notes/notes.js +98 -0
- data/reveal.js/plugin/postmessage/example.html +39 -0
- data/reveal.js/plugin/postmessage/postmessage.js +42 -0
- data/reveal.js/plugin/print-pdf/print-pdf.js +39 -0
- data/reveal.js/plugin/remotes/remotes.js +30 -0
- data/reveal.js/plugin/zoom-js/zoom.js +251 -0
- data/spec/data/haml/basic.haml +7 -0
- data/spec/data/html/converted_basic_haml.html +10 -0
- data/spec/data/html/reveal-js-index.html +375 -0
- data/spec/data/slicer/after_remove +6 -0
- data/spec/data/slicer/before_remove +10 -0
- data/spec/data/splicer/abcd +4 -0
- data/spec/data/splicer/after_insert +14 -0
- data/spec/data/splicer/before_insert +10 -0
- data/spec/lib/reveal-ck/file_slicer_spec.rb +42 -0
- data/spec/lib/reveal-ck/file_splicer_spec.rb +41 -0
- data/spec/lib/reveal-ck/haml_processor_spec.rb +38 -0
- data/spec/spec_helper.rb +27 -0
- metadata +271 -0
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
environment_id="ruby-1.9.3-p327@reveal-ck"
|
4
|
+
|
5
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
6
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
7
|
+
then
|
8
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
9
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
10
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
11
|
+
else
|
12
|
+
rvm --create "$environment_id" || {
|
13
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
14
|
+
return 1
|
15
|
+
}
|
16
|
+
fi
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'haml'
|
4
|
+
gem 'gli'
|
5
|
+
gem 'rake'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem 'jeweler'
|
11
|
+
gem 'rspec'
|
12
|
+
gem 'bundler'
|
13
|
+
gem 'cucumber'
|
14
|
+
gem 'aruba'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
aruba (0.5.1)
|
5
|
+
childprocess (~> 0.3.6)
|
6
|
+
cucumber (>= 1.1.1)
|
7
|
+
rspec-expectations (>= 2.7.0)
|
8
|
+
builder (3.1.4)
|
9
|
+
childprocess (0.3.7)
|
10
|
+
ffi (~> 1.0, >= 1.0.6)
|
11
|
+
cucumber (1.2.1)
|
12
|
+
builder (>= 2.1.2)
|
13
|
+
diff-lcs (>= 1.1.3)
|
14
|
+
gherkin (~> 2.11.0)
|
15
|
+
json (>= 1.4.6)
|
16
|
+
diff-lcs (1.1.3)
|
17
|
+
ffi (1.3.1)
|
18
|
+
gherkin (2.11.6)
|
19
|
+
json (>= 1.7.6)
|
20
|
+
git (1.2.5)
|
21
|
+
gli (2.5.4)
|
22
|
+
haml (3.1.7)
|
23
|
+
jeweler (1.8.4)
|
24
|
+
bundler (~> 1.0)
|
25
|
+
git (>= 1.2.5)
|
26
|
+
rake
|
27
|
+
rdoc
|
28
|
+
json (1.7.6)
|
29
|
+
rake (10.0.3)
|
30
|
+
rdoc (3.12)
|
31
|
+
json (~> 1.4)
|
32
|
+
rspec (2.12.0)
|
33
|
+
rspec-core (~> 2.12.0)
|
34
|
+
rspec-expectations (~> 2.12.0)
|
35
|
+
rspec-mocks (~> 2.12.0)
|
36
|
+
rspec-core (2.12.2)
|
37
|
+
rspec-expectations (2.12.1)
|
38
|
+
diff-lcs (~> 1.1.3)
|
39
|
+
rspec-mocks (2.12.1)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
aruba
|
46
|
+
bundler
|
47
|
+
cucumber
|
48
|
+
gli
|
49
|
+
haml
|
50
|
+
jeweler
|
51
|
+
rake
|
52
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Jed Northridge, http://jednorthridge.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# reveal-ck: a [reveal.js](http://lab.hakim.se/reveal-js/) construction kit
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
The goal of this project is let you quickly author
|
6
|
+
[reveal.js](http://lab.hakim.se/reveal-js/) presentations.
|
7
|
+
|
8
|
+
It enables you to author reveal.js-aware-[haml](http://haml.info/) that
|
9
|
+
can conveniently be transformed into slides.
|
10
|
+
|
11
|
+
The hope is that you will be able to leverage all of the power,
|
12
|
+
beauty, and functionality that comes from reveal.js while focusing
|
13
|
+
entirely on the actual content and ideas you are trying to get across.
|
14
|
+
|
15
|
+
This content will usually take the form of:
|
16
|
+
|
17
|
+
* A file containing your slides (```slides.haml```)
|
18
|
+
* A directory containing any images you'd like to reference relatively
|
19
|
+
(```images```).
|
20
|
+
|
21
|
+
And, in return for this, you will be able to create slides that can be
|
22
|
+
placed anywhere on the web (or kept locally). As with all
|
23
|
+
[reveal.js](http://lab.hakim.se/reveal-js/) presentations, you can
|
24
|
+
show these to other people on an iPhone, iPad, or present them in your
|
25
|
+
browser.
|
26
|
+
|
27
|
+
Here's an example of the inputs you'd provide:
|
28
|
+
https://github.com/jedcn/talk-learning-with-tools
|
29
|
+
|
30
|
+
Here's an example of the output you'd get: Coming Soon
|
31
|
+
|
32
|
+
For a full sampling of everything
|
33
|
+
[reveal.js](http://lab.hakim.se/reveal-js/) can do, take a look at the
|
34
|
+
[live demo](http://lab.hakim.se/reveal-js/).
|
35
|
+
|
36
|
+
## Getting Started
|
37
|
+
|
38
|
+
At present, we assume you've got a functional Ruby 1.9.x environment
|
39
|
+
up and running.
|
40
|
+
|
41
|
+
If that's the case, try the following:
|
42
|
+
|
43
|
+
* clone this project
|
44
|
+
* run a ```bundle```
|
45
|
+
* run ```reveal-ck```
|
46
|
+
|
47
|
+
At this point, the sample ```slides.haml``` that came with the project
|
48
|
+
will be transformed into a set of slides. You can see the result by
|
49
|
+
opening up ```slides/index.html``` in your browser.
|
50
|
+
|
51
|
+
If you've made it this far, you've got the basic basic functionality
|
52
|
+
up and running.
|
53
|
+
|
54
|
+
## Authoring Slides
|
55
|
+
|
56
|
+
Now that you are assured of basic functionality, start making changes
|
57
|
+
and customizing ```slides.haml```. Once you've made a change you'd
|
58
|
+
like to see, re-run ```reveal-ck``` and then re-open (or refresh) ```slides/index.html```
|
59
|
+
|
60
|
+
[reveal.js](http://lab.hakim.se/reveal-js/) has a great
|
61
|
+
[live demo](http://lab.hakim.se/reveal-js/), and if you take a look at
|
62
|
+
the source in the demo, you can get up and running quickly with things
|
63
|
+
that can be placed into your ```slides.haml```.
|
64
|
+
|
65
|
+
## Why not just clone reveal.js?
|
66
|
+
|
67
|
+
Or why not use http://www.rvl.io/ which offers a WYSIWYG experience?
|
68
|
+
|
69
|
+
You can! For sure.
|
70
|
+
|
71
|
+
The whole reveal.js offering is great.
|
72
|
+
|
73
|
+
If reveal-ck's approach is too contrived or doesn't warrant the setup
|
74
|
+
time, skip it!
|
75
|
+
|
76
|
+
## Then.. why would anyone use reveal-ck?
|
77
|
+
|
78
|
+
The thought behind this project to help you focus on what *you* want
|
79
|
+
to say.
|
80
|
+
|
81
|
+
For me, focusing becomes easier and my thoughts clearer when I reduce
|
82
|
+
the list of slides to a single file (```slides.haml```). It only
|
83
|
+
contains the slide content I am presenting and there's minimal markup.
|
84
|
+
|
85
|
+
HAML isn't the most readable thing (say, compared to markdown), but it
|
86
|
+
is decent and sharing or reviewing something like ```slides.haml``` is
|
87
|
+
easier than reviewing the final presentation:
|
88
|
+
|
89
|
+
* If you look at the presentation in a browser, you can't scan all of
|
90
|
+
the slides at once. You need to visit them. If you're looking at
|
91
|
+
```slides.haml``` you can quickly scan through 30+ slides.
|
92
|
+
|
93
|
+
* If you look at the html behind the presentation (say, view source),
|
94
|
+
there's a bunch of stuff that makes the magic happen: styles,
|
95
|
+
javascript, etc.
|
96
|
+
|
97
|
+
Finally, if you track your slides in a system like git, you can get
|
98
|
+
meaningful diffs between versions of ```slides.haml```. This is
|
99
|
+
slightly easier than if you track the generated presentation.
|
100
|
+
|
101
|
+
In the end, the presentation framework,
|
102
|
+
[reveal.js](http://lab.hakim.se/reveal-js/), can make things pretty,
|
103
|
+
but only you can make a presentation that is worthwhile.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rake'
|
14
|
+
require 'rake/clean'
|
15
|
+
require_relative 'lib/reveal-ck'
|
16
|
+
task :default => [ :spec, :cucumber ]
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/reveal-ck
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'reveal-ck'
|
4
|
+
|
5
|
+
# Setup rake and load needed parts of rakelib so that rake tasks can be
|
6
|
+
# invoked programmatically
|
7
|
+
require 'rake'
|
8
|
+
rakelib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'rakelib'))
|
9
|
+
load File.join(rakelib, 'presentation.rake')
|
10
|
+
|
11
|
+
include GLI::App
|
12
|
+
|
13
|
+
program_desc 'A reveal.js construction kit'
|
14
|
+
|
15
|
+
version RevealCK::VERSION
|
16
|
+
|
17
|
+
desc 'Generate reveal.js slides'
|
18
|
+
arg_name 'Tranforms your slides.haml into a presentation'
|
19
|
+
command :generate do |c|
|
20
|
+
c.action do |global_options,options,args|
|
21
|
+
Rake::Task['presentation'].invoke
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
pre do |global,command,options,args|
|
26
|
+
# Pre logic here
|
27
|
+
# Return true to proceed; false to abort and not call the
|
28
|
+
# chosen command
|
29
|
+
# Use skips_pre before a command to skip this block
|
30
|
+
# on that command only
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
post do |global,command,options,args|
|
35
|
+
# Post logic here
|
36
|
+
# Use skips_post before a command to skip this
|
37
|
+
# block on that command only
|
38
|
+
end
|
39
|
+
|
40
|
+
on_error do |exception|
|
41
|
+
# Error logic here
|
42
|
+
# return false to skip default error handling
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
exit run(ARGV)
|
Binary file
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: Generate slides
|
2
|
+
|
3
|
+
In order to easily generate reveal.js presentations
|
4
|
+
As a user of reveal-ck
|
5
|
+
I want to use the "reveal-ck generate" command
|
6
|
+
|
7
|
+
Scenario: Generating basic slides
|
8
|
+
Given a file named "slides.haml" with:
|
9
|
+
"""
|
10
|
+
%section
|
11
|
+
%h1
|
12
|
+
Made with RevealCK
|
13
|
+
%p.small
|
14
|
+
oh yeah!
|
15
|
+
"""
|
16
|
+
When I run `reveal-ck generate`
|
17
|
+
Then the exit status should be 0
|
18
|
+
And the following files should exist:
|
19
|
+
| slides.html |
|
20
|
+
| slides/index.html |
|
21
|
+
And the file "slides.html" should contain exactly:
|
22
|
+
"""
|
23
|
+
<section>
|
24
|
+
<h1>
|
25
|
+
Made with RevealCK
|
26
|
+
</h1>
|
27
|
+
<p class='small'>
|
28
|
+
oh yeah!
|
29
|
+
</p>
|
30
|
+
</section>
|
31
|
+
|
32
|
+
"""
|
33
|
+
And the file "slides/index.html" should contain:
|
34
|
+
"""
|
35
|
+
<section>
|
36
|
+
<h1>
|
37
|
+
Made with RevealCK
|
38
|
+
</h1>
|
39
|
+
<p class='small'>
|
40
|
+
oh yeah!
|
41
|
+
</p>
|
42
|
+
</section>
|
43
|
+
"""
|
44
|
+
|
45
|
+
Scenario: Generating slides with images
|
46
|
+
Given a file named "images/ruby100.png" that's a copy of "data/images/ruby100.png"
|
47
|
+
And a file named "slides.haml" with:
|
48
|
+
"""
|
49
|
+
%section
|
50
|
+
%img{ alt: 'Ruby Logo', src: 'images/ruby100.png' }
|
51
|
+
"""
|
52
|
+
When I run `reveal-ck generate`
|
53
|
+
Then the exit status should be 0
|
54
|
+
And the following files should exist:
|
55
|
+
| slides.html |
|
56
|
+
| slides/index.html |
|
57
|
+
| slides/images/ruby100.png |
|
58
|
+
And the file "slides/index.html" should contain:
|
59
|
+
"""
|
60
|
+
<section>
|
61
|
+
<img alt='Ruby Logo' src='images/ruby100.png' />
|
62
|
+
</section>
|
63
|
+
"""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Getting Command Line Help
|
2
|
+
|
3
|
+
reveal-ck provides general command line help to a user so that she
|
4
|
+
understands what it does and is aware of the commands and options.
|
5
|
+
|
6
|
+
Scenario: Show general help if reveal-ck is run without options
|
7
|
+
When I run `reveal-ck`
|
8
|
+
Then it should pass with:
|
9
|
+
"""
|
10
|
+
help - Shows a list of commands or help for one command
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: Show general help if reveal-ck is run with --help
|
14
|
+
When I run `reveal-ck --help`
|
15
|
+
Then it should pass with:
|
16
|
+
"""
|
17
|
+
help - Shows a list of commands or help for one command
|
18
|
+
"""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
4
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
5
|
+
|
6
|
+
Before do
|
7
|
+
# Using "announce" causes massive warnings on 1.9.2
|
8
|
+
@puts = true
|
9
|
+
@original_rubylib = ENV['RUBYLIB']
|
10
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
After do
|
14
|
+
ENV['RUBYLIB'] = @original_rubylib
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Absolute path of reveal-ck/features
|
2
|
+
def features_dir
|
3
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
4
|
+
end
|
5
|
+
|
6
|
+
# Support for easily copying any file underneath features to a new
|
7
|
+
# location. Presumed to be helpful for copying around test data stored
|
8
|
+
# at reveal-ck/features/data.
|
9
|
+
def copy_file_under_features(rel_features_file, dest_file)
|
10
|
+
abs_features_file = File.join features_dir, rel_features_file
|
11
|
+
in_current_dir do
|
12
|
+
dest_dir = File.dirname dest_file
|
13
|
+
FileUtils.mkdir_p(dest_dir) unless File.directory?(dest_dir)
|
14
|
+
FileUtils.cp abs_features_file, dest_dir
|
15
|
+
end
|
16
|
+
end
|
data/lib/reveal-ck.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class FileSlicer
|
2
|
+
|
3
|
+
def self.remove!(path, range)
|
4
|
+
slice_file = if File.exists? path
|
5
|
+
path
|
6
|
+
else
|
7
|
+
File.expand_path(File.join(Dir.pwd, path))
|
8
|
+
end
|
9
|
+
lines = File.open(slice_file).readlines
|
10
|
+
slicer = FileSlicer.new lines
|
11
|
+
sliced_lines = slicer.remove range
|
12
|
+
File.open(slice_file, 'w') { |f| f << sliced_lines.join }
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(lines)
|
16
|
+
@lines = lines
|
17
|
+
end
|
18
|
+
|
19
|
+
def remove(range)
|
20
|
+
@lines.select.with_index { |line, index| ! range.cover? index }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|