copyright_presenter 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rspec
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in copyright_presenter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jason Harrelson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # CopyrightPresenter
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'copyright_presenter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install copyright_presenter
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'copyright_presenter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "copyright_presenter"
8
+ spec.version = CopyrightPresenter::VERSION
9
+ spec.authors = ["Jason Harrelson"]
10
+ spec.email = ["jason@lookforwardenterprises.com"]
11
+ spec.description = %q{Provides a set of tools to help in presenting copyright text.}
12
+ spec.summary = %q{Tools for presenting copyright text.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,8 @@
1
+ require "copyright_presenter/version"
2
+
3
+ module CopyrightPresenter
4
+
5
+ autoload :Copyright, 'copyright_presenter/copyright'
6
+ autoload :Helpers, 'copyright_presenter/helpers'
7
+
8
+ end
@@ -0,0 +1,40 @@
1
+ module CopyrightPresenter
2
+
3
+ class Copyright
4
+
5
+ attr_reader :company, :start_year
6
+
7
+ def initialize( company, start_year=Time.now.strftime( '%Y' ) )
8
+ @company = company
9
+ @start_year = start_year
10
+ end
11
+
12
+ def long( options={:single_year => false} )
13
+ "#{short( options )} All Rights Reserved."
14
+ end
15
+
16
+ def short( options={:single_year => false} )
17
+ "Copyright #{symbol} #{years( options )} #{company}."
18
+ end
19
+
20
+ def symbol
21
+ "©"
22
+ end
23
+
24
+ protected
25
+
26
+ def current_year
27
+ Time.now.strftime( '%Y' )
28
+ end
29
+
30
+ def years( options )
31
+ if options[:single_year] || start_year == current_year
32
+ return current_year
33
+ end
34
+
35
+ return "#{start_year} - #{current_year}"
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,29 @@
1
+ module CopyrightPresenter
2
+ module Helpers
3
+
4
+ def copyright_long( name, start_year=Time.now.strftime( '%Y' ))
5
+ copyright_long_multi_year( name, start_year )
6
+ end
7
+
8
+ def copyright_short( name, start_year=Time.now.strftime( '%Y' ))
9
+ copyright_short_multi_year( name, start_year )
10
+ end
11
+
12
+ def copyright_long_single_year( company_name, start_year=Time.now.strftime( '%Y' ))
13
+ CopyrightPresenter::Copyright.new( company_name, start_year ).long( :single_year => true )
14
+ end
15
+
16
+ def copyright_long_multi_year( company_name, start_year=Time.now.strftime( '%Y' ))
17
+ CopyrightPresenter::Copyright.new( company_name, start_year ).long
18
+ end
19
+
20
+ def copyright_short_single_year( company_name, start_year=Time.now.strftime( '%Y' ))
21
+ CopyrightPresenter::Copyright.new( company_name, start_year ).short( :single_year => true )
22
+ end
23
+
24
+ def copyright_short_multi_year( company_name, start_year=Time.now.strftime( '%Y' ))
25
+ CopyrightPresenter::Copyright.new( company_name, start_year ).short
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module CopyrightPresenter
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe CopyrightPresenter::Copyright do
4
+
5
+ let :company_name do
6
+ 'Some Company'
7
+ end
8
+
9
+ let :current_year do
10
+ Time.now.strftime '%Y'
11
+ end
12
+
13
+ context 'when no #start_year is provided' do
14
+
15
+ subject do
16
+ described_class.new company_name
17
+ end
18
+
19
+ its( :short ) { should == "Copyright © 2013 #{company_name}." }
20
+
21
+ its( :long ) { should == "Copyright © 2013 #{company_name}. All Rights Reserved." }
22
+
23
+ end
24
+
25
+ context 'when a #start_year is provided' do
26
+
27
+ subject do
28
+ described_class.new company_name, start_year
29
+ end
30
+
31
+ let :start_year do
32
+ 2008
33
+ end
34
+
35
+ its( :short ) { should == "Copyright © #{start_year} - #{current_year} #{company_name}." }
36
+
37
+ its( :long ) { should == "Copyright © #{start_year} - #{current_year} #{company_name}. All Rights Reserved." }
38
+
39
+ context 'when the :single_year options is provided as true' do
40
+
41
+ let :options do
42
+ { :single_year => true }
43
+ end
44
+
45
+ it "should return the correct value for #short" do
46
+ subject.short( options ).should == "Copyright © #{current_year} #{company_name}."
47
+ end
48
+
49
+ it "should return the correct value for #long" do
50
+ subject.long( options ).should == "Copyright © #{current_year} #{company_name}. All Rights Reserved."
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe CopyrightPresenter::Helpers do
4
+
5
+ class SomeHelper
6
+ include CopyrightPresenter::Helpers
7
+ end
8
+
9
+ subject { SomeHelper.new }
10
+
11
+ let :company_name do
12
+ 'Some Company'
13
+ end
14
+
15
+ let :current_year do
16
+ Time.now.strftime( '%Y' )
17
+ end
18
+
19
+ context 'when no #start_year is provided' do
20
+
21
+ it "should return the correct value for #copyright_long" do
22
+ subject.copyright_long( company_name ).should == "Copyright © #{current_year} #{company_name}. All Rights Reserved."
23
+ end
24
+
25
+ it "should return the correct value for #copyright_short" do
26
+ subject.copyright_short( company_name ).should == "Copyright © #{current_year} #{company_name}."
27
+ end
28
+
29
+ end
30
+
31
+ context 'when a #start_year is provided' do
32
+
33
+ let :start_year do
34
+ 2008
35
+ end
36
+
37
+ it "should return the correct value for #copyright_long" do
38
+ subject.copyright_long( company_name, start_year ).should == "Copyright © #{start_year} - #{current_year} #{company_name}. All Rights Reserved."
39
+ end
40
+
41
+ it "should return the correct value for #copyright_short" do
42
+ subject.copyright_short( company_name, start_year ).should == "Copyright © #{start_year} - #{current_year} #{company_name}."
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'copyright_presenter'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ config.mock_with :rspec
9
+
10
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: copyright_presenter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Harrelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Provides a set of tools to help in presenting copyright text.
63
+ email:
64
+ - jason@lookforwardenterprises.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - copyright_presenter.gemspec
75
+ - lib/copyright_presenter.rb
76
+ - lib/copyright_presenter/copyright.rb
77
+ - lib/copyright_presenter/helpers.rb
78
+ - lib/copyright_presenter/version.rb
79
+ - spec/copyright_presenter/copyright_spec.rb
80
+ - spec/copyright_presenter/helpers_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: -1415019662730180900
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: -1415019662730180900
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.25
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Tools for presenting copyright text.
113
+ test_files:
114
+ - spec/copyright_presenter/copyright_spec.rb
115
+ - spec/copyright_presenter/helpers_spec.rb
116
+ - spec/spec_helper.rb