utopia_data 0.0.1 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,8 +5,10 @@ Quando minha Utopia de Abertura de Dados por parte do governo for realidade,
5
5
  ainda então, estaremos caminhando para um pais mais democratico
6
6
 
7
7
  == Install
8
- UtopiaData run on top of Rails application
9
- gem 'utopia_data' # on Gemfile
8
+ UtopiaData run on top of Rails application, on your Gemfile
9
+ gem 'utopia_data'
10
+ gem "inherited_resources"
11
+ gem "roar-rails"
10
12
 
11
13
  bundle install
12
14
  bundle exec rails g utopia:resource law
@@ -22,7 +24,7 @@ In the example _law_ is my resource, the should be a word in singular
22
24
  bundle exec rails g utopia:resource law
23
25
 
24
26
  It will create app/resource/law.rb, like it
25
- UtopiaData.register :site do
27
+ UtopiaData.register :law do
26
28
  end
27
29
 
28
30
  === Changing default
data/Rakefile CHANGED
@@ -23,19 +23,4 @@ end
23
23
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
24
  load 'rails/tasks/engine.rake'
25
25
 
26
-
27
- desc "update documentation"
28
- task :update_documentation => :rdoc do
29
-
30
- system 'mv rdoc /tmp/rdoc'
31
- system 'git checkout gh-pages'
32
- system 'rm -Rf doc/code'
33
- system 'mv /tmp/rdoc doc/code'
34
- system 'git add doc/'
35
- system 'git commit -m "updated code documentation"'
36
- system 'git push origin gh-pages'
37
- system 'git checkout master'
38
-
39
- end
40
-
41
26
  Bundler::GemHelper.install_tasks
@@ -22,10 +22,12 @@
22
22
  module UtopiaData
23
23
  class Resource
24
24
  module Models
25
+ # @return [String] the model class name
25
26
  def model_name
26
27
  resource_class_name
27
28
  end
28
29
 
30
+ # @return [ActiveRecord] the model to current resource
29
31
  def model
30
32
  @model ||= resource_class
31
33
  end
@@ -36,24 +38,38 @@ module UtopiaData
36
38
  end
37
39
 
38
40
  def set(attribute, options = {})
39
- @columns << attribute
41
+ @columns << attribute.to_s
40
42
  end
41
43
 
42
44
  def columns
43
- @columns ||= []
45
+ @columns ||= model.column_names
44
46
  end
45
47
 
46
48
  # Create the resource model
47
49
  def create_resource_model
48
- table_name = @config[:table_name] ? "self.table_name = '#{@config[:table_name]}'" : nil
49
- model_class = <<-MODEL
50
- class ::#{model_name} < ActiveRecord::Base
51
- #{table_name}
52
- attr_accessor #{columns.join(", ")}
53
- end
54
- MODEL
55
- eval model_class
50
+ initialize_model
51
+ configure_model
56
52
  end
53
+
54
+ private
55
+ def initialize_model
56
+ model_class = <<-MODEL
57
+ class ::#{model_name} < ActiveRecord::Base
58
+ attr_accessible nil
59
+ end
60
+ MODEL
61
+ eval model_class
62
+ end
63
+
64
+ def configure_model
65
+ model_class = <<-MODEL
66
+ class ::#{model_name}
67
+ attr_accessible #{columns.map{|c| ":#{c}"}.join(", ")}
68
+ end
69
+ MODEL
70
+ @model.table_name = @config[:table_name] unless @config[:table_name].nil?
71
+ eval model_class
72
+ end
57
73
  end
58
74
  end
59
75
  end
@@ -32,6 +32,14 @@ module UtopiaData
32
32
  include Roar::Representer::Feature::Hypermedia
33
33
 
34
34
  #{columns.map{|c| "property :#{c}" }.join("\n")}
35
+
36
+ link :self do
37
+ #{resource_name.singular}_url(self)
38
+ end
39
+
40
+ link :#{resource_name.plural} do
41
+ #{resource_name.plural}_url
42
+ end
35
43
  end
36
44
  MODEL
37
45
  eval representer_module
@@ -20,5 +20,5 @@
20
20
  #++
21
21
 
22
22
  module UtopiaData
23
- VERSION = "0.0.1"
23
+ VERSION = "1.0.0.beta"
24
24
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 1.0.0.beta
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Duke
@@ -13,7 +13,7 @@ date: 2012-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70290610791600 !ruby/object:Gem::Requirement
16
+ requirement: &70233330418020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70290610791600
24
+ version_requirements: *70233330418020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: inherited_resources
27
- requirement: &70290610791120 !ruby/object:Gem::Requirement
27
+ requirement: &70233330417500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70290610791120
35
+ version_requirements: *70233330417500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: roar-rails
38
- requirement: &70290610790460 !ruby/object:Gem::Requirement
38
+ requirement: &70233330416780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70290610790460
46
+ version_requirements: *70233330416780
47
47
  description: Gem to open data.
48
48
  email:
49
49
  - duke@vertigem.xxx
@@ -93,16 +93,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  segments:
95
95
  - 0
96
- hash: 2849814793115095415
96
+ hash: 1815176515712391208
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
- - - ! '>='
100
+ - - ! '>'
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
103
- segments:
104
- - 0
105
- hash: 2849814793115095415
102
+ version: 1.3.1
106
103
  requirements: []
107
104
  rubyforge_project:
108
105
  rubygems_version: 1.8.15