parse_resource_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "parse_resource"
4
+ gem "rails"
5
+
6
+ group :test do
7
+ gem "rspec"
8
+ gem "generator_spec"
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.2)
5
+ actionpack (= 3.2.2)
6
+ mail (~> 2.4.0)
7
+ actionpack (3.2.2)
8
+ activemodel (= 3.2.2)
9
+ activesupport (= 3.2.2)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.1)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.2)
17
+ activemodel (3.2.2)
18
+ activesupport (= 3.2.2)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.2)
21
+ activemodel (= 3.2.2)
22
+ activesupport (= 3.2.2)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.2)
26
+ activemodel (= 3.2.2)
27
+ activesupport (= 3.2.2)
28
+ activesupport (3.2.2)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.0)
33
+ diff-lcs (1.1.3)
34
+ erubis (2.7.0)
35
+ generator_spec (0.8.5)
36
+ rails (>= 3.0, < 4.0)
37
+ rspec-rails
38
+ hike (1.2.1)
39
+ i18n (0.6.0)
40
+ journey (1.0.3)
41
+ json (1.6.6)
42
+ mail (2.4.4)
43
+ i18n (>= 0.4.0)
44
+ mime-types (~> 1.16)
45
+ treetop (~> 1.4.8)
46
+ mime-types (1.18)
47
+ multi_json (1.3.2)
48
+ parse_resource (1.7.1)
49
+ activemodel
50
+ activesupport
51
+ rest-client
52
+ polyglot (0.3.3)
53
+ rack (1.4.1)
54
+ rack-cache (1.2)
55
+ rack (>= 0.4)
56
+ rack-ssl (1.3.2)
57
+ rack
58
+ rack-test (0.6.1)
59
+ rack (>= 1.0)
60
+ rails (3.2.2)
61
+ actionmailer (= 3.2.2)
62
+ actionpack (= 3.2.2)
63
+ activerecord (= 3.2.2)
64
+ activeresource (= 3.2.2)
65
+ activesupport (= 3.2.2)
66
+ bundler (~> 1.0)
67
+ railties (= 3.2.2)
68
+ railties (3.2.2)
69
+ actionpack (= 3.2.2)
70
+ activesupport (= 3.2.2)
71
+ rack-ssl (~> 1.3.2)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (~> 0.14.6)
75
+ rake (0.9.2.2)
76
+ rdoc (3.12)
77
+ json (~> 1.4)
78
+ rest-client (1.6.7)
79
+ mime-types (>= 1.16)
80
+ rspec (2.9.0)
81
+ rspec-core (~> 2.9.0)
82
+ rspec-expectations (~> 2.9.0)
83
+ rspec-mocks (~> 2.9.0)
84
+ rspec-core (2.9.0)
85
+ rspec-expectations (2.9.1)
86
+ diff-lcs (~> 1.1.3)
87
+ rspec-mocks (2.9.0)
88
+ rspec-rails (2.9.0)
89
+ actionpack (>= 3.0)
90
+ activesupport (>= 3.0)
91
+ railties (>= 3.0)
92
+ rspec (~> 2.9.0)
93
+ sprockets (2.1.2)
94
+ hike (~> 1.2)
95
+ rack (~> 1.0)
96
+ tilt (~> 1.1, != 1.3.0)
97
+ thor (0.14.6)
98
+ tilt (1.3.3)
99
+ treetop (1.4.10)
100
+ polyglot
101
+ polyglot (>= 0.3.1)
102
+ tzinfo (0.3.33)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ generator_spec
109
+ parse_resource
110
+ rails
111
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Zhi-Qiang Lei
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.md ADDED
@@ -0,0 +1 @@
1
+ # parse_resource_rails
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a configuration of parse_resource
3
+
4
+ Example:
5
+ rails generate parse_resource:config
6
+
7
+ This will create:
8
+ config/parse_resource.yml
@@ -0,0 +1,13 @@
1
+ module ParseResource
2
+ module Generators
3
+ class ConfigGenerator < ::Rails::Generators::Base
4
+ argument :database_name, type: :string, optional: true
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def create_config_file
9
+ copy_file 'parse_resource.yml', File.join('config', 'parse_resource.yml')
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ development:
2
+ app_id: 1234567890
3
+ master_key: abcdefgh
4
+
5
+ test:
6
+ app_id: 1234567890
7
+ master_key: abcdefgh
8
+
9
+ production:
10
+ app_id: 1234567890
11
+ master_key: abcdefgh
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a model of parse_resource
3
+
4
+ Example:
5
+ rails generate model Thing
6
+
7
+ This will create:
8
+ app/models/thing.rb
@@ -0,0 +1,18 @@
1
+ module ParseResource
2
+ module Generators
3
+ class ModelGenerator < ::Rails::Generators::NamedBase
4
+
5
+ argument :attributes, type: :array, default: [], banner: "field field"
6
+
7
+ check_class_collision
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+
11
+ def create_model_file
12
+ template "model.rb", File.join("app", "models", "#{file_name}.rb")
13
+ end
14
+
15
+ hook_for :test_framework
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %> < ParseResource::Base
3
+ <% attributes.reject{ |attr| attr.reference? }.each do |attribute| -%>
4
+ field :<%= attribute.name %>
5
+ <% end -%>
6
+ <% attributes.select{ |attr| attr.reference? }.each do |attribute| -%>
7
+ belongs_to :<%= attribute.name%>
8
+ <% end -%>
9
+ end
10
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup(:default)
4
+
5
+ require "rails/generators"
6
+ require "parse_resource"
7
+ require "generators/parse_resource/config/config_generator"
8
+ require "generators/parse_resource/model/model_generator"
@@ -0,0 +1,38 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "parse_resource_rails"
3
+ s.version = "0.0.1"
4
+ s.date = "2012-04-27"
5
+ s.summary = "Rails 3 generators of parse_resource"
6
+ s.description = ""
7
+ s.authors = ["Zhi-Qiang Lei"]
8
+ s.email = "zhiqiang.lei@gmail.com"
9
+ s.files = [
10
+ "Gemfile",
11
+ "Gemfile.lock",
12
+ "lib/generators/parse_resource/config/config_generator.rb",
13
+ "lib/generators/parse_resource/config/templates/parse_resource.yml",
14
+ "lib/generators/parse_resource/config/USAGE",
15
+ "lib/generators/parse_resource/model/model_generator.rb",
16
+ "lib/generators/parse_resource/model/templates/model.rb",
17
+ "lib/generators/parse_resource/model/USAGE",
18
+ "lib/parse_resource_rails.rb",
19
+ "LICENSE",
20
+ "parse_resource_rails.gemspec",
21
+ "README.md",
22
+ "spec/generators/config_generator_spec.rb",
23
+ "spec/generators/model_generator_spec.rb",
24
+ "spec/spec_helper.rb"
25
+ ]
26
+ s.licenses = ["MIT"]
27
+ s.require_paths = ["lib"]
28
+ s.homepage = "https://github.com/siegfried/parse_resource_rails"
29
+ s.extra_rdoc_files = [
30
+ "LICENSE",
31
+ "README.md"
32
+ ]
33
+ s.test_files = [
34
+ "spec/generators/config_generator_spec.rb",
35
+ "spec/generators/model_generator_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe ::ParseResource::Generators::ConfigGenerator do
4
+ include GeneratorSpec::TestCase
5
+
6
+ destination File.expand_path("../../tmp", __FILE__)
7
+
8
+ before(:all) do
9
+ prepare_destination
10
+ run_generator
11
+ end
12
+
13
+ it "creates a configuration" do
14
+ assert_file "config/parse_resource.yml", <<-EOT
15
+ development:
16
+ app_id: 1234567890
17
+ master_key: abcdefgh
18
+
19
+ test:
20
+ app_id: 1234567890
21
+ master_key: abcdefgh
22
+
23
+ production:
24
+ app_id: 1234567890
25
+ master_key: abcdefgh
26
+ EOT
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe ::ParseResource::Generators::ModelGenerator do
4
+ include GeneratorSpec::TestCase
5
+
6
+ destination File.expand_path("../../tmp", __FILE__)
7
+
8
+ arguments %w{Post title:string body:text}
9
+
10
+ before(:all) do
11
+ prepare_destination
12
+ run_generator
13
+ end
14
+
15
+ it "creates a model" do
16
+ assert_file "app/models/post.rb", <<-EOT
17
+ class Post < ParseResource::Base
18
+ field :title
19
+ field :body
20
+ end
21
+ EOT
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require "bundler/setup"
4
+ require "rails/all"
5
+ require "parse_resource_rails"
6
+ require "generator_spec/test_case"
7
+ require "fileutils"
8
+
9
+ RSpec.configure do |config|
10
+ config.before(:all) do
11
+ ::FileUtils.rm_rf ::File.join(::File.dirname(__FILE__), "tmp")
12
+ end
13
+ config.after(:each) do
14
+ ::FileUtils.rm_rf ::File.join(::File.dirname(__FILE__), "tmp")
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: parse_resource_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zhi-Qiang Lei
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ''
15
+ email: zhiqiang.lei@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - LICENSE
20
+ - README.md
21
+ files:
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - lib/generators/parse_resource/config/config_generator.rb
25
+ - lib/generators/parse_resource/config/templates/parse_resource.yml
26
+ - lib/generators/parse_resource/config/USAGE
27
+ - lib/generators/parse_resource/model/model_generator.rb
28
+ - lib/generators/parse_resource/model/templates/model.rb
29
+ - lib/generators/parse_resource/model/USAGE
30
+ - lib/parse_resource_rails.rb
31
+ - LICENSE
32
+ - parse_resource_rails.gemspec
33
+ - README.md
34
+ - spec/generators/config_generator_spec.rb
35
+ - spec/generators/model_generator_spec.rb
36
+ - spec/spec_helper.rb
37
+ homepage: https://github.com/siegfried/parse_resource_rails
38
+ licenses:
39
+ - MIT
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.21
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Rails 3 generators of parse_resource
62
+ test_files:
63
+ - spec/generators/config_generator_spec.rb
64
+ - spec/generators/model_generator_spec.rb
65
+ - spec/spec_helper.rb