supa 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,10 @@
1
+ require 'supa/command'
2
+
1
3
  module Supa
2
4
  module Commands
3
5
  class Attribute < Supa::Command
4
6
  def represent
5
- @tree[@name] = value
7
+ tree[name] = dynamic_value
6
8
  end
7
9
  end
8
10
  end
@@ -1,15 +1,15 @@
1
+ require 'supa/command'
2
+
1
3
  module Supa
2
4
  module Commands
3
5
  class Collection < Supa::Command
4
- include Supa::Commands::Collectionable
5
-
6
6
  def represent
7
- @tree[@name] = [] unless @options[:squash]
7
+ tree[name] = []
8
8
 
9
- collection.each do |element|
10
- @tree[@name] << {}
9
+ Array(dynamic_value).each do |element|
10
+ tree[name] << {}
11
11
 
12
- Supa::Builder.new(element, tree: @tree[@name][-1], representer: @representer).instance_exec(&@block)
12
+ Supa::Builder.new(representer: representer, context: element, tree: tree[name][-1]).instance_exec(&block)
13
13
  end
14
14
  end
15
15
  end
@@ -1,11 +1,15 @@
1
+ require 'supa/command'
2
+
1
3
  module Supa
2
4
  module Commands
3
5
  class Namespace < Supa::Command
4
6
  def represent
5
- @tree[@name] = {}
7
+ tree[name] = {}
6
8
 
7
- Supa::Builder.new(@object, tree: @tree[@name], representer: @representer).instance_exec(&@block)
9
+ Supa::Builder.new(representer: representer, context: context, tree: tree[name]).instance_exec(&block)
8
10
  end
9
11
  end
10
12
  end
11
13
  end
14
+
15
+
@@ -1,10 +1,12 @@
1
+ require 'supa/command'
2
+
1
3
  module Supa
2
4
  module Commands
3
5
  class Object < Supa::Command
4
6
  def represent
5
- @tree[@name] = {}
7
+ tree[name] = {}
6
8
 
7
- Supa::Builder.new(value, tree: @tree[@name], representer: @representer).instance_exec(&@block)
9
+ Supa::Builder.new(representer: representer, context: dynamic_value, tree: tree[name]).instance_exec(&block)
8
10
  end
9
11
  end
10
12
  end
@@ -0,0 +1,11 @@
1
+ require 'supa/command'
2
+
3
+ module Supa
4
+ module Commands
5
+ class Virtual < Supa::Command
6
+ def represent
7
+ tree[name] = static_value
8
+ end
9
+ end
10
+ end
11
+ end
@@ -11,7 +11,7 @@ module Supa
11
11
  end
12
12
 
13
13
  def to_hash
14
- Supa::Builder.new(@object, tree: {}, representer: self).tap do |builder|
14
+ Supa::Builder.new(representer: self, context: object, tree: {}).tap do |builder|
15
15
  builder.instance_exec(&self.class.definition)
16
16
  end.to_hash
17
17
  end
@@ -19,6 +19,10 @@ module Supa
19
19
  def to_json
20
20
  to_hash.to_json
21
21
  end
22
+
23
+ private
24
+
25
+ attr_reader :object
22
26
  end
23
27
 
24
28
  module ClassMethods
data/lib/supa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Supa
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'
3
3
  end
data/supa.gemspec CHANGED
@@ -1,37 +1,30 @@
1
+ # coding: utf-8
1
2
  lib = File.expand_path('../lib', __FILE__)
2
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require 'supa/version'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
- spec.name = 'supa'
7
+ spec.name = "supa"
7
8
  spec.version = Supa::VERSION
8
9
  spec.platform = Gem::Platform::RUBY
9
- spec.authors = ['Andrey Duplichev', 'Jan Rietema', 'Jakub Gorzelak']
10
- spec.email = %w(
11
- andrey.duplichev@distribusion.com
12
- jan.rietema@distribusion.com
13
- jakub.gorzelak@distribusion.com
14
- )
10
+ spec.authors = ["Das"]
11
+ spec.email = [""]
15
12
 
16
- spec.summary = 'Ruby object → JSON serialization.'
17
- spec.description = 'Ruby object → JSON serialization.'
18
- spec.homepage = 'https://github.com/distribusion/supa'
19
- spec.license = 'MIT'
13
+ spec.summary = "Ruby object → JSON serialization."
14
+ spec.description = "Ruby object → JSON serialization."
15
+ spec.homepage = "https://github.com/dasnotme/supa"
16
+ spec.license = "MIT"
20
17
 
