markup_model 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3edbb9c665be475c56c06ee0271a31cb564625ff
4
+ data.tar.gz: 5b94726f0a13fb3d8a168a2858b804ce6621b836
5
+ SHA512:
6
+ metadata.gz: 914de1998ba817cfc2d60b661dabebac617a147556b6d26ca214ffbbbc8ff3f701f965d8892ac5979dd6a801d92182c5299d5589c8df4d2b6cb06340bf2e1d75
7
+ data.tar.gz: 05d2fd888bf4473201e60140a4501340d3b4ee1522d8fe5a072fb7fc67375b2adeb3f08459306f236db96205587183b5f03e4f1ffe3fa00fed94cb9dbca5b1aa
data/README.md CHANGED
@@ -1,24 +1,43 @@
1
1
  # MarkupModel
2
2
 
3
- TODO: Write a gem description
3
+ Loads ActiveModel records from Markdown files (with YAML headers). This allows you to keep records in your git repository then load them into your DB for querying as a deploy task.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your application's Gemfile and run `bundle install`:
8
8
 
9
9
  gem 'markup_model'
10
10
 
11
- And then execute:
11
+ ## Usage
12
12
 
13
- $ bundle
13
+ Create a model like this:
14
14
 
15
- Or install it yourself as:
15
+ ```ruby
16
+ class Post < ActiveRecord::Base
17
+ include MarkupModel
16
18
 
17
- $ gem install markup_model
19
+ validates :content, :published_at, :title, presence: true
18
20
 
19
- ## Usage
21
+ def self.default_yaml_header
22
+ {
23
+ published_at: Time.zone.now,
24
+ title: "New Post",
25
+ }
26
+ end
27
+ end
28
+ ```
29
+
30
+ Then generate a Markdown file for the model by running:
31
+
32
+ ```
33
+ rails g markup_model:model Post
34
+ ```
35
+
36
+ After you finish editing the file, update the records in your DB:
20
37
 
21
- TODO: Write usage instructions here
38
+ ```
39
+ rake markup_model:reload CLASS=Post
40
+ ```
22
41
 
23
42
  ## Contributing
24
43
 
@@ -3,7 +3,10 @@ require "markup_model/config"
3
3
  require "markup_model/model_file"
4
4
  require "markup_model/version"
5
5
 
6
- require "markup_model/engine" if defined?(Rails)
6
+ if defined?(Rails)
7
+ require "markup_model/engine"
8
+ require "markup_model/generators/model_generator"
9
+ end
7
10
 
8
11
  module MarkupModel
9
12
  extend ActiveSupport::Concern
@@ -3,5 +3,9 @@ module MarkupModel
3
3
  initializer "markup_model.config" do
4
4
  MarkupModel.config.content_directory ||= Rails.root + "content"
5
5
  end
6
+
7
+ rake_tasks do
8
+ load "markup_model/tasks.rake"
9
+ end
6
10
  end
7
11
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+
3
+ module MarkupModel
4
+ module Generators
5
+ class ModelGenerator < Rails::Generators::Base
6
+ argument :class_name, :type => :string
7
+
8
+ def method_name
9
+ klass = class_name.constantize
10
+ id = (klass.markup_model_files.map(&:id).map(&:to_i).max || 0) + 1
11
+ path = "#{MarkupModel.config.content_directory}/#{klass.model_name.plural}/%03d.md" % id
12
+
13
+ create_file path,
14
+ "#{YAML.dump(klass.default_yaml_header.stringify_keys)}---\n\nType content here using *Markdown* or <em>HTML</em>."
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ namespace :markup_model do
2
+ desc "Reloads a markup model. Needs the CLASS environment variable."
3
+ task :reload => :environment do
4
+ raise "CLASS environment variable not set" unless ENV['CLASS'].present?
5
+ klass = ENV['CLASS'].constantize
6
+ klass.markup_model_reload
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module MarkupModel
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markup_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Alexander
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-08 00:00:00.000000000 Z
11
+ date: 2013-03-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard-rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pry
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: supermodel
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Under construction
@@ -107,7 +96,9 @@ files:
107
96
  - lib/markup_model.rb
108
97
  - lib/markup_model/config.rb
109
98
  - lib/markup_model/engine.rb
99
+ - lib/markup_model/generators/model_generator.rb
110
100
  - lib/markup_model/model_file.rb
101
+ - lib/markup_model/tasks.rake
111
102
  - lib/markup_model/version.rb
112
103
  - markup_model.gemspec
113
104
  - spec/content/posts/001.md
@@ -116,27 +107,26 @@ files:
116
107
  - spec/spec_helper.rb
117
108
  homepage: https://github.com/balexand/markup_model
118
109
  licenses: []
110
+ metadata: {}
119
111
  post_install_message:
120
112
  rdoc_options: []
121
113
  require_paths:
122
114
  - lib
123
115
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
116
  requirements:
126
- - - ! '>='
117
+ - - '>='
127
118
  - !ruby/object:Gem::Version
128
119
  version: '0'
129
120
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
121
  requirements:
132
- - - ! '>='
122
+ - - '>='
133
123
  - !ruby/object:Gem::Version
134
124
  version: '0'
135
125
  requirements: []
136
126
  rubyforge_project:
137
- rubygems_version: 1.8.24
127
+ rubygems_version: 2.0.0
138
128
  signing_key:
139
- specification_version: 3
129
+ specification_version: 4
140
130
  summary: Under construction
141
131
  test_files:
142
132
  - spec/content/posts/001.md