openehr-rails 0.0.2

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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +46 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +3 -0
  6. data/Guardfile +15 -0
  7. data/README.rdoc +21 -0
  8. data/Rakefile +33 -0
  9. data/db/seeds.rb +7 -0
  10. data/doc/README_FOR_APP +2 -0
  11. data/lib/assets/.gitkeep +0 -0
  12. data/lib/generators/openehr/controller/controller_generator.rb +16 -0
  13. data/lib/generators/openehr/controller/templates/controller.rb +13 -0
  14. data/lib/generators/openehr/i18n/i18n_generator.rb +53 -0
  15. data/lib/generators/openehr/i18n/templates/i18n.rb +6 -0
  16. data/lib/generators/openehr/i18n/templates/language.yml +10 -0
  17. data/lib/generators/openehr/install/install_generator.rb +18 -0
  18. data/lib/generators/openehr/install/templates/i18n.rb +8 -0
  19. data/lib/generators/openehr/migration/migration_generator.rb +17 -0
  20. data/lib/generators/openehr/model/model_generator.rb +16 -0
  21. data/lib/generators/openehr/scaffold/scaffold_generator.rb +149 -0
  22. data/lib/generators/openehr/scaffold/templates/_form.html.erb +19 -0
  23. data/lib/generators/openehr/scaffold/templates/application_controller.rb +2 -0
  24. data/lib/generators/openehr/scaffold/templates/edit.html.erb +6 -0
  25. data/lib/generators/openehr/scaffold/templates/index.html.erb +28 -0
  26. data/lib/generators/openehr/scaffold/templates/new.html.erb +0 -0
  27. data/lib/generators/openehr/scaffold/templates/route.rb +2 -0
  28. data/lib/generators/openehr/scaffold/templates/routes.rb +2 -0
  29. data/lib/generators/openehr/scaffold/templates/show.html.erb +6 -0
  30. data/lib/generators/openehr.rb +71 -0
  31. data/lib/openehr/rails.rb +1 -0
  32. data/lib/openehr-rails/version.rb +5 -0
  33. data/lib/openehr-rails.rb +7 -0
  34. data/lib/rcomponents.rb +48 -0
  35. data/openehr-rails.gemspec +36 -0
  36. data/spec/generators/openehr/archetyped_base_spec.rb +47 -0
  37. data/spec/generators/openehr/controller/controller_generator_spec.rb +9 -0
  38. data/spec/generators/openehr/i18n/i18n_generator_spec.rb +62 -0
  39. data/spec/generators/openehr/install/install_generator_spec.rb +15 -0
  40. data/spec/generators/openehr/migration/migration_generator_spec.rb +16 -0
  41. data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +70 -0
  42. data/spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl +1021 -0
  43. data/spec/rcomponents/relement_spec.rb +21 -0
  44. data/spec/rcomponents/robservation_spec.rb +21 -0
  45. data/spec/spec_helper.rb +18 -0
  46. metadata +257 -0
