sinatra-strap 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +7 -26
- data/exe/sinatra-strap +2 -1
- data/lib/sinatra/strap/version.rb +1 -1
- data/lib/sinatra/strap.rb +31 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 799c8b095c608c7145570fe0a45babf95f9f07a6
|
4
|
+
data.tar.gz: ba0660f9a666a291b6a10eac050432bb0859d422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f253e0a19f96c80562e452f7b9430535914633caace79c7bb752a402070e9ae57c0f4aceb6d2cb9e74a73d93bd91afd7eccc18819e0fe9241da2f134f6ed4ac3
|
7
|
+
data.tar.gz: 11fc4341978696df769efc1599357417a19d245b6e8e2202d2bfc2bc6e707195cd2030074b3bd58281096a7d36ec67c7257c4f8d2297e3566bee294145026d7e
|
data/README.md
CHANGED
@@ -1,36 +1,17 @@
|
|
1
1
|
# Sinatra::Strap
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sinatra/strap`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'sinatra-strap'
|
13
6
|
```
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install sinatra-strap
|
7
|
+
$ gem install sinatra-strap
|
8
|
+
```
|
22
9
|
|
23
10
|
## Usage
|
24
11
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sinatra-strap.
|
12
|
+
```
|
13
|
+
$ sinatra-strap new APP_PATH
|
14
|
+
```
|
36
15
|
|
16
|
+
## Author
|
17
|
+
Shohei Aoki <<shoaok@gmail.com>>
|
data/exe/sinatra-strap
CHANGED
data/lib/sinatra/strap.rb
CHANGED
@@ -4,12 +4,19 @@ module Sinatra
|
|
4
4
|
module Strap
|
5
5
|
class Base
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
attr_accessor :appname
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@vendor_dir = File.expand_path "#{File.dirname(__FILE__)}/../../vendor"
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate
|
14
|
+
unless directory_exists?(@appname)
|
15
|
+
system("mkdir #{@appname}")
|
16
|
+
system("cp -r #{@vendor_dir}/public #{@appname}")
|
17
|
+
system("cp -r #{@vendor_dir}/views #{@appname}")
|
18
|
+
system("cp #{@vendor_dir}/app.rb #{@appname}")
|
19
|
+
replace
|
13
20
|
else
|
14
21
|
puts "app folder already exists."
|
15
22
|
end
|
@@ -22,7 +29,24 @@ module Sinatra
|
|
22
29
|
end
|
23
30
|
|
24
31
|
def directory_exists?(directory)
|
25
|
-
|
32
|
+
File.directory?(directory)
|
33
|
+
end
|
34
|
+
|
35
|
+
def replace
|
36
|
+
template_path = File.expand_path "#{Dir.pwd}/#{@appname}/views/index.haml"
|
37
|
+
open("#{template_path}","r+") {|f|
|
38
|
+
f.flock(File::LOCK_EX)
|
39
|
+
body = f.read
|
40
|
+
body = body.gsub(/%title.*/) do |tmp|
|
41
|
+
"%title #{@appname}"
|
42
|
+
end
|
43
|
+
body = body.gsub(/%h1.*/) do |tmp|
|
44
|
+
"%h1 #{@appname}"
|
45
|
+
end
|
46
|
+
f.rewind
|
47
|
+
f.puts body
|
48
|
+
f.truncate(f.tell)
|
49
|
+
}
|
26
50
|
end
|
27
51
|
|
28
52
|
end
|