21
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
19
  f.match(%r{^(test|spec|features)/})
23
20
  end
24
- spec.bindir = 'exe'
21
+ spec.bindir = "exe"
25
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- spec.require_paths = ['lib']
23
+ spec.require_paths = ["lib"]
27
24
 
28
- spec.add_development_dependency 'bundler', '~> 1.13'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'rspec-benchmark', '~> 0.2.0'
32
- spec.add_development_dependency 'rubocop', '~> 0.45.0'
33
- spec.add_development_dependency 'reek', '~> 4.5.0'
34
- spec.add_development_dependency 'simplecov', '~> 0.12'
35
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
36
- spec.add_development_dependency 'pry-byebug', '~> 3.4.0'
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "minitest", "~> 5.0"
28
+ spec.add_development_dependency "simplecov", "~> 0.12"
29
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
37
30
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
- - Andrey Duplichev
8
- - Jan Rietema
9
- - Jakub Gorzelak
7
+ - Das
10
8
  autorequire:
11
9
  bindir: exe
12
10
  cert_chain: []
13
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: bundler
@@ -41,61 +39,19 @@ dependencies:
41
39
  - !ruby/object:Gem::Version
42
40
  version: '10.0'
43
41
  - !ruby/object:Gem::Dependency
44
- name: rspec
42
+ name: minitest
45
43
  requirement: !ruby/object:Gem::Requirement
46
44
  requirements:
47
45
  - - "~>"
48
46
  - !ruby/object:Gem::Version
49
- version: '3.0'
47
+ version: '5.0'
50
48
  type: :development
51
49
  prerelease: false
52
50
  version_requirements: !ruby/object:Gem::Requirement
53
51
  requirements:
54
52
  - - "~>"
55
53
  - !ruby/object:Gem::Version
56
- version: '3.0'
57
- - !ruby/object:Gem::Dependency
58
- name: rspec-benchmark
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: 0.2.0
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - "~>"
69
- - !ruby/object:Gem::Version
70
- version: 0.2.0
71
- - !ruby/object:Gem::Dependency
72
- name: rubocop
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: 0.45.0
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: 0.45.0
85
- - !ruby/object:Gem::Dependency
86
- name: reek
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: 4.5.0
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - "~>"
97
- - !ruby/object:Gem::Version
98
- version: 4.5.0
54
+ version: '5.0'
99
55
  - !ruby/object:Gem::Dependency
100
56
  name: simplecov
101
57
  requirement: !ruby/object:Gem::Requirement
@@ -124,33 +80,15 @@ dependencies:
124
80
  - - "~>"
125
81
  - !ruby/object:Gem::Version
126
82
  version: 1.0.0
127
- - !ruby/object:Gem::Dependency
128
- name: pry-byebug
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - "~>"
132
- - !ruby/object:Gem::Version
133
- version: 3.4.0
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - "~>"
139
- - !ruby/object:Gem::Version
140
- version: 3.4.0
141
83
  description: Ruby object → JSON serialization.
142
84
  email:
143
- - andrey.duplichev@distribusion.com
144
- - jan.rietema@distribusion.com
145
- - jakub.gorzelak@distribusion.com
85
+ - ''
146
86
  executables: []
147
87
  extensions: []
148
88
  extra_rdoc_files: []
149
89
  files:
150
90
  - ".codeclimate.yml"
151
91
  - ".gitignore"
152
- - ".reek"
153
- - ".rspec"
154
92
  - ".rubocop.yml"
155
93
  - ".travis.yml"
156
94
  - CODE_OF_CONDUCT.md
@@ -163,15 +101,16 @@ files:
163
101
  - lib/supa.rb
164
102
  - lib/supa/builder.rb
165
103
  - lib/supa/command.rb
104
+ - lib/supa/commands/append.rb
166
105
  - lib/supa/commands/attribute.rb
167
106
  - lib/supa/commands/collection.rb
168
107
  - lib/supa/commands/namespace.rb
169
108
  - lib/supa/commands/object.rb
170
- - lib/supa/commands/traits/collectionable.rb
109
+ - lib/supa/commands/virtual.rb
171
110
  - lib/supa/representable.rb
