georgedrummond_sinatra_helpers 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011, George Drummond, AccountsApp Ltd
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
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = GeorgeDrummond::Sinatra::Helpers
2
+
3
+ This is a collection of common helper methods that I use within my Sinatra apps. They have a rails like feel and they mainly fill in for helpers you would find in Rails. They do not behave exactly like their rails counterparts so please be careful to read the RDOC.
4
+
5
+ == Installation
6
+
7
+ First of all install the gem or add it to your Gemfile.
8
+
9
+ gem install georgedrummond_sinatra_helpers
10
+
11
+ In your Gemfile
12
+
13
+ gem "georgedrummond_sinatra_helpers"
14
+
15
+
16
+ == Usage
17
+
18
+ Sample usage in a project
19
+
20
+ require "georgedrummond_sinatra_helpers"
21
+
22
+ class Application < Sinatra::Base
23
+ include GeorgeDrummond::Sinatra::Helpers
24
+
25
+ get "/" do
26
+ haml :index
27
+ end
28
+
29
+ end
30
+
31
+ Helper methods will be available in your views and methods within the Application class.
32
+
33
+ == Documentation
34
+
35
+ For documentation please see GeorgeDrummond::Sinatra::Helpers
36
+
37
+ == License
38
+
39
+ Released under the MIT License.
@@ -4,21 +4,19 @@ require "georgedrummond_sinatra_helpers/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "georgedrummond_sinatra_helpers"
7
- s.version = GeorgedrummondSinatraHelpers::VERSION
7
+ s.version = GeorgeDrummond::Sinatra::Helpers::VERSION
8
8
  s.authors = ["George Drummond"]
9
9
  s.email = ["george@accountsapp.com"]
10
- s.homepage = ""
11
- s.summary = %q{Common helper methods}
12
- s.description = %q{Some common helper methods I use in my apps}
13
-
14
- s.rubyforge_project = "georgedrummond_sinatra_helpers"
10
+ s.homepage = "https://github.com/georgedrummond/georgedrummond_sinatra_helpers"
11
+ s.description = %q{This is a collection of common helper methods that I use within my Sinatra apps. They have a rails like feel and they mainly fill in for helpers you would find in Rails. They do not behave exactly like their rails counterparts so please be careful to read the RDOC.}
12
+ s.summary = s.description
15
13
 
14
+ s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
15
+ s.rdoc_options = %w[--line-numbers --inline-source --title Sinatra --main README.rdoc]
16
+
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
20
  s.require_paths = ["lib"]
20
21
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
24
22
  end
@@ -3,7 +3,22 @@ require "georgedrummond_sinatra_helpers/version"
3
3
  module GeorgeDrummond
4
4
  module Sinatra
5
5
  module Helpers
6
-
6
+ # Creates html tags for stylesheets from the arguements provided. Dont include the <tt>.css</tt> extension as this
7
+ # will be automatically appended. You can specify one or multiple css files at once. Place your css files in
8
+ # the <tt>public/css</tt> folder of your app.
9
+ #
10
+ # ==== Examples
11
+ #
12
+ # With only one CSS file
13
+ #
14
+ # stylesheet_link_tag :app
15
+ # # => <link href="/css/app.css" type="text/css" />
16
+ #
17
+ # With an array of CSS files we want to show
18
+ #
19
+ # stylesheet_link_tag :app, :header # =>
20
+ # <link href="/css/app.css" type="text/css" />
21
+ # <link href="/css/header.css" type="text/css" />
7
22
  def stylesheet_link_tag(*sources)
8
23
  html = []
9
24
  sources.each do |stylesheet|
@@ -12,7 +27,23 @@ module GeorgeDrummond
12
27
  end
13
28
  return html.join("\n")
14
29
  end
