sinatra-strap 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c531983dcde93d900f8bd81388ffd014216f582b
4
- data.tar.gz: a460de79378dd87c19b8dd3bfd67cc21e451d597
3
+ metadata.gz: 799c8b095c608c7145570fe0a45babf95f9f07a6
4
+ data.tar.gz: ba0660f9a666a291b6a10eac050432bb0859d422
5
5
  SHA512:
6
- metadata.gz: eddd42b8cc21a54cebeae0e552767e26bd6b14e35e01963c00b59a9ae0e94ab07e5fb54c3c3c4bf1185e69475e4a0aa7b6bcffc95ff68395d18a855e93eaf46b
7
- data.tar.gz: 1baf296d8f9a05ccea36761eae0ae52e2129f50053a1a702bb7819f61429059f04a57e5cefa5e14585eba987d9a5ddc282cc19744a2458c6a9f542b1a60842c0
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
- And then execute:
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
- TODO: Write usage instructions here
26
-
27
- ## Development
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
@@ -5,7 +5,8 @@ s = Sinatra::Strap::Base.new
5
5
 
6
6
  if ARGV[0] == "new"
7
7
  unless (appname=ARGV[1]) == nil
8
- s.generate(appname)
8
+ s.appname = appname
9
+ s.generate
9
10
  end
10
11
  else
11
12
  s.show_help
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Strap
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
data/lib/sinatra/strap.rb CHANGED
@@ -4,12 +4,19 @@ module Sinatra
4
4
  module Strap
5
5
  class Base
6
6
 
7
- def generate(appname)
8
- unless directory_exists?(appname)
9
- system("mkdir #{appname}")
10
- system("cp -r #{File.dirname(__FILE__)}/../..//vendor/public #{appname}")
11
- system("cp -r #{File.dirname(__FILE__)}/../../vendor/views #{appname}")
12
- system("cp #{File.dirname(__FILE__)}/../../vendor/app.rb #{appname}")
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
- File.directory?(directory)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-strap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shohei Aoki