@@ -0,0 +1,48 @@
1
+ module OpenEHR
2
+ module RComponents
3
+ class Base
4
+ attr_reader :node_id, :path, :rm_type_name
5
+ def initialize(args = { })
6
+ self.node_id = args[:node_id]
7
+ self.path = args[:path]
8
+ self.rm_type_name = args[:rm_type_name]
9
+ end
10
+
11
+ def node_id=(node_id)
12
+ raise ArgumentError if node_id.nil?
13
+ @node_id = node_id
14
+ end
15
+
16
+ def path=(path)
17
+ raise ArgumentError if path.nil?
18
+ @path= path
19
+ end
20
+
21
+ def rm_type_name=(rm_type_name)
22
+ raise ArgumentError if rm_type_name.nil?
23
+ @rm_type_name = rm_type_name
24
+ end
25
+ end
26
+
27
+ class RElement < Base
28
+ end
29
+
30
+ class REntry < Base
31
+ attr_accessor :data
32
+
33
+ def initialize(args = {})
34
+ self.data = args[:data]
35
+ end
36
+ end
37
+
38
+ class RObservation < REntry
39
+ attr_accessor :state, :protocol
40
+
41
+ def initialize(args = {})
42
+ self.state = args[:state]
43
+ self.protocol = args[:protocol]
44
+ super
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "openehr-rails/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "openehr-rails"
7
+ gem.version = OpenEHR::Rails::VERSION
8
+ gem.platform = Gem::Platform::RUBY
9
+ gem.authors = ["Shinji KOBAYASHI"]
10
+ gem.email = "skoba@moss.gr.jp"
11
+
12
+ gem.summary = "Rails extension for the openEHR archetypes"
13
+ gem.description = "This product is a Rails extansion for openEHR"
14
+ gem.homepage = "http://openehr.jp"
15
+ gem.license = "Apache 2.0"
16
+ gem.extra_rdoc_files = [
17
+ "README.rdoc"
18
+ ]
19
+ gem.files = `git ls-files`.split("\n")
20
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+
22
+ gem.require_paths = ["lib"]
23
+ gem.add_dependency('openehr', '1.2.14')
24
+ gem.add_dependency('rails', '~> 4.0.0')
25
+
26
+ gem.add_development_dependency('rake')
27
+ gem.add_development_dependency('ammeter')
28
+ gem.add_development_dependency('rspec')
29
+ gem.add_development_dependency('rspec-rails')
30
+ gem.add_development_dependency('guard')
31
+ gem.add_development_dependency('guard-rspec')
32
+ gem.add_development_dependency('guard-spork')
33
+ gem.add_development_dependency('simplecov')
34
+ gem.add_development_dependency('listen', '0.6')
35
+ gem.add_development_dependency('libnotify')
36
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr'
3
+
4
+ describe OpenEHR::Rails::Generators::ArchetypedBase do
5
+ before (:each) do
6
+ adl_file = File.expand_path '../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__
7
+ @archetyped_base = OpenEHR::Rails::Generators::ArchetypedBase.new([adl_file])
8
+ end
9
+
10
+ context 'archtype path' do
11
+ it 'archetype_path is app/archetypes' do
12
+ @archetyped_base.archetype_path.should == 'app/archetypes'
13
+ end
14
+ end
15
+
16
+ context 'data_tree' do
17
+ it 'rm_attribute_name.should data' do
18
+ @archetyped_base.data_tree.rm_attribute_name.should == 'data'
19
+ end
20
+ end
21
+
22
+ context 'index data' do
23
+ it 'includes value data' do
24
+ @archetyped_base.index_data.should include 'at0004'
25
+ end
26
+
27
+ it 'includes at0005, too' do
28
+ @archetyped_base.index_data.should include 'at0005'
29
+ end
30
+
31
+ it 'does not include at0006' do
32
+ @archetyped_base.index_data.should_not include 'at0006'
33
+ end
34
+ end
35
+
36
+ # context 'show data' do
37
+ # subject { @archetyped_base. }
38
+
39
+ # it { should have_key :protocol }
40
+ # end
41
+
42
+ context 'model name' do
43
+ it 'is origined form archetype id' do
44
+ expect(@archetyped_base.model_name).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/controller/controller_generator'
3
+
4
+ describe OpenEHR::Rails::Generators::ControllerGenerator do
5
+
6
+ destination File.expand_path("../../../../../tmp", __FILE__)
7
+
8
+ before { prepare_destination }
9
+ end
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'generators/openehr/i18n/i18n_generator'
4
+
5
+ module OpenEHR
6
+ module Rails
7
+ module Generators
8
+ describe I18nGenerator do
9
+ destination File.expand_path '../../../../../tmp/', __FILE__
10
+
11
+ before do
12
+ prepare_destination
13
+ run_generator %w(spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl)
14
+ end
15
+
16
+ describe 'File generation' do
17
+ describe 'i18n.rb generation' do
18
+ subject { file('config/initializers/i18n.rb') }
19
+
20
+ it { should exist }
21
+ it { should contain /I18n\.default_locale = :en/ }
22
+ it { should contain /LANGUAGES/ }
23
+ it { should contain /\['English', 'en'\],/ }
24
+ it { should contain /\['Japanese', 'ja'\]/ }
25
+ it { should contain /\['Dutch', 'nl'\],/ }
26
+ end
27
+
28
+ describe 'en.yml generation' do
29
+ subject { file('config/locales/en.yml') }
30
+
31
+ it { should exist }
32
+ it { should contain /en:/ }
33
+ it { should contain /layouts:/ }
34
+ it { should contain /application:/ }
35
+ it { should contain /open_ehr_ehr_observation.blood_pressure.v1/ }
36
+ it { should contain /index: &ontology/ }
37
+ it { should contain /at0000: "Blood Pressure"/ }
38
+ it { should contain /at0001: "history"/ }
39
+ it { should contain /new: \*ontology/ }
40
+ it { should contain /form: \*ontology/ }
41
+ it { should contain /show: \*ontology/ }
42
+ it { should contain /edit: \*ontology/ }
43
+ end
44
+
45
+ describe 'ja.yml generation' do
46
+ subject { file('config/locales/ja.yml')}
47
+
48
+ it { should exist }
49
+ it { should contain /ja:/ }
50
+ end
51
+
52
+ describe 'nl.yml generation' do
53
+ subject { file('config/locales/nl.yml') }
54
+
55
+ it { should exist }
56
+ it { should contain /nl:/ }
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/install/install_generator'
3
+
4
+ describe OpenEHR::Rails::Generators::InstallGenerator do
5
+ destination File.expand_path('../../../../../tmp', __FILE__)
6
+
7
+ before do
8
+ prepare_destination
9
+ end
10
+
11
+ it 'makes app/archetypes directory' do
12
+ run_generator
13
+ file('app/archetypes').should exist
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/migration/migration_generator'
3
+
4
+ describe OpenEHR::Rails::Generators::MigrationGenerator do
5
+ destination File.expand_path(destination_root)
6
+
7
+ before { prepare_destination }
8
+
9
+ describe 'default rm db migration' do
10
+ before { run_generator }
11
+
12
+ # subject {file('db/migration/20121127020800_create_archetype_db')}
13
+
14
+ # it { should exist }
15
+ end
16
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/scaffold/scaffold_generator'
3
+
4
+ module OpenEHR
5
+ module Rails
6
+ module Generators
7
+ describe ScaffoldGenerator do
8
+ destination File.expand_path('../../../../../tmp', __FILE__)
9
+
10
+ before do
11
+ prepare_destination
12
+ run_generator %w(spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl)
13
+ end
14
+
15
+ describe 'invoke index.html.erb template engine' do
16
+ subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/index.html.erb') }
17
+
18
+ it { should exist }
19
+ it { should contain /\<h1\>Listing \<%= t\("\.at0000"\) %\>\<\/h1\>/ }
20
+ it { should contain /\<th\>\<%= t\("\.at0004"\) %\>\<\/th\>/ }
21
+ it { should contain /\<th\>\<%= t\("\.at0005"\) %\>\<\/th\>/ }
22
+ it { should_not contain /\<th\>\<%= t\("\.at0006"\) %\>\<\/th\>/ }
23
+ it { should contain /\<td\>\<%= open_ehr_ehr_observation_blood_pressure_v1\.at0004 %\>\<\/td\>/ }
24
+ it { should contain /link_to \<%= t\("\.at0000"\) %\>/}
25
+ end
26
+
27
+ describe 'invoke show.html.erb template engine' do
28
+ subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/show.html.erb') }
29
+
30
+ it { should exist }
31
+ it { should contain /Observation/ }
32
+ it { should contain /t\(\"\.at0000\"\)/ }
33
+ it { should contain /Data/ }
34
+ it { should contain /Protocol/ }
35
+ end
36
+
37
+ describe 'invoke edit.html.erb template engine' do
38
+ subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/edit.html.erb') }
39
+
40
+ it { should exist }
41
+ it { should contain /Editing \<%= t\(\"\.at0000\"\) /}
42
+ end
43
+
44
+ describe 'invoke _form.html.erb template engine' do
45
+ subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/_form.html.erb')}
46
+
47
+ it { should exist }
48
+ it { should contain // }
49
+
50
+ end
51
+
52
+ describe 'invoke routing generator' do
53
+ subject { file('config/routes.rb')}
54
+
55
+ it { should contain /scope "\/:locale" do/ }
56
+ it { should contain /resources :open_ehr_ehr_observation.blood_pressure.v1/}
57
+ end
58
+
59
+ describe 'application controller modifier' do
60
+ subject { file('app/controllers/application_controller.rb')}
61
+
62
+ it { should contain /before_action :set_locale/ }
63
+ it { should contain /def set_locale/ }
64
+ it { should contain /I18n\.locale = params\[:locale\] \|\| I18n.default_locale/ }
65
+ it { should contain /end$/ }
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end