gast 0.0.1 → 0.0.2

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: 7137e787b00e633d33b82e86e81521ac9d74d184
4
- data.tar.gz: f46f99a0614c4a5f37a5bcbde3cd7586babdfe3e
3
+ metadata.gz: 62f0f0b4b03eaf63cbfb2e6ddb5d41137b174ddd
4
+ data.tar.gz: 5d18e8c2a79ade92fb5c3ca3881a24f75d0549c4
5
5
  SHA512:
6
- metadata.gz: c4f0669303fb5278c7947d888b443bec0a52a513a86e19171e5c4f11e076e4fa6d22a20a8eb42b0984deb75c359c5207213fb4e0ca18d1908cd4d5a488946e71
7
- data.tar.gz: e278d5c37a085b5702c6aad84d16420b78374c3be3d14a947d457d15f39affc12888ec2038985bfa8271ebd90540da03ace082003240db6986054398af849c64
6
+ metadata.gz: beee6f573bde844c995656b335571892c1e7a45fdff0679b18b4c23fc1c07acf2527ed636f956272769eab887084345eb1ea239a26bf9e49967dbf39629b88f1
7
+ data.tar.gz: f42392c4a42e9f6cde24c7a98b08fdf600663b0f3aeb51c49874d58538b9c9627ba918f6eca3a42a0ab164ead6bc830d63bbc1af1a071671fbe534488578206e
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ before_install:
3
+ - travis_retry gem install bundler
4
+ before_script:
5
+ - git config --global user.name "travis.ci"
6
+ - git config --global user.email "travis-test@example.com"
7
+ rvm:
8
+ - 2.1
9
+ bundler_args: --path vendor/bundle
10
+ script: bundle ex rspec
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Gast
2
2
 
