metaxa 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbb8b2aa707af59b6d69c406173a0e29cdb982ad
4
+ data.tar.gz: f81cf1c9acf4d500149c9e199dbfa5b063f58777
5
+ SHA512:
6
+ metadata.gz: a9e971830fd26cea9f0fd53804ce8baddd6b59c6a72f309c908fdef773e6fb079c47ac7baf218450cccad6cb41b0b69edca3d47b7a274f2eb945fb9903ac7924
7
+ data.tar.gz: 9034e1fe96f8bba995950c9e2906c9c2df1d02c8b19a8bf3725032a834dd45e68a2381c2a098c981067cfcb913eaef94f731dd710658f720577c7d2fb5bb3236
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.3.1
5
+ script: bin/test
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at mckomo@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in metaxa.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Mckomo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Metaxa
2
+
3
+ [![Build Status](https://travis-ci.org/mckomo/metaxa.svg?branch=master)](https://travis-ci.org/mckomo/metaxa)
4
+
5
+ Metaxa enables you to dynamically define variables in the main scope (main:Object).
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ require 'metaxa'
11
+
12
+ include Metaxa
13
+
14
+ introduce :foo, with_value: 'foo'
15
+
16
+ puts foo == 'foo' # true
17
+ puts foo === get(:foo) # true
18
+
19
+ set :foo, 'foobar'
20
+
21
+ puts foo == 'foobar' # true
22
+ puts foo === get(:foo) # true
23
+
24
+ self.foo = 'foobarbaz' # foo = ... will introduce new overlying variable
25
+
26
+ puts foo == 'foobarbaz' # true
27
+ puts foo === get(:foo) # true
28
+ ```
29
+
30
+ See more constructive examples in `examples` dir :thumbsup:.
31
+
32
+ ## Installation
33
+
34
+ Add this line to your application's Gemfile:
35
+
36
+ ```ruby
37
+ gem 'metaxa'
38
+ ```
39
+
40
+ And then execute:
41
+
42
+ $ bundle
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install metaxa
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests.
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mckomo/metaxa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
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
13
+
14
+ include Metaxa
15
+
16
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/test ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ ruby 'test/metaxa_test.rb'
@@ -0,0 +1,64 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'bundler/setup'
4
+ require 'active_support/inflector'
5
+ require 'httparty'
6
+ require 'pry'
7
+ require 'metaxa'
8
+ require 'json'
9
+
10
+ include Metaxa
11
+
12
+ colors = HTTParty.get('http://www.colourlovers.com/api/colors?format=json&numResults=30').tap do |res|
13
+ JSON.parse(res.body)
14
+ end
15
+
16
+ colors.each do |c|
17
+ c['name'] = c['title'].parameterize.underscore
18
+ introduce c['name'], with_value: c['rgb']
19
+ end
20
+
21
+ introduce :colors, with_value: colors.map { |c| c['name'].to_sym }
22
+
23
+ Pry.start
24
+
25
+ # Usage:
26
+ #
27
+ # [1] pry(main)> red
28
+ # => {"red"=>255, "green"=>0, "blue"=>0}
29
+ # [2] pry(main)> aglet
30
+ # => {"red"=>240, "green"=>240, "blue"=>216}
31
+ # [3] pry(main)> black_tulip
32
+ # => {"red"=>66, "green"=>9, "blue"=>67}
33
+ # [4] pry(main)> colors
34
+ # => [:black,
35
+ # :white,
36
+ # :dutch_teal,
37
+ # :serenity_is,
38
+ # :heart_of_gold,
39
+ # :hot_pink,
40
+ # :mighty_slate,
41
+ # :haunted_milk,
42
+ # :vanilla_cream,
43
+ # :certain_frogs,
44
+ # :red,
45
+ # :grr_ey,
46
+ # :vitamin_c,
47
+ # :sugar_hearts_you,
48
+ # :bloons,
49
+ # :sex_on_the_floor,
50
+ # :orange_icing,
51
+ # :aglet,
52
+ # :darth_gray,
53
+ # :strawberry_lipgloss,
54
+ # :raspberry_lemonade,
55
+ # :minted_peas,
56
+ # :barbie_world,
57
+ # :chartreuse,
58
+ # :christmas_blue,
59
+ # :love_like_a_man,
60
+ # :millennial_blue,
61
+ # :lickable_lips,
62
+ # :alice_in_freezeland,
63
+ # :black_tulip]
64
+ # [5] pry(main)>
@@ -0,0 +1,3 @@
1
+ module Metaxa
2
+ VERSION = [0, 1, 0].join('.')
3
+ end
data/lib/metaxa.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'metaxa/version'
2
+
3
+ module Metaxa
4
+
5
+ def introduce(variable, with_value: true)
6
+ var_module = Module.new do
7
+ attr_accessor variable.to_sym
8
+ end
9
+
10
+ include var_module
11
+
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
22
+
23
+ end
data/metaxa.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'metaxa/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "metaxa"
8
+ spec.version = Metaxa::VERSION
9
+ spec.authors = ["Mckomo"]
10
+ spec.email = ["mckomo@gmail.com"]
11
+
12
+ spec.summary = %q{Introduce dynamic variables in the main scope}
13
+ spec.homepage = "https://github.com/mckomo/metaxa"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
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"
27
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metaxa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mckomo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ description:
98
+ email:
99
+ - mckomo@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - bin/console
112
+ - bin/setup
113
+ - bin/test
114
+ - examples/colors.rb
115
+ - lib/metaxa.rb
116
+ - lib/metaxa/version.rb
117
+ - metaxa.gemspec
118
+ homepage: https://github.com/mckomo/metaxa
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Introduce dynamic variables in the main scope
142
+ test_files: []