Skip to content

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Jul 18, 2017
2 parents ba825a9 + cebe353 commit afa343a
Show file tree
Hide file tree
Showing 18 changed files with 583 additions and 185 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_name: travis-ci
coverage_clover: build/coverage-clover.xml
json_path: build/coveralls-upload.json
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

[*.php]
indent_style = space
indent_size = 4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendor/
/build/
/composer.lock
/phpunit.xml
44 changes: 33 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
sudo: false

notifications:
email: [email protected]
email: [email protected]

branches:
except:
- /^analysis-.*$/

matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.0
- php: 5.6
- php: 5.5
- php: 5.5
env: SYMFONY_VERSION=2.7.*
- php: 5.5
env: SYMFONY_VERSION=2.8.*
- php: 5.5
env: SYMFONY_VERSION=3.0.*
- php: hhvm
sudo: required
dist: trusty
group: edge

before_install:
- if [ "$TRAVIS_PHP_VERSION" = "hhvm" ]; then echo 'xdebug.enable = on' >> /etc/hhvm/php.ini; fi
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;

before_script:
- composer self-update
- composer install --dev
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --dev --no-update; fi;
- composer install --prefer-dist --no-interaction --no-scripts --no-progress

script:
- phpunit --verbose --coverage-clover=coverage.clover
- vendor/bin/phpunit --coverage-clover build/coverage-clover.xml

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- vendor/bin/ocular code-coverage:upload --format=php-clover build/coverage-clover.xml
- vendor/bin/coveralls -v -c .coveralls.yml
103 changes: 88 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,90 @@
<img src="http://anime-db.org/bundles/animedboffsite/images/shikimori.org.png" /><br />

