micro_flip 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 +7 -0
- data/.gitignore +19 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/bin/flip +15 -0
- data/lib/micro_flip.rb +58 -0
- data/lib/micro_flip/version.rb +3 -0
- data/micro_flip.gemspec +26 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab7146b210ce138a88d65e809cf138e0f5e1cd2b
|
4
|
+
data.tar.gz: 46bcc61e822b2ceff71c09fe676bde6f729a2c72
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 209152a27ed65c80360223c1e532a31df5df4694ed40d5ea7c77f4ebccefb03cda3f251653f6b8397f3a10617b4c21b54037c5487081df2a0a1855d2180a40ce
|
7
|
+
data.tar.gz: 7b1a5795cb06ddeecade1c5ff7a056d2333f3f8e72dacc9091bed8f54756aef11f64d23aebeb03f574c01608949a59748bd857794e213176a49b65419a2ad2ae
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Zander Hill
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# MicroFlip
|
2
|
+
|
3
|
+
Putting the µ back into micro feature flippers. Add it to random scripts and flip it.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'micro_flip'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install micro_flip
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Convenient version:
|
22
|
+
```
|
23
|
+
require 'micro_flip'
|
24
|
+
|
25
|
+
MicroFlip.setup
|
26
|
+
|
27
|
+
# Inside code where you want the flipping
|
28
|
+
puts "Ponies" if $flip.true?('pony_feature')
|
29
|
+
```
|
30
|
+
|
31
|
+
```
|
32
|
+
# Meanwhile in pry session, external script
|
33
|
+
$flip.set({'pony_feature' => 'true'})
|
34
|
+
```
|
35
|
+
|
36
|
+
Alternately, there's `bin/flip` to use from commandline:
|
37
|
+
`bundle exec flip pony_feature=true`
|
38
|
+
|
39
|
+
Or
|
40
|
+
`bundle exec bin/flip pony_feature=true pony_powerup='hot cocoa'`
|
41
|
+
If it's in your gems rather than bundle gemset
|
42
|
+
`flip pony_feature=1`
|
43
|
+
|
44
|
+
For the non-global variable implementation, see how it's done in
|
45
|
+
`bin/flip`.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it ( http://github.com/zph/micro_flip/fork )
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/flip
ADDED
data/lib/micro_flip.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'moneta'
|
4
|
+
require 'sqlite3'
|
5
|
+
|
6
|
+
module MicroFlip
|
7
|
+
def self.setup(filename = '.micro_flip.db')
|
8
|
+
DB.create(filename)
|
9
|
+
end
|
10
|
+
|
11
|
+
class DB
|
12
|
+
attr_accessor :db, :filename
|
13
|
+
def initialize(filename = '.micro_flip.db')
|
14
|
+
@filename = filename
|
15
|
+
@db = Moneta.build do
|
16
|
+
adapter :Sqlite, file: filename
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create(filename = '.micro_flip.db')
|
21
|
+
$flip = new(filename)
|
22
|
+
end
|
23
|
+
|
24
|
+
def set(hash)
|
25
|
+
hash.each do |k,v|
|
26
|
+
db[k] = v
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def true?(key)
|
31
|
+
db[key] == true || 'true' || 't' || 1 || '1'
|
32
|
+
end
|
33
|
+
|
34
|
+
def false?(key)
|
35
|
+
db[key] == false || 'false' || 'f' || 0 || '0'
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
File.rm_f filename
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module CLI
|
44
|
+
def self.parse_args(argv)
|
45
|
+
args = argv.dup
|
46
|
+
#TODO handle case where we get default= and set the 2nd bit to empty string
|
47
|
+
#TODO maybe use optparser for this?
|
48
|
+
hashes = args.flat_map { |a| Hash[*a.split('=') ] }
|
49
|
+
hashes.reduce(&:merge)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.display_changes(hash, io = STDOUT)
|
53
|
+
hash.each do |key, value|
|
54
|
+
io.puts "Flip: #{key} set to #{value}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/micro_flip.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'micro_flip/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "micro_flip"
|
8
|
+
spec.version = MicroFlip::VERSION
|
9
|
+
spec.authors = ["Zander Hill"]
|
10
|
+
spec.email = ["Zander@civet.ws"]
|
11
|
+
spec.summary = %q{Feature flipping in < 50 lines of code (SLOC).}
|
12
|
+
spec.description = %q{Putting the µ back in micro flippers.}
|
13
|
+
spec.homepage = "http://github.com/zph/micro_flip"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "moneta"
|
22
|
+
spec.add_dependency "sqlite3"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micro_flip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zander Hill
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: moneta
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
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'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Putting the µ back in micro flippers.
|
84
|
+
email:
|
85
|
+
- Zander@civet.ws
|
86
|
+
executables:
|
87
|
+
- flip
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/flip
|
97
|
+
- lib/micro_flip.rb
|
98
|
+
- lib/micro_flip/version.rb
|
99
|
+
- micro_flip.gemspec
|
100
|
+
homepage: http://github.com/zph/micro_flip
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Feature flipping in < 50 lines of code (SLOC).
|
124
|
+
test_files: []
|