badgify 0.0.4
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 +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/badgify.gemspec +24 -0
- data/config/badgify_config.yml +4 -0
- data/lib/badgify.rb +16 -0
- data/lib/badgify/badge.rb +2 -0
- data/lib/badgify/version.rb +3 -0
- data/lib/generators/badgify/badgify_generator.rb +17 -0
- data/lib/generators/badgify/templates/badgify_config.yml +4 -0
- data/lib/generators/badgify/templates/migrations/create_badges_table.rb +9 -0
- data/spec/badgify_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/rspec.rake +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b895a2468279893afbda5dcd034846022d258561
|
4
|
+
data.tar.gz: 2f904960dea85ede8f261d24a91d7bb6d2177398
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e8fc005fbd7734cd9e05cd84b7f5cf7c0cbb2d31590d325746cd3d3ab72d009d0ad15686029a67b8f9413972014b83541476e0f5718f14fb561d4c6d51cfc69
|
7
|
+
data.tar.gz: 4b7f21d599cd86dc52f3447c64edc2054a75c9fb38393376bd0572033a09dc6321669915c7867cee7ae9ca9aa491517a6e7806982dc95d84d47723284927bd6c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Luis Saffie
|
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,49 @@
|
|
1
|
+
# Badgify
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'badgify', git: 'git@github.com:homestars/badgify.git'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Create configuration file
|
18
|
+
|
19
|
+
$ bundle exec rails g badgify badge
|
20
|
+
|
21
|
+
This will create a config/badgify_config.yml
|
22
|
+
|
23
|
+
Edit that file as you see fit. The format is
|
24
|
+
|
25
|
+
number: string_representation
|
26
|
+
|
27
|
+
(see example in file)
|
28
|
+
|
29
|
+
USAGE:
|
30
|
+
|
31
|
+
Badgify.new(approved_reviews).badge
|
32
|
+
|
33
|
+
That will return the string representation defined in the yml config file
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install badgify
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
TODO: Write usage instructions here
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/badgify/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/badgify.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'badgify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "badgify"
|
8
|
+
spec.version = Badgify::VERSION
|
9
|
+
spec.authors = ["Luis Saffie"]
|
10
|
+
spec.email = ["luis@homestars.com"]
|
11
|
+
spec.summary = %q{Manages roles for users}
|
12
|
+
spec.description = %q{Provides a way to configure and query system for roles}
|
13
|
+
spec.homepage = ""
|
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_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
data/lib/badgify.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "badgify/version"
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class Badgify
|
5
|
+
|
6
|
+
CONFIG = YAML.load_file('config/badgify_config.yml') rescue {}
|
7
|
+
|
8
|
+
def initialize(key)
|
9
|
+
@key = key
|
10
|
+
end
|
11
|
+
|
12
|
+
def badge
|
13
|
+
min_key = CONFIG.keys.detect {|x| x.include?(@key)}
|
14
|
+
CONFIG[min_key].to_s
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
class BadgifyGenerator < ActiveRecord::Generators::Base
|
4
|
+
desc "Generates the necessary migrations"
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.expand_path('../templates', __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_migration
|
11
|
+
#migration_template "migrations/create_badges_table.rb", "db/migrate/create_badges_table.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_initializer_file
|
15
|
+
copy_file "badgify_config.yml", "config/badgify_config.yml"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Badgify do
|
4
|
+
|
5
|
+
describe "badge" do
|
6
|
+
it 'returns a basic role' do
|
7
|
+
badge_service= Badgify.new(1)
|
8
|
+
expect(badge_service.badge).to eq("")
|
9
|
+
end
|
10
|
+
it 'returns a basic role' do
|
11
|
+
badge_service = Badgify.new(2)
|
12
|
+
expect(badge_service.badge).to eq("")
|
13
|
+
end
|
14
|
+
it 'returns a basic role' do
|
15
|
+
badge_service = Badgify.new(3)
|
16
|
+
expect(badge_service.badge).to eq("basic")
|
17
|
+
end
|
18
|
+
it 'returns a basic role' do
|
19
|
+
badge_service = Badgify.new(4)
|
20
|
+
expect(badge_service.badge).to eq("basic")
|
21
|
+
end
|
22
|
+
it 'returns a basic role' do
|
23
|
+
badge_service = Badgify.new(5)
|
24
|
+
expect(badge_service.badge).to eq("basic")
|
25
|
+
end
|
26
|
+
it 'returns a gold role' do
|
27
|
+
badge_service = Badgify.new(6)
|
28
|
+
expect(badge_service.badge).to eq("gold")
|
29
|
+
end
|
30
|
+
it 'returns a gold role' do
|
31
|
+
badge_service = Badgify.new(7)
|
32
|
+
expect(badge_service.badge).to eq("gold")
|
33
|
+
end
|
34
|
+
it 'returns a gold role' do
|
35
|
+
badge_service = Badgify.new(8)
|
36
|
+
expect(badge_service.badge).to eq("gold")
|
37
|
+
end
|
38
|
+
it 'returns a gold role' do
|
39
|
+
badge_service = Badgify.new(9)
|
40
|
+
expect(badge_service.badge).to eq("gold")
|
41
|
+
end
|
42
|
+
it 'returns a gold role' do
|
43
|
+
badge_service = Badgify.new(10)
|
44
|
+
expect(badge_service.badge).to eq("premium")
|
45
|
+
end
|
46
|
+
it 'returns a platium role' do
|
47
|
+
badge_service = Badgify.new(25)
|
48
|
+
expect(badge_service.badge).to eq("platium")
|
49
|
+
end
|
50
|
+
it 'returns a platium role' do
|
51
|
+
badge_service = Badgify.new(100)
|
52
|
+
expect(badge_service.badge).to eq("platium")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'badgify'
|
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: badgify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luis Saffie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-28 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Provides a way to configure and query system for roles
|
56
|
+
email:
|
57
|
+
- luis@homestars.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- badgify.gemspec
|
68
|
+
- config/badgify_config.yml
|
69
|
+
- lib/badgify.rb
|
70
|
+
- lib/badgify/badge.rb
|
71
|
+
- lib/badgify/version.rb
|
72
|
+
- lib/generators/badgify/badgify_generator.rb
|
73
|
+
- lib/generators/badgify/templates/badgify_config.yml
|
74
|
+
- lib/generators/badgify/templates/migrations/create_badges_table.rb
|
75
|
+
- spec/badgify_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- tasks/rspec.rake
|
78
|
+
homepage: ''
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.0.3
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Manages roles for users
|
102
|
+
test_files:
|
103
|
+
- spec/badgify_spec.rb
|
104
|
+
- spec/spec_helper.rb
|