[![Latest Stable Version](https://poser.pugx.org/anime-db/shikimori-browser-bundle/v/stable.png)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)
[![Latest Unstable Version](https://poser.pugx.org/anime-db/shikimori-browser-bundle/v/unstable.png)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)
[![Total Downloads](https://poser.pugx.org/anime-db/shikimori-browser-bundle/downloads)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)
[![Build Status](https://travis-ci.org/anime-db/shikimori-browser-bundle.png)](https://travis-ci.org/anime-db/shikimori-browser-bundle)
[![Code Coverage](https://scrutinizer-ci.com/g/anime-db/shikimori-browser-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/anime-db/shikimori-browser-bundle/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/anime-db/shikimori-browser-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/anime-db/shikimori-browser-bundle/?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/fde73716-6558-46ff-b3a9-f2f989a59d0c/mini.png)](https://insight.sensiolabs.com/projects/fde73716-6558-46ff-b3a9-f2f989a59d0c)
[![StyleCI](https://styleci.io/repos/18437335/shield)](https://styleci.io/repos/18437335)
[![Dependency Status](https://www.versioneye.com/user/projects/5746f648ce8d0e004130cad7/badge.svg?style=flat)](https://www.versioneye.com/user/projects/5746f648ce8d0e004130cad7)
[![License](https://poser.pugx.org/anime-db/shikimori-browser-bundle/license.png)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)

shikimori-browser-bundle
========================
[![Shikimori](http://anime-db.org/bundles/animedboffsite/images/shikimori.org.png)](https://shikimori.org)

[![Latest Stable Version](https://img.shields.io/packagist/v/anime-db/shikimori-browser-bundle.svg?maxAge=3600&label=stable)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)
[![Total Downloads](https://img.shields.io/packagist/dt/anime-db/shikimori-browser-bundle.svg?maxAge=3600)](https://packagist.org/packages/anime-db/shikimori-browser-bundle)
[![Build Status](https://img.shields.io/travis/anime-db/shikimori-browser-bundle.svg?maxAge=3600)](https://travis-ci.org/anime-db/shikimori-browser-bundle)
[![Coverage Status](https://img.shields.io/coveralls/anime-db/shikimori-browser-bundle.svg?maxAge=3600)](https://coveralls.io/github/anime-db/shikimori-browser-bundle?branch=master)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/anime-db/shikimori-browser-bundle.svg?maxAge=3600)](https://scrutinizer-ci.com/g/anime-db/shikimori-browser-bundle/?branch=master)
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/fde73716-6558-46ff-b3a9-f2f989a59d0c.svg?maxAge=3600&label=SLInsight)](https://insight.sensiolabs.com/projects/fde73716-6558-46ff-b3a9-f2f989a59d0c)
[![StyleCI](https://styleci.io/repos/18437335/shield?branch=master)](https://styleci.io/repos/18437335)
[![License](https://img.shields.io/packagist/l/anime-db/shikimori-browser-bundle.svg?maxAge=3600)](https://github.com/anime-db/shikimori-browser-bundle)

Shikimori.org API browser
=========================

Read API documentation here: http://shikimori.org/api/doc

Installation
------------

Pretty simple with [Composer](http://packagist.org), run:

```sh
composer anime-db/shikimori-browser-bundle
```

Configuration
-------------

```yml
anime_db_shikimori_browser:
# API host
# As a default used 'https://shikimori.org'
host: 'https://shikimori.org'

# Prefix for API resurces
# As a default used '/api/'
prefix: '/api/'
```
Usage
-----
First get browser
```php
$browser = $this->get('anime_db.shikimori.browser');
```

List animes ([docs](https://shikimori.org/api/doc/1.0/animes/index))

```php
$animes = $browser->get('animes', ['limit' => 10]);
```

Mark all messages as read ([docs](https://shikimori.org/api/doc/1.0/messages/read_all))

```php
$response = $browser->post('messages/read_all');
```

Update a message ([docs](https://shikimori.org/api/doc/1.0/messages/update))

```php
$response = $browser->patch('messages/12', [
"message" => [
"body": "blablabla",
],
]);
```

Update a comment ([docs](https://shikimori.org/api/doc/1.0/comments/update))

```php
$response = $browser->put('comments/8', [
"message" => [
"body": "blablabla",
],
]);
```

Destroy a message ([docs](https://shikimori.org/api/doc/1.0/messages/destroy))

```php
$browser->delete('messages/12');
```

License
-------

This bundle is under the [MIT license](http://opensource.org/licenses/MIT). See the complete license in the file: LICENSE
58 changes: 33 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
{
"name" : "anime-db/shikimori-browser-bundle",
"license" : "GPL-3.0",
"type" : "library",
"description" : "Plugin Shikimori for the catalog Anime DB",
"homepage" : "http://github.com/anime-db/shikimori-browser-bundle",
"autoload" : {
"psr-4" : {
"AnimeDb\\Bundle\\ShikimoriBrowserBundle\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"AnimeDb\\Bundle\\ShikimoriBrowserBundle\\Tests\\" : "tests/"
}
},
"require" : {
"php" : ">=5.3.3",
"guzzle/guzzle" : "3.9.*"
},
"require-dev" : {
"symfony/dependency-injection" : ">=2.3.17",
"symfony/expression-language" : ">=2.3.17",
"symfony/config" : ">=2.3.17",
"symfony/http-kernel" : ">=2.3.17"
}
"name": "anime-db/shikimori-browser-bundle",
"license": "GPL-3.0",
"type": "library",
"description": "Plugin Shikimori for the catalog Anime DB",
"homepage": "http://github.com/anime-db/shikimori-browser-bundle",
"autoload": {
"psr-4": {
"AnimeDb\\Bundle\\ShikimoriBrowserBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AnimeDb\\Bundle\\ShikimoriBrowserBundle\\Tests\\": "tests/"
}
},
"require": {
"php": ">=5.5",
"guzzlehttp/guzzle" : "~6.3"
},
"require-dev": {
"symfony/dependency-injection": "~2.7|~3.0",
"symfony/expression-language": "~2.7|~3.0",
"symfony/config": "~2.7|~3.0",
"symfony/http-kernel": "~2.7|~3.0",
"phpunit/phpunit": "~4.8",
"scrutinizer/ocular": "~1.3",
"satooshi/php-coveralls": "^1.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions src/AnimeDbShikimoriBrowserBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* AnimeDb package.
*
Expand Down
12 changes: 10 additions & 2 deletions src/DependencyInjection/AnimeDbShikimoriBrowserExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* AnimeDb package.
*
Expand All @@ -17,13 +18,20 @@
class AnimeDbShikimoriBrowserExtension extends Extension
{
/**
* @param array $configs
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('parameters.yml');
$loader->load('services.yml');

$config = $this->processConfiguration(new Configuration(), $configs);

$container
->getDefinition('anime_db.shikimori.browser')
->replaceArgument(1, $config['host'])
->replaceArgument(2, $config['prefix'])
;
}
}
46 changes: 46 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* AnimeDb package.
*
* @author Peter Gribanov <[email protected]>
* @copyright Copyright (c) 2011, Peter Gribanov
* @license http://opensource.org/licenses/GPL-3.0 GPL v3
*/

namespace AnimeDb\Bundle\ShikimoriBrowserBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
{
/**
* Config tree builder.
*
* Example config:
*
* anime_db_shikimori_browser:
* host: 'https://shikimori.org'
* prefix: '/api/'
*
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
{
return (new TreeBuilder())
->root('anime_db_shikimori_browser')
->children()
->scalarNode('host')
->cannotBeEmpty()
->defaultValue('https://shikimori.org')
->end()
->scalarNode('prefix')
->cannotBeEmpty()
->defaultValue('/api/')
->end()
->end()
->end()
;
}
}
4 changes: 0 additions & 4 deletions src/Resources/config/parameters.yml

This file was deleted.

8 changes: 2 additions & 6 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
services:
anime_db.shikimori.browser:
class: AnimeDb\Bundle\ShikimoriBrowserBundle\Service\Browser
arguments:
- '@anime_db.shikimori.browser.client'
- '%anime_db.shikimori.host%'
- '%anime_db.shikimori.api.prefix%'
arguments: [ '@anime_db.shikimori.browser.client', ~, ~ ]

anime_db.shikimori.browser.client:
class: Guzzle\Http\Client
arguments: [ '%anime_db.shikimori.api.host%' ]
class: GuzzleHttp\Client
public: false
Loading

0 comments on commit afa343a

Please sign in to comment.