wordpress_theme_finder 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d864c85c3efc54d607ed8191470e6c0c1718769c
4
+ data.tar.gz: 5a944a9c908485d65f71ffdfb22f0a0f681b46b3
5
+ SHA512:
6
+ metadata.gz: 14ca2b05457efa1736492011fa5a94d012a9e8109e79d9af844032c9fdc70624f57ee864f5f8caef5bcd4124e3d01135d90f888930d3c37c490840a9302d4b27
7
+ data.tar.gz: 461a0e818814307228a0374f3cf93bab8e66e3b96a12a06403e2bf63b64058c0e6eee0c41d65fc1076639528cbc59c28b42b826c61a869891c372cba03777166
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ wordpress_theme_finder
2
+ ===================
3
+
4
+ Gem to check if a website is built with wordpress and get theme informations.
5
+
6
+ ## Requirements
7
+
8
+ * Ruby 1.9+
9
+
10
+ ## Installation
11
+
12
+ Add it to your Gemfile:
13
+
14
+ `gem 'wordpress_theme_finder'`
15
+
16
+ Then:
17
+
18
+ `bundle`
19
+
20
+ ## Usage
21
+
22
+ Call check function of WordpressThemeFinder, param is url.
23
+
24
+ ```ruby
25
+ result = WordpressThemeFinder.check(site_url)
26
+ ```
27
+
28
+ If result is null website is not built with wordpress.
29
+
30
+ If not null result contains a hash with one ore more of the following keys:
31
+ * Theme Name
32
+ * Theme URI
33
+ * Author
34
+ * Author URI
35
+ * Description
36
+ * Version
37
+ * License
38
+ * License URI
39
+ * Tags
40
+ * Text Domain
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( http://github.com/MirkoMignini/wordpress_theme_finder/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
49
+
50
+ ## License
51
+
52
+ MIT License. Copyright 2015 by Mirko Mignini (https://github.com/MirkoMignini)
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'WordpressCheck'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,28 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module WordpressThemeFinder
5
+
6
+ def self.check(url)
7
+ doc = Nokogiri::HTML(open(url))
8
+ style_css = doc.xpath("//link[@rel='stylesheet' and contains(@href, 'style.css')]/@href").first
9
+
10
+ return nil if style_css.nil?
11
+
12
+ values = Hash.new
13
+
14
+ source = open(style_css){|f|f.read}
15
+ source.each_line do |line|
16
+ ['Theme Name', 'Theme URI', 'Author', 'Author URI', 'Description', 'Version', 'License', 'License URI', 'Tags', 'Text Domain'].each do |key|
17
+ values[key] = line.gsub("#{key}:", '').strip if line.match("#{key}:") && values[key].nil?
18
+ end
19
+ end
20
+
21
+ if values.has_key?('Tags')
22
+ values['Tags'] = values['Tags'].split(',').map!(&:strip)
23
+ end
24
+
25
+ values
26
+ end
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module WordpressThemeFinder
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/wordpress_theme_finder'
3
+
4
+ class TestAll < Minitest::Test
5
+ def test_not_wordpress_site
6
+ result = WordpressThemeFinder.check('http://www.google.com')
7
+ assert_nil result
8
+ end
9
+
10
+ def test_wordpress_site
11
+ result = WordpressThemeFinder.check('https://wp-themes.com/twentyfifteen/')
12
+ assert_kind_of Hash, result
13
+
14
+ assert_equal 'Twenty Fifteen', result['Theme Name']
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wordpress_theme_finder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mirko Mignini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
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
+ description: Gem to check if a site is built with wordpress and get theme informations.
42
+ email:
43
+ - mirko.mignini@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/wordpress_theme_finder.rb
52
+ - lib/wordpress_theme_finder/version.rb
53
+ - test/wordpress_theme_finder.rb
54
+ homepage: https://github.com/MirkoMignini/wordpress_theme_finder
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.6
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Gem to check if a site is built with wordpress and get theme informations.
78
+ test_files:
79
+ - test/wordpress_theme_finder.rb