3
- TODO: Write a gem description
3
+ [![Build Status](https://travis-ci.org/futoase/gast.svg?branch=feature/support-travis)](https://travis-ci.org/futoase/gast)
4
+
5
+ memo application of using git.
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,7 +20,10 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ ```
24
+ > gast
25
+ > open http://localhost:4567/
26
+ ```
22
27
 
23
28
  ## Contributing
24
29
 
data/lib/gast/app.rb CHANGED
@@ -1,8 +1,3 @@
1
- require 'sinatra/base'
2
- require 'sinatra/reloader'
3
- require 'sprockets'
4
- require 'sprockets-helpers'
5
- require 'gast/memo'
6
1
  require 'gast'
7
2
 
8
3
  module Gast
@@ -23,7 +18,7 @@ module Gast
23
18
  config.environment = sprockets
24
19
  config.prefix = assets_prefix
25
20
  config.digest = digest_assets
26
- #config.public_path = public_folder
21
+ config.public_path = '/public'
27
22
 
28
23
  config.debug = true
29
24
  end
@@ -41,6 +36,14 @@ module Gast
41
36
  end
42
37
  end
43
38
 
39
+ not_found do
40
+ haml :not_found
41
+ end
42
+
43
+ error do
44
+ haml :error
45
+ end
46
+
44
47
  get '/' do
45
48
  haml :index, locals: { new_post: true }
46
49
  end
data/lib/gast/memo.rb CHANGED
@@ -1,7 +1,4 @@
1
- require 'git'
2
- require 'date'
3
- require 'digest/sha2'
4
- require 'gast/repository'
1
+ require 'gast'
5
2
 
6
3
  module Gast
7
4
 
@@ -9,15 +6,16 @@ module Gast
9
6
 
10
7
  def self.save(content)
11
8
  @repo = Gast::Repository.new
12
- @repo.content = content.to_s
9
+ @repo.content = CGI.unescapeHTML(content.to_s)
13
10
  @repo.publish
14
11
  @repo.commit!
15
12
  @repo.dir_name
16
13
  end
17
14
 
18
15
  def self.update(id, content)
16
+ return id if content.to_s.chomp == item(id).chomp
19
17
  @repo = Gast::Repository.new(id)
20
- @repo.content = content.to_s
18
+ @repo.content = CGI.unescapeHTML(content.to_s)
21
19
  @repo.publish
22
20
  @repo.commit!
23
21
  @repo.dir_name
@@ -34,7 +32,9 @@ module Gast
34
32
  end
35
33
 
36
34
  def self.item(id)
37
- File.read(File.expand_path(Gast::PATH + "/#{id}/content"))
35
+ CGI.escapeHTML(
36
+ File.read(File.expand_path(Gast::PATH + "/#{id}/content"))
37
+ )
38
38
  end
39
39
 
40
40
  def initialize; end
@@ -1,4 +1,4 @@
1
- require 'digest/sha2'
1
+ require 'gast'
2
2
 
3
3
  module Gast
4
4
  class Repository
@@ -1,2 +1,4 @@
1
1
  %h1
2
- Error!
2
+ Error
3
+ %p
4
+ Server Error!
@@ -0,0 +1,4 @@
1
+ %h1
2
+ Error
3
+ %p
4
+ Not Found
data/lib/gast/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gast
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/gast.rb CHANGED
@@ -1,5 +1,15 @@
1
- require "gast/version"
2
- require "gast/app"
1
+ require 'digest/sha2'
2
+ require 'sinatra/base'
3
+ require 'sinatra/reloader'
4
+ require 'sprockets'
5
+ require 'sprockets-helpers'
6
+ require 'gast/memo'
7
+ require 'gast/app'
8
+ require 'gast/repository'
9
+ require 'haml'
10
+ require 'sass'
11
+ require 'git'
12
+ require 'cgi'
3
13
 
4
14
  module Gast
5
15
  PATH = '/tmp/gast'
@@ -14,6 +14,7 @@ describe Gast::App do
14
14
 
15
15
  let(:hello_world) { "Hello World" }
16
16
  let(:welcome_to_underground) { "Welcome to underground" }
17
+ let(:inline_html) { "<script>alert('Hello world!');</script>" }
17
18
  let(:view_path) { /.+\/posts\/view\/[a-z0-9]+/ }
18
19
 
19
20
  it "should be get index" do
@@ -81,4 +82,27 @@ describe Gast::App do
81
82
  expect(File.read(repository + '/content')).to eq welcome_to_underground
82
83
  end
83
84
 
85
+ it "should be get not found" do
86
+ get "/posts/hoge"
87
+
88
+ expect(last_response).not_to be_ok
89
+ expect(last_response.status).to be 404
90
+ expect(last_response.body).to match(/Not Found/)
91
+ end
92
+
93
+ it "should be get content is escaped by HTML" do
94
+
95
+ post '/posts/new', { content: inline_html }
96
+
97
+ repository = File.expand_path(Dir.glob(repo_dir + '/**').first)
98
+
99
+ expect(File.read(repository + '/content')).to eq inline_html
100
+
101
+ get "/posts/view/#{repository.split('/').last}"
102
+
103
+ expect(last_response).to be_ok
104
+ expect(last_response.body).to include(CGI.escapeHTML(inline_html))
105
+
106
+ end
107
+
84
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - futoase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-18 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -244,6 +244,7 @@ extra_rdoc_files: []
244
244
  files:
245
245
  - ".gitignore"
246
246
  - ".rspec"
247
+ - ".travis.yml"
247
248
  - Gemfile
248
249
  - Guardfile
249
250
  - LICENSE.txt
@@ -254,7 +255,6 @@ files:
254
255
  - gast.gemspec
255
256
  - lib/gast.rb
256
257
  - lib/gast/app.rb
257
- - lib/gast/assets/stylesheets/application.sass
258
258
  - lib/gast/memo.rb
259
259
  - lib/gast/repository.rb
260
260
  - lib/gast/templates/edit.haml
@@ -266,6 +266,7 @@ files:
266
266
  - lib/gast/templates/layout.haml
267
267
  - lib/gast/templates/list.haml
268
268
  - lib/gast/templates/navbar.haml
269
+ - lib/gast/templates/not_found.haml
269
270
  - lib/gast/templates/save.haml
270
271
  - lib/gast/templates/view.haml
271
272
  - lib/gast/version.rb
File without changes