publishing_logic 0.0.0
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.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/features/publishing_logic.feature +9 -0
- data/features/step_definitions/publishing_logic_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/model_logic.rb +7 -0
- data/lib/publishing_logic.rb +0 -0
- data/rails_generators/publishing_logic_fields/publishing_logic_fields_generator.rb +13 -0
- data/spec/lib/model_logic_spec.rb +16 -0
- data/spec/publishing_logic_spec.rb +4 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +18 -0
- metadata +92 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Unboxed Consulting
|
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,27 @@
|
|
1
|
+
= publishing_logic
|
2
|
+
|
3
|
+
Publishing logic for ActiveRecord models
|
4
|
+
* Generates a migration with fields required for publishing
|
5
|
+
logic. Fields are:
|
6
|
+
* publishing_enabled:boolean
|
7
|
+
* publish_from_datetime:datetime
|
8
|
+
* publish_until_datetime:datetime
|
9
|
+
* Defines logic on models that include PublishingLogic::ModelLogic
|
10
|
+
* published named scope
|
11
|
+
* published? method
|
12
|
+
* ordering by publish_from_date
|
13
|
+
|
14
|
+
== Note on Patches/Pull Requests
|
15
|
+
|
16
|
+
* Fork the project.
|
17
|
+
* Make your feature addition or bug fix.
|
18
|
+
* Add tests for it. This is important so I don't break it in a
|
19
|
+
future version unintentionally.
|
20
|
+
* Commit, do not mess with rakefile, version, or history.
|
21
|
+
(if you want to have your own version, that is fine but
|
22
|
+
bump version in a commit by itself I can ignore when I pull)
|
23
|
+
* Send me a pull request. Bonus points for topic branches.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2009 Unboxed Consulting. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "publishing_logic"
|
8
|
+
gem.summary = %Q{Publishing logic for ActiveRecord models}
|
9
|
+
gem.description = %Q{Publishing logic for ActiveRecord models}
|
10
|
+
gem.email = "enquiries@unboxedconsulting.com"
|
11
|
+
gem.homepage = "http://github.com/tomtt/publishing_logic"
|
12
|
+
gem.authors = ["Unboxed Consulting"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "cucumber", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
Cucumber::Rake::Task.new(:features)
|
39
|
+
|
40
|
+
task :features => :check_dependencies
|
41
|
+
rescue LoadError
|
42
|
+
task :features do
|
43
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :spec
|
48
|
+
|
49
|
+
require 'rake/rdoctask'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "publishing_logic #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
File without changes
|
data/lib/model_logic.rb
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class PublishingLogicGenerator < Rails::Generator::NamedBase
|
2
|
+
def initialize(args, options)
|
3
|
+
super(args, options)
|
4
|
+
end
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
record do |m|
|
8
|
+
m.migration_template 'publishing_logic_fields.rb', 'db/migrate', :assigns => {
|
9
|
+
:migration_name => "AddPublishingLogicFieldsTo#{class_name.pluralize.gsub(/::/, '')}"
|
10
|
+
}, :migration_file_name => "add_publishing_logic_field_to_#{file_path.gsub(/\//, '_').pluralize}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
2
|
+
require 'model_logic'
|
3
|
+
|
4
|
+
class FunItem < ActiveRecord::Base
|
5
|
+
include PublishingLogic::ModelLogic
|
6
|
+
end
|
7
|
+
|
8
|
+
Factory.define :fun_item do |c|
|
9
|
+
end
|
10
|
+
|
11
|
+
describe PublishingLogic::ModelLogic do
|
12
|
+
it "should be published by default" do
|
13
|
+
# Factory.create(:fun_item, :publishing_enabled => true).should be_published
|
14
|
+
Factory.create(:fun_item).should be_published
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
ENV["RAILS_ENV"] ||= "test"
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../../../../config/environment"))
|
5
|
+
require 'spec/rails'
|
6
|
+
|
7
|
+
require 'factory_girl'
|
8
|
+
|
9
|
+
# require 'publishing_logic'
|
10
|
+
# require 'spec'
|
11
|
+
# require 'spec/autorun'
|
12
|
+
|
13
|
+
class Programme < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
|
16
|
+
Spec::Runner.configure do |config|
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: publishing_logic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Unboxed Consulting
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-09 00:00:00 +00:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Publishing logic for ActiveRecord models
|
36
|
+
email: enquiries@unboxedconsulting.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- features/publishing_logic.feature
|
52
|
+
- features/step_definitions/publishing_logic_steps.rb
|
53
|
+
- features/support/env.rb
|
54
|
+
- lib/model_logic.rb
|
55
|
+
- lib/publishing_logic.rb
|
56
|
+
- rails_generators/publishing_logic_fields/publishing_logic_fields_generator.rb
|
57
|
+
- spec/lib/model_logic_spec.rb
|
58
|
+
- spec/publishing_logic_spec.rb
|
59
|
+
- spec/spec.opts
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/tomtt/publishing_logic
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --charset=UTF-8
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.3.5
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Publishing logic for ActiveRecord models
|
89
|
+
test_files:
|
90
|
+
- spec/lib/model_logic_spec.rb
|
91
|
+
- spec/publishing_logic_spec.rb
|
92
|
+
- spec/spec_helper.rb
|