publishing_logic 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.document +1 -1
  3. data/.gitignore +9 -23
  4. data/.rspec +2 -0
  5. data/.specification.example +34 -34
  6. data/.travis.yml +4 -0
  7. data/CODE_OF_CONDUCT.md +49 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE +1 -1
  10. data/README.md +65 -0
  11. data/Rakefile +3 -49
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/lib/generators/publishing_logic/fields_generator.rb +13 -0
  15. data/lib/generators/publishing_logic/templates/migration.erb +10 -0
  16. data/lib/locale/en.yml +9 -0
  17. data/lib/locale/hu.yml +9 -0
  18. data/lib/publishing_logic.rb +7 -1
  19. data/lib/publishing_logic/model_logic.rb +51 -0
  20. data/lib/publishing_logic/version.rb +3 -0
  21. data/publishing_logic.gemspec +29 -0
  22. metadata +114 -176
  23. data/README.rdoc +0 -29
  24. data/VERSION +0 -1
  25. data/lib/model_logic.rb +0 -82
  26. data/rails_generators/publishing_logic_fields/USAGE +0 -2
  27. data/rails_generators/publishing_logic_fields/publishing_logic_fields_generator.rb +0 -34
  28. data/rails_generators/publishing_logic_fields/templates/app/views/publishing_logic_fields.html.erb +0 -12
  29. data/rails_generators/publishing_logic_fields/templates/db/migrate/add_publishing_logic_fields.rb.erb +0 -18
  30. data/spec/general_model_logic.rb +0 -93
  31. data/spec/models_with_all_fields_spec.rb +0 -85
  32. data/spec/models_with_no_published_until_field_spec.rb +0 -68
  33. data/spec/spec.opts +0 -1
  34. data/spec/spec_helper.rb +0 -55
  35. data/spec/support/database_cleanliness.rb +0 -14
  36. data/spec/support/database_connection.rb +0 -4
  37. data/spec/support/database_migrations.rb +0 -56
  38. data/spec/support/factories.rb +0 -10
  39. data/spec/support/logging.rb +0 -2
  40. data/spec/support/models/article.rb +0 -3
  41. data/spec/support/models/programme.rb +0 -3
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 287c958dddb6fe13f9d051a117ca72fe8f6fc588
4
+ data.tar.gz: 211a9d8ff00cbcd80bc215fd07116cfedcecc29c
5
+ SHA512:
6
+ metadata.gz: 1ff56dc46696bea5f033d6620c210884be30bdaeada20c2c98a03aee0d2d2ac67cbaf6b6c61616da57ae11e05e6bd29d7349e7a085e3dc40142202ef4bcb35eb
7
+ data.tar.gz: aba4e869e760739e2da5d39fdfb2d4d527ec49f4d683b8fa47c27b0992e5d9b6f3fce1170e16c93b35d3445cd0135f4d231f19012ab0a5abbfa07b09b421c868
data/.document CHANGED
@@ -1,4 +1,4 @@
1
- README.rdoc
1
+ README.md
2
2
  lib/**/*.rb
3
3
  bin/*
4
4
  features/**/*.feature
data/.gitignore CHANGED
@@ -1,23 +1,9 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- spec/support/test_publishing_logic.db
23
- test.log
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -1,47 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: publishing_logic
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
4
  version: 0.0.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Unboxed Consulting
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
12
  date: 2009-12-09 00:00:00 +00:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
17
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
21
  - - ">="
22
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
23
23
  version: 1.2.9
24
- version:
25
- - !ruby/object:Gem::Dependency
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
26
  name: cucumber
27
27
  type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
31
  - - ">="
32
- - !ruby/object:Gem::Version
32
+ - !ruby/object:Gem::Version
33
33
  version: "0"
34
- version:
34
+ version:
35
35
  description: Publishing logic for ActiveRecord models
36
36
  email: enquiries@unboxedconsulting.com
37
37
  executables: []
38
38
 
39
39
  extensions: []
40
40
 
41
- extra_rdoc_files:
41
+ extra_rdoc_files:
42
42
  - LICENSE
43
43
  - README.rdoc
44
- files:
44
+ files:
45
45
  - .document
46
46
  - .gitignore
47
47
  - LICENSE
@@ -62,31 +62,31 @@ has_rdoc: true
62
62
  homepage: http://github.com/tomtt/publishing_logic
63
63
  licenses: []
64
64
 
65
- post_install_message:
66
- rdoc_options:
65
+ post_install_message:
66
+ rdoc_options:
67
67
  - --charset=UTF-8
68
- require_paths:
68
+ require_paths:
69
69
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- requirements:
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
72
  - - ">="
73
- - !ruby/object:Gem::Version
73
+ - !ruby/object:Gem::Version
74
74
  version: "0"
75
- version:
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- requirements:
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
78
  - - ">="
79
- - !ruby/object:Gem::Version
79
+ - !ruby/object:Gem::Version
80
80
  version: "0"
81
- version:
81
+ version:
82
82
  requirements: []
83
83
 
84
- rubyforge_project:
84
+ rubyforge_project:
85
85
  rubygems_version: 1.3.5
86
- signing_key:
86
+ signing_key:
87
87
  specification_version: 3
88
88
  summary: Publishing logic for ActiveRecord models
