ruby-xcdm 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem 'activesupport'
5
5
  gem 'rake'
6
6
  gem 'builder'
7
7
  gem 'plist'
8
+ gem 'ruby-xcdm', path: '.'
8
9
 
9
10
  group :test do
10
11
  gem 'turn'
data/Gemfile.lock CHANGED
@@ -1,13 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby-xcdm (0.0.8)
5
+ activesupport (~> 3.2)
6
+ builder (~> 3.2)
7
+ plist (~> 3.1)
8
+
1
9
  GEM
2
10
  remote: https://rubygems.org/
3
11
  specs:
4
- activesupport (3.2.13)
5
- i18n (= 0.6.1)
12
+ activesupport (3.2.17)
13
+ i18n (~> 0.6, >= 0.6.4)
6
14
  multi_json (~> 1.0)
7
15
  ansi (1.4.3)
8
16
  builder (3.2.0)
9
- i18n (0.6.1)
10
- multi_json (1.7.3)
17
+ i18n (0.6.9)
18
+ multi_json (1.9.2)
11
19
  plist (3.1.0)
12
20
  rake (10.0.4)
13
21
  turn (0.9.6)
@@ -21,4 +29,5 @@ DEPENDENCIES
21
29
  builder
22
30
  plist
23
31
  rake
32
+ ruby-xcdm!
24
33
  turn
data/README.md CHANGED
@@ -6,6 +6,10 @@ ruby, but it will be of particular interest to RubyMotion developers.
6
6
  It offers the essential features that XCode does, plus a text-based
7
7
  workflow and some niceties, like automatic inverse relationships.
8
8
 
9
+ [![Dependency Status](https://gemnasium.com/infinitered/ruby-xcdm.png)](https://gemnasium.com/infinitered/ruby-xcdm)
10
+ [![Build Status](https://travis-ci.org/infinitered/ruby-xcdm.png?branch=master)](https://travis-ci.org/infinitered/ruby-xcdm)
11
+ [![Gem Version](https://badge.fury.io/rb/ruby-xcdm.png)](http://badge.fury.io/rb/ruby-xcdm)
12
+
9
13
  ## Installation
10
14
 
11
15
  Add this line to your application's Gemfile:
@@ -39,6 +43,13 @@ this to your Rakefile:
39
43
  task :"build:simulator" => :"schema:build"
40
44
  ```
41
45
 
46
+ You can override the name of the datamodel file, if you need to, using a config
47
+ variable:
48
+
49
+ ```ruby
50
+ app.xcdm.name = "custom"
51
+ ```
52
+
42
53
  ## Usage (Plain Ruby)
43
54
 
44
55
  1. Make a directory to hold your schemas (a.k.a. data model in XCode parlance)
@@ -46,7 +57,7 @@ task :"build:simulator" => :"schema:build"
46
57
  3. Run the command to generate a datamodel:
47
58
 
48
59
  ```
49
- xcdm MyApplicationName schemadir datamodeldestdir
60
+ xcdm MyApplicationName ./schema ./resources
50
61
  ```
51
62
 
52
63
 
@@ -62,7 +73,7 @@ Here's a sample schema file:
62
73
  string :body, optional: false
63
74
  integer32 :length
64
75
  boolean :published, default: false
65
- datetime :publishedAt, default: false
76
+ datetime :publishedAt
66
77
  string :title, optional: false
67
78
 
68
79
  belongs_to :author
@@ -82,7 +93,7 @@ All the built-in data types are supported:
82
93
  * integer16
83
94
  * integer32
84
95
  * integer64
85
- * decimal
96
+ * decimal (See note below)
86
97
  * double
87
98
  * float
88
99
  * string
@@ -91,6 +102,8 @@ All the built-in data types are supported:
91
102
  * binary
92
103
  * transformable
93
104
 
105
+ NSDecimal is not well-supported in RubyMotion as of this writing. They are converted to floats and lose precision. HipByte is aware of the issue and intends to fix it, but until they do, you will need to use something else for storing currency. For an example, see [here](https://github.com/skandragon/stringify_float).
106
+
94
107
  Inverse relationships are generated automatically.
95
108
  If the inverse relationship cannot be derived
96
109
  from the association name, you can use the ```:inverse``` option:
@@ -139,7 +152,7 @@ scenes. If you want more control, you can make the intermediate table yourself:
139
152
  end
140
153
  ```
141
154
 
142
- Core data has no equivalent of ```:through``` in ActiveRecord, so you'll
155
+ Core Data has no equivalent of ```:through``` in ActiveRecord, so you'll
143
156
  need to handle that relation yourself.
144
157
 
145
158
  If you need to set some of the more esoteric options on properties or
data/lib/ruby-xcdm.rb CHANGED
@@ -3,12 +3,21 @@ require 'xcdm/entity'
3
3
 
4
4
  if defined?(Motion::Project::Config)
5
5
 
6
+ class Motion::Project::Config
7
+ variable :xcdm
8
+
9
+ def xcdm
10
+ @xcdm ||= Struct.new(:name).new(nil)
11
+ end
12
+ end
13
+
6
14
  if File.directory?(File.join(App.config.project_dir, "schemas"))
7
15
  namespace :schema do
8
16
 
9
17
  desc "Clear the datamodel outputs"
10
18
  task :clean do
11
- files = Dir.glob(File.join(App.config.project_dir, 'resources', App.config.name) + ".{momd,xcdatamodeld}")
19
+ App.config.xcdm.name ||= App.config.name
20
+ files = Dir.glob(File.join(App.config.project_dir, 'resources', App.config.xcdm.name) + ".{momd,xcdatamodeld}")
12
21
  files.each do |f|
13
22
  rm_rf f
14
23
  end
@@ -16,14 +25,15 @@ if defined?(Motion::Project::Config)
16
25
 
17
26
  desc "Generate the xcdatamodel file"
18
27
  task :build => :clean do
28
+ App.config.xcdm.name ||= App.config.name
19
29
  Dir.chdir App.config.project_dir
20
30
  if `xcodebuild -version` =~ /Xcode (\d.\d+)/
21
31
  xcode_version = $1
22
32
  else
23
33
  raise "could not determine xcode version"
24
34
  end
25
- runner = XCDM::Schema::Runner.new( App.config.name, "schemas", "resources", App.config.sdk_version)
26
- App.info "Generating", "Data Model #{App.config.name}"
35
+ runner = XCDM::Schema::Runner.new( App.config.xcdm.name, "schemas", "resources", App.config.sdk_version)
36
+ App.info "Generating", "Data Model #{App.config.xcdm.name}"
27
37
  runner.load_all { |schema, file| App.info "Loading", file }
28
38
  runner.write_all { |schema, file| App.info "Writing", file }
29
39
  end
data/lib/xcdm/schema.rb CHANGED
@@ -30,7 +30,7 @@ module XCDM
30
30
  name: "",
31
31
  userDefinedModelVersionIdentifier: version,
32
32
  type: "com.apple.IDECoreDataModeler.DataModel",
33
- documentVersion: "1.0",
33
+ documentVersion: "1.0",
34
34
  lastSavedToolsVersion: "3389",
35
35
  systemVersion: "12E55",
36
36
  minimumToolsVersion: "Xcode 5",
@@ -42,7 +42,7 @@ module XCDM
42
42
  name: "",
43
43
  userDefinedModelVersionIdentifier: version,
44
44
  type: "com.apple.IDECoreDataModeler.DataModel",
45
- documentVersion: "1.0",
45
+ documentVersion: "1.0",
46
46
  lastSavedToolsVersion: "2061",
47
47
  systemVersion: "12D78",
48
48
  minimumToolsVersion: "Xcode 4.3",
@@ -71,7 +71,7 @@ module XCDM
71
71
  def schema(version, options = {}, &block)
72
72
  xcv = options[:xcode_version] || xcode_version
73
73
  @found_schema = Schema.new(version, xcv).tap { |s| s.instance_eval(&block) }
74
- @schemas << @found_schema
74
+ @schemas << @found_schema
75
75
  end
76
76
 
77
77
  def load_file(file)
@@ -84,10 +84,19 @@ module XCDM
84
84
  end
85
85
 
86
86
  class Runner
87
- def initialize(name, inpath, outpath, xcode_version)
87
+ def initialize(name, inpath, outpath, xcode_version = nil)
88
88
  @inpath = inpath
89
89
  @name = name
90
90
  @container_path = File.join(outpath, "#{name}.xcdatamodeld")
91
+ if !xcode_version
92
+ begin
93
+ `xcodebuild -version` =~ /(\d+\.\d+\.\d+)/
94
+ xcode_version = $1
95
+ rescue => e
96
+ p e
97
+ puts "XCode not installed?"
98
+ end
99
+ end
91
100
  @loader = Loader.new(xcode_version)
92
101
  end
93
102
 
data/lib/xcdm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module XCDM
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xcdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-21 00:00:00.000000000 Z
12
+ date: 2014-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -146,12 +146,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  - - ! '>='
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
+ segments:
150
+ - 0
151
+ hash: -2545899322055109517
149
152
  required_rubygems_version: !ruby/object:Gem::Requirement
150
153
  none: false
151
154
  requirements:
152
155
  - - ! '>='
153
156
  - !ruby/object:Gem::Version
154
157
  version: '0'
158
+ segments:
159
+ - 0
160
+ hash: -2545899322055109517
155
161
  requirements: []
156
162
  rubyforge_project:
157
163
  rubygems_version: 1.8.23