15
-
30
+
31
+ # Creates html tags for javascript includes from the arguments provided. Dont include the <tt>.js</tt> extension as this
32
+ # will be automatically appended. You can specify one or multiple javascript files at once. Place your javascript files in
33
+ # the <tt>public/js</tt> folder of your app.
34
+ #
35
+ # ==== Examples
36
+ #
37
+ # With only one javascript file
38
+ #
39
+ # javascript_include_tag :app
40
+ # # => <script type="text/javascript" src="/js/app.js"></script>
41
+ #
42
+ # With an array of javascript files we want to show
43
+ #
44
+ # javascript_include_tag :jquery, :app # =>
45
+ # <script type="text/javascript" src="/js/jquery.js"></script>
46
+ # <script type="text/javascript" src="/js/app.js"></script>
16
47
  def javascript_include_tag(*sources)
17
48
  html = []
18
49
  sources.each do |javascript|
@@ -21,12 +52,26 @@ module GeorgeDrummond
21
52
  end
22
53
  return html.join("\n")
23
54
  end
24
-
55
+
56
+ # Creates a html image tag given a file name. File should be located in <tt>public/images</tt>. Will not work with external
57
+ # files for now however I may add this at a later date if it is needed.
58
+ #
59
+ # ==== Examples
60
+ #
61
+ # image_tag "home.png"
62
+ # # => <img src="/images/home.png" />
25
63
  def image_tag(image)
26
64
  path = "/images/#{image}"
27
65
  return "<img src=\"#{url(path)}\" />\n"
28
66
  end
29
67
 
68
+ # Creates a html link tag given a page <tt>title</tt> and resource <tt>path</tt>. Works similar to the Rails link_to method
69
+ # however does not accept any other options.
70
+ #
71
+ # ==== Examples
72
+ #
73
+ # link_to "Home", "/"
74
+ # # => <a href="/">Home</a>
30
75
  def link_to(title, path)
31
76
  return "<a href=\"#{url(path)}\">#{title}</a>"
32
77
  end
@@ -1,3 +1,7 @@
1
- module GeorgedrummondSinatraHelpers
2
- VERSION = "0.0.1"
1
+ module GeorgeDrummond
2
+ module Sinatra
3
+ module Helpers
4
+ VERSION = "0.0.2"
5
+ end
6
+ end
3
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgedrummond_sinatra_helpers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - George Drummond
@@ -15,31 +15,39 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-16 00:00:00 Z
18
+ date: 2011-10-17 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: Some common helper methods I use in my apps
21
+ description: This is a collection of common helper methods that I use within my Sinatra apps. They have a rails like feel and they mainly fill in for helpers you would find in Rails. They do not behave exactly like their rails counterparts so please be careful to read the RDOC.
22
22
  email:
23
23
  - george@accountsapp.com
24
24
  executables: []
25
25
 
26
26
  extensions: []
27
27
 
28
- extra_rdoc_files: []
29
-
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ - LICENSE
30
31
  files:
31
32
  - .gitignore
32
33
  - Gemfile
34
+ - LICENSE
35
+ - README.rdoc
33
36
  - Rakefile
34
37
  - georgedrummond_sinatra_helpers.gemspec
35
38
  - lib/georgedrummond_sinatra_helpers.rb
36
39
  - lib/georgedrummond_sinatra_helpers/version.rb
37
- homepage: ""
40
+ homepage: https://github.com/georgedrummond/georgedrummond_sinatra_helpers
38
41
  licenses: []
39
42
 
40
43
  post_install_message:
41
- rdoc_options: []
42
-
44
+ rdoc_options:
45
+ - --line-numbers
46
+ - --inline-source
47
+ - --title
48
+ - Sinatra
49
+ - --main
50
+ - README.rdoc
43
51
  require_paths:
44
52
  - lib
45
53
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -62,10 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
70
  version: "0"
63
71
  requirements: []
64
72
 
65
- rubyforge_project: georgedrummond_sinatra_helpers
73
+ rubyforge_project:
66
74
  rubygems_version: 1.8.10
67
75
  signing_key:
68
76
  specification_version: 3
69
- summary: Common helper methods
77
+ summary: This is a collection of common helper methods that I use within my Sinatra apps. They have a rails like feel and they mainly fill in for helpers you would find in Rails. They do not behave exactly like their rails counterparts so please be careful to read the RDOC.
70
78
  test_files: []
71
79