89
- test_files:
89
+ test_files:
90
90
  - spec/lib/model_logic_spec.rb
91
91
  - spec/publishing_logic_spec.rb
92
92
  - spec/spec_helper.rb
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at attila@attilagyorffy.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in publishing_logic.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Unboxed Consulting
1
+ Copyright (c) 2009-2016 Unboxed Consulting, Attila Györffy
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # PublishingLogic
2
+
3
+ This gem adds publishing logic to ActiveRecord models. It can be used to schedule content using the scopes and methods the gem provides. The gem includes a migration generator that adds the necessary fields to your models. Fields are:
4
+
5
+ * `publishing_enabled:boolean`
6
+ * `published_at:datetime`
7
+ * `published_until:datetime` (optional)
8
+
9
+ By including `PublishingLogic::ModelLogic` in a model, the following methods are available:
10
+
11
+ * a `published` scope
12
+ * a `by_publication_date_oldest_first` scope
13
+ * a `by_publication_date_newest_first` scope
14
+ * a `#published?` method to check individual records
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'publishing_logic'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install publishing_logic
31
+
32
+ ## Usage
33
+
34
+ 1) After installing the gem add the publishing logic fields to your model by running:
35
+
36
+ $ bundle exec rails generate publishing_logic:fields MODEL_NAME
37
+
38
+ (To see full documentation of generator options run it without arguments)
39
+
40
+ 2) Include the `PublishingLogic::ModelLogic` module in the model you wish to add the logic to:
41
+
42
+ ```ruby
43
+ class Article < ActiveRecord::Base
44
+ include PublishingLogic::ModelLogic
45
+ end
46
+ ```
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+
52
+ 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).
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/liquid/publishing_logic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
57
+
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
62
+
63
+ ## Copyright
64
+
65
+ Copyright (c) 2009-2016 Unboxed Consulting and Channel 5 Broadcasting Ltd. See LICENSE for details
data/Rakefile CHANGED
@@ -1,52 +1,6 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
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/unboxed/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.add_development_dependency 'rspec-rails', ">= 1.3.0"
16
- gem.add_development_dependency 'factory_girl', ">= 1.2.0"
17
- gem.add_development_dependency 'activesupport', ">= 2.3.0"
18
- gem.add_development_dependency 'activerecord', ">= 2.3.0"
19
- gem.add_development_dependency 'database_cleaner', ">= 0.5.0"
20
-
21
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
- end
23
- Jeweler::GemcutterTasks.new
24
- rescue LoadError
25
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
26
- end
27
-
28
- require 'spec/rake/spectask'
29
- Spec::Rake::SpecTask.new(:spec) do |spec|
30
- spec.libs << 'lib' << 'spec'
31
- spec.spec_files = FileList['spec/**/*_spec.rb']
32
- end
33
-
34
- Spec::Rake::SpecTask.new(:rcov) do |spec|
35
- spec.libs << 'lib' << 'spec'
36
- spec.pattern = 'spec/**/*_spec.rb'
37
- spec.rcov = true
38
- end
39
-
40
- task :spec => :check_dependencies
4
+ RSpec::Core::RakeTask.new(:spec)
41
5
 
42
6
  task :default => :spec
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "publishing_logic #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "publishing_logic"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module PublishingLogic
4
+ module Generators
5
+ class FieldsGenerator < ActiveRecord::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_publishing_logic_fields_migration
9
+ migration_template "migration.erb", "db/migrate/add_publishing_logic_fields_to_#{table_name}.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class AddPublishingLogicFieldsTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def change
3
+ change_table :<%= table_name %> do |<%= table_name %>|
4
+ <%= table_name %>.boolean :publishing_enabled, default: false
5
+ <%= table_name %>.datetime :published_at
6
+ <%= table_name %>.datetime :published_until
7
+ <%= table_name %>.index [:published_at, :publishing_enabled, :published_until], name: 'index_<%= table_name %>_on_publishing_logic_fields'
8
+ end
9
+ end
10
+ end
data/lib/locale/en.yml ADDED
@@ -0,0 +1,9 @@
1
+ en:
2
+ attributes:
3
+ publishing_enabled: 'Publishing enabled?'
4
+ published_at: 'Published at'
5
+ published_unttil: 'Published until'
6
+ errors:
7
+ messages:
8
+ must_be_before_publishing_at: 'must be before publishing at'
9
+ must_be_in_the_future: 'must be in the future'
data/lib/locale/hu.yml ADDED
@@ -0,0 +1,9 @@
1
+ hu:
2
+ attributes:
3
+ publishing_enabled: 'Publikus?'
4
+ published_at: Közzététel kezdete
5
+ published_until: Közzététel vége
6
+ errors:
7
+ messages:
8
+ must_be_before_publishing_at: 'a közzététel kezdete után kell legyen'
9
+ must_be_in_the_future: 'nem lehet múltbéli időpont'
@@ -1 +1,7 @@
1
- require 'model_logic'
1
+ require 'publishing_logic/version'
2
+ require 'publishing_logic/model_logic'
3
+
4
+ if defined?(I18n)
5
+ I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml'
6
+ I18n.load_path << File.dirname(__FILE__) + '/locale/hu.yml'
7
+ end