amcss 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Guardfile +39 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +7 -0
- data/amcss.gemspec +26 -0
- data/lib/amcss.rb +27 -0
- data/lib/amcss/concepts.rb +2 -0
- data/lib/amcss/concepts/module.rb +9 -0
- data/lib/amcss/concepts/trait.rb +9 -0
- data/lib/amcss/concepts/variation.rb +9 -0
- data/lib/amcss/configuration.rb +9 -0
- data/lib/amcss/css.rb +2 -0
- data/lib/amcss/css/selector.rb +23 -0
- data/lib/amcss/html.rb +2 -0
- data/lib/amcss/html/attribute.rb +28 -0
- data/lib/amcss/version.rb +3 -0
- data/spec/amcss_spec.rb +7 -0
- data/spec/lib/amcss/configuration_spec.rb +11 -0
- data/spec/lib/amcss/css/selector_spec.rb +37 -0
- data/spec/lib/amcss/html/attribute_spec.rb +38 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/rspec.rake +3 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cde4f1718730893ea2e6f333bf71028fbf04b1b3
|
4
|
+
data.tar.gz: b9906f38f6c5154f3f51c6fccfb8168bdbfb33f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f75f0acef59e02de8222cab03de3b30e88ccefb298644e9b144f900e3839d1963d2ce31cd44f4197cfd03d11129bc7b17300041a2610ec6bb07aeb30a4b1886
|
7
|
+
data.tar.gz: 9c6962bc0cfcb872a8c67028773c0f04281c22ab6f0b71fa5a2466d18064e1500cc8a4864870505510b324d461c9401c6d199e1d08b9de26b06c185c9ea2a155
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec feature)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), the you will want to move the Guardfile
|
18
|
+
## to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
36
|
+
watch(%r{^spec/.+_spec\.rb$})
|
37
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
38
|
+
watch('spec/spec_helper.rb') { "spec" }
|
39
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Silvano Stralla
|
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,45 @@
|
|
1
|
+
# AMCSS
|
2
|
+
|
3
|
+
[AMCSS](http://amcss.github.io/) in Ruby.
|
4
|
+
|
5
|
+
## Why AMCSS?
|
6
|
+
|
7
|
+
Nowadays it seems like "to do everything using classes" is the mantra for most CSS development.
|
8
|
+
Why can't we use different approaches? AMCSS uses custom, namespaced attributes and mostly unknown
|
9
|
+
CSS selector to apply style to the page.
|
10
|
+
|
11
|
+
Take a deep breath and [have a look at the documentation](http://amcss.github.io/), 'cause it worths
|
12
|
+
a moment of you developer time.
|
13
|
+
|
14
|
+
## Install
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'amcss'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ gem install amcss
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
AMCSS is designed as a foundation for other libraries, specifically
|
37
|
+
developed for different environments.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/sistrall/amcss/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/amcss.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 'amcss/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "amcss"
|
8
|
+
spec.version = Amcss::VERSION
|
9
|
+
spec.authors = ["Silvano Stralla"]
|
10
|
+
spec.email = ["silvano.stralla@sistrall.it"]
|
11
|
+
spec.summary = %q{Attribute Modules for CSS (AMCSS) in Ruby}
|
12
|
+
spec.description = %q{"Attribute Modules (AM) is a technique for using HTML attributes and their values rather than classes for styling elements."}
|
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
|
+
spec.add_development_dependency 'guard'
|
25
|
+
spec.add_development_dependency 'guard-rspec'
|
26
|
+
end
|
data/lib/amcss.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "amcss/version"
|
2
|
+
require "amcss/configuration"
|
3
|
+
|
4
|
+
require "amcss/concepts"
|
5
|
+
require "amcss/concepts/module"
|
6
|
+
require "amcss/concepts/trait"
|
7
|
+
require "amcss/concepts/variation"
|
8
|
+
|
9
|
+
require "amcss/html"
|
10
|
+
require "amcss/html/attribute"
|
11
|
+
|
12
|
+
require "amcss/css"
|
13
|
+
require "amcss/css/selector"
|
14
|
+
|
15
|
+
module Amcss
|
16
|
+
def self.configure
|
17
|
+
yield(configuration)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configuration
|
21
|
+
@configuration ||= Configuration.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset
|
25
|
+
@configuration = Configuration.new
|
26
|
+
end
|
27
|
+
end
|
data/lib/amcss/css.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Amcss::Css
|
2
|
+
class Selector
|
3
|
+
attr_reader :value
|
4
|
+
alias_method :to_s, :value
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def from(modüle, variation_or_trait = nil)
|
8
|
+
new(variation_or_trait ?
|
9
|
+
%Q{[#{namespace}-#{modüle}~="#{variation_or_trait}"]} :
|
10
|
+
%Q{[#{namespace}-#{modüle}]})
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def namespace
|
15
|
+
[Amcss.configuration.prefix, "am"].compact.join('-')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(value)
|
20
|
+
@value = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/amcss/html.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Amcss::Html
|
2
|
+
class Attribute
|
3
|
+
attr_reader :name, :value
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def from(modüle, *variations_or_traits)
|
7
|
+
new("#{namespace}-#{modüle}", variations_or_traits.compact.map(&:to_s).join(' '))
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def namespace
|
12
|
+
[Amcss.configuration.prefix, "am"].compact.join('-')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(name, value)
|
17
|
+
@name, @value = name, value
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash
|
21
|
+
{name => value}
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
%Q{#{name}="#{value}"}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/amcss_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Amcss::Css::Selector do
|
4
|
+
describe '.from' do
|
5
|
+
context 'with variation or trait' do
|
6
|
+
subject { Amcss::Css::Selector.from('Calendar', 'big') }
|
7
|
+
|
8
|
+
it 'has the correct value' do
|
9
|
+
expect(subject.value).to eq('[am-Calendar~="big"]')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'without variation or trait' do
|
14
|
+
subject { Amcss::Css::Selector.from('Calendar') }
|
15
|
+
|
16
|
+
it 'has the correct value' do
|
17
|
+
expect(subject.value).to eq('[am-Calendar]')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#new' do
|
23
|
+
subject { Amcss::Css::Selector }
|
24
|
+
|
25
|
+
it 'prepare an Amcss::Css::Selector' do
|
26
|
+
expect(subject.new('*')).to be_an(Amcss::Css::Selector)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#to_s' do
|
31
|
+
subject { Amcss::Css::Selector.new('html > body') }
|
32
|
+
|
33
|
+
it 'returns a suitable HTML attribute' do
|
34
|
+
expect(subject.to_s).to eq 'html > body'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Amcss::Html::Attribute do
|
4
|
+
subject { Amcss::Html::Attribute.new('am-BlockName', 'deep') }
|
5
|
+
|
6
|
+
describe '.from' do
|
7
|
+
subject { Amcss::Html::Attribute.from('Calendar', 'big', 'rounded') }
|
8
|
+
|
9
|
+
it 'prepare an Amcss::Html::Attribute from a module and a list of traits' do
|
10
|
+
expect(subject).to be_an(Amcss::Html::Attribute)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has the correct name and value' do
|
14
|
+
expect(subject.name).to eq('am-Calendar')
|
15
|
+
expect(subject.value).to eq('big rounded')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#new' do
|
20
|
+
subject { Amcss::Html::Attribute }
|
21
|
+
|
22
|
+
it 'prepare an Amcss::Html::Attribute' do
|
23
|
+
expect(subject.new('am-Module', 'big')).to be_an(Amcss::Html::Attribute)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#to_hash' do
|
28
|
+
it 'returns an hash ready to be merge to some view helper option' do
|
29
|
+
expect(subject.to_hash).to eq({"am-BlockName" => 'deep'})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#to_s' do
|
34
|
+
it 'returns a suitable HTML attribute' do
|
35
|
+
expect(subject.to_s).to eq 'am-BlockName="deep"'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amcss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Silvano Stralla
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-17 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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
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: guard-rspec
|
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: '"Attribute Modules (AM) is a technique for using HTML attributes and
|
84
|
+
their values rather than classes for styling elements."'
|
85
|
+
email:
|
86
|
+
- silvano.stralla@sistrall.it
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- Guardfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- amcss.gemspec
|
100
|
+
- lib/amcss.rb
|
101
|
+
- lib/amcss/concepts.rb
|
102
|
+
- lib/amcss/concepts/module.rb
|
103
|
+
- lib/amcss/concepts/trait.rb
|
104
|
+
- lib/amcss/concepts/variation.rb
|
105
|
+
- lib/amcss/configuration.rb
|
106
|
+
- lib/amcss/css.rb
|
107
|
+
- lib/amcss/css/selector.rb
|
108
|
+
- lib/amcss/html.rb
|
109
|
+
- lib/amcss/html/attribute.rb
|
110
|
+
- lib/amcss/version.rb
|
111
|
+
- spec/amcss_spec.rb
|
112
|
+
- spec/lib/amcss/configuration_spec.rb
|
113
|
+
- spec/lib/amcss/css/selector_spec.rb
|
114
|
+
- spec/lib/amcss/html/attribute_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- tasks/rspec.rake
|
117
|
+
homepage: ''
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.2.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Attribute Modules for CSS (AMCSS) in Ruby
|
141
|
+
test_files:
|
142
|
+
- spec/amcss_spec.rb
|
143
|
+
- spec/lib/amcss/configuration_spec.rb
|
144
|
+
- spec/lib/amcss/css/selector_spec.rb
|
145
|
+
- spec/lib/amcss/html/attribute_spec.rb
|
146
|
+
- spec/spec_helper.rb
|