metaxa 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbb8b2aa707af59b6d69c406173a0e29cdb982ad
4
- data.tar.gz: f81cf1c9acf4d500149c9e199dbfa5b063f58777
3
+ metadata.gz: d51e4f66d3f3b0a730793fe868924b0085cdb50c
4
+ data.tar.gz: 3076ce82abe7451a9a8be52e7cf66229a5b205ff
5
5
  SHA512:
6
- metadata.gz: a9e971830fd26cea9f0fd53804ce8baddd6b59c6a72f309c908fdef773e6fb079c47ac7baf218450cccad6cb41b0b69edca3d47b7a274f2eb945fb9903ac7924
7
- data.tar.gz: 9034e1fe96f8bba995950c9e2906c9c2df1d02c8b19a8bf3725032a834dd45e68a2381c2a098c981067cfcb913eaef94f731dd710658f720577c7d2fb5bb3236
6
+ metadata.gz: b3a32f1cd1fc54df1e5ede9f90d9a59d687c3f8e1e0f8b7950cc6111ed09031dd8ffd6471eb530b531fa3e141e1125caa316062ed9247974d79f324112d74f66
7
+ data.tar.gz: 63fe77f5285d1575697b6cc3839f029ad33474a0aacdf6700644508515c7fef37c9ac69360d3257133349b899a547a3d81cf272d68cafe7d5e85a3114d885ec7
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .DS_Store
11
+ *.gem
12
+ playground.rb
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,12 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-10-13 15:07:46 +0200 using RuboCop version 0.43.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Style/Documentation:
11
+ Exclude:
12
+ - '**/*'
data/README.md CHANGED
@@ -27,7 +27,7 @@ puts foo == 'foobarbaz' # true
27
27
  puts foo === get(:foo) # true
28
28
  ```
29
29
 
30
- See more constructive examples in `examples` dir :thumbsup:.
30
+ See more constructive examples in `examples` dir :sunglasses:.
31
31
 
32
32
  ## Installation
33
33
 
data/bin/console CHANGED
@@ -1,15 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "metaxa"
5
- require "pry"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
3
+ require 'bundler/setup'
4
+ require 'metaxa'
5
+ require 'pry'
13
6
 
14
7
  include Metaxa
15
8
 
data/bin/test CHANGED
@@ -1,2 +1,4 @@
1
1
  #!/usr/bin/env sh
2
- ruby 'test/metaxa_test.rb'
2
+ ruby 'test/metaxa_main_test.rb'
3
+ ruby 'test/metaxa_instance_test.rb'
4
+ ruby 'test/metaxa_class_test.rb'
data/examples/colors.rb CHANGED
@@ -9,7 +9,9 @@ require 'json'
9
9
 
10
10
  include Metaxa
11
11
 
12
- colors = HTTParty.get('http://www.colourlovers.com/api/colors?format=json&numResults=30').tap do |res|
12
+ URL = 'http://www.colourlovers.com/api/colors?format=json&numResults=30'.freez
13
+
14
+ colors = HTTParty.get(URL).tap do |res|
13
15
  JSON.parse(res.body)
14
16
  end
15
17
 
@@ -20,7 +22,7 @@ end
20
22
 
21
23
  introduce :colors, with_value: colors.map { |c| c['name'].to_sym }
22
24
 
23
- Pry.start
25
+ Pry.start # Now you can start typing color names
24
26
 
25
27
  # Usage:
26
28
  #
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'metaxa'
4
+
5
+ class Entity
6
+ include Metaxa
7
+
8
+ def extend_with(params)
9
+ params.each do |k, v|
10
+ introduce k, with_value: v
11
+ end
12
+ self
13
+ end
14
+ end
15
+
16
+ entity = Entity.new.extend_with(name: 'John', age: rand(100), sex: 'M')
17
+
18
+ puts entity.name # => John
19
+ puts entity.age # => 0..100
20
+ puts entity.sex # => M
data/lib/metaxa.rb CHANGED
@@ -1,23 +1,21 @@
1
1
  require 'metaxa/version'
2
2
 
3
3
  module Metaxa
4
+ def introduce(variable, with_value: true)
5
+ var_module = Module.new do
6
+ attr_accessor variable.to_sym
7
+ end
4
8
 
5
- def introduce(variable, with_value: true)
6
- var_module = Module.new do
7
- attr_accessor variable.to_sym
8
- end
9
+ extend var_module
9
10
 
10
- include var_module
11
+ set(variable, with_value)
12
+ end
11
13
 
12
- set variable, with_value
13
- end
14
-
15
- def get(variable)
16
- instance_variable_get "@#{variable}"
17
- end
18
-
19
- def set(variable, value)
20
- instance_variable_set "@#{variable}", value
21
- end
14
+ def get(variable)
15
+ instance_variable_get("@#{variable}")
16
+ end
22
17
 
18
+ def set(variable, value)
19
+ instance_variable_set("@#{variable}", value)
20
+ end
23
21
  end
@@ -1,3 +1,3 @@
1
1
  module Metaxa
2
- VERSION = [0, 1, 0].join('.')
2
+ VERSION = [0, 1, 1].join('.')
3
3
  end
data/metaxa.gemspec CHANGED
@@ -4,24 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'metaxa/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "metaxa"
7
+ spec.name = 'metaxa'
8
8
  spec.version = Metaxa::VERSION
9
- spec.authors = ["Mckomo"]
10
- spec.email = ["mckomo@gmail.com"]
9
+ spec.authors = ['Mckomo']
10
+ spec.email = ['mckomo@gmail.com']
11
11
 
12
- spec.summary = %q{Introduce dynamic variables in the main scope}
13
- spec.homepage = "https://github.com/mckomo/metaxa"
14
- spec.license = "MIT"
12
+ spec.summary = 'Introduce dynamic variables in the main scope'
13
+ spec.homepage = 'https://github.com/mckomo/metaxa'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
16
+ spec.files = `git ls-files -z`
17
+ .split("\x0")
18
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+
20
+ spec.bindir = 'exe'
18
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
20
23
 
21
- spec.add_development_dependency "bundler", "~> 1.11"
22
- spec.add_development_dependency "httparty", "~> 0.14"
23
- spec.add_development_dependency "test-unit", "~> 3.2"
24
- spec.add_development_dependency "colorize", "~> 0.7"
25
- spec.add_development_dependency "pry", "~> 0.10"
26
- spec.add_development_dependency "activesupport", "~> 5.0"
24
+ spec.add_development_dependency 'bundler', '~> 1.11'
25
+ spec.add_development_dependency 'httparty', '~> 0.14'
26
+ spec.add_development_dependency 'test-unit', '~> 3.2'
27
+ spec.add_development_dependency 'colorize', '~> 0.7'
28
+ spec.add_development_dependency 'pry', '~> 0.10'
29
+ spec.add_development_dependency 'activesupport', '~> 5.0'
30
+ spec.add_development_dependency 'rubocop', '~> 0.41'
27
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaxa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mckomo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.41'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.41'
97
111
  description:
98
112
  email:
99
113
  - mckomo@gmail.com
@@ -103,6 +117,8 @@ extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
105
119
  - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".rubocop_todo.yml"
106
122
  - ".travis.yml"
107
123
  - CODE_OF_CONDUCT.md
108
124
  - Gemfile
@@ -112,6 +128,7 @@ files:
112
128
  - bin/setup
113
129
  - bin/test
114
130
  - examples/colors.rb
131
+ - examples/dynamic_structure.rb
115
132
  - lib/metaxa.rb
116
133
  - lib/metaxa/version.rb
117
134
  - metaxa.gemspec