transcriber 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,9 +12,9 @@ class Root < Transcriber::Resource
12
12
  end
13
13
 
14
14
 
15
- @root = Root.parse({'locale' => 'pt-BR',
16
- 'key' => 19190839,
17
- 'names' => {
15
+ @root = Root.parse({locale: 'pt-BR',
16
+ key: 19190839,
17
+ names: {
18
18
  'en' => 'Woot',
19
19
  'pt-BR' => 'Úia',
20
20
  'es' => 'Me gusta'
@@ -8,7 +8,7 @@ class Root < Transcriber::Resource
8
8
  embeds_many :items
9
9
  end
10
10
 
11
- @root = Root.parse({"items" => [{"id" => 2000}, {"id" => 2001}]}).first
11
+ @root = Root.parse({items: [{id: 2000}, {id: 2001}]}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -8,7 +8,7 @@ class Root < Transcriber::Resource
8
8
  embeds_many :items, class_name: :entry
9
9
  end
10
10
 
11
- @root = Root.parse({"items" => [{"id" => 2000}]}).first
11
+ @root = Root.parse({items: [{id: 2000}]}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -9,13 +9,13 @@ class Root < Transcriber::Resource
9
9
  embeds_many :items, if: proc {id == "10"}
10
10
  end
11
11
 
12
- @root_with_items = Root.parse({"id" => 10, "items" => [{"id" => 2000}]}).first
12
+ @root_with_items = Root.parse({id: 10, items: [{id: 2000}]}).first
13
13
 
14
14
  puts "root: #{@root_with_items.inspect}"
15
15
  puts "resource: #{@root_with_items.resource}"
16
16
 
17
17
 
18
- @root_without_items = Root.parse({"id" => 1, "items" => [{"id" => 2000}]}).first
18
+ @root_without_items = Root.parse({id: 1, items: [{id: 2000}]}).first
19
19
 
20
20
  puts "root: #{@root_without_items.inspect}"
21
21
  puts "resource: #{@root_without_items.resource}"
@@ -10,7 +10,7 @@ class Root < Transcriber::Resource
10
10
  embeds_many :items, start_key: 'detalhe.itens'
11
11
  end
12
12
 
13
- @root = Root.parse({"detalhe" => {"itens" => [{"item_id" => 2000}]}}).first
13
+ @root = Root.parse({"detalhe" => {"itens" => [{item_id: 2000}]}}).first
14
14
 
15
15
  puts "root: #{@root.inspect}"
16
16
  puts "resource: #{@root.resource}"
@@ -8,7 +8,7 @@ class Item < Transcriber::Resource
8
8
  property :id
9
9
  end
10
10
 
11
- @root = Root.parse({"id" => 2000}).first
11
+ @root = Root.parse({id: 2000}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -8,7 +8,7 @@ class Item < Transcriber::Resource
8
8
  property :id
9
9
  end
10
10
 
11
- @root = Root.parse({"item" => {"id" => 2000}}).first
11
+ @root = Root.parse({item: {id: 2000}}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -8,7 +8,7 @@ class Root < Transcriber::Resource
8
8
  embeds_one :item, class_name: :entry
9
9
  end
10
10
 
11
- @root = Root.parse({"item" => {"id" => 2000}}).first
11
+ @root = Root.parse({item: {id: 2000}}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -9,13 +9,13 @@ class Item < Transcriber::Resource
9
9
  property :id
10
10
  end
11
11
 
12
- @root_with_item = Root.parse({"id"=> 1, "item" => {"id" => 2000}}).first
12
+ @root_with_item = Root.parse({id: 1, item: {id: 2000}}).first
13
13
 
14
14
  puts "root: #{@root_with_item.inspect}"
15
15
  puts "resource: #{@root_with_item.resource}"
16
16
 
17
17
 
18
- @root_without_item = Root.parse({"id"=> 100, "item" => {"id" => 2000}}).first
18
+ @root_without_item = Root.parse({id: 100, item: {id: 2000}}).first
19
19
 
20
20
  puts "root: #{@root_without_item.inspect}"
21
21
  puts "resource: #{@root_without_item.resource}"
@@ -1,14 +1,14 @@
1
1
  $:.push 'lib'; require 'transcriber'
2
2
 
3
3
  class Root < Transcriber::Resource
4
- embeds_one :item, start_key: :ugly_nesting_key
4
+ embeds_one :item, start_key: 'ugly_nesting_key'
5
5
  end
6
6
 
7
7
  class Item < Transcriber::Resource
8
8
  property :id
9
9
  end
10
10
 
11
- @root = Root.parse({"ugly_nesting_key" => {"id" => 2000}}).first
11
+ @root = Root.parse({'ugly_nesting_key' => {id: 2000}}).first
12
12
 
13
13
  puts "root: #{@root.inspect}"
14
14
  puts "resource: #{@root.resource}"
@@ -23,7 +23,7 @@ class Customer < Transcriber::Resource
23
23
  has_one :devops, class_name: :developer
24
24
  end
25
25
 
26
- @root = Customer.parse({"customer_id" => 123, "login" => 'jackiechan2010'}).first
26
+ @root = Customer.parse({customer_id: 123, login: 'jackiechan2010'}).first
27
27
 
28
28
  puts "root: #{@root.inspect}"
29
29
  puts "resource: #{@root.resource}"
@@ -4,7 +4,7 @@ class Customer < Transcriber::Resource
4
4
  property :products, type: Enumerable
5
5
  end
6
6
 
7
- @root = Customer.parse({'products' => ['a', 'b', 'c']}).first
7
+ @root = Customer.parse({products: ['a', 'b', 'c']}).first
8
8
 
9
9
  puts "root: #{@root.inspect}"
10
10
  puts "resource: #{@root.resource}"
@@ -4,9 +4,9 @@ class Customer < Transcriber::Resource
4
4
  property :login
5
5
  end
6
6
 
7
- @customers = Customer.parse([{"login" => "jackiechan2010"},
8
- {"login" => "brucelee"},
9
- {"login" => "vcr2"}])
7
+ @customers = Customer.parse([{login: "jackiechan2010"},
8
+ {login: "brucelee"},
9
+ {login: "vcr2"}])
10
10
 
11
11
  puts "root: #{@customers.inspect}"
12
12
  puts "resource: #{Customer.resources @customers}"
@@ -4,7 +4,7 @@ class Customer < Transcriber::Resource
4
4
  property :login
5
5
  end
6
6
 
7
- @root = Customer.parse({"login" => 'jackiechan2010'}).first
7
+ @root = Customer.parse({login: 'jackiechan2010'}).first
8
8
 
9
9
  puts "root: #{@root.inspect}"
10
10
  puts "resource: #{@root.resource}"
@@ -4,7 +4,7 @@ class Customer < Transcriber::Resource
4
4
  property :login, field: :customer_login
5
5
  end
6
6
 
7
- @root = Customer.parse({"customer_login" => 'jackiechan2010'}).first
7
+ @root = Customer.parse({customer_login: 'jackiechan2010'}).first
8
8
 
9
9
  puts "root: #{@root.inspect}"
10
10
  puts "resource: #{@root.resource}"
@@ -4,7 +4,7 @@ class Customer < Transcriber::Resource
4
4
  id
5
5
  end
6
6
 
7
- @root = Customer.parse({"id" => 2000}).first
7
+ @root = Customer.parse({id: 2000}).first
8
8
 
9
9
  puts "root: #{@root.inspect}"
10
10
  puts "resource: #{@root.resource}"
@@ -7,9 +7,9 @@ class Customer < Transcriber::Resource
7
7
  end
8
8
 
9
9
  @root_with_description = Customer.parse({
10
- "login" => 2000,
11
- "password" => "abc",
12
- "description" => "description"}).first
10
+ login: 2000,
11
+ password: "abc",
12
+ description: "description"}).first
13
13
 
14
14
 
15
15
  puts "root: #{@root_with_description.inspect}"
@@ -17,9 +17,9 @@ puts "resource: #{@root_with_description.resource}"
17
17
 
18
18
 
19
19
  @root_without_description = Customer.parse({
20
- "login" => 2000,
21
- "password" => "abcd",
22
- "description" => "some text II"}).first
20
+ login: 2000,
21
+ password: "abcd",
22
+ description: "some text II"}).first
23
23
 
24
24
  puts "root: #{@root_without_description.inspect}"
25
25
  puts "resource: #{@root_without_description.resource}"
@@ -1,13 +1,8 @@
1
1
  $:.push 'lib'; require 'transcriber'
2
2
 
3
- module AsDefined
4
- def self.call(keys)
5
- keys
6
- end
7
- end
8
-
9
3
  class Customer < Transcriber::Resource
10
- convert_input_keys AsDefined
4
+ convert_input_keys proc {|keys| keys}
5
+
11
6
  id
12
7
  properties :login, :name, :postal_code, :email, :secondary_email
13
8
  summarizes :id, :login
@@ -2,7 +2,7 @@ module Transcriber
2
2
  class Configuration
3
3
  attr_accessor :host
4
4
 
5
- DefaultHandler = lambda {|keys| keys.map(&:to_s)}
5
+ DefaultHandler = lambda {|keys| keys}
6
6
 
7
7
  def convert_input_keys
8
8
  @convert_input_keys || DefaultHandler
@@ -12,7 +12,13 @@ module Transcriber
12
12
  end
13
13
 
14
14
  def self.keys_for_path(path)
15
- path.empty? ? [] : path.values.first.to_s.split('.')
15
+ return [] if path.empty?
16
+
17
+ if path.values.first.kind_of?(Symbol)
18
+ [path.values.first]
19
+ else
20
+ path.values.first.to_s.split('.')
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -1,3 +1,3 @@
1
1
  module Transcriber
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -16,7 +16,7 @@ describe Resource::InputPath do
16
16
  context "when a custom path is not defined" do
17
17
  context "and there is'nt a custom keys input converter" do
18
18
  subject {Resource::Key.new(:name)}
19
- let(:path) {['name']}
19
+ let(:path) {[:name]}
20
20
  it_behaves_like "an input path"
21
21
  end
22
22
 
@@ -30,7 +30,7 @@ describe Resource::InputPath do
30
30
  context "when a custom path is defined" do
31
31
  context "and it is a simple name" do
32
32
  subject {Resource::Key.new(:name, field: :other_name)}
33
- let(:path) {['other_name']}
33
+ let(:path) {[:other_name]}
34
34
  it_behaves_like "an input path"
35
35
  end
36
36
 
@@ -7,7 +7,7 @@ describe Resource::Parser do
7
7
  property :login
8
8
  end
9
9
 
10
- models = Example.parse({'login' => 'jackiechan2010'})
10
+ models = Example.parse({login: 'jackiechan2010'})
11
11
  models.should be_an(Array)
12
12
  models.first.login.should == 'jackiechan2010'
13
13
  end
@@ -17,7 +17,7 @@ describe Resource::Parser do
17
17
  property :login, field: :customer_login
18
18
  end
19
19
 
20
- models = Example.parse({'customer_login' => 'jackiechan2010'})
20
+ models = Example.parse({customer_login: 'jackiechan2010'})
21
21
  models.should be_an(Array)
22
22
  models.first.login.should == 'jackiechan2010'
23
23
  end
@@ -31,12 +31,12 @@ describe Resource::Parser do
31
31
  end
32
32
 
33
33
  it "returns true when value is 'X'" do
34
- models = Example.parse({'can_merge' => 'X'})
34
+ models = Example.parse({can_merge: 'X'})
35
35
  models.first.can_merge.should be_true
36
36
  end
37
37
 
38
38
  it "returns false when value isn't 'X'" do
39
- models = Example.parse({'can_merge' => ''})
39
+ models = Example.parse({can_merge: ''})
40
40
  models.first.can_merge.should be_false
41
41
  end
42
42
  end
@@ -47,7 +47,7 @@ describe Resource::Parser do
47
47
  property :issue_date, type: Date
48
48
  end
49
49
 
50
- models = Example.parse({'issue_date' => '2011-01-01'})
50
+ models = Example.parse({issue_date: '2011-01-01'})
51
51
  models.first.issue_date.should == Date.parse('2011-01-01')
52
52
  end
53
53
  end
@@ -58,7 +58,7 @@ describe Resource::Parser do
58
58
  property :amount, type: Float
59
59
  end
60
60
 
61
- models = Example.parse({'amount' => '1234.5'})
61
+ models = Example.parse({amount: '1234.5'})
62
62
  models.first.amount.should == 1234.5
63
63
  end
64
64
  end
@@ -72,12 +72,12 @@ describe Resource::Parser do
72
72
  end
73
73
 
74
74
  it "returns key when value was mapped" do
75
- models = Example.parse({'status' => '02'})
75
+ models = Example.parse({status: '02'})
76
76
  models.first.status.should == :unpaid
77
77
  end
78
78
 
79
79
  it "returns nil when value wasn't mapped" do
80
- models = Example.parse({'status' => '03'})
80
+ models = Example.parse({status: '03'})
81
81
  models.first.status.should be_nil
82
82
  end
83
83
  end
@@ -8,7 +8,7 @@ describe Resource::Parser::Embeddable do
8
8
  end
9
9
  end
10
10
 
11
- let(:value) {{"id" => "7000"}}
11
+ let(:value) {{id: "7000"}}
12
12
 
13
13
  subject {Resource::Embeddable.new(:example_child, many: false)}
14
14
 
@@ -25,7 +25,7 @@ describe Resource::Parser::Embeddable do
25
25
  end
26
26
  end
27
27
 
28
- let(:value) {[{"id" => "7000"}, {"id" => "7001"}]}
28
+ let(:value) {[{id: "7000"}, {id: "7001"}]}
29
29
 
30
30
  subject {Resource::Embeddable.new(:example_children, many: true)}
31
31
 
@@ -16,11 +16,11 @@ describe Transcriber::Resource::Response do
16
16
 
17
17
  let(:input) do
18
18
  {
19
- 'login' => 'jackiechan2010',
20
- 'phone' => '32232188',
21
- 'address' => {
22
- 'street' => 'Aurora St.',
23
- 'city' => 'Recife'
19
+ login: 'jackiechan2010',
20
+ phone: '32232188',
21
+ address: {
22
+ street: 'Aurora St.',
23
+ city: 'Recife'
24
24
  }
25
25
  }
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-08-29 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70363203539880 !ruby/object:Gem::Requirement
18
+ requirement: &70248985347520 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70363203539880
26
+ version_requirements: *70248985347520
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70363203539360 !ruby/object:Gem::Requirement
29
+ requirement: &70248985346960 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70363203539360
37
+ version_requirements: *70248985346960
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70363203538900 !ruby/object:Gem::Requirement
40
+ requirement: &70248985346440 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '2.6'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70363203538900
48
+ version_requirements: *70248985346440
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: guard
51
- requirement: &70363203538440 !ruby/object:Gem::Requirement
51
+ requirement: &70248985345860 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0.5'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70363203538440
59
+ version_requirements: *70248985345860
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: guard-rspec
62
- requirement: &70363203537960 !ruby/object:Gem::Requirement
62
+ requirement: &70248985345280 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.4'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70363203537960
70
+ version_requirements: *70248985345280
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: growl
73
- requirement: &70363203537480 !ruby/object:Gem::Requirement
73
+ requirement: &70248985344720 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '1.0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70363203537480
81
+ version_requirements: *70248985344720
82
82
  description: ''
83
83
  email:
84
84
  - victorcrodrigues@gmail.com