172
111
  - lib/supa/version.rb
173
112
  - supa.gemspec
174
- homepage: https://github.com/distribusion/supa
113
+ homepage: https://github.com/dasnotme/supa
175
114
  licenses:
176
115
  - MIT
177
116
  metadata: {}
data/.reek DELETED
@@ -1,128 +0,0 @@
1
- ---
2
- Attribute:
3
- enabled: false
4
- exclude: []
5
- BooleanParameter:
6
- enabled: true
7
- exclude: []
8
- ClassVariable:
9
- enabled: true
10
- exclude: []
11
- ControlParameter:
12
- enabled: true
13
- exclude: []
14
- DataClump:
15
- enabled: true
16
- exclude: []
17
- max_copies: 2
18
- min_clump_size: 2
19
- DuplicateMethodCall:
20
- enabled: false
21
- exclude: []
22
- max_calls: 1
23
- allow_calls: []
24
- FeatureEnvy:
25
- enabled: true
26
- exclude: []
27
- InstanceVariableAssumption:
28
- enabled: false
29
- exclude: []
30
- IrresponsibleModule:
31
- enabled: false
32
- exclude: []
33
- LongParameterList:
34
- enabled: true
35
- exclude: []
36
- max_params: 3
37
- overrides:
38
- initialize:
39
- max_params: 5
40
- LongYieldList:
41
- enabled: true
42
- exclude: []
43
- max_params: 3
44
- ManualDispatch:
45
- enabled: true
46
- exclude: []
47
- ModuleInitialize:
48
- enabled: true
49
- exclude: []
50
- NestedIterators:
51
- enabled: true
52
- exclude: []
53
- max_allowed_nesting: 2
54
- ignore_iterators:
55
- - tap
56
- NilCheck:
57
- enabled: true
58
- exclude: []
59
- PrimaDonnaMethod:
60
- enabled: true
61
- exclude: []
62
- RepeatedConditional:
63
- enabled: true
64
- exclude: []
65
- max_ifs: 2
66
- SubclassedFromCoreClass:
67
- enabled: true
68
- exclude: []
69
- TooManyConstants:
70
- enabled: true
71
- exclude: []
72
- max_constants: 10
73
- TooManyInstanceVariables:
74
- enabled: true
75
- exclude: []
76
- max_instance_variables: 4
77
- TooManyMethods:
78
- enabled: true
79
- exclude: []
80
- max_methods: 15
81
- TooManyStatements:
82
- enabled: true
83
- exclude:
84
- - initialize
85
- max_statements: 10
86
- UncommunicativeMethodName:
87
- enabled: true
88
- exclude: []
89
- reject:
90
- - !ruby/regexp /^[a-z]$/
91
- - !ruby/regexp /[0-9]$/
92
- - !ruby/regexp /[A-Z]/
93
- accept: []
94
- UncommunicativeModuleName:
95
- enabled: true
96
- exclude: []
97
- reject:
98
- - !ruby/regexp /^.$/
99
- - !ruby/regexp /[0-9]$/
100
- accept: []
101
- UncommunicativeParameterName:
102
- enabled: true
103
- exclude: []
104
- reject:
105
- - !ruby/regexp /^.$/
106
- - !ruby/regexp /[0-9]$/
107
- - !ruby/regexp /[A-Z]/
108
- - !ruby/regexp /^_/
109
- accept: []
110
- UncommunicativeVariableName:
111
- enabled: true
112
- exclude: []
113
- reject:
114
- - !ruby/regexp /^.$/
115
- - !ruby/regexp /[0-9]$/
116
- - !ruby/regexp /[A-Z]/
117
- accept:
118
- - !ruby/regexp /^_$/
119
- UnusedParameters:
120
- enabled: true
121
- exclude: []
122
- UnusedPrivateMethod:
123
- enabled: false
124
- exclude: []
125
- UtilityFunction:
126
- enabled: true
127
- exclude: []
128
- public_methods_only: true
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --order rand
@@ -1,12 +0,0 @@
1
- module Supa
2
- module Commands
3
- module Collectionable
4
- private
5
-
6
- def collection
7
- collection = value
8
- collection.is_a?(Array) ? collection : [collection]
9
- end
10
- end
11
